项目部署包

315.7612841b.js 610KB

12
  1. (self["webpackChunknouiroom"]=self["webpackChunknouiroom"]||[]).push([[315],{2799:function(e,t,i){i(560),i(5847),i(8858),i(1318),i(3228),i(4224),i(1121),i(7133),i(3429),function(t,i){e.exports=i()}(0,(function(){function e(e,t){return t.forEach((function(t){t&&"string"!=typeof t&&!Array.isArray(t)&&Object.keys(t).forEach((function(i){if("default"!==i&&!(i in e)){var n=Object.getOwnPropertyDescriptor(t,i);Object.defineProperty(e,i,n.get?n:{enumerable:!0,get:function(){return t[i]}})}}))})),Object.freeze(e)}var t="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof i.g?i.g:"undefined"!=typeof self?self:{},n=function(e){try{return!!e()}catch(t){return!0}},r=!n((function(){var e=function(){}.bind();return"function"!=typeof e||e.hasOwnProperty("prototype")})),o=r,s=Function.prototype,a=s.call,c=o&&s.bind.bind(a,a),l=o?c:function(e){return function(){return a.apply(e,arguments)}},d=l,u=d({}.toString),h=d("".slice),p=function(e){return h(u(e),8,-1)},m=n,_=p,f=Object,g=l("".split),T=m((function(){return!f("z").propertyIsEnumerable(0)}))?function(e){return"String"==_(e)?g(e,""):f(e)}:f,E=function(e){return null==e},S=E,I=TypeError,y=function(e){if(S(e))throw I("Can't call method on "+e);return e},v=T,A=y,R=function(e){return v(A(e))},C=function(e){return e&&e.Math==Math&&e},b=C("object"==typeof globalThis&&globalThis)||C("object"==typeof window&&window)||C("object"==typeof self&&self)||C("object"==typeof t&&t)||function(){return this}()||Function("return this")(),k={},N={get exports(){return k},set exports(e){k=e}},D=b,O=Object.defineProperty,w=function(e,t){try{O(D,e,{value:t,configurable:!0,writable:!0})}catch(n){D[e]=t}return t},P=w,L="__core-js_shared__",M=b[L]||P(L,{}),x=M;(N.exports=function(e,t){return x[e]||(x[e]=void 0!==t?t:{})})("versions",[]).push({version:"3.30.0",mode:"global",copyright:"© 2014-2023 Denis Pushkarev (zloirock.ru)",license:"https://github.com/zloirock/core-js/blob/v3.30.0/LICENSE",source:"https://github.com/zloirock/core-js"});var V,U,F=y,B=Object,H=function(e){return B(F(e))},j=H,G=l({}.hasOwnProperty),W=Object.hasOwn||function(e,t){return G(j(e),t)},J=l,z=0,K=Math.random(),q=J(1..toString),Y=function(e){return"Symbol("+(void 0===e?"":e)+")_"+q(++z+K,36)},Q="undefined"!=typeof navigator&&String(navigator.userAgent)||"",X=b,$=Q,Z=X.process,ee=X.Deno,te=Z&&Z.versions||ee&&ee.version,ie=te&&te.v8;ie&&(U=(V=ie.split("."))[0]>0&&V[0]<4?1:+(V[0]+V[1])),!U&&$&&(!(V=$.match(/Edge\/(\d+)/))||V[1]>=74)&&(V=$.match(/Chrome\/(\d+)/))&&(U=+V[1]);var ne=U,re=ne,oe=n,se=!!Object.getOwnPropertySymbols&&!oe((function(){var e=Symbol();return!String(e)||!(Object(e)instanceof Symbol)||!Symbol.sham&&re&&re<41})),ae=se&&!Symbol.sham&&"symbol"==typeof Symbol.iterator,ce=k,le=W,de=Y,ue=se,he=ae,pe=b.Symbol,me=ce("wks"),_e=he?pe.for||pe:pe&&pe.withoutSetter||de,fe=function(e){return le(me,e)||(me[e]=ue&&le(pe,e)?pe[e]:_e("Symbol."+e)),me[e]},ge="object"==typeof document&&document.all,Te={all:ge,IS_HTMLDDA:void 0===ge&&void 0!==ge},Ee=Te.all,Se=Te.IS_HTMLDDA?function(e){return"function"==typeof e||e===Ee}:function(e){return"function"==typeof e},Ie=Se,ye=Te.all,ve=Te.IS_HTMLDDA?function(e){return"object"==typeof e?null!==e:Ie(e)||e===ye}:function(e){return"object"==typeof e?null!==e:Ie(e)},Ae=ve,Re=String,Ce=TypeError,be=function(e){if(Ae(e))return e;throw Ce(Re(e)+" is not an object")},ke={},Ne=!n((function(){return 7!=Object.defineProperty({},1,{get:function(){return 7}})[1]})),De=Ne&&n((function(){return 42!=Object.defineProperty((function(){}),"prototype",{value:42,writable:!1}).prototype})),Oe={},we=ve,Pe=b.document,Le=we(Pe)&&we(Pe.createElement),Me=function(e){return Le?Pe.createElement(e):{}},xe=Me,Ve=!Ne&&!n((function(){return 7!=Object.defineProperty(xe("div"),"a",{get:function(){return 7}}).a})),Ue=r,Fe=Function.prototype.call,Be=Ue?Fe.bind(Fe):function(){return Fe.apply(Fe,arguments)},He=b,je=Se,Ge=function(e,t){return arguments.length<2?(i=He[e],je(i)?i:void 0):He[e]&&He[e][t];var i},We=l({}.isPrototypeOf),Je=Ge,ze=Se,Ke=We,qe=Object,Ye=ae?function(e){return"symbol"==typeof e}:function(e){var t=Je("Symbol");return ze(t)&&Ke(t.prototype,qe(e))},Qe=String,Xe=function(e){try{return Qe(e)}catch(t){return"Object"}},$e=Se,Ze=Xe,et=TypeError,tt=function(e){if($e(e))return e;throw et(Ze(e)+" is not a function")},it=tt,nt=E,rt=function(e,t){var i=e[t];return nt(i)?void 0:it(i)},ot=Be,st=Se,at=ve,ct=TypeError,lt=Be,dt=ve,ut=Ye,ht=rt,pt=function(e,t){var i,n;if("string"===t&&st(i=e.toString)&&!at(n=ot(i,e)))return n;if(st(i=e.valueOf)&&!at(n=ot(i,e)))return n;if("string"!==t&&st(i=e.toString)&&!at(n=ot(i,e)))return n;throw ct("Can't convert object to primitive value")},mt=TypeError,_t=fe("toPrimitive"),ft=function(e,t){if(!dt(e)||ut(e))return e;var i,n=ht(e,_t);if(n){if(void 0===t&&(t="default"),i=lt(n,e,t),!dt(i)||ut(i))return i;throw mt("Can't convert object to primitive value")}return void 0===t&&(t="number"),pt(e,t)},gt=ft,Tt=Ye,Et=function(e){var t=gt(e,"string");return Tt(t)?t:t+""},St=Ne,It=Ve,yt=De,vt=be,At=Et,Rt=TypeError,Ct=Object.defineProperty,bt=Object.getOwnPropertyDescriptor,kt="enumerable",Nt="configurable",Dt="writable";Oe.f=St?yt?function(e,t,i){if(vt(e),t=At(t),vt(i),"function"==typeof e&&"prototype"===t&&"value"in i&&Dt in i&&!i[Dt]){var n=bt(e,t);n&&n[Dt]&&(e[t]=i.value,i={configurable:Nt in i?i[Nt]:n[Nt],enumerable:kt in i?i[kt]:n[kt],writable:!1})}return Ct(e,t,i)}:Ct:function(e,t,i){if(vt(e),t=At(t),vt(i),It)try{return Ct(e,t,i)}catch(r){}if("get"in i||"set"in i)throw Rt("Accessors not supported");return"value"in i&&(e[t]=i.value),e};var Ot=Math.ceil,wt=Math.floor,Pt=Math.trunc||function(e){var t=+e;return(t>0?wt:Ot)(t)},Lt=Pt,Mt=function(e){var t=+e;return t!=t||0===t?0:Lt(t)},xt=Mt,Vt=Math.max,Ut=Math.min,Ft=function(e,t){var i=xt(e);return i<0?Vt(i+t,0):Ut(i,t)},Bt=Mt,Ht=Math.min,jt=function(e){return e>0?Ht(Bt(e),9007199254740991):0},Gt=jt,Wt=function(e){return Gt(e.length)},Jt=R,zt=Ft,Kt=Wt,qt=function(e){return function(t,i,n){var r,o=Jt(t),s=Kt(o),a=zt(n,s);if(e&&i!=i){for(;s>a;)if((r=o[a++])!=r)return!0}else for(;s>a;a++)if((e||a in o)&&o[a]===i)return e||a||0;return!e&&-1}},Yt={includes:qt(!0),indexOf:qt(!1)},Qt={},Xt=W,$t=R,Zt=Yt.indexOf,ei=Qt,ti=l([].push),ii=function(e,t){var i,n=$t(e),r=0,o=[];for(i in n)!Xt(ei,i)&&Xt(n,i)&&ti(o,i);for(;t.length>r;)Xt(n,i=t[r++])&&(~Zt(o,i)||ti(o,i));return o},ni=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"],ri=ii,oi=ni,si=Object.keys||function(e){return ri(e,oi)},ai=Ne,ci=De,li=Oe,di=be,ui=R,hi=si;ke.f=ai&&!ci?Object.defineProperties:function(e,t){di(e);for(var i,n=ui(t),r=hi(t),o=r.length,s=0;o>s;)li.f(e,i=r[s++],n[i]);return e};var pi,mi=Ge("document","documentElement"),_i=Y,fi=k("keys"),gi=function(e){return fi[e]||(fi[e]=_i(e))},Ti=be,Ei=ke,Si=ni,Ii=Qt,yi=mi,vi=Me,Ai="prototype",Ri="script",Ci=gi("IE_PROTO"),bi=function(){},ki=function(e){return"<"+Ri+">"+e+"</"+Ri+">"},Ni=function(e){e.write(ki("")),e.close();var t=e.parentWindow.Object;return e=null,t},Di=function(){try{pi=new ActiveXObject("htmlfile")}catch(o){}var e,t,i;Di="undefined"!=typeof document?document.domain&&pi?Ni(pi):(t=vi("iframe"),i="java"+Ri+":",t.style.display="none",yi.appendChild(t),t.src=String(i),(e=t.contentWindow.document).open(),e.write(ki("document.F=Object")),e.close(),e.F):Ni(pi);for(var n=Si.length;n--;)delete Di[Ai][Si[n]];return Di()};Ii[Ci]=!0;var Oi=Object.create||function(e,t){var i;return null!==e?(bi[Ai]=Ti(e),i=new bi,bi[Ai]=null,i[Ci]=e):i=Di(),void 0===t?i:Ei.f(i,t)},wi=fe,Pi=Oi,Li=Oe.f,Mi=wi("unscopables"),xi=Array.prototype;null==xi[Mi]&&Li(xi,Mi,{configurable:!0,value:Pi(null)});var Vi,Ui,Fi,Bi=function(e){xi[Mi][e]=!0},Hi={},ji=Se,Gi=b.WeakMap,Wi=ji(Gi)&&/native code/.test(String(Gi)),Ji=function(e,t){return{enumerable:!(1&e),configurable:!(2&e),writable:!(4&e),value:t}},zi=Oe,Ki=Ji,qi=Ne?function(e,t,i){return zi.f(e,t,Ki(1,i))}:function(e,t,i){return e[t]=i,e},Yi=Wi,Qi=b,Xi=ve,$i=qi,Zi=W,en=M,tn=gi,nn=Qt,rn="Object already initialized",on=Qi.TypeError,sn=Qi.WeakMap;if(Yi||en.state){var an=en.state||(en.state=new sn);an.get=an.get,an.has=an.has,an.set=an.set,Vi=function(e,t){if(an.has(e))throw on(rn);return t.facade=e,an.set(e,t),t},Ui=function(e){return an.get(e)||{}},Fi=function(e){return an.has(e)}}else{var cn=tn("state");nn[cn]=!0,Vi=function(e,t){if(Zi(e,cn))throw on(rn);return t.facade=e,$i(e,cn,t),t},Ui=function(e){return Zi(e,cn)?e[cn]:{}},Fi=function(e){return Zi(e,cn)}}var ln={set:Vi,get:Ui,has:Fi,enforce:function(e){return Fi(e)?Ui(e):Vi(e,{})},getterFor:function(e){return function(t){var i;if(!Xi(t)||(i=Ui(t)).type!==e)throw on("Incompatible receiver, "+e+" required");return i}}},dn={},un={},hn={}.propertyIsEnumerable,pn=Object.getOwnPropertyDescriptor,mn=pn&&!hn.call({1:2},1);un.f=mn?function(e){var t=pn(this,e);return!!t&&t.enumerable}:hn;var _n=Ne,fn=Be,gn=un,Tn=Ji,En=R,Sn=Et,In=W,yn=Ve,vn=Object.getOwnPropertyDescriptor;dn.f=_n?vn:function(e,t){if(e=En(e),t=Sn(t),yn)try{return vn(e,t)}catch(n){}if(In(e,t))return Tn(!fn(gn.f,e,t),e[t])};var An={},Rn={get exports(){return An},set exports(e){An=e}},Cn=Ne,bn=W,kn=Function.prototype,Nn=Cn&&Object.getOwnPropertyDescriptor,Dn=bn(kn,"name"),On={EXISTS:Dn,PROPER:Dn&&"something"===function(){}.name,CONFIGURABLE:Dn&&(!Cn||Cn&&Nn(kn,"name").configurable)},wn=Se,Pn=M,Ln=l(Function.toString);wn(Pn.inspectSource)||(Pn.inspectSource=function(e){return Ln(e)});var Mn=Pn.inspectSource,xn=l,Vn=n,Un=Se,Fn=W,Bn=Ne,Hn=On.CONFIGURABLE,jn=Mn,Gn=ln.enforce,Wn=ln.get,Jn=String,zn=Object.defineProperty,Kn=xn("".slice),qn=xn("".replace),Yn=xn([].join),Qn=Bn&&!Vn((function(){return 8!==zn((function(){}),"length",{value:8}).length})),Xn=String(String).split("String"),$n=Rn.exports=function(e,t,i){"Symbol("===Kn(Jn(t),0,7)&&(t="["+qn(Jn(t),/^Symbol\(([^)]*)\)/,"$1")+"]"),i&&i.getter&&(t="get "+t),i&&i.setter&&(t="set "+t),(!Fn(e,"name")||Hn&&e.name!==t)&&(Bn?zn(e,"name",{value:t,configurable:!0}):e.name=t),Qn&&i&&Fn(i,"arity")&&e.length!==i.arity&&zn(e,"length",{value:i.arity});try{i&&Fn(i,"constructor")&&i.constructor?Bn&&zn(e,"prototype",{writable:!1}):e.prototype&&(e.prototype=void 0)}catch(o){}var n=Gn(e);return Fn(n,"source")||(n.source=Yn(Xn,"string"==typeof t?t:"")),e};Function.prototype.toString=$n((function(){return Un(this)&&Wn(this).source||jn(this)}),"toString");var Zn=Se,er=Oe,tr=An,ir=w,nr=function(e,t,i,n){n||(n={});var r=n.enumerable,o=void 0!==n.name?n.name:t;if(Zn(i)&&tr(i,o,n),n.global)r?e[t]=i:ir(t,i);else{try{n.unsafe?e[t]&&(r=!0):delete e[t]}catch(a){}r?e[t]=i:er.f(e,t,{value:i,enumerable:!1,configurable:!n.nonConfigurable,writable:!n.nonWritable})}return e},rr={},or=ii,sr=ni.concat("length","prototype");rr.f=Object.getOwnPropertyNames||function(e){return or(e,sr)};var ar={};ar.f=Object.getOwnPropertySymbols;var cr,lr,dr,ur=Ge,hr=rr,pr=ar,mr=be,_r=l([].concat),fr=ur("Reflect","ownKeys")||function(e){var t=hr.f(mr(e)),i=pr.f;return i?_r(t,i(e)):t},gr=W,Tr=fr,Er=dn,Sr=Oe,Ir=function(e,t,i){for(var n=Tr(t),r=Sr.f,o=Er.f,s=0;s<n.length;s++){var a=n[s];gr(e,a)||i&&gr(i,a)||r(e,a,o(t,a))}},yr=n,vr=Se,Ar=/#|\.prototype\./,Rr=function(e,t){var i=br[Cr(e)];return i==Nr||i!=kr&&(vr(t)?yr(t):!!t)},Cr=Rr.normalize=function(e){return String(e).replace(Ar,".").toLowerCase()},br=Rr.data={},kr=Rr.NATIVE="N",Nr=Rr.POLYFILL="P",Dr=Rr,Or=b,wr=dn.f,Pr=qi,Lr=nr,Mr=w,xr=Ir,Vr=Dr,Ur=function(e,t){var i,n,r,o,s,a=e.target,c=e.global,l=e.stat;if(i=c?Or:l?Or[a]||Mr(a,{}):(Or[a]||{}).prototype)for(n in t){if(o=t[n],r=e.dontCallGetSet?(s=wr(i,n))&&s.value:i[n],!Vr(c?n:a+(l?".":"#")+n,e.forced)&&void 0!==r){if(typeof o==typeof r)continue;xr(o,r)}(e.sham||r&&r.sham)&&Pr(o,"sham",!0),Lr(i,n,o,e)}},Fr=!n((function(){function e(){}return e.prototype.constructor=null,Object.getPrototypeOf(new e)!==e.prototype})),Br=W,Hr=Se,jr=H,Gr=Fr,Wr=gi("IE_PROTO"),Jr=Object,zr=Jr.prototype,Kr=Gr?Jr.getPrototypeOf:function(e){var t=jr(e);if(Br(t,Wr))return t[Wr];var i=t.constructor;return Hr(i)&&t instanceof i?i.prototype:t instanceof Jr?zr:null},qr=n,Yr=Se,Qr=ve,Xr=Kr,$r=nr,Zr=fe("iterator"),eo=!1;[].keys&&("next"in(dr=[].keys())?(lr=Xr(Xr(dr)))!==Object.prototype&&(cr=lr):eo=!0);var to=!Qr(cr)||qr((function(){var e={};return cr[Zr].call(e)!==e}));to&&(cr={}),Yr(cr[Zr])||$r(cr,Zr,(function(){return this}));var io={IteratorPrototype:cr,BUGGY_SAFARI_ITERATORS:eo},no=Oe.f,ro=W,oo=fe("toStringTag"),so=function(e,t,i){e&&!i&&(e=e.prototype),e&&!ro(e,oo)&&no(e,oo,{configurable:!0,value:t})},ao=io.IteratorPrototype,co=Oi,lo=Ji,uo=so,ho=Hi,po=function(){return this},mo=function(e,t,i,n){var r=t+" Iterator";return e.prototype=co(ao,{next:lo(+!n,i)}),uo(e,r,!1),ho[r]=po,e},_o=l,fo=tt,go=Se,To=String,Eo=TypeError,So=function(e,t,i){try{return _o(fo(Object.getOwnPropertyDescriptor(e,t)[i]))}catch(r){}},Io=be,yo=function(e){if("object"==typeof e||go(e))return e;throw Eo("Can't set "+To(e)+" as a prototype")},vo=Object.setPrototypeOf||("__proto__"in{}?function(){var e,t=!1,i={};try{(e=So(Object.prototype,"__proto__","set"))(i,[]),t=i instanceof Array}catch(r){}return function(i,n){return Io(i),yo(n),t?e(i,n):i.__proto__=n,i}}():void 0),Ao=Ur,Ro=Be,Co=Se,bo=mo,ko=Kr,No=vo,Do=so,Oo=qi,wo=nr,Po=Hi,Lo=On.PROPER,Mo=On.CONFIGURABLE,xo=io.IteratorPrototype,Vo=io.BUGGY_SAFARI_ITERATORS,Uo=fe("iterator"),Fo="keys",Bo="values",Ho="entries",jo=function(){return this},Go=function(e,t,i,n,r,o,s){bo(i,t,n);var a,c,l,d=function(e){if(e===r&&_)return _;if(!Vo&&e in p)return p[e];switch(e){case Fo:case Bo:case Ho:return function(){return new i(this,e)}}return function(){return new i(this)}},u=t+" Iterator",h=!1,p=e.prototype,m=p[Uo]||p["@@iterator"]||r&&p[r],_=!Vo&&m||d(r),f="Array"==t&&p.entries||m;if(f&&(a=ko(f.call(new e)))!==Object.prototype&&a.next&&(ko(a)!==xo&&(No?No(a,xo):Co(a[Uo])||wo(a,Uo,jo)),Do(a,u,!0)),Lo&&r==Bo&&m&&m.name!==Bo&&(Mo?Oo(p,"name",Bo):(h=!0,_=function(){return Ro(m,this)})),r)if(c={values:d(Bo),keys:o?_:d(Fo),entries:d(Ho)},s)for(l in c)(Vo||h||!(l in p))&&wo(p,l,c[l]);else Ao({target:t,proto:!0,forced:Vo||h},c);return p[Uo]!==_&&wo(p,Uo,_,{name:r}),Po[t]=_,c},Wo=function(e,t){return{value:e,done:t}},Jo=R,zo=Bi,Ko=Hi,qo=ln,Yo=Oe.f,Qo=Go,Xo=Wo,$o=Ne,Zo="Array Iterator",es=qo.set,ts=qo.getterFor(Zo),is=Qo(Array,"Array",(function(e,t){es(this,{type:Zo,target:Jo(e),index:0,kind:t})}),(function(){var e=ts(this),t=e.target,i=e.kind,n=e.index++;return!t||n>=t.length?(e.target=void 0,Xo(void 0,!0)):Xo("keys"==i?n:"values"==i?t[n]:[n,t[n]],!1)}),"values"),ns=Ko.Arguments=Ko.Array;if(zo("keys"),zo("values"),zo("entries"),$o&&"values"!==ns.name)try{Yo(ns,"name",{value:"values"})}catch(IU){}var rs={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},os=Me("span").classList,ss=os&&os.constructor&&os.constructor.prototype,as=ss===Object.prototype?void 0:ss,cs=b,ls=rs,ds=as,us=is,hs=qi,ps=fe,ms=ps("iterator"),_s=ps("toStringTag"),fs=us.values,gs=function(e,t){if(e){if(e[ms]!==fs)try{hs(e,ms,fs)}catch(IU){e[ms]=fs}if(e[_s]||hs(e,_s,t),ls[t])for(var i in us)if(e[i]!==us[i])try{hs(e,i,us[i])}catch(IU){e[i]=us[i]}}};for(var Ts in ls)gs(cs[Ts]&&cs[Ts].prototype,Ts);gs(ds,"DOMTokenList");var Es="undefined"!=typeof process&&"process"==p(process),Ss=An,Is=Oe,ys=function(e,t,i){return i.get&&Ss(i.get,t,{getter:!0}),i.set&&Ss(i.set,t,{setter:!0}),Is.f(e,t,i)},vs=Ge,As=ys,Rs=Ne,Cs=fe("species"),bs=function(e){var t=vs(e);Rs&&t&&!t[Cs]&&As(t,Cs,{configurable:!0,get:function(){return this}})},ks=We,Ns=TypeError,Ds=function(e,t){if(ks(t,e))return e;throw Ns("Incorrect invocation")},Os={};Os[fe("toStringTag")]="z";var ws="[object z]"===String(Os),Ps=Se,Ls=p,Ms=fe("toStringTag"),xs=Object,Vs="Arguments"==Ls(function(){return arguments}()),Us=ws?Ls:function(e){var t,i,n;return void 0===e?"Undefined":null===e?"Null":"string"==typeof(i=function(e,t){try{return e[t]}catch(IU){}}(t=xs(e),Ms))?i:Vs?Ls(t):"Object"==(n=Ls(t))&&Ps(t.callee)?"Arguments":n},Fs=l,Bs=n,Hs=Se,js=Us,Gs=Mn,Ws=function(){},Js=[],zs=Ge("Reflect","construct"),Ks=/^\s*(?:class|function)\b/,qs=Fs(Ks.exec),Ys=!Ks.exec(Ws),Qs=function(e){if(!Hs(e))return!1;try{return zs(Ws,Js,e),!0}catch(IU){return!1}},Xs=function(e){if(!Hs(e))return!1;switch(js(e)){case"AsyncFunction":case"GeneratorFunction":case"AsyncGeneratorFunction":return!1}try{return Ys||!!qs(Ks,Gs(e))}catch(IU){return!0}};Xs.sham=!0;var $s,Zs,ea,ta,ia=!zs||Bs((function(){var e;return Qs(Qs.call)||!Qs(Object)||!Qs((function(){e=!0}))||e}))?Xs:Qs,na=ia,ra=Xe,oa=TypeError,sa=function(e){if(na(e))return e;throw oa(ra(e)+" is not a constructor")},aa=be,ca=sa,la=E,da=fe("species"),ua=function(e,t){var i,n=aa(e).constructor;return void 0===n||la(i=aa(n)[da])?t:ca(i)},ha=r,pa=Function.prototype,ma=pa.apply,_a=pa.call,fa="object"==typeof Reflect&&Reflect.apply||(ha?_a.bind(ma):function(){return _a.apply(ma,arguments)}),ga=p,Ta=l,Ea=function(e){if("Function"===ga(e))return Ta(e)},Sa=tt,Ia=r,ya=Ea(Ea.bind),va=function(e,t){return Sa(e),void 0===t?e:Ia?ya(e,t):function(){return e.apply(t,arguments)}},Aa=l([].slice),Ra=TypeError,Ca=function(e,t){if(e<t)throw Ra("Not enough arguments");return e},ba=/(?:ipad|iphone|ipod).*applewebkit/i.test(Q),ka=b,Na=fa,Da=va,Oa=Se,wa=W,Pa=n,La=mi,Ma=Aa,xa=Me,Va=Ca,Ua=ba,Fa=Es,Ba=ka.setImmediate,Ha=ka.clearImmediate,ja=ka.process,Ga=ka.Dispatch,Wa=ka.Function,Ja=ka.MessageChannel,za=ka.String,Ka=0,qa={},Ya="onreadystatechange";Pa((function(){$s=ka.location}));var Qa=function(e){if(wa(qa,e)){var t=qa[e];delete qa[e],t()}},Xa=function(e){return function(){Qa(e)}},$a=function(e){Qa(e.data)},Za=function(e){ka.postMessage(za(e),$s.protocol+"//"+$s.host)};Ba&&Ha||(Ba=function(e){Va(arguments.length,1);var t=Oa(e)?e:Wa(e),i=Ma(arguments,1);return qa[++Ka]=function(){Na(t,void 0,i)},Zs(Ka),Ka},Ha=function(e){delete qa[e]},Fa?Zs=function(e){ja.nextTick(Xa(e))}:Ga&&Ga.now?Zs=function(e){Ga.now(Xa(e))}:Ja&&!Ua?(ta=(ea=new Ja).port2,ea.port1.onmessage=$a,Zs=Da(ta.postMessage,ta)):ka.addEventListener&&Oa(ka.postMessage)&&!ka.importScripts&&$s&&"file:"!==$s.protocol&&!Pa(Za)?(Zs=Za,ka.addEventListener("message",$a,!1)):Zs=Ya in xa("script")?function(e){La.appendChild(xa("script"))[Ya]=function(){La.removeChild(this),Qa(e)}}:function(e){setTimeout(Xa(e),0)});var ec={set:Ba,clear:Ha},tc=function(){this.head=null,this.tail=null};tc.prototype={add:function(e){var t={item:e,next:null},i=this.tail;i?i.next=t:this.head=t,this.tail=t},get:function(){var e=this.head;if(e)return null===(this.head=e.next)&&(this.tail=null),e.item}};var ic,nc,rc,oc,sc,ac=tc,cc=/ipad|iphone|ipod/i.test(Q)&&"undefined"!=typeof Pebble,lc=/web0s(?!.*chrome)/i.test(Q),dc=b,uc=va,hc=dn.f,pc=ec.set,mc=ac,_c=ba,fc=cc,gc=lc,Tc=Es,Ec=dc.MutationObserver||dc.WebKitMutationObserver,Sc=dc.document,Ic=dc.process,yc=dc.Promise,vc=hc(dc,"queueMicrotask"),Ac=vc&&vc.value;if(!Ac){var Rc=new mc,Cc=function(){var e,t;for(Tc&&(e=Ic.domain)&&e.exit();t=Rc.get();)try{t()}catch(IU){throw Rc.head&&ic(),IU}e&&e.enter()};_c||Tc||gc||!Ec||!Sc?!fc&&yc&&yc.resolve?((oc=yc.resolve(void 0)).constructor=yc,sc=uc(oc.then,oc),ic=function(){sc(Cc)}):Tc?ic=function(){Ic.nextTick(Cc)}:(pc=uc(pc,dc),ic=function(){pc(Cc)}):(nc=!0,rc=Sc.createTextNode(""),new Ec(Cc).observe(rc,{characterData:!0}),ic=function(){rc.data=nc=!nc}),Ac=function(e){Rc.head||ic(),Rc.add(e)}}var bc=Ac,kc=function(e){try{return{error:!1,value:e()}}catch(IU){return{error:!0,value:IU}}},Nc=b.Promise,Dc="object"==typeof Deno&&Deno&&"object"==typeof Deno.version,Oc=!Dc&&!Es&&"object"==typeof window&&"object"==typeof document,wc=b,Pc=Nc,Lc=Se,Mc=Dr,xc=Mn,Vc=fe,Uc=Oc,Fc=Dc,Bc=ne;Pc&&Pc.prototype;var Hc=Vc("species"),jc=!1,Gc=Lc(wc.PromiseRejectionEvent),Wc=Mc("Promise",(function(){var e=xc(Pc),t=e!==String(Pc);if(!t&&66===Bc)return!0;if(!Bc||Bc<51||!/native code/.test(e)){var i=new Pc((function(e){e(1)})),n=function(e){e((function(){}),(function(){}))};if((i.constructor={})[Hc]=n,!(jc=i.then((function(){}))instanceof n))return!0}return!t&&(Uc||Fc)&&!Gc})),Jc={CONSTRUCTOR:Wc,REJECTION_EVENT:Gc,SUBCLASSING:jc},zc={},Kc=tt,qc=TypeError,Yc=function(e){var t,i;this.promise=new e((function(e,n){if(void 0!==t||void 0!==i)throw qc("Bad Promise constructor");t=e,i=n})),this.resolve=Kc(t),this.reject=Kc(i)};zc.f=function(e){return new Yc(e)};var Qc,Xc,$c,Zc=Ur,el=Es,tl=b,il=Be,nl=nr,rl=vo,ol=so,sl=bs,al=tt,cl=Se,ll=ve,dl=Ds,ul=ua,hl=ec.set,pl=bc,ml=function(e,t){try{1==arguments.length?console.error(e):console.error(e,t)}catch(IU){}},_l=kc,fl=ac,gl=ln,Tl=Nc,El=zc,Sl="Promise",Il=Jc.CONSTRUCTOR,yl=Jc.REJECTION_EVENT,vl=Jc.SUBCLASSING,Al=gl.getterFor(Sl),Rl=gl.set,Cl=Tl&&Tl.prototype,bl=Tl,kl=Cl,Nl=tl.TypeError,Dl=tl.document,Ol=tl.process,wl=El.f,Pl=wl,Ll=!!(Dl&&Dl.createEvent&&tl.dispatchEvent),Ml="unhandledrejection",xl=function(e){var t;return!(!ll(e)||!cl(t=e.then))&&t},Vl=function(e,t){var i,n,r,o=t.value,s=1==t.state,a=s?e.ok:e.fail,c=e.resolve,l=e.reject,d=e.domain;try{a?(s||(2===t.rejection&&jl(t),t.rejection=1),!0===a?i=o:(d&&d.enter(),i=a(o),d&&(d.exit(),r=!0)),i===e.promise?l(Nl("Promise-chain cycle")):(n=xl(i))?il(n,i,c,l):c(i)):l(o)}catch(IU){d&&!r&&d.exit(),l(IU)}},Ul=function(e,t){e.notified||(e.notified=!0,pl((function(){for(var i,n=e.reactions;i=n.get();)Vl(i,e);e.notified=!1,t&&!e.rejection&&Bl(e)})))},Fl=function(e,t,i){var n,r;Ll?((n=Dl.createEvent("Event")).promise=t,n.reason=i,n.initEvent(e,!1,!0),tl.dispatchEvent(n)):n={promise:t,reason:i},!yl&&(r=tl["on"+e])?r(n):e===Ml&&ml("Unhandled promise rejection",i)},Bl=function(e){il(hl,tl,(function(){var t,i=e.facade,n=e.value;if(Hl(e)&&(t=_l((function(){el?Ol.emit("unhandledRejection",n,i):Fl(Ml,i,n)})),e.rejection=el||Hl(e)?2:1,t.error))throw t.value}))},Hl=function(e){return 1!==e.rejection&&!e.parent},jl=function(e){il(hl,tl,(function(){var t=e.facade;el?Ol.emit("rejectionHandled",t):Fl("rejectionhandled",t,e.value)}))},Gl=function(e,t,i){return function(n){e(t,n,i)}},Wl=function(e,t,i){e.done||(e.done=!0,i&&(e=i),e.value=t,e.state=2,Ul(e,!0))},Jl=function(e,t,i){if(!e.done){e.done=!0,i&&(e=i);try{if(e.facade===t)throw Nl("Promise can't be resolved itself");var n=xl(t);n?pl((function(){var i={done:!1};try{il(n,t,Gl(Jl,i,e),Gl(Wl,i,e))}catch(IU){Wl(i,IU,e)}})):(e.value=t,e.state=1,Ul(e,!1))}catch(IU){Wl({done:!1},IU,e)}}};if(Il&&(kl=(bl=function(e){dl(this,kl),al(e),il(Qc,this);var t=Al(this);try{e(Gl(Jl,t),Gl(Wl,t))}catch(IU){Wl(t,IU)}}).prototype,(Qc=function(e){Rl(this,{type:Sl,done:!1,notified:!1,parent:!1,reactions:new fl,rejection:!1,state:0,value:void 0})}).prototype=nl(kl,"then",(function(e,t){var i=Al(this),n=wl(ul(this,bl));return i.parent=!0,n.ok=!cl(e)||e,n.fail=cl(t)&&t,n.domain=el?Ol.domain:void 0,0==i.state?i.reactions.add(n):pl((function(){Vl(n,i)})),n.promise})),Xc=function(){var e=new Qc,t=Al(e);this.promise=e,this.resolve=Gl(Jl,t),this.reject=Gl(Wl,t)},El.f=wl=function(e){return e===bl||void 0===e?new Xc(e):Pl(e)},cl(Tl)&&Cl!==Object.prototype)){$c=Cl.then,vl||nl(Cl,"then",(function(e,t){var i=this;return new bl((function(e,t){il($c,i,e,t)})).then(e,t)}),{unsafe:!0});try{delete Cl.constructor}catch(IU){}rl&&rl(Cl,kl)}Zc({global:!0,constructor:!0,wrap:!0,forced:Il},{Promise:bl}),ol(bl,Sl,!1),sl(Sl);var zl=Hi,Kl=fe("iterator"),ql=Array.prototype,Yl=function(e){return void 0!==e&&(zl.Array===e||ql[Kl]===e)},Ql=Us,Xl=rt,$l=E,Zl=Hi,ed=fe("iterator"),td=function(e){if(!$l(e))return Xl(e,ed)||Xl(e,"@@iterator")||Zl[Ql(e)]},id=Be,nd=tt,rd=be,od=Xe,sd=td,ad=TypeError,cd=function(e,t){var i=arguments.length<2?sd(e):t;if(nd(i))return rd(id(i,e));throw ad(od(e)+" is not iterable")},ld=Be,dd=be,ud=rt,hd=function(e,t,i){var n,r;dd(e);try{if(!(n=ud(e,"return"))){if("throw"===t)throw i;return i}n=ld(n,e)}catch(IU){r=!0,n=IU}if("throw"===t)throw i;if(r)throw n;return dd(n),i},pd=va,md=Be,_d=be,fd=Xe,gd=Yl,Td=Wt,Ed=We,Sd=cd,Id=td,yd=hd,vd=TypeError,Ad=function(e,t){this.stopped=e,this.result=t},Rd=Ad.prototype,Cd=function(e,t,i){var n,r,o,s,a,c,l,d=i&&i.that,u=!(!i||!i.AS_ENTRIES),h=!(!i||!i.IS_RECORD),p=!(!i||!i.IS_ITERATOR),m=!(!i||!i.INTERRUPTED),_=pd(t,d),f=function(e){return n&&yd(n,"normal",e),new Ad(!0,e)},g=function(e){return u?(_d(e),m?_(e[0],e[1],f):_(e[0],e[1])):m?_(e,f):_(e)};if(h)n=e.iterator;else if(p)n=e;else{if(!(r=Id(e)))throw vd(fd(e)+" is not iterable");if(gd(r)){for(o=0,s=Td(e);s>o;o++)if((a=g(e[o]))&&Ed(Rd,a))return a;return new Ad(!1)}n=Sd(e,r)}for(c=h?e.next:n.next;!(l=md(c,n)).done;){try{a=g(l.value)}catch(IU){yd(n,"throw",IU)}if("object"==typeof a&&a&&Ed(Rd,a))return a}return new Ad(!1)},bd=fe("iterator"),kd=!1;try{var Nd=0,Dd={next:function(){return{done:!!Nd++}},return:function(){kd=!0}};Dd[bd]=function(){return this},Array.from(Dd,(function(){throw 2}))}catch(IU){}var Od=function(e,t){if(!t&&!kd)return!1;var i=!1;try{var n={};n[bd]=function(){return{next:function(){return{done:i=!0}}}},e(n)}catch(IU){}return i},wd=Nc,Pd=Jc.CONSTRUCTOR||!Od((function(e){wd.all(e).then(void 0,(function(){}))})),Ld=Be,Md=tt,xd=zc,Vd=kc,Ud=Cd;Ur({target:"Promise",stat:!0,forced:Pd},{all:function(e){var t=this,i=xd.f(t),n=i.resolve,r=i.reject,o=Vd((function(){var i=Md(t.resolve),o=[],s=0,a=1;Ud(e,(function(e){var c=s++,l=!1;a++,Ld(i,t,e).then((function(e){l||(l=!0,o[c]=e,--a||n(o))}),r)})),--a||n(o)}));return o.error&&r(o.value),i.promise}});var Fd=Ur,Bd=Jc.CONSTRUCTOR,Hd=Nc,jd=Ge,Gd=Se,Wd=nr,Jd=Hd&&Hd.prototype;if(Fd({target:"Promise",proto:!0,forced:Bd,real:!0},{catch:function(e){return this.then(void 0,e)}}),Gd(Hd)){var zd=jd("Promise").prototype.catch;Jd.catch!==zd&&Wd(Jd,"catch",zd,{unsafe:!0})}var Kd=Be,qd=tt,Yd=zc,Qd=kc,Xd=Cd;Ur({target:"Promise",stat:!0,forced:Pd},{race:function(e){var t=this,i=Yd.f(t),n=i.reject,r=Qd((function(){var r=qd(t.resolve);Xd(e,(function(e){Kd(r,t,e).then(i.resolve,n)}))}));return r.error&&n(r.value),i.promise}});var $d=Be,Zd=zc;Ur({target:"Promise",stat:!0,forced:Jc.CONSTRUCTOR},{reject:function(e){var t=Zd.f(this);return $d(t.reject,void 0,e),t.promise}});var eu=be,tu=ve,iu=zc,nu=function(e,t){if(eu(e),tu(t)&&t.constructor===e)return t;var i=iu.f(e);return(0,i.resolve)(t),i.promise},ru=Ur,ou=Jc.CONSTRUCTOR,su=nu;Ge("Promise"),ru({target:"Promise",stat:!0,forced:ou},{resolve:function(e){return su(this,e)}});var au=Se,cu=ve,lu=vo,du=function(e,t,i){var n,r;return lu&&au(n=t.constructor)&&n!==i&&cu(r=n.prototype)&&r!==i.prototype&&lu(e,r),e},uu=ve,hu=p,pu=fe("match"),mu=function(e){var t;return uu(e)&&(void 0!==(t=e[pu])?!!t:"RegExp"==hu(e))},_u=Us,fu=String,gu=function(e){if("Symbol"===_u(e))throw TypeError("Cannot convert a Symbol value to a string");return fu(e)},Tu=be,Eu=function(){var e=Tu(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},Su=Be,Iu=W,yu=We,vu=Eu,Au=RegExp.prototype,Ru=function(e){var t=e.flags;return void 0!==t||"flags"in Au||Iu(e,"flags")||!yu(Au,e)?t:Su(vu,e)},Cu=n,bu=b.RegExp,ku=Cu((function(){var e=bu("a","y");return e.lastIndex=2,null!=e.exec("abcd")})),Nu=ku||Cu((function(){return!bu("a","y").sticky})),Du=ku||Cu((function(){var e=bu("^r","gy");return e.lastIndex=2,null!=e.exec("str")})),Ou={BROKEN_CARET:Du,MISSED_STICKY:Nu,UNSUPPORTED_Y:ku},wu=Oe.f,Pu=n,Lu=b.RegExp,Mu=Pu((function(){var e=Lu(".","s");return!(e.dotAll&&e.exec("\n")&&"s"===e.flags)})),xu=n,Vu=b.RegExp,Uu=xu((function(){var e=Vu("(?<a>b)","g");return"b"!==e.exec("b").groups.a||"bc"!=="b".replace(e,"$<a>c")})),Fu=Ne,Bu=b,Hu=l,ju=Dr,Gu=du,Wu=qi,Ju=rr.f,zu=We,Ku=mu,qu=gu,Yu=Ru,Qu=Ou,Xu=function(e,t,i){i in e||wu(e,i,{configurable:!0,get:function(){return t[i]},set:function(e){t[i]=e}})},$u=nr,Zu=n,eh=W,th=ln.enforce,ih=bs,nh=Mu,rh=Uu,oh=fe("match"),sh=Bu.RegExp,ah=sh.prototype,ch=Bu.SyntaxError,lh=Hu(ah.exec),dh=Hu("".charAt),uh=Hu("".replace),hh=Hu("".indexOf),ph=Hu("".slice),mh=/^\?<[^\s\d!#%&*+<=>@^][^\s!#%&*+<=>@^]*>/,_h=/a/g,fh=/a/g,gh=new sh(_h)!==_h,Th=Qu.MISSED_STICKY,Eh=Qu.UNSUPPORTED_Y,Sh=Fu&&(!gh||Th||nh||rh||Zu((function(){return fh[oh]=!1,sh(_h)!=_h||sh(fh)==fh||"/a/i"!=sh(_h,"i")})));if(ju("RegExp",Sh)){for(var Ih=function(e,t){var i,n,r,o,s,a,c=zu(ah,this),l=Ku(e),d=void 0===t,u=[],h=e;if(!c&&l&&d&&e.constructor===Ih)return e;if((l||zu(ah,e))&&(e=e.source,d&&(t=Yu(h))),e=void 0===e?"":qu(e),t=void 0===t?"":qu(t),h=e,nh&&"dotAll"in _h&&(n=!!t&&hh(t,"s")>-1)&&(t=uh(t,/s/g,"")),i=t,Th&&"sticky"in _h&&(r=!!t&&hh(t,"y")>-1)&&Eh&&(t=uh(t,/y/g,"")),rh&&(o=function(e){for(var t,i=e.length,n=0,r="",o=[],s={},a=!1,c=!1,l=0,d="";n<=i;n++){if("\\"===(t=dh(e,n)))t+=dh(e,++n);else if("]"===t)a=!1;else if(!a)switch(!0){case"["===t:a=!0;break;case"("===t:lh(mh,ph(e,n+1))&&(n+=2,c=!0),r+=t,l++;continue;case">"===t&&c:if(""===d||eh(s,d))throw new ch("Invalid capture group name");s[d]=!0,o[o.length]=[d,l],c=!1,d="";continue}c?d+=t:r+=t}return[r,o]}(e),e=o[0],u=o[1]),s=Gu(sh(e,t),c?this:ah,Ih),(n||r||u.length)&&(a=th(s),n&&(a.dotAll=!0,a.raw=Ih(function(e){for(var t,i=e.length,n=0,r="",o=!1;n<=i;n++)"\\"!==(t=dh(e,n))?o||"."!==t?("["===t?o=!0:"]"===t&&(o=!1),r+=t):r+="[\\s\\S]":r+=t+dh(e,++n);return r}(e),i)),r&&(a.sticky=!0),u.length&&(a.groups=u)),e!==h)try{Wu(s,"source",""===h?"(?:)":h)}catch(IU){}return s},yh=Ju(sh),vh=0;yh.length>vh;)Xu(Ih,sh,yh[vh++]);ah.constructor=Ih,Ih.prototype=ah,$u(Bu,"RegExp",Ih,{constructor:!0})}ih("RegExp");var Ah=Be,Rh=l,Ch=gu,bh=Eu,kh=Ou,Nh=Oi,Dh=ln.get,Oh=Mu,wh=Uu,Ph=k("native-string-replace",String.prototype.replace),Lh=RegExp.prototype.exec,Mh=Lh,xh=Rh("".charAt),Vh=Rh("".indexOf),Uh=Rh("".replace),Fh=Rh("".slice),Bh=function(){var e=/a/,t=/b*/g;return Ah(Lh,e,"a"),Ah(Lh,t,"a"),0!==e.lastIndex||0!==t.lastIndex}(),Hh=kh.BROKEN_CARET,jh=void 0!==/()??/.exec("")[1];(Bh||jh||Hh||Oh||wh)&&(Mh=function(e){var t,i,n,r,o,s,a,c=this,l=Dh(c),d=Ch(e),u=l.raw;if(u)return u.lastIndex=c.lastIndex,t=Ah(Mh,u,d),c.lastIndex=u.lastIndex,t;var h=l.groups,p=Hh&&c.sticky,m=Ah(bh,c),_=c.source,f=0,g=d;if(p&&(m=Uh(m,"y",""),-1===Vh(m,"g")&&(m+="g"),g=Fh(d,c.lastIndex),c.lastIndex>0&&(!c.multiline||c.multiline&&"\n"!==xh(d,c.lastIndex-1))&&(_="(?: "+_+")",g=" "+g,f++),i=new RegExp("^(?:"+_+")",m)),jh&&(i=new RegExp("^"+_+"$(?!\\s)",m)),Bh&&(n=c.lastIndex),r=Ah(Lh,p?i:c,g),p?r?(r.input=Fh(r.input,f),r[0]=Fh(r[0],f),r.index=c.lastIndex,c.lastIndex+=r[0].length):c.lastIndex=0:Bh&&r&&(c.lastIndex=c.global?r.index+r[0].length:n),jh&&r&&r.length>1&&Ah(Ph,r[0],i,(function(){for(o=1;o<arguments.length-2;o++)void 0===arguments[o]&&(r[o]=void 0)})),r&&h)for(r.groups=s=Nh(null),o=0;o<h.length;o++)s[(a=h[o])[0]]=r[a[1]];return r});var Gh=Mh;Ur({target:"RegExp",proto:!0,forced:/./.exec!==Gh},{exec:Gh});var Wh=p,Jh=Array.isArray||function(e){return"Array"==Wh(e)},zh=Jh,Kh=ia,qh=ve,Yh=fe("species"),Qh=Array,Xh=function(e){var t;return zh(e)&&(t=e.constructor,(Kh(t)&&(t===Qh||zh(t.prototype))||qh(t)&&null===(t=t[Yh]))&&(t=void 0)),void 0===t?Qh:t},$h=va,Zh=T,ep=H,tp=Wt,ip=function(e,t){return new(Xh(e))(0===t?0:t)},np=l([].push),rp=function(e){var t=1==e,i=2==e,n=3==e,r=4==e,o=6==e,s=7==e,a=5==e||o;return function(c,l,d,u){for(var h,p,m=ep(c),_=Zh(m),f=$h(l,d),g=tp(_),T=0,E=u||ip,S=t?E(c,g):i||s?E(c,0):void 0;g>T;T++)if((a||T in _)&&(p=f(h=_[T],T,m),e))if(t)S[T]=p;else if(p)switch(e){case 3:return!0;case 5:return h;case 6:return T;case 2:np(S,h)}else switch(e){case 4:return!1;case 7:np(S,h)}return o?-1:n||r?r:S}},op={forEach:rp(0),map:rp(1),filter:rp(2),some:rp(3),every:rp(4),find:rp(5),findIndex:rp(6),filterReject:rp(7)},sp=n,ap=function(e,t){var i=[][e];return!!i&&sp((function(){i.call(null,t||function(){return 1},1)}))},cp=op.forEach,lp=ap("forEach")?[].forEach:function(e){return cp(this,e,arguments.length>1?arguments[1]:void 0)},dp=b,up=rs,hp=as,pp=lp,mp=qi,_p=function(e){if(e&&e.forEach!==pp)try{mp(e,"forEach",pp)}catch(IU){e.forEach=pp}};for(var fp in up)up[fp]&&_p(dp[fp]&&dp[fp].prototype);_p(hp);var gp=tt,Tp=H,Ep=T,Sp=Wt,Ip=TypeError,yp=function(e){return function(t,i,n,r){gp(i);var o=Tp(t),s=Ep(o),a=Sp(o),c=e?a-1:0,l=e?-1:1;if(n<2)for(;;){if(c in s){r=s[c],c+=l;break}if(c+=l,e?c<0:a<=c)throw Ip("Reduce of empty array with no initial value")}for(;e?c>=0:a>c;c+=l)c in s&&(r=i(r,s[c],c,o));return r}},vp={left:yp(!1),right:yp(!0)}.left;Ur({target:"Array",proto:!0,forced:!Es&&ne>79&&ne<83||!ap("reduce")},{reduce:function(e){var t=arguments.length;return vp(this,e,t,t>1?arguments[1]:void 0)}});var Ap=Ea,Rp=nr,Cp=Gh,bp=n,kp=fe,Np=qi,Dp=kp("species"),Op=RegExp.prototype,wp=l,Pp=Mt,Lp=gu,Mp=y,xp=wp("".charAt),Vp=wp("".charCodeAt),Up=wp("".slice),Fp=function(e){return function(t,i){var n,r,o=Lp(Mp(t)),s=Pp(i),a=o.length;return s<0||s>=a?e?"":void 0:(n=Vp(o,s))<55296||n>56319||s+1===a||(r=Vp(o,s+1))<56320||r>57343?e?xp(o,s):n:e?Up(o,s,s+2):r-56320+(n-55296<<10)+65536}},Bp={codeAt:Fp(!1),charAt:Fp(!0)},Hp=Bp.charAt,jp=l,Gp=H,Wp=Math.floor,Jp=jp("".charAt),zp=jp("".replace),Kp=jp("".slice),qp=/\$([$&'`]|\d{1,2}|<[^>]*>)/g,Yp=/\$([$&'`]|\d{1,2})/g,Qp=function(e,t,i,n,r,o){var s=i+e.length,a=n.length,c=Yp;return void 0!==r&&(r=Gp(r),c=qp),zp(o,c,(function(o,c){var l;switch(Jp(c,0)){case"$":return"$";case"&":return e;case"`":return Kp(t,0,i);case"'":return Kp(t,s);case"<":l=r[Kp(c,1,-1)];break;default:var d=+c;if(0===d)return o;if(d>a){var u=Wp(d/10);return 0===u?o:u<=a?void 0===n[u-1]?Jp(c,1):n[u-1]+Jp(c,1):o}l=n[d-1]}return void 0===l?"":l}))},Xp=Be,$p=be,Zp=Se,em=p,tm=Gh,im=TypeError,nm=fa,rm=Be,om=l,sm=function(e,t,i,n){var r=kp(e),o=!bp((function(){var t={};return t[r]=function(){return 7},7!=""[e](t)})),s=o&&!bp((function(){var t=!1,i=/a/;return"split"===e&&((i={}).constructor={},i.constructor[Dp]=function(){return i},i.flags="",i[r]=/./[r]),i.exec=function(){return t=!0,null},i[r](""),!t}));if(!o||!s||i){var a=Ap(/./[r]),c=t(r,""[e],(function(e,t,i,n,r){var s=Ap(e),c=t.exec;return c===Cp||c===Op.exec?o&&!r?{done:!0,value:a(t,i,n)}:{done:!0,value:s(i,t,n)}:{done:!1}}));Rp(String.prototype,e,c[0]),Rp(Op,r,c[1])}n&&Np(Op[r],"sham",!0)},am=n,cm=be,lm=Se,dm=E,um=Mt,hm=jt,pm=gu,mm=y,_m=function(e,t,i){return t+(i?Hp(e,t).length:1)},fm=rt,gm=Qp,Tm=function(e,t){var i=e.exec;if(Zp(i)){var n=Xp(i,e,t);return null!==n&&$p(n),n}if("RegExp"===em(e))return Xp(tm,e,t);throw im("RegExp#exec called on incompatible receiver")},Em=fe("replace"),Sm=Math.max,Im=Math.min,ym=om([].concat),vm=om([].push),Am=om("".indexOf),Rm=om("".slice),Cm=function(e){return void 0===e?e:String(e)},bm="$0"==="a".replace(/./,"$0"),km=!!/./[Em]&&""===/./[Em]("a","$0"),Nm=!am((function(){var e=/./;return e.exec=function(){var e=[];return e.groups={a:"7"},e},"7"!=="".replace(e,"$<a>")}));sm("replace",(function(e,t,i){var n=km?"$":"$0";return[function(e,i){var n=mm(this),r=dm(e)?void 0:fm(e,Em);return r?rm(r,e,n,i):rm(t,pm(n),e,i)},function(e,r){var o=cm(this),s=pm(e);if("string"==typeof r&&-1===Am(r,n)&&-1===Am(r,"$<")){var a=i(t,o,s,r);if(a.done)return a.value}var c=lm(r);c||(r=pm(r));var l=o.global;if(l){var d=o.unicode;o.lastIndex=0}for(var u=[];;){var h=Tm(o,s);if(null===h)break;if(vm(u,h),!l)break;""===pm(h[0])&&(o.lastIndex=_m(s,hm(o.lastIndex),d))}for(var p="",m=0,_=0;_<u.length;_++){for(var f=pm((h=u[_])[0]),g=Sm(Im(um(h.index),s.length),0),T=[],E=1;E<h.length;E++)vm(T,Cm(h[E]));var S=h.groups;if(c){var I=ym([f],T,g,s);void 0!==S&&vm(I,S);var y=pm(nm(r,void 0,I))}else y=gm(f,s,g,T,S,r);g>=m&&(p+=Rm(s,m,g)+y,m=g+f.length)}return p+Rm(s,m)}]}),!Nm||!bm||km);var Dm=Yt.includes,Om=Bi;Ur({target:"Array",proto:!0,forced:n((function(){return!Array(1).includes()}))},{includes:function(e){return Dm(this,e,arguments.length>1?arguments[1]:void 0)}}),Om("includes");var wm=Mt,Pm=gu,Lm=y,Mm=RangeError,xm=l,Vm=jt,Um=gu,Fm=function(e){var t=Pm(Lm(this)),i="",n=wm(e);if(n<0||1/0==n)throw Mm("Wrong number of repetitions");for(;n>0;(n>>>=1)&&(t+=t))1&n&&(i+=t);return i},Bm=y,Hm=xm(Fm),jm=xm("".slice),Gm=Math.ceil,Wm=function(e){return function(t,i,n){var r,o,s=Um(Bm(t)),a=Vm(i),c=s.length,l=void 0===n?" ":Um(n);return a<=c||""==l?s:((o=Hm(l,Gm((r=a-c)/l.length))).length>r&&(o=jm(o,0,r)),e?s+o:o+s)}},Jm={start:Wm(!1),end:Wm(!0)},zm=/Version\/10(?:\.\d+){1,2}(?: [\w./]+)?(?: Mobile\/\w+)? Safari\//.test(Q),Km=Jm.start;Ur({target:"String",proto:!0,forced:zm},{padStart:function(e){return Km(this,e,arguments.length>1?arguments[1]:void 0)}});var qm=n,Ym=Ne,Qm=fe("iterator"),Xm=!qm((function(){var e=new URL("b?a=1&b=2&c=3","http://a"),t=e.searchParams,i="";return e.pathname="c%20d",t.forEach((function(e,n){t.delete("b"),i+=n+e})),!t.size&&!Ym||!t.sort||"http://a/c%20d?a=1&c=3"!==e.href||"3"!==t.get("c")||"a=1"!==String(new URLSearchParams("?a=1"))||!t[Qm]||"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"!==i||"x"!==new URL("http://x",void 0).host})),$m=nr,Zm=function(e,t,i){for(var n in t)$m(e,n,t[n],i);return e},e_=Et,t_=Oe,i_=Ji,n_=function(e,t,i){var n=e_(t);n in e?t_.f(e,n,i_(0,i)):e[n]=i},r_=Ft,o_=Wt,s_=n_,a_=Array,c_=Math.max,l_=function(e,t,i){for(var n=o_(e),r=r_(t,n),o=r_(void 0===i?n:i,n),s=a_(c_(o-r,0)),a=0;r<o;r++,a++)s_(s,a,e[r]);return s.length=a,s},d_=l_,u_=Math.floor,h_=function(e,t){var i=e.length,n=u_(i/2);return i<8?p_(e,t):m_(e,h_(d_(e,0,n),t),h_(d_(e,n),t),t)},p_=function(e,t){for(var i,n,r=e.length,o=1;o<r;){for(n=o,i=e[o];n&&t(e[n-1],i)>0;)e[n]=e[--n];n!==o++&&(e[n]=i)}return e},m_=function(e,t,i,n){for(var r=t.length,o=i.length,s=0,a=0;s<r||a<o;)e[s+a]=s<r&&a<o?n(t[s],i[a])<=0?t[s++]:i[a++]:s<r?t[s++]:i[a++];return e},__=h_,f_=Ur,g_=b,T_=Be,E_=l,S_=Ne,I_=Xm,y_=nr,v_=ys,A_=Zm,R_=so,C_=mo,b_=ln,k_=Ds,N_=Se,D_=W,O_=va,w_=Us,P_=be,L_=ve,M_=gu,x_=Oi,V_=Ji,U_=cd,F_=td,B_=Ca,H_=__,j_=fe("iterator"),G_="URLSearchParams",W_=G_+"Iterator",J_=b_.set,z_=b_.getterFor(G_),K_=b_.getterFor(W_),q_=Object.getOwnPropertyDescriptor,Y_=function(e){if(!S_)return g_[e];var t=q_(g_,e);return t&&t.value},Q_=Y_("fetch"),X_=Y_("Request"),$_=Y_("Headers"),Z_=X_&&X_.prototype,ef=$_&&$_.prototype,tf=g_.RegExp,nf=g_.TypeError,rf=g_.decodeURIComponent,of=g_.encodeURIComponent,sf=E_("".charAt),af=E_([].join),cf=E_([].push),lf=E_("".replace),df=E_([].shift),uf=E_([].splice),hf=E_("".split),pf=E_("".slice),mf=/\+/g,_f=Array(4),ff=function(e){return _f[e-1]||(_f[e-1]=tf("((?:%[\\da-f]{2}){"+e+"})","gi"))},gf=function(e){try{return rf(e)}catch(IU){return e}},Tf=function(e){var t=lf(e,mf," "),i=4;try{return rf(t)}catch(IU){for(;i;)t=lf(t,ff(i--),gf);return t}},Ef=/[!'()~]|%20/g,Sf={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+"},If=function(e){return Sf[e]},yf=function(e){return lf(of(e),Ef,If)},vf=C_((function(e,t){J_(this,{type:W_,iterator:U_(z_(e).entries),kind:t})}),"Iterator",(function(){var e=K_(this),t=e.kind,i=e.iterator.next(),n=i.value;return i.done||(i.value="keys"===t?n.key:"values"===t?n.value:[n.key,n.value]),i}),!0),Af=function(e){this.entries=[],this.url=null,void 0!==e&&(L_(e)?this.parseObject(e):this.parseQuery("string"==typeof e?"?"===sf(e,0)?pf(e,1):e:M_(e)))};Af.prototype={type:G_,bindURL:function(e){this.url=e,this.update()},parseObject:function(e){var t,i,n,r,o,s,a,c=F_(e);if(c)for(i=(t=U_(e,c)).next;!(n=T_(i,t)).done;){if(o=(r=U_(P_(n.value))).next,(s=T_(o,r)).done||(a=T_(o,r)).done||!T_(o,r).done)throw nf("Expected sequence with length 2");cf(this.entries,{key:M_(s.value),value:M_(a.value)})}else for(var l in e)D_(e,l)&&cf(this.entries,{key:l,value:M_(e[l])})},parseQuery:function(e){if(e)for(var t,i,n=hf(e,"&"),r=0;r<n.length;)(t=n[r++]).length&&(i=hf(t,"="),cf(this.entries,{key:Tf(df(i)),value:Tf(af(i,"="))}))},serialize:function(){for(var e,t=this.entries,i=[],n=0;n<t.length;)e=t[n++],cf(i,yf(e.key)+"="+yf(e.value));return af(i,"&")},update:function(){this.entries.length=0,this.parseQuery(this.url.query)},updateURL:function(){this.url&&this.url.update()}};var Rf=function(){k_(this,Cf);var e=J_(this,new Af(arguments.length>0?arguments[0]:void 0));S_||(this.length=e.entries.length)},Cf=Rf.prototype;if(A_(Cf,{append:function(e,t){B_(arguments.length,2);var i=z_(this);cf(i.entries,{key:M_(e),value:M_(t)}),S_||this.length++,i.updateURL()},delete:function(e){B_(arguments.length,1);for(var t=z_(this),i=t.entries,n=M_(e),r=0;r<i.length;)i[r].key===n?uf(i,r,1):r++;S_||(this.length=i.length),t.updateURL()},get:function(e){B_(arguments.length,1);for(var t=z_(this).entries,i=M_(e),n=0;n<t.length;n++)if(t[n].key===i)return t[n].value;return null},getAll:function(e){B_(arguments.length,1);for(var t=z_(this).entries,i=M_(e),n=[],r=0;r<t.length;r++)t[r].key===i&&cf(n,t[r].value);return n},has:function(e){B_(arguments.length,1);for(var t=z_(this).entries,i=M_(e),n=0;n<t.length;)if(t[n++].key===i)return!0;return!1},set:function(e,t){B_(arguments.length,1);for(var i,n=z_(this),r=n.entries,o=!1,s=M_(e),a=M_(t),c=0;c<r.length;c++)(i=r[c]).key===s&&(o?uf(r,c--,1):(o=!0,i.value=a));o||cf(r,{key:s,value:a}),S_||(this.length=r.length),n.updateURL()},sort:function(){var e=z_(this);H_(e.entries,(function(e,t){return e.key>t.key?1:-1})),e.updateURL()},forEach:function(e){for(var t,i=z_(this).entries,n=O_(e,arguments.length>1?arguments[1]:void 0),r=0;r<i.length;)n((t=i[r++]).value,t.key,this)},keys:function(){return new vf(this,"keys")},values:function(){return new vf(this,"values")},entries:function(){return new vf(this,"entries")}},{enumerable:!0}),y_(Cf,j_,Cf.entries,{name:"entries"}),y_(Cf,"toString",(function(){return z_(this).serialize()}),{enumerable:!0}),S_&&v_(Cf,"size",{get:function(){return z_(this).entries.length},configurable:!0,enumerable:!0}),R_(Rf,G_),f_({global:!0,constructor:!0,forced:!I_},{URLSearchParams:Rf}),!I_&&N_($_)){var bf=E_(ef.has),kf=E_(ef.set),Nf=function(e){if(L_(e)){var t,i=e.body;if(w_(i)===G_)return t=e.headers?new $_(e.headers):new $_,bf(t,"content-type")||kf(t,"content-type","application/x-www-form-urlencoded;charset=UTF-8"),x_(e,{body:V_(0,M_(i)),headers:V_(0,t)})}return e};if(N_(Q_)&&f_({global:!0,enumerable:!0,dontCallGetSet:!0,forced:!0},{fetch:function(e){return Q_(e,arguments.length>1?Nf(arguments[1]):{})}}),N_(X_)){var Df=function(e){return k_(this,Z_),new X_(e,arguments.length>1?Nf(arguments[1]):{})};Z_.constructor=Df,Df.prototype=Z_,f_({global:!0,constructor:!0,dontCallGetSet:!0,forced:!0},{Request:Df})}}var Of={URLSearchParams:Rf,getState:z_},wf="\t\n\v\f\r                 \u2028\u2029\ufeff",Pf=y,Lf=gu,Mf=wf,xf=l("".replace),Vf=RegExp("^["+Mf+"]+"),Uf=RegExp("(^|[^"+Mf+"])["+Mf+"]+$"),Ff=function(e){return function(t){var i=Lf(Pf(t));return 1&e&&(i=xf(i,Vf,"")),2&e&&(i=xf(i,Uf,"$1")),i}},Bf={start:Ff(1),end:Ff(2),trim:Ff(3)},Hf=On.PROPER,jf=n,Gf=wf,Wf=Bf.trim;Ur({target:"String",proto:!0,forced:function(e){return jf((function(){return!!Gf[e]()||"​…᠎"!=="​…᠎"[e]()||Hf&&Gf[e].name!==e}))}("trim")},{trim:function(){return Wf(this)}});var Jf=Ur,zf=Ne,Kf=l,qf=W,Yf=Se,Qf=We,Xf=gu,$f=ys,Zf=Ir,eg=b.Symbol,tg=eg&&eg.prototype;if(zf&&Yf(eg)&&(!("description"in tg)||void 0!==eg().description)){var ig={},ng=function(){var e=arguments.length<1||void 0===arguments[0]?void 0:Xf(arguments[0]),t=Qf(tg,this)?new eg(e):void 0===e?eg():eg(e);return""===e&&(ig[t]=!0),t};Zf(ng,eg),ng.prototype=tg,tg.constructor=ng;var rg="Symbol(test)"==String(eg("test")),og=Kf(tg.valueOf),sg=Kf(tg.toString),ag=/^Symbol\((.*)\)[^)]+$/,cg=Kf("".replace),lg=Kf("".slice);$f(tg,"description",{configurable:!0,get:function(){var e=og(this);if(qf(ig,e))return"";var t=sg(e),i=rg?lg(t,7,-1):cg(t,ag,"$1");return""===i?void 0:i}}),Jf({global:!0,constructor:!0,forced:!0},{Symbol:ng})}var dg=Bp.charAt,ug=gu,hg=ln,pg=Go,mg=Wo,_g="String Iterator",fg=hg.set,gg=hg.getterFor(_g);pg(String,"String",(function(e){fg(this,{type:_g,string:ug(e),index:0})}),(function(){var e,t=gg(this),i=t.string,n=t.index;return n>=i.length?mg(void 0,!0):(e=dg(i,n),t.index+=e.length,mg(e,!1))}));var Tg,Eg=Ne,Sg=l,Ig=Be,yg=n,vg=si,Ag=ar,Rg=un,Cg=H,bg=T,kg=Object.assign,Ng=Object.defineProperty,Dg=Sg([].concat),Og=!kg||yg((function(){if(Eg&&1!==kg({b:1},kg(Ng({},"a",{enumerable:!0,get:function(){Ng(this,"b",{value:3,enumerable:!1})}}),{b:2})).b)return!0;var e={},t={},i=Symbol(),n="abcdefghijklmnopqrst";return e[i]=7,n.split("").forEach((function(e){t[e]=e})),7!=kg({},e)[i]||vg(kg({},t)).join("")!=n}))?function(e,t){for(var i=Cg(e),n=arguments.length,r=1,o=Ag.f,s=Rg.f;n>r;)for(var a,c=bg(arguments[r++]),l=o?Dg(vg(c),o(c)):vg(c),d=l.length,u=0;d>u;)a=l[u++],Eg&&!Ig(s,c,a)||(i[a]=c[a]);return i}:kg,wg=be,Pg=hd,Lg=va,Mg=Be,xg=H,Vg=function(e,t,i,n){try{return n?t(wg(i)[0],i[1]):t(i)}catch(IU){Pg(e,"throw",IU)}},Ug=Yl,Fg=ia,Bg=Wt,Hg=n_,jg=cd,Gg=td,Wg=Array,Jg=l,zg=2147483647,Kg=/[^\0-\u007E]/,qg=/[.\u3002\uFF0E\uFF61]/g,Yg="Overflow: input needs wider integers to process",Qg=RangeError,Xg=Jg(qg.exec),$g=Math.floor,Zg=String.fromCharCode,eT=Jg("".charCodeAt),tT=Jg([].join),iT=Jg([].push),nT=Jg("".replace),rT=Jg("".split),oT=Jg("".toLowerCase),sT=function(e){return e+22+75*(e<26)},aT=function(e,t,i){var n=0;for(e=i?$g(e/700):e>>1,e+=$g(e/t);e>455;)e=$g(e/35),n+=36;return $g(n+36*e/(e+38))},cT=function(e){var t=[];e=function(e){for(var t=[],i=0,n=e.length;i<n;){var r=eT(e,i++);if(r>=55296&&r<=56319&&i<n){var o=eT(e,i++);56320==(64512&o)?iT(t,((1023&r)<<10)+(1023&o)+65536):(iT(t,r),i--)}else iT(t,r)}return t}(e);var i,n,r=e.length,o=128,s=0,a=72;for(i=0;i<e.length;i++)(n=e[i])<128&&iT(t,Zg(n));var c=t.length,l=c;for(c&&iT(t,"-");l<r;){var d=zg;for(i=0;i<e.length;i++)(n=e[i])>=o&&n<d&&(d=n);var u=l+1;if(d-o>$g((zg-s)/u))throw Qg(Yg);for(s+=(d-o)*u,o=d,i=0;i<e.length;i++){if((n=e[i])<o&&++s>zg)throw Qg(Yg);if(n==o){for(var h=s,p=36;;){var m=p<=a?1:p>=a+26?26:p-a;if(h<m)break;var _=h-m,f=36-m;iT(t,Zg(sT(m+_%f))),h=$g(_/f),p+=36}iT(t,Zg(sT(h))),a=aT(s,u,l==c),s=0,l++}}s++,o++}return tT(t,"")},lT=Ur,dT=Ne,uT=Xm,hT=b,pT=va,mT=l,_T=nr,fT=ys,gT=Ds,TT=W,ET=Og,ST=function(e){var t=xg(e),i=Fg(this),n=arguments.length,r=n>1?arguments[1]:void 0,o=void 0!==r;o&&(r=Lg(r,n>2?arguments[2]:void 0));var s,a,c,l,d,u,h=Gg(t),p=0;if(!h||this===Wg&&Ug(h))for(s=Bg(t),a=i?new this(s):Wg(s);s>p;p++)u=o?r(t[p],p):t[p],Hg(a,p,u);else for(d=(l=jg(t,h)).next,a=i?new this:[];!(c=Mg(d,l)).done;p++)u=o?Vg(l,r,[c.value,p],!0):c.value,Hg(a,p,u);return a.length=p,a},IT=l_,yT=Bp.codeAt,vT=function(e){var t,i,n=[],r=rT(nT(oT(e),qg,"."),".");for(t=0;t<r.length;t++)i=r[t],iT(n,Xg(Kg,i)?"xn--"+cT(i):i);return tT(n,".")},AT=gu,RT=so,CT=Ca,bT=Of,kT=ln,NT=kT.set,DT=kT.getterFor("URL"),OT=bT.URLSearchParams,wT=bT.getState,PT=hT.URL,LT=hT.TypeError,MT=hT.parseInt,xT=Math.floor,VT=Math.pow,UT=mT("".charAt),FT=mT(/./.exec),BT=mT([].join),HT=mT(1..toString),jT=mT([].pop),GT=mT([].push),WT=mT("".replace),JT=mT([].shift),zT=mT("".split),KT=mT("".slice),qT=mT("".toLowerCase),YT=mT([].unshift),QT="Invalid scheme",XT="Invalid host",$T="Invalid port",ZT=/[a-z]/i,eE=/[\d+-.a-z]/i,tE=/\d/,iE=/^0x/i,nE=/^[0-7]+$/,rE=/^\d+$/,oE=/^[\da-f]+$/i,sE=/[\0\t\n\r #%/:<>?@[\\\]^|]/,aE=/[\0\t\n\r #/:<>?@[\\\]^|]/,cE=/^[\u0000-\u0020]+/,lE=/(^|[^\u0000-\u0020])[\u0000-\u0020]+$/,dE=/[\t\n\r]/g,uE=function(e){var t,i,n,r;if("number"==typeof e){for(t=[],i=0;i<4;i++)YT(t,e%256),e=xT(e/256);return BT(t,".")}if("object"==typeof e){for(t="",n=function(e){for(var t=null,i=1,n=null,r=0,o=0;o<8;o++)0!==e[o]?(r>i&&(t=n,i=r),n=null,r=0):(null===n&&(n=o),++r);return r>i&&(t=n,i=r),t}(e),i=0;i<8;i++)r&&0===e[i]||(r&&(r=!1),n===i?(t+=i?":":"::",r=!0):(t+=HT(e[i],16),i<7&&(t+=":")));return"["+t+"]"}return e},hE={},pE=ET({},hE,{" ":1,'"':1,"<":1,">":1,"`":1}),mE=ET({},pE,{"#":1,"?":1,"{":1,"}":1}),_E=ET({},mE,{"/":1,":":1,";":1,"=":1,"@":1,"[":1,"\\":1,"]":1,"^":1,"|":1}),fE=function(e,t){var i=yT(e,0);return i>32&&i<127&&!TT(t,e)?e:encodeURIComponent(e)},gE={ftp:21,file:null,http:80,https:443,ws:80,wss:443},TE=function(e,t){var i;return 2==e.length&&FT(ZT,UT(e,0))&&(":"==(i=UT(e,1))||!t&&"|"==i)},EE=function(e){var t;return e.length>1&&TE(KT(e,0,2))&&(2==e.length||"/"===(t=UT(e,2))||"\\"===t||"?"===t||"#"===t)},SE=function(e){return"."===e||"%2e"===qT(e)},IE={},yE={},vE={},AE={},RE={},CE={},bE={},kE={},NE={},DE={},OE={},wE={},PE={},LE={},ME={},xE={},VE={},UE={},FE={},BE={},HE={},jE=function(e,t,i){var n,r,o,s=AT(e);if(t){if(r=this.parse(s))throw LT(r);this.searchParams=null}else{if(void 0!==i&&(n=new jE(i,!0)),r=this.parse(s,null,n))throw LT(r);(o=wT(new OT)).bindURL(this),this.searchParams=o}};jE.prototype={type:"URL",parse:function(e,t,i){var n,r,o,s,a,c=this,l=t||IE,d=0,u="",h=!1,p=!1,m=!1;for(e=AT(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=WT(e,cE,""),e=WT(e,lE,"$1")),e=WT(e,dE,""),n=ST(e);d<=n.length;){switch(r=n[d],l){case IE:if(!r||!FT(ZT,r)){if(t)return QT;l=vE;continue}u+=qT(r),l=yE;break;case yE:if(r&&(FT(eE,r)||"+"==r||"-"==r||"."==r))u+=qT(r);else{if(":"!=r){if(t)return QT;u="",l=vE,d=0;continue}if(t&&(c.isSpecial()!=TT(gE,u)||"file"==u&&(c.includesCredentials()||null!==c.port)||"file"==c.scheme&&!c.host))return;if(c.scheme=u,t)return void(c.isSpecial()&&gE[c.scheme]==c.port&&(c.port=null));u="","file"==c.scheme?l=LE:c.isSpecial()&&i&&i.scheme==c.scheme?l=AE:c.isSpecial()?l=kE:"/"==n[d+1]?(l=RE,d++):(c.cannotBeABaseURL=!0,GT(c.path,""),l=FE)}break;case vE:if(!i||i.cannotBeABaseURL&&"#"!=r)return QT;if(i.cannotBeABaseURL&&"#"==r){c.scheme=i.scheme,c.path=IT(i.path),c.query=i.query,c.fragment="",c.cannotBeABaseURL=!0,l=HE;break}l="file"==i.scheme?LE:CE;continue;case AE:if("/"!=r||"/"!=n[d+1]){l=CE;continue}l=NE,d++;break;case RE:if("/"==r){l=DE;break}l=UE;continue;case CE:if(c.scheme=i.scheme,r==Tg)c.username=i.username,c.password=i.password,c.host=i.host,c.port=i.port,c.path=IT(i.path),c.query=i.query;else if("/"==r||"\\"==r&&c.isSpecial())l=bE;else if("?"==r)c.username=i.username,c.password=i.password,c.host=i.host,c.port=i.port,c.path=IT(i.path),c.query="",l=BE;else{if("#"!=r){c.username=i.username,c.password=i.password,c.host=i.host,c.port=i.port,c.path=IT(i.path),c.path.length--,l=UE;continue}c.username=i.username,c.password=i.password,c.host=i.host,c.port=i.port,c.path=IT(i.path),c.query=i.query,c.fragment="",l=HE}break;case bE:if(!c.isSpecial()||"/"!=r&&"\\"!=r){if("/"!=r){c.username=i.username,c.password=i.password,c.host=i.host,c.port=i.port,l=UE;continue}l=DE}else l=NE;break;case kE:if(l=NE,"/"!=r||"/"!=UT(u,d+1))continue;d++;break;case NE:if("/"!=r&&"\\"!=r){l=DE;continue}break;case DE:if("@"==r){h&&(u="%40"+u),h=!0,o=ST(u);for(var _=0;_<o.length;_++){var f=o[_];if(":"!=f||m){var g=fE(f,_E);m?c.password+=g:c.username+=g}else m=!0}u=""}else if(r==Tg||"/"==r||"?"==r||"#"==r||"\\"==r&&c.isSpecial()){if(h&&""==u)return"Invalid authority";d-=ST(u).length+1,u="",l=OE}else u+=r;break;case OE:case wE:if(t&&"file"==c.scheme){l=xE;continue}if(":"!=r||p){if(r==Tg||"/"==r||"?"==r||"#"==r||"\\"==r&&c.isSpecial()){if(c.isSpecial()&&""==u)return XT;if(t&&""==u&&(c.includesCredentials()||null!==c.port))return;if(s=c.parseHost(u))return s;if(u="",l=VE,t)return;continue}"["==r?p=!0:"]"==r&&(p=!1),u+=r}else{if(""==u)return XT;if(s=c.parseHost(u))return s;if(u="",l=PE,t==wE)return}break;case PE:if(!FT(tE,r)){if(r==Tg||"/"==r||"?"==r||"#"==r||"\\"==r&&c.isSpecial()||t){if(""!=u){var T=MT(u,10);if(T>65535)return $T;c.port=c.isSpecial()&&T===gE[c.scheme]?null:T,u=""}if(t)return;l=VE;continue}return $T}u+=r;break;case LE:if(c.scheme="file","/"==r||"\\"==r)l=ME;else{if(!i||"file"!=i.scheme){l=UE;continue}if(r==Tg)c.host=i.host,c.path=IT(i.path),c.query=i.query;else if("?"==r)c.host=i.host,c.path=IT(i.path),c.query="",l=BE;else{if("#"!=r){EE(BT(IT(n,d),""))||(c.host=i.host,c.path=IT(i.path),c.shortenPath()),l=UE;continue}c.host=i.host,c.path=IT(i.path),c.query=i.query,c.fragment="",l=HE}}break;case ME:if("/"==r||"\\"==r){l=xE;break}i&&"file"==i.scheme&&!EE(BT(IT(n,d),""))&&(TE(i.path[0],!0)?GT(c.path,i.path[0]):c.host=i.host),l=UE;continue;case xE:if(r==Tg||"/"==r||"\\"==r||"?"==r||"#"==r){if(!t&&TE(u))l=UE;else if(""==u){if(c.host="",t)return;l=VE}else{if(s=c.parseHost(u))return s;if("localhost"==c.host&&(c.host=""),t)return;u="",l=VE}continue}u+=r;break;case VE:if(c.isSpecial()){if(l=UE,"/"!=r&&"\\"!=r)continue}else if(t||"?"!=r)if(t||"#"!=r){if(r!=Tg&&(l=UE,"/"!=r))continue}else c.fragment="",l=HE;else c.query="",l=BE;break;case UE:if(r==Tg||"/"==r||"\\"==r&&c.isSpecial()||!t&&("?"==r||"#"==r)){if(".."===(a=qT(a=u))||"%2e."===a||".%2e"===a||"%2e%2e"===a?(c.shortenPath(),"/"==r||"\\"==r&&c.isSpecial()||GT(c.path,"")):SE(u)?"/"==r||"\\"==r&&c.isSpecial()||GT(c.path,""):("file"==c.scheme&&!c.path.length&&TE(u)&&(c.host&&(c.host=""),u=UT(u,0)+":"),GT(c.path,u)),u="","file"==c.scheme&&(r==Tg||"?"==r||"#"==r))for(;c.path.length>1&&""===c.path[0];)JT(c.path);"?"==r?(c.query="",l=BE):"#"==r&&(c.fragment="",l=HE)}else u+=fE(r,mE);break;case FE:"?"==r?(c.query="",l=BE):"#"==r?(c.fragment="",l=HE):r!=Tg&&(c.path[0]+=fE(r,hE));break;case BE:t||"#"!=r?r!=Tg&&("'"==r&&c.isSpecial()?c.query+="%27":c.query+="#"==r?"%23":fE(r,hE)):(c.fragment="",l=HE);break;case HE:r!=Tg&&(c.fragment+=fE(r,pE))}d++}},parseHost:function(e){var t,i,n;if("["==UT(e,0)){if("]"!=UT(e,e.length-1))return XT;if(t=function(e){var t,i,n,r,o,s,a,c=[0,0,0,0,0,0,0,0],l=0,d=null,u=0,h=function(){return UT(e,u)};if(":"==h()){if(":"!=UT(e,1))return;u+=2,d=++l}for(;h();){if(8==l)return;if(":"!=h()){for(t=i=0;i<4&&FT(oE,h());)t=16*t+MT(h(),16),u++,i++;if("."==h()){if(0==i)return;if(u-=i,l>6)return;for(n=0;h();){if(r=null,n>0){if(!("."==h()&&n<4))return;u++}if(!FT(tE,h()))return;for(;FT(tE,h());){if(o=MT(h(),10),null===r)r=o;else{if(0==r)return;r=10*r+o}if(r>255)return;u++}c[l]=256*c[l]+r,2!=++n&&4!=n||l++}if(4!=n)return;break}if(":"==h()){if(u++,!h())return}else if(h())return;c[l++]=t}else{if(null!==d)return;u++,d=++l}}if(null!==d)for(s=l-d,l=7;0!=l&&s>0;)a=c[l],c[l--]=c[d+s-1],c[d+--s]=a;else if(8!=l)return;return c}(KT(e,1,-1)),!t)return XT;this.host=t}else if(this.isSpecial()){if(e=vT(e),FT(sE,e))return XT;if(t=function(e){var t,i,n,r,o,s,a,c=zT(e,".");if(c.length&&""==c[c.length-1]&&c.length--,(t=c.length)>4)return e;for(i=[],n=0;n<t;n++){if(""==(r=c[n]))return e;if(o=10,r.length>1&&"0"==UT(r,0)&&(o=FT(iE,r)?16:8,r=KT(r,8==o?1:2)),""===r)s=0;else{if(!FT(10==o?rE:8==o?nE:oE,r))return e;s=MT(r,o)}GT(i,s)}for(n=0;n<t;n++)if(s=i[n],n==t-1){if(s>=VT(256,5-t))return null}else if(s>255)return null;for(a=jT(i),n=0;n<i.length;n++)a+=i[n]*VT(256,3-n);return a}(e),null===t)return XT;this.host=t}else{if(FT(aE,e))return XT;for(t="",i=ST(e),n=0;n<i.length;n++)t+=fE(i[n],hE);this.host=t}},cannotHaveUsernamePasswordPort:function(){return!this.host||this.cannotBeABaseURL||"file"==this.scheme},includesCredentials:function(){return""!=this.username||""!=this.password},isSpecial:function(){return TT(gE,this.scheme)},shortenPath:function(){var e=this.path,t=e.length;!t||"file"==this.scheme&&1==t&&TE(e[0],!0)||e.length--},serialize:function(){var e=this,t=e.scheme,i=e.username,n=e.password,r=e.host,o=e.port,s=e.path,a=e.query,c=e.fragment,l=t+":";return null!==r?(l+="//",e.includesCredentials()&&(l+=i+(n?":"+n:"")+"@"),l+=uE(r),null!==o&&(l+=":"+o)):"file"==t&&(l+="//"),l+=e.cannotBeABaseURL?s[0]:s.length?"/"+BT(s,"/"):"",null!==a&&(l+="?"+a),null!==c&&(l+="#"+c),l},setHref:function(e){var t=this.parse(e);if(t)throw LT(t);this.searchParams.update()},getOrigin:function(){var e=this.scheme,t=this.port;if("blob"==e)try{return new GE(e.path[0]).origin}catch(IU){return"null"}return"file"!=e&&this.isSpecial()?e+"://"+uE(this.host)+(null!==t?":"+t:""):"null"},getProtocol:function(){return this.scheme+":"},setProtocol:function(e){this.parse(AT(e)+":",IE)},getUsername:function(){return this.username},setUsername:function(e){var t=ST(AT(e));if(!this.cannotHaveUsernamePasswordPort()){this.username="";for(var i=0;i<t.length;i++)this.username+=fE(t[i],_E)}},getPassword:function(){return this.password},setPassword:function(e){var t=ST(AT(e));if(!this.cannotHaveUsernamePasswordPort()){this.password="";for(var i=0;i<t.length;i++)this.password+=fE(t[i],_E)}},getHost:function(){var e=this.host,t=this.port;return null===e?"":null===t?uE(e):uE(e)+":"+t},setHost:function(e){this.cannotBeABaseURL||this.parse(e,OE)},getHostname:function(){var e=this.host;return null===e?"":uE(e)},setHostname:function(e){this.cannotBeABaseURL||this.parse(e,wE)},getPort:function(){var e=this.port;return null===e?"":AT(e)},setPort:function(e){this.cannotHaveUsernamePasswordPort()||(""==(e=AT(e))?this.port=null:this.parse(e,PE))},getPathname:function(){var e=this.path;return this.cannotBeABaseURL?e[0]:e.length?"/"+BT(e,"/"):""},setPathname:function(e){this.cannotBeABaseURL||(this.path=[],this.parse(e,VE))},getSearch:function(){var e=this.query;return e?"?"+e:""},setSearch:function(e){""==(e=AT(e))?this.query=null:("?"==UT(e,0)&&(e=KT(e,1)),this.query="",this.parse(e,BE)),this.searchParams.update()},getSearchParams:function(){return this.searchParams.facade},getHash:function(){var e=this.fragment;return e?"#"+e:""},setHash:function(e){""!=(e=AT(e))?("#"==UT(e,0)&&(e=KT(e,1)),this.fragment="",this.parse(e,HE)):this.fragment=null},update:function(){this.query=this.searchParams.serialize()||null}};var GE=function(e){var t=gT(this,WE),i=CT(arguments.length,1)>1?arguments[1]:void 0,n=NT(t,new jE(e,!1,i));dT||(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())},WE=GE.prototype,JE=function(e,t){return{get:function(){return DT(this)[e]()},set:t&&function(e){return DT(this)[t](e)},configurable:!0,enumerable:!0}};if(dT&&(fT(WE,"href",JE("serialize","setHref")),fT(WE,"origin",JE("getOrigin")),fT(WE,"protocol",JE("getProtocol","setProtocol")),fT(WE,"username",JE("getUsername","setUsername")),fT(WE,"password",JE("getPassword","setPassword")),fT(WE,"host",JE("getHost","setHost")),fT(WE,"hostname",JE("getHostname","setHostname")),fT(WE,"port",JE("getPort","setPort")),fT(WE,"pathname",JE("getPathname","setPathname")),fT(WE,"search",JE("getSearch","setSearch")),fT(WE,"searchParams",JE("getSearchParams")),fT(WE,"hash",JE("getHash","setHash"))),_T(WE,"toJSON",(function(){return DT(this).serialize()}),{enumerable:!0}),_T(WE,"toString",(function(){return DT(this).serialize()}),{enumerable:!0}),PT){var zE=PT.createObjectURL,KE=PT.revokeObjectURL;zE&&_T(GE,"createObjectURL",pT(zE,PT)),KE&&_T(GE,"revokeObjectURL",pT(KE,PT))}RT(GE,"URL"),lT({global:!0,constructor:!0,forced:!uT,sham:!dT},{URL:GE});var qE="undefined"!=typeof ArrayBuffer&&"undefined"!=typeof DataView,YE=Mt,QE=jt,XE=RangeError,$E=function(e){if(void 0===e)return 0;var t=YE(e),i=QE(t);if(t!==i)throw XE("Wrong length or index");return i},ZE=Array,eS=Math.abs,tS=Math.pow,iS=Math.floor,nS=Math.log,rS=Math.LN2,oS={pack:function(e,t,i){var n,r,o,s=ZE(i),a=8*i-t-1,c=(1<<a)-1,l=c>>1,d=23===t?tS(2,-24)-tS(2,-77):0,u=e<0||0===e&&1/e<0?1:0,h=0;for((e=eS(e))!=e||1/0===e?(r=e!=e?1:0,n=c):(n=iS(nS(e)/rS),e*(o=tS(2,-n))<1&&(n--,o*=2),(e+=n+l>=1?d/o:d*tS(2,1-l))*o>=2&&(n++,o/=2),n+l>=c?(r=0,n=c):n+l>=1?(r=(e*o-1)*tS(2,t),n+=l):(r=e*tS(2,l-1)*tS(2,t),n=0));t>=8;)s[h++]=255&r,r/=256,t-=8;for(n=n<<t|r,a+=t;a>0;)s[h++]=255&n,n/=256,a-=8;return s[--h]|=128*u,s},unpack:function(e,t){var i,n=e.length,r=8*n-t-1,o=(1<<r)-1,s=o>>1,a=r-7,c=n-1,l=e[c--],d=127&l;for(l>>=7;a>0;)d=256*d+e[c--],a-=8;for(i=d&(1<<-a)-1,d>>=-a,a+=t;a>0;)i=256*i+e[c--],a-=8;if(0===d)d=1-s;else{if(d===o)return i?NaN:l?-1/0:1/0;i+=tS(2,t),d-=s}return(l?-1:1)*i*tS(2,d-t)}},sS=H,aS=Ft,cS=Wt,lS=function(e){for(var t=sS(this),i=cS(t),n=arguments.length,r=aS(n>1?arguments[1]:void 0,i),o=n>2?arguments[2]:void 0,s=void 0===o?i:aS(o,i);s>r;)t[r++]=e;return t},dS=b,uS=l,hS=Ne,pS=qE,mS=On,_S=qi,fS=ys,gS=Zm,TS=n,ES=Ds,SS=Mt,IS=jt,yS=$E,vS=oS,AS=Kr,RS=vo,CS=rr.f,bS=lS,kS=l_,NS=so,DS=ln,OS=mS.PROPER,wS=mS.CONFIGURABLE,PS="ArrayBuffer",LS="DataView",MS="prototype",xS="Wrong index",VS=DS.getterFor(PS),US=DS.getterFor(LS),FS=DS.set,BS=dS[PS],HS=BS,jS=HS&&HS[MS],GS=dS[LS],WS=GS&&GS[MS],JS=Object.prototype,zS=dS.Array,KS=dS.RangeError,qS=uS(bS),YS=uS([].reverse),QS=vS.pack,XS=vS.unpack,$S=function(e){return[255&e]},ZS=function(e){return[255&e,e>>8&255]},eI=function(e){return[255&e,e>>8&255,e>>16&255,e>>24&255]},tI=function(e){return e[3]<<24|e[2]<<16|e[1]<<8|e[0]},iI=function(e){return QS(e,23,4)},nI=function(e){return QS(e,52,8)},rI=function(e,t,i){fS(e[MS],t,{configurable:!0,get:function(){return i(this)[t]}})},oI=function(e,t,i,n){var r=yS(i),o=US(e);if(r+t>o.byteLength)throw KS(xS);var s=o.bytes,a=r+o.byteOffset,c=kS(s,a,a+t);return n?c:YS(c)},sI=function(e,t,i,n,r,o){var s=yS(i),a=US(e);if(s+t>a.byteLength)throw KS(xS);for(var c=a.bytes,l=s+a.byteOffset,d=n(+r),u=0;u<t;u++)c[l+u]=d[o?u:t-u-1]};if(pS){var aI=OS&&BS.name!==PS;if(TS((function(){BS(1)}))&&TS((function(){new BS(-1)}))&&!TS((function(){return new BS,new BS(1.5),new BS(NaN),1!=BS.length||aI&&!wS})))aI&&wS&&_S(BS,"name",PS);else{(HS=function(e){return ES(this,jS),new BS(yS(e))})[MS]=jS;for(var cI,lI=CS(BS),dI=0;lI.length>dI;)(cI=lI[dI++])in HS||_S(HS,cI,BS[cI]);jS.constructor=HS}RS&&AS(WS)!==JS&&RS(WS,JS);var uI=new GS(new HS(2)),hI=uS(WS.setInt8);uI.setInt8(0,2147483648),uI.setInt8(1,2147483649),!uI.getInt8(0)&&uI.getInt8(1)||gS(WS,{setInt8:function(e,t){hI(this,e,t<<24>>24)},setUint8:function(e,t){hI(this,e,t<<24>>24)}},{unsafe:!0})}else jS=(HS=function(e){ES(this,jS);var t=yS(e);FS(this,{type:PS,bytes:qS(zS(t),0),byteLength:t}),hS||(this.byteLength=t,this.detached=!1)})[MS],WS=(GS=function(e,t,i){ES(this,WS),ES(e,jS);var n=VS(e),r=n.byteLength,o=SS(t);if(o<0||o>r)throw KS("Wrong offset");if(o+(i=void 0===i?r-o:IS(i))>r)throw KS("Wrong length");FS(this,{type:LS,buffer:e,byteLength:i,byteOffset:o,bytes:n.bytes}),hS||(this.buffer=e,this.byteLength=i,this.byteOffset=o)})[MS],hS&&(rI(HS,"byteLength",VS),rI(GS,"buffer",US),rI(GS,"byteLength",US),rI(GS,"byteOffset",US)),gS(WS,{getInt8:function(e){return oI(this,1,e)[0]<<24>>24},getUint8:function(e){return oI(this,1,e)[0]},getInt16:function(e){var t=oI(this,2,e,arguments.length>1?arguments[1]:void 0);return(t[1]<<8|t[0])<<16>>16},getUint16:function(e){var t=oI(this,2,e,arguments.length>1?arguments[1]:void 0);return t[1]<<8|t[0]},getInt32:function(e){return tI(oI(this,4,e,arguments.length>1?arguments[1]:void 0))},getUint32:function(e){return tI(oI(this,4,e,arguments.length>1?arguments[1]:void 0))>>>0},getFloat32:function(e){return XS(oI(this,4,e,arguments.length>1?arguments[1]:void 0),23)},getFloat64:function(e){return XS(oI(this,8,e,arguments.length>1?arguments[1]:void 0),52)},setInt8:function(e,t){sI(this,1,e,$S,t)},setUint8:function(e,t){sI(this,1,e,$S,t)},setInt16:function(e,t){sI(this,2,e,ZS,t,arguments.length>2?arguments[2]:void 0)},setUint16:function(e,t){sI(this,2,e,ZS,t,arguments.length>2?arguments[2]:void 0)},setInt32:function(e,t){sI(this,4,e,eI,t,arguments.length>2?arguments[2]:void 0)},setUint32:function(e,t){sI(this,4,e,eI,t,arguments.length>2?arguments[2]:void 0)},setFloat32:function(e,t){sI(this,4,e,iI,t,arguments.length>2?arguments[2]:void 0)},setFloat64:function(e,t){sI(this,8,e,nI,t,arguments.length>2?arguments[2]:void 0)}});NS(HS,PS),NS(GS,LS);var pI={ArrayBuffer:HS,DataView:GS},mI=bs,_I="ArrayBuffer",fI=pI[_I];Ur({global:!0,constructor:!0,forced:b[_I]!==fI},{ArrayBuffer:fI}),mI(_I);var gI=Ur,TI=Ea,EI=n,SI=be,II=Ft,yI=jt,vI=ua,AI=pI.ArrayBuffer,RI=pI.DataView,CI=RI.prototype,bI=TI(AI.prototype.slice),kI=TI(CI.getUint8),NI=TI(CI.setUint8);gI({target:"ArrayBuffer",proto:!0,unsafe:!0,forced:EI((function(){return!new AI(2).slice(1,void 0).byteLength}))},{slice:function(e,t){if(bI&&void 0===t)return bI(SI(this),e);for(var i=SI(this).byteLength,n=II(e,i),r=II(void 0===t?i:t,i),o=new(vI(this,AI))(yI(r-n)),s=new RI(this),a=new RI(o),c=0;n<r;)NI(a,c++,kI(s,n++));return o}});var DI,OI,wI,PI={},LI={get exports(){return PI},set exports(e){PI=e}},MI=qE,xI=Ne,VI=b,UI=Se,FI=ve,BI=W,HI=Us,jI=Xe,GI=qi,WI=nr,JI=ys,zI=We,KI=Kr,qI=vo,YI=fe,QI=Y,XI=ln.enforce,$I=ln.get,ZI=VI.Int8Array,ey=ZI&&ZI.prototype,ty=VI.Uint8ClampedArray,iy=ty&&ty.prototype,ny=ZI&&KI(ZI),ry=ey&&KI(ey),oy=Object.prototype,sy=VI.TypeError,ay=YI("toStringTag"),cy=QI("TYPED_ARRAY_TAG"),ly="TypedArrayConstructor",dy=MI&&!!qI&&"Opera"!==HI(VI.opera),uy=!1,hy={Int8Array:1,Uint8Array:1,Uint8ClampedArray:1,Int16Array:2,Uint16Array:2,Int32Array:4,Uint32Array:4,Float32Array:4,Float64Array:8},py={BigInt64Array:8,BigUint64Array:8},my=function(e){var t=KI(e);if(FI(t)){var i=$I(t);return i&&BI(i,ly)?i[ly]:my(t)}},_y=function(e){if(!FI(e))return!1;var t=HI(e);return BI(hy,t)||BI(py,t)};for(DI in hy)(wI=(OI=VI[DI])&&OI.prototype)?XI(wI)[ly]=OI:dy=!1;for(DI in py)(wI=(OI=VI[DI])&&OI.prototype)&&(XI(wI)[ly]=OI);if((!dy||!UI(ny)||ny===Function.prototype)&&(ny=function(){throw sy("Incorrect invocation")},dy))for(DI in hy)VI[DI]&&qI(VI[DI],ny);if((!dy||!ry||ry===oy)&&(ry=ny.prototype,dy))for(DI in hy)VI[DI]&&qI(VI[DI].prototype,ry);if(dy&&KI(iy)!==ry&&qI(iy,ry),xI&&!BI(ry,ay))for(DI in uy=!0,JI(ry,ay,{configurable:!0,get:function(){return FI(this)?this[cy]:void 0}}),hy)VI[DI]&&GI(VI[DI],cy,DI);var fy={NATIVE_ARRAY_BUFFER_VIEWS:dy,TYPED_ARRAY_TAG:uy&&cy,aTypedArray:function(e){if(_y(e))return e;throw sy("Target is not a typed array")},aTypedArrayConstructor:function(e){if(UI(e)&&(!qI||zI(ny,e)))return e;throw sy(jI(e)+" is not a typed array constructor")},exportTypedArrayMethod:function(e,t,i,n){if(xI){if(i)for(var r in hy){var o=VI[r];if(o&&BI(o.prototype,e))try{delete o.prototype[e]}catch(IU){try{o.prototype[e]=t}catch(a){}}}ry[e]&&!i||WI(ry,e,i?t:dy&&ey[e]||t,n)}},exportTypedArrayStaticMethod:function(e,t,i){var n,r;if(xI){if(qI){if(i)for(n in hy)if((r=VI[n])&&BI(r,e))try{delete r[e]}catch(IU){}if(ny[e]&&!i)return;try{return WI(ny,e,i?t:dy&&ny[e]||t)}catch(IU){}}for(n in hy)!(r=VI[n])||r[e]&&!i||WI(r,e,t)}},getTypedArrayConstructor:my,isView:function(e){if(!FI(e))return!1;var t=HI(e);return"DataView"===t||BI(hy,t)||BI(py,t)},isTypedArray:_y,TypedArray:ny,TypedArrayPrototype:ry},gy=b,Ty=n,Ey=Od,Sy=fy.NATIVE_ARRAY_BUFFER_VIEWS,Iy=gy.ArrayBuffer,yy=gy.Int8Array,vy=!Sy||!Ty((function(){yy(1)}))||!Ty((function(){new yy(-1)}))||!Ey((function(e){new yy,new yy(null),new yy(1.5),new yy(e)}),!0)||Ty((function(){return 1!==new yy(new Iy(2),1,void 0).length})),Ay=ve,Ry=Math.floor,Cy=Number.isInteger||function(e){return!Ay(e)&&isFinite(e)&&Ry(e)===e},by=Mt,ky=RangeError,Ny=function(e){var t=by(e);if(t<0)throw ky("The argument can't be less than 0");return t},Dy=RangeError,Oy=function(e,t){var i=Ny(e);if(i%t)throw Dy("Wrong offset");return i},wy=Us,Py=ft,Ly=TypeError,My=function(e){var t=Py(e,"number");if("number"==typeof t)throw Ly("Can't convert number to bigint");return BigInt(t)},xy=va,Vy=Be,Uy=sa,Fy=H,By=Wt,Hy=cd,jy=td,Gy=Yl,Wy=function(e){var t=wy(e);return"BigInt64Array"==t||"BigUint64Array"==t},Jy=fy.aTypedArrayConstructor,zy=My,Ky=Ur,qy=b,Yy=Be,Qy=Ne,Xy=vy,$y=fy,Zy=pI,ev=Ds,tv=Ji,iv=qi,nv=Cy,rv=jt,ov=$E,sv=Oy,av=Et,cv=W,lv=Us,dv=ve,uv=Ye,hv=Oi,pv=We,mv=vo,_v=rr.f,fv=function(e){var t,i,n,r,o,s,a,c,l=Uy(this),d=Fy(e),u=arguments.length,h=u>1?arguments[1]:void 0,p=void 0!==h,m=jy(d);if(m&&!Gy(m))for(c=(a=Hy(d,m)).next,d=[];!(s=Vy(c,a)).done;)d.push(s.value);for(p&&u>2&&(h=xy(h,arguments[2])),i=By(d),n=new(Jy(l))(i),r=Wy(n),t=0;i>t;t++)o=p?h(d[t],t):d[t],n[t]=r?zy(o):+o;return n},gv=op.forEach,Tv=bs,Ev=ys,Sv=Oe,Iv=dn,yv=du,vv=ln.get,Av=ln.set,Rv=ln.enforce,Cv=Sv.f,bv=Iv.f,kv=Math.round,Nv=qy.RangeError,Dv=Zy.ArrayBuffer,Ov=Dv.prototype,wv=Zy.DataView,Pv=$y.NATIVE_ARRAY_BUFFER_VIEWS,Lv=$y.TYPED_ARRAY_TAG,Mv=$y.TypedArray,xv=$y.TypedArrayPrototype,Vv=$y.aTypedArrayConstructor,Uv=$y.isTypedArray,Fv="BYTES_PER_ELEMENT",Bv="Wrong length",Hv=function(e,t){Vv(e);for(var i=0,n=t.length,r=new e(n);n>i;)r[i]=t[i++];return r},jv=function(e,t){Ev(e,t,{configurable:!0,get:function(){return vv(this)[t]}})},Gv=function(e){var t;return pv(Ov,e)||"ArrayBuffer"==(t=lv(e))||"SharedArrayBuffer"==t},Wv=function(e,t){return Uv(e)&&!uv(t)&&t in e&&nv(+t)&&t>=0},Jv=function(e,t){return t=av(t),Wv(e,t)?tv(2,e[t]):bv(e,t)},zv=function(e,t,i){return t=av(t),!(Wv(e,t)&&dv(i)&&cv(i,"value"))||cv(i,"get")||cv(i,"set")||i.configurable||cv(i,"writable")&&!i.writable||cv(i,"enumerable")&&!i.enumerable?Cv(e,t,i):(e[t]=i.value,e)};Qy?(Pv||(Iv.f=Jv,Sv.f=zv,jv(xv,"buffer"),jv(xv,"byteOffset"),jv(xv,"byteLength"),jv(xv,"length")),Ky({target:"Object",stat:!0,forced:!Pv},{getOwnPropertyDescriptor:Jv,defineProperty:zv}),LI.exports=function(e,t,i){var n=e.match(/\d+/)[0]/8,r=e+(i?"Clamped":"")+"Array",o="get"+e,s="set"+e,a=qy[r],c=a,l=c&&c.prototype,d={},u=function(e,t){Cv(e,t,{get:function(){return function(e,t){var i=vv(e);return i.view[o](t*n+i.byteOffset,!0)}(this,t)},set:function(e){return function(e,t,r){var o=vv(e);i&&(r=(r=kv(r))<0?0:r>255?255:255&r),o.view[s](t*n+o.byteOffset,r,!0)}(this,t,e)},enumerable:!0})};Pv?Xy&&(c=t((function(e,t,i,r){return ev(e,l),yv(dv(t)?Gv(t)?void 0!==r?new a(t,sv(i,n),r):void 0!==i?new a(t,sv(i,n)):new a(t):Uv(t)?Hv(c,t):Yy(fv,c,t):new a(ov(t)),e,c)})),mv&&mv(c,Mv),gv(_v(a),(function(e){e in c||iv(c,e,a[e])})),c.prototype=l):(c=t((function(e,t,i,r){ev(e,l);var o,s,a,d=0,h=0;if(dv(t)){if(!Gv(t))return Uv(t)?Hv(c,t):Yy(fv,c,t);o=t,h=sv(i,n);var p=t.byteLength;if(void 0===r){if(p%n)throw Nv(Bv);if((s=p-h)<0)throw Nv(Bv)}else if((s=rv(r)*n)+h>p)throw Nv(Bv);a=s/n}else a=ov(t),o=new Dv(s=a*n);for(Av(e,{buffer:o,byteOffset:h,byteLength:s,length:a,view:new wv(o)});d<a;)u(e,d++)})),mv&&mv(c,Mv),l=c.prototype=hv(xv)),l.constructor!==c&&iv(l,"constructor",c),Rv(l).TypedArrayConstructor=c,Lv&&iv(l,Lv,r);var h=c!=a;d[r]=c,Ky({global:!0,constructor:!0,forced:h,sham:!Pv},d),Fv in c||iv(c,Fv,n),Fv in l||iv(l,Fv,n),Tv(r)}):LI.exports=function(){},PI("Float32",(function(e){return function(t,i,n){return e(this,t,i,n)}}));var Kv=lS,qv=My,Yv=Us,Qv=Be,Xv=n,$v=fy.aTypedArray,Zv=fy.exportTypedArrayMethod,eA=l("".slice);Zv("fill",(function(e){var t=arguments.length;$v(this);var i="Big"===eA(Yv(this),0,3)?qv(e):+e;return Qv(Kv,this,i,t>1?arguments[1]:void 0,t>2?arguments[2]:void 0)}),Xv((function(){var e=0;return new Int8Array(2).fill({valueOf:function(){return e++}}),1!==e})));var tA=b,iA=Be,nA=fy,rA=Wt,oA=Oy,sA=H,aA=n,cA=tA.RangeError,lA=tA.Int8Array,dA=lA&&lA.prototype,uA=dA&&dA.set,hA=nA.aTypedArray,pA=nA.exportTypedArrayMethod,mA=!aA((function(){var e=new Uint8ClampedArray(2);return iA(uA,e,{length:1,0:3},1),3!==e[1]})),_A=mA&&nA.NATIVE_ARRAY_BUFFER_VIEWS&&aA((function(){var e=new lA(2);return e.set(1),e.set("2",1),0!==e[0]||2!==e[1]}));pA("set",(function(e){hA(this);var t=oA(arguments.length>1?arguments[1]:void 0,1),i=sA(e);if(mA)return iA(uA,this,i,t);var n=this.length,r=rA(i),o=0;if(r+t>n)throw cA("Wrong length");for(;o<r;)this[t+o]=i[o++]}),!mA||_A);var fA=Q.match(/firefox\/(\d+)/i),gA=!!fA&&+fA[1],TA=/MSIE|Trident/.test(Q),EA=Q.match(/AppleWebKit\/(\d+)\./),SA=!!EA&&+EA[1],IA=Ea,yA=n,vA=tt,AA=__,RA=gA,CA=TA,bA=ne,kA=SA,NA=fy.aTypedArray,DA=fy.exportTypedArrayMethod,OA=b.Uint16Array,wA=OA&&IA(OA.prototype.sort),PA=!(!wA||yA((function(){wA(new OA(2),null)}))&&yA((function(){wA(new OA(2),{})}))),LA=!!wA&&!yA((function(){if(bA)return bA<74;if(RA)return RA<67;if(CA)return!0;if(kA)return kA<602;var e,t,i=new OA(516),n=Array(516);for(e=0;e<516;e++)t=e%4,i[e]=515-e,n[e]=e-2*t+3;for(wA(i,(function(e,t){return(e/4|0)-(t/4|0)})),e=0;e<516;e++)if(i[e]!==n[e])return!0}));DA("sort",(function(e){return void 0!==e&&vA(e),LA?wA(this,e):AA(NA(this),function(e){return function(t,i){return void 0!==e?+e(t,i)||0:i!=i?-1:t!=t?1:0===t&&0===i?1/t>0&&1/i<0?1:-1:t>i}}(e))}),!LA||PA);var MA=Xe,xA=TypeError,VA=Ur,UA=l,FA=tt,BA=H,HA=Wt,jA=function(e,t){if(!delete e[t])throw xA("Cannot delete property "+MA(t)+" of "+MA(e))},GA=gu,WA=n,JA=__,zA=ap,KA=gA,qA=TA,YA=ne,QA=SA,XA=[],$A=UA(XA.sort),ZA=UA(XA.push),eR=WA((function(){XA.sort(void 0)})),tR=WA((function(){XA.sort(null)})),iR=zA("sort"),nR=!WA((function(){if(YA)return YA<70;if(!(KA&&KA>3)){if(qA)return!0;if(QA)return QA<603;var e,t,i,n,r="";for(e=65;e<76;e++){switch(t=String.fromCharCode(e),e){case 66:case 69:case 70:case 72:i=3;break;case 68:case 71:i=4;break;default:i=2}for(n=0;n<47;n++)XA.push({k:t+n,v:i})}for(XA.sort((function(e,t){return t.v-e.v})),n=0;n<XA.length;n++)t=XA[n].k.charAt(0),r.charAt(r.length-1)!==t&&(r+=t);return"DGBEFHACIJK"!==r}}));VA({target:"Array",proto:!0,forced:eR||!tR||!iR||!nR},{sort:function(e){void 0!==e&&FA(e);var t=BA(this);if(nR)return void 0===e?$A(t):$A(t,e);var i,n,r=[],o=HA(t);for(n=0;n<o;n++)n in t&&ZA(r,t[n]);for(JA(r,function(e){return function(t,i){return void 0===i?-1:void 0===t?1:void 0!==e?+e(t,i)||0:GA(t)>GA(i)?1:-1}}(e)),i=HA(r),n=0;n<i;)t[n]=r[n++];for(;n<o;)jA(t,n++);return t}}),PI("Uint8",(function(e){return function(t,i,n){return e(this,t,i,n)}}));var rR=Ur,oR=Jh,sR=l([].reverse),aR=[1,2];rR({target:"Array",proto:!0,forced:String(aR)===String(aR.reverse())},{reverse:function(){return oR(this)&&(this.length=this.length),sR(this)}});var cR=Ur,lR=Nc,dR=n,uR=Ge,hR=Se,pR=ua,mR=nu,_R=nr,fR=lR&&lR.prototype;if(cR({target:"Promise",proto:!0,real:!0,forced:!!lR&&dR((function(){fR.finally.call({then:function(){}},(function(){}))}))},{finally:function(e){var t=pR(this,uR("Promise")),i=hR(e);return this.then(i?function(i){return mR(t,e()).then((function(){return i}))}:e,i?function(i){return mR(t,e()).then((function(){throw i}))}:e)}}),hR(lR)){var gR=uR("Promise").prototype.finally;fR.finally!==gR&&_R(fR,"finally",gR,{unsafe:!0})}var TR=Ur,ER=Be,SR=l,IR=y,yR=Se,vR=E,AR=mu,RR=gu,CR=rt,bR=Ru,kR=Qp,NR=fe("replace"),DR=TypeError,OR=SR("".indexOf);SR("".replace);var wR=SR("".slice),PR=Math.max,LR=function(e,t,i){return i>e.length?-1:""===t?i:OR(e,t,i)};TR({target:"String",proto:!0},{replaceAll:function(e,t){var i,n,r,o,s,a,c,l,d=IR(this),u=0,h=0,p="";if(!vR(e)){if(AR(e)&&(i=RR(IR(bR(e))),!~OR(i,"g")))throw DR("`.replaceAll` does not allow non-global regexes");if(n=CR(e,NR))return ER(n,e,d,t)}for(r=RR(d),o=RR(e),(s=yR(t))||(t=RR(t)),a=o.length,c=PR(1,a),u=LR(r,o,0);-1!==u;)l=s?RR(t(o,u,r)):kR(o,r,u,[],void 0,t),p+=wR(r,h,u)+l,h=u+a,u=LR(r,o,u+c);return h<r.length&&(p+=wR(r,h)),p}});let MR=!0,xR=!0;function VR(e,t,i){const n=e.match(t);return n&&n.length>=i&&parseInt(n[i],10)}function UR(e,t,i){if(!e.RTCPeerConnection)return;const n=e.RTCPeerConnection.prototype,r=n.addEventListener;n.addEventListener=function(e,n){if(e!==t)return r.apply(this,arguments);const o=e=>{const t=i(e);t&&(n.handleEvent?n.handleEvent(t):n(t))};return this._eventMap=this._eventMap||{},this._eventMap[t]||(this._eventMap[t]=new Map),this._eventMap[t].set(n,o),r.apply(this,[e,o])};const o=n.removeEventListener;n.removeEventListener=function(e,i){if(e!==t||!this._eventMap||!this._eventMap[t])return o.apply(this,arguments);if(!this._eventMap[t].has(i))return o.apply(this,arguments);const n=this._eventMap[t].get(i);return this._eventMap[t].delete(i),0===this._eventMap[t].size&&delete this._eventMap[t],0===Object.keys(this._eventMap).length&&delete this._eventMap,o.apply(this,[e,n])},Object.defineProperty(n,"on"+t,{get(){return this["_on"+t]},set(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 FR(e){return"boolean"!=typeof e?new Error("Argument type: "+typeof e+". Please use a boolean."):(MR=e,e?"adapter.js logging disabled":"adapter.js logging enabled")}function BR(e){return"boolean"!=typeof e?new Error("Argument type: "+typeof e+". Please use a boolean."):(xR=!e,"adapter.js deprecation warnings "+(e?"disabled":"enabled"))}function HR(){if("object"==typeof window){if(MR)return;"undefined"!=typeof console&&"function"==typeof console.log&&console.log.apply(console,arguments)}}function jR(e,t){xR&&console.warn(e+" is deprecated, please use "+t+" instead.")}function GR(e){return"[object Object]"===Object.prototype.toString.call(e)}function WR(e){return GR(e)?Object.keys(e).reduce((function(t,i){const n=GR(e[i]),r=n?WR(e[i]):e[i],o=n&&!Object.keys(r).length;return void 0===r||o?t:Object.assign(t,{[i]:r})}),{}):e}function JR(e,t,i){t&&!i.has(t.id)&&(i.set(t.id,t),Object.keys(t).forEach((n=>{n.endsWith("Id")?JR(e,e.get(t[n]),i):n.endsWith("Ids")&&t[n].forEach((t=>{JR(e,e.get(t),i)}))})))}function zR(e,t,i){const n=i?"outbound-rtp":"inbound-rtp",r=new Map;if(null===t)return r;const o=[];return e.forEach((e=>{"track"===e.type&&e.trackIdentifier===t.id&&o.push(e)})),o.forEach((t=>{e.forEach((i=>{i.type===n&&i.trackId===t.id&&JR(e,i,r)}))})),r}const KR=HR;function qR(e,t){const i=e&&e.navigator;if(!i.mediaDevices)return;const n=function(e){if("object"!=typeof e||e.mandatory||e.optional)return e;const t={};return Object.keys(e).forEach((i=>{if("require"===i||"advanced"===i||"mediaSource"===i)return;const n="object"==typeof e[i]?e[i]:{ideal:e[i]};void 0!==n.exact&&"number"==typeof n.exact&&(n.min=n.max=n.exact);const r=function(e,t){return e?e+t.charAt(0).toUpperCase()+t.slice(1):"deviceId"===t?"sourceId":t};if(void 0!==n.ideal){t.optional=t.optional||[];let e={};"number"==typeof n.ideal?(e[r("min",i)]=n.ideal,t.optional.push(e),e={},e[r("max",i)]=n.ideal,t.optional.push(e)):(e[r("",i)]=n.ideal,t.optional.push(e))}void 0!==n.exact&&"number"!=typeof n.exact?(t.mandatory=t.mandatory||{},t.mandatory[r("",i)]=n.exact):["min","max"].forEach((e=>{void 0!==n[e]&&(t.mandatory=t.mandatory||{},t.mandatory[r(e,i)]=n[e])}))})),e.advanced&&(t.optional=(t.optional||[]).concat(e.advanced)),t},r=function(e,r){if(t.version>=61)return r(e);if((e=JSON.parse(JSON.stringify(e)))&&"object"==typeof e.audio){const t=function(e,t,i){t in e&&!(i in e)&&(e[i]=e[t],delete e[t])};t((e=JSON.parse(JSON.stringify(e))).audio,"autoGainControl","googAutoGainControl"),t(e.audio,"noiseSuppression","googNoiseSuppression"),e.audio=n(e.audio)}if(e&&"object"==typeof e.video){let o=e.video.facingMode;o=o&&("object"==typeof o?o:{ideal:o});const s=t.version<66;if(o&&("user"===o.exact||"environment"===o.exact||"user"===o.ideal||"environment"===o.ideal)&&(!i.mediaDevices.getSupportedConstraints||!i.mediaDevices.getSupportedConstraints().facingMode||s)){let t;if(delete e.video.facingMode,"environment"===o.exact||"environment"===o.ideal?t=["back","rear"]:"user"!==o.exact&&"user"!==o.ideal||(t=["front"]),t)return i.mediaDevices.enumerateDevices().then((i=>{i=i.filter((e=>"videoinput"===e.kind));let s=i.find((e=>t.some((t=>e.label.toLowerCase().includes(t)))));return!s&&i.length&&t.includes("back")&&(s=i[i.length-1]),s&&(e.video.deviceId=o.exact?{exact:s.deviceId}:{ideal:s.deviceId}),e.video=n(e.video),KR("chrome: "+JSON.stringify(e)),r(e)}))}e.video=n(e.video)}return KR("chrome: "+JSON.stringify(e)),r(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(){return this.name+(this.message&&": ")+this.message}}};if(i.getUserMedia=function(e,t,n){r(e,(e=>{i.webkitGetUserMedia(e,t,(e=>{n&&n(o(e))}))}))}.bind(i),i.mediaDevices.getUserMedia){const e=i.mediaDevices.getUserMedia.bind(i.mediaDevices);i.mediaDevices.getUserMedia=function(t){return r(t,(t=>e(t).then((e=>{if(t.audio&&!e.getAudioTracks().length||t.video&&!e.getVideoTracks().length)throw e.getTracks().forEach((e=>{e.stop()})),new DOMException("","NotFoundError");return e}),(e=>Promise.reject(o(e))))))}}}function YR(e){e.MediaStream=e.MediaStream||e.webkitMediaStream}function QR(e){if("object"==typeof e&&e.RTCPeerConnection&&!("ontrack"in e.RTCPeerConnection.prototype)){Object.defineProperty(e.RTCPeerConnection.prototype,"ontrack",{get(){return this._ontrack},set(e){this._ontrack&&this.removeEventListener("track",this._ontrack),this.addEventListener("track",this._ontrack=e)},enumerable:!0,configurable:!0});const t=e.RTCPeerConnection.prototype.setRemoteDescription;e.RTCPeerConnection.prototype.setRemoteDescription=function(){return this._ontrackpoly||(this._ontrackpoly=t=>{t.stream.addEventListener("addtrack",(i=>{let n;n=e.RTCPeerConnection.prototype.getReceivers?this.getReceivers().find((e=>e.track&&e.track.id===i.track.id)):{track:i.track};const r=new Event("track");r.track=i.track,r.receiver=n,r.transceiver={receiver:n},r.streams=[t.stream],this.dispatchEvent(r)})),t.stream.getTracks().forEach((i=>{let n;n=e.RTCPeerConnection.prototype.getReceivers?this.getReceivers().find((e=>e.track&&e.track.id===i.id)):{track:i};const r=new Event("track");r.track=i,r.receiver=n,r.transceiver={receiver:n},r.streams=[t.stream],this.dispatchEvent(r)}))},this.addEventListener("addstream",this._ontrackpoly)),t.apply(this,arguments)}}else UR(e,"track",(e=>(e.transceiver||Object.defineProperty(e,"transceiver",{value:{receiver:e.receiver}}),e)))}function XR(e){if("object"==typeof e&&e.RTCPeerConnection&&!("getSenders"in e.RTCPeerConnection.prototype)&&"createDTMFSender"in e.RTCPeerConnection.prototype){const 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(){return this._senders=this._senders||[],this._senders.slice()};const i=e.RTCPeerConnection.prototype.addTrack;e.RTCPeerConnection.prototype.addTrack=function(e,n){let r=i.apply(this,arguments);return r||(r=t(this,e),this._senders.push(r)),r};const n=e.RTCPeerConnection.prototype.removeTrack;e.RTCPeerConnection.prototype.removeTrack=function(e){n.apply(this,arguments);const t=this._senders.indexOf(e);-1!==t&&this._senders.splice(t,1)}}const i=e.RTCPeerConnection.prototype.addStream;e.RTCPeerConnection.prototype.addStream=function(e){this._senders=this._senders||[],i.apply(this,[e]),e.getTracks().forEach((e=>{this._senders.push(t(this,e))}))};const n=e.RTCPeerConnection.prototype.removeStream;e.RTCPeerConnection.prototype.removeStream=function(e){this._senders=this._senders||[],n.apply(this,[e]),e.getTracks().forEach((e=>{const t=this._senders.find((t=>t.track===e));t&&this._senders.splice(this._senders.indexOf(t),1)}))}}else if("object"==typeof e&&e.RTCPeerConnection&&"getSenders"in e.RTCPeerConnection.prototype&&"createDTMFSender"in e.RTCPeerConnection.prototype&&e.RTCRtpSender&&!("dtmf"in e.RTCRtpSender.prototype)){const t=e.RTCPeerConnection.prototype.getSenders;e.RTCPeerConnection.prototype.getSenders=function(){const e=t.apply(this,[]);return e.forEach((e=>e._pc=this)),e},Object.defineProperty(e.RTCRtpSender.prototype,"dtmf",{get(){return void 0===this._dtmf&&("audio"===this.track.kind?this._dtmf=this._pc.createDTMFSender(this.track):this._dtmf=null),this._dtmf}})}}function $R(e){if(!e.RTCPeerConnection)return;const t=e.RTCPeerConnection.prototype.getStats;e.RTCPeerConnection.prototype.getStats=function(){const[e,i,n]=arguments;if(arguments.length>0&&"function"==typeof e)return t.apply(this,arguments);if(0===t.length&&(0===arguments.length||"function"!=typeof e))return t.apply(this,[]);const r=function(e){const t={};return e.result().forEach((e=>{const i={id:e.id,timestamp:e.timestamp,type:{localcandidate:"local-candidate",remotecandidate:"remote-candidate"}[e.type]||e.type};e.names().forEach((t=>{i[t]=e.stat(t)})),t[i.id]=i})),t},o=function(e){return new Map(Object.keys(e).map((t=>[t,e[t]])))};if(arguments.length>=2){const n=function(e){i(o(r(e)))};return t.apply(this,[n,e])}return new Promise(((e,i)=>{t.apply(this,[function(t){e(o(r(t)))},i])})).then(i,n)}}function ZR(e){if(!("object"==typeof e&&e.RTCPeerConnection&&e.RTCRtpSender&&e.RTCRtpReceiver))return;if(!("getStats"in e.RTCRtpSender.prototype)){const t=e.RTCPeerConnection.prototype.getSenders;t&&(e.RTCPeerConnection.prototype.getSenders=function(){const e=t.apply(this,[]);return e.forEach((e=>e._pc=this)),e});const i=e.RTCPeerConnection.prototype.addTrack;i&&(e.RTCPeerConnection.prototype.addTrack=function(){const e=i.apply(this,arguments);return e._pc=this,e}),e.RTCRtpSender.prototype.getStats=function(){const e=this;return this._pc.getStats().then((t=>zR(t,e.track,!0)))}}if(!("getStats"in e.RTCRtpReceiver.prototype)){const t=e.RTCPeerConnection.prototype.getReceivers;t&&(e.RTCPeerConnection.prototype.getReceivers=function(){const e=t.apply(this,[]);return e.forEach((e=>e._pc=this)),e}),UR(e,"track",(e=>(e.receiver._pc=e.srcElement,e))),e.RTCRtpReceiver.prototype.getStats=function(){const e=this;return this._pc.getStats().then((t=>zR(t,e.track,!1)))}}if(!("getStats"in e.RTCRtpSender.prototype)||!("getStats"in e.RTCRtpReceiver.prototype))return;const t=e.RTCPeerConnection.prototype.getStats;e.RTCPeerConnection.prototype.getStats=function(){if(arguments.length>0&&arguments[0]instanceof e.MediaStreamTrack){const e=arguments[0];let t,i,n;return this.getSenders().forEach((i=>{i.track===e&&(t?n=!0:t=i)})),this.getReceivers().forEach((t=>(t.track===e&&(i?n=!0:i=t),t.track===e))),n||t&&i?Promise.reject(new DOMException("There are more than one sender or receiver for the track.","InvalidAccessError")):t?t.getStats():i?i.getStats():Promise.reject(new DOMException("There is no sender or receiver for the track.","InvalidAccessError"))}return t.apply(this,arguments)}}function eC(e){e.RTCPeerConnection.prototype.getLocalStreams=function(){return this._shimmedLocalStreams=this._shimmedLocalStreams||{},Object.keys(this._shimmedLocalStreams).map((e=>this._shimmedLocalStreams[e][0]))};const t=e.RTCPeerConnection.prototype.addTrack;e.RTCPeerConnection.prototype.addTrack=function(e,i){if(!i)return t.apply(this,arguments);this._shimmedLocalStreams=this._shimmedLocalStreams||{};const n=t.apply(this,arguments);return this._shimmedLocalStreams[i.id]?-1===this._shimmedLocalStreams[i.id].indexOf(n)&&this._shimmedLocalStreams[i.id].push(n):this._shimmedLocalStreams[i.id]=[i,n],n};const i=e.RTCPeerConnection.prototype.addStream;e.RTCPeerConnection.prototype.addStream=function(e){this._shimmedLocalStreams=this._shimmedLocalStreams||{},e.getTracks().forEach((e=>{if(this.getSenders().find((t=>t.track===e)))throw new DOMException("Track already exists.","InvalidAccessError")}));const t=this.getSenders();i.apply(this,arguments);const n=this.getSenders().filter((e=>-1===t.indexOf(e)));this._shimmedLocalStreams[e.id]=[e].concat(n)};const 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)};const r=e.RTCPeerConnection.prototype.removeTrack;e.RTCPeerConnection.prototype.removeTrack=function(e){return this._shimmedLocalStreams=this._shimmedLocalStreams||{},e&&Object.keys(this._shimmedLocalStreams).forEach((t=>{const i=this._shimmedLocalStreams[t].indexOf(e);-1!==i&&this._shimmedLocalStreams[t].splice(i,1),1===this._shimmedLocalStreams[t].length&&delete this._shimmedLocalStreams[t]})),r.apply(this,arguments)}}function tC(e,t){if(!e.RTCPeerConnection)return;if(e.RTCPeerConnection.prototype.addTrack&&t.version>=65)return eC(e);const i=e.RTCPeerConnection.prototype.getLocalStreams;e.RTCPeerConnection.prototype.getLocalStreams=function(){const e=i.apply(this);return this._reverseStreams=this._reverseStreams||{},e.map((e=>this._reverseStreams[e.id]))};const n=e.RTCPeerConnection.prototype.addStream;e.RTCPeerConnection.prototype.addStream=function(t){if(this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{},t.getTracks().forEach((e=>{if(this.getSenders().find((t=>t.track===e)))throw new DOMException("Track already exists.","InvalidAccessError")})),!this._reverseStreams[t.id]){const i=new e.MediaStream(t.getTracks());this._streams[t.id]=i,this._reverseStreams[i.id]=t,t=i}n.apply(this,[t])};const r=e.RTCPeerConnection.prototype.removeStream;function o(e,t){let i=t.sdp;return Object.keys(e._reverseStreams||[]).forEach((t=>{const n=e._reverseStreams[t],r=e._streams[n.id];i=i.replace(new RegExp(r.id,"g"),n.id)})),new RTCSessionDescription({type:t.type,sdp:i})}e.RTCPeerConnection.prototype.removeStream=function(e){this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{},r.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,i){if("closed"===this.signalingState)throw new DOMException("The RTCPeerConnection's signalingState is 'closed'.","InvalidStateError");const n=[].slice.call(arguments,1);if(1!==n.length||!n[0].getTracks().find((e=>e===t)))throw new DOMException("The adapter.js addTrack polyfill only supports a single stream which is associated with the specified track.","NotSupportedError");if(this.getSenders().find((e=>e.track===t)))throw new DOMException("Track already exists.","InvalidAccessError");this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{};const r=this._streams[i.id];if(r)r.addTrack(t),Promise.resolve().then((()=>{this.dispatchEvent(new Event("negotiationneeded"))}));else{const n=new e.MediaStream([t]);this._streams[i.id]=n,this._reverseStreams[n.id]=i,this.addStream(n)}return this.getSenders().find((e=>e.track===t))},["createOffer","createAnswer"].forEach((function(t){const i=e.RTCPeerConnection.prototype[t],n={[t](){const e=arguments;return arguments.length&&"function"==typeof arguments[0]?i.apply(this,[t=>{const i=o(this,t);e[0].apply(null,[i])},t=>{e[1]&&e[1].apply(null,t)},arguments[2]]):i.apply(this,arguments).then((e=>o(this,e)))}};e.RTCPeerConnection.prototype[t]=n[t]}));const s=e.RTCPeerConnection.prototype.setLocalDescription;e.RTCPeerConnection.prototype.setLocalDescription=function(){return arguments.length&&arguments[0].type?(arguments[0]=function(e,t){let i=t.sdp;return Object.keys(e._reverseStreams||[]).forEach((t=>{const n=e._reverseStreams[t],r=e._streams[n.id];i=i.replace(new RegExp(n.id,"g"),r.id)})),new RTCSessionDescription({type:t.type,sdp:i})}(this,arguments[0]),s.apply(this,arguments)):s.apply(this,arguments)};const a=Object.getOwnPropertyDescriptor(e.RTCPeerConnection.prototype,"localDescription");Object.defineProperty(e.RTCPeerConnection.prototype,"localDescription",{get(){const e=a.get.apply(this);return""===e.type?e:o(this,e)}}),e.RTCPeerConnection.prototype.removeTrack=function(e){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");let t;this._streams=this._streams||{},Object.keys(this._streams).forEach((i=>{this._streams[i].getTracks().find((t=>e.track===t))&&(t=this._streams[i])})),t&&(1===t.getTracks().length?this.removeStream(this._reverseStreams[t.id]):t.removeTrack(e.track),this.dispatchEvent(new Event("negotiationneeded")))}}function iC(e,t){!e.RTCPeerConnection&&e.webkitRTCPeerConnection&&(e.RTCPeerConnection=e.webkitRTCPeerConnection),e.RTCPeerConnection&&t.version<53&&["setLocalDescription","setRemoteDescription","addIceCandidate"].forEach((function(t){const i=e.RTCPeerConnection.prototype[t],n={[t](){return arguments[0]=new("addIceCandidate"===t?e.RTCIceCandidate:e.RTCSessionDescription)(arguments[0]),i.apply(this,arguments)}};e.RTCPeerConnection.prototype[t]=n[t]}))}function nC(e,t){UR(e,"negotiationneeded",(e=>{const i=e.target;if(!(t.version<72||i.getConfiguration&&"plan-b"===i.getConfiguration().sdpSemantics)||"stable"===i.signalingState)return e}))}var rC=Object.freeze({__proto__:null,shimMediaStream:YR,shimOnTrack:QR,shimGetSendersWithDtmf:XR,shimGetStats:$R,shimSenderReceiverGetStats:ZR,shimAddTrackRemoveTrackWithNative:eC,shimAddTrackRemoveTrack:tC,shimPeerConnection:iC,fixNegotiationNeeded:nC,shimGetUserMedia:qR,shimGetDisplayMedia:function(e,t){e.navigator.mediaDevices&&"getDisplayMedia"in e.navigator.mediaDevices||e.navigator.mediaDevices&&("function"==typeof t?e.navigator.mediaDevices.getDisplayMedia=function(i){return t(i).then((t=>{const n=i.video&&i.video.width,r=i.video&&i.video.height,o=i.video&&i.video.frameRate;return i.video={mandatory:{chromeMediaSource:"desktop",chromeMediaSourceId:t,maxFrameRate:o||3}},n&&(i.video.mandatory.maxWidth=n),r&&(i.video.mandatory.maxHeight=r),e.navigator.mediaDevices.getUserMedia(i)}))}:console.error("shimGetDisplayMedia: getSourceId argument is not a function"))}});function oC(e,t){const i=e&&e.navigator,n=e&&e.MediaStreamTrack;if(i.getUserMedia=function(e,t,n){jR("navigator.getUserMedia","navigator.mediaDevices.getUserMedia"),i.mediaDevices.getUserMedia(e).then(t,n)},!(t.version>55&&"autoGainControl"in i.mediaDevices.getSupportedConstraints())){const e=function(e,t,i){t in e&&!(i in e)&&(e[i]=e[t],delete e[t])},t=i.mediaDevices.getUserMedia.bind(i.mediaDevices);if(i.mediaDevices.getUserMedia=function(i){return"object"==typeof i&&"object"==typeof i.audio&&(i=JSON.parse(JSON.stringify(i)),e(i.audio,"autoGainControl","mozAutoGainControl"),e(i.audio,"noiseSuppression","mozNoiseSuppression")),t(i)},n&&n.prototype.getSettings){const t=n.prototype.getSettings;n.prototype.getSettings=function(){const i=t.apply(this,arguments);return e(i,"mozAutoGainControl","autoGainControl"),e(i,"mozNoiseSuppression","noiseSuppression"),i}}if(n&&n.prototype.applyConstraints){const t=n.prototype.applyConstraints;n.prototype.applyConstraints=function(i){return"audio"===this.kind&&"object"==typeof i&&(i=JSON.parse(JSON.stringify(i)),e(i,"autoGainControl","mozAutoGainControl"),e(i,"noiseSuppression","mozNoiseSuppression")),t.apply(this,[i])}}}}function sC(e){"object"==typeof e&&e.RTCTrackEvent&&"receiver"in e.RTCTrackEvent.prototype&&!("transceiver"in e.RTCTrackEvent.prototype)&&Object.defineProperty(e.RTCTrackEvent.prototype,"transceiver",{get(){return{receiver:this.receiver}}})}function aC(e,t){if("object"!=typeof e||!e.RTCPeerConnection&&!e.mozRTCPeerConnection)return;!e.RTCPeerConnection&&e.mozRTCPeerConnection&&(e.RTCPeerConnection=e.mozRTCPeerConnection),t.version<53&&["setLocalDescription","setRemoteDescription","addIceCandidate"].forEach((function(t){const i=e.RTCPeerConnection.prototype[t],n={[t](){return arguments[0]=new("addIceCandidate"===t?e.RTCIceCandidate:e.RTCSessionDescription)(arguments[0]),i.apply(this,arguments)}};e.RTCPeerConnection.prototype[t]=n[t]}));const i={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(){const[e,r,o]=arguments;return n.apply(this,[e||null]).then((e=>{if(t.version<53&&!r)try{e.forEach((e=>{e.type=i[e.type]||e.type}))}catch(aN){if("TypeError"!==aN.name)throw aN;e.forEach(((t,n)=>{e.set(n,Object.assign({},t,{type:i[t.type]||t.type}))}))}return e})).then(r,o)}}function cC(e){if("object"!=typeof e||!e.RTCPeerConnection||!e.RTCRtpSender)return;if(e.RTCRtpSender&&"getStats"in e.RTCRtpSender.prototype)return;const t=e.RTCPeerConnection.prototype.getSenders;t&&(e.RTCPeerConnection.prototype.getSenders=function(){const e=t.apply(this,[]);return e.forEach((e=>e._pc=this)),e});const i=e.RTCPeerConnection.prototype.addTrack;i&&(e.RTCPeerConnection.prototype.addTrack=function(){const e=i.apply(this,arguments);return e._pc=this,e}),e.RTCRtpSender.prototype.getStats=function(){return this.track?this._pc.getStats(this.track):Promise.resolve(new Map)}}function lC(e){if("object"!=typeof e||!e.RTCPeerConnection||!e.RTCRtpSender)return;if(e.RTCRtpSender&&"getStats"in e.RTCRtpReceiver.prototype)return;const t=e.RTCPeerConnection.prototype.getReceivers;t&&(e.RTCPeerConnection.prototype.getReceivers=function(){const e=t.apply(this,[]);return e.forEach((e=>e._pc=this)),e}),UR(e,"track",(e=>(e.receiver._pc=e.srcElement,e))),e.RTCRtpReceiver.prototype.getStats=function(){return this._pc.getStats(this.track)}}function dC(e){e.RTCPeerConnection&&!("removeStream"in e.RTCPeerConnection.prototype)&&(e.RTCPeerConnection.prototype.removeStream=function(e){jR("removeStream","removeTrack"),this.getSenders().forEach((t=>{t.track&&e.getTracks().includes(t.track)&&this.removeTrack(t)}))})}function uC(e){e.DataChannel&&!e.RTCDataChannel&&(e.RTCDataChannel=e.DataChannel)}function hC(e){if("object"!=typeof e||!e.RTCPeerConnection)return;const t=e.RTCPeerConnection.prototype.addTransceiver;t&&(e.RTCPeerConnection.prototype.addTransceiver=function(){this.setParametersPromises=[];let e=arguments[1]&&arguments[1].sendEncodings;void 0===e&&(e=[]),e=[...e];const i=e.length>0;i&&e.forEach((e=>{if("rid"in e&&!/^[a-z0-9]{0,16}$/i.test(e.rid))throw new TypeError("Invalid RID value provided.");if("scaleResolutionDownBy"in e&&!(parseFloat(e.scaleResolutionDownBy)>=1))throw new RangeError("scale_resolution_down_by must be >= 1.0");if("maxFramerate"in e&&!(parseFloat(e.maxFramerate)>=0))throw new RangeError("max_framerate must be >= 0.0")}));const n=t.apply(this,arguments);if(i){const{sender:t}=n,i=t.getParameters();(!("encodings"in i)||1===i.encodings.length&&0===Object.keys(i.encodings[0]).length)&&(i.encodings=e,t.sendEncodings=e,this.setParametersPromises.push(t.setParameters(i).then((()=>{delete t.sendEncodings})).catch((()=>{delete t.sendEncodings}))))}return n})}function pC(e){if("object"!=typeof e||!e.RTCRtpSender)return;const t=e.RTCRtpSender.prototype.getParameters;t&&(e.RTCRtpSender.prototype.getParameters=function(){const e=t.apply(this,arguments);return"encodings"in e||(e.encodings=[].concat(this.sendEncodings||[{}])),e})}function mC(e){if("object"!=typeof e||!e.RTCPeerConnection)return;const t=e.RTCPeerConnection.prototype.createOffer;e.RTCPeerConnection.prototype.createOffer=function(){return this.setParametersPromises&&this.setParametersPromises.length?Promise.all(this.setParametersPromises).then((()=>t.apply(this,arguments))).finally((()=>{this.setParametersPromises=[]})):t.apply(this,arguments)}}function _C(e){if("object"!=typeof e||!e.RTCPeerConnection)return;const t=e.RTCPeerConnection.prototype.createAnswer;e.RTCPeerConnection.prototype.createAnswer=function(){return this.setParametersPromises&&this.setParametersPromises.length?Promise.all(this.setParametersPromises).then((()=>t.apply(this,arguments))).finally((()=>{this.setParametersPromises=[]})):t.apply(this,arguments)}}var fC=Object.freeze({__proto__:null,shimOnTrack:sC,shimPeerConnection:aC,shimSenderGetStats:cC,shimReceiverGetStats:lC,shimRemoveStream:dC,shimRTCDataChannel:uC,shimAddTransceiver:hC,shimGetParameters:pC,shimCreateOffer:mC,shimCreateAnswer:_C,shimGetUserMedia:oC,shimGetDisplayMedia:function(e,t){e.navigator.mediaDevices&&"getDisplayMedia"in e.navigator.mediaDevices||e.navigator.mediaDevices&&(e.navigator.mediaDevices.getDisplayMedia=function(i){if(!i||!i.video){const e=new DOMException("getDisplayMedia without video constraints is undefined");return e.name="NotFoundError",e.code=8,Promise.reject(e)}return!0===i.video?i.video={mediaSource:t}:i.video.mediaSource=t,e.navigator.mediaDevices.getUserMedia(i)})}});function gC(e){if("object"==typeof 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)){const t=e.RTCPeerConnection.prototype.addTrack;e.RTCPeerConnection.prototype.addStream=function(e){this._localStreams||(this._localStreams=[]),this._localStreams.includes(e)||this._localStreams.push(e),e.getAudioTracks().forEach((i=>t.call(this,i,e))),e.getVideoTracks().forEach((i=>t.call(this,i,e)))},e.RTCPeerConnection.prototype.addTrack=function(e,...i){return i&&i.forEach((e=>{this._localStreams?this._localStreams.includes(e)||this._localStreams.push(e):this._localStreams=[e]})),t.apply(this,arguments)}}"removeStream"in e.RTCPeerConnection.prototype||(e.RTCPeerConnection.prototype.removeStream=function(e){this._localStreams||(this._localStreams=[]);const t=this._localStreams.indexOf(e);if(-1===t)return;this._localStreams.splice(t,1);const i=e.getTracks();this.getSenders().forEach((e=>{i.includes(e.track)&&this.removeTrack(e)}))})}}function TC(e){if("object"==typeof e&&e.RTCPeerConnection&&("getRemoteStreams"in e.RTCPeerConnection.prototype||(e.RTCPeerConnection.prototype.getRemoteStreams=function(){return this._remoteStreams?this._remoteStreams:[]}),!("onaddstream"in e.RTCPeerConnection.prototype))){Object.defineProperty(e.RTCPeerConnection.prototype,"onaddstream",{get(){return this._onaddstream},set(e){this._onaddstream&&(this.removeEventListener("addstream",this._onaddstream),this.removeEventListener("track",this._onaddstreampoly)),this.addEventListener("addstream",this._onaddstream=e),this.addEventListener("track",this._onaddstreampoly=e=>{e.streams.forEach((e=>{if(this._remoteStreams||(this._remoteStreams=[]),this._remoteStreams.includes(e))return;this._remoteStreams.push(e);const t=new Event("addstream");t.stream=e,this.dispatchEvent(t)}))})}});const t=e.RTCPeerConnection.prototype.setRemoteDescription;e.RTCPeerConnection.prototype.setRemoteDescription=function(){const e=this;return this._onaddstreampoly||this.addEventListener("track",this._onaddstreampoly=function(t){t.streams.forEach((t=>{if(e._remoteStreams||(e._remoteStreams=[]),e._remoteStreams.indexOf(t)>=0)return;e._remoteStreams.push(t);const i=new Event("addstream");i.stream=t,e.dispatchEvent(i)}))}),t.apply(e,arguments)}}}function EC(e){if("object"!=typeof e||!e.RTCPeerConnection)return;const t=e.RTCPeerConnection.prototype,i=t.createOffer,n=t.createAnswer,r=t.setLocalDescription,o=t.setRemoteDescription,s=t.addIceCandidate;t.createOffer=function(e,t){const n=arguments.length>=2?arguments[2]:arguments[0],r=i.apply(this,[n]);return t?(r.then(e,t),Promise.resolve()):r},t.createAnswer=function(e,t){const i=arguments.length>=2?arguments[2]:arguments[0],r=n.apply(this,[i]);return t?(r.then(e,t),Promise.resolve()):r};let a=function(e,t,i){const n=r.apply(this,[e]);return i?(n.then(t,i),Promise.resolve()):n};t.setLocalDescription=a,a=function(e,t,i){const n=o.apply(this,[e]);return i?(n.then(t,i),Promise.resolve()):n},t.setRemoteDescription=a,a=function(e,t,i){const n=s.apply(this,[e]);return i?(n.then(t,i),Promise.resolve()):n},t.addIceCandidate=a}function SC(e){const t=e&&e.navigator;if(t.mediaDevices&&t.mediaDevices.getUserMedia){const e=t.mediaDevices,i=e.getUserMedia.bind(e);t.mediaDevices.getUserMedia=e=>i(IC(e))}!t.getUserMedia&&t.mediaDevices&&t.mediaDevices.getUserMedia&&(t.getUserMedia=function(e,i,n){t.mediaDevices.getUserMedia(e).then(i,n)}.bind(t))}function IC(e){return e&&void 0!==e.video?Object.assign({},e,{video:WR(e.video)}):e}function yC(e){if(!e.RTCPeerConnection)return;const t=e.RTCPeerConnection;e.RTCPeerConnection=function(e,i){if(e&&e.iceServers){const t=[];for(let i=0;i<e.iceServers.length;i++){let n=e.iceServers[i];void 0===n.urls&&n.url?(jR("RTCIceServer.url","RTCIceServer.urls"),n=JSON.parse(JSON.stringify(n)),n.urls=n.url,delete n.url,t.push(n)):t.push(e.iceServers[i])}e.iceServers=t}return new t(e,i)},e.RTCPeerConnection.prototype=t.prototype,"generateCertificate"in t&&Object.defineProperty(e.RTCPeerConnection,"generateCertificate",{get:()=>t.generateCertificate})}function vC(e){"object"==typeof e&&e.RTCTrackEvent&&"receiver"in e.RTCTrackEvent.prototype&&!("transceiver"in e.RTCTrackEvent.prototype)&&Object.defineProperty(e.RTCTrackEvent.prototype,"transceiver",{get(){return{receiver:this.receiver}}})}function AC(e){const t=e.RTCPeerConnection.prototype.createOffer;e.RTCPeerConnection.prototype.createOffer=function(e){if(e){void 0!==e.offerToReceiveAudio&&(e.offerToReceiveAudio=!!e.offerToReceiveAudio);const t=this.getTransceivers().find((e=>"audio"===e.receiver.track.kind));!1===e.offerToReceiveAudio&&t?"sendrecv"===t.direction?t.setDirection?t.setDirection("sendonly"):t.direction="sendonly":"recvonly"===t.direction&&(t.setDirection?t.setDirection("inactive"):t.direction="inactive"):!0!==e.offerToReceiveAudio||t||this.addTransceiver("audio",{direction:"recvonly"}),void 0!==e.offerToReceiveVideo&&(e.offerToReceiveVideo=!!e.offerToReceiveVideo);const i=this.getTransceivers().find((e=>"video"===e.receiver.track.kind));!1===e.offerToReceiveVideo&&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.offerToReceiveVideo||i||this.addTransceiver("video",{direction:"recvonly"})}return t.apply(this,arguments)}}function RC(e){"object"!=typeof e||e.AudioContext||(e.AudioContext=e.webkitAudioContext)}var CC=Object.freeze({__proto__:null,shimLocalStreamsAPI:gC,shimRemoteStreamsAPI:TC,shimCallbacksAPI:EC,shimGetUserMedia:SC,shimConstraints:IC,shimRTCIceServerUrls:yC,shimTrackEventTransceiver:vC,shimCreateOfferLegacy:AC,shimAudioContext:RC}),bC={},kC={get exports(){return bC},set exports(e){bC=e}};!function(e){const t={generateIdentifier:function(){return Math.random().toString(36).substring(2,12)}};t.localCName=t.generateIdentifier(),t.splitLines=function(e){return e.trim().split("\n").map((e=>e.trim()))},t.splitSections=function(e){return e.split("\nm=").map(((e,t)=>(t>0?"m="+e:e).trim()+"\r\n"))},t.getDescription=function(e){const i=t.splitSections(e);return i&&i[0]},t.getMediaSections=function(e){const i=t.splitSections(e);return i.shift(),i},t.matchPrefix=function(e,i){return t.splitLines(e).filter((e=>0===e.indexOf(i)))},t.parseCandidate=function(e){let t;t=0===e.indexOf("a=candidate:")?e.substring(12).split(" "):e.substring(10).split(" ");const i={foundation:t[0],component:{1:"rtp",2:"rtcp"}[t[1]]||t[1],protocol:t[2].toLowerCase(),priority:parseInt(t[3],10),ip:t[4],address:t[4],port:parseInt(t[5],10),type:t[7]};for(let n=8;n<t.length;n+=2)switch(t[n]){case"raddr":i.relatedAddress=t[n+1];break;case"rport":i.relatedPort=parseInt(t[n+1],10);break;case"tcptype":i.tcpType=t[n+1];break;case"ufrag":i.ufrag=t[n+1],i.usernameFragment=t[n+1];break;default:void 0===i[t[n]]&&(i[t[n]]=t[n+1])}return i},t.writeCandidate=function(e){const t=[];t.push(e.foundation);const i=e.component;"rtp"===i?t.push(1):"rtcp"===i?t.push(2):t.push(i),t.push(e.protocol.toUpperCase()),t.push(e.priority),t.push(e.address||e.ip),t.push(e.port);const 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(" ")},t.parseIceOptions=function(e){return e.substring(14).split(" ")},t.parseRtpMap=function(e){let t=e.substring(9).split(" ");const i={payloadType:parseInt(t.shift(),10)};return t=t[0].split("/"),i.name=t[0],i.clockRate=parseInt(t[1],10),i.channels=3===t.length?parseInt(t[2],10):1,i.numChannels=i.channels,i},t.writeRtpMap=function(e){let t=e.payloadType;void 0!==e.preferredPayloadType&&(t=e.preferredPayloadType);const i=e.channels||e.numChannels||1;return"a=rtpmap:"+t+" "+e.name+"/"+e.clockRate+(1!==i?"/"+i:"")+"\r\n"},t.parseExtmap=function(e){const t=e.substring(9).split(" ");return{id:parseInt(t[0],10),direction:t[0].indexOf("/")>0?t[0].split("/")[1]:"sendrecv",uri:t[1],attributes:t.slice(2).join(" ")}},t.writeExtmap=function(e){return"a=extmap:"+(e.id||e.preferredId)+(e.direction&&"sendrecv"!==e.direction?"/"+e.direction:"")+" "+e.uri+(e.attributes?" "+e.attributes:"")+"\r\n"},t.parseFmtp=function(e){const t={};let i;const n=e.substring(e.indexOf(" ")+1).split(";");for(let r=0;r<n.length;r++)i=n[r].trim().split("="),t[i[0].trim()]=i[1];return t},t.writeFmtp=function(e){let t="",i=e.payloadType;if(void 0!==e.preferredPayloadType&&(i=e.preferredPayloadType),e.parameters&&Object.keys(e.parameters).length){const n=[];Object.keys(e.parameters).forEach((t=>{void 0!==e.parameters[t]?n.push(t+"="+e.parameters[t]):n.push(t)})),t+="a=fmtp:"+i+" "+n.join(";")+"\r\n"}return t},t.parseRtcpFb=function(e){const t=e.substring(e.indexOf(" ")+1).split(" ");return{type:t.shift(),parameter:t.join(" ")}},t.writeRtcpFb=function(e){let t="",i=e.payloadType;return void 0!==e.preferredPayloadType&&(i=e.preferredPayloadType),e.rtcpFeedback&&e.rtcpFeedback.length&&e.rtcpFeedback.forEach((e=>{t+="a=rtcp-fb:"+i+" "+e.type+(e.parameter&&e.parameter.length?" "+e.parameter:"")+"\r\n"})),t},t.parseSsrcMedia=function(e){const t=e.indexOf(" "),i={ssrc:parseInt(e.substring(7,t),10)},n=e.indexOf(":",t);return n>-1?(i.attribute=e.substring(t+1,n),i.value=e.substring(n+1)):i.attribute=e.substring(t+1),i},t.parseSsrcGroup=function(e){const t=e.substring(13).split(" ");return{semantics:t.shift(),ssrcs:t.map((e=>parseInt(e,10)))}},t.getMid=function(e){const i=t.matchPrefix(e,"a=mid:")[0];if(i)return i.substring(6)},t.parseFingerprint=function(e){const t=e.substring(14).split(" ");return{algorithm:t[0].toLowerCase(),value:t[1].toUpperCase()}},t.getDtlsParameters=function(e,i){return{role:"auto",fingerprints:t.matchPrefix(e+i,"a=fingerprint:").map(t.parseFingerprint)}},t.writeDtlsParameters=function(e,t){let i="a=setup:"+t+"\r\n";return e.fingerprints.forEach((e=>{i+="a=fingerprint:"+e.algorithm+" "+e.value+"\r\n"})),i},t.parseCryptoLine=function(e){const t=e.substring(9).split(" ");return{tag:parseInt(t[0],10),cryptoSuite:t[1],keyParams:t[2],sessionParams:t.slice(3)}},t.writeCryptoLine=function(e){return"a=crypto:"+e.tag+" "+e.cryptoSuite+" "+("object"==typeof e.keyParams?t.writeCryptoKeyParams(e.keyParams):e.keyParams)+(e.sessionParams?" "+e.sessionParams.join(" "):"")+"\r\n"},t.parseCryptoKeyParams=function(e){if(0!==e.indexOf("inline:"))return null;const t=e.substring(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}},t.writeCryptoKeyParams=function(e){return e.keyMethod+":"+e.keySalt+(e.lifeTime?"|"+e.lifeTime:"")+(e.mkiValue&&e.mkiLength?"|"+e.mkiValue+":"+e.mkiLength:"")},t.getCryptoParameters=function(e,i){return t.matchPrefix(e+i,"a=crypto:").map(t.parseCryptoLine)},t.getIceParameters=function(e,i){const n=t.matchPrefix(e+i,"a=ice-ufrag:")[0],r=t.matchPrefix(e+i,"a=ice-pwd:")[0];return n&&r?{usernameFragment:n.substring(12),password:r.substring(10)}:null},t.writeIceParameters=function(e){let t="a=ice-ufrag:"+e.usernameFragment+"\r\na=ice-pwd:"+e.password+"\r\n";return e.iceLite&&(t+="a=ice-lite\r\n"),t},t.parseRtpParameters=function(e){const i={codecs:[],headerExtensions:[],fecMechanisms:[],rtcp:[]},n=t.splitLines(e)[0].split(" ");i.profile=n[2];for(let o=3;o<n.length;o++){const r=n[o],s=t.matchPrefix(e,"a=rtpmap:"+r+" ")[0];if(s){const n=t.parseRtpMap(s),o=t.matchPrefix(e,"a=fmtp:"+r+" ");switch(n.parameters=o.length?t.parseFmtp(o[0]):{},n.rtcpFeedback=t.matchPrefix(e,"a=rtcp-fb:"+r+" ").map(t.parseRtcpFb),i.codecs.push(n),n.name.toUpperCase()){case"RED":case"ULPFEC":i.fecMechanisms.push(n.name.toUpperCase())}}}t.matchPrefix(e,"a=extmap:").forEach((e=>{i.headerExtensions.push(t.parseExtmap(e))}));const r=t.matchPrefix(e,"a=rtcp-fb:* ").map(t.parseRtcpFb);return i.codecs.forEach((e=>{r.forEach((t=>{e.rtcpFeedback.find((e=>e.type===t.type&&e.parameter===t.parameter))||e.rtcpFeedback.push(t)}))})),i},t.writeRtpDescription=function(e,i){let n="";n+="m="+e+" ",n+=i.codecs.length>0?"9":"0",n+=" "+(i.profile||"UDP/TLS/RTP/SAVPF")+" ",n+=i.codecs.map((e=>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",i.codecs.forEach((e=>{n+=t.writeRtpMap(e),n+=t.writeFmtp(e),n+=t.writeRtcpFb(e)}));let r=0;return i.codecs.forEach((e=>{e.maxptime>r&&(r=e.maxptime)})),r>0&&(n+="a=maxptime:"+r+"\r\n"),i.headerExtensions&&i.headerExtensions.forEach((e=>{n+=t.writeExtmap(e)})),n},t.parseRtpEncodingParameters=function(e){const i=[],n=t.parseRtpParameters(e),r=-1!==n.fecMechanisms.indexOf("RED"),o=-1!==n.fecMechanisms.indexOf("ULPFEC"),s=t.matchPrefix(e,"a=ssrc:").map((e=>t.parseSsrcMedia(e))).filter((e=>"cname"===e.attribute)),a=s.length>0&&s[0].ssrc;let c;const l=t.matchPrefix(e,"a=ssrc-group:FID").map((e=>e.substring(17).split(" ").map((e=>parseInt(e,10)))));l.length>0&&l[0].length>1&&l[0][0]===a&&(c=l[0][1]),n.codecs.forEach((e=>{if("RTX"===e.name.toUpperCase()&&e.parameters.apt){let t={ssrc:a,codecPayloadType:parseInt(e.parameters.apt,10)};a&&c&&(t.rtx={ssrc:c}),i.push(t),r&&(t=JSON.parse(JSON.stringify(t)),t.fec={ssrc:a,mechanism:o?"red+ulpfec":"red"},i.push(t))}})),0===i.length&&a&&i.push({ssrc:a});let d=t.matchPrefix(e,"b=");return d.length&&(d=0===d[0].indexOf("b=TIAS:")?parseInt(d[0].substring(7),10):0===d[0].indexOf("b=AS:")?1e3*parseInt(d[0].substring(5),10)*.95-16e3:void 0,i.forEach((e=>{e.maxBitrate=d}))),i},t.parseRtcpParameters=function(e){const i={},n=t.matchPrefix(e,"a=ssrc:").map((e=>t.parseSsrcMedia(e))).filter((e=>"cname"===e.attribute))[0];n&&(i.cname=n.value,i.ssrc=n.ssrc);const r=t.matchPrefix(e,"a=rtcp-rsize");i.reducedSize=r.length>0,i.compound=0===r.length;const o=t.matchPrefix(e,"a=rtcp-mux");return i.mux=o.length>0,i},t.writeRtcpParameters=function(e){let 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},t.parseMsid=function(e){let i;const n=t.matchPrefix(e,"a=msid:");if(1===n.length)return i=n[0].substring(7).split(" "),{stream:i[0],track:i[1]};const r=t.matchPrefix(e,"a=ssrc:").map((e=>t.parseSsrcMedia(e))).filter((e=>"msid"===e.attribute));return r.length>0?(i=r[0].value.split(" "),{stream:i[0],track:i[1]}):void 0},t.parseSctpDescription=function(e){const i=t.parseMLine(e),n=t.matchPrefix(e,"a=max-message-size:");let r;n.length>0&&(r=parseInt(n[0].substring(19),10)),isNaN(r)&&(r=65536);const o=t.matchPrefix(e,"a=sctp-port:");if(o.length>0)return{port:parseInt(o[0].substring(12),10),protocol:i.fmt,maxMessageSize:r};const s=t.matchPrefix(e,"a=sctpmap:");if(s.length>0){const e=s[0].substring(10).split(" ");return{port:parseInt(e[0],10),protocol:e[1],maxMessageSize:r}}},t.writeSctpDescription=function(e,t){let i=[];return i="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&&i.push("a=max-message-size:"+t.maxMessageSize+"\r\n"),i.join("")},t.generateSessionId=function(){return Math.random().toString().substr(2,22)},t.writeSessionBoilerplate=function(e,i,n){let r;const o=void 0!==i?i:2;return r=e||t.generateSessionId(),"v=0\r\no="+(n||"thisisadapterortc")+" "+r+" "+o+" IN IP4 127.0.0.1\r\ns=-\r\nt=0 0\r\n"},t.getDirection=function(e,i){const n=t.splitLines(e);for(let t=0;t<n.length;t++)switch(n[t]){case"a=sendrecv":case"a=sendonly":case"a=recvonly":case"a=inactive":return n[t].substring(2)}return i?t.getDirection(i):"sendrecv"},t.getKind=function(e){return t.splitLines(e)[0].split(" ")[0].substring(2)},t.isRejected=function(e){return"0"===e.split(" ",2)[1]},t.parseMLine=function(e){const i=t.splitLines(e)[0].substring(2).split(" ");return{kind:i[0],port:parseInt(i[1],10),protocol:i[2],fmt:i.slice(3).join(" ")}},t.parseOLine=function(e){const i=t.matchPrefix(e,"o=")[0].substring(2).split(" ");return{username:i[0],sessionId:i[1],sessionVersion:parseInt(i[2],10),netType:i[3],addressType:i[4],address:i[5]}},t.isValidSDP=function(e){if("string"!=typeof e||0===e.length)return!1;const i=t.splitLines(e);for(let t=0;t<i.length;t++)if(i[t].length<2||"="!==i[t].charAt(1))return!1;return!0},e.exports=t}(kC);var NC=bC,DC=e({__proto__:null,default:NC},[bC]);function OC(e){if(!e.RTCIceCandidate||e.RTCIceCandidate&&"foundation"in e.RTCIceCandidate.prototype)return;const t=e.RTCIceCandidate;e.RTCIceCandidate=function(e){if("object"==typeof e&&e.candidate&&0===e.candidate.indexOf("a=")&&((e=JSON.parse(JSON.stringify(e))).candidate=e.candidate.substring(2)),e.candidate&&e.candidate.length){const i=new t(e),n=NC.parseCandidate(e.candidate);for(const e in n)e in i||Object.defineProperty(i,e,{value:n[e]});return i.toJSON=function(){return{candidate:i.candidate,sdpMid:i.sdpMid,sdpMLineIndex:i.sdpMLineIndex,usernameFragment:i.usernameFragment}},i}return new t(e)},e.RTCIceCandidate.prototype=t.prototype,UR(e,"icecandidate",(t=>(t.candidate&&Object.defineProperty(t,"candidate",{value:new e.RTCIceCandidate(t.candidate),writable:"false"}),t)))}function wC(e){!e.RTCIceCandidate||e.RTCIceCandidate&&"relayProtocol"in e.RTCIceCandidate.prototype||UR(e,"icecandidate",(e=>{if(e.candidate){const t=NC.parseCandidate(e.candidate.candidate);"relay"===t.type&&(e.candidate.relayProtocol={0:"tls",1:"tcp",2:"udp"}[t.priority>>24])}return e}))}function PC(e,t){if(!e.RTCPeerConnection)return;"sctp"in e.RTCPeerConnection.prototype||Object.defineProperty(e.RTCPeerConnection.prototype,"sctp",{get(){return void 0===this._sctp?null:this._sctp}});const i=e.RTCPeerConnection.prototype.setRemoteDescription;e.RTCPeerConnection.prototype.setRemoteDescription=function(){if(this._sctp=null,"chrome"===t.browser&&t.version>=76){const{sdpSemantics:e}=this.getConfiguration();"plan-b"===e&&Object.defineProperty(this,"sctp",{get(){return void 0===this._sctp?null:this._sctp},enumerable:!0,configurable:!0})}if(function(e){if(!e||!e.sdp)return!1;const t=NC.splitSections(e.sdp);return t.shift(),t.some((e=>{const t=NC.parseMLine(e);return t&&"application"===t.kind&&-1!==t.protocol.indexOf("SCTP")}))}(arguments[0])){const e=function(e){const t=e.sdp.match(/mozilla...THIS_IS_SDPARTA-(\d+)/);if(null===t||t.length<2)return-1;const i=parseInt(t[1],10);return i!=i?-1:i}(arguments[0]),i=function(e){let i=65536;return"firefox"===t.browser&&(i=t.version<57?-1===e?16384:2147483637:t.version<60?57===t.version?65535:65536:2147483637),i}(e),n=function(e,i){let n=65536;"firefox"===t.browser&&57===t.version&&(n=65535);const r=NC.matchPrefix(e.sdp,"a=max-message-size:");return r.length>0?n=parseInt(r[0].substring(19),10):"firefox"===t.browser&&-1!==i&&(n=2147483637),n}(arguments[0],e);let r;r=0===i&&0===n?Number.POSITIVE_INFINITY:0===i||0===n?Math.max(i,n):Math.min(i,n);const o={};Object.defineProperty(o,"maxMessageSize",{get:()=>r}),this._sctp=o}return i.apply(this,arguments)}}function LC(e){if(!e.RTCPeerConnection||!("createDataChannel"in e.RTCPeerConnection.prototype))return;function t(e,t){const i=e.send;e.send=function(){const n=arguments[0],r=n.length||n.size||n.byteLength;if("open"===e.readyState&&t.sctp&&r>t.sctp.maxMessageSize)throw new TypeError("Message too large (can send a maximum of "+t.sctp.maxMessageSize+" bytes)");return i.apply(e,arguments)}}const i=e.RTCPeerConnection.prototype.createDataChannel;e.RTCPeerConnection.prototype.createDataChannel=function(){const e=i.apply(this,arguments);return t(e,this),e},UR(e,"datachannel",(e=>(t(e.channel,e.target),e)))}function MC(e){if(!e.RTCPeerConnection||"connectionState"in e.RTCPeerConnection.prototype)return;const t=e.RTCPeerConnection.prototype;Object.defineProperty(t,"connectionState",{get(){return{completed:"connected",checking:"connecting"}[this.iceConnectionState]||this.iceConnectionState},enumerable:!0,configurable:!0}),Object.defineProperty(t,"onconnectionstatechange",{get(){return this._onconnectionstatechange||null},set(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((e=>{const i=t[e];t[e]=function(){return this._connectionstatechangepoly||(this._connectionstatechangepoly=e=>{const t=e.target;if(t._lastConnectionState!==t.connectionState){t._lastConnectionState=t.connectionState;const i=new Event("connectionstatechange",e);t.dispatchEvent(i)}return e},this.addEventListener("iceconnectionstatechange",this._connectionstatechangepoly)),i.apply(this,arguments)}}))}function xC(e,t){if(!e.RTCPeerConnection)return;if("chrome"===t.browser&&t.version>=71)return;if("safari"===t.browser&&t.version>=605)return;const i=e.RTCPeerConnection.prototype.setRemoteDescription;e.RTCPeerConnection.prototype.setRemoteDescription=function(t){if(t&&t.sdp&&-1!==t.sdp.indexOf("\na=extmap-allow-mixed")){const i=t.sdp.split("\n").filter((e=>"a=extmap-allow-mixed"!==e.trim())).join("\n");e.RTCSessionDescription&&t instanceof e.RTCSessionDescription?arguments[0]=new e.RTCSessionDescription({type:t.type,sdp:i}):t.sdp=i}return i.apply(this,arguments)}}function VC(e,t){if(!e.RTCPeerConnection||!e.RTCPeerConnection.prototype)return;const i=e.RTCPeerConnection.prototype.addIceCandidate;i&&0!==i.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?Promise.resolve():i.apply(this,arguments):(arguments[1]&&arguments[1].apply(null),Promise.resolve())})}function UC(e,t){if(!e.RTCPeerConnection||!e.RTCPeerConnection.prototype)return;const i=e.RTCPeerConnection.prototype.setLocalDescription;i&&0!==i.length&&(e.RTCPeerConnection.prototype.setLocalDescription=function(){let e=arguments[0]||{};if("object"!=typeof e||e.type&&e.sdp)return i.apply(this,arguments);if(e={type:e.type,sdp:e.sdp},!e.type)switch(this.signalingState){case"stable":case"have-local-offer":case"have-remote-pranswer":e.type="offer";break;default:e.type="answer"}return e.sdp||"offer"!==e.type&&"answer"!==e.type?i.apply(this,[e]):("offer"===e.type?this.createOffer:this.createAnswer).apply(this).then((e=>i.apply(this,[e])))})}var FC=Object.freeze({__proto__:null,shimRTCIceCandidate:OC,shimRTCIceCandidateRelayProtocol:wC,shimMaxMessageSize:PC,shimSendThrowTypeError:LC,shimConnectionState:MC,removeExtmapAllowMixed:xC,shimAddIceCandidateNullOrEmpty:VC,shimParameterlessSetLocalDescription:UC});!function({window:e}={},t={shimChrome:!0,shimFirefox:!0,shimSafari:!0}){const i=HR,n=function(e){const t={browser:null,version:null};if(void 0===e||!e.navigator||!e.navigator.userAgent)return t.browser="Not a browser.",t;const{navigator:i}=e;if(i.mozGetUserMedia)t.browser="firefox",t.version=VR(i.userAgent,/Firefox\/(\d+)\./,1);else if(i.webkitGetUserMedia||!1===e.isSecureContext&&e.webkitRTCPeerConnection)t.browser="chrome",t.version=VR(i.userAgent,/Chrom(e|ium)\/(\d+)\./,2);else{if(!e.RTCPeerConnection||!i.userAgent.match(/AppleWebKit\/(\d+)\./))return t.browser="Not a supported browser.",t;t.browser="safari",t.version=VR(i.userAgent,/AppleWebKit\/(\d+)\./,1),t.supportsUnifiedPlan=e.RTCRtpTransceiver&&"currentDirection"in e.RTCRtpTransceiver.prototype}return t}(e),r={browserDetails:n,commonShim:FC,extractVersion:VR,disableLog:FR,disableWarnings:BR,sdp:DC};switch(n.browser){case"chrome":if(!rC||!iC||!t.shimChrome)return i("Chrome shim is not included in this adapter release."),r;if(null===n.version)return i("Chrome shim can not determine version, not shimming."),r;i("adapter.js shimming chrome."),r.browserShim=rC,VC(e,n),UC(e),qR(e,n),YR(e),iC(e,n),QR(e),tC(e,n),XR(e),$R(e),ZR(e),nC(e,n),OC(e),wC(e),MC(e),PC(e,n),LC(e),xC(e,n);break;case"firefox":if(!fC||!aC||!t.shimFirefox)return i("Firefox shim is not included in this adapter release."),r;i("adapter.js shimming firefox."),r.browserShim=fC,VC(e,n),UC(e),oC(e,n),aC(e,n),sC(e),dC(e),cC(e),lC(e),uC(e),hC(e),pC(e),mC(e),_C(e),OC(e),MC(e),PC(e,n),LC(e);break;case"safari":if(!CC||!t.shimSafari)return i("Safari shim is not included in this adapter release."),r;i("adapter.js shimming safari."),r.browserShim=CC,VC(e,n),UC(e),yC(e),AC(e),EC(e),gC(e),TC(e),vC(e),SC(e),RC(e),OC(e),wC(e),PC(e,n),LC(e),xC(e,n);break;default:i("Unsupported browser!")}}({window:"undefined"==typeof window?void 0:window});var BC,HC=Object.create,jC=Object.defineProperty,GC=Object.defineProperties,WC=Object.getOwnPropertyDescriptor,JC=Object.getOwnPropertyDescriptors,zC=Object.getOwnPropertyNames,KC=Object.getOwnPropertySymbols,qC=Object.getPrototypeOf,YC=Object.prototype.hasOwnProperty,QC=Object.prototype.propertyIsEnumerable,XC=Reflect.get,$C=Math.pow,ZC=(e,t,i)=>t in e?jC(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i,eb=(e,t)=>{for(var i in t||(t={}))YC.call(t,i)&&ZC(e,i,t[i]);if(KC)for(var i of KC(t))QC.call(t,i)&&ZC(e,i,t[i]);return e},tb=(e,t)=>GC(e,JC(t)),ib=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),nb=(e,t)=>{for(var i in t)jC(e,i,{get:t[i],enumerable:!0})},rb=(e,t,i)=>(i=null!=e?HC(qC(e)):{},((e,t,i,n)=>{if(t&&"object"==typeof t||"function"==typeof t)for(let r of zC(t))!YC.call(e,r)&&r!==i&&jC(e,r,{get:()=>t[r],enumerable:!(n=WC(t,r))||n.enumerable});return e})(!t&&e&&e.__esModule?i:jC(i,"default",{value:e,enumerable:!0}),e)),ob=(e,t,i,n)=>{for(var r,o=n>1?void 0:n?WC(t,i):t,s=e.length-1;s>=0;s--)(r=e[s])&&(o=(n?r(t,i,o):r(o))||o);return n&&o&&jC(t,i,o),o},sb=(e,t,i)=>(ZC(e,"symbol"!=typeof t?t+"":t,i),i),ab=(e,t,i)=>XC(qC(e),i,t),cb=(e,t,i)=>new Promise(((n,r)=>{var o=e=>{try{a(i.next(e))}catch(t){r(t)}},s=e=>{try{a(i.throw(e))}catch(t){r(t)}},a=e=>e.done?n(e.value):Promise.resolve(e.value).then(o,s);a((i=i.apply(e,t)).next())})),lb=ib(((e,t)=>{var i=Object.prototype.hasOwnProperty,n="~";function r(){}function o(e,t,i){this.fn=e,this.context=t,this.once=i||!1}function s(e,t,i,r,s){if("function"!=typeof i)throw new TypeError("The listener must be a function");var a=new o(i,r||e,s),c=n?n+t:t;return e._events[c]?e._events[c].fn?e._events[c]=[e._events[c],a]:e._events[c].push(a):(e._events[c]=a,e._eventsCount++),e}function a(e,t){0==--e._eventsCount?e._events=new r:delete e._events[t]}function c(){this._events=new r,this._eventsCount=0}Object.create&&(r.prototype=Object.create(null),(new r).__proto__||(n=!1)),c.prototype.eventNames=function(){var e,t,r=[];if(0===this._eventsCount)return r;for(t in e=this._events)i.call(e,t)&&r.push(n?t.slice(1):t);return Object.getOwnPropertySymbols?r.concat(Object.getOwnPropertySymbols(e)):r},c.prototype.listeners=function(e){var t=n?n+e:e,i=this._events[t];if(!i)return[];if(i.fn)return[i.fn];for(var r=0,o=i.length,s=new Array(o);r<o;r++)s[r]=i[r].fn;return s},c.prototype.listenerCount=function(e){var t=n?n+e:e,i=this._events[t];return i?i.fn?1:i.length:0},c.prototype.emit=function(e,t,i,r,o,s){var a=n?n+e:e;if(!this._events[a])return!1;var c,l,d=this._events[a],u=arguments.length;if(d.fn){switch(d.once&&this.removeListener(e,d.fn,void 0,!0),u){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,i),!0;case 4:return d.fn.call(d.context,t,i,r),!0;case 5:return d.fn.call(d.context,t,i,r,o),!0;case 6:return d.fn.call(d.context,t,i,r,o,s),!0}for(l=1,c=new Array(u-1);l<u;l++)c[l-1]=arguments[l];d.fn.apply(d.context,c)}else{var h,p=d.length;for(l=0;l<p;l++)switch(d[l].once&&this.removeListener(e,d[l].fn,void 0,!0),u){case 1:d[l].fn.call(d[l].context);break;case 2:d[l].fn.call(d[l].context,t);break;case 3:d[l].fn.call(d[l].context,t,i);break;case 4:d[l].fn.call(d[l].context,t,i,r);break;default:if(!c)for(h=1,c=new Array(u-1);h<u;h++)c[h-1]=arguments[h];d[l].fn.apply(d[l].context,c)}}return!0},c.prototype.on=function(e,t,i){return s(this,e,t,i,!1)},c.prototype.once=function(e,t,i){return s(this,e,t,i,!0)},c.prototype.removeListener=function(e,t,i,r){var o=n?n+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&&(!r||s.once)&&(!i||s.context===i)&&a(this,o);else{for(var c=0,l=[],d=s.length;c<d;c++)(s[c].fn!==t||r&&!s[c].once||i&&s[c].context!==i)&&l.push(s[c]);l.length?this._events[o]=1===l.length?l[0]:l:a(this,o)}return this},c.prototype.removeAllListeners=function(e){var t;return e?(t=n?n+e:e,this._events[t]&&a(this,t)):(this._events=new r,this._eventsCount=0),this},c.prototype.off=c.prototype.removeListener,c.prototype.addListener=c.prototype.on,c.prefixed=n,c.EventEmitter=c,void 0!==t&&(t.exports=c)})),db=ib(((e,t)=>{var i=t.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:%d 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":"")}},{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:"mid",reg:/^mid:([^\s]*)/,format:"mid:%s"},{name:"msid",reg:/^msid:(.*)/,format:"msid:%s"},{name:"ptime",reg:/^ptime:(\d*)/,format:"ptime:%d"},{name:"maxptime",reg:/^maxptime:(\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:"invalid",names:["value"]}]};Object.keys(i).forEach((function(e){i[e].forEach((function(e){e.reg||(e.reg=/(.*)/),e.format||(e.format="%s")}))}))})),ub=ib((e=>{var t=function(e){return String(Number(e))===e?Number(e):e},i=function(e,i,n){var r=e.name&&e.names;e.push&&!i[e.push]?i[e.push]=[]:r&&!i[e.name]&&(i[e.name]={});var o=e.push?{}:r?i[e.name]:i;(function(e,i,n,r){if(r&&!n)i[r]=t(e[1]);else for(var o=0;o<n.length;o+=1)null!=e[o+1]&&(i[n[o]]=t(e[o+1]))})(n.match(e.reg),o,e.names,e.name),e.push&&i[e.push].push(o)},n=db(),r=RegExp.prototype.test.bind(/^([a-z])=(.*)/);e.parse=function(e){var t={},o=[],s=t;return e.split(/(\r\n|\r|\n)/).filter(r).forEach((function(e){var t=e[0],r=e.slice(2);"m"===t&&(o.push({rtp:[],fmtp:[]}),s=o[o.length-1]);for(var a=0;a<(n[t]||[]).length;a+=1){var c=n[t][a];if(c.reg.test(r))return i(c,s,r)}})),t.media=o,t};var o=function(e,i){var n=i.split(/=(.+)/,2);return 2===n.length?e[n[0]]=t(n[1]):1===n.length&&i.length>1&&(e[n[0]]=void 0),e};e.parseParams=function(e){return e.split(/;\s?/).reduce(o,{})},e.parseFmtpConfig=e.parseParams,e.parsePayloads=function(e){return e.toString().split(" ").map(Number)},e.parseRemoteCandidates=function(e){for(var i=[],n=e.split(" ").map(t),r=0;r<n.length;r+=3)i.push({component:n[r],ip:n[r+1],port:n[r+2]});return i},e.parseImageAttributes=function(e){return e.split(" ").map((function(e){return e.substring(1,e.length-1).split(",").reduce(o,{})}))},e.parseSimulcastStreamList=function(e){return e.split(";").map((function(e){return e.split(",").map((function(e){var i,n=!1;return"~"!==e[0]?i=t(e):(i=t(e.substring(1,e.length)),n=!0),{scid:i,paused:n}}))}))}})),hb=ib(((e,t)=>{var i=db(),n=/%[sdv%]/g,r=function(e){var t=1,i=arguments,r=i.length;return e.replace(n,(function(e){if(t>=r)return e;var n=i[t];switch(t+=1,e){case"%%":return"%";case"%s":return String(n);case"%d":return Number(n);case"%v":return""}}))},o=function(e,t,i){var n=[e+"="+(t.format instanceof Function?t.format(t.push?i:i[t.name]):t.format)];if(t.names)for(var o=0;o<t.names.length;o+=1){var s=t.names[o];t.name?n.push(i[t.name][s]):n.push(i[t.names[o]])}else n.push(i[t.name]);return r.apply(null,n)},s=["v","o","s","i","u","e","p","c","b","t","r","z","a"],a=["i","c","b","a"];t.exports=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 n=t.outerOrder||s,r=t.innerOrder||a,c=[];return n.forEach((function(t){i[t].forEach((function(i){i.name in e&&null!=e[i.name]?c.push(o(t,i,e)):i.push in e&&null!=e[i.push]&&e[i.push].forEach((function(e){c.push(o(t,i,e))}))}))})),e.media.forEach((function(e){c.push(o("m",i.m[0],e)),r.forEach((function(t){i[t].forEach((function(i){i.name in e&&null!=e[i.name]?c.push(o(t,i,e)):i.push in e&&null!=e[i.push]&&e[i.push].forEach((function(e){c.push(o(t,i,e))}))}))}))})),c.join("\r\n")+"\r\n"}})),pb=ib((e=>{var t=ub(),i=hb();e.write=i,e.parse=t.parse,e.parseFmtpConfig=t.parseFmtpConfig,e.parseParams=t.parseParams,e.parsePayloads=t.parsePayloads,e.parseRemoteCandidates=t.parseRemoteCandidates,e.parseImageAttributes=t.parseImageAttributes,e.parseSimulcastStreamList=t.parseSimulcastStreamList})),mb=rb(lb()),_b=((BC=_b||{})[BC.INVALID_PARAMETER=4096]="INVALID_PARAMETER",BC[BC.INVALID_OPERATION=4097]="INVALID_OPERATION",BC[BC.NOT_SUPPORTED=4098]="NOT_SUPPORTED",BC[BC.DEVICE_NOT_FOUND=4099]="DEVICE_NOT_FOUND",BC[BC.INITIALIZE_FAILED=4100]="INITIALIZE_FAILED",BC[BC.SIGNAL_CHANNEL_SETUP_FAILED=16385]="SIGNAL_CHANNEL_SETUP_FAILED",BC[BC.SIGNAL_CHANNEL_ERROR=16386]="SIGNAL_CHANNEL_ERROR",BC[BC.ICE_TRANSPORT_ERROR=16387]="ICE_TRANSPORT_ERROR",BC[BC.JOIN_ROOM_FAILED=16388]="JOIN_ROOM_FAILED",BC[BC.CREATE_OFFER_FAILED=16389]="CREATE_OFFER_FAILED",BC[BC.SIGNAL_CHANNEL_RECONNECTION_FAILED=16390]="SIGNAL_CHANNEL_RECONNECTION_FAILED",BC[BC.UPLINK_RECONNECTION_FAILED=16391]="UPLINK_RECONNECTION_FAILED",BC[BC.DOWNLINK_RECONNECTION_FAILED=16392]="DOWNLINK_RECONNECTION_FAILED",BC[BC.REMOTE_STREAM_NOT_EXIST=16400]="REMOTE_STREAM_NOT_EXIST",BC[BC.CLIENT_BANNED=16448]="CLIENT_BANNED",BC[BC.SERVER_TIMEOUT=16449]="SERVER_TIMEOUT",BC[BC.SUBSCRIPTION_TIMEOUT=16450]="SUBSCRIPTION_TIMEOUT",BC[BC.PLAY_NOT_ALLOWED=16451]="PLAY_NOT_ALLOWED",BC[BC.DEVICE_AUTO_RECOVER_FAILED=16452]="DEVICE_AUTO_RECOVER_FAILED",BC[BC.START_PUBLISH_CDN_FAILED=16453]="START_PUBLISH_CDN_FAILED",BC[BC.STOP_PUBLISH_CDN_FAILED=16454]="STOP_PUBLISH_CDN_FAILED",BC[BC.START_MIX_TRANSCODE_FAILED=16455]="START_MIX_TRANSCODE_FAILED",BC[BC.STOP_MIX_TRANSCODE_FAILED=16456]="STOP_MIX_TRANSCODE_FAILED",BC[BC.NOT_SUPPORTED_H264=16457]="NOT_SUPPORTED_H264",BC[BC.SWITCH_ROLE_FAILED=16458]="SWITCH_ROLE_FAILED",BC[BC.API_CALL_TIMEOUT=16459]="API_CALL_TIMEOUT",BC[BC.SCHEDULE_FAILED=16460]="SCHEDULE_FAILED",BC[BC.API_CALL_ABORTED=16461]="API_CALL_ABORTED",BC[BC.UNKNOWN=65535]="UNKNOWN",BC),fb=_b,gb=class extends Error{constructor(e){let{name:t="RtcError",message:i,code:n=fb.UNKNOWN,extraCode:r=0,constraint:o}=e,s="<".concat(function(e){for(let t in fb)if(fb[t]===e)return t;return"UNKNOWN"}(n)," 0x").concat(n.toString(16),">"),a="".concat(i).concat(o?" constraint: ".concat(o):"").concat(null!=i&&i.includes(s)?"":" ".concat(s));super(a),sb(this,"code"),sb(this,"extraCode"),sb(this,"message"),sb(this,"originMessage"),sb(this,"name"),sb(this,"constraint"),this.code=n,this.extraCode=r,this.name=t,this.message=a,this.constraint=o,this.originMessage=i}getCode(){return this.code}getExtraCode(){return this.extraCode}toString(){return this.originMessage}},Tb=gb,Eb=((new Date).getTime(),0),Sb=function(){return(new Date).getTime()+Eb},Ib=function(){let e=new Date;return e.setTime(Sb()),e.toLocaleString()},yb={};nb(yb,{bytes2ms:()=>KD,copyProperties:()=>zD,deepMerge:()=>bO,env:()=>vb,fibonacci:()=>eO,formatedTime:()=>DO,getConstructorName:()=>mO,getContainerFromElement:()=>kO,getEnv:()=>FD,getInternalVersion:()=>EO,getLoggerUrl:()=>HD,getMuteStateFromFlag:()=>yO,getNetworkQuality:()=>vO,getNetworkType:()=>WD,getOSType:()=>GD,getReconnectionTimeout:()=>tO,getStringByteLength:()=>PO,getSysInfo:()=>JD,getTerminalType:()=>jD,getTurnServer:()=>AO,getValueType:()=>iO,glog:()=>XD,ipv4ToUint32:()=>RO,isArray:()=>lO,isArrayOrObject:()=>CO,isAudioWorkletSupported:()=>_O,isBoolean:()=>aO,isConstructor:()=>pO,isEmpty:()=>IO,isFunction:()=>nO,isLangChinese:()=>$D,isMediaStreamTrack:()=>dO,isNumber:()=>sO,isObject:()=>cO,isOverseaSdkAppId:()=>BD,isPlainObject:()=>ZD,isPromise:()=>hO,isRemoteTrack:()=>uO,isString:()=>oO,isUndefined:()=>rO,ms2bytes:()=>YD,ms2samples:()=>QD,performanceNow:()=>gO,promiseAny:()=>fO,samples2ms:()=>qD,stringify:()=>OO,stringifyIncludeValue:()=>wO});var vb={};nb(vb,{ANDROID_VERSION:()=>xb,CHROME_MAJOR_VERSION:()=>Vk,CHROME_VERSION:()=>Uk,EDGE_VERSION:()=>Gb,EDG_MAJOR_VERSION:()=>zb,EDG_VERSION:()=>Jb,FIREFOX_MAJOR_VERSION:()=>Hb,FIREFOX_VERSION:()=>Bb,HUAWEI_VERSION:()=>Ck,IE_VERSION:()=>nk,IOS_MAIN_VERSION:()=>Wk,IOS_VERSION:()=>Gk,IPADQQB_VERSION:()=>mk,IS_ANDROID:()=>Mb,IS_ANDROID_WEBVIEW:()=>jk,IS_ANY_SAFARI:()=>Bk,IS_CHROME:()=>Mk,IS_CHROME_OS:()=>Tk,IS_CHROMIUM_BASE:()=>Lk,IS_EDG:()=>Wb,IS_EDGE:()=>jb,IS_ELECTRON:()=>Ik,IS_FIREFOX:()=>Fb,IS_HEADLESS_CHROME:()=>xk,IS_HUAWEI:()=>Rk,IS_HUAWEIBROWSER:()=>Ak,IS_IE:()=>ik,IS_IE8:()=>tk,IS_IOS:()=>Lb,IS_IOS_13_OR_14:()=>Kk,IS_IOS_15_1:()=>zk,IS_IPAD:()=>Db,IS_IPADQQB:()=>pk,IS_IPAD_PRO:()=>Ob,IS_IPHONE:()=>wb,IS_IPOD:()=>Pb,IS_LINUX:()=>gk,IS_LOCAL:()=>qk,IS_MAC:()=>fk,IS_MACQQB:()=>uk,IS_MIBROWSER:()=>yk,IS_MQQB:()=>ak,IS_NATIVE_ANDROID:()=>Ub,IS_OLD_ANDROID:()=>Vb,IS_OPPOBROWSER:()=>Nk,IS_SAFARI:()=>Fk,IS_SAFARI_15_1:()=>Jk,IS_SAMSUNGBROWSER:()=>bk,IS_SOGOU:()=>Yb,IS_SOGOUM:()=>Kb,IS_TBS:()=>Xb,IS_UCBROWSER:()=>Sk,IS_VIVOBROWSER:()=>Ok,IS_WECHAT:()=>rk,IS_WIN:()=>_k,IS_WQQB:()=>lk,IS_WX:()=>Ek,IS_X5MQQB:()=>sk,IS_XWEB:()=>Zb,MACQQB_VERSION:()=>hk,MI_VERSION:()=>vk,MQQB_VERSION:()=>ck,OPPO_VERSION:()=>Dk,SAFARI_VERSION:()=>Hk,SAMSUNG_VERSION:()=>kk,SOGOUM_VERSION:()=>qb,SOGOU_VERSION:()=>Qb,TBS_VERSION:()=>$b,USER_AGENT:()=>Ab,VIVO_VERSION:()=>wk,WECHAT_VERSION:()=>ok,WQQB_VERSION:()=>dk,XWEB_VERSION:()=>ek,browserInfo:()=>Qk,getBrowserInfo:()=>Xk,getChromeMajorVersion:()=>Pk,getOSName:()=>tN,getOSString:()=>iN,getUserAgentData:()=>Zk,isLocalStorageEnabled:()=>Yk});var Ab="undefined"==typeof navigator?"":navigator.userAgent,Rb=e=>new RegExp(e,"i").test(Ab),Cb=e=>{if(Rb(e)){let t=new RegExp("".concat(e,"\\/([\\d.]+)")),i=Ab.match(t);if(i&&i[1])return i[1]}return""},bb=e=>{if(Rb(e)){let t=new RegExp("".concat(e,"\\/(\\d+)")),i=Ab.match(t);if(i&&i[1])return parseFloat(i[1])}return NaN},kb=/AppleWebKit\/([\d.]+)/i.exec(Ab),Nb=kb?parseFloat(kb[1]):NaN,Db=Rb("iPad"),Ob="undefined"!=typeof navigator&&navigator.maxTouchPoints&&navigator.maxTouchPoints>2&&Rb("Macintosh"),wb=Rb("iPhone")&&!Db,Pb=Rb("iPod"),Lb=wb||Db||Pb||Ob,Mb=Rb("Android"),xb=function(){if(Mb){let e=Ab.match(/Android (\d+)(?:\.(\d+))?(?:\.(\d+))*/i);if(e){let t=e[1]&&parseFloat(e[1]),i=e[2]&&parseFloat(e[2]);if(t&&i)return parseFloat("".concat(e[1],".").concat(e[2]));if(t)return t}}return NaN}(),Vb=Mb&&Rb("webkit")&&xb<2.3,Ub=Mb&&xb<5&&Nb<537,Fb=Rb("Firefox"),Bb=Cb("Firefox"),Hb=bb("Firefox"),jb=Rb("Edge"),Gb=Cb("Edge"),Wb=Rb("Edg"),Jb=Cb("Edg"),zb=bb("Edg"),Kb=Rb("SogouMobileBrowser"),qb=Cb("SogouMobileBrowser"),Yb=Rb("MetaSr\\s"),Qb=Cb("MetaSr\\s"),Xb=Rb("TBS"),$b=Cb("TBS"),Zb=Rb("XWEB"),ek=Cb("XWEB"),tk=Rb("MSIE\\s8\\.0"),ik=Rb("MSIE\\/\\d+"),nk=function(){if(ik){let e=/MSIE\s(\d+)\.\d/.exec(Ab),t=e&&parseFloat(e[1]);return!t&&/Trident\/7.0/i.test(Ab)&&/rv:11.0/.test(Ab)&&(t=11),t}return NaN}(),rk=Rb("(micromessenger|webbrowser)"),ok=Cb("MicroMessenger"),sk=!Xb&&Rb("MQQBrowser")&&Rb("COVC"),ak=!Xb&&Rb("MQQBrowser")&&!Rb("COVC"),ck=ak||sk?Cb("MQQBrowser"):"",lk=!Xb&&Rb(" QQBrowser"),dk=Cb(" QQBrowser"),uk=!Xb&&Rb("QQBrowserLite"),hk=Cb("QQBrowserLite"),pk=!Xb&&Rb("MQBHD"),mk=Cb("MQBHD"),_k=Rb("Windows"),fk=!Lb&&Rb("MAC OS X"),gk=!Mb&&Rb("Linux"),Tk=Rb("CrOS"),Ek=Rb("MicroMessenger"),Sk=Rb("UCBrowser"),Ik=Rb("Electron"),yk=Rb("MiuiBrowser"),vk=Cb("MiuiBrowser"),Ak=Rb("HuaweiBrowser"),Rk=Rb("Huawei"),Ck=Cb("HuaweiBrowser"),bk=Rb("SamsungBrowser"),kk=Cb("SamsungBrowser"),Nk=Rb("HeyTapBrowser"),Dk=Cb("HeyTapBrowser"),Ok=Rb("VivoBrowser"),wk=Cb("VivoBrowser"),Pk=()=>bb("Chrome"),Lk=Rb("Chrome"),Mk=!jb&&!Yb&&!Kb&&!Xb&&!Zb&&!Wb&&!lk&&!yk&&!Ak&&!bk&&!Nk&&!Ok&&Lk,xk=Rb("HeadlessChrome"),Vk=Pk(),Uk=Cb("Chrome"),Fk=!Lk&&!ak&&!sk&&!uk&&!pk&&Rb("Safari"),Bk=Fk||Lb,Hk=Cb("Version"),jk=/Android.*(wv|.0.0.0)/.test(Ab),Gk=(()=>{if(Ob)return Hk;if(Lb){let e=Ab.match(/OS (\d+)_(\d+)/i);if(e&&e[1]){let t=e[1];return e[2]&&(t+=".".concat(e[2])),t}}return""})(),Wk=Number(Gk.split(".")[0]),Jk="15.1"===Hk,zk="15.1"===Gk,Kk=(()=>{let e=Number(Gk.split(".")[0]);return 14===e||13===e})(),qk="undefined"!=typeof location&&("file:"===location.protocol||"localhost"===location.hostname||"127.0.0.1"===location.hostname),Yk=(()=>{let e;return()=>{if(rO(e))try{e=!!window.localStorage}catch(FL){e=!1}return e}})(),Qk=Xk();function Xk(){let e=new Map([[Fb,["Firefox",Bb]],[Wb,["Edg",Jb]],[Mk,["Chrome",Uk]],[Fk,["Safari",Hk]],[Xb,["TBS",$b]],[Zb,["XWEB",ek]],[rk&&wb,["WeChat",ok]],[lk,["QQ(Win)",dk]],[ak,["QQ(Mobile)",ck]],[sk,["QQ(Mobile X5)",ck]],[uk,["QQ(Mac)",hk]],[pk,["QQ(iPad)",mk]],[yk,["MI",vk]],[Ak,["HW",Ck]],[bk,["Samsung",kk]],[Nk,["OPPO",Dk]],[Ok,["VIVO",wk]],[jb,["EDGE",Gb]],[Kb,["SogouMobile",qb]],[Yb,["Sogou",Qb]]]),t="unknown",i="unknown";return e.has(!0)&&([t,i]=e.get(!0)),{name:t,version:i}}var $k=null;function Zk(){return cb(this,null,(function*(){if($k)return $k;if(!navigator.userAgentData||!nO(navigator.userAgentData.getHighEntropyValues))return null;try{return $k=yield navigator.userAgentData.getHighEntropyValues(["architecture","bitness","model","platformVersion","fullVersionList"])}catch(UL){return null}}))}var eN=new Map([[Mb,"Android"],[Lb,"iOS"],[_k,"Windows"],[fk,"MacOS"],[gk,"Linux"],[Tk,"ChromeOS"]]),tN=function(){return eN.get(!0)?eN.get(!0):$k?$k.platform:"unknown"},iN=()=>{let e=tN();return e+="/".concat(Qk.name,"/").concat(Fk?Qk.version:Qk.version.split(".")[0]),null!=$k&&$k.platformVersion&&(e+="/".concat($k.platformVersion)),null!=$k&&$k.architecture&&(e+="/".concat($k.architecture)),e},nN={};nb(nN,{AUDIO_MUTE_BIT:()=>GN,AUDIO_STAT_BIT:()=>jN,AUX_STAT_BIT:()=>HN,AUX_STREAM_MSID:()=>zN,BACKEND_ENV:()=>VN,BASE_DOC_URL:()=>EN,BASE_HOST:()=>_N,CAPABILITIES_KEYS:()=>VD,CLASS_NAME:()=>AD,CLOUD_CONSOLE_URL:()=>TN,DATA_FREEZE_TIMING:()=>gD,DOC_URL:()=>SN,DTLS_STATE_UNKNOWN:()=>iD,ENV_NAME:()=>RN,EXCHANGE_SDP_TIMEOUT:()=>hD,INTERVAL:()=>MD,IS_WORKER:()=>dN,IS_WORKLET:()=>uN,KIBANA_EVENT:()=>lD,LOCAL_STREAM_PUBLISH_STATE:()=>fD,LOGGER_CMD_TYPE:()=>AN,LOGGER_DOMAIN:()=>IN,LOGGER_DOMAIN_OVERSEA:()=>yN,LOG_LEVEL:()=>CN,LOG_LEVEL_NAME:()=>ND,MAIN_STREAM_MSID:()=>JN,MICROPHONE_COMMUNICATIONS:()=>kD,MICROPHONE_DEFAULT:()=>CD,NAME:()=>MN,NETWORK_TYPE:()=>NN,NOT_SUPPORTED_H264:()=>_D,PAUSED_RETRY_COUNT:()=>RD,PEERCONNECTION_CONNECTING_TIMEOUT:()=>ID,PEER_CONNECTION_STATE:()=>nD,PEER_LEAVE_REASON:()=>DD,RAF:()=>LD,RECOVER_CAPTURE_INTERVAL:()=>wD,REMOTE_STREAM_TYPE_AUX:()=>qN,REMOTE_STREAM_TYPE_MAIN:()=>KN,RENDER_FREEZE_TIMING:()=>TD,RIC:()=>PD,SCHEDULE_DOMAIN:()=>yD,SCHEDULE_TIMEOUT:()=>vD,SDP_SEMANTICS_PLAN_B:()=>mD,SDP_SEMANTICS_UNIFIED_PLAN:()=>pD,SECOND_HOST:()=>fN,SIGNAL_PING_PONG_INTERVAL:()=>kN,SIGNAL_PING_TIMEOUT:()=>bN,SIGNAL_RECONNECTION_COUNT:()=>cD,SMALL_STAT_BIT:()=>BN,SPEAKER_DEFAULT:()=>bD,STORAGE_EXPIRES_TIME:()=>DN,STREAM_TYPE_BIG:()=>ED,STREAM_TYPE_SMALL:()=>SD,SUBSCRIBE_SMALL_RETRY_COUNT:()=>OD,SYNC_USER_LIST_INTERVAL:()=>dD,Scene:()=>UN,Switch:()=>ON,THIRD_HOST:()=>gN,TIMEOUT:()=>xD,TRANSPORT_DIRECTION:()=>xN,TRTC_ERROR_ASSISTANCE:()=>vN,TRTC_QUALITY_BAD:()=>ZN,TRTC_QUALITY_DISCONNECTED:()=>tD,TRTC_QUALITY_EXCELLENT:()=>QN,TRTC_QUALITY_GOOD:()=>XN,TRTC_QUALITY_POOR:()=>$N,TRTC_QUALITY_UNKNOWN:()=>YN,TRTC_QUALITY_VERY_BAD:()=>eD,UPDATE_OFFER_TIMEOUT:()=>uD,VIDEO_MUTE_BIT:()=>WN,VIDEO_STAT_BIT:()=>FN,audioProfileMap:()=>wN,getRetryCount:()=>sD,getScriptDir:()=>hN,innerVersion:()=>rN,loggerProxy:()=>pN,screenProfileMap:()=>LN,setLoggerProxy:()=>mN,setRetryCount:()=>oD,setVersion:()=>sN,version:()=>oN,videoProfileMap:()=>PN});var rN="4.15.00.1600",oN="5.0.0";function sN(e){oN=e;let[t,i,n]=e.split(".").map((e=>parseInt(e,10)));rN="".concat(t,".").concat(Math.min(15,i),".").concat(Math.min(15,n),".").concat(i.toString().padStart(2,"0")).concat(n.toString().padStart(2,"0"))}var aN,cN,lN,dN="undefined"!=typeof importScripts,uN="undefined"!=typeof registerProcessor,hN=()=>{let e=dN?self.location.href:document.currentScript.src;return e.substring(0,e.lastIndexOf("/")+1)},pN="",mN=e=>pN=e,_N="web.sdk.qcloud.com",fN="web.sdk.tencent.cn",gN="web.sdk.cloud.tencent.cn",TN="https://console.cloud.tencent.com/trtc",EN="https://".concat(_N,"/trtc/webrtc/v5/doc"),SN="".concat(EN,"/zh-cn/"),IN="https://yun.tim.qq.com",yN="https://apisgp.my-imcloud.com",vN="trtc_error_assistance",AN={LOG:"jssdk_log",EVENT:"jssdk_event",KEY_POINT:"jssdk_new_endreport"},RN={QCLOUD:"qcloud",OLD_CLOUD_LADDER:"trtc",WEBRTC:"webrtc"},CN=((lN=CN||{})[lN.TRACE=0]="TRACE",lN[lN.DEBUG=1]="DEBUG",lN[lN.INFO=2]="INFO",lN[lN.WARN=3]="WARN",lN[lN.ERROR=4]="ERROR",lN[lN.NONE=5]="NONE",lN),bN=18e3,kN=2e3,NN={unknown:0,wifi:1,"3g":2,"2g":3,"4g":4,wired:5},DN=6048e5,ON=((cN=ON||{}).USEAINS="useAINS",cN.ENABLEDEBUG="enableDebug",cN.USEV2="useV2",cN.USEWT="useWt",cN),wN={standard:{sampleRate:48e3,channelCount:1,bitrate:40},"standard-stereo":{sampleRate:48e3,channelCount:2,bitrate:64},high:{sampleRate:48e3,channelCount:1,bitrate:192},"high-stereo":{sampleRate:48e3,channelCount:2,bitrate:192}},PN={"120p":{width:160,height:120,frameRate:15,bitrate:200},"120p_2":{width:160,height:120,frameRate:15,bitrate:100},"180p":{width:320,height:180,frameRate:15,bitrate:350},"180p_2":{width:320,height:180,frameRate:15,bitrate:150},"240p":{width:320,height:240,frameRate:15,bitrate:400},"240p_2":{width:320,height:240,frameRate:15,bitrate:200},"360p":{width:640,height:360,frameRate:15,bitrate:800},"360p_2":{width:640,height:360,frameRate:15,bitrate:400},"480p":{width:640,height:480,frameRate:15,bitrate:900},"480p_2":{width:640,height:480,frameRate:15,bitrate:500},"720p":{width:1280,height:720,frameRate:15,bitrate:1500},"1080p":{width:1920,height:1080,frameRate:15,bitrate:2e3},"1440p":{width:2560,height:1440,frameRate:30,bitrate:4860},"4K":{width:3840,height:2160,frameRate:30,bitrate:9e3}},LN={"480p":{width:640,height:480,frameRate:5,bitrate:900},"480p_2":{width:640,height:480,frameRate:30,bitrate:1e3},"720p":{width:1280,height:720,frameRate:5,bitrate:1200},"720p_2":{width:1280,height:720,frameRate:30,bitrate:3e3},"1080p":{width:1920,height:1080,frameRate:5,bitrate:1600},"1080p_2":{width:1920,height:1080,frameRate:30,bitrate:4e3}},MN={CANVAS:"canvas",AUDIO:"audio",VIDEO:"video",SCREEN:"screen",SMALL:"small",BIG:"big",AUXILIARY:"auxiliary",SMALL_VIDEO:"smallVideo",FACING_MODE_USER:"user",FACING_MODE_ENVIRONMENT:"environment",MUTE:"mute",UNMUTE:"unmute",ENDED:"ended",PLAYING:"playing",PAUSE:"pause",ERROR:"error",LOADEDDATA:"loadeddata",AUDIO_INPUT:"audioinput",VIDEO_INPUT:"videoinput",DETAIL:"detail",TEXT:"text",MAIN:"main",BACKUP:"backup",BANNED:"banned",KICK:"kick",USER_TIME_OUT:"user_time_out",ROOM_DISBAND:"room_disband",SEI_MESSAGE:"sei-message",ADD:"add",REMOVE:"remove",REPLACE:"replace",TRACK:"track",SUBSCRIBE:"subscribe",UNSUBSCRIBE:"unsubscribe",TRANSCEIVER_DIRECTION_SENDONLY:"sendonly",TRANSCEIVER_DIRECTION_RECVONLY:"recvonly",ENTER_PICTURE_IN_PICTURE:"enterpictureinpicture",LEAVE_PICTURE_IN_PICTURE:"leavepictureinpicture"},xN={INACTIVE:"inactive",SENDONLY:"sendonly",RECVONLY:"recvonly"},VN={OLD_CLOUD_LADDER:"wss://trtc.rtc.qq.com",WEBRTC:"wss://webrtc.qq.com"},UN=((aN=UN||{}).LIVE="live",aN.RTC="rtc",aN),FN=1,BN=2,HN=4,jN=8,GN=64,WN=16,JN="5Y2wZK8nANNAoVw6dSAHVjNxrD1ObBM2kBPV",zN="224d130c-7b5c-415b-aaa2-79c2eb5a6df2",KN=MN.MAIN,qN=MN.AUXILIARY,YN=0,QN=1,XN=2,$N=3,ZN=4,eD=5,tD=6,iD="unknown",nD={NEW:"new",CONNECTING:"connecting",FAILED:"failed",CLOSED:"closed",DISCONNECTED:"disconnected",CONNECTED:"connected",COMPLETED:"completed"},rD=1/0;function oD(e){rD=e}function sD(){return rD}var aD,cD=30,lD={JOIN:"join",DELTA_JOIN:"delta-join",REJOIN:"rejoin",LEAVE:"leave",DELTA_LEAVE:"delta-leave",PUBLISH:"publish",DELTA_PUBLISH:"delta-publish",UNPUBLISH:"unpublish",SUBSCRIBE:"subscribe",UNSUBSCRIBE:"unsubscribe",UPLINK_CONNECTION:"uplink-connection",UPLINK_RECONNECTION:"uplink-reconnection",DOWNLINK_CONNECTION:"downlink-connection",DOWNLINK_RECONNECTION:"downlink-reconnection",ON_TRACK:"ontrack",ICE_CONNECTION_STATE:"iceConnectionState",LOCAL_STREAM_INITIALIZE:"stream-initialize",SIGNAL_CONNECTION:"websocketConnectionState",SIGNAL_RECONNECTION:"websocketReconnectionState",UPDATE_STREAM:"update-stream",RECOVER_LOCAL_AUDIO_TRACK:"recover-local-audio-track",RECOVER_LOCAL_VIDEO_TRACK:"recover-local-video-track",RECOVER_SUBSCRIPTION:"recover-subscription",START_MIX_TRANSCODE:"start-mix-transcode",STOP_MIX_TRANSCODE:"stop-mix-transcode",PLAYER_ERROR:"player-error",SCHEDULE:"schedule",LOAD_WORKLET:"load-worklet",VIDEO_FROZEN_COUNT:"videoFrozenCount",GET_USER_MEDIA_RETRY:"getUserMedia-retry"},dD=1e4,uD=1e4,hD=1e4,pD="unified-plan",mD="plan-b",_D=1028,fD=((aD=fD||{})[aD.UNPUBLISH=-1]="UNPUBLISH",aD[aD.PUBLISHING=0]="PUBLISHING",aD[aD.PUBLISHED=1]="PUBLISHED",aD),gD=500,TD=1e3,ED=MN.BIG,SD=MN.SMALL,ID=1e4,yD={MAIN:"schedule.rtc.qq.com",BACKUP:"schedule.rtc.qcloud.com",MAIN_OVERSEA:"schedule.rtc.tencentcloud.com",BACKUP_OVERSEA:"schedule-ecdn.rtc.tencentcloud.com"},vD=2e3,AD={TRTC:"TRTC",CLIENT:"Client",LOCAL_STREAM:"LocalStream",REMOTE_STREAM:"RemoteStream",STREAM:"Stream"},RD=5,CD="default",bD=CD,kD="communications",ND=Object.keys(CN),DD=["normal leave","timeout leave","kick","role change"],OD=10,wD=2e3,PD="ric",LD="raf",MD="interval",xD="timeout",VD=["width","height","frameRate","facingMode","sampleRate","sampleSize","channelCount","deviceId"],UD=1e8,FD=function(){return new URLSearchParams(location.search).get("trtc_env")||""},BD=e=>Number(e)<14e8,HD=function(e,t){let i;i=pN||(BD(e)?yN:IN);let n=Math.floor(Math.random()*$C(2,31));return"".concat(i,"/v5/AVQualityReportSvc/C2S?random=").concat(n,"&sdkappid=").concat(e,"&cmdtype=").concat(t)};function jD(){return Mb?4:wb?2:Db?3:fk?12:_k?5:gk?13:1}function GD(){return Mb?"Android":wb?"iPhone":Db?"iPad":fk?"Mac":_k?"Windows":gk?"Linux":"unknown"}function WD(){let{userAgent:e,connection:t}=navigator,i=(e.match(/NetType\/\S+/)||[])[0]||"";i=i.toLowerCase().replace("nettype/",""),"3gnet"===i&&(i="3g");let n=t&&t.type&&t.type.toLowerCase(),r=t&&t.effectiveType&&t.effectiveType.toLowerCase();"slow-2"===r&&(r="2g");let o=i||"unknown";if(n)switch(n){case"cellular":case"wimax":o=r||"unknown";break;case"wifi":o="wifi";break;case"ethernet":o="wired";break;default:o="unknown"}return o}var JD=function(e){return{AbilityOption:{AVLimit:e,GeneralLimit:{CPULimit:{uint32_CPU_num:navigator.hardwareConcurrency||0,str_CPU_name:String(navigator.platform),uint32_CPU_maxfreq:0,model:"",uint32_total_memory:0},uint32_terminal_type:jD(),uint32_device_type:0,str_os_verion:GD(),uint32_link_type:1,str_client_version:rN,uint32_net_type:NN[WD()],ua:navigator.userAgent,version:""}}}};function zD(e,t){for(let i of Reflect.ownKeys(t))if("constructor"!==i&&"prototype"!==i&&"name"!==i){let n=Object.getOwnPropertyDescriptor(t,i)||"";Object.defineProperty(e,i,n)}return e}function KD(e){return qD(e/4,arguments.length>1&&void 0!==arguments[1]?arguments[1]:48e3)}function qD(e){return 1e3*e/(arguments.length>1&&void 0!==arguments[1]?arguments[1]:48e3)}function YD(e){return 4*QD(e,arguments.length>1&&void 0!==arguments[1]?arguments[1]:48e3)}function QD(e){return e*(arguments.length>1&&void 0!==arguments[1]?arguments[1]:48e3)/1e3}var XD="undefined"!=typeof window&&"function"==typeof window.glog?window.glog:()=>{},$D=()=>{let e=navigator.language;return e=e.substring(0,2),"zh"===e},ZD=function(e){if(!e||"object"!=typeof e||"[object Object]"!=Object.prototype.toString.call(e))return!1;let t=Object.getPrototypeOf(e);if(null===t)return!0;let i=Object.prototype.hasOwnProperty.call(t,"constructor")&&t.constructor;return"function"==typeof i&&i instanceof i&&Function.prototype.toString.call(i)===Function.prototype.toString.call(Object)};function eO(e){let t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1;return e<=1?t:eO(e-1,t,(arguments.length>1&&void 0!==arguments[1]?arguments[1]:1)+t)}function tO(e){return e>8?3e4:1e3*eO(e)}function iO(e){return Reflect.apply(Object.prototype.toString,e,[]).replace(/^\[object\s(\w+)\]$/,"$1").toLowerCase()}var nO=e=>"function"==typeof e,rO=e=>void 0===e,oO=e=>"string"==typeof e,sO=e=>"number"==typeof e,aO=e=>"boolean"==typeof e,cO=e=>"object"===iO(e),lO=e=>"array"===iO(e),dO=e=>iO(e)==="MediaStreamTrack".toLowerCase(),uO=e=>e.isRemote,hO=e=>"promise"===iO(e),pO=e=>nO(e)&&e.prototype.constructor===e,mO=e=>pO(e)?e.prototype.constructor.name:"",_O="undefined"!=typeof AudioWorkletNode;function fO(e){return new Promise(((t,i)=>{let n=[];e.forEach((r=>{r.then(t).catch((t=>{n.push(t),n.length===e.length&&i(n)}))}))}))}function gO(){return performance&&performance.now?Math.floor(performance.now()):Date.now()}var TO=e=>+e<10?"0".concat(e):e,EO=e=>{let t=e.match(/^\d+\.\d+\.\d+/)[0];if(!t)return e;let i=t.split("."),n=TO(i[1])+TO(i[2]);return i[1]-15>0&&(i[1]="15"),i[2]-15>0&&(i[2]="15"),"".concat(i.join("."),".").concat(n)},SO=Object.prototype.hasOwnProperty;function IO(e){if(null==e)return!0;if("boolean"==typeof e)return!1;if("number"==typeof e)return 0===e;if("string"==typeof e||"function"==typeof e||Array.isArray(e))return 0===e.length;if(e instanceof Error)return""===e.message;if(ZD(e))switch(Object.prototype.toString.call(e)){case"[object File]":case"[object Map]":case"[object Set]":return 0===e.size;case"[object Object]":for(let t in e)if(SO.call(e,t))return!1;return!0}return!1}function yO(e,t){return{userId:t,hasAudio:!!(e&jN),hasVideo:!!(e&FN),hasAuxiliary:!!(e&HN),hasSmall:!!(e&BN),audioMuted:!!(e&GN),videoMuted:!!(e&WN),audioAvailable:!(!(e&jN)||e&GN),videoAvailable:!(!(e&FN)||e&WN)}}function vO(e,t){return e>50||t>500?5:e>30||t>350?4:e>20||t>200?3:e>10||t>100?2:e>=0||t>=0?1:0}function AO(e){let t={urls:"turn:".concat(e.url)};return!rO(e.username)&&!rO(e.credential)&&(t.username=e.username,t.credential=e.credential,t.credentialType="password",rO(e.credentialType)||(t.credentialType=e.credentialType)),t}function RO(e){let t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];if(!oO(e))return 0;let i=e.split(".");return t?(Number(i[0])<<24|Number(i[1])<<16|Number(i[2])<<8|Number(i[3]))>>>0:(Number(i[3])<<24|Number(i[2])<<16|Number(i[1])<<8|Number(i[0]))>>>0}var CO=function(e){return lO(e)||cO(e)},bO=function(e,t,i,n){if(!CO(e)||!CO(t))return 0;let r,o=0,s=Object.keys(t);for(let a=0,c=s.length;a<c;a++)if(r=s[a],!(rO(t[r])||i&&i.includes(r)))if(CO(e[r])&&CO(t[r]))o+=bO(e[r],t[r],i,n);else{if(n&&n.includes(t[r]))continue;e[r]!==t[r]&&(e[r]=t[r],o+=1)}return o},kO=e=>oO(e)?document.getElementById(e):e,NO=new Intl.DateTimeFormat("zh-CN",{dateStyle:"short",timeStyle:"medium"}),DO=()=>NO.format(new Date);function OO(e,t){let{keysToInclude:i,keysToExclude:n}=t;try{if(lO(e))return"[".concat(e.map((e=>OO(e,{keysToInclude:i,keysToExclude:n}))).join(","),"]");if(!ZD(e)||!lO(i)&&!lO(n))return JSON.stringify(e);let t={},r=new Set(i),o=new Set(n);return Object.keys(e).forEach((s=>{(0===o.size&&r.has(s)||0===r.size&&!o.has(s))&&(t[s]=ZD(e[s])||lO(e[s])?JSON.parse(OO(e[s],{keysToExclude:n,keysToInclude:i})):e[s])})),JSON.stringify(t)}catch(aD){return"{}"}}function wO(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],i=[];return Object.keys(e).forEach((n=>{t===e[n]&&i.push(n)})),OO(e,{keysToInclude:i})}function PO(e){return e.replace(/[\u4e00-\u9fa5]/g,"aa").length}function LO(e){let{url:t,body:i,method:n,timeout:r}=e,o=new XMLHttpRequest;return new Promise(((e,s)=>{o.onreadystatechange=()=>{if(4===o.readyState)if(o.status>=200&&o.status<300)try{let t=JSON.parse(o.response);e({data:t})}catch(JV){e({data:o.response})}else s({status:o.status,statusText:o.statusText||"request failed!"})},o.timeout=r||5e3,o.open(n||"POST",t,!0),o.send(i)}))}var MO,xO=function(e){let{retryFunction:t,settings:i,onError:n,onRetrying:r,onRetryFailed:o,onRetrySuccess:s,context:a}=e;return function(){for(var e=arguments.length,c=new Array(e),l=0;l<e;l++)c[l]=arguments[l];let{retries:d=5,timeout:u=1e3}=i,h=0,p=-1,m=0,_=(e,i)=>cb(this,null,(function*(){let l=a||this;try{let i=yield t.apply(l,c);h>0&&s&&s.call(this,h),h=0,e(i)}catch(g){let s=()=>{clearTimeout(p),h=0,m=2,i(g)},a=()=>{2!==m&&h<(nO(d)?d():d)?(h++,m=1,nO(r)&&r.call(this,h,s),p=window.setTimeout((()=>{p=-1,_(e,i)}),nO(u)?u(h):u)):(s(),nO(o)&&o.call(this,g))};nO(n)?n.call(this,{error:g,retry:a,reject:i,retryFuncArgs:c,retryCount:h}):a()}}));return new Promise(_)}},VO=class{constructor(e){sb(this,"userId"),sb(this,"remoteUserId"),sb(this,"id"),sb(this,"sdkAppId"),sb(this,"type"),sb(this,"isLocal"),this.id=e.id,this.userId=e.userId,this.sdkAppId=e.sdkAppId,this.remoteUserId=e.remoteUserId,this.isLocal=!aO(e.isLocal)||e.isLocal,this.type=this.isLocal?"":e.type}createChild(e){return Object.setPrototypeOf(e,this)}setUserId(e){this.userId=e}setSdkAppId(e){this.sdkAppId=e}log(e,t){let i=this.isLocal?this.userId:this.remoteUserId;t.unshift("[".concat(this.isLocal?"↑":"↓").concat(this.type&&"main"!==this.type?"*":"").concat(this.id).concat(i?"|".concat(i):"","]")),jO.log(e,t,rO(this.userId)||IO(this.userId),this.userId,this.sdkAppId)}info(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];this.log(2,t)}debug(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];this.log(1,t)}warn(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];this.log(3,t)}error(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];this.log(4,t)}},UO=new(rb(lb(),1).default),FO=((MO=FO||{}).ROOM_DESTROY="1",MO.JOIN_START="21",MO.JOIN_SCHEDULE_SUCCESS="22",MO.JOIN_SIGNAL_CONNECTION_START="23",MO.JOIN_SIGNAL_CONNECTION_END="24",MO.JOIN_SEND_CMD="25",MO.JOIN_RECEIVED_CMD_RES="26",MO.JOIN_SUCCESS="27",MO.JOIN_FAILED="28",MO.LEAVE_START="51",MO.LEAVE_SEND_CMD="52",MO.LEAVE_SUCCESS="53",MO.PUBLISH_START="61",MO.SEND_FIRST_VIDEO_FRAME="62",MO.PUBLISH_FAILED="63",MO.SUBSCRIBE_START="81",MO.SUBSCRIBE_SUCCESS="82",MO.SUBSCRIBE_FAILED="84",MO.UNSUBSCRIBE_SUCCESS="83",MO.LOCAL_TRACK_CAPTURE_START="101",MO.LOCAL_TRACK_CAPTURE_SUCCESS="102",MO.LOCAL_TRACK_CAPTURE_FAILED="103",MO.LOCAL_TRACK_PUBLISHED="104",MO.LOCAL_TRACK_UNPUBLISHED="105",MO.LOCAL_TRACK_REPLACED="106",MO.SWITCH_DEVICE_SUCCESS="107",MO.TRACK_MUTED="108",MO.TRACK_UNMUTED="109",MO.REMOTE_TRACK_SUBSCRIBED="110",MO.REMOTE_TRACK_UNSUBSCRIBED="111",MO.PLAY_TRACK_START="151",MO.PLAYER_STATE_CHANGED="152",MO.VIDEO_LOADED_DATA="153",MO.AUTOPLAY_DIALOG_CLICK_CONFIRM="154",MO.WORKLET_LOADED_SUCCESS="155",MO.WORKLET_LOADED_FAILED="156",MO.SIGNAL_CONNECTION_STATE_CHANGED="201",MO.PEER_CONNECTION_STATE_CHANGED="202",MO.SINGLE_CONNECTION_STAT="203",MO.HEARTBEAT_REPORT="251",MO.RECEIVED_PUBLISHED_USER_LIST="252",MO.REMOTE_PUBLISH_STATE_CHANGED="253",MO.AUDIO_LEVEL_INTERVAL="260",MO.NETWORK_QUALITY="261",MO.API_SUCCESS_RATE="262",MO),BO=FO,HO=!(Lb||Mb||xk),jO=new class{constructor(){sb(this,"_isEnableUploadLog",!0),sb(this,"_localJoinedUser",new Map),sb(this,"_queue",[]),sb(this,"_timeoutId",-1),sb(this,"_logLevel",1),sb(this,"_logLevelToUpload",2),!dN&&!uN&&(this.checkURLParam(),this.installEvents())}get isAbleToUpload(){return this._isEnableUploadLog&&-1!==this._timeoutId}installEvents(){UO.on(BO.JOIN_SCHEDULE_SUCCESS,(e=>{let{schedule:t}=e;var i;(null==(i=null==t?void 0:t.config)?void 0:i.logLevelToUpload)&&CN[t.config.logLevelToUpload]&&(this._logLevelToUpload=t.config.logLevelToUpload)})),UO.on(BO.JOIN_SUCCESS,(e=>{let{room:t}=e;this.addJoinedUser({userId:t.userId,sdkAppId:t.sdkAppId}),this.startUpload()})),UO.once(BO.JOIN_FAILED,(()=>{this.startUpload()})),UO.on(BO.LEAVE_SUCCESS,(e=>{let{room:t}=e;this.deleteJoinedUser(t.userId)}))}startUpload(){-1===this._timeoutId&&this.uploadInterval()}addJoinedUser(e){this._localJoinedUser.set(e.userId,e),this.startUpload()}deleteJoinedUser(e){this._localJoinedUser.delete(e)}uploadInterval(){this.upload().catch((()=>{})),this._timeoutId=window.setTimeout((()=>this.uploadInterval()),2e3)}getLogsToUpload(){let e={map:new Map,splicedQueue:[]};if(this._queue[0].forAllJoinedClients&&0===this._localJoinedUser.size)return e;let t=0;for(;t<this._queue.length&&50!==t;t++){let i=this._queue[t];if(i.forAllJoinedClients)this._localJoinedUser.forEach((t=>{let{userId:n,sdkAppId:r}=t;e.map.has(n)?e.map.get(n).logs.push(i):e.map.set(n,{userId:n,sdkAppId:r,logs:[i]})}));else if(oO(i.userId)&&sO(i.sdkAppId)){let{userId:t,sdkAppId:n}=i;e.map.has(t)?e.map.get(t).logs.push(i):e.map.set(t,{userId:t,sdkAppId:n,logs:[i]})}}return e.map.size>0&&(e.splicedQueue=this._queue.splice(0,t)),e}upload(){return cb(this,null,(function*(){if(0===this._queue.length||!this._isEnableUploadLog)return;let{map:e,splicedQueue:t}=this.getLogsToUpload();if(0===e.size)return;try{let t=[...e.values()];for(let e=0;e<t.length;e++){let{userId:i,sdkAppId:n,logs:r}=t[e];yield this.uploadLogWithRetry(JSON.stringify({timestamp:Ib(),sdkAppId:String(n),userId:i,version:oN,log:r.map((e=>e.log)).join("\n")}),n),r.forEach((e=>e.uploaded=!0))}}catch(cN){}let i=t.filter((e=>!e.uploaded));i.length>0&&(this._queue=i.concat(this._queue))}))}uploadLogWithRetry(e,t){return xO({retryFunction:()=>LO({url:HD(t,AN.LOG),body:e,timeout:5e3}),settings:{retries:3,timeout:1e3},onError:e=>{let{retry:t}=e;t()}})()}getPrefix(e){let t=new Date;t.setTime(Sb());let i=String(t.getMilliseconds());return"padStart"in String.prototype&&(i=i.toString().padStart(3,"0")),"[".concat(t.toTimeString().replace(/.*(\d{2}:\d{2}:\d{2}).*/,"$1"),":").concat(i,"] <").concat(CN[e],">")}getLogLevel(){return this._logLevel}setLogLevel(e){rO(CN[e])||(this._logLevel!==e&&this.info("setLogLevel",e),this._logLevel=e)}enableUploadLog(){this._isEnableUploadLog=!0}disableUploadLog(){this.warn("disableUploadLog"),this._isEnableUploadLog=!1}logChunkToString(e){if(oO(e))return e;try{return JSON.stringify(e)}catch(aN){return""}}log(e,t){let i=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],n=arguments.length>3?arguments[3]:void 0,r=arguments.length>4?arguments[4]:void 0;var o;if(t.unshift(this.getPrefix(e)),this._isEnableUploadLog&&e>=this._logLevelToUpload&&this._queue.push({log:t.reduce(((e,t)=>"".concat(e," ").concat(this.logChunkToString(t)).trim()),""),level:e,userId:n,sdkAppId:r,forAllJoinedClients:i}),e<this._logLevel)return;let s=(null==(o=CN[e])?void 0:o.toLowerCase())||"info";HO?console[s]("%cTRTC%c%s","padding: 1px 4px;border-radius: 3px;color: #fff;background: #1E88E5;","display: inline",...t):console[s](...t)}debug(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];this.log(1,t)}info(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];this.log(2,t)}warn(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];this.log(3,t)}error(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];this.log(4,t)}createLogger(e){return new VO(e)}checkURLParam(){let e=new URLSearchParams(location.search).get("logLevelToUpload"),t=e?Number(e):-1;CN[t]&&(this._logLevelToUpload=t)}},GO=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(e=>{let t=16*Math.random()|0;return("x"==e?t:3&t|8).toString(16)}))},WO=new class{constructor(){sb(this,"_prefix","TRTC"),sb(this,"_queue",new Map),this.checkStorage()}getRealKey(e){return"".concat(this._prefix,"_").concat(e)}checkStorage(){Yk()&&(setInterval(this.doFlush.bind(this),2e4),Object.keys(localStorage).filter((e=>{if(e.startsWith(this._prefix)){let t=JSON.parse(localStorage.getItem(e));if(t&&t.expiresIn<Date.now())return!0}return!1})).forEach((e=>localStorage.removeItem(e))))}doFlush(){if(Yk())try{for(let[e,t]of this._queue)localStorage.setItem(e,JSON.stringify(t))}catch(FL){jO.warn(FL)}}getItem(e){if(!Yk())return null;try{let t=JSON.parse(localStorage.getItem(this.getRealKey(e)));return t&&t.expiresIn>=Date.now()?t.value:null}catch(aN){jO.warn(aN)}}setItem(e,t){if(Yk())try{let i={expiresIn:Date.now()+DN,value:t};this._queue.set(this.getRealKey(e),i)}catch(aD){jO.warn(aD)}}deleteItem(e){if(!Yk())return!1;try{return e=this.getRealKey(e),this._queue.delete(e),localStorage.removeItem(e),!0}catch(aN){return jO.warn(aN),!1}}clear(){if(Yk())try{localStorage.clear()}catch(FL){jO.warn(FL)}}},JO={};nb(JO,{HTTPS_API:()=>uw,IS_GET_CAPABILITIES_SUPPORTED:()=>kw,IS_GET_SETTINGS_SUPPORTED:()=>bw,IS_SEI_SUPPORTED:()=>Nw,IS_SPC_SUPPORTED:()=>vw,basis:()=>Lw,checkSystemRequirementsInternal:()=>cw,decodeSupportStatus:()=>aw,encodeSupportStatus:()=>sw,getBrowserInfo:()=>ZO,getDisplayResolution:()=>pw,isAddTransceiverSupported:()=>yw,isBrowserSupported:()=>ew,isGetReceiversSupported:()=>Ew,isGetSendersSupported:()=>Sw,isGetTransceiversSupported:()=>Iw,isGetUserMediaSupported:()=>mw,isMediaDevicesSupported:()=>iw,isMediaSessionSupported:()=>ww,isMediaStreamTrackProcessorSupported:()=>ow,isReplaceTrackSupported:()=>Rw,isScreenCaptureApiAvailable:()=>dw,isSelectedCandidatePair:()=>hw,isSetParametersSupported:()=>Cw,isSmallStreamAPISupported:()=>fw,isSmallStreamSupported:()=>gw,isStopTransceiverSupported:()=>Aw,isTRTCSupported:()=>lw,isUnifiedPlanDefault:()=>Tw,isUsedInHttpProtocol:()=>rw,isWebAudioSupported:()=>_w,isWebCodecSupported:()=>Ow,isWebCodecsSupported:()=>tw,isWebRTCSupported:()=>Dw,isWebTransportSupported:()=>Pw});var zO={AVOID_REPEATED_CALL:"AVOID_REPEATED_CALL",INVALID_PARAMETER_REQUIRED:"INVALID_PARAMETER_REQUIRED",INVALID_PARAMETER_TYPE:"INVALID_PARAMETER_TYPE",INVALID_PARAMETER_EMPTY:"INVALID_PARAMETER_EMPTY",INVALID_PARAMETER_INSTANCE:"INVALID_PARAMETER_INSTANCE",INVALID_PARAMETER_RANGE:"INVALID_PARAMETER_RANGE",INVALID_PARAMETER_MIN:"INVALID_PARAMETER_MIN",INVALID_PARAMETER_MAX:"INVALID_PARAMETER_MAX",INVALID_PARAMETER_STREAMTYPE:"INVALID_PARAMETER_STREAMTYPE",API_CALL_TIMEOUT:"API_CALL_TIMEOUT",SIGNAL_CHANNEL_RECONNECTION_FAILED:"SIGNAL_CHANNEL_RECONNECTION_FAILED",SIGNAL_CHANNEL_SETUP_FAILED:"SIGNAL_CHANNEL_SETUP_FAILED",ERROR_MESSAGE:"ERROR_MESSAGE",EXCHANGE_SDP_TIMEOUT:"EXCHANGE_SDP_TIMEOUT",DOWNLINK_RECONNECTION_FAILED:"DOWNLINK_RECONNECTION_FAILED",EXCHANGE_SDP_FAILED:"EXCHANGE_SDP_FAILED",UPDATE_OFFER_TIMEOUT:"UPDATE_OFFER_TIMEOUT",UPLINK_RECONNECTION_FAILED:"UPLINK_RECONNECTION_FAILED",INVALID_RECORDID:"INVALID_RECORDID",INVALID_PURE_AUDIO:"INVALID_PURE_AUDIO",INVALID_STREAMID:"INVALID_STREAMID",INVALID_USER_DEFINE_RECORDID:"INVALID_USER_DEFINE_RECORDID",INVALID_USER_DEFINE_PUSH_ARGS:"INVALID_USER_DEFINE_PUSH_ARGS",INVALID_PROXY:"INVALID_PROXY",INVALID_JOIN:"INVALID_JOIN",INVALID_ROOMID_STRING:"INVALID_ROOMID_STRING",INVALID_ROOMID_INTEGER:"INVALID_ROOMID_INTEGER",INVALID_SIGNAL_CHANNEL:"INVALID_SIGNAL_CHANNEL",JOIN_ROOM_TIMEOUT:"JOIN_ROOM_TIMEOUT",JOIN_ROOM_FAILED:"JOIN_ROOM_FAILED",REJOIN_ROOM_FAILED:"REJOIN_ROOM_FAILED",INVALID_DESTROY:"INVALID_DESTROY",INVALID_PUBLISH:"INVALID_PUBLISH",INVALID_UNPUBLISH:"INVALID_UNPUBLISH",INVALID_AUDIENCE:"INVALID_AUDIENCE",INVALID_INITIALIZE:"INVALID_INITIALIZE",INVALID_DUPLICATE_PUBLISHING:"INVALID_DUPLICATE_PUBLISHING",INVALID_SUBSCRIBE_UNDEFINED:"INVALID_SUBSCRIBE_UNDEFINED",INVALID_SUBSCRIBE_LOCAL:"INVALID_SUBSCRIBE_LOCAL",INVALID_REMOTE_STREAM:"INVALID_REMOTE_STREAM",SUBSCRIBE_FAILED:"SUBSCRIBE_FAILED",INVALID_ROLE:"INVALID_ROLE",INVALID_PARAMETER_SWITCH_ROLE:"INVALID_PARAMETER_SWITCH_ROLE",INVALID_OPERATION_SWITCH_ROLE:"INVALID_OPERATION_SWITCH_ROLE",SWITCH_ROLE_TIMEOUT:"SWITCH_ROLE_TIMEOUT",SWITCH_ROLE_FAILED:"SWITCH_ROLE_FAILED",CLIENT_BANNED:"CLIENT_BANNED",INVALID_OPERATION_START_PUBLISH_CDN:"INVALID_OPERATION_START_PUBLISH_CDN",INVALID_OPERATION_STOP_PUBLISH_CDN:"INVALID_OPERATION_STOP_PUBLISH_CDN",INVALID_STREAM_ID:"INVALID_STREAM_ID",START_PUBLISH_CDN_FAILED:"START_PUBLISH_CDN_FAILED",STOP_PUBLISH_CDN_FAILED:"STOP_PUBLISH_CDN_FAILED",START_MIX_TRANSCODE:"START_MIX_TRANSCODE",STOP_MIX_TRANSCODE:"STOP_MIX_TRANSCODE",INVALID_AUDIO_VOLUME:"INVALID_AUDIO_VOLUME",ENABLE_SMALL_STREAM_PUBLISHED:"ENABLE_SMALL_STREAM_PUBLISHED",DISABLE_SMALL_STREAM_PUBLISHED:"DISABLE_SMALL_STREAM_PUBLISHED",NOT_SUPPORTED_SMALL_STREAM:"NOT_SUPPORTED_SMALL_STREAM",INVALID_SMALL_STREAM_PROFILE:"INVALID_SMALL_STREAM_PROFILE",INVALID_PARAMETER_REMOTE_STREAM:"INVALID_PARAMETER_REMOTE_STREAM",INVALID_OPERATION_CHANGE_SMALL:"INVALID_OPERATION_CHANGE_SMALL",REMOTE_NOT_PUBLISH_SMALL_STREAM:"REMOTE_NOT_PUBLISH_SMALL_STREAM",INVALID_SWITCH_DEVICE:"INVALID_SWITCH_DEVICE",INVALID_SWITCH_DEVICE_PUBLISHING:"INVALID_SWITCH_DEVICE_PUBLISHING",INVALID_REPLACE_TRACK:"INVALID_REPLACE_TRACK",INVALID_INITIALIZE_LOCAL_STREAM:"INVALID_INITIALIZE_LOCAL_STREAM",INVALID_ADD_TRACK_REPETITIVE:"INVALID_ADD_TRACK_REPETITIVE",INVALID_ADD_TRACK_REMOVING:"INVALID_ADD_TRACK_REMOVING",INVALID_ADD_TRACK_PUBLISHING:"INVALID_ADD_TRACK_PUBLISHING",INVALID_STREAM_INITIALIZED:"INVALID_STREAM_INITIALIZED",INVALID_ADD_TRACK_NUMBER:"INVALID_ADD_TRACK_NUMBER",INVALID_REMOVE_AUDIO_TRACK:"INVALID_REMOVE_AUDIO_TRACK",INVALID_REMOVE_AUDIO_ADDING:"INVALID_REMOVE_AUDIO_ADDING",INVALID_REMOVE_AUDIO_ON:"INVALID_REMOVE_AUDIO_ON",INVALID_REMOVE_TRACK_PUBLISHING:"INVALID_REMOVE_TRACK_PUBLISHING",INVALID_REMOVE_TRACK_NOT_TRACK:"INVALID_REMOVE_TRACK_NOT_TRACK",INVALID_REMOVE_TRACK_NUMBER:"INVALID_REMOVE_TRACK_NUMBER",INVALID_REPLACE_TRACK_NO_TRACK:"INVALID_REPLACE_TRACK_NO_TRACK",REPEAT_JOIN:"REPEAT_JOIN",CLIENT_DESTROYED:"CLIENT_DESTROYED",NOT_BUG_PACKAGE:"NOT_BUG_PACKAGE",START_MIX_TRANSCODE_FAILED:"START_MIX_TRANSCODE_FAILED",STOP_MIX_TRANSCODE_FAILED:"STOP_MIX_TRANSCODE_FAILED",MIX_TRANSCODE_NOT_STARTED:"MIX_TRANSCODE_NOT_STARTED",CANNOT_LESS_THAN_ZERO:"CANNOT_LESS_THAN_ZERO",MIX_PARAMS_VIDEO_FRAMERATE:"MIX_PARAMS_VIDEO_FRAMERATE",MIX_PARAMS_VIDEO_GOP:"MIX_PARAMS_VIDEO_GOP",MIX_PARAMS_AUDIO_BITRATE:"MIX_PARAMS_AUDIO_BITRATE",MIX_PARAMS_USER_Z_ORDER:"MIX_PARAMS_USER_Z_ORDER",MIX_PARAMS_NOT_SELF:"MIX_PARAMS_NOT_SELF",MIX_PARAMS_USER_STREAM:"MIX_PARAMS_USER_STREAM",INVALID_PLAY:"INVALID_PLAY",INVALID_ELEMENT_ID:"INVALID_ELEMENT_ID",INVALID_ELEMENT_ID_TYPE:"INVALID_ELEMENT_ID_TYPE",PLAY_FAILED:"PLAY_FAILED",INVALID_USERID:"INVALID_USERID",INVALID_CREATE_STREAM_SOURCE:"INVALID_CREATE_STREAM_SOURCE",INVALID_CREATE_STREAM_SCREEN:"INVALID_CREATE_STREAM_SCREEN",INVALID_CREATE_STREAM_AUDIO:"INVALID_CREATE_STREAM_AUDIO",INVALID_CREATE_STREAM_SCREEN_AUDIO:"INVALID_CREATE_STREAM_SCREEN_AUDIO",NOT_SUPPORTED_HTTP:"NOT_SUPPORTED_HTTP",NOT_SUPPORTED_WEBRTC:"NOT_SUPPORTED_WEBRTC",NOT_SUPPORTED_PROFILE:"NOT_SUPPORTED_PROFILE",NOT_SUPPORTED_MEDIA:"NOT_SUPPORTED_MEDIA",NOT_SUPPORTED_H264ENCODE:"NOT_SUPPORTED_H264ENCODE",NOT_SUPPORTED_H264DECODE:"NOT_SUPPORTED_H264DECODE",NOT_SUPPORTED_TRACK:"NOT_SUPPORTED_TRACK",NOT_SUPPORTED_SWITCH_DEVICE:"NOT_SUPPORTED_SWITCH_DEVICE",NOT_SUPPORTED_CAPTURE:"NOT_SUPPORTED_CAPTURE",NOT_SUPPORTED_AUX:"NOT_SUPPORTED_AUX",MICROPHONE_NOT_FOUND:"MICROPHONE_NOT_FOUND",CAMERA_NOT_FOUND:"CAMERA_NOT_FOUND",SIGNAL_RESPONSE_FAILED:"SIGNAL_RESPONSE_FAILED",CATCH_HANDLER_ERROR:"CATCH_HANDLER_ERROR",API_NOT_EXIST:"API_NOT_EXIST",CONNECTION_CLOSED:"CONNECTION_CLOSED",SUBSCRIBE_ALL_FALSE:"SUBSCRIBE_ALL_FALSE",SEI_NOT_SUPPORT:"SEI_NOT_SUPPORT",SEI_DISABLED:"SEI_DISABLED",SEI_EMPTY:"SEI_EMPTY",SEI_OVERSIZE:"SEI_OVERSIZE",SEI_BEFORE_PUBLISH:"SEI_BEFORE_PUBLISH",SEI_NOT_VIDEO:"SEI_NOT_VIDEO",CALL_FREQUENCY_LIMIT:"CALL_FREQUENCY_LIMIT",CONNECTION_ABORTED:"CONNECTION_ABORTED",API_CALL_ABORTED:"API_CALL_ABORTED",DUPLICATE_AUX:"DUPLICATE_AUX"},KO={AVOID_REPEATED_CALL:e=>"previous ".concat(e.name,"() is ongoing, please avoid repeated calls."),INVALID_PARAMETER_REQUIRED(e){let{key:t,rule:i,fnName:n,value:r}=e;return"'".concat(t||i.name,"' is a required param when calling ").concat(n,"(), received: ").concat(r,".")},INVALID_PARAMETER_TYPE(e){let{key:t,rule:i,fnName:n,value:r}=e,o="".concat(t||i.name),s="";return s=Array.isArray(i.type)?i.type.join("|"):i.type,"'".concat(o,"' must be type of ").concat(s," when calling ").concat(n,"(), received type: ").concat(iO(r),".")},INVALID_PARAMETER_EMPTY(e){let{key:t,rule:i,fnName:n,value:r}=e;return"'".concat(t||i.name,"' cannot be '").concat(r,"' when calling ").concat(n,"().")},INVALID_PARAMETER_INSTANCE(e){let{key:t,rule:i,fnName:n,value:r}=e,o="".concat(t||i.name),s="".concat(i.instanceOf.name||i.instanceOf);return"'".concat(o,"' must be instanceof ").concat(s," when calling ").concat(n,"(), received type: ").concat(iO(r),".")},INVALID_PARAMETER_RANGE(e){let{key:t,rule:i,fnName:n,value:r}=e;return"'".concat(t||i.name,"' must be one of ").concat(i.values.join("|")," when calling ").concat(n,"(), received: ").concat(r,".")},INVALID_PARAMETER_MIN(e){let{key:t,rule:i,fnName:n,value:r}=e;return"the min value of ".concat(t||i.name," is ").concat(i.min,", received: ").concat(r,".")},INVALID_PARAMETER_MAX(e){let{key:t,rule:i,fnName:n,value:r}=e;return"the max value of ".concat(t||i.name," is ").concat(i.max,", received: ").concat(r,".")},API_CALL_TIMEOUT:e=>"".concat(e.commandDesc||e.command," timeout observed."),SIGNAL_CHANNEL_RECONNECTION_FAILED:"signal channel reconnection failed, please check your network.",SIGNAL_CHANNEL_SETUP_FAILED:e=>"SignalChannel setup failure: (errorCode: ".concat(e.errorCode,", errorMsg: ").concat(e.errorMsg," })."),ERROR_MESSAGE(e){let t="".concat(e.type," failed");return e.message&&(t="".concat(t,": ").concat(e.message,".")),t},EXCHANGE_SDP_TIMEOUT:"exchange sdp timeout.",DOWNLINK_RECONNECTION_FAILED:"downlink reconnection failed, please check your network and re-join room.",EXCHANGE_SDP_FAILED:e=>"exchange sdp failed ".concat(e.errMsg,"."),UPDATE_OFFER_TIMEOUT:"update offer timeout observed.",UPLINK_RECONNECTION_FAILED:"uplink reconnection failed, please check your network and publish again.",INVALID_RECORDID:"recordId must be an integer number.",INVALID_PURE_AUDIO:"pureAudioPushMode must be 1 or 2.",INVALID_STREAMID:"streamId must be a sting literal within 64 bytes, and not be empty.",INVALID_USER_DEFINE_RECORDID:"userDefineRecordId must be a sting literal contains (a-zA-Z),(0-9), underline and hyphen, within 64 bytes, and not be empty.",INVALID_USER_DEFINE_PUSH_ARGS:"userDefinePushArgs must be a sting literal within 256 bytes, and not be empty.",INVALID_PROXY:'proxy server url must start with "wss://".',INVALID_JOIN:"duplicate join() called.",INVALID_ROOMID_STRING:e=>"'".concat(e,"' must be validate string when useStringRoomId is true."),INVALID_ROOMID_INTEGER:e=>"'".concat(e,"' must be an integer between [1, 4294967294] when useStringRoomId is false."),INVALID_SIGNAL_CHANNEL:"SignalChannel is not ready yet.",JOIN_ROOM_TIMEOUT:"join room timeout.",JOIN_ROOM_FAILED(e){let{error:t,code:i}=e;return"Failed to join room - ".concat(t," code: ").concat(i)},REJOIN_ROOM_FAILED:e=>"reJoin room: ".concat(e.roomId," failed, please check your network."),INVALID_DESTROY:"please call leave() before destroy().",INVALID_PUBLISH:"please call join() before publish().",INVALID_UNPUBLISH:"stream has not been published yet.",INVALID_AUDIENCE:"no permission to publish() under live/".concat("audience",', please call switchRole("',"anchor",'") firstly before publish().'),INVALID_INITIALIZE:"cannot publish stream because stream is not initialized, is switching device, or has been closed.",INVALID_DUPLICATE_PUBLISHING:e=>"duplicate ".concat(e," stream publishing, please unpublish your prev ").concat(e," stream and then re-publish."),INVALID_SUBSCRIBE_UNDEFINED:"stream is undefined or null.",INVALID_SUBSCRIBE_LOCAL:"stream cannot be LocalStream.",INVALID_REMOTE_STREAM:"remoteStream does not exist because it has been unpublished by remote peer.",SUBSCRIBE_FAILED(e){let{message:t,userId:i,streamType:n}=e;return"failed to subscribe ".concat(i," ").concat(n," stream, reason: ").concat(t,".")},INVALID_ROLE:"switchRole can only be called in live mode.",INVALID_PARAMETER_SWITCH_ROLE:"role could only be set to a value as ".concat("anchor"," or ","audience","."),INVALID_OPERATION_SWITCH_ROLE:"please call join() before switchRole().",SWITCH_ROLE_TIMEOUT:"switchRole timeout.",SWITCH_ROLE_FAILED:e=>"switchRole failed, errCode: ".concat(e.code," errMsg: ").concat(e.message,"."),CLIENT_BANNED:e=>"client was banned because of ".concat(e.message,"."),INVALID_OPERATION_START_PUBLISH_CDN:"please call startPublishCDNStream() after join room and publish the local stream.",INVALID_OPERATION_STOP_PUBLISH_CDN:"please call startPublishCDNStream() before stopPublishCDNStream().",START_PUBLISH_CDN_FAILED:e=>"startPublishCDNStream failed, errMsg: ".concat(e.message,"."),STOP_PUBLISH_CDN_FAILED:e=>"stopPublishCDNStream failed, errMsg: ".concat(e.message,"."),INVALID_STREAM_ID:e=>"'".concat(e,"' can only consist of uppercase and lowercase english letters (a-zA-Z), numbers (0-9), hyphens and underscores."),START_MIX_TRANSCODE:"please call startMixTranscode() after join().",STOP_MIX_TRANSCODE:"please call stopMixTranscode() after startMixTranscode().",INVALID_AUDIO_VOLUME:"interval must be a number.",ENABLE_SMALL_STREAM_PUBLISHED:"Cannot enable small stream after localStream published.",DISABLE_SMALL_STREAM_PUBLISHED:"Cannot disable small stream after localStream published.",NOT_SUPPORTED_SMALL_STREAM:"your browser does not support opening small stream.",INVALID_SMALL_STREAM_PROFILE:"small stream profile is invalid.",INVALID_PARAMETER_REMOTE_STREAM:"remoteStream is invalid.",INVALID_OPERATION_CHANGE_SMALL:"cannot switch to the small stream without subscribing to the video of remoteStream.",REMOTE_NOT_PUBLISH_SMALL_STREAM:"remote peer does not publish small stream.",INVALID_SWITCH_DEVICE:"cannot switch device on current stream.",INVALID_SWITCH_DEVICE_PUBLISHING:"cannot switch device when publishing localStream.",INVALID_REPLACE_TRACK:"cannot replace track when publishing localStream.",INVALID_INITIALIZE_LOCAL_STREAM:"local stream has not initialized yet.",INVALID_ADD_TRACK_REPETITIVE:"previous addTrack is ongoing, please avoid repetitive execution.",INVALID_ADD_TRACK_REMOVING:"cannot add track when a track is removing.",INVALID_ADD_TRACK_PUBLISHING:"cannot add track when publishing localStream.",INVALID_STREAM_INITIALIZED:"your local stream haven't been initialized yet.",INVALID_ADD_TRACK_NUMBER:"a Stream has at most one audio track and one video track.",INVALID_REMOVE_AUDIO_TRACK:"remove audio track is not supported on your browser.",INVALID_REMOVE_AUDIO_ADDING:"cannot remove track when a track is adding.",INVALID_REMOVE_AUDIO_ON:"previous removeTrack is ongoing, please avoid repetitive execution.",INVALID_REMOVE_TRACK_PUBLISHING:"cannot remove track when publishing localStream.",INVALID_REMOVE_TRACK_NOT_TRACK:"localStream has not this track.",INVALID_REMOVE_TRACK_NUMBER:"remove the only video track is not supported, please use replaceTrack or muteVideo.",INVALID_REPLACE_TRACK_NO_TRACK:e=>"cannot replace ".concat(e.kind," track because stream has not ").concat(e.kind," track"),NOT_BUG_PACKAGE:"You need to buy packages, refer to tencent console.",START_MIX_TRANSCODE_FAILED:e=>"startMixTranscode failed, errMsg: ".concat(e.message,"."),STOP_MIX_TRANSCODE_FAILED:e=>"stopMixTranscode failed, errMsg: ".concat(e.message,"."),MIX_TRANSCODE_NOT_STARTED:"mixTranscode has not been started.",CANNOT_LESS_THAN_ZERO(e){let{key:t,rule:i,fnName:n,value:r}=e;return"'".concat(t||i.name,"' cannot be less than 0 when calling ").concat(n,"().")},MIX_PARAMS_VIDEO_FRAMERATE:"'config.videoFramerate' should be an integer between 0 and 30, excluding 0.",MIX_PARAMS_VIDEO_GOP:"'config.videoGOP' should be an integer between 1 and 8.",MIX_PARAMS_AUDIO_BITRATE:"'config.audioBitrate' should be an integer between 32 and 192.",MIX_PARAMS_USER_Z_ORDER:e=>"'".concat(e,"' is required and must be between 1 and 15."),MIX_PARAMS_NOT_SELF:"'config.mixUsers' must contain self.",MIX_PARAMS_USER_STREAM:"'config.videoWidth' and 'config.videoHeight' of output stream should be contain all mix stream.",INVALID_PLAY:"duplicate play() call observed, please stop() firstly.",INVALID_ELEMENT_ID:e=>{let{key:t,fnName:i}=e;return"'".concat(t,"' is not found in the document object when calling ").concat(i,"().")},INVALID_ELEMENT_ID_TYPE:e=>{let{key:t,fnName:i,type:n}=e;return"the element corresponding to '".concat(t,"' must be instanceof HTMLElement when calling ").concat(i,"(), received: ").concat(n,".")},PLAY_FAILED:e=>"".concat(e.media," play failed,browser exception: ").concat(e.error.toString()),INVALID_USERID:"userId cannot be all spaces.",INVALID_CREATE_STREAM_SOURCE:"LocalStream must be created by createStream() with either audio/video or audioSource/videoSource, but can not be mixed with audio/video and audioSource/videoSource.",INVALID_CREATE_STREAM_SCREEN:"screen/video cannot be both true.",INVALID_CREATE_STREAM_AUDIO:"audio/screenAudio cannot be both true.",INVALID_CREATE_STREAM_SCREEN_AUDIO:"when screen is true, screenAudio can be configured.",NOT_SUPPORTED_HTTP:"http protocol does not support the ability to capture microphone, camera and screen. please use https to deploy your page.",NOT_SUPPORTED_WEBRTC:"your browser or environment does not support full WebRTC capabilities.",NOT_SUPPORTED_PROFILE:"your browser does not support setVideoProfile.",NOT_SUPPORTED_MEDIA:"your browser or environment does not support navigator.mediaDevices.",NOT_SUPPORTED_H264ENCODE:"your device does not support H.264 encoding.",NOT_SUPPORTED_H264DECODE:"your device does not support H.264 decoding.",NOT_SUPPORTED_TRACK:e=>"".concat(e,"Track is not supported on your browser."),NOT_SUPPORTED_SWITCH_DEVICE:"switchDevice is not supported on your browser.",NOT_SUPPORTED_CAPTURE:"Your browser or environment does not support screen sharing, please check whether the browser version.",MICROPHONE_NOT_FOUND:"no microphone detected, please check your microphone.",CAMERA_NOT_FOUND:"no camera detected, please check your camera.",SIGNAL_RESPONSE_FAILED:e=>"".concat(e.signalResponse," failed, response code is ").concat(e.code," , errMsg: ").concat(e.message,"."),CATCH_HANDLER_ERROR(e){let{name:t,event:i}=e;return"an error was caught on ".concat(t,".on('").concat(i,"', handler), please check your code on 'handler'.")},API_NOT_EXIST(e){let{name:t}=e;return"experimental api ".concat(t," does not exist.")},REPEAT_JOIN:e=>"[".concat(e,"] is calling client.join api or has already joined room, please avoid repeated join."),CONNECTION_CLOSED:"remoteStream has been unsubscribed or unpublished by remote user.",SUBSCRIBE_ALL_FALSE:"cannot subscribe when both audio & video are false, use client.unsubscribe() instead",CLIENT_DESTROYED(e){let{funName:t}=e;return"failed to call ".concat(t,"() because client was destroyed.")},SEI_NOT_SUPPORT:e=>"not support to sendSEIMessage".concat(!1===e?" without using h264 codec":""),SEI_DISABLED:"SEI is disabled",SEI_EMPTY:"buffer cannot be empty",SEI_OVERSIZE:e=>"buffer size(".concat(e,") is over 1000 Bytes"),SEI_BEFORE_PUBLISH:"please call sendSEIMessage() after publish() success",SEI_NOT_VIDEO:"cannot send sei when localStream has not video.",CALL_FREQUENCY_LIMIT:e=>{let{isSize:t,name:i,timesInSecond:n,maxSizeInSecond:r}=e;return"api ".concat(i," call ").concat(t?"size":"times"," is over ").concat(t?"".concat(r," bytes"):n," in a second.")},CONNECTION_ABORTED:e=>"connection aborted due to: ".concat(e),API_CALL_ABORTED(e){let t;return t=e.message.includes("REMOTE_STREAM_NOT_EXIST")?"Subscribe ".concat(e.userId," ").concat(e.streamType," stream aborted, reason: remote user ").concat(e.userId," unpublished stream."):"API aborted, reason: ".concat(e.message),t},DUPLICATE_AUX:"only one auxiliary stream can be published in a room.",NOT_SUPPORTED_AUX:"publish auxiliary stream is not supported on your browser.",INVALID_PARAMETER_STREAMTYPE:e=>"'streamType' is required when 'userId' is not '*', calling ".concat(e,"()")},qO=(e,t)=>t?"".concat(EN,"/").concat(e,"/").concat(t):"".concat(EN,"/").concat(e,"/index.html"),YO=()=>{if(window.TRTC_ERROR_INFO&&window.TRTC_ERROR_LINK)return{TRTC_ERROR_INFO:window.TRTC_ERROR_INFO,TRTC_ERROR_LINK:window.TRTC_ERROR_LINK};let e=localStorage.getItem(vN);if(e){e=JSON.parse(e);let t=document.createElement("script");t.type="text/javascript",t.text=e.message,document.body.appendChild(t);let i=window.TRTC_ERROR_INFO,n=window.TRTC_ERROR_LINK;return document.body.removeChild(t),{TRTC_ERROR_INFO:i,TRTC_ERROR_LINK:n}}return{}};function QO(e){let{key:t,data:i,link:n,addDocLink:r=!0}=e,o="",s="",a="";nO(KO[t])?o=KO[t](i):oO(KO[t])&&(o=KO[t]);let{TRTC_ERROR_INFO:c,TRTC_ERROR_LINK:l}=YO();n?a="".concat(n.className,".html#").concat(n.fnName):l&&l[t]&&(nO(l[t])?a=l[t](i):oO(l[t])&&(a=l[t]));let d=o;return $D()&&(c&&c[t]&&(nO(c[t])?s=c[t](i):oO(c[t])&&(s=c[t])),s&&(d=r?"".concat(s,"\n请查看文档: ").concat(qO("zh-cn",a),"\n\n"):"".concat(s,"\n\n"),d+=o)),r&&(d+=" \nRefer to: ".concat(qO("en",a),"\n")),d}var XO={result:!1,detail:{isBrowserSupported:!1,isWebRTCSupported:!1,isWebCodecsSupported:!1,isMediaDevicesSupported:!1,isScreenShareSupported:!1,isSmallStreamSupported:!1,isH264EncodeSupported:!1,isVp8EncodeSupported:!1,isH264DecodeSupported:!1,isVp8DecodeSupported:!1}},$O=new Map([[Fb,["Firefox",Bb]],[Wb,["Edg",Jb]],[Mk,["Chrome",Uk]],[Fk,["Safari",Hk]],[Xb,["TBS",$b]],[Zb,["XWEB",ek]],[rk&&wb,["WeChat",ok]],[lk,["QQ(Win)",dk]],[ak,["QQ(Mobile)",ck]],[sk,["QQ(Mobile X5)",ck]],[uk,["QQ(Mac)",hk]],[pk,["QQ(iPad)",mk]],[yk,["MI",vk]],[Ak,["HW",Ck]],[bk,["Samsung",kk]],[Nk,["OPPO",Dk]],[Ok,["VIVO",wk]],[jb,["EDGE",Gb]],[Kb,["SogouMobile",qb]],[Yb,["Sogou",Qb]]]);function ZO(){let e=$O.get(!0);return{browserName:e?e[0]:"unknown",browserVersion:e?e[1]:"unknown"}}var ew=function(){return!(Sk||jb||Wb&&zb<80||Fb&&Hb<56)},tw=function(){return["VideoDecoder","VideoEncoder","AudioEncoder","AudioDecoder","MediaStreamTrackGenerator"].every((e=>e in window))},iw=function(){if(!navigator.mediaDevices)return rw()||jO.error(KO.NOT_SUPPORTED_MEDIA),!1;let e=["getUserMedia","enumerateDevices"];return e.filter((e=>e in navigator.mediaDevices)).length===e.length},nw=!1;function rw(){return"http:"===location.protocol&&!qk&&(nw||jO.error(QO({key:zO.NOT_SUPPORTED_HTTP})),nw=!0,!0)}var ow=function(){return(null==window?void 0:window.OffscreenCanvas)&&(null==window?void 0:window.MediaStreamTrackProcessor)&&(null==window?void 0:window.MediaStreamTrackGenerator)},sw=function(){return cb(this,null,(function*(){if(XO.detail.isH264EncodeSupported||XO.detail.isVp8EncodeSupported)return{isH264EncodeSupported:XO.detail.isH264EncodeSupported,isVp8EncodeSupported:XO.detail.isVp8EncodeSupported};let e,t=!1,i=!1;try{let n=new RTCPeerConnection,r=document.createElement(MN.CANVAS);r.getContext("2d");let o=r.captureStream(0);return n.addTrack(o.getVideoTracks()[0],o),e=yield n.createOffer(),-1!==e.sdp.toLowerCase().indexOf("h264")&&(t=!0),-1!==e.sdp.toLowerCase().indexOf("vp8")&&(i=!0),n.close(),XO.detail.isH264EncodeSupported=t,XO.detail.isVp8EncodeSupported=i,{isH264EncodeSupported:XO.detail.isH264EncodeSupported,isVp8EncodeSupported:XO.detail.isVp8EncodeSupported}}catch(aD){return{isH264EncodeSupported:!1,isVp8EncodeSupported:!1}}}))},aw=function(){return cb(this,null,(function*(){if(XO.detail.isH264DecodeSupported&&XO.detail.isVp8DecodeSupported)return{isH264DecodeSupported:XO.detail.isH264DecodeSupported,isVp8DecodeSupported:XO.detail.isVp8DecodeSupported};let e,t=!1,i=!1;try{let n=new RTCPeerConnection;return e=yield n.createOffer({offerToReceiveAudio:!0,offerToReceiveVideo:!0}),-1!==e.sdp.toLowerCase().indexOf("h264")&&(t=!0),-1!==e.sdp.toLowerCase().indexOf("vp8")&&(i=!0),n.close(),{isH264DecodeSupported:t,isVp8DecodeSupported:i}}catch(aD){return{isH264DecodeSupported:!1,isVp8DecodeSupported:!1}}}))},cw=function(){return cb(this,null,(function*(){if(XO.result)return XO;let e=ew(),t=Dw(),i=tw(),n=iw(),{isH264EncodeSupported:r,isVp8EncodeSupported:o}=yield sw(),{isH264DecodeSupported:s,isVp8DecodeSupported:a}=yield aw();return XO.result=e&&t&&n&&(r||o)&&(s||a),XO.detail.isBrowserSupported=e,XO.detail.isWebRTCSupported=t,XO.detail.isWebCodecsSupported=i,XO.detail.isMediaDevicesSupported=n,XO.detail.isScreenShareSupported=dw(),XO.detail.isSmallStreamSupported=gw(),XO.detail.isH264EncodeSupported=r,XO.detail.isVp8EncodeSupported=o,XO.detail.isH264DecodeSupported=s,XO.detail.isVp8DecodeSupported=a,XO.result||jO.error("".concat(navigator.userAgent," ").concat(wO(XO.detail,!1))),XO}))},lw=function(){return XO.result},dw=function(){return!(!navigator.mediaDevices||!navigator.mediaDevices.getDisplayMedia)},uw=(e,t,i)=>{"http:"===location.protocol&&!qk&&(e[t]=()=>{throw new Tb({code:fb.INVALID_OPERATION,message:KO.NOT_SUPPORTED_HTTP})})},hw=function(e){return!("candidate-pair"!==e.type||!e.nominated||"in-progress"!==e.state&&"succeeded"!==e.state)&&!(aO(e.selected)&&!e.selected)};function pw(){let e="";if(screen.width){let t=screen.width?screen.width*window.devicePixelRatio:"",i=screen.height?screen.height*window.devicePixelRatio:"";e+="".concat(t," * ").concat(i)}return e}function mw(){return navigator.getUserMedia||navigator.mediaDevices&&navigator.mediaDevices.getUserMedia}function _w(){let e={isSupported:!1},t=["AudioContext","webkitAudioContext","mozAudioContext","msAudioContext"];for(let i=0;i<t.length;i++)if(t[i]in window){e.isSupported=!0;break}return e.isSupported}function fw(){return"captureStream"in HTMLCanvasElement.prototype}function gw(){return!(rk||Lb||Vk&&Vk<63)&&!(!ew()||!fw())}var Tw=function(){if(rO(window.RTCRtpTransceiver)||!("currentDirection"in RTCRtpTransceiver.prototype))return!1;let e=null,t=!1;try{e=new RTCPeerConnection({sdpSemantics:pD}),e.addTransceiver(MN.AUDIO),t=!0}catch(aN){}return null==e||e.close(),t};function Ew(){return"RTCPeerConnection"in window&&"getReceivers"in window.RTCPeerConnection.prototype}function Sw(){return"RTCPeerConnection"in window&&"getSenders"in window.RTCPeerConnection.prototype}function Iw(){return"RTCPeerConnection"in window&&"getTransceivers"in window.RTCPeerConnection.prototype}function yw(){return 11!==Wk&&"RTCPeerConnection"in window&&"addTransceiver"in window.RTCPeerConnection.prototype}var vw=!(!yw()||Lk&&Vk<74);function Aw(){return"RTCRtpTransceiver"in window&&"stop"in window.RTCRtpTransceiver.prototype}function Rw(){return"RTCRtpSender"in window&&"replaceTrack"in window.RTCRtpSender.prototype}function Cw(){return"RTCRtpSender"in window&&"setParameters"in window.RTCRtpSender.prototype&&Sw()}var bw=window.MediaStreamTrack&&"getSettings"in MediaStreamTrack.prototype,kw=window.MediaStreamTrack&&"getCapabilities"in MediaStreamTrack.prototype,Nw="RTCRtpSender"in window&&"createEncodedStreams"in window.RTCRtpSender.prototype&&Pk()>=86,Dw=function(){return["RTCPeerConnection","webkitRTCPeerConnection","RTCIceGatherer"].filter((e=>e in window)).length>0};function Ow(){let e={AudioDecoder:!1,AudioEncoder:!1,VideoDecoder:!1,VideoEncoder:!1,ImageDecoder:!1};return rO(window.AudioDecoder)||(e.AudioDecoder=!0),rO(window.AudioEncoder)||(e.AudioEncoder=!0),rO(window.VideoDecoder)||(e.VideoDecoder=!0),rO(window.VideoEncoder)||(e.VideoEncoder=!0),rO(window.ImageDecoder)||(e.ImageDecoder=!0),e}function ww(){return"mediaSession"in navigator&&!rO(navigator.mediaSession.setActionHandler)}function Pw(){return!rO(window.WebTransport)}function Lw(){let e={browser:"".concat(Qk.name,"/").concat(Qk.version),os:tN(),displayResolution:pw(),isScreenShareSupported:dw(),isWebRTCSupported:Dw(),isGetUserMediaSupported:mw(),isWebAudioSupported:_w(),isWebSocketsSupported:"WebSocket"in window&&2===window.WebSocket.CLOSING,isWebCodecSupported:Ow(),isMediaSessionSupported:ww(),isWebTransportSupported:Pw()};return navigator.userAgent.includes("miniProgram")&&(e.browser="mini/".concat(e.browser)),e}var Mw=rb(lb(),1),xw=Symbol("instance"),Vw=Symbol("cacheResult"),Uw=class{constructor(e,t,i){this.oldState=e,this.newState=t,this.action=i,this.aborted=!1}abort(e){this.aborted=!0,Gw.call(e,this.oldState,new Error("action '".concat(this.action,"' aborted")))}toString(){return"".concat(this.action,"ing")}},Fw=class extends Error{constructor(e,t,i){super(t),this.state=e,this.message=t,this.cause=i}},Bw=new Map;function Hw(e,t){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return(n,r,o)=>{let s=i.action||r;if(!i.context){let i=Bw.get(n)||[];Bw.has(n)||Bw.set(n,i),i.push({from:e,to:t,action:s})}let a=o.value;o.value=function(){let n=this;for(var r=arguments.length,o=new Array(r),c=0;c<r;c++)o[c]=arguments[c];if(i.context&&(n=Ww.get("function"==typeof i.context?i.context.call(this,...o):i.context)),n.state===t)return n[Vw];n.state instanceof Uw&&n.state.action==i.abortAction&&n.state.abort(n);let l=null;if(Array.isArray(e)?0==e.length?n.state instanceof Uw&&n.state.abort(n):("string"!=typeof n.state||!e.includes(n.state))&&(l=new Fw(n._state,"".concat(n.name," ").concat(s," to ").concat(t," failed: current state ").concat(n._state," not in from config"))):e!==n.state&&(l=new Fw(n._state,"".concat(n.name," ").concat(s," to ").concat(t," failed: current state ").concat(n._state," not from ").concat(e))),l){if(!i.fail){if(i.ignoreError)return l;throw l}i.fail.call(this,l)}let d=n.state,u=new Uw(d,t,s);Gw.call(n,u);let h=e=>{var r;return n[Vw]=e,u.aborted||(Gw.call(n,t),null===(r=i.success)||void 0===r||r.call(this,n[Vw])),e},p=e=>{let t=e instanceof Error?e.message:String(e);if(Gw.call(n,d,e),!i.fail){if(i.ignoreError)return e;throw e}i.fail.call(this,new Fw(n._state,"action '".concat(s,"' failed :").concat(t),e instanceof Error?e:new Error(t)))};try{let e=a.apply(this,o);return function(e){return"object"==typeof e&&e&&"then"in e}(e)?e.then(h).catch(p):h(e)}catch(_){p(_)}}}}var jw="undefined"!=typeof window&&window.__AFSM__?(e,t)=>{window.dispatchEvent(new CustomEvent(e,{detail:t}))}:"undefined"!=typeof importScripts?(e,t)=>{postMessage({type:e,payload:t})}:()=>{};function Gw(e,t){let i=this._state;this._state=e;let n=e.toString();e&&this.emit(n,i),this.emit(Ww.STATECHANGED,e,i,t),this.updateDevTools({value:e,old:i,err:t instanceof Error?t.message:String(t)})}var Ww=class extends Mw.default{constructor(e,t,i){super(),this.name=e,this.groupName=t,this._state=Ww.INIT,e||(e=Date.now().toString(36)),i?Object.setPrototypeOf(this,i):i=Object.getPrototypeOf(this),t||(this.groupName=this.constructor.name);let n=i[xw];n?this.name=n.name+"-"+n.count++:i[xw]={name:this.name,count:0},this.updateDevTools({diagram:this.stateDiagram})}get stateDiagram(){let e=Object.getPrototypeOf(this),t=Bw.get(e)||[],i=new Set,n=[],r=[],o=new Set,s=Object.getPrototypeOf(e);Bw.has(s)&&(s.stateDiagram.forEach((e=>i.add(e))),s.allStates.forEach((e=>o.add(e)))),t.forEach((e=>{let{from:t,to:i,action:o}=e;"string"==typeof t?n.push({from:t,to:i,action:o}):t.length?t.forEach((e=>{n.push({from:e,to:i,action:o})})):r.push({to:i,action:o})})),n.forEach((e=>{let{from:t,to:n,action:r}=e;o.add(t),o.add(n),o.add(r+"ing"),i.add("".concat(t," --\x3e ").concat(r,"ing : ").concat(r)),i.add("".concat(r,"ing --\x3e ").concat(n," : ").concat(r," 🟢")),i.add("".concat(r,"ing --\x3e ").concat(t," : ").concat(r," 🔴"))})),r.forEach((e=>{let{to:t,action:n}=e;i.add("".concat(n,"ing --\x3e ").concat(t," : ").concat(n," 🟢")),o.forEach((e=>{e!==t&&i.add("".concat(e," --\x3e ").concat(n,"ing : ").concat(n))}))}));let a=[...i];return Object.defineProperties(e,{stateDiagram:{value:a},allStates:{value:o}}),a}static get(e){let t;return"string"==typeof e?(t=Ww.instances.get(e),t||Ww.instances.set(e,t=new Ww(e,void 0,Object.create(Ww.prototype)))):(t=Ww.instances2.get(e),t||Ww.instances2.set(e,t=new Ww(e.constructor.name,void 0,Object.create(Ww.prototype)))),t}static getState(e){var t;return null===(t=Ww.get(e))||void 0===t?void 0:t.state}updateDevTools(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};jw(Ww.UPDATEAFSM,Object.assign({name:this.name,group:this.groupName},e))}get state(){return this._state}set state(e){Gw.call(this,e)}};Ww.STATECHANGED="stateChanged",Ww.UPDATEAFSM="updateAFSM",Ww.INIT="[*]",Ww.ON="on",Ww.OFF="off",Ww.instances=new Map,Ww.instances2=new WeakMap;var Jw=(null==window?void 0:window.requestIdleCallback)||function(e){let t=Date.now();return setTimeout((()=>{e({didTimeout:!1,timeRemaining:()=>Math.max(0,50-(Date.now()-t))})}),1e3)},zw=(null==window?void 0:window.cancelIdleCallback)||function(e){clearTimeout(e)},Kw=(null==window?void 0:window.cancelAnimationFrame)||(null==window?void 0:window.mozCancelAnimationFrame),qw=class{static generateTaskID(){return this.currentTaskID++}static run(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:xD,t=arguments.length>1?arguments[1]:void 0,i=arguments.length>2?arguments[2]:void 0;i=eb(e===MD?{delay:2e3,count:0,backgroundTask:!0}:e===PD?{delay:1e4,count:0}:e===LD?{fps:60,delay:16.6,count:0,backgroundTask:!0}:{delay:2e3,count:0,backgroundTask:!0},i),cO(t)&&(i=eb(eb({},i),t)),nO(e)&&(t=e,e=xD);let n=eb({taskID:this.generateTaskID(),loopCount:0,intervalID:null,timeoutID:null,rafID:null,ricID:null,taskName:e,callback:t},i);return this.taskMap.set(n.taskID,n),this[e](n),n.taskID}static interval(e){return e.intervalID=setInterval((()=>{e.callback(),e.loopCount+=1,this.isBreakLoop(e)}),e.delay)}static intervalInWorker(e){e.delay=(1e3/e.fps).toFixed(2);let t=new Worker(URL.createObjectURL(new Blob(["\n let timerID = null;\n self.onmessage = function (e) {\n if (e.data === 'start') {\n timerID = setInterval(() => {\n self.postMessage('tick');\n }, ".concat(e.delay,");\n } else if (e.data === 'stop') {\n clearInterval(timerID);\n }\n };\n ")])));t.onmessage=i=>{"tick"===i.data&&(e.callback(),e.loopCount+=1,this.isBreakLoop(e)&&t.postMessage("stop"))},e.worker=t,t.postMessage("start")}static timeout(e){let t=()=>{if(e.callback(),e.loopCount+=1,!this.isBreakLoop(e))return e.timeoutID=setTimeout(t,e.delay)};return e.timeoutID=setTimeout(t,e.delay)}static ric(e){let t,i=gO(),n=()=>{if(t=gO()-i,t>=e.delay&&(i=gO()-Math.floor(t%e.delay),e.callback(),e.loopCount+=1),!this.isBreakLoop(e))return e.ricID=Jw(n,{timeout:e.delay})};return e.ricID=Jw(n,{timeout:e.delay})}static raf(e){e.delay=(1e3/e.fps).toFixed(2);let t,i=gO(),n=()=>document.hidden&&e.backgroundTask?(t=gO()-i,i=gO(),e.callback(),e.loopCount+=1,this.isBreakLoop(e)?void 0:e.timeoutID=setTimeout(n,e.delay-Math.floor(t%e.delay))):(t=gO()-i,t>=e.delay&&(i=gO()-Math.floor(t%e.delay),e.callback(),e.loopCount+=1),this.isBreakLoop(e)?void 0:e.rafID=requestAnimationFrame(n));if(e.rafID=requestAnimationFrame(n),e.backgroundTask){let t=()=>{if(document.hidden){let t=gO()-i;t>=e.delay?n():e.timeoutID=setTimeout(n,e.delay-t)}};document.addEventListener("visibilitychange",t),e.onVisibilitychange=t,document.hidden&&t()}return e.taskID}static hasTask(e){return this.taskMap.has(e)}static clearTask(e){if(!this.taskMap.has(e))return!0;let{intervalID:t,timeoutID:i,rafID:n,ricID:r,onVisibilitychange:o,worker:s}=this.taskMap.get(e);return s&&s.terminate(),t&&clearInterval(t),i&&clearTimeout(i),n&&Kw(n),r&&zw(r),o&&document.removeEventListener("visibilitychange",o),this.taskMap.delete(e),!0}static isBreakLoop(e){return!this.taskMap.has(e.taskID)||0!==e.count&&e.loopCount>=e.count&&(this.clearTask(e.taskID),!0)}};qw.taskMap=new Map,qw.currentTaskID=1;var Yw=qw;MN.SEI_MESSAGE;var Qw={LOADED_DATA:MN.LOADEDDATA,MEDIA_TRACK_CHANGED:"media-track-changed",PLAYER_STATE_CHANGED:"player-state-changed"},Xw=new class{constructor(){sb(this,"_roomIdMap",new Map),sb(this,"_configs"),"undefined"==typeof registerProcessor&&(this._configs={sdkAppId:"",userId:"",version:oN,env:RN.QCLOUD,browserVersion:Qk.name+Qk.version,ua:navigator.userAgent})}setConfig(e){let{sdkAppId:t,env:i,userId:n,roomId:r}=e;t!==this._configs.sdkAppId&&(this._configs.sdkAppId=String(t)),this._configs.env=i,this._configs.userId=n,this._roomIdMap.set(n,String(r))}logSuccessEvent(e){qk||!jO.isAbleToUpload||this._configs.env===RN.QCLOUD&&this.uploadEventToKibana(tb(eb({},e),{result:"success"}))}logFailedEvent(e){if(qk||!jO.isAbleToUpload)return;let{eventType:t,code:i,error:n,userId:r}=e,o={roomId:this._roomIdMap.get(r||this._configs.userId),userId:r,eventType:t,result:"failed",code:i||(null==n?void 0:n.extraCode)||(null==n?void 0:n.code)||fb.UNKNOWN};this._configs.env===RN.QCLOUD&&this.uploadEventToKibana(tb(eb({},o),{error:n}))}uploadEventToKibana(e){let t="stat-".concat(e.eventType,"-").concat(e.result);("delta-join"===e.eventType||"delta-leave"===e.eventType||"delta-publish"===e.eventType)&&(t="".concat(e.eventType,":").concat(e.delta)),this.uploadEvent({log:t,userId:e.userId}),"failed"===e.result&&(t="stat-".concat(e.eventType,"-").concat(e.result,"-").concat(e.code),this.uploadEvent({log:t,userId:e.userId,error:e.error}))}uploadEvent(e){let{log:t,userId:i,error:n}=e,r={timestamp:Ib(),sdkAppId:this._configs.sdkAppId,userId:i||this._configs.userId,version:oN,log:t};n&&(r.errorInfo=n.message),this.sendRequest(HD(this._configs.sdkAppId,AN.LOG),r)}sendRequest(e,t){jO.isAbleToUpload?LO({url:e,body:JSON.stringify(t)}).catch((()=>{})):setTimeout((()=>{this.sendRequest(e,t)}),1e3)}},$w="trtc_autoplay",Zw="".concat($w,"_mask"),eP="".concat($w,"_wrapper"),tP="".concat($w,"_header"),iP="".concat($w,"_content"),nP="".concat($w,"_action_wrapper"),rP="".concat($w,"_question"),oP="".concat($w,"_collapse"),sP="".concat($w,"_action_confirm"),aP="".concat($w,"_detail"),cP="#2473E8",lP="dialog",dP="".concat(lP,"-show"),uP="".concat(lP,"-1"),hP="".concat(lP,"-2"),pP=!1,mP=()=>!!document.querySelector(".".concat(eP)),_P="".concat(EN,"/").concat($D()?"zh-cn":"en","/tutorial-21-advanced-auto-play-policy.html"),fP="<br><a href='".concat(_P,"' target='_blank'>").concat($D()?"其他方案?":"Any other solution?","</a>"),gP="".concat($D()?"浏览器自动播放策略:在用户与页面产生交互(点击、触摸)之前,浏览器禁止播放有声媒体。该弹窗用于帮助用户恢复音视频播放。".concat(fP):"Autoplay Policy: Before user interacts with the web page (clicking, touching), page will not be allowed to play media with sound. This Dialog is used to help users resume playback. ".concat(fP)),TP=class{constructor(){if(sb(this,"content","音视频播放被浏览器拦截,请点击“恢复播放”。"),sb(this,"_dialogNode",null),sb(this,"_bodyPosition",""),sb(this,"_showDetail",!1),sb(this,"_isCollapseClicked",!1),sb(this,"_isQuestionClicked",!1),$D()||(this.content='Media playback failed. Click the "Resume" to resume playback.'),!pP){let e=document.createElement("style");e.innerHTML=".".concat(Zw,"{position:fixed;top:0;left:0;right:0;bottom:0;width:100vw;height:100vh;display:flex;justify-content:center;align-items:center;background:rgba(0,0,0,0.5);z-index:1500;}.").concat(Zw," div:not(.").concat(nP,"){display:block !important;}.").concat(eP,"{padding:14px;background:#fff;border-radius:3px;box-shadow:0px 3px 15px #434343;border:1px solid #d1cfcf;max-width:500px;}.").concat(eP," a{color:").concat(cP,";}.").concat(tP,"{overflow:hidden;text-overflow:ellipsis;font-size:16px;font-weight:600;}.").concat(iP,"{margin:8px 0;}.").concat(nP,"{width:100%;display:flex !important;align-items:center;justify-content:right;float:right;}.").concat(oP,"{margin-right:auto;cursor:pointer}.").concat(rP,"{height:100%;line-height:16px;cursor:pointer;}.").concat(sP,"{margin-left:8px;color:#fff;background:").concat(cP,";padding:4px 12px;outline:none;border:1px solid;border-radius:3px;font-weight:bold;}.").concat(sP,":hover{opacity:0.9;}.").concat(oP,",.").concat(sP,",.").concat(iP,",.").concat(rP,"{font-size:14px;}@media screen and (max-width:750px){.").concat(eP,"{width:80vw;}}"),document.head.appendChild(e),pP=!0}this.addDiaLog()}createDiaLog(){let e=document.createElement("template");e.innerHTML='<div class="'.concat(Zw,"\"><div class='").concat(eP,"'><div class='").concat(tP,"'>").concat(location.host,"</div><div class='").concat(iP,"'>").concat(this.content,"</div><div class='").concat(aP,'\' style="visibility:hidden;width:100%;height:0;font-size:12px;color:gray;">').concat(gP,"</div><div class='").concat(nP,"'></div></div></div>").trim();let t=document.createElement("button");t.className=sP,t.innerText=$D()?"恢复播放":"Resume",t.onclick=this.onConfirm.bind(this);let i=document.createElement("div");i.className=rP,i.innerHTML='<?xml version="1.0" encoding="UTF-8"?>\n <svg class="icon" width="18" height="18" p-id="2030" t="1639646523624" version="1.1" viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg">\n <path d="m464 784.35c0 26.51 21.49 48 48 48s48-21.49 48-48-21.49-48-48-48-48 21.49-48 48z" p-id="2031"/>\n <path d="m512 960c-247.04 0-448-200.96-448-448s200.96-448 448-448 448 200.96 448 448-200.96 448-448 448zm0-831.71c-211.58 0-383.71 172.13-383.71 383.71 0 211.55 172.13 383.71 383.71 383.71 211.55 0 383.71-172.16 383.71-383.71 0-211.58-172.16-383.71-383.71-383.71z" p-id="2032"/>\n <path d="m512 673.7c-17.665 0-32.001-14.336-32.001-31.999v-54.112c0-52.353 40-92.352 75.328-127.65 25.887-25.92 52.672-52.672 52.672-74.017 0-53.343-43.072-96.735-95.999-96.735-53.823 0-95.999 41.536-95.999 94.559 0 17.665-14.336 31.999-32.001 31.999s-32.001-14.336-32.001-31.999c0-87.424 71.775-158.56 160-158.56s160 72.095 160 160.74c0 47.904-36.32 84.192-71.424 119.3-27.84 27.776-56.576 56.512-56.576 82.336v54.112c0 17.665-14.336 32.032-32.001 32.032z" p-id="2033"/>\n </svg>\n ',i.onclick=this.onQuestionClick.bind(this);let n=document.createElement("div");n.className=oP,n.innerText="".concat($D()?"详情 >":"Detail >"),n.onclick=this.onCollapseClick.bind(this);let r=e.content.firstChild,o=r.querySelector(".".concat(nP));return o.appendChild(n),o.appendChild(i),o.appendChild(t),r}addDiaLog(){mP()||(this._dialogNode=this.createDiaLog(),document.body.appendChild(this._dialogNode),this._dialogNode.onclick=this.onConfirm.bind(this),this._dialogNode.querySelector(".".concat(eP)).onclick=e=>e.stopPropagation(),this._bodyPosition=document.body.style.position,document.body.style.position="fixed",jO.info("show autoplay dialog"),Xw.uploadEvent({log:dP}))}deleteDiaLog(){this._dialogNode&&(document.body.removeChild(this._dialogNode),document.body.style.position=this._bodyPosition,this._dialogNode=null)}onConfirm(){jO.warn("confirm clicked, try resume stream"),UO.emit(BO.AUTOPLAY_DIALOG_CLICK_CONFIRM),this.deleteDiaLog()}onCollapseClick(){let e=this._dialogNode.querySelector(".".concat(aP));e.style.visibility="".concat(this._showDetail?"hidden":"visible"),e.style.height="".concat(this._showDetail?0:"fit-content"),this._showDetail=!this._showDetail,this._isCollapseClicked||Xw.uploadEvent({log:uP}),this._isCollapseClicked=!0}onQuestionClick(){window.open(_P,"_blank"),this._isQuestionClicked||Xw.uploadEvent({log:hP}),this._isQuestionClicked=!0}},EP={};nb(EP,{create:()=>IP,remove:()=>yP});var SP=new WeakMap;function IP(e,t){SP.has(e)||SP.set(e,[]);let i=SP.get(e),n={add:(e,r)=>("addEventListener"in t?(i.push(t.removeEventListener.bind(t,e,r)),t.addEventListener(e,r)):(i.push(t.off.bind(t,e,r)),t.on(e,r)),n)};return n}function yP(e){let t=SP.get(e);t&&(t.forEach((e=>e())),SP.delete(e))}var vP=class extends Ww{constructor(e,t){super(e.id,"".concat(t,"-player")),this.kind=t,sb(this,"id"),sb(this,"element",null),sb(this,"container",null),sb(this,"mediaStream",new MediaStream),sb(this,"track"),sb(this,"url"),sb(this,"attr"),sb(this,"muted"),sb(this,"_log"),sb(this,"_pausedRetryCount"),sb(this,"_isElementPlayingFired",!1),sb(this,"_interval"),this.id=e.id,this._log=e.log,this.track=e.track,this.container=e.container,this.muted=e.muted,this._pausedRetryCount=RD,this._state="STOPPED",this.bindTrackEvents()}get isPlaying(){return"PLAYING"===this._state}get isStopped(){return"STOPPED"===this._state}setAttr(e){this.attr=e}setTrack(e){if(e!==this.track&&(this.unbindTrackEvents(),this.track=e,this.emit(Qw.MEDIA_TRACK_CHANGED,e),null!==e&&(this.bindTrackEvents(),this.element))){let t=new MediaStream;t.addTrack(e),this.element.srcObject=t}}setUrl(e){this.track&&(this.unbindTrackEvents(),this.element&&(this.element.srcObject=null),this.track=null),e!==this.url&&(this.url=e,null!==e&&this.element&&(this.element.crossOrigin="anonymous",this.element.src=e))}setContainer(e){this.container=e,this.track&&this.element&&this.container&&this.container.appendChild(this.element)}play(){return cb(this,null,(function*(){if(this.element&&this.element.parentElement!==this.container&&this.container&&this.container.append(this.element),!this.isPlaying)try{this.bindAutoPlayEvent(),yield this.element.play()}catch(aN){let t=QO({key:zO.PLAY_FAILED,data:{media:this.kind,error:aN}});if(this.track&&!this.track.muted&&this._log.warn(aN),t.includes("NotAllowedError"))throw new Tb({code:fb.PLAY_NOT_ALLOWED,message:t})}}))}stop(){this.unbindEvents(),this._isElementPlayingFired=!1,this.element&&(this.container&&this.container.removeChild(this.element),this.element.srcObject=null,this.element=null),this.handleStopped(MN.ENDED),this._interval>0&&Yw.clearTask(this._interval)}pause(){var e;this.isPlaying&&(null==(e=this.element)||e.pause())}resume(){return this.isPlaying?Promise.resolve():zk?this.replay():this.play().catch((()=>{}))}setMuted(e){this.element&&(this.element.muted=e),this.muted=e}setRect(e,t){this.element&&(this.element.style.width="".concat(e,"px"),this.element.style.height="".concat(t,"px"))}replay(){return this.stop(),this.play().catch((()=>{}))}bindElementEvents(){if(this.element){let e=this.handleElementEvent.bind(this);return IP(this.element,this.element).add(MN.PLAYING,e).add(MN.ENDED,e).add(MN.PAUSE,e).add(MN.ERROR,e).add(MN.LOADEDDATA,e)}}bindTrackEvents(){if(this.track){let e=this.handleTrackEvent.bind(this);null==EP||EP.create(this.track,this.track).add(MN.ENDED,e).add(MN.MUTE,e).add(MN.UNMUTE,e),this.track.readyState===MN.ENDED&&this.handleTrackEvent({type:MN.ENDED}),this.track.muted&&this.handleTrackEvent({type:MN.MUTE})}}bindAutoPlayEvent(){UO.on(BO.AUTOPLAY_DIALOG_CLICK_CONFIRM,this.resume,this)}unbindTrackEvents(){this.track&&yP(this.track)}unbindEvents(){this.element&&yP(this.element),this.unbindTrackEvents(),UO.off(BO.AUTOPLAY_DIALOG_CLICK_CONFIRM,this.resume,this)}handleElementEvent(e){var t;switch(e.type){case MN.PLAYING:this._isElementPlayingFired=!0,this._log.info("".concat(this.kind," player is playing")),this.handlePlaying(MN.PLAYING),this._interval&&(Yw.clearTask(this._interval),this._interval=-1);break;case MN.ENDED:this._log.info("".concat(this.kind," player is ended")),this.handleStopped(MN.ENDED);break;case MN.PAUSE:this._log.info("".concat(this.kind," player is paused")),this.handlePaused(MN.PAUSE);let e=this.container&&document.getElementById(this.container.id);e||this._log.warn("".concat(this.kind," player has been remove, element ID: ").concat(null==(t=this.container)?void 0:t.id));let i=Pk();this._pausedRetryCount>0&&(this.kind===MN.VIDEO&&!mP()||this.kind===MN.AUDIO&&(sO(i)&&i<=70||!e))&&(this._log.info("".concat(this.kind," player auto resume when paused")),this.resume(),this._pausedRetryCount--),Lb&&(this._interval=Yw.run(xD,(()=>{this.element&&"PAUSED"===this._state&&this.resume()}),{delay:3e3}));break;case MN.ERROR:if(this.element&&this.element.error){let{code:e,message:t}=this.element.error;this._log.error("".concat(this.kind," player error observed. code: ").concat(e," message: ").concat(t," userAgent: ").concat(navigator.userAgent)),Xw.uploadEvent({log:"stat-".concat(this.kind,"-").concat(lD.PLAYER_ERROR,"-").concat(e,"-").concat(navigator.userAgent),error:this.element.error})}break;case MN.LOADEDDATA:this.kind===MN.VIDEO&&this.emit(Qw.LOADED_DATA)}}handleTrackEvent(e){switch(e.type){case MN.ENDED:this._log.info("".concat(this.kind," track is ended")),this.handleStopped(MN.ENDED);break;case MN.MUTE:this._log.info("".concat(this.kind," track is unable to provide media output")),this.handlePaused(MN.MUTE);break;case MN.UNMUTE:this._log.info("".concat(this.kind," track is able to provide media output")),this._isElementPlayingFired&&this.handlePlaying(MN.UNMUTE)}}handlePlaying(e){this.emit(Qw.PLAYER_STATE_CHANGED,{type:this.kind,state:"PLAYING",reason:e})}handlePaused(e){this.emit(Qw.PLAYER_STATE_CHANGED,{type:this.kind,state:"PAUSED",reason:e})}handleStopped(e){this.emit(Qw.PLAYER_STATE_CHANGED,{type:this.kind,state:"STOPPED",reason:e})}getElement(){return this.element}};ob([Hw([],"PLAYING")],vP.prototype,"handlePlaying",1),ob([Hw("PLAYING","PAUSED",{ignoreError:!0})],vP.prototype,"handlePaused",1),ob([Hw([],"STOPPED")],vP.prototype,"handleStopped",1);var AP=class extends vP{constructor(e){super(e,MN.VIDEO),sb(this,"mirror"),sb(this,"objectFit"),rO(e.mirror)||(this.mirror=e.mirror),rO(e.objectFit)||(this.objectFit=e.objectFit)}initializeElement(){var e;let t=document.createElement(MN.VIDEO);if(this.track){let e=new MediaStream;e.addTrack(this.track),t.srcObject=e}t.muted=!0;let i="width: 100%; height: 100%; object-fit: ".concat(this.objectFit,";background-color: black;");this.mirror&&(i+="transform: scaleX(-1);"),t.setAttribute("id","video_".concat(this.id)),t.setAttribute("style",i),t.setAttribute("autoplay","autoplay"),t.setAttribute("playsinline","playsinline"),null==(e=this.container)||e.appendChild(t),this.element=t,this.bindElementEvents()}bindElementEvents(){let e=super.bindElementEvents();this.handleElementEvent=this.handleElementEvent.bind(this),e&&e.add(MN.ENTER_PICTURE_IN_PICTURE,this.handleElementEvent).add(MN.LEAVE_PICTURE_IN_PICTURE,this.handleElementEvent)}handleElementEvent(e){super.handleElementEvent(e);let t=e.type;if(this.mirror&&this.element){let e=this.element.style.transform;t===MN.ENTER_PICTURE_IN_PICTURE?this.element.style.transform=e.replace("scaleX(-1)",""):t===MN.LEAVE_PICTURE_IN_PICTURE&&!e.includes("scaleX")&&(this.element.style.transform="".concat(e," scaleX(-1)"))}}setAttr(e){let t=Object.assign({autoplay:"autoplay",playsinline:"playsinline",muted:!0},e);t.style=Object.assign({width:"100%",height:"100%"},t.style),super.setAttr(t)}setMirror(e){this.element&&(this.element.style.transform=e?"scaleX(-1)":""),this.mirror=e}setObjectFit(e){this.element&&(this.element.style.objectFit="".concat(e)),this.objectFit=e}play(){return this.element||this.initializeElement(),super.play()}getVideoFrame(){if(!this.element)return"";let e=document.createElement("canvas");return e.width=this.element.videoWidth,e.height=this.element.videoHeight,e.getContext("2d").drawImage(this.element,0,0),e.toDataURL("image/png")}getElement(){return this.element}},RP=!1,CP=class{constructor(e){sb(this,"context_"),sb(this,"blob_"),this.context_=e.context,this.blob_=new Blob(['class VolumeMeter extends AudioWorkletProcessor{constructor(){super(),this.volume=0,this.intervalTime=200,this.tick=this.intervalTime,this.isStop=!1,this.port.onmessage=t=>{let{data:e}=t;switch(e.name){case"setIntervalTime":this.intervalTime=e.intervalTime;break;case"stop":this.isStop=!0}}}process(t){let e=t[0];if(this.isStop)return!1;if(e.length>0){let i=e[0],s=0;for(let l=0;l<i.length;++l)s=Math.max(Math.abs(i[l]),s);this.volume=s,this.tick-=i.length,this.tick<0&&(this.tick+=this.intervalTime/1e3*sampleRate,this.port.postMessage({volume:this.volume}))}return!0}}registerProcessor("volume-meter",VolumeMeter);'],{type:"application/javascript"}),this.addModuleToContext()}addModuleToContext(){return cb(this,null,(function*(){try{yield this.context_.audioWorklet.addModule(URL.createObjectURL(this.blob_)),jO.info("worklet addModule success"),UO.emit(BO.WORKLET_LOADED_SUCCESS),RP=!0}catch(FL){jO.info("worklet addModule catch error. ".concat(FL.message)),UO.emit(BO.WORKLET_LOADED_FAILED)}}))}get initWorkletSuccess(){return RP}};"undefined"!=typeof window&&(window.AudioContext=window.AudioContext||window.webkitAudioContext||window.mozAudioContext);var bP,kP,NP=0,DP=(e,t)=>{let i=new window.AudioContext(t),n=++NP,r=()=>{"suspended"===i.state?(i.resume(),document.addEventListener("click",r)):"interrupted"===i.state?i.resume():document.removeEventListener("click",r)};return document.addEventListener("click",r),i.onstatechange=()=>{jO.info("".concat(e,"-").concat(n," context state: ").concat(i.state)),r()},i},OP=0,wP=class{constructor(e){sb(this,"_volume"),sb(this,"_log"),sb(this,"_track"),sb(this,"_stream"),sb(this,"_audioCtx"),sb(this,"_destination"),sb(this,"_streamSource"),sb(this,"_scriptProcessorNode"),sb(this,"_audioWorkletNode"),sb(this,"_interval");let{track:t,log:i}=e;this._volume=0,this._log=i,this._track=t,bP||(bP=DP("volume-meter")),this._audioCtx=bP,this._destination=this._audioCtx.destination;let n=new MediaStream;n.addTrack(this._track),this._streamSource=this._audioCtx.createMediaStreamSource(n),this._audioWorkletNode=null,this._scriptProcessorNode=null,this._interval=200,UO.on(BO.AUDIO_LEVEL_INTERVAL,this.handleAudioLevelInterval,this),_O?(UO.on(BO.WORKLET_LOADED_SUCCESS,this.initAudioWorklet,this),UO.on(BO.WORKLET_LOADED_FAILED,this.initScriptProcessor,this),this.preload()):this.initScriptProcessor(),OP+=1}preload(){kP?kP.initWorkletSuccess&&this.initAudioWorklet():kP=new CP({context:bP})}initAudioWorklet(){if(!this._audioWorkletNode)try{this._audioWorkletNode=new AudioWorkletNode(this._audioCtx,"volume-meter"),this._audioWorkletNode.port.onmessage=e=>{this._volume=e.data.volume||0},this._streamSource.connect(this._audioWorkletNode).connect(this._destination),this.handleAudioLevelInterval({interval:this._interval})}catch(FL){Xw.logFailedEvent({userId:this._log.userId,eventType:lD.LOAD_WORKLET,error:FL}),this.initScriptProcessor()}}initScriptProcessor(){if(!this._scriptProcessorNode)try{this._scriptProcessorNode=this._audioCtx.createScriptProcessor(2048,1,1),this._scriptProcessorNode.onaudioprocess=e=>{let t=e.inputBuffer.getChannelData(0),i=0;for(let n=0;n<t.length;++n)i+=t[n]*t[n];this._volume=Math.sqrt(i/t.length)||0},this._streamSource.connect(this._scriptProcessorNode),this._scriptProcessorNode.connect(this._destination)}catch(FL){this._log.error("volumeMeter init script processor error: ".concat(FL))}}destroy(){this._streamSource&&this._streamSource.disconnect(),this._scriptProcessorNode&&(this._scriptProcessorNode.onaudioprocess=null,this._scriptProcessorNode.disconnect()),this._audioWorkletNode&&(this._audioWorkletNode.port.postMessage({name:"stop"}),this._audioWorkletNode.port.onmessage=null,this._audioWorkletNode.disconnect()),this._audioWorkletNode=null,this._scriptProcessorNode=null,this._audioCtx=null,UO.off(BO.AUDIO_LEVEL_INTERVAL,this.handleAudioLevelInterval,this),UO.off(BO.WORKLET_LOADED_SUCCESS,this.initAudioWorklet,this),UO.off(BO.WORKLET_LOADED_FAILED,this.initScriptProcessor,this),OP>0&&(OP-=1),0===OP&&(null==bP||bP.close(),bP=null,kP=null)}resume(){null==bP||bP.resume()}getInternalAudioLevel(){return this._volume}getCalculatedVolume(){return parseFloat(this._volume.toFixed(2))}handleAudioLevelInterval(e){var t;let{interval:i}=e;this._interval=i,null==(t=this._audioWorkletNode)||t.port.postMessage({name:"setIntervalTime",intervalTime:i})}},PP=null,LP=0,MP=class extends vP{constructor(e){super(e,MN.AUDIO),sb(this,"_volumeMeter"),sb(this,"_gainedTrack",null),sb(this,"_gainNode",null),sb(this,"_destination",null),sb(this,"_mediaStreamSource",null),sb(this,"_sourceElement",null),sb(this,"_outputDeviceId"),sb(this,"_volume",1),sb(this,"_loop",!1),e.gainedTrack&&(this._gainedTrack=e.gainedTrack),this._outputDeviceId=e.outputDeviceId,this.track&&this.initVolumeMeter(this.track)}setTrack(e){this.track!==e&&(this._volumeMeter&&(this._volumeMeter.destroy(),this._volumeMeter=null),null!==e&&this.initVolumeMeter(e)),super.setTrack(e)}initVolumeMeter(e){this._volumeMeter=new wP({track:this._gainedTrack||e,log:this._log})}initializeElement(){if(("15.2"===Gk||"15.3"===Gk||"15.4"===Gk)&&this.muted)return void this._log.info("audioElement is muted.");let e=document.createElement(MN.AUDIO);this.track&&(e.srcObject=new MediaStream([this._gainedTrack||this.track])),e.muted=this.muted,e.setAttribute("id","audio_".concat(this.id)),e.setAttribute("autoplay","autoplay"),e.setAttribute("playsinline","playsinline"),this.element=e,this.bindElementEvents()}play(){return cb(this,null,(function*(){this.element||this.initializeElement(),this._outputDeviceId&&(yield this.setSinkId(this._outputDeviceId)),!this._volumeMeter&&this.track&&this.initVolumeMeter(this.track),this.setVolume(this._volume),yield ab(MP.prototype,this,"play").call(this)}))}stop(){this._volumeMeter&&(this._volumeMeter.destroy(),this._volumeMeter=null),this.destroyGain(),super.stop()}resume(){return cb(this,null,(function*(){yield ab(MP.prototype,this,"resume").call(this),this._volumeMeter&&this._volumeMeter.resume()}))}setSinkId(e){return cb(this,null,(function*(){this._outputDeviceId!==e&&(this.element&&(yield this.element.setSinkId(e)),this._outputDeviceId=e)}))}setVolume(e){this._volume=e,this._gainNode?this._gainNode.gain.value=e:e>1?this.createGain(e):this.element&&(this.element.volume=e)}createGain(e){PP||(PP=DP("player")),this._log.info("create gainNode ".concat(e));let t=PP.createMediaStreamSource(new MediaStream([this.track])),i=PP.createGain(),n=PP.createMediaStreamDestination();t.connect(i),i.connect(n),i.gain.value=e,this._gainNode=i,this._destination=n,this._mediaStreamSource=t,this._gainedTrack=n.stream.getAudioTracks()[0],LP+=1,this.element&&(yP(this.element),this._sourceElement=this.element,this.element.muted=!0,this.element=null),this.play()}destroyGain(){var e,t,i;!this._gainNode||(this._log.info("destroy gainNode"),null==(e=this._gainNode)||e.disconnect(),null==(t=this._destination)||t.disconnect(),null==(i=this._mediaStreamSource)||i.disconnect(),this._gainNode=null,this._destination=null,this._mediaStreamSource=null,this._sourceElement&&(this._sourceElement.srcObject=null,this._sourceElement=null),this._gainedTrack=null,0===(LP-=1)&&PP&&(this._log.info("destroy gain audioContext"),PP.close(),PP=null))}setLoop(e){!this.element||(this.element.loop=e,this._loop=e)}getAudioLevel(){var e;return(null==(e=this._volumeMeter)?void 0:e.getCalculatedVolume())||0}getInternalAudioLevel(){var e;return null==(e=this._volumeMeter)?void 0:e.getInternalAudioLevel()}},xP=class extends Ww{constructor(e){let{userId:t,sdkAppId:i,mediaType:n,room:r,isInitPlayer:o=!0}=e;var s;super(),sb(this,"id",GO()),sb(this,"userId"),sb(this,"isRemote"),sb(this,"mediaType"),sb(this,"room"),sb(this,"user"),sb(this,"_log"),sb(this,"_inputTrack"),sb(this,"_outputTrack"),sb(this,"isPlayCalled"),sb(this,"container",null),sb(this,"player"),sb(this,"subVideoPlayerMap"),sb(this,"playerMuted",!1),sb(this,"abortCtrl"),sb(this,"audioOutputDeviceId"),sb(this,"audioVolume"),sb(this,"objectFit","cover"),sb(this,"mirror",!1),sb(this,"gain"),sb(this,"isScreen",!1),sb(this,"manager"),rO(t)||(this.userId=t),this.mediaType=n,this._log=jO.createLogger({id:"".concat(this.kind[0],"t"),userId:null==(s=r||this.room)?void 0:s.userId,remoteUserId:this instanceof rL?void 0:this.userId,sdkAppId:i,type:2===this.mediaType?"auxiliary":"main",isLocal:this instanceof rL}),o&&this.initPlayer()}get log(){return this._log||jO}get kind(){return 1===this.mediaType?MN.AUDIO:MN.VIDEO}get muted(){return!(!this.outMediaTrack||this.outMediaTrack.enabled)}get strMediaType(){return 4===this.mediaType?MN.VIDEO:2===this.mediaType?MN.SCREEN:MN.AUDIO}play(e,t){return cb(this,null,(function*(){let i=lO(e)?e[0]:e;if(this.isPlayCalled)return this.log.info("play update options: ".concat(JSON.stringify(t))),t&&!rO(t.muted)&&this.setPlayerMute(t.muted),t&&!rO(t.objectFit)&&(this.objectFit=t.objectFit),this.isScreen?this.mirror=!1:t&&!rO(t.mirror)&&(this.mirror=t.mirror),void(this.kind===MN.VIDEO&&(this.player.setObjectFit(this.objectFit),this.player.setMirror(this.mirror),this.container!==i&&i&&(this.container=i,this.player.setContainer(i)),lO(e)&&e.length>=1&&(yield this.playSubContainer(e.slice(1),t))));if(t&&!rO(t.muted)?this.setPlayerMute(t.muted):(!this.isRemote||this.kind===MN.VIDEO)&&this.setPlayerMute(!0),t&&!rO(t.objectFit)&&(this.objectFit=t.objectFit),this.isRemote||(this.mirror=!0),this.isScreen?this.mirror=!1:t&&!rO(t.mirror)&&(this.mirror=t.mirror),this.kind===MN.VIDEO&&(this.player.setObjectFit(this.objectFit),this.player.setMirror(this.mirror)),this.isPlayCalled=!0,i&&(this.container=i,this.player.setContainer(i)),UO.emit(BO.PLAY_TRACK_START,{track:this}),this._outputTrack){this._log.info("play with options: ".concat(JSON.stringify(t)));try{this.player.setTrack(this._outputTrack),yield this.player.play(),lO(e)&&e.length>1&&(yield this.playSubContainer(e.slice(1),t))}catch(r){throw this.handleAutoPlayFailed(),this.emit("error",r),r}}else this.log.info("play has not mediaTrack, abort")}))}playSubContainer(e,t){return cb(this,null,(function*(){if(!this._outputTrack||this.kind===MN.AUDIO)return;this.subVideoPlayerMap||(this.subVideoPlayerMap=new Map),this.subVideoPlayerMap.forEach(((t,i)=>{var n;e.find((e=>i===e))||(t.stop(),t.setContainer(null),null==(n=this.subVideoPlayerMap)||n.delete(i))}));for(let[n,r]of e.entries()){let e=this.subVideoPlayerMap.get(r);e?t&&(rO(t.mirror)||e.setMirror(t.mirror),rO(t.objectFit)||e.setObjectFit(t.objectFit)):this.subVideoPlayerMap.set(r,new AP({id:this.userId||this.id,track:this.outMediaTrack,container:r,muted:this.playerMuted,objectFit:this.objectFit,mirror:this.mirror,log:this.log.createChild({id:"vp-sub".concat(n+1)})}))}let i=[...this.subVideoPlayerMap.values()];for(let e of i)yield e.play()}))}initPlayer(){var e;this.log.info("create ".concat(this.kind,"Player")),this.kind===MN.AUDIO?this.player=new MP({id:this.userId||this.id,track:this.outMediaTrack,gainedTrack:null==(e=this.gain)?void 0:e.audioTrack,container:this.container||null,muted:this.playerMuted,outputDeviceId:this.audioOutputDeviceId,log:this.log}):(this.player=new AP({id:this.userId||this.id,track:this.outMediaTrack,container:this.container||null,muted:this.playerMuted,objectFit:this.objectFit,mirror:this.mirror,log:this.log}),this.player.on(Qw.LOADED_DATA,(()=>{UO.emit(BO.VIDEO_LOADED_DATA,{track:this})})),this.player.on(Qw.MEDIA_TRACK_CHANGED,(e=>{var t;null==(t=this.subVideoPlayerMap)||t.forEach((t=>t.setTrack(e)))}))),this.player.on(Qw.PLAYER_STATE_CHANGED,(e=>{UO.emit(BO.PLAYER_STATE_CHANGED,eb({track:this},e)),this.emit("player-state-changed",e)}))}setAudioOutput(e){return cb(this,null,(function*(){var t;this.audioOutputDeviceId=e,yield null==(t=this.player)?void 0:t.setSinkId(e)}))}setAudioVolume(e){var t;this.audioVolume=e,this.log.info("setAudioVolume to ".concat(e)),null==(t=this.player)||t.setVolume(e)}getAudioLevel(){var e;return(null==(e=this.player)?void 0:e.getAudioLevel())||0}getInternalAudioLevel(){var e;return(null==(e=this.player)?void 0:e.getInternalAudioLevel())||0}stop(){!this.isPlayCalled||(this.isPlayCalled=!1,this.player&&(this.log.info("stop ".concat(this.kind," player")),this.player.stop(),this.player.setContainer(null)),this.subVideoPlayerMap&&this.subVideoPlayerMap.size>0&&this.subVideoPlayerMap.forEach((e=>{e.stop(),e.setContainer(null)})),this.container=null)}resume(){return cb(this,null,(function*(){var e;!this.isPlayCalled||(yield null==(e=this.player)?void 0:e.resume())}))}close(){this.log.info("close"),this.isPlayCalled&&this.stop()}setMute(e){return!!this.outMediaTrack&&(this.outMediaTrack.enabled=!e,this.emit(e?"mute":"unmute",this),UO.emit(e?BO.TRACK_MUTED:BO.TRACK_UNMUTED,{track:this}),!0)}setPlayerMute(e){this.playerMuted=e,this.player.setMuted(e)}get mediaTrack(){return this._inputTrack||null}get outMediaTrack(){return this._outputTrack||null}setInputMediaStreamTrack(e){let t=this._inputTrack;if(e!==t)return this._inputTrack=e,this.emit("input-media-track-changed",e||null,t||null),this.manager?this.manager.changeInput(this,t):this.setOutputMediaStreamTrack(e)}setOutputMediaStreamTrack(e){var t;e!==this._outputTrack&&(this.isRemote?this.log.debug("setOutputMediaStreamTrack",e.label):this.log.info("setOutputMediaStreamTrack",(null==(t=e.getSettings)?void 0:t.call(e).deviceId)||e.label),this._outputTrack=e,e.enabled=!this.muted,this.updatePlayingState(!!e))}setMediaType(e){this.mediaType=e}updatePlayingState(e){if(this.isPlayCalled)if(e){if(this.player.setTrack(this.outMediaTrack),this.player.isStopped)return this.player.play().catch((()=>this.handleAutoPlayFailed())),void this.log.info("playing state updated, play ".concat(this.kind))}else if(!this.player.isStopped)return this.player.stop(),void this.log.info("playing state updated, stop ".concat(this.kind));this.log.debug("updatePlayingState abort ".concat(this.isPlayCalled," ").concat(e," ").concat(this.player.isStopped))}handleAutoPlayFailed(){if(this.room&&this.room.enableAutoPlayDialog)new TP;else{let e=()=>{this.resume().then((()=>{document.removeEventListener("click",e,!0),document.removeEventListener("touchstart",e,!0)}))};document.addEventListener("click",e,!0),document.addEventListener("touchstart",e,!0)}}};ob([Hw([],Ww.INIT)],xP.prototype,"close",1);var VP=Object.prototype.hasOwnProperty,UP=function(e){if(null==e)return!0;if("boolean"==typeof e)return!1;if("number"==typeof e)return 0===e;if("string"==typeof e||"function"==typeof e||Array.isArray(e))return 0===e.length;if(e instanceof Error)return""===e.message;if(ZD(e))switch(Object.prototype.toString.call(e)){case"[object File]":case"[object Map]":case"[object Set]":return 0===e.size;case"[object Object]":for(let t in e)if(VP.call(e,t))return!1;return!0}return!1},FP=rb(lb(),1),BP=e=>t=>t.deviceId===e,HP=class{constructor(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"Input";sb(this,"kind"),sb(this,"type"),sb(this,"devices",[]),this.kind=e,this.type=t}update(e,t){let i=e.filter((e=>e.kind==="".concat(this.kind).concat(this.type.toLocaleLowerCase())));t&&(i.forEach((e=>{if(e.deviceId&&!this.devices.find(BP(e.deviceId))){let i="".concat(this.kind).concat(this.type,"Added");jO.warn("".concat(i,": ").concat(JSON.stringify(e))),t.emit(i,e)}})),this.devices.forEach((e=>{if(e.deviceId&&!i.find(BP(e.deviceId))){let i="".concat(this.kind).concat(this.type,"Removed");jO.warn("".concat(i,": ").concat(JSON.stringify(e))),t.emit(i,e)}}))),this.devices=i}hasDevice(e){return!!this.devices.find((t=>t.deviceId===e))}},jP=class extends FP.EventEmitter{constructor(){super(),sb(this,"audioInputs",new HP(MN.AUDIO)),sb(this,"videoInputs",new HP(MN.VIDEO)),sb(this,"audioOutputs",new HP(MN.AUDIO,"Output")),this.init(),navigator.mediaDevices&&(navigator.mediaDevices.addEventListener&&navigator.mediaDevices.addEventListener("devicechange",this.update.bind(this)),"ondevicechange"in navigator.mediaDevices||Yw.run(MD,(()=>{this.update()}),{delay:1e4}))}init(){WP().then((e=>{this.audioInputs.update(e),this.videoInputs.update(e),this.audioOutputs.update(e)}))}update(){return cb(this,null,(function*(){let e=yield WP();return this.audioInputs.update(e,this),this.videoInputs.update(e,this),this.audioOutputs.update(e,this),this}))}},GP=uN||dN?null:new jP;function WP(){return cb(this,null,(function*(){return rw()||!iw()?[]:(yield navigator.mediaDevices.enumerateDevices()).map(((e,t)=>{let i={kind:e.kind,deviceId:e.deviceId,groupId:e.groupId,label:e.label||"".concat(e.kind,"_").concat(t)};return e.deviceId.length>0&&qP.add("".concat(e.deviceId,"_").concat(e.kind)),e.getCapabilities&&(i.getCapabilities=()=>e.getCapabilities()),i}))}))}function JP(){return GP.update().then((e=>e.audioInputs.devices))}function zP(){return GP.update().then((e=>e.videoInputs.devices))}function KP(){return cb(this,null,(function*(){return GP.update().then((e=>e.audioOutputs.devices))}))}var qP=new Set;function YP(e,t){return cb(this,null,(function*(){let i=(yield JP()).find((e=>e.deviceId===CD));return(null==i?void 0:i.groupId)===e&&i.label===t}))}var QP=xO({retryFunction:function(e){return cb(this,null,(function*(){let t=function(e){return{audio:$P(e),video:ZP(e)}}(e);jO.info("getUserMedia with constraints: ".concat(JSON.stringify(t)));let i=[],n=[],r=["label","deviceId"];t.audio&&(i=yield JP(),jO.info("microphones: ".concat(OO(i,{keysToInclude:r})))),t.video&&(n=yield zP(),jO.info("cameras: ".concat(OO(n,{keysToInclude:r}))));try{let e=yield navigator.mediaDevices.getUserMedia(t);return kw&&e.getTracks().forEach((e=>{jO.info("".concat(e.kind," capabilities: ").concat(OO(e.getCapabilities(),{keysToInclude:VD})))})),e}catch(s){if("NotFoundError"===s.name){if(e.video&&n&&0===n.length)throw new Tb({code:fb.DEVICE_NOT_FOUND,message:QO({key:zO.CAMERA_NOT_FOUND})});if(e.audio&&i&&0===i.length)throw new Tb({code:fb.DEVICE_NOT_FOUND,message:QO({key:zO.MICROPHONE_NOT_FOUND})})}throw new Tb({code:fb.INITIALIZE_FAILED,name:s.name,message:s.message,constraint:s.constraint})}}))},settings:{retries:3,timeout:500},onError:e=>{let{error:t,retry:i,reject:n,retryFuncArgs:r,retryCount:o}=e;"NotReadableError"===t.name?(r[0].video&&(r[0].maxResolution=!1,r[0].frameRate&&(r[0].frameRate=r[0].frameRate>10?10:5)),2===o&&(r[0].useTrueAsConstraint=!0),i()):n(t),r[0].microphoneId&&XP(r[0].microphoneId,!1),r[0].cameraId&&XP(r[0].cameraId,!0)},onRetrying:e=>{jO.warn("getUserMedia NotReadableError observed, retrying [".concat(e,"/3]"))},onRetryFailed:e=>{Xw.logFailedEvent({eventType:lD.GET_USER_MEDIA_RETRY,error:e})},onRetrySuccess:e=>{Xw.logSuccessEvent({eventType:lD.GET_USER_MEDIA_RETRY}),Xw.uploadEvent({log:"stat-".concat(lD.GET_USER_MEDIA_RETRY,"-success-").concat(e)})}});function XP(e,t){return cb(this,null,(function*(){let i=(t?yield zP():yield JP()).find((t=>t.deviceId===e));i&&nO(i.getCapabilities)&&jO.warn(OO(i.getCapabilities(),{keysToInclude:VD}))}))}function $P(e){if(!e.audio)return!1;if(e.useTrueAsConstraint)return!0;let t={echoCancellation:!0,noiseSuppression:!0,autoGainControl:!0};return UP(e.microphoneId)||(t.deviceId=e.useExact?{exact:e.microphoneId}:e.microphoneId),sO(e.channelCount)&&e.channelCount>1&&(t.channelCount=e.channelCount),aO(e.echoCancellation)&&!e.echoCancellation&&(t.echoCancellation=!1),aO(e.noiseSuppression)&&!e.noiseSuppression&&(t.noiseSuppression=!1),aO(e.autoGainControl)&&!e.autoGainControl&&(t.autoGainControl=!1),!!UP(t)||t}function ZP(e){if(!e.video)return!1;if(e.useTrueAsConstraint)return!0;let{maxResolution:t=!0}=e,i={};return e.cameraId?i.deviceId=e.useExact?{exact:e.cameraId}:e.cameraId:e.facingMode&&(i.facingMode=e.facingMode),e.width&&(i.width={ideal:e.width},t&&!Fb&&(i.width.max=e.width)),e.height&&(i.height={ideal:e.height},t&&!Fb&&(i.height.max=e.height)),Fb&&fk&&e.width&&e.height&&e.width*e.height<101376&&(i.width=e.width,i.height=e.height),e.frameRate&&(i.frameRate=e.frameRate),!!UP(i)||i}var eL=QP;function tL(e){return nL(((t,i)=>function(){for(var i=arguments.length,n=new Array(i),r=0;r<i;r++)n[r]=arguments[r];return cb(this,null,(function*(){return yield e.apply(this,n),t.apply(this,n)}))}))}function iL(e){return nL(((t,i)=>function(){for(var i=arguments.length,n=new Array(i),r=0;r<i;r++)n[r]=arguments[r];return cb(this,null,(function*(){return e.call(this,t.apply(this,n))}))}))}function nL(e){return function(t,i,n){return n.value=e(n.value,i),n}}var rL=class extends xP{constructor(e){super({mediaType:e,isInitPlayer:!(arguments.length>1&&void 0!==arguments[1])||arguments[1]}),sb(this,"isRemote",!1),sb(this,"deviceId"),sb(this,"groupId",""),sb(this,"label",""),sb(this,"_isRecapturing",!1),sb(this,"_lastRecaptureTime",0),sb(this,"_onMuteTimeoutId",-1),sb(this,"profile"),this.onTrackMuted=this.onTrackMuted.bind(this),this.onTrackUnmuted=this.onTrackUnmuted.bind(this),this.onTrackEnded=this.onTrackEnded.bind(this)}installTrackEvent(e){IP(e,e).add(MN.MUTE,this.onTrackMuted).add(MN.UNMUTE,this.onTrackUnmuted).add(MN.ENDED,this.onTrackEnded),e.muted&&this.onTrackMuted(),e.readyState===MN.ENDED&&this.onTrackEnded()}uninstallTrackEvent(e){yP(e)}setStateToCapture(){}capture(e){return cb(this,null,(function*(){try{let t;UO.emit(BO.LOCAL_TRACK_CAPTURE_START,{track:this}),e.customSource?(t=new MediaStream,t.addTrack(e.customSource)):t=yield eL(e);let i=t.getTracks()[0];return yield this.setInputMediaStreamTrack(i),e.customSource||(this.updateDeviceIdInUse(),this.listenDeviceChange()),UO.emit(BO.LOCAL_TRACK_CAPTURE_SUCCESS,{track:this}),t}catch(aD){throw UO.emit(BO.LOCAL_TRACK_CAPTURE_FAILED,{track:this,error:aD}),this.log.error("getUserMedia error observed ".concat(aD)),aD}}))}setInputMediaStreamTrack(e){this.state===Ww.INIT&&this.setStateToCapture(),this._inputTrack&&this.uninstallTrackEvent(this._inputTrack);let t=super.setInputMediaStreamTrack(e);return this.installTrackEvent(e),t}publish(e,t){return this.room=e,this.emit("4",{mediaType:this.strMediaType,state:"starting",prevState:"stopped"}),this.userId=e.userId,this._log.setUserId(e.userId),this._log.setSdkAppId(e.sdkAppId),UO.emit(BO.LOCAL_TRACK_PUBLISHED,{track:this}),t}unpublish(){this.room&&this.room.localTracks.delete(this),UO.emit(BO.LOCAL_TRACK_UNPUBLISHED,{track:this})}updateDeviceIdInUse(){return cb(this,null,(function*(){if(this.mediaTrack&&bw){let{deviceId:e,groupId:t}=this.mediaTrack.getSettings(),{label:i}=this.mediaTrack;(yield function(e){return cb(this,arguments,(function(e){let{newDeviceId:t,oldDeviceId:i,oldGroupId:n,oldLabel:r,kind:o}=e;return function*(){return t===i&&(o!==MN.AUDIO||t!==CD||(yield YP(n,r)))}()}))}({newDeviceId:e,oldDeviceId:this.deviceId,oldGroupId:this.groupId,oldLabel:this.label,kind:this.kind}))||(this.deviceId=e,this.label=i,t&&(this.groupId=t),WP().then((t=>{let i=t.find((t=>t.deviceId===e));i&&this.emit("2",i)})))}}))}setProfile(e){this.log.info("setProfile",e),Object.assign(this.profile,e)}isNeedToRecapture(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return!(!this.deviceId||!this.mediaTrack||this.kind===MN.AUDIO&&!function(e){if(e instanceof CanvasCaptureMediaStreamTrack||!(e instanceof MediaStreamTrack))return!1;let t=e.label.toLocaleLowerCase();if(t.includes("mic")||t.includes("麦克风"))return!0;let i="".concat(((null==e?void 0:e.getSettings())||{}).deviceId,"_").concat(MN.AUDIO_INPUT);return!!qP.has(i)}(this.mediaTrack)||this.kind===MN.VIDEO&&!function(e){if(e instanceof CanvasCaptureMediaStreamTrack||!(e instanceof MediaStreamTrack))return!1;let t=e.label.toLocaleLowerCase();if(t.includes("camera")||t.includes("webcam"))return!0;let i="".concat(((null==e?void 0:e.getSettings())||{}).deviceId,"_").concat(MN.VIDEO_INPUT);return!!qP.has(i)}(this.mediaTrack)||this._isRecapturing||e&&fk&&Fk)}onTrackMuted(){if(this.isNeedToRecapture(!0)){if(Date.now()-this._lastRecaptureTime<wD)return void setTimeout((()=>this.onTrackMuted()),wD);this._onMuteTimeoutId=setTimeout((()=>cb(this,null,(function*(){var e;(null==(e=this.mediaTrack)?void 0:e.muted)&&"visible"===document.visibilityState&&this.recapture(yield this.getRecoverCaptureDeviceId())}))),5e3)}}onTrackUnmuted(){this._onMuteTimeoutId>0&&clearTimeout(this._onMuteTimeoutId)}onTrackEnded(){return cb(this,null,(function*(){if(this.isNeedToRecapture()){if(Date.now()-this._lastRecaptureTime<wD)return void setTimeout((()=>this.onTrackEnded()),wD);this.recapture(yield this.getRecoverCaptureDeviceId())}}))}recapture(e){return cb(this,null,(function*(){var t;if(this._isRecapturing||!this._inputTrack)return;let i;return this.log.warn("recapture trying"),null==(t=this._inputTrack)||t.stop(),this._isRecapturing=!0,this._lastRecaptureTime=Date.now(),("audio"===this.kind?yield JP():yield zP()).find((t=>t.deviceId===e))&&(i=e),this.capture({deviceId:i,useExact:!0}).then((()=>{this._isRecapturing=!1,this.log.warn("recapture success"),this.emit("1",{deviceId:this.deviceId})})).catch((e=>{this._isRecapturing=!1,this.log.warn("recapture failed ".concat(e.message)),this.emit("5",e)}))}))}getRecoverCaptureDeviceId(){return cb(this,null,(function*(){let{deviceId:e}=this;if(e){let t=(oL.get(e)||0)+1;if(oL.set(e,t),t>=3){let i="video"===this.kind?(yield zP()).find((e=>!oL.has(e.deviceId))):(yield JP()).find((e=>!oL.has(e.deviceId)));i&&(this.log.warn("".concat(e," capture fail ").concat(t," times, change new ").concat(i.deviceId)),e=i.deviceId)}}return e}))}close(){var e;super.close(),this._inputTrack&&(this._inputTrack.stop(),this.uninstallTrackEvent(this._inputTrack)),null==(e=this.manager)||e.removeInput(this)}};ob([Hw(Ww.INIT,"capture",{ignoreError:!0})],rL.prototype,"setStateToCapture",1),ob([Hw("capture","publish",{ignoreError:!0,success(){this.room.localTracks.add(this),this.emit("4",{mediaType:this.strMediaType,state:"started",prevState:"starting"})},fail(e){let t="error",i=e.cause;i.message.includes("timeout")?t="timeout":i.code===fb.API_CALL_ABORTED&&(t="api-call"),this.emit("4",{mediaType:this.strMediaType,state:"stopped",prevState:"starting",reason:t,error:i})}})],rL.prototype,"publish",1),ob([nL((e=>function(){return cb(this,null,(function*(){let t="publish"===this.state?"started":"starting";e.call(this),this.emit("4",{mediaType:this.strMediaType,state:"stopped",prevState:t,reason:"api-call"}),2===this.mediaType&&(this.mediaType=4)}))})),Hw([],"capture")],rL.prototype,"unpublish",1);var oL=new Map;UO.on(BO.SWITCH_DEVICE_SUCCESS,(e=>{e.track.deviceId&&oL.delete(e.track.deviceId)}));var sL=class extends rL{constructor(e){super(1),sb(this,"mediaType",1),sb(this,"volume",0),sb(this,"captureVolume",1),sb(this,"profile",{echoCancellation:!0,autoGainControl:!0,noiseSuppression:!0,sampleRate:48e3,channelCount:1,bitrate:40}),sb(this,"playerMuted",!0),this.manager=e}getAudioLevel(){return this.volume||super.getAudioLevel()}capture(){let{deviceId:e,customSource:t,useExact:i=!1}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return super.capture({video:!1,audio:!0,microphoneId:e,echoCancellation:this.profile.echoCancellation,autoGainControl:this.profile.autoGainControl,noiseSuppression:this.profile.noiseSuppression,sampleRate:this.profile.sampleRate,channelCount:this.profile.channelCount,useExact:i,customSource:t})}switchDevice(e){return cb(this,null,(function*(){if(this.mediaTrack){if(this.deviceId===e){if(e!==CD)return;if(yield YP(this.groupId,this.label))return}try{this.log.info("switchDevice audio to: ".concat(e)),this.mediaTrack&&this.mediaTrack.stop(),yield this.capture({deviceId:e,useExact:!0}),this.room&&(yield this.room.replaceTrack(this)),UO.emit(BO.SWITCH_DEVICE_SUCCESS,{track:this}),this.log.info("switch microphone success")}catch(aD){throw this.log.error("switch microphone failed ".concat(aD)),this.deviceId&&this.recapture(this.deviceId),aD}}}))}listenDeviceChange(){GP&&!GP.listeners("audioInputRemoved").includes(this.handleMicrophoneRemoved)&&GP.on("audioInputRemoved",this.handleMicrophoneRemoved,this)}handleMicrophoneRemoved(e){return cb(this,null,(function*(){if(e.deviceId===this.deviceId){this.log.warn("current microphone is lost: ".concat(JSON.stringify(e)));let t=yield JP();t[0]?this.recapture(t[0].deviceId):GP.on("audioInputAdded",this.handleMicrophoneAdded,this)}}))}handleMicrophoneAdded(e){this.log.warn("microphone added: ".concat(JSON.stringify(e))),this.recapture(e.deviceId)}update3A(e){return cb(this,arguments,(function(e){var t=this;let{echoCancellation:i,noiseSuppression:n,autoGainControl:r}=e;return function*(){let e=!1;!rO(i)&&i!==t.profile.echoCancellation&&(t.profile.echoCancellation=i,e=!0),!rO(n)&&n!==t.profile.noiseSuppression&&(t.profile.noiseSuppression=n,e=!0),!rO(r)&&r!==t.profile.autoGainControl&&(t.profile.autoGainControl=r,e=!0),e&&t.deviceId&&(yield t.recapture(t.deviceId))}()}))}setCaptureVolume(e){var t;let i=e/100;i!==this.captureVolume&&(null==(t=this.manager)||t.setCaptureVolume(i),this.captureVolume=i)}close(){GP.off("audioInputAdded",this.handleMicrophoneAdded,this),GP.off("audioInputRemoved",this.handleMicrophoneRemoved,this),super.close()}},aL=class extends rL{constructor(e){super(4),sb(this,"mediaType",4),sb(this,"profile",{width:640,height:480,frameRate:15,bitrate:500}),sb(this,"states",{bytesSent:0,packetsSent:0,framesEncoded:0,framesSent:0,frameWidth:0,frameHeight:0}),sb(this,"small"),sb(this,"facingMode"),sb(this,"isNeedToSetBandwidth"),this.manager=e;let t=()=>{this.isAllowed2k4k(this.profile)?this.room&&this.settings.height>=1440&&"publish"===this.state&&this.room.sendAbilityStatus({"2k4k":1}):(this.log.warn("Resolution is reset to 1080p, need to upgrade ability here https://cloud.tencent.com/document/product/647/85386"),this.setProfile(tb(eb({},this.profile),{width:1920,height:1080})),this.applyProfile())};this.on("input-media-track-changed",t),this.on("publish",t)}capture(){let{deviceId:e,facingMode:t,useExact:i=!1,customSource:n}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return super.capture({audio:!1,video:!0,facingMode:t||this.facingMode,cameraId:e,width:this.profile.width,height:this.profile.height,frameRate:this.profile.frameRate,useExact:i,customSource:n})}setOutputMediaStreamTrack(e){var t;return super.setOutputMediaStreamTrack(e),null==(t=this.room)?void 0:t.replaceTrack(this)}setProfile(e){!e||(e.bitrate&&(this.isNeedToSetBandwidth=e.bitrate!==this.profile.bitrate),this.isAllowed2k4k(this.profile)?super.setProfile(e):(this.log.warn("Resolution is reset to 1080p, need to upgrade ability here https://cloud.tencent.com/document/product/647/85386"),super.setProfile(tb(eb({},this.profile),{width:1920,height:1080}))))}applyProfile(){var e;if(!this.mediaTrack)return;let t=this.settings;return t.height!==this.profile.height||t.width!==this.profile.width||t.frameRate!==this.profile.frameRate?null==(e=this.mediaTrack)?void 0:e.applyConstraints({width:this.profile.width,height:this.profile.height,frameRate:this.profile.frameRate}).then((()=>{if(this.manager&&this.manager.changeInput(this),this.room&&this.settings.height>=1440&&"publish"===this.state&&this.room.sendAbilityStatus({"2k4k":1}),this.isNeedToSetBandwidth&&this.room&&this.room.setBandWidth)return this.isNeedToSetBandwidth=!1,this.room.setBandWidth({bandwidth:this.profile.bitrate,type:MN.VIDEO,videoType:MN.BIG})})):void 0}get settings(){let e={width:this.profile.width,height:this.profile.height,frameRate:this.profile.frameRate};return bw&&this.mediaTrack&&Object.assign(e,this.mediaTrack.getSettings()),e}isAllowed2k4k(e){var t;return!(this.room&&this.room.scheduleResult&&!this.isScreen&&!(e.height*e.width<3686400))||1===(null==(t=this.room.scheduleResult.trtcAutoConf)?void 0:t["2k4k"])}isNeedToSwitchDevice(e){return!(!this.mediaTrack||this.deviceId===e||this.facingMode===e)}switchDevice(e){return cb(this,null,(function*(){let t=e;try{if(!this.isNeedToSwitchDevice(t))return;(t===MN.FACING_MODE_USER||t===MN.FACING_MODE_ENVIRONMENT)&&(this.facingMode=e,t=void 0),this.mediaTrack.stop(),yield this.capture({deviceId:t,useExact:!0}),UO.emit(BO.SWITCH_DEVICE_SUCCESS,{track:this}),this.log.info("switch camera success")}catch(cN){throw this.log.error("switch camera failed ".concat(cN)),this.deviceId&&this.recapture(this.deviceId),cN}}))}listenDeviceChange(){GP&&!GP.listeners("audioInputRemoved").includes(this.handleCameraRemoved)&&GP.on("videoInputRemoved",this.handleCameraRemoved,this)}handleCameraRemoved(e){return cb(this,null,(function*(){if(e.deviceId===this.deviceId){this.log.warn("current camera is lost: ".concat(JSON.stringify(e)));let t=yield zP();t[0]?this.recapture(t[0].deviceId):GP.on("videoInputAdded",this.handleCameraAdded,this)}}))}handleCameraAdded(e){return cb(this,null,(function*(){this.log.warn("camera added: ".concat(JSON.stringify(e))),this.recapture(e.deviceId)}))}close(){GP.off("videoInputAdded",this.handleCameraAdded,this),GP.off("videoInputRemoved",this.handleCameraRemoved,this),super.close()}},cL=function(e){return cb(this,null,(function*(){let t=null,i=function(e){let t={systemAudio:"include",selfBrowserSurface:"include",surfaceSwitching:"include"},i={width:Fk?{max:e.width}:{ideal:e.width,max:e.width},height:Fk?{max:e.height}:{ideal:e.height,max:e.height},frameRate:e.frameRate,displaySurface:"monitor"};if(t.video=i,e.systemAudio){let{echoCancellation:i=!0,noiseSuppression:n=!1,autoGainControl:r=!1}=e;t.audio={echoCancellation:i,noiseSuppression:n,autoGainControl:r,sampleRate:48e3}}return t}(e);jO.info("getDisplayMedia with constraints: ".concat(JSON.stringify(i)));let n=yield navigator.mediaDevices.getDisplayMedia(i);if(e.systemAudio&&0===n.getAudioTracks().length&&(Mk&&Vk<74||Fk||Fb)&&jO.warn("Your browser not support capture system audio"),e.frameRate&&n.getVideoTracks()[0]&&n.getVideoTracks()[0].applyConstraints({frameRate:{min:e.frameRate,ideal:e.frameRate},width:e.width,height:e.height}).catch((e=>{jO.warn("screen applyConstraints failed: ".concat(e))})),e.audio){let i=function(e){let t={echoCancellation:e.echoCancellation,autoGainControl:e.autoGainControl,noiseSuppression:e.noiseSuppression,sampleRate:e.sampleRate,channelCount:e.channelCount};return rO(e.microphoneId)||(t.deviceId=e.microphoneId),{audio:t,video:!1}}(e);jO.info("getUserMedia with constraints: ".concat(JSON.stringify(i))),t=yield navigator.mediaDevices.getUserMedia(i),n.addTrack(t.getAudioTracks()[0])}return n}))},lL=class extends aL{constructor(e){super(e),sb(this,"profile",{width:1920,height:1080,frameRate:5,bitrate:1600}),sb(this,"objectFit","contain"),sb(this,"isScreen",!0),this._log.id="s-".concat(this._log.id)}capture(){return cb(this,arguments,(function(){var e=this;let{systemAudio:t=!1,autoGainControl:i,echoCancellation:n,noiseSuppression:r,audioTrack:o,videoTrack:s}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return function*(){try{let a;return s||o?(a=new MediaStream,s&&a.addTrack(s),o&&a.addTrack(o)):a=yield cL({audio:!1,systemAudio:t,width:e.profile.width,height:e.profile.height,frameRate:e.profile.frameRate,autoGainControl:i,echoCancellation:n,noiseSuppression:r}),yield e.setInputMediaStreamTrack(a.getVideoTracks()[0]),a}catch(c){throw e.log.error("getDisplayMedia error observed ".concat(c)),c instanceof Tb?c:new Tb({code:fb.INITIALIZE_FAILED,name:c.name,message:c.message})}}()}))}switchDevice(e){return cb(this,null,(function*(){throw new Error("Method not implemented.")}))}},dL=class extends sL{constructor(e){super(e),this._log.id="s-".concat(this._log.id)}},uL=class extends sL{constructor(e){super(e),sb(this,"_inputs",new Map),sb(this,"_destination"),sb(this,"audioContext",DP("audio-mixer")),this._log.id="m-".concat(this._log.id),"running"!==this.audioContext.state&&this._log.warn("audio mixer context state: ".concat(this.audioContext.state)),this._destination=this.audioContext.createMediaStreamDestination(),this._destination.channelCount=1}setInputMediaStreamTrack(e){this._inputTrack=e;let t=this.audioContext.createMediaStreamSource(new MediaStream([e]));this._inputs.set(e,{sourceNode:t}),t.connect(this._destination),this._outputTrack||(this._outputTrack=this._destination.stream.getAudioTracks()[0],this.setStateToCapture())}setTrackCaptureVolume(e,t){if(!this._inputs.has(e)||!this._destination)return;let i=this._inputs.get(e),{sourceNode:n}=i;i.gainNode||(this._log.info("create GainNode"),i.gainNode=this.audioContext.createGain()),i.gainNode.gain.value=t,n.disconnect(),n.connect(i.gainNode).connect(this._destination)}publish(e,t){return this.room=e,t}unpublish(){delete this.room}replaceTrack(e,t){var i;!this.hasMix||(t&&(null==(i=this._inputs.get(t))||i.sourceNode.disconnect(),this._inputs.delete(t)),this.setInputMediaStreamTrack(e.outMediaTrack))}removeTrack(e){var t;null==(t=this._inputs.get(e))||t.sourceNode.disconnect(),this._inputs.delete(e),0===this._inputs.size&&(delete this._outputTrack,this.unpublish())}close(){this.stop(),this.audioContext.close()}get hasMix(){return!!this._outputTrack}set channelCount(e){this._destination.channelCount=e}};ob([Hw("capture","publish",{ignoreError:!0})],uL.prototype,"publish",1),ob([Hw([],"capture")],uL.prototype,"unpublish",1);var hL=class extends rL{constructor(e,t){super(1),sb(this,"musicId"),sb(this,"mediaType",1),sb(this,"volume",0),sb(this,"profile",{echoCancellation:!0,autoGainControl:!0,noiseSuppression:!0,sampleRate:48e3,channelCount:1,bitrate:40}),sb(this,"playerMuted",!1),sb(this,"audio"),sb(this,"_audioContext"),sb(this,"_destination"),sb(this,"_source",null),this.manager=e,this.initAudioContext(),this._destination=this._audioContext.createMediaStreamDestination(),this._destination.channelCount=1,this.audio=document.createElement("audio"),this.audio.src=t.url,this.audio.crossOrigin="anonymous",aO(t.loop)&&this.loop(t.loop),sO(t.volume)&&this.setVolume(t.volume),t.id&&(this.musicId=t.id),this._source=this._audioContext.createMediaElementSource(this.audio),this._source.connect(this._destination),this.setInputMediaStreamTrack(this._destination.stream.getAudioTracks()[0]),this.installPlayerEvent()}play(){return cb(this,null,(function*(){try{yield this.audio.play(),yield ab(hL.prototype,this,"play").call(this,null,{muted:!1}),this._log.info("music ".concat(this.musicId," play success"))}catch(aN){this._log.error("music ".concat(this.musicId," play error"),aN)}}))}installPlayerEvent(){this.audio.addEventListener("error",this.handleAudioError.bind(this))}uninstallPlayerEvent(){this.audio.removeEventListener("error",this.handleAudioError.bind(this))}handleAudioError(e){this._log.warn("local music ".concat(this.musicId," audio error"),e)}initAudioContext(){this._audioContext=DP("music"),"running"!==this._audioContext.state&&this._log.warn("local music ".concat(this.musicId," context state: ").concat(this._audioContext.state))}destroy(){var e,t;null==(e=this._source)||e.disconnect(),null==(t=this._destination)||t.disconnect(),this.uninstallPlayerEvent(),this.player.stop(),this._audioContext.close().then((()=>{this._source=null,this._destination=null,this._audioContext=null}))}getStream(){var e;return(null==(e=this._destination)?void 0:e.stream)||null}seek(e){e<0&&e>this.duration()?this._log.warn("Time beyond song duration."):this.audio.currentTime=e}getPosition(){return this.audio.currentTime||0}setVolume(e){e>1&&e<0?this.log.warn("volume is out of range"):this.audio.volume=e}getVolume(){return this.audio.volume||0}setPlayBackRate(e){e>8&&e<0?this.log.warn("rate is out of range"):this.audio.playbackRate=e}getPlayBackRate(){return this.audio.playbackRate||0}duration(){return this.audio.duration||0}loop(e){return this.audio&&aO(e)&&(this.audio.loop=e),this.audio.loop||!1}setOperation(e){"pause"===e&&this.audio.pause(),"resume"===e&&(this.audio.pause(),this.audio.play()),"stop"===e&&(this.audio.pause(),this.seek(0))}listenDeviceChange(){}},pL="input",mL="output",_L=e=>(e=Number(e))>0&&e<14e8;function fL(e){return cb(this,arguments,(function(e){let{sdkAppId:t,userId:i,userSig:n,timestamp:r}=e;return function*(){let e="https://".concat(function(e){let t;return t=_L(e)?"intl-schedule.rtc.qq.com":"schedule.rtc.qq.com",t}(t),"/api/v1/audioAiAuth?sdkAppId=").concat(t,"&userId=").concat(i,"&userSig=").concat(n,"&timestamp=").concat(r),o=yield fetch(e),{data:{errCode:s,errMsg:a,sign:c,status:l}}=yield o.json();if("1"===l)return{auth:!0,sign:c,status:l,message:a};let d="Init RTCAIDenoiser failed.",u="";switch(s){case 1:u="Please check your params.";break;case 2:u="You need to buy packages. Refer to: https://cloud.tencent.com/document/product/647/44247";break;case 3:u="Server is invalid. Please contact our engineer. ";break;case 4:u="Your packages is not active. Refer to: https://cloud.tencent.com/document/product/647/44247";break;case 5:u="Your packages is expired. Refer to: https://cloud.tencent.com/document/product/647/44247";break;case 6:u="Your version is not supported."}return{auth:!1,status:l,message:a?"".concat(d," Reason: ").concat(a,". ").concat(u):"".concat(d,", ").concat(u)}}()}))}var gL=rb(lb(),1);function TL(e,t){t=t||{};let i,n=e.numberOfChannels,{sampleRate:r}=e,o=t.float32?3:1,s=3===o?32:16;return i=2===n?function(e,t){let i=e.length+t.length,n=new Float32Array(i),r=0,o=0;for(;r<i;)n[r++]=e[o],n[r++]=t[o],o++;return n}(e.getChannelData(0),e.getChannelData(1)):e.getChannelData(0),function(e,t,i,n,r){let o=r/8,s=n*o,a=new ArrayBuffer(44+e.length*o),c=new DataView(a);return EL(c,0,"RIFF"),c.setUint32(4,36+e.length*o,!0),EL(c,8,"WAVE"),EL(c,12,"fmt "),c.setUint32(16,16,!0),c.setUint16(20,t,!0),c.setUint16(22,n,!0),c.setUint32(24,i,!0),c.setUint32(28,i*s,!0),c.setUint16(32,s,!0),c.setUint16(34,r,!0),EL(c,36,"data"),c.setUint32(40,e.length*o,!0),1===t?function(e,t,i){for(let n=0;n<i.length;n++,t+=2){let r=Math.max(-1,Math.min(1,i[n]));e.setInt16(t,r<0?32768*r:32767*r,!0)}}(c,44,e):function(e,t,i){for(let n=0;n<i.length;n++,t+=4)e.setFloat32(t,i[n],!0)}(c,44,e),a}(i,o,r,n,s)}function EL(e,t,i){for(let n=0;n<i.length;n++)e.setUint8(t+n,i.charCodeAt(n))}var SL=class{constructor(e){sb(this,"audioContext_"),sb(this,"inputPCM_",new Float32Array),sb(this,"outputPCM_",new Float32Array),this.audioContext_=e}onDump(e,t){if(t===pL){let t=this.inputPCM_.length,i=new Float32Array(t+e[0].length);i.set(this.inputPCM_),i.set(e[0],t),this.inputPCM_=i}if(t===mL){let t=this.outputPCM_.length,i=new Float32Array(t+e[0].length);i.set(this.outputPCM_),i.set(e[0],t),this.outputPCM_=i}}getBlob(e){let t=e===pL?this.inputPCM_:this.outputPCM_,i=this.audioContext_.createBuffer(2,t.length,48e3);i.copyToChannel(t,0,0),i.copyToChannel(t,1,0);let n=TL(i);return i=null,new window.Blob([new DataView(n)],{type:"audio/wav"})}reset(){this.inputPCM_=new Float32Array,this.outputPCM_=new Float32Array}destroy(){this.reset()}},IL=class{constructor(e){let{sdkAppId:t,userId:i,audioContext:n,sign:r,status:o,worklet:s,timestamp:a,logger:c}=e;sb(this,"audioContext_"),sb(this,"destination_"),sb(this,"gainNode_"),sb(this,"log_"),sb(this,"workletNode_"),sb(this,"isDumping_",!1),sb(this,"dump_"),sb(this,"trackConstraint_",{}),sb(this,"audioTrack_"),sb(this,"source_"),sb(this,"denoiserTrack_"),sb(this,"enableDenoise_",!0),sb(this,"emitter_",new gL.default),this.audioContext_=n,this.destination_=this.audioContext_.createMediaStreamDestination(),this.gainNode_=this.audioContext_.createGain(),this.gainNode_.gain.value=1.1,this.log_=c,this.workletNode_=s,this.workletNode_.connect(this.gainNode_).connect(this.destination_),this.workletNode_.port.postMessage({type:"init",data:{sdkAppId:String(t),userId:i,timestamp:a,sign:r,status:o}}),this.workletNode_.port.onmessage=e=>{let{type:t,data:i}=e.data;if("ondump"===t&&this.isDumping_){let{inputPCM:e,outputPCM:t}=i;this.dump_.onDump(e,pL),this.dump_.onDump(t,mL)}"dumped"===t&&this.dumped()},this.dump_=new SL(this.audioContext_)}dumped(){this.isDumping_=!1;let e=this.dump_.getBlob(pL),t=this.dump_.getBlob(mL);this.emitter_.emit("ondumpend",{blob:e,name:pL}),this.emitter_.emit("ondumpend",{blob:t,name:mL}),this.dumpedWAV(e,pL),this.dumpedWAV(t,mL),this.dump_.reset()}dumpedWAV(e,t){let i=window.URL.createObjectURL(e),n=document.createElement("a");n.href=i,n.download="".concat(t,"-").concat(Date.now(),".wav"),n.click(),window.URL.revokeObjectURL(i),n.href=""}process(e){return cb(this,null,(function*(){if(this.audioTrack_=e,!this.audioTrack_)throw new Error("RTCAIDenoiser: cannot process without audioTrack.");let t=new MediaStream;t.addTrack(this.audioTrack_),this.source_=this.audioContext_.createMediaStreamSource(t),yield this.source_.connect(this.workletNode_),this.trackConstraint_=this.audioTrack_.getConstraints(),this.trackConstraint_.noiseSuppression=!1,yield this.audioTrack_.applyConstraints(this.trackConstraint_);let i=this.destination_.stream;return this.denoiserTrack_=i.getAudioTracks()[0],this.log_.info("RTCAIDenoiser: denoiser process track ID: ".concat(e.id," success.")),this.denoiserTrack_}))}updateTrack(e){return cb(this,null,(function*(){var t;let i=new MediaStream;yield i.addTrack(e);let n=this.audioContext_.createMediaStreamSource(i);this.source_.disconnect(),n.connect(this.workletNode_),null==(t=this.audioTrack_)||t.stop(),this.audioTrack_=e,this.source_=n,this.log_.info("RTCAIDenoiser: updateTrack success.")}))}disable(){return cb(this,null,(function*(){var e,t;return this.enableDenoise_=!1,null==(e=this.workletNode_)||e.port.postMessage({type:"disable"}),this.trackConstraint_.noiseSuppression=!0,yield null==(t=this.audioTrack_)?void 0:t.applyConstraints(this.trackConstraint_),this.log_.info("RTCAIDenoiser: disable ai denoiser."),this.enableDenoise_}))}enable(){return cb(this,null,(function*(){var e,t;return this.enableDenoise_=!0,null==(e=this.workletNode_)||e.port.postMessage({type:"enable"}),this.trackConstraint_.noiseSuppression=!1,yield null==(t=this.audioTrack_)?void 0:t.applyConstraints(this.trackConstraint_),this.log_.info("RTCAIDenoiser: enable ai denoiser."),this.enableDenoise_}))}startDump(){return this.isDumping_?(this.log_.info("RTCAIDenoiser: data is currently being dumped."),!1):(this.workletNode_.port.postMessage({type:"startDump"}),this.dump_?this.dump_.reset():this.dump_=new SL(this.audioContext_),this.isDumping_=!0,this.log_.info("RTCAIDenoiser: start dump data."),!0)}stopDump(){!this.isDumping_||(this.workletNode_.port.postMessage({type:"stopDump"}),this.isDumping_=!1,this.log_.info("RTCAIDenoiser: stop dump data."))}getAudioTrack(){return this.audioTrack_}getDenoiserTrack(){return this.destination_.stream.getAudioTracks()[0]}get enabled(){return this.enableDenoise_}destroy(){var e,t,i,n,r,o;this.log_.info("RTCAIDenoiser: destroy processor."),null==(e=this.audioTrack_)||e.stop(),null==(t=this.workletNode_)||t.port.postMessage({type:"destroy"}),this.workletNode_.port.onmessage=null,null==(i=this.source_)||i.disconnect(),null==(n=this.destination_)||n.disconnect(),null==(r=this.workletNode_)||r.disconnect(),null==(o=this.dump_)||o.destroy(),this.emitter_.removeAllListeners()}on(e,t,i){this.emitter_.on(e,t,i)}off(e,t,i){"*"===e?this.emitter_.removeAllListeners():this.emitter_.off(e,t,i)}},yL=class{constructor(e){let{assetsPath:t,log:i,audioContext:n}=e;this.isLoaded_=!1,this.audioContext_=n,this.log_=i,this.assetsPath_=t}createProcessor(e){return cb(this,null,(function*(){let t=String(Date.now()).slice(0,-3),{auth:i,sign:n,status:r,message:o}=yield fL(tb(eb({},e),{timestamp:t}));if(!i)throw this.log_.info("RTCAIDenoiser: ".concat(e.userId," auth result: ").concat(i,". Message: ").concat(o)),new Error(o);try{yield this.load()}catch(l){throw new Error("Init wasm failed, please check your assetsPath.")}let s=yield this.initWorklet(),a=new IL(tb(eb({},e),{audioContext:this.audioContext_,timestamp:t,sign:n,status:r,worklet:s,logger:this.log_}));return this.log_.info("RTCAIDenoiser: ".concat(e.userId," create denoiser processor success.")),a}))}load(){return cb(this,null,(function*(){if(!this.isLoaded_)try{yield this.audioContext_.audioWorklet.addModule("".concat(this.assetsPath_,"/denoiser-wasm.js")),this.isLoaded_=!0}catch(FL){throw this.log_.error("Init assets from ".concat(this.assetsPath_," failed! Reason: ").concat(FL)),FL}}))}initWorklet(){return cb(this,null,(function*(){try{return new AudioWorkletNode(this.audioContext_,"trtc-denoiser-processor",{numberOfInputs:1,numberOfOutputs:1})}catch(FL){return yield this.load(),new AudioWorkletNode(this.audioContext_,"trtc-denoiser-processor",{numberOfInputs:1,numberOfOutputs:1})}}))}destroy(){var e;null==(e=this.audioContext_)||e.close()}isSupported(){return"AudioWorklet"in window&&"WebAssembly"in window}},vL=class{constructor(e){let{room:t}=e;sb(this,"_localAudioTrack",null),sb(this,"_localScreenAudioTrack",null),sb(this,"localMixAudioTrack"),sb(this,"isDenoiserInit",!1),sb(this,"isDenoiserEnabled",!1),sb(this,"isDenoiserProcessed",!1),sb(this,"mixedMusicMap",new Map),sb(this,"cacheMusicMap",new Map),sb(this,"_log"),sb(this,"denoiserTrack",null),sb(this,"denoiser",null),sb(this,"denoiserProcessor"),sb(this,"initProcessorOptions"),sb(this,"denoiserContext"),this._log=jO.createLogger({id:"am",userId:t.userId,sdkAppId:t.sdkAppId})}get mixedAudioTrack(){return this.localMixAudioTrack?this.localMixAudioTrack.outMediaTrack:null}get hasScreenAudioTrack(){return null!==this._localScreenAudioTrack}get hasAudioTrack(){return null!==this._localAudioTrack}changeInput(e,t){var i,n,r;return e instanceof dL?(this._localScreenAudioTrack=e,void(e._outputTrack=e.mediaTrack)):e instanceof hL?(e._outputTrack=e.mediaTrack,void(null==(i=this.localMixAudioTrack)||i.replaceTrack(e,t))):e instanceof sL?(this._localAudioTrack=e,this.isDenoiserProcessed&&(null==(n=this.denoiserProcessor)||n.updateTrack(e.mediaTrack)),e.setOutputMediaStreamTrack(this.isDenoiserProcessed?this.denoiserTrack:e.mediaTrack),void(null==(r=this.localMixAudioTrack)||r.replaceTrack(e,t))):e instanceof CL?e.setOutputMediaStreamTrack(e.mediaTrack):void 0}removeInput(e){if(e instanceof sL)return this.removeAudioTrack(e)}addMusicSource(e){return cb(this,null,(function*(){this._log.info("add music source, id: ".concat(e.id," url: ").concat(e.url));let t,{id:i,url:n,loop:r,volume:o}=e;if(!this.mixedMusicMap.has(i))return t=this.cacheMusicMap.has(i)?this.cacheMusicMap.get(i):new hL(this,e),t.play(),this._log.info("start mix audio ".concat(i," success.")),this.mixedMusicMap.set(i,t),this.cacheMusicMap.set(i,t),t}))}updateMusicSource(e){return cb(this,null,(function*(){let{id:t,volume:i,loop:n,operation:r,seekFrom:o}=e;if(this._log.info("update music source, ".concat(JSON.stringify(e))),this.mixedMusicMap.has(t)){let e=this.mixedMusicMap.get(t);rO(i)||e.setVolume(i),rO(n)||e.loop(n),rO(r)||e.setOperation(r),rO(o)||e.seek(o)}}))}addAudioTrack(e){return cb(this,null,(function*(){var t;if(this.localMixAudioTrack||(this.localMixAudioTrack=new uL(this)),this._log.info("start add audioTrack, userId: ".concat(e.userId)),e===this._localAudioTrack){if(bw){let i=yield null==(t=e.mediaTrack)?void 0:t.getSettings();this.localMixAudioTrack.channelCount=(null==i?void 0:i.channelCount)||1}this.mixedMusicMap.forEach((e=>{var t;null==(t=this.localMixAudioTrack)||t.setInputMediaStreamTrack(e.outMediaTrack)}))}this.localMixAudioTrack.setInputMediaStreamTrack(e.outMediaTrack),this._localAudioTrack&&1!==this._localAudioTrack.captureVolume&&this.setCaptureVolume(this._localAudioTrack.captureVolume)}))}removeAudioTrack(e){!this.localMixAudioTrack||(e===this._localAudioTrack&&this.mixedMusicMap.forEach((e=>{this.localMixAudioTrack.removeTrack(e.outMediaTrack)})),this.localMixAudioTrack.removeTrack(e.outMediaTrack))}removeMusicSource(e){let{id:t}=e;if(this.localMixAudioTrack){if(this.mixedMusicMap.has(t)){this._log.info("remove music source, music id: ".concat(t));let e=this.mixedMusicMap.get(t);e.stop(),this.localMixAudioTrack.removeTrack(e.outMediaTrack),this.mixedMusicMap.delete(t)}"*"===t&&this.destroyAllMusic()}}destroyAllMusic(){this._log.info("destroy all music source."),this.mixedMusicMap.forEach(((e,t)=>{this.removeMusicSource({id:t})}))}destroyAllCache(){this._log.info("destroy all music cache."),this.cacheMusicMap.forEach((e=>e.stop()))}initDenoiser(e){return cb(this,null,(function*(){let{assetsPath:t,sdkAppId:i,userId:n,userSig:r}=e;try{(!this.denoiserContext||"closed"===this.denoiserContext.state)&&(this.denoiserContext=DP("denoiser")),this.denoiser||(this.denoiser=new yL({assetsPath:t,log:this._log,audioContext:this.denoiserContext})),this.denoiserProcessor||(this.denoiserProcessor=yield this.denoiser.createProcessor({sdkAppId:i,userId:n,userSig:r})),this.isDenoiserInit=!0,this.initProcessorOptions=e}catch(lN){throw lN}}))}enableDenoiser(e){return cb(this,null,(function*(){var e,t,i;if(this.isDenoiserEnabled=!0,!this.hasAudioTrack){let e="enableDenoiser failed, there is no audio";throw this._log.error(e),new Error(e)}if(this.isDenoiserProcessed)null==(i=this.denoiserProcessor)||i.enable();else{let i=null==(e=this._localAudioTrack)?void 0:e.mediaTrack;if(!i)return;this.denoiserProcessor||(yield this.initDenoiser(this.initProcessorOptions)),this.denoiserTrack=yield this.denoiserProcessor.process(i),this.isDenoiserProcessed=!0,this._localAudioTrack._outputTrack=this.denoiserTrack,null==(t=this.localMixAudioTrack)||t.replaceTrack(this._localAudioTrack,i)}}))}disableDenoiser(){return cb(this,null,(function*(){var e;this.isDenoiserEnabled&&(null==(e=this.denoiserProcessor)||e.disable(),this.isDenoiserEnabled=!1)}))}setCaptureVolume(e){var t;this.localMixAudioTrack&&this._localAudioTrack&&this._localAudioTrack.mediaTrack&&(null==(t=this.localMixAudioTrack)||t.setTrackCaptureVolume(this._localAudioTrack.mediaTrack,e))}destroyDenoiserProcessor(){var e;this.denoiserProcessor&&(this.denoiserProcessor.destroy(),delete this.denoiserProcessor,this.isDenoiserInit=!1,this.isDenoiserEnabled=!1,this.isDenoiserProcessed=!1,null==(e=this.denoiserTrack)||e.stop(),this.denoiserTrack=null),this.denoiserContext&&(this.denoiserContext.close(),delete this.denoiserContext)}destroy(){var e;this.destroyAllMusic(),this.destroyAllCache(),this.destroyDenoiserProcessor(),null==(e=this.denoiser)||e.destroy(),this.localMixAudioTrack&&(this.localMixAudioTrack.close(),delete this.localMixAudioTrack)}},AL=class extends xP{constructor(e,t,i){super({userId:t.userId,sdkAppId:e.sdkAppId,mediaType:i,room:e}),this.room=e,this.user=t,sb(this,"tinyId"),sb(this,"isRemote",!0),this.tinyId=t.tinyId}setMute(e){return this.hasFlag&&super.setMute(e)}setInputMediaStreamTrack(e){super.setInputMediaStreamTrack(e),this.hasFlag&&this.isSubscribed&&this.player.setTrack(this.outMediaTrack)}waitHasMediaTrack(){return new Promise((e=>{this.mediaTrack?e():this.once("input-media-track-changed",e)}))}get isSubscribing(){return"subscribeing"===this.state.toString()}get isSubscribed(){return this.state===AL.STATE_SUBSCRIBE}get streamType(){return 0==(2&this.mediaType)?"main":"auxiliary"}subscribe(e){return e}unsubscribe(){this.player.setTrack(null),"main"===this.streamType&&"video"===this.kind&&this.room.changeType(!1,this.user)}updatePlayingState(e){if(this.isPlayCalled&&this.player.isStopped===e){if(e&&(!this.isSubscribed||!this.hasFlag||!this.outMediaTrack))return void this.log.info("abort play, isSubscribed:".concat(this.isSubscribed," hasFlag:").concat(this.hasFlag," hasTrack:").concat(!!this.outMediaTrack));super.updatePlayingState(e)}}onFlagChanged(){this.updatePlayingState(this.hasFlag)}},RL=AL;sb(RL,"STATE_SUBSCRIBE","subscribe"),ob([Hw(Ww.INIT,RL.STATE_SUBSCRIBE,{success(){this.log.info("subscribed"),UO.emit(BO.REMOTE_TRACK_SUBSCRIBED,{track:this}),this.updatePlayingState(!0)},ignoreError:!0})],RL.prototype,"subscribe",1),ob([Hw(RL.STATE_SUBSCRIBE,Ww.INIT,{success(){this.log.info("unsubscribed"),this.updatePlayingState(!1),UO.emit(BO.REMOTE_TRACK_UNSUBSCRIBED,{track:this})}})],RL.prototype,"unsubscribe",1);var CL=class extends RL{constructor(e,t){super(e,t,1),sb(this,"volume",0),sb(this,"mediaType",1),sb(this,"stat",{bytesReceived:0,packetsReceived:0,packetsLost:0,end2EndDelay:0,jitterBufferDelay:0}),this.manager=e.audioManager}getAudioLevel(){return this.volume||super.getAudioLevel()}get hasFlag(){return this.user.muteState.hasAudio&&!this.user.muteState.audioMuted}isFlagChanged(e){let t=e.hasAudio&&!e.audioMuted;return this.hasFlag||(this.volume=0),this.hasFlag!==t}},bL=class extends RL{constructor(e,t){super(e,t,arguments.length>2&&void 0!==arguments[2]?arguments[2]:4),sb(this,"mediaType",4),sb(this,"stat",{bytesReceived:0,packetsReceived:0,packetsLost:0,framesReceived:0,framesDecoded:0,frameWidth:0,frameHeight:0,end2EndDelay:0,jitterBufferDelay:0}),this.manager=e.videoManager}changeType(e){this.room.changeType(e,this.user)}get hasFlag(){return this.user.muteState.hasVideo&&!this.user.muteState.videoMuted}isFlagChanged(e){let t=e.hasVideo&&!e.videoMuted;return this.hasFlag!==t}},kL=class extends bL{constructor(e,t){super(e,t,2),sb(this,"mediaType",2),sb(this,"objectFit","contain")}get hasFlag(){return this.user.muteState.hasAuxiliary}isFlagChanged(e){let t=e.hasAuxiliary;return this.hasFlag!==t}};function NL(){}var DL=e=>e(),OL=()=>"undefined"!=typeof __FASTRX_DEVTOOLS__,wL=1,PL=class extends Function{toString(){return"".concat(this.name,"(").concat(this.args.length?[...this.args].join(", "):"",")")}subscribe(e){let t=new BL(e,this,this.streamId++);return HL.subscribe({id:this.id,end:!1},{nodeId:t.sourceId,streamId:t.id}),this(t),t}},LL=class{constructor(){this.defers=new Set,this.disposed=!1}next(e){}complete(){this.dispose()}error(e){this.dispose()}get bindDispose(){return()=>this.dispose()}dispose(){this.disposed=!0,this.complete=NL,this.error=NL,this.next=NL,this.dispose=NL,this.subscribe=NL,this.doDefer()}subscribe(e){return e instanceof PL?e.subscribe(this):e(this),this}get bindSubscribe(){return e=>this.subscribe(e)}doDefer(){this.defers.forEach(DL),this.defers.clear()}defer(e){this.defers.add(e)}removeDefer(e){this.defers.delete(e)}reset(){this.disposed=!1,delete this.complete,delete this.next,delete this.dispose,delete this.next,delete this.subscribe}resetNext(){delete this.next}resetComplete(){delete this.complete}resetError(){delete this.error}},ML=class extends LL{constructor(e){super(),this.sink=e,e.defer(this.bindDispose)}next(e){this.sink.next(e)}complete(){this.sink.complete()}error(e){this.sink.error(e)}};function xL(e,t,i){if(OL()){let n=Object.defineProperties(Object.setPrototypeOf(e,PL.prototype),{streamId:{value:0,writable:!0,configurable:!0},name:{value:t,writable:!0,configurable:!0},args:{value:i,writable:!0,configurable:!0},id:{value:0,writable:!0,configurable:!0}});HL.create(n);for(let e=0;e<i.length;e++){let t=i[e];"function"==typeof t&&t instanceof PL&&HL.addSource(n,t)}return n}return e}function VL(e,t){window.postMessage({source:"fastrx-devtools-backend",payload:{event:e,payload:t}})}var UL,FL,BL=class extends ML{constructor(e,t,i){super(e),this.source=t,this.id=i,this.sourceId=e.sourceId,this.defer((()=>{HL.defer(this.source,this.id)}))}next(e){HL.next(this.source,this.id,e),this.sink.next(e)}complete(){HL.complete(this.source,this.id),this.sink.complete()}error(e){HL.complete(this.source,this.id,e),this.sink.error(e)}},HL={addSource(e,t){VL("addSource",{id:e.id,name:e.toString(),source:{id:t.id,name:t.toString()}})},next(e,t,i){VL("next",{id:e.id,streamId:t,data:i&&i.toString()})},subscribe(e,t){let{id:i,end:n}=e;VL("subscribe",{id:i,end:n,sink:{nodeId:t&&t.nodeId,streamId:t&&t.streamId}})},complete(e,t,i){VL("complete",{id:e.id,streamId:t,err:i?i.toString():null})},defer(e,t){VL("defer",{id:e.id,streamId:t})},pipe(e){VL("pipe",{name:e.toString(),id:e.id,source:{id:e.source.id,name:e.source.toString()}})},update(e){VL("update",{id:e.id,name:e.toString()})},create(e){e.id||(e.id=wL++),VL("create",{name:e.toString(),id:e.id})}},jL=class extends LL{constructor(e){super(),this.source=e,this.sinks=new Set}add(e){e.defer((()=>this.remove(e))),1===this.sinks.add(e).size&&(this.reset(),this.subscribe(this.source))}remove(e){this.sinks.delete(e),0===this.sinks.size&&this.dispose()}next(e){this.sinks.forEach((t=>t.next(e)))}complete(){this.sinks.forEach((e=>e.complete())),this.sinks.clear()}error(e){this.sinks.forEach((t=>t.error(e))),this.sinks.clear()}},GL=(UL=class extends ML{constructor(e,t,i){super(e),this.mapper=t,this.thisArg=i}next(e){super.next(this.mapper.call(this.thisArg,e))}},FL="map",function(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];return e=>{if(e instanceof PL){let i=xL((n=>{let r=new UL(n,...t);r.sourceId=i.id,r.subscribe(e)}),FL,arguments);return i.source=e,HL.pipe(i),i}return i=>e(new UL(i,...t))}});!function(e){for(var t=arguments.length,i=new Array(t>1?t-1:0),n=1;n<t;n++)i[n-1]=arguments[n];i.reduce(((e,t)=>t(e)),e)}(function(e){return xL((t=>{let i=0,n=setInterval((()=>t.next(i++)),e);return t.defer((()=>{clearInterval(n)})),"interval"}),"interval",arguments)}(250),GL((()=>performance.now())),function(){return e=>{let t=new jL(e);if(e instanceof PL){let i=xL((e=>{t.add(e)}),"share",arguments);return t.sourceId=i.id,i.source=e,HL.pipe(i),i}return xL(t.add.bind(t),"share",arguments)}}());var WL=new Map;function JL(e,t){let i=tb(eb({},t),{timestamp:Sb()});WL.has(e)?WL.get(e).push(i):WL.set(e,[i])}UO.on(BO.JOIN_SUCCESS,(e=>{let{room:t}=e;JL(t.userId,{eventId:32788,eventDesc:"join room"})})),UO.on(BO.LEAVE_START,(e=>{let{room:t}=e;JL(t.userId,{eventId:32789,eventDesc:"leave room"})})),UO.on(BO.LOCAL_TRACK_PUBLISHED,(e=>{let{track:t}=e;if(t.room){let e=32769;4===t.mediaType?e=32768:2===t.mediaType&&(e=32805),JL(t.room.userId,{eventId:e,eventDesc:"publish ".concat(t.kind)})}})),UO.on(BO.LOCAL_TRACK_UNPUBLISHED,(e=>{let{track:t}=e;if(t.room){let e=32771;4===t.mediaType?e=32770:2===t.mediaType&&(e=32806),JL(t.room.userId,{eventId:e,eventDesc:"unpublish ".concat(t.kind)})}})),UO.on(BO.TRACK_MUTED,(e=>{let{track:t}=e;t.room&&(t.kind===MN.AUDIO?JL(t.room.userId,{eventId:t.isRemote?32785:32772,eventDesc:"mute audio",remoteUserId:t.isRemote?t.userId:void 0}):JL(t.room.userId,{eventId:t.isRemote?32784:32773,eventDesc:"mute video",remoteUserId:t.isRemote?t.userId:void 0}))})),UO.on(BO.TRACK_UNMUTED,(e=>{let{track:t}=e;t.room&&(t.kind===MN.AUDIO?JL(t.room.userId,{eventId:t.isRemote?32787:32774,eventDesc:"unmute audio",remoteUserId:t.isRemote?t.userId:void 0}):JL(t.room.userId,{eventId:t.isRemote?32786:32775,eventDesc:"unmute video",remoteUserId:t.isRemote?t.userId:void 0}))})),UO.on(BO.REMOTE_TRACK_SUBSCRIBED,(e=>{let{track:t}=e;!t.room||(1===t.mediaType&&JL(t.room.userId,{eventId:32777,eventDesc:"".concat(MN.SUBSCRIBE," ").concat(t.kind),remoteUserId:t.userId}),4===t.mediaType&&JL(t.room.userId,{eventId:32776,eventDesc:"".concat(MN.SUBSCRIBE," ").concat(t.kind),remoteUserId:t.userId}),8===t.mediaType&&JL(t.room.userId,{eventId:32803,eventDesc:"".concat(MN.SUBSCRIBE," ").concat(MN.SMALL_VIDEO),remoteUserId:t.userId}))})),UO.on(BO.REMOTE_TRACK_UNSUBSCRIBED,(e=>{let{track:t}=e;!t.room||(1===t.mediaType&&JL(t.room.userId,{eventId:32779,eventDesc:"".concat(MN.UNSUBSCRIBE," ").concat(t.kind),remoteUserId:t.userId}),4===t.mediaType&&JL(t.room.userId,{eventId:32778,eventDesc:"".concat(MN.UNSUBSCRIBE," ").concat(t.kind),remoteUserId:t.userId}),8===t.mediaType&&JL(t.room.userId,{eventId:32804,eventDesc:"".concat(MN.UNSUBSCRIBE," ").concat(MN.SMALL_VIDEO),remoteUserId:t.userId}))})),UO.on(BO.SWITCH_DEVICE_SUCCESS,(e=>{let{track:t}=e;t.room&&JL(t.room.userId,{eventId:t.kind===MN.VIDEO?32780:32781,eventDesc:"switch ".concat(t.kind===MN.VIDEO?"camera":"microphone")})})),UO.on(BO.LOCAL_TRACK_REPLACED,(e=>{let{track:t}=e;t.room&&JL(t.room.userId,{eventId:t.kind===MN.VIDEO?32782:32783,eventDesc:"replace ".concat(t.kind)})})),UO.on(BO.SIGNAL_CONNECTION_STATE_CHANGED,(e=>{let t,i,{room:n,prevState:r,state:o}=e;switch(o){case"CONNECTED":"RECONNECTING"===r?(t=32795,i="signal reconnected"):(t=32791,i="signal connected");break;case"DISCONNECTED":"RECONNECTING"===r?(t=32796,i="signal reconnect fail"):(t=32790,i="signal disconnected");break;case"RECONNECTING":t=32794,i="signal reconnecting"}t&&i&&JL(n.userId,{eventId:t,eventDesc:i})})),UO.on(BO.PEER_CONNECTION_STATE_CHANGED,(e=>{let t,i,{room:n,prevState:r,state:o,remoteUserId:s}=e,a=!!s,c=a?"downlink":"uplink";switch(o){case"CONNECTED":"RECONNECTING"===r?(t=a?32801:32798,i="".concat(c," reconnected")):(t=a?32793:32792,i="".concat(c," connected"));break;case"DISCONNECTED":"RECONNECTING"===r&&(t=a?32802:32799,i="".concat(c," reconnect fail"));break;case"RECONNECTING":t=a?32800:32797,i="".concat(c," reconnecting")}t&&i&&JL(n.userId,{eventId:t,eventDesc:i,remoteUserId:s})}));var zL,KL=rb(lb(),1),qL=class extends KL.EventEmitter{constructor(e,t){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"userId";super(),this.mySelfId=e,this._log=t,this.key=i,sb(this,"userMap",new Map),sb(this,"remotePublishedUserMap",new Map)}getPublishedUser(e){return this.remotePublishedUserMap.get(e)}addUser(e){let t=e[this.key],{userId:i,tinyId:n,role:r}=e;if(this.userMap.has(t))return;let o={userId:i,tinyId:n,role:20===r?"anchor":"audience"};this.userMap.set(t,o),this.emit("1",o)}deleteUser(e,t){let i=this.userMap.get(e);if(!i)return;let n="peer leave [".concat(e,"]");rO(t)||(n+=":".concat(DD[t])),this._log.info(n);let r=this.remotePublishedUserMap.get(e);if(r){let t=r.muteState;r.flag=0,this.emit("5",r.userId),this.deleteRemotePublishedUser(e),this.emit("6",{prevMuteState:t,muteState:r.muteState,flag:0})}this.userMap.delete(e),this.emit("2",i.userId)}setUserList(e){this.userMap.forEach((t=>{e.findIndex((e=>e[this.key]===t[this.key]))<0&&this.deleteUser(t[this.key],0)})),e.forEach((e=>{!this.userMap.has(e[this.key])&&e[this.key]!==this.mySelfId&&this.addUser(e)}))}addRemotePublishedUser(e){this.remotePublishedUserMap.has(e[this.key])||this.remotePublishedUserMap.set(e[this.key],e)}deleteRemotePublishedUser(e){!this.remotePublishedUserMap.has(e)||this.remotePublishedUserMap.delete(e)}setRemotePublishedUserList(e){this.remotePublishedUserMap.forEach((t=>{let i=t[this.key];if(e.findIndex((e=>e[this.key]===t[this.key]))<0){this._log.info("remote [".concat(i,"] unpublish"));let e=t.muteState;t.flag=0,this.emit("5",t.userId),this.deleteRemotePublishedUser(i),this.emit("6",{prevMuteState:e,muteState:t.muteState,flag:0})}})),e.forEach((e=>{var t;let i=e[this.key];if(i===this.mySelfId)return;let{flag:n,userId:r,tinyId:o}=e,s=yO(n,r),a=null==(t=this.remotePublishedUserMap.get(i))?void 0:t.muteState;if(a){let e=this.remotePublishedUserMap.get(i);e&&e.flag!==n&&(e.flag=n,this._log.info("remote publish updated: ".concat(JSON.stringify(e.muteState))),this.emit("6",{prevMuteState:a,muteState:s,flag:n}))}else this._log.info("remote publish. state: ".concat(JSON.stringify(s))),this.addUser({userId:r,tinyId:o,role:20}),this.emit("3",e),this.emit("6",{prevMuteState:yO(0,r),muteState:s,flag:n})}))}clear(){this.userMap.clear(),this.remotePublishedUserMap.clear()}},YL=!0,QL={SCENE_LIVE:"live",SCENE_RTC:"rtc",ROLE_ANCHOR:"anchor",ROLE_AUDIENCE:"audience",STREAM_TYPE_MAIN:"main",STREAM_TYPE_SUB:"sub",AUDIO_PROFILE_STANDARD:"standard",AUDIO_PROFILE_STANDARD_STEREO:"standard-stereo",AUDIO_PROFILE_HIGH:"high",AUDIO_PROFILE_HIGH_STEREO:"high-stereo",QOS_PREFERENCE_SMOOTH:"smooth",QOS_PREFERENCE_CLEAR:"clear"},XL={INVALID_PARAMETER:5e3,INVALID_OPERATION:5100,ENV_NOT_SUPPORTED:5200,DEVICE_ERROR:5300,SERVER_ERROR:5400,OPERATION_FAILED:5500,OPERATION_ABORT:5998,UNKNOWN_ERROR:5999},$L=((zL=$L||{})[zL.INVALID_PARAMETER=5e3]="INVALID_PARAMETER",zL[zL.INVALID_PARAMETER_REQUIRED=5001]="INVALID_PARAMETER_REQUIRED",zL[zL.INVALID_PARAMETER_TYPE=5002]="INVALID_PARAMETER_TYPE",zL[zL.INVALID_PARAMETER_EMPTY=5003]="INVALID_PARAMETER_EMPTY",zL[zL.INVALID_PARAMETER_INSTANCE=5004]="INVALID_PARAMETER_INSTANCE",zL[zL.INVALID_PARAMETER_RANGE=5005]="INVALID_PARAMETER_RANGE",zL[zL.INVALID_PARAMETER_LESS_THAN_ZERO=5006]="INVALID_PARAMETER_LESS_THAN_ZERO",zL[zL.INVALID_PARAMETER_MIN=5007]="INVALID_PARAMETER_MIN",zL[zL.INVALID_PARAMETER_MAX=5008]="INVALID_PARAMETER_MAX",zL[zL.INVALID_ELEMENT_ID=5009]="INVALID_ELEMENT_ID",zL[zL.INVALID_ELEMENT_ID_TYPE=5010]="INVALID_ELEMENT_ID_TYPE",zL[zL.INVALID_STREAM_ID=5011]="INVALID_STREAM_ID",zL[zL.INVALID_ROOM_ID_STRING=5012]="INVALID_ROOM_ID_STRING",zL[zL.INVALID_ROOM_ID_INTEGER=5013]="INVALID_ROOM_ID_INTEGER",zL[zL.INVALID_STREAM_TYPE=5014]="INVALID_STREAM_TYPE",zL[zL.INVALID_ROOM_ID_REQUIED=5015]="INVALID_ROOM_ID_REQUIED",zL[zL.INVALID_ROOM_ID_INTEGER_STRING=5016]="INVALID_ROOM_ID_INTEGER_STRING",zL[zL.INVALID_OPERATION=5100]="INVALID_OPERATION",zL[zL.INVALID_OPERATION_NOT_JOINED=5101]="INVALID_OPERATION_NOT_JOINED",zL[zL.INVALID_OPERATION_REMOTE_USER_NOT_EXIST=5102]="INVALID_OPERATION_REMOTE_USER_NOT_EXIST",zL[zL.INVALID_OPERATION_STREAM_TYPE_NOT_EXIST=5103]="INVALID_OPERATION_STREAM_TYPE_NOT_EXIST",zL[zL.INVALID_OPERATION_REPEAT_CALL=5104]="INVALID_OPERATION_REPEAT_CALL",zL[zL.ENV_NOT_SUPPORTED=5200]="ENV_NOT_SUPPORTED",zL[zL.NOT_SUPPORTED_HTTP=5201]="NOT_SUPPORTED_HTTP",zL[zL.NOT_SUPPORTED_WEBRTC=5202]="NOT_SUPPORTED_WEBRTC",zL[zL.NOT_SUPPORTED_H264_ENCODE=5203]="NOT_SUPPORTED_H264_ENCODE",zL[zL.NOT_SUPPORTED_H264_DECODE=5204]="NOT_SUPPORTED_H264_DECODE",zL[zL.NOT_SUPPORTED_SCREEN_SHARE=5205]="NOT_SUPPORTED_SCREEN_SHARE",zL[zL.NOT_SUPPORTED_SMALL_VIDEO=5206]="NOT_SUPPORTED_SMALL_VIDEO",zL[zL.NOT_SUPPORTED_SEI=5207]="NOT_SUPPORTED_SEI",zL[zL.DEVICE_ERROR=5300]="DEVICE_ERROR",zL[zL.DEVICE_NOT_FOUND_ERROR=5301]="DEVICE_NOT_FOUND_ERROR",zL[zL.DEVICE_NOT_ALLOWED_ERROR=5302]="DEVICE_NOT_ALLOWED_ERROR",zL[zL.DEVICE_NOT_READABLE_ERROR=5303]="DEVICE_NOT_READABLE_ERROR",zL[zL.DEVICE_OVERCONSTRAINED_ERROR=5304]="DEVICE_OVERCONSTRAINED_ERROR",zL[zL.DEVICE_INVALID_STATE_ERROR=5305]="DEVICE_INVALID_STATE_ERROR",zL[zL.DEVICE_SECURITY_ERROR=5306]="DEVICE_SECURITY_ERROR",zL[zL.DEVICE_ABORT_ERROR=5307]="DEVICE_ABORT_ERROR",zL[zL.CAMERA_RECOVER_FAILED=5308]="CAMERA_RECOVER_FAILED",zL[zL.MICROPHONE_RECOVER_FAILED=5309]="MICROPHONE_RECOVER_FAILED",zL[zL.SERVER_ERROR=5400]="SERVER_ERROR",zL[zL.ACCOUNT_NO_MONEY=-100013]="ACCOUNT_NO_MONEY",zL[zL.OPERATION_FAILED=5500]="OPERATION_FAILED",zL[zL.FIREWALL_RESTRICTION=5501]="FIREWALL_RESTRICTION",zL[zL.REJOIN_FAILED=5502]="REJOIN_FAILED",zL[zL.EVENT_HANDLER_ERROR=5503]="EVENT_HANDLER_ERROR",zL[zL.VIDEO_CONTEXT_ERROR=5504]="VIDEO_CONTEXT_ERROR",zL[zL.OPERATION_ABORT=5998]="OPERATION_ABORT",zL[zL.UNKNOWN_ERROR=5999]="UNKNOWN_ERROR",zL),ZL=tb(eb({},KO),{INVALID_PARAMETER(e){let{fnName:t}=e;return"the parameters of the '".concat(t,"' you called does not meet the requirements, please check the API documentation.")},INVALID_PARAMETER_REQUIRED(e){let{key:t,rule:i,fnName:n,value:r}=e;return"'".concat(t||i.name,"' is a required param when calling ").concat(n,"(), received: ").concat(r,".")},INVALID_PARAMETER_TYPE(e){let{key:t,rule:i,fnName:n,value:r}=e,o="".concat(t||i.name),s="";return s=Array.isArray(i.type)?i.type.join("|"):i.type,"'".concat(o,"' must be type of ").concat(s," when calling ").concat(n,"(), received type: ").concat(iO(r),".")},INVALID_PARAMETER_EMPTY(e){let{key:t,rule:i,fnName:n,value:r}=e;return"'".concat(t||i.name,"' cannot be '").concat(r,"' when calling ").concat(n,"().")},INVALID_PARAMETER_INSTANCE(e){let{key:t,rule:i,fnName:n,value:r}=e,o="".concat(t||i.name),s="".concat(i.instanceOf.name||i.instanceOf);return"'".concat(o,"' must be instanceof ").concat(s," when calling ").concat(n,"(), received type: ").concat(iO(r),".")},INVALID_PARAMETER_RANGE(e){let{key:t,rule:i,fnName:n,value:r}=e;return"'".concat(t||i.name,"' must be one of ").concat(i.values.join("|")," when calling ").concat(n,"(), received: ").concat(r,".")},INVALID_PARAMETER_LESS_THAN_ZERO(e){let{key:t,rule:i,fnName:n}=e;return"'".concat(t||i.name,"' cannot be less than 0 when calling ").concat(n,"().")},INVALID_PARAMETER_MIN(e){let{key:t,rule:i,value:n}=e;return"the min value of ".concat(t||i.name," is ").concat(i.min,", received: ").concat(n,".")},INVALID_PARAMETER_MAX(e){let{key:t,rule:i,value:n}=e;return"the max value of ".concat(t||i.name," is ").concat(i.max,", received: ").concat(n,".")},INVALID_ELEMENT_ID(e){let{key:t,fnName:i}=e;return"'".concat(t,"' is not found in the document object when calling ").concat(i,"().")},INVALID_ELEMENT_ID_TYPE(e){let{key:t,fnName:i,type:n}=e;return"the element corresponding to '".concat(t,"' must be instanceof HTMLElement when calling ").concat(i,"(), received: ").concat(n,".")},INVALID_STREAM_ID(e){let{key:t}=e;return"'".concat(t,"' can only consist of uppercase and lowercase english letters (a-zA-Z), numbers (0-9), hyphens and underscores.")},INVALID_ROOM_ID_STRING(e){let{key:t}=e;return"'".concat(t,"' must be a valid string.")},INVALID_ROOM_ID_INTEGER(e){let{key:t}=e;return"'".concat(t,"' must be an integer between [1, 4294967294].")},INVALID_ROOM_ID_INTEGER_STRING(e){let{key:t}=e;return"'".concat(t,"' must be an integer but go a string, use 'parseInt' to convert it or use 'strRoomId' instead.")},INVALID_ROOM_ID_REQUIED:()=>"at least one of 'roomId'(between [1, 4294967294]) and 'strRoomId'(not empty) is required.",INVALID_STREAM_TYPE:e=>{let{fnName:t}=e;return"'streamType' is required when 'userId' is not '*', calling ".concat(t,"()")},MIX_PARAMS_USER_Z_ORDER(e){let{key:t}=e;return"'".concat(t,"' is required and must be between 1 and 15.")},MIX_PARAMS_VIDEO_FRAMERATE:"'config.videoFramerate' should be an integer between 0 and 30, excluding 0.",MIX_PARAMS_VIDEO_GOP:"'config.videoGOP' should be an integer between 1 and 8.",MIX_PARAMS_AUDIO_BITRATE:"'config.audioBitrate' should be an integer between 32 and 192.",MIX_PARAMS_NOT_SELF:"'config.mixUsers' must contain self.",MIX_PARAMS_USER_STREAM:"'config.videoWidth' and 'config.videoHeight' of output stream should be contain all mix stream.",INVALID_OPERATION(e){let{fnName:t}=e;return"the API '".concat(t,"' you called does not meet the requirements, please check the API documentation.")},INVALID_OPERATION_NOT_JOINED(e){let{fnName:t}=e;return"cannot ".concat(t," because you are not enter room yet.")},INVALID_OPERATION_REMOTE_USER_NOT_EXIST(e){let{fnName:t,value:i}=e;return"cannot ".concat(t," because remote user(userId: ").concat(i.userId,") does not publishing stream.")},INVALID_OPERATION_STREAM_TYPE_NOT_EXIST(e){let{fnName:t,value:i}=e;return"cannot ".concat(t," because remote user(userId: ").concat(i.userId,") does not publishing ").concat(i.streamType," video.")},INVALID_OPERATION_REPEAT_CALL(e){let{fnName:t}=e;return"you are already ".concat(t,"(), cannot repeated call '").concat(t,"'.")},ENV_NOT_SUPPORTED(e){let{fnName:t}=e;return"the current browser does not support the capability of the function '".concat(t,"' you are calling, please check the API documentation.")},NOT_SUPPORTED_WEBRTC:"the current browser does not support WebRTC capability, please check the SDK documentation.",NOT_SUPPORTED_H264_ENCODE:"this browser does not support H264 encode.",NOT_SUPPORTED_H264_DECODE:"this browser does not support H264 decode.",NOT_SUPPORTED_SCREEN_SHARE:"this browser does not support screen share, please check the browser version.",NOT_SUPPORTED_SMALL_VIDEO:"this browser does not support small video, please check the browser version.",NOT_SUPPORTED_SEI:"this browser does not support SEI, please check the browser version.",DEVICE_ERROR(e){let{fnName:t,error:i}=e;return"'".concat(t,"' got device exception").concat(i?", error: ".concat(i.toString(),"."):".")},DEVICE_NOT_FOUND_ERROR(e){let{fnName:t,deviceType:i=eM(t),error:n}=e;return"NotFoundError, no ".concat(i," detected, please check your device and the configuration on '").concat(t,"'").concat(n?", error: ".concat(n.toString(),"."):".")},DEVICE_NOT_ALLOWED_ERROR(e){let{fnName:t,deviceType:i=eM(t),error:n}=e;return"NotAllowedError, you have disabled ".concat(i," access, please allow the current application to use the ").concat(i).concat(n?", error: ".concat(n.toString(),"."):".")},DEVICE_NOT_READABLE_ERROR(e){let{fnName:t,deviceType:i=eM(t),error:n}=e;return"NotReadableError, the ".concat(i," maybe in use by another APP, please check if the device is pre-occupied by another APP.")},DEVICE_OVERCONSTRAINED_ERROR(e){let{fnName:t,deviceType:i=eM(t),error:n}=e;return"OverconstrainedError, the device ID is incorrect, please check whether the device ID passed in is correct".concat(n?", error: ".concat(n.toString(),"."):".")},DEVICE_INVALID_STATE_ERROR(e){let{fnName:t,deviceType:i=eM(t),error:n}=e;return"InvalidStateError, after the user clicks and interacts with the page, turn on the ".concat(i).concat(n?", error: ".concat(n.toString(),"."):".")},DEVICE_SECURITY_ERROR(e){let{fnName:t,deviceType:i=eM(t),error:n}=e;return"SecurityError, check whether the system security policy restricts the use of the ".concat(i,", and it is recommended to turn on the ").concat(i," after the user interacts with the page").concat(n?", error: ".concat(n.toString(),"."):".")},DEVICE_ABORT_ERROR(e){let{fnName:t,deviceType:i=eM(t),error:n}=e;return"AbortError, an unknown exception in the system makes the device unusable, recommended to change the device or browser and re-check whether the device is normal".concat(n?" error: ".concat(n.toString(),"."):".")},CAMERA_RECOVER_FAILED(e){let{error:t}=e;return"camera recover capture failed ".concat((null==t?void 0:t.name)||"",": ").concat((null==t?void 0:t.originMessage)||(null==t?void 0:t.message))},MICROPHONE_RECOVER_FAILED(e){let{error:t}=e;return"microphone recover capture failed ".concat((null==t?void 0:t.name)||"",": ").concat((null==t?void 0:t.originMessage)||(null==t?void 0:t.message))},OPERATION_FAILED(e){let{fnName:t,error:i}=e;return"'".concat(t,"' failed, reason: ").concat(null==i?void 0:i.toString())},FIREWALL_RESTRICTION:()=>"media connection failure due to firewall restrictions, please try to change your network.",EVENT_HANDLER_ERROR(e){let{eventName:t}=e;return"an error was caught on trtc.on('".concat(t,"', handler), please check your code on 'handler'.")},VIDEO_CONTEXT_ERROR(e){let{reason:t,error:i}=e;return"video context error ".concat(t," ").concat((null==i?void 0:i.name)||""," ").concat((null==i?void 0:i.message)||"")},SERVER_ERROR(e){let{fnName:t,error:i}=e;return"'".concat(t,"' got server error: ").concat(null==i?void 0:i.toString(),", please check the SDK documentation.")},ACCOUNT_NO_MONEY:e=>{let{fnParams:t}=e;return"your TRTC account run out of credit, please recharge.".concat(t.sdkAppId?" SDKAppId: ".concat(t.sdkAppId):"")},OPERATION_ABORT(e){let{fnName:t}=e;return"'".concat(t,"' abort")},UNKNOWN_ERROR(e){let{fnName:t,error:i}=e;return"'".concat(t,"' throw unknown exception").concat(i?", error: ".concat(i.toString(),"."):".")}});function eM(e){if(!e)return"camera";let t=e.toLowerCase();return t.includes("screen")?"screen share":t.includes("audio")?"microphone":"camera"}var tM=class extends Error{constructor(e){let{code:t,extraCode:i,message:n="",messageParams:r,fnName:o="",originError:s}=e;var a;let c;c=n||function(e){let t,{code:i,params:n,enableDocLink:r=!1}=e,s="",a=$L[i];try{t=ZL[a]}catch(o){t=ZL.UNKNOWN_ERROR}return nO(t)?s=t(n):oO(t)&&(s=t),r&&(s+=" doc:"),s}({code:i||t,params:eb({fnName:o,error:s},r)}),super(c),sb(this,"name","RtcError"),sb(this,"code"),sb(this,"extraCode"),sb(this,"functionName"),sb(this,"message"),sb(this,"handler"),sb(this,"originError"),this.name=$L[t],this.code=t,this.extraCode=i,this.functionName=o,this.originError=s,this.message=c,5302===this.extraCode&&(null==(a=this.originError)?void 0:a.message.includes("system"))&&(this.handler=()=>{let e=document.createElement("a");_k?e.href="ms-settings:privacy-".concat({startLocalVideo:"webcam",startLocalAudio:"microphone"}[this.functionName]):fk&&(e.href="x-apple.systempreferences:com.apple.preference.security?Privacy_".concat({startLocalVideo:"Camera",startLocalAudio:"Microphone",startScreenShare:"ScreenCapture"}[this.functionName])),e.href.length>0&&e.click()})}static convertFrom(e,t,i){let n=e;if(e instanceof Tb){let{stack:r}=e,o={code:XL.UNKNOWN_ERROR,fnName:t,originError:e};switch(e.getCode()){case fb.INVALID_PARAMETER:o.code=XL.INVALID_PARAMETER;break;case fb.INVALID_OPERATION:o.code=XL.INVALID_OPERATION;break;case fb.NOT_SUPPORTED:case fb.NOT_SUPPORTED_H264:o.code=XL.ENV_NOT_SUPPORTED,e.getCode()===fb.NOT_SUPPORTED_H264&&(o.extraCode=e.message.includes(KO.NOT_SUPPORTED_H264ENCODE)?5203:5204);break;case fb.DEVICE_NOT_FOUND:case fb.DEVICE_AUTO_RECOVER_FAILED:o.code=XL.DEVICE_ERROR;break;case fb.JOIN_ROOM_FAILED:o.messageParams={fnParams:i};case fb.SERVER_TIMEOUT:case fb.SWITCH_ROLE_FAILED:o.code=XL.SERVER_ERROR,o.extraCode=e.getExtraCode();break;case fb.API_CALL_ABORTED:o.code=XL.OPERATION_ABORT;break;case fb.INITIALIZE_FAILED:o.code=5300,o.extraCode=function(e){let t;switch(e){case"NotFoundError":t=5301;break;case"NotAllowedError":t=5302;break;case"NotReadableError":t=5303;break;case"OverconstrainedError":t=5304;break;case"InvalidStateError":t=5305;break;case"SecurityError":t=5306;break;case"AbortError":t=5307;break;default:t=5300}return t}(e.name);break;case fb.UNKNOWN:break;default:o.code=XL.OPERATION_FAILED}n=new tM(o),r&&(n.stack+=r.substr(r.indexOf("\n")))}else n=new tM({code:XL.UNKNOWN_ERROR,fnName:t,originError:e});return n}},iM=tM,nM={type:"object",properties:{cameraId:{type:"string"},useFrontCamera:{type:"boolean"},fillMode:{type:"string",values:["contain","cover","fill"]},mirror:{type:"boolean"},small:{properties:{width:{type:"number"},height:{type:"number"},frameRate:{type:"number"},bitrate:{type:"number"}}},videoTrack:{instanceOf:MediaStreamTrack}}},rM={type:"object",properties:{systemAudio:{type:"boolean"},fillMode:{type:"string",values:["contain","cover","fill"]},profile:{type:["string","object"],properties:{width:{type:"number"},height:{type:"number"},frameRate:{type:"number"},bitrate:{type:"number"}}},videoTrack:{instanceOf:MediaStreamTrack},audioTrack:{instanceOf:MediaStreamTrack}}},oM={type:["string",HTMLElement,null,"array"],arrayItem:{instanceOf:HTMLElement},validate(e,t,i){if(oO(e)){let n=document.getElementById(e);if(!n)throw new iM({code:XL.INVALID_PARAMETER,extraCode:5009,fnName:i,messageParams:{key:t}});if(!(n instanceof HTMLElement))throw new iM({code:XL.INVALID_PARAMETER,extraCode:5010,fnName:i,messageParams:{key:t,type:iO(n)}})}}},sM={name:"userId",required:!0,type:"string"},aM={type:"object",properties:{microphoneId:{type:"string"},audioTrack:{instanceOf:MediaStreamTrack},captureVolume:{type:"number",min:0},earMonitorVolume:{type:"number",min:0,max:100},echoCancellation:{type:"boolean"},autoGainControl:{type:"boolean"},noiseSuppression:{type:"boolean"}}};function cM(e,t){if(!e)throw new iM({code:XL.INVALID_OPERATION,extraCode:5101,fnName:t})}function lM(e,t,i){if(!e)throw new iM({code:XL.INVALID_OPERATION,extraCode:5102,fnName:t,messageParams:{value:i}})}var dM={create:[{name:"RoomConfig",instanceOf:Function},{name:"CreateConfig",type:"object",properties:{plugins:{type:"array",arrayItem:{instanceOf:Function}}}}],enterRoom:{name:"EnterRoomConfig",type:"object",required:!0,validate(e,t,i){if(this._room.isJoined)throw new iM({code:XL.INVALID_OPERATION,extraCode:5104,fnName:i});if(e.roomId){if(oO(e.roomId))throw new iM({code:XL.INVALID_PARAMETER,extraCode:5016,fnName:i,messageParams:{key:t}});if(!(/^[1-9]\d*$/.test(String(e.roomId))&&e.roomId<4294967295))throw new iM({code:XL.INVALID_PARAMETER,extraCode:5013,fnName:i,messageParams:{key:t}})}else{if(!e.strRoomId)throw new iM({code:XL.INVALID_PARAMETER,extraCode:5015,fnName:i});if(!/^[A-Za-z\d\s!#$%&()+\-:;<=.>?@[\]^_{}|~,]{1,64}$/.test(e.strRoomId))throw new iM({code:XL.INVALID_PARAMETER,extraCode:5012,fnName:i,messageParams:{key:t}})}},properties:{sdkAppId:{required:!0,type:"number",allowEmpty:!1},userId:{required:!0,type:"string",allowEmpty:!1},userSig:{required:!0,type:"string",allowEmpty:!1},scene:{type:"string",values:["live","rtc"]},role:{type:"string",values:["audience","anchor"]},roomId:{type:["string","number"]},strRoomId:{type:"string"},proxy:{type:["object","string"],properties:{websocketProxy:{type:"string"},turnServer:{type:["object","array"],properties:{url:{required:!0,type:"string"},username:{type:"string"},credential:{type:"string"},credentialType:{type:"string",values:["password"]}}},loggerProxy:{type:"string"},webtransportProxy:{type:"string"}}},enableAutoPlayDialog:{type:"boolean"},userDefineRecordId:{type:"string"}}},startLocalVideo:{name:"LocalVideoConfig",type:"object",properties:{view:oM,publish:{type:"boolean"},option:nM},validate(e){var t;if((null==(t=null==e?void 0:e.option)||!t.videoTrack)&&rw())throw new iM({code:XL.ENV_NOT_SUPPORTED,extraCode:5201})}},updateLocalVideo:{name:"updateLocalVideoConfig",type:"object",required:!0,properties:{view:tb(eb({},oM),{required:!1}),publish:{type:"boolean"},mute:{type:"boolean"},option:nM}},startLocalAudio:{name:"LocalAudioConfig",type:"object",properties:{publish:{type:"boolean"},option:aM},validate(e){var t;if((null==(t=null==e?void 0:e.option)||!t.audioTrack)&&rw())throw new iM({code:XL.ENV_NOT_SUPPORTED,extraCode:5201})}},updateLocalAudio:{name:"updateLocalAudioConfig",type:"object",required:!0,properties:{publish:{type:"boolean"},mute:{type:"boolean"},option:aM}},startScreenShare:{name:"ScreenShareConfig",type:"object",properties:{view:oM,publish:{type:"boolean"},option:rM},validate(e,t,i,n,r){var o;if((null==(o=null==e?void 0:e.option)||!o.videoTrack)&&rw())throw new iM({code:XL.ENV_NOT_SUPPORTED,extraCode:5201});if(!dw())throw new iM({code:XL.ENV_NOT_SUPPORTED,fnName:i,extraCode:5205})}},updateScreenShare:{name:"updateScreenShareConfig",type:"object",required:!0,properties:{view:oM,publish:{type:"boolean"},option:rM}},muteRemoteAudio:[sM,{name:"mute",required:!0,type:"boolean"}],setRemoteAudioVolume:[sM,{name:"volume",required:!0,type:"number",min:0}],startRemoteVideo:{name:"startRemoteVideoConfig",type:"object",required:!0,properties:{view:oM,userId:{type:"string",required:!0},streamType:{values:["main","sub"],required:!0},option:{type:"object",properties:{fillMode:{type:"string",values:["contain","cover","fill"]},mirror:{type:"boolean"}}}},validate(e,t,i){cM(this._room.isJoined,i);let n=this._room.remotePublishedUserMap.get(e.userId);if(lM(!!n,i,e),n&&("main"===e.streamType&&!n.muteState.videoAvailable||"sub"===e.streamType&&!n.muteState.hasAuxiliary))throw new iM({code:XL.INVALID_OPERATION,extraCode:5103,fnName:i,messageParams:{value:e}})}},updateRemoteVideo:{name:"updateRemoteVideoConfig",type:"object",required:!0,properties:{view:tb(eb({},oM),{required:!1}),userId:{type:"string",required:!0},streamType:{values:["main","sub"],required:!0},option:{type:"object",properties:{fillMode:{type:"string",values:["contain","cover","fill"]},mirror:{type:"boolean"}}}},validate(e,t,i){cM(this._room.isJoined,i);let n=this._room.remotePublishedUserMap.get(e.userId);if(lM(!!n,i,e),n&&("main"===e.streamType&&!n.muteState.videoAvailable||"sub"===e.streamType&&!n.muteState.hasAuxiliary))throw new iM({code:XL.INVALID_OPERATION,extraCode:5103,fnName:i,messageParams:{value:e}})}},stopRemoteVideo:{name:"stopRemoteVideoConfig",type:"object",required:!0,properties:{userId:{type:"string",required:!0},streamType:{values:["main","sub"]}},validate(e,t,i){if("*"!==e.userId&&rO(e.streamType))throw new iM({code:XL.INVALID_PARAMETER,extraCode:5014,fnName:i})}},switchRole:{name:"role",required:!0,values:["anchor","audience"],validate(e,t,i){cM(this._room.isJoined,i)}},enableAudioVolumeEvaluation:[{name:"interval",type:"number"},{name:"enableInBackground",type:"boolean"}],sendSEIMessage:[{name:"buffer",required:!0,instanceOf:ArrayBuffer,validate(e,t,i,n){if(!Nw)throw new iM({code:XL.ENV_NOT_SUPPORTED,fnName:i,extraCode:5207});if(!this._room.enableSEI)throw new iM({code:XL.INVALID_OPERATION,messageParams:{key:zO.SEI_DISABLED}});if(e.byteLength>1e3)throw new iM({code:XL.INVALID_PARAMETER,messageParams:{key:zO.SEI_OVERSIZE,data:e.byteLength}});if(0===e.byteLength)throw new iM({code:XL.INVALID_PARAMETER,messageParams:{key:zO.SEI_EMPTY}});if(cM(this._room.isJoined,i),!this._room.isMainStreamPublished)throw new iM({code:XL.INVALID_PARAMETER,messageParams:{key:zO.SEI_BEFORE_PUBLISH}})}},{name:"options",type:"object",properties:{seiPayloadType:{type:"number",values:[5,243]}}}]},uM={TRTC:dM},hM=class extends Error{};function pM(e,t){let i=[];return bO(i,e),bO(i,t),i}function mM(e){this._resolve=Promise.resolve(e)}function _M(e){this._reject=Promise.reject(e)}var fM=class{constructor(e,t){this.instance=e,this.group=t,this.started=!1,this.ops=[],this.startSame=()=>!0,this.mergeUpdate=pM;let i=fM.instances.get(e);i?i.set(t,this):fM.instances.set(e,new Map([[t,this]]))}static get(e,t){let i=fM.instances.get(e);return i&&i.get(t)||new fM(e,t)}action(e,t,i){let n=t=>{var i;return 0===e?this.started=!0:3===e&&(this.started=!1),this.ops.shift(),null==(i=this.currentOp)||i.action(),t},r=t=>{var i,n;throw this.ops.shift(),0===e&&2===(null==(i=this.currentOp)?void 0:i.type)&&this.ops.shift().reject(new hM("start failed")),null==(n=this.currentOp)||n.action(),t},o={type:e,action:()=>t(...o.args).then(n,r),args:i,resolve:mM,reject:_M};try{switch(this.state){case 1:if(0===e)throw new hM("already started");break;case 4:if(2===e)throw new hM("not started");break;default:return this.cacheOp(o)}}catch(JV){return Promise.reject(JV)}return this.ops.push(o),o.promise=t(...o.args).then(n,r)}cacheOp(e){if(1===this.ops.length)switch(this.state){case 0:case 2:if(0===e.type)throw new hM("already start");break;case 3:switch(e.type){case 2:throw new hM("update not allowed when stopping");case 3:return this.currentOp.promise}break;default:throw new hM("unknown state")}else switch(e.type){case 3:if(3===this.lastOpType)return this.lastOp.promise;{let e=new hM("keep stop");if(this.ops.slice(1).forEach((t=>t.reject(e))),this.ops=this.ops.slice(0,1),3===this.state)return this.currentOp.promise}break;case 2:switch(this.lastOpType){case 2:return this.lastOp.args=this.mergeUpdate(this.lastOp.args,e.args),this.lastOp.promise;case 3:throw new hM("update not allowed after stop")}break;case 0:switch(this.lastOpType){case 2:throw new hM("start not allowed after update");case 0:throw new hM("duplicate start");case 3:if(this.startSame(this.currentOp.args,e.args))throw this.ops.pop().reject(new hM("keep start")),new hM("already start")}}e.promise=new Promise(((t,i)=>{e._resolve?e._resolve.then(t):e.resolve=t,e._reject?e._reject.catch(i):e.reject=i}));let{action:t}=e;return e.action=()=>t().then(e.resolve,e.reject),this.ops.push(e),e.promise}get lastOp(){return this.ops[this.ops.length-1]}get lastOpType(){return this.lastOp.type}get currentOp(){return this.ops[0]}get state(){return this.currentOp?this.currentOp.type:this.started?1:4}},gM=fM;gM.instances=new WeakMap;var TM=new WeakMap,EM=(e,t)=>{if(t instanceof hM){let{stack:i}=t;t=new iM({code:XL.OPERATION_ABORT,message:"".concat(e," abort: ").concat(t.message),fnName:e}),i&&(t.stack+=i.substr(i.indexOf("\n")))}throw t};function SM(e,t){return nL(((i,n)=>function(){for(var r=arguments.length,o=new Array(r),s=0;s<r;s++)o[s]=arguments[s];let a=gM.get(this,"string"==typeof e?e:e.call(this,...o));return t&&(a.startSame=t.bind(this)),a.action(0,i.bind(this),o).catch(EM.bind(null,n))}))}function IM(e,t){let{merge:i,debounce:n}=t||{};return nL(((t,r)=>function(){for(var o=arguments.length,s=new Array(o),a=0;a<o;a++)s[a]=arguments[a];let c=gM.get(this,"string"==typeof e?e:e.call(this,...s));if(i&&(c.mergeUpdate=i.bind(this)),n&&n.isNeedToDebounce.apply(this,s)){let{delay:e,getKey:i}=n;return new Promise(((n,o)=>{var a,l;let d=null==(a=TM.get(this))?void 0:a.get(i(...s));if(d){let{timeoutId:e,resolve:t}=d;clearTimeout(e),t()}let u=setTimeout((()=>{if(3===c.state||4===c.state)return n();c.action(2,t.bind(this),s).catch(EM.bind(null,r)).then(n,o)}),e);TM.has(this)?null==(l=TM.get(this))||l.set(i(...s),{timeoutId:u,resolve:n}):TM.set(this,new Map([[i(...s),{timeoutId:u,resolve:n}]]))}))}return c.action(2,t.bind(this),s).catch(EM.bind(null,r))}))}function yM(e){return nL(((t,i)=>function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return gM.get(this,"string"==typeof e?e:e.call(this,...r)).action(3,t.bind(this),r).catch(EM.bind(null,i))}))}var vM={ERROR:"error",AUTOPLAY_FAILED:"autoplay-failed",KICKED_OUT:"kicked-out",REMOTE_USER_ENTER:"remote-user-enter",REMOTE_USER_EXIT:"remote-user-exit",REMOTE_AUDIO_AVAILABLE:"remote-audio-available",REMOTE_AUDIO_UNAVAILABLE:"remote-audio-unavailable",REMOTE_VIDEO_AVAILABLE:"remote-video-available",REMOTE_VIDEO_UNAVAILABLE:"remote-video-unavailable",AUDIO_VOLUME:"audio-volume",NETWORK_QUALITY:"network-quality",CONNECTION_STATE_CHANGED:"connection-state-changed",AUDIO_PLAY_STATE_CHANGED:"audio-play-state-changed",VIDEO_PLAY_STATE_CHANGED:"video-play-state-changed",SCREEN_SHARE_STOPPED:"screen-share-stopped",DEVICE_CHANGED:"device-changed",PUBLISH_STATE_CHANGED:"publish-state-changed",SEI_MESSAGE:"sei-message",STATISTICS:"statistics"};function AM(e){return e===QL.QOS_PREFERENCE_CLEAR?"detail":e===QL.QOS_PREFERENCE_SMOOTH?"motion":""}function RM(e){return{room:e,innerEmitter:UO,constants:nN,environment:vb,utils:yb,eventLogger:Xw,log:e.getLogger(),clearStarted(t,i){let n=t.getAlias(),r=gM.instances.get(e);if(r)if(i){let e=r.get(n+i);if(!e)return;e.started=!1}else r.forEach(((e,t)=>{t.startsWith(n)&&(e.started=!1)}))}}}var CM=new WeakMap;function bM(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];return nL(((e,i)=>function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];try{NM.call(this,t,r,i,this._name)}catch(cN){return Promise.reject(cN)}return e.apply(this,r)}))}function kM(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];return nL(((e,i)=>function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];try{NM.call(this,t,r,i,this._name)}catch(cN){throw cN}return e.apply(this,r)}))}function NM(e,t,i,n){if(lO(e))for(let r=0;r<e.length;r++)DM.call(this,{rule:e[r],value:t[r],key:e[r].name,fnName:i,className:n});else DM.call(this,{rule:e,value:t[0],key:e.name,fnName:i,className:n})}function DM(e){let{rule:t,value:i,key:n,fnName:r,className:o}=e;function s(e){return{code:XL.INVALID_PARAMETER,extraCode:e,fnName:r,messageParams:{key:n,rule:t,value:i}}}if(rO(i)){if(t.required)throw new iM(s(5001));if(rO(t.defaultValue))return void(nO(t.validate)&&t.validate.call(this,i,n,r,o,this));i=t.defaultValue}if(Array.isArray(t.type)){let e=!1;for(let n=0;n<t.type.length;n++)null===t.type[n]&&null===i&&(e=!0),nO(t.type[n])&&i instanceof t.type[n]&&(e=!0),oO(t.type[n])&&iO(i)===t.type[n].toLowerCase()&&(e=!0);if(!e)throw new iM({code:XL.INVALID_PARAMETER,extraCode:5002,fnName:r,messageParams:{key:n,rule:{type:t.type.map((e=>pO(e)?mO(e):oO(e)?e:iO(e)))},value:i}})}else if(!rO(t.type)&&iO(i)!==t.type)throw new iM(s(5002));if(!1===t.allowEmpty){let e=sO(i)&&(0===i||Number.isNaN(i)),t=oO(i)&&""===i.trim();if(e||t)throw new iM(s(5003))}if(t.notLessThanZero&&sO(i)&&i<0)throw new iM(s(5006));if(!rO(t.min)&&sO(i)&&i<t.min)throw new iM(s(5007));if(!rO(t.max)&&sO(i)&&i>t.max)throw new iM(s(5008));if(oO(t.instanceOf)){if(!i||i._name!==t.instanceOf)throw new iM(s(5004))}else if(nO(t.instanceOf)&&!(i instanceof t.instanceOf))throw new iM(s(5004));if(Array.isArray(t.values)&&!t.values.includes(i))throw new iM(s(5005));let{properties:a}=t;ZD(a)&&cO(i)&&Object.keys(a).forEach((e=>{DM.call(this,{rule:a[e],value:i&&i[e],key:"".concat(e),fnName:r,className:o})}));let{arrayItem:c}=t;ZD(c)&&lO(i)&&i.forEach(((e,t)=>{DM.call(this,{rule:c,value:e,key:"".concat(n,"[").concat(t,"]"),fnName:r,className:o})})),nO(t.validate)&&t.validate.call(this,i,n,r,o,this)}function OM(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},{namePrefix:t=(()=>""),getRemoteId:i=(()=>"")}=e;return nL(((e,n)=>function(){for(var r=arguments.length,o=new Array(r),s=0;s<r;s++)o[s]=arguments[s];function a(e,t,i){if(i&&i.includes(e))return"hided";if(t===o||e in o)return t;try{return t instanceof HTMLElement?"id: ".concat(t.id," type:").concat(iO(t)):(JSON.stringify(t),t)}catch(n){return"type:".concat(iO(t))}}let c=this._log||loggerManager,l=t.call(this,...o),d=""!==l?"".concat(l,".").concat(n):n;o.length>0?c.info("".concat(d,"() ").concat(JSON.stringify(o,((e,t)=>a(e,t,["userSig","privateMapKey"]))))):c.info("".concat(d,"()"));try{let t=e.apply(this,o),n=gO();return hO(t)?t.then((e=>(c.info("".concat(d,"() success ").concat(i.call(this,...o))),UO.emit(BO.API_SUCCESS_RATE,{room:this._room,apiName:d,cost:gO()-n}),e))).catch((e=>{throw e=iM.convertFrom.call(this,e,d,1===o.length?o[0]:o),c.error("".concat(d,"() failed ").concat(i.call(this,...o)," ").concat(e," params: ").concat(JSON.stringify(o,a))),UO.emit(BO.API_SUCCESS_RATE,{room:this._room,apiName:d,error:e}),e})):(UO.emit(BO.API_SUCCESS_RATE,{room:this._room,apiName:d,cost:gO()-n}),t)}catch(h){throw h=iM.convertFrom.call(this,h,d),c.error("".concat(d,"() failed ").concat(h," params: ").concat(JSON.stringify(o,a))),UO.emit(BO.API_SUCCESS_RATE,{room:this._room,apiName:d,error:h}),h}}))}var wM=e=>nL(((t,i)=>function(n,r){return cb(this,null,(function*(){let o=this._plugins.get(n);if(o)return NM.call(this,o.getValidateRule(e),[r],i,"TRTC"),t.call(this,o,r);this._log.warn("plugin ".concat(n," is not found"))}))})),PM=0,LM=class{constructor(e){this.core=e,sb(this,"log"),PM+=1,this.log=e.log.createChild({id:"".concat(this.getAlias()).concat(PM)}),this.log.info("[audioMixer] created id=".concat(this.getAlias()).concat(PM)),this.core=e}getName(){return"AudioMixer"}getAlias(){return"ax"}getGroup(e){return null==e?void 0:e.id}getValidateRule(e){switch(e){case"start":return LM.startValidateRule;case"update":return LM.updateValidateRule;case"stop":return LM.stopValidateRule}}start(e){return cb(this,null,(function*(){let{room:t}=this.core;yield t.audioManager.addMusicSource(e)}))}update(e){return cb(this,null,(function*(){let{room:t}=this.core;yield t.audioManager.updateMusicSource(e)}))}stop(e){return cb(this,null,(function*(){let{room:t}=this.core;yield t.audioManager.removeMusicSource(e)}))}},MM=LM;sb(MM,"startValidateRule",{name:"options",required:!0,type:"object",properties:{id:{type:"string",required:!0},url:{type:"string",required:!0},loop:{type:"boolean"},volume:{type:"number"}},validate(e,t,i){if("*"!==e.url){let t=["mp3","ogg","wav","flac"],n=e.url.split(".").pop(),r=t.indexOf(n)>=0,o=e.url.startsWith("blob"),s=e.url.startsWith("data");if(!(r||o||s))throw new iM({code:XL.INVALID_PARAMETER,message:"start audioMixer plugin: music url is invalid, please check your file format.",fnName:i})}}}),sb(MM,"updateValidateRule",{name:"options",required:!0,type:"object",properties:{id:{type:"string",required:!0},loop:{type:"boolean"},volume:{type:"number"},seekFrom:{type:"number"},operation:{type:"string",values:["pause","resume","stop"]}}}),sb(MM,"stopValidateRule",{name:"options",type:"object",required:!0,properties:{id:{type:"string",required:!0}}});var xM=0,VM=class{constructor(e){this.core=e,sb(this,"log"),xM+=1,this.log=e.log.createChild({id:"".concat(this.getAlias()).concat(xM)}),this.log.info("[audioDenoiser] created id=".concat(this.getAlias()).concat(xM))}getName(){return"AIDenoiser"}getAlias(){return"ad"}getGroup(e){return"AIDenoiser_".concat(Date.now())}getValidateRule(e){switch(e){case"start":return VM.startValidateRule;case"update":return VM.updateValidateRule;case"stop":return VM.stopValidateRule}}start(e){return cb(this,null,(function*(){let{room:t}=this.core,{assetsPath:i,sdkAppId:n,userId:r,userSig:o}=e;if(i&&!t.audioManager.isDenoiserInit)try{yield t.audioManager.initDenoiser({assetsPath:i,sdkAppId:n,userId:r,userSig:o})}catch(JV){if(JV.message)throw new Tb({code:fb.INVALID_PARAMETER,message:JV.message})}yield t.audioManager.enableDenoiser(e),t.sendAbilityStatus({ai_denoise:1})}))}update(e){return cb(this,null,(function*(){}))}stop(e){return cb(this,null,(function*(){let{room:e}=this.core;yield e.audioManager.disableDenoiser()}))}},UM=VM;sb(UM,"startValidateRule",{name:"options",required:!0,type:"object",properties:{assetsPath:{type:"string",required:!0},sdkAppId:{type:"number",required:!0},userId:{type:"string",required:!0},userSig:{type:"string",required:!0}}}),sb(UM,"updateValidateRule",{type:"object"}),sb(UM,"stopValidateRule",{type:"object"});var FM=0,BM=new Set,HM=null;sN("5.2.1");var jM=class extends mb.EventEmitter{constructor(e,t){super(),sb(this,"_room"),sb(this,"_eventListened",new Set),sb(this,"_localVideoTrack",null),sb(this,"_localAudioTrack",null),sb(this,"_localScreenTrack",null),sb(this,"_localScreenAudioTrack",null),sb(this,"_localVideoConfig",null),sb(this,"_localScreenConfig",null),sb(this,"_localAudioConfig",null),sb(this,"_remoteVideoConfigMap",new Map),sb(this,"_remoteAudioConfigMap",new Map),sb(this,"_remoteAudioMuteMap",new Map),sb(this,"_log",jO.createLogger({id:"t".concat(++FM)})),sb(this,"_plugins",new Map),sb(this,"_networkQuality",null),this._room=new e(eb({logger:this._log,frameWorkType:jM.frameWorkType},t)),t.plugins&&t.plugins.forEach((e=>{let t=new e(RM(this._room));this._plugins.set(t.getName(),t)}));let i=new MM(RM(this._room));this._plugins.set(i.getName(),i);let n=new UM(RM(this._room));this._plugins.set(n.getName(),n),this._room.on("audio-volume",(e=>{!e.find((e=>""===e.userId))&&this._localAudioTrack&&e.push({userId:"",volume:Math.floor(100*this._localAudioTrack.getAudioLevel())}),this.emit(vM.AUDIO_VOLUME,{result:e.sort(((e,t)=>t.volume-e.volume))})})),this._room.videoManager.on("error",(e=>{let{reason:t,error:i}=e;this._log.error(new iM({code:XL.OPERATION_FAILED,extraCode:5504,messageParams:{reason:t,error:i}}))})),this.on(vM.REMOTE_AUDIO_UNAVAILABLE,(e=>{let{userId:t}=e;this._stopRemoteAudio({userId:t},!1).catch((()=>{}))})),this.on(vM.REMOTE_VIDEO_UNAVAILABLE,(e=>{let{userId:t,streamType:i}=e;this._stopRemoteVideo({userId:t,streamType:i},!1).catch((()=>{}))})),IP(GP,GP).add("audioInputAdded",(e=>{this.emit(vM.DEVICE_CHANGED,{type:"microphone",action:"add",device:e})})).add("audioInputRemoved",(e=>{this.emit(vM.DEVICE_CHANGED,{type:"microphone",action:"remove",device:e})})).add("videoInputAdded",(e=>{this.emit(vM.DEVICE_CHANGED,{type:"camera",action:"add",device:e})})).add("videoInputRemoved",(e=>{this.emit(vM.DEVICE_CHANGED,{type:"camera",action:"remove",device:e})})).add("audioOutputAdded",(e=>cb(this,null,(function*(){if(this.emit(vM.DEVICE_CHANGED,{type:"speaker",action:"add",device:e}),HM&&HM.deviceId===bD){let e=(yield KP()).find((e=>e.deviceId===bD));e&&HM.groupId!==e.groupId&&(HM=e,this.emit(vM.DEVICE_CHANGED,{type:"speaker",action:"active",device:e}))}})))).add("audioOutputRemoved",(e=>cb(this,null,(function*(){this.emit(vM.DEVICE_CHANGED,{type:"speaker",action:"remove",device:e});let t=(yield KP())[0];t&&HM&&(HM.deviceId===e.deviceId||HM.deviceId===bD&&HM.groupId!==t.groupId)&&(HM=t,this.emit(vM.DEVICE_CHANGED,{type:"speaker",action:"active",device:t}))})))),((e,t)=>{let{emit:n}=e;e.emit=function(){for(var r=arguments.length,o=new Array(r),s=0;s<r;s++)o[s]=arguments[s];try{return n.apply(e,o)}catch(i){let n=QO({key:zO.CATCH_HANDLER_ERROR,data:{name:t,event:o[0]},addDocLink:!1});return jO.warn("".concat(n,"\n\n").concat(i.stack)),!1}}})(this,"trtc")}static create(e){}static _create(e,t){!function(){var e;YL&&(YL=!1,5!==jO.getLogLevel()&&(console.info("******************************************************************************"),console.info("* TRTC Web SDK"),console.info("* API Document: ".concat(EN,"/en/index.html")),console.info("* Changelog: ".concat(EN,"/en/tutorial-01-info-changelog.html")),console.info("* Report issues: https://github.com/LiteAVSDK/TRTC_Web/issues"),console.info("******************************************************************************")),jO.info("TRTC Web SDK Version:",oN),jO.info("UA:",navigator.userAgent),jO.info("URL: ".concat(location.href).concat("IFRAME"===(null==(e=self.frameElement)?void 0:e.tagName)?" in iframe":"")),Zk().then((e=>{if(e){let t="UAData: ".concat(e.platform,"/").concat(e.platformVersion);e.architecture&&e.bitness&&(t+=" ".concat(e.architecture,"/").concat(e.bitness)),e.mobile&&(t+=" mobile"),e.model&&(t+=" model: ".concat(e.model)),e.fullVersionList&&(t+=" ".concat(e.fullVersionList.filter((e=>"Not/A)Brand"!==e.brand)).map((e=>"".concat(e.brand,"/").concat(e.version))).join(","))),jO.info(t)}})))}();let i=new jM(e,t||{});return BM.add(i),HM?i.emit(vM.DEVICE_CHANGED,{type:"speaker",action:"active",device:HM}):KP().then((e=>{e[0]&&(HM=e[0],i.emit(vM.DEVICE_CHANGED,{type:"speaker",action:"active",device:e[0]}))})),i}enterRoom(e){return cb(this,null,(function*(){var t,i;let{scene:n="rtc",enableAutoPlayDialog:r=!0,autoReceiveAudio:o=!0,autoReceiveVideo:s=!0}=e;e.proxy&&(this._room.setProxyServer(e.proxy),!oO(e.proxy)&&e.proxy.turnServer&&(null==(i=(t=this._room).setTurnServer)||i.call(t,e.proxy.turnServer,e.proxy.iceTransportPolicy))),this._room.enableAutoPlayDialog=r,this._room.autoReceiveAudio=o,this._room.autoReceiveVideo=s,aO(e.enableHWEncoder)&&(this._room.enableHWEncoder=e.enableHWEncoder);let a={sdkAppId:e.sdkAppId,userId:e.userId,userSig:e.userSig,privateMapKey:e.privateMapKey||null,role:"audience"===e.role?21:20,roomId:e.roomId||0,strRoomId:e.strRoomId||"",businessInfo:e.businessInfo||null,streamId:null,userDefineRecordId:e.userDefineRecordId||null,frameWorkType:e.frameWorkType,component:e.component,language:e.language};e.strRoomId&&!e.roomId&&(this._room.useStringRoomId=!0),IP(this,this._room).add("peer-join",(e=>{let{userId:t}=e;this.emit(vM.REMOTE_USER_ENTER,{userId:t})})).add("peer-leave",(e=>{this.emit(vM.REMOTE_USER_EXIT,{userId:e})})).add("banned",(e=>{this._exitRoom().then((()=>{this.emit(vM.KICKED_OUT,{reason:e.reason})}))})).add("error",(e=>{this._exitRoom().then((()=>{this.emit(vM.ERROR,iM.convertFrom(e))}))})).add("signal-connection-state-changed",(e=>{this.emit(vM.CONNECTION_STATE_CHANGED,e)})).add("network-quality",(e=>{this._networkQuality=e,this.emit(vM.NETWORK_QUALITY,e)})).add("remote-published",(e=>{[e.remoteAudioTrack,e.remoteVideoTrack,e.remoteAuxiliaryTrack].forEach((t=>{IP(t,t).add("player-state-changed",(i=>{let n=tb(eb({},i),{userId:e.userId});t.kind===MN.VIDEO&&(n.streamType=function(e){return"sub"===e?"auxiliary":"auxiliary"===e?"sub":"main"}(t.streamType)),this.emit(t.kind===MN.AUDIO?vM.AUDIO_PLAY_STATE_CHANGED:vM.VIDEO_PLAY_STATE_CHANGED,n)})).add("error",(e=>{e.getCode()===fb.PLAY_NOT_ALLOWED&&this.emit(vM.AUTOPLAY_FAILED,{userId:t.userId})}))}))})).add("remote-unpublished",(e=>{[e.remoteAudioTrack,e.remoteVideoTrack,e.remoteAuxiliaryTrack].forEach((e=>{yP(e)}))})).add("remote-publish-state-changed",(e=>{let{prevMuteState:t,muteState:i}=e,{userId:n}=i;this._room.remotePublishedUserMap.get(n);let r=t.audioAvailable,o=t.videoAvailable,{audioAvailable:s,videoAvailable:a}=i;s||this._remoteAudioConfigMap.delete(n),a||this._remoteVideoConfigMap.delete("".concat(n,"_","main")),i.hasAuxiliary||this._remoteVideoConfigMap.delete("".concat(n,"_","sub")),r!==s&&this.emit(s?vM.REMOTE_AUDIO_AVAILABLE:vM.REMOTE_AUDIO_UNAVAILABLE,{userId:n}),o!==a&&this.emit(a?vM.REMOTE_VIDEO_AVAILABLE:vM.REMOTE_VIDEO_UNAVAILABLE,{userId:n,streamType:"main"}),t.hasAuxiliary!==i.hasAuxiliary&&this.emit(i.hasAuxiliary?vM.REMOTE_VIDEO_AVAILABLE:vM.REMOTE_VIDEO_UNAVAILABLE,{userId:n,streamType:"sub"})})).add("firewall-restriction",(()=>{this.emit(vM.ERROR,new iM({code:XL.OPERATION_FAILED,extraCode:5501}))})).add("sei-message",(e=>{this.emit(vM.SEI_MESSAGE,e)})).add("heartbeat-report",(e=>{var t,i,n,r,o,s,a;let c={2:"big",3:"small",7:"sub"},l={rtt:e.msg_up_stream_info.msg_network_status.uint32_rtt||(null==(t=e.msg_down_stream_info[0])?void 0:t.msg_network_status.uint32_rtt)||(null==(i=this._networkQuality)?void 0:i.uplinkRTT)||(null==(n=this._networkQuality)?void 0:n.downlinkRTT)||0,upLoss:(null==(r=this._networkQuality)?void 0:r.uplinkLoss)||0,downLoss:(null==(o=this._networkQuality)?void 0:o.downlinkLoss)||0,bytesSent:e.bytes_sent||0,bytesReceived:e.bytes_received||0,localStatistics:{audio:{bitrate:((null==(s=e.msg_up_stream_info.msg_audio_status)?void 0:s.uint32_audio_codec_bitrate)||0)/1e3,audioLevel:((null==(a=e.msg_up_stream_info.msg_audio_status)?void 0:a.uint32_audio_level)||0)/UD},video:e.msg_up_stream_info.msg_video_status.filter((e=>c[e.uint32_video_stream_type])).map((e=>({bitrate:(e.uint32_video_codec_bitrate||0)/1e3,width:e.uint32_video_width,height:e.uint32_video_height,frameRate:e.uint32_video_enc_fps,videoType:c[e.uint32_video_stream_type]})))},remoteStatistics:e.msg_down_stream_info.map((e=>({userId:e.msg_user_info.str_identifier,audio:{bitrate:(e.msg_audio_status.uint32_audio_codec_bitrate||0)/1e3,audioLevel:(e.msg_audio_status.uint32_audio_level||0)/UD},video:e.msg_video_status.map((e=>({bitrate:(e.uint32_video_codec_bitrate||0)/1e3,width:e.uint32_video_width,height:e.uint32_video_height,frameRate:e.uint32_video_dec_fps,videoType:c[e.uint32_video_stream_type]})))})))};this.emit(vM.STATISTICS,l)})),this._handleReceiveMode(),yield this._room.join(a,n,jM.frameWorkType),this._checkTrackToPublish()}))}exitRoom(){return cb(this,null,(function*(){return yield this._exitRoom()}))}switchRole(e){return cb(this,null,(function*(){yield this._room.switchRole(e),"anchor"===e&&this._checkTrackToPublish()}))}destroy(){yP(GP),this.removeAllListeners(),this._room.destroy(),BM.delete(this),this._localAudioTrack&&this.stopLocalAudio(),this._localVideoTrack&&this.stopLocalVideo(),this._localScreenTrack&&this.stopScreenShare()}startLocalAudio(){return cb(this,arguments,(function(){var e=this;let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{publish:!0};return function*(){if(e._localAudioTrack)return void e._log.warn("local audio is already started");let{publish:i=!0,option:n}=t,r=new sL(e._room.audioManager),o={},s={muted:!0};n&&(rO(n.microphoneId)?rO(n.audioTrack)||(o.customSource=n.audioTrack):o.deviceId=n.microphoneId,n&&sO(n.captureVolume)&&r.setCaptureVolume(n.captureVolume),rO(n.profile)||(oO(n.profile)?wN[n.profile]&&r.setProfile(wN[n.profile]):r.setProfile(n.profile)),sO(n.earMonitorVolume)&&(s.muted=!(n.earMonitorVolume>0),s.volume=n.earMonitorVolume),rO(n.echoCancellation)||(r.profile.echoCancellation=n.echoCancellation),rO(n.noiseSuppression)||(r.profile.noiseSuppression=n.noiseSuppression),rO(n.autoGainControl)||(r.profile.autoGainControl=n.autoGainControl)),r.on("5",(t=>{e.emit(vM.ERROR,new iM({code:XL.DEVICE_ERROR,extraCode:5309,messageParams:{error:t}}))})),r.on("2",(t=>{e.emit(vM.DEVICE_CHANGED,{type:"microphone",action:"active",device:t})})),r.on("4",(t=>{let i;t.error&&(i=iM.convertFrom(t.error)),e.emit(vM.PUBLISH_STATE_CHANGED,tb(eb({},t),{error:i}))})),yield r.capture(o),IP(r,r).add("player-state-changed",(t=>{e.emit(vM.AUDIO_PLAY_STATE_CHANGED,tb(eb({},t),{userId:""}))})),i&&e._room.isJoined&&e._room.publish(r).catch((()=>{})),yield e._updateAudioPlayOption({playOption:s,track:r}),e._localAudioTrack=r,e._localAudioConfig=tb(eb({},t),{publish:i})}()}))}updateLocalAudio(e){return cb(this,null,(function*(){if(!this._localAudioTrack||!this._localAudioConfig)return;let{publish:t,mute:i,option:n}=e,r={};n&&(n.microphoneId?yield this._localAudioTrack.switchDevice(n.microphoneId):rO(n.audioTrack)||(yield this._localAudioTrack.setInputMediaStreamTrack(n.audioTrack)),rO(n.captureVolume)||this._localAudioTrack.setCaptureVolume(n.captureVolume),rO(n.earMonitorVolume)||(r.muted=!(n.earMonitorVolume>0),r.volume=n.earMonitorVolume),yield this._localAudioTrack.update3A(n)),this._room.isJoined&&!rO(t)&&(t&&!this._localAudioConfig.publish&&this._room.publish(this._localAudioTrack).catch((()=>{})),this._localAudioConfig.publish&&!t&&this._room.unpublish(this._localAudioTrack).catch((()=>{}))),rO(i)||this._localAudioTrack.setMute(i),yield this._updateAudioPlayOption({playOption:r,track:this._localAudioTrack,prevConfig:this._localAudioConfig}),bO(this._localAudioConfig,e)}))}stopLocalAudio(){return cb(this,null,(function*(){!this._localAudioTrack||(this._room.isJoined&&(yield this._room.unpublish(this._localAudioTrack).catch((()=>{}))),this._localAudioTrack.stop(),this._localAudioTrack.close(),yP(this._localAudioTrack),this._localAudioTrack=null,this._localAudioConfig=null)}))}startLocalVideo(){return cb(this,arguments,(function(){var e=this;let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{publish:!0,view:null};return function*(){if(e._localVideoTrack)return void e._log.warn("local video is already started");let{view:i,publish:n=!0,option:r}=t,o=new aL(e._room.videoManager),s={},a={};if(r&&(r.cameraId?s.deviceId=r.cameraId:rO(r.useFrontCamera)?rO(r.videoTrack)||(s.customSource=r.videoTrack):s.facingMode=r.useFrontCamera?MN.FACING_MODE_USER:MN.FACING_MODE_ENVIRONMENT,rO(r.profile)||(oO(r.profile)?PN[r.profile]&&o.setProfile(PN[r.profile]):o.setProfile(r.profile)),rO(r.fillMode)||(a.objectFit=r.fillMode),rO(r.mirror)||(a.mirror=r.mirror),rO(r.small)||(gw()?oO(r.small)?o.small=PN[r.small]:o.small=r.small:e._log.warn("small stream is not supported"))),o.on("5",(t=>{e.emit(vM.ERROR,new iM({code:XL.DEVICE_ERROR,extraCode:5308,messageParams:{error:t}}))})),o.on("2",(t=>{e.emit(vM.DEVICE_CHANGED,{type:"camera",action:"active",device:t})})),o.on("4",(t=>{let i;t.error&&(i=iM.convertFrom(t.error)),e.emit(vM.PUBLISH_STATE_CHANGED,tb(eb({},t),{error:i}))})),yield o.capture(s),(null==r?void 0:r.qosPreference)&&o.mediaTrack){let e=AM(r.qosPreference);o.mediaTrack.contentHint=e}IP(o,o).add("player-state-changed",(t=>{e.emit(vM.VIDEO_PLAY_STATE_CHANGED,tb(eb({},t),{userId:"",streamType:"main"}))})),n&&e._room.isJoined&&e._room.publish(o).catch((()=>{})),yield e._updateVideoPlayOption({view:i,playOption:a,track:o}),e._localVideoTrack=o,e._localVideoConfig=tb(eb({},t),{view:i,publish:n})}()}))}updateLocalVideo(e){return cb(this,null,(function*(){if(!this._localVideoTrack||!this._localVideoConfig)return;let{view:t,publish:i,mute:n,option:r}=e,o={};if(r&&(rO(r.profile)||(oO(r.profile)?PN[r.profile]&&this._localVideoTrack.setProfile(PN[r.profile]):this._localVideoTrack.setProfile(r.profile),(!r.cameraId||!this._localVideoTrack.isNeedToSwitchDevice(r.cameraId))&&rO(r.useFrontCamera)&&this._localVideoTrack.applyProfile()),r.cameraId?yield this._localVideoTrack.switchDevice(r.cameraId):rO(r.useFrontCamera)?rO(r.videoTrack)||(yield this._localVideoTrack.setInputMediaStreamTrack(r.videoTrack)):yield this._localVideoTrack.switchDevice(r.useFrontCamera?MN.FACING_MODE_USER:MN.FACING_MODE_ENVIRONMENT),rO(r.fillMode)||(o.objectFit=r.fillMode),rO(r.mirror)||(o.mirror=r.mirror),r.qosPreference&&this._localVideoTrack.mediaTrack)){let e=AM(r.qosPreference);this._localVideoTrack.mediaTrack.contentHint=e}this._room.isJoined&&!rO(i)&&(i&&!this._localVideoConfig.publish&&this._room.publish(this._localVideoTrack).catch((()=>{})),this._localVideoConfig.publish&&!i&&this._room.unpublish(this._localVideoTrack).catch((()=>{}))),rO(n)||this._localVideoTrack.setMute(n),yield this._updateVideoPlayOption({view:t,playOption:o,track:this._localVideoTrack,prevConfig:this._localVideoConfig}),bO(this._localVideoConfig,e)}))}stopLocalVideo(){return cb(this,null,(function*(){!this._localVideoTrack||(this._room.isJoined&&(yield this._room.unpublish(this._localVideoTrack).catch((()=>{}))),this._localVideoTrack.stop(),this._localVideoTrack.close(),yP(this._localVideoTrack),this._localVideoTrack=null,this._localVideoConfig=null)}))}startScreenShare(){return cb(this,arguments,(function(){var e=this;let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{publish:!0,view:null};return function*(){if(e._localScreenTrack)return void e._log.warn("screen share is already started");let{view:i=null,publish:n=!0,option:r}=t,o=new lL(e._room.videoManager);o.on("4",(t=>{let i;t.error&&(i=iM.convertFrom(t.error)),e.emit(vM.PUBLISH_STATE_CHANGED,tb(eb({},t),{error:i}))}));let s=null;o.setMediaType(2);let a={},c={};r&&(rO(r.profile)||(oO(r.profile)?LN[r.profile]&&o.setProfile(LN[r.profile]):o.setProfile(r.profile)),r.systemAudio&&(a.systemAudio=!0,a.echoCancellation=r.echoCancellation,a.noiseSuppression=r.noiseSuppression,a.autoGainControl=r.autoGainControl),rO(r.fillMode)||(c.objectFit=r.fillMode),r.videoTrack&&(a.videoTrack=r.videoTrack),r.audioTrack&&(a.audioTrack=r.audioTrack));let l=yield o.capture(a);if(null!=r&&r.qosPreference){let e=AM(r.qosPreference);o.mediaTrack.contentHint=e}if(o.mediaTrack.addEventListener(MN.ENDED,(()=>{e._stopScreenShare(),e.emit(vM.SCREEN_SHARE_STOPPED)})),l.getAudioTracks()[0]&&(s=new dL(e._room.audioManager),s.setInputMediaStreamTrack(l.getAudioTracks()[0])),IP(o,o).add("player-state-changed",(t=>{e.emit(vM.VIDEO_PLAY_STATE_CHANGED,tb(eb({},t),{userId:"",streamType:"sub"}))})),n&&e._room.isJoined){let t=[o];s&&t.push(s),e._room.publish(...t).catch((()=>{}))}yield e._updateVideoPlayOption({view:i,playOption:c,track:o}),e._localScreenTrack=o,e._localScreenAudioTrack=s,e._localScreenConfig=tb(eb({},t),{view:i,publish:n})}()}))}updateScreenShare(e){return cb(this,null,(function*(){if(!this._localScreenTrack||!this._localScreenConfig)return;let{view:t,publish:i,option:n}=e,r={};if(n&&(rO(n.fillMode)||(r.objectFit=n.fillMode),n.qosPreference)){let e=AM(n.qosPreference);this._localScreenTrack.mediaTrack.contentHint=e}this._room.isJoined&&!rO(i)&&(i&&!this._localScreenConfig.publish&&this._room.publish(this._localScreenTrack).catch((()=>{})),this._localScreenConfig.publish&&!i&&this._room.unpublish(this._localScreenTrack).catch((()=>{}))),yield this._updateVideoPlayOption({view:t,playOption:r,track:this._localScreenTrack,prevConfig:this._localScreenConfig}),bO(this._localScreenConfig,e)}))}stopScreenShare(){return cb(this,null,(function*(){return yield this._stopScreenShare()}))}startRemoteVideo(e){return cb(this,null,(function*(){let{view:t,userId:i,streamType:n,option:r}=e,o="".concat(i,"_").concat(n);if(this._remoteVideoConfigMap.has(o))return void this._log.warn("remote video has already started. userId:".concat(i,", streamType:").concat(n));let s=this._room.remotePublishedUserMap.get(i);if(!s)return;let a={},c="main"===n?s.remoteVideoTrack:s.remoteAuxiliaryTrack;r&&(rO(r.fillMode)||(a.objectFit=r.fillMode),rO(r.mirror)||(a.mirror=r.mirror),"main"===n&&!rO(r.small)&&this._room.changeType(r.small,c.user)),yield this._room.subscribe(c),yield this._updateVideoPlayOption({view:t,playOption:a,track:c}),this._remoteVideoConfigMap.set(o,e)}))}updateRemoteVideo(e){return cb(this,null,(function*(){let{view:t,userId:i,streamType:n,option:r}=e,o="".concat(i,"_").concat(n);if(!this._remoteVideoConfigMap.has(o)||!this._room.remotePublishedUserMap.has(i))return;let s={};r&&(rO(r.fillMode)||(s.objectFit=r.fillMode),rO(r.mirror)||(s.mirror=r.mirror));let a=null,c=this._room.remotePublishedUserMap.get(i);"main"===n&&(null==c?void 0:c.muteState.hasVideo)&&(a=c.remoteVideoTrack),"sub"===n&&(null==c?void 0:c.muteState.hasAuxiliary)&&(a=c.remoteAuxiliaryTrack);let l=this._remoteVideoConfigMap.get(o);a&&("main"===n&&r&&!rO(r.small)&&this._room.changeType(r.small,a.user),yield this._updateVideoPlayOption({view:t,playOption:s,track:a,prevConfig:l})),bO(l,e)}))}stopRemoteVideo(e){return cb(this,null,(function*(){return this._stopRemoteVideo(e)}))}_stopRemoteVideo(e){let t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];return cb(this,null,(function*(){let i=[],n=this._room.remotePublishedUserMap.get(e.userId);if(n){let{muteState:t,remoteVideoTrack:r,remoteAuxiliaryTrack:o}=n;"main"===e.streamType&&(r.stop(),t.hasVideo&&i.push(r)),"sub"===e.streamType&&(o.stop(),t.hasAuxiliary&&i.push(o))}for(let e of i)t&&(yield this._room.unsubscribe(e));this._remoteVideoConfigMap.delete("".concat(e.userId,"_").concat(e.streamType))}))}muteRemoteAudio(e,t){return cb(this,null,(function*(){if("*"===e)if(t)yield this._stopRemoteAudio({userId:e});else{let e=[...this._room.remotePublishedUserMap.values()];for(let t of e)t.muteState.hasAudio&&(yield this._startRemoteAudio({userId:t.userId}))}else t?yield this._stopRemoteAudio({userId:e}):yield this._startRemoteAudio({userId:e});this._remoteAudioMuteMap.set(e,t)}))}setRemoteAudioVolume(e,t){if("*"===e){let e=[...this._room.remotePublishedUserMap.values()];for(let i of e)this._updateAudioPlayOption({playOption:{volume:t},track:i.remoteAudioTrack})}else if(e){let i=this._room.remotePublishedUserMap.get(e);i&&this._updateAudioPlayOption({playOption:{volume:t},track:i.remoteAudioTrack})}}startPlugin(e,t){return cb(this,null,(function*(){return e.start(t)}))}updatePlugin(e,t){return cb(this,null,(function*(){return e.update(t)}))}stopPlugin(e,t){return cb(this,null,(function*(){return e.stop(t)}))}enableAudioVolumeEvaluation(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:2e3,t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];this._room.enableAudioVolumeEvaluation(e,t)}on(e,t,i){return super.on(e,t,i),this._eventListened.add(e),this}off(e,t,i){return"*"===e?(this._eventListened.clear(),this.removeAllListeners()):super.off(e,t,i),this}getVideoTrack(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{userId:"",streamType:"main"},{userId:t="",streamType:i="main"}=e;if(""===t){if("main"===i&&this._localVideoTrack)return this._localVideoTrack.mediaTrack;if("sub"===i&&this._localScreenTrack)return this._localScreenTrack.mediaTrack}else{let e=this._room.remotePublishedUserMap.get(t);if(e)return"main"===i?e.remoteVideoTrack.mediaTrack:e.remoteAuxiliaryTrack.mediaTrack}return null}getAudioTrack(e){if(e){let t=this._room.remotePublishedUserMap.get(e);if(t)return t.remoteAudioTrack.mediaTrack}else if(this._localAudioTrack)return this._localAudioTrack.mediaTrack;return null}setCurrentSpeaker(e){var t;null==(t=this._localAudioTrack)||t.setAudioOutput(e),this._room.remotePublishedUserMap.forEach((t=>t.remoteAudioTrack.setAudioOutput(e)))}_startRemoteAudio(e){return cb(this,null,(function*(){let{userId:t,option:i}=e;if(this._remoteAudioConfigMap.has(t))return void this._log.warn("remote audio has already started. userId:".concat(t));let n=this._room.remotePublishedUserMap.get(t);if(!n)return;let r={};i&&(rO(i.volume)||(r.volume=i.volume));let o=n.remoteAudioTrack;yield this._room.subscribe(o),yield this._updateAudioPlayOption({playOption:r,track:o}),this._remoteAudioConfigMap.set(t,e)}))}_stopRemoteAudio(e){let t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];return cb(this,null,(function*(){let i=this._room.remotePublishedUserMap.get(e.userId);i&&(i.remoteAudioTrack.stop(),i.muteState.hasAudio&&t&&(yield this._room.unsubscribe(i.remoteAudioTrack))),this._remoteAudioConfigMap.delete("".concat(e.userId))}))}_updateVideoPlayOption(e){return cb(this,arguments,(function(e){let{view:t,playOption:i,track:n,prevConfig:r}=e;return function*(){if(rO(t)&&r&&r.view&&!IO(i)){let e;e=lO(r.view)?r.view:kO(r.view),e&&(yield n.play(e,i))}if(!rO(t)){let e;e=lO(t)?t:kO(t),e?yield n.play(e,i):n.stop()}}()}))}_updateAudioPlayOption(e){return cb(this,arguments,(function(e){let{playOption:t={},track:i,prevConfig:n}=e;return function*(){if(!i.isPlayCalled)try{yield i.play(null,t)}catch(lN){}rO(t.muted)||i.setPlayerMute(t.muted),rO(t.volume)||i.setAudioVolume(t.volume/100)}()}))}_checkTrackToPublish(){var e,t,i;let n=[];if((null==(e=this._localAudioConfig)?void 0:e.publish)&&this._localAudioTrack&&n.push(this._localAudioTrack),(null==(t=this._localVideoConfig)?void 0:t.publish)&&this._localVideoTrack&&n.push(this._localVideoTrack),null!=(i=this._localScreenConfig)&&i.publish&&(this._localScreenTrack&&n.push(this._localScreenTrack),this._localScreenAudioTrack&&n.push(this._localScreenAudioTrack)),0!==n.length)return this._room.publish(...n).catch((()=>{}))}_handleReceiveMode(){this._room.autoReceiveAudio&&IP(this,this).add(vM.REMOTE_AUDIO_AVAILABLE,(e=>cb(this,[e],(function(e){var t=this;let{userId:i}=e;return function*(){if(t._remoteAudioMuteMap.get("*")||t._remoteAudioMuteMap.get(i))return;let e=t._room.remotePublishedUserMap.get(i);e&&(yield t._room.subscribe(e.remoteAudioTrack).catch((()=>{})),yield t._updateAudioPlayOption({track:e.remoteAudioTrack}).catch((()=>{})),t._remoteAudioConfigMap.set(i,{userId:i}))}()})))),this._room.autoReceiveVideo&&IP(this,this).add(vM.REMOTE_VIDEO_AVAILABLE,(e=>{let{userId:t,streamType:i}=e,n=this._room.remotePublishedUserMap.get(t);n&&("main"===i?this._room.subscribe(n.remoteVideoTrack).catch((()=>{})):"sub"===i&&this._room.subscribe(n.remoteAuxiliaryTrack).catch((()=>{})))}))}_exitRoom(){return cb(this,null,(function*(){this._room.isJoined&&(yield this._room.leave()),[...this._remoteAudioConfigMap.keys()].forEach((e=>{this._stopRemoteAudio({userId:e}).catch()})),[...this._remoteVideoConfigMap.keys()].forEach((e=>{let t=e.includes("main")?"main":"sub",i=e.split("_".concat(t))[0];i&&this._stopRemoteVideo({userId:i,streamType:t}).catch()})),this._remoteVideoConfigMap.clear(),this._remoteAudioConfigMap.clear(),this._remoteAudioMuteMap.clear(),this._room.remotePublishedUserMap.forEach((e=>{yP(e.remoteAudioTrack),yP(e.remoteVideoTrack),yP(e.remoteAuxiliaryTrack)})),yP(this)}))}_stopScreenShare(){return cb(this,null,(function*(){var e,t,i;if(this._localScreenTrack){if(this._room.isJoined){let t=[this._localScreenTrack];this._localScreenAudioTrack&&t.push(this._localScreenAudioTrack),yield null==(e=this._room)?void 0:e.unpublish(...t).catch((()=>{}))}this._localScreenTrack.stop(),this._localScreenTrack.close(),null==(t=this._localScreenAudioTrack)||t.stop(),null==(i=this._localScreenAudioTrack)||i.close(),yP(this._localScreenTrack),this._localScreenTrack=null,this._localScreenAudioTrack=null,this._localScreenConfig=null}}))}sendSEIMessage(e,t){this._room.sendSEI(e,t||{seiPayloadType:243})}static setLogLevel(e,t){jO.setLogLevel(e),rO(t)||(t?jO.enableUploadLog():jO.disableUploadLog())}static isSupported(){return cw()}static getCameraList(){return zP()}static getMicrophoneList(){return JP()}static getSpeakerList(){return KP()}static setCurrentSpeaker(e){return cb(this,null,(function*(){(yield KP()).forEach((t=>{t.deviceId===e&&(BM.forEach((i=>{i.setCurrentSpeaker(e),i.emit(vM.DEVICE_CHANGED,{type:"speaker",action:"active",device:t})})),HM=t)}))}))}},GM=jM;sb(GM,"_loggerManager",jO),sb(GM,"EVENT",vM),sb(GM,"ERROR_CODE",XL),sb(GM,"TYPE",QL),sb(GM,"frameWorkType",30),ob([bM(uM.TRTC.enterRoom),SM("room",((e,t)=>{let[i]=e,[n]=t;return(i.roomId||i.strRoomId)===(n.roomId||n.strRoomId)&&i.userId===n.userId&&i.sdkAppId===n.sdkAppId})),nL((e=>function(t){return this._log.setUserId(t.userId),this._log.setSdkAppId(t.sdkAppId),e.call(this,t).catch((e=>{throw yP(this),e}))})),OM()],GM.prototype,"enterRoom",1),ob([OM()],GM.prototype,"exitRoom",1),ob([bM(uM.TRTC.switchRole),IM("room",{merge:(e,t)=>t}),OM()],GM.prototype,"switchRole",1),ob([OM()],GM.prototype,"destroy",1),ob([bM(uM.TRTC.startLocalAudio),SM("audio",((e,t)=>{let[i]=e,[n]=t;var r,o;return(null==(r=null==i?void 0:i.option)?void 0:r.microphoneId)===(null==(o=null==n?void 0:n.option)?void 0:o.microphoneId)})),OM()],GM.prototype,"startLocalAudio",1),ob([bM(uM.TRTC.updateLocalAudio),IM("audio",{debounce:{delay:200,getKey:()=>"".concat(FM,"-localAudio"),isNeedToDebounce:e=>{var t;return!rO(null==(t=e.option)?void 0:t.captureVolume)}}}),OM()],GM.prototype,"updateLocalAudio",1),ob([yM("audio"),OM()],GM.prototype,"stopLocalAudio",1),ob([bM(uM.TRTC.startLocalVideo),SM("video",((e,t)=>{let[i]=e,[n]=t;var r,o;return(null==(r=null==i?void 0:i.option)?void 0:r.cameraId)===(null==(o=null==n?void 0:n.option)?void 0:o.cameraId)})),OM()],GM.prototype,"startLocalVideo",1),ob([bM(uM.TRTC.updateLocalVideo),IM("video"),OM()],GM.prototype,"updateLocalVideo",1),ob([yM("video"),OM()],GM.prototype,"stopLocalVideo",1),ob([bM(uM.TRTC.startScreenShare),SM("screen",(()=>!0)),OM()],GM.prototype,"startScreenShare",1),ob([bM(uM.TRTC.updateScreenShare),IM("screen"),OM()],GM.prototype,"updateScreenShare",1),ob([OM()],GM.prototype,"stopScreenShare",1),ob([bM(uM.TRTC.startRemoteVideo),SM((e=>"v".concat(e.userId).concat(e.streamType)),(()=>!0)),OM({getRemoteId:e=>"".concat(e.userId,"_").concat(e.streamType)})],GM.prototype,"startRemoteVideo",1),ob([bM(uM.TRTC.updateRemoteVideo),IM((e=>"v".concat(e.userId).concat(e.streamType))),OM({getRemoteId:e=>"".concat(e.userId,"_").concat(e.streamType)})],GM.prototype,"updateRemoteVideo",1),ob([bM(uM.TRTC.stopRemoteVideo),nL((e=>function(t){return cb(this,null,(function*(){if("*"===t.userId){let e=[];return this._room.remotePublishedUserMap.forEach((t=>{this._remoteVideoConfigMap.has("".concat(t.userId,"_","main"))&&e.push(this.stopRemoteVideo({streamType:"main",userId:t.userId}).catch((()=>{}))),this._remoteVideoConfigMap.has("".concat(t.userId,"_","sub"))&&e.push(this.stopRemoteVideo({streamType:"sub",userId:t.userId}).catch((()=>{})))})),Promise.all(e)}return e.call(this,t)}))})),OM({getRemoteId:e=>"".concat(e.userId,"_").concat(e.streamType)})],GM.prototype,"stopRemoteVideo",1),ob([yM((e=>"v".concat(e.userId).concat(e.streamType)))],GM.prototype,"_stopRemoteVideo",1),ob([bM(...uM.TRTC.muteRemoteAudio),OM({getRemoteId:e=>e})],GM.prototype,"muteRemoteAudio",1),ob([kM(...uM.TRTC.setRemoteAudioVolume),function(e,t){return nL(((i,n)=>function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];var s,a;let c=null==(s=CM.get(this))?void 0:s.get(t(...r));c&&c>0&&clearTimeout(c);let l=window.setTimeout((()=>{i.apply(this,r)}),e);CM.has(this)?null==(a=CM.get(this))||a.set(t(...r),l):CM.set(this,new Map([[t(...r),l]]))}))}(200,(e=>e)),OM({getRemoteId:e=>e})],GM.prototype,"setRemoteAudioVolume",1),ob([wM("start"),SM(((e,t)=>e.getAlias()+e.getGroup(t))),OM({namePrefix:e=>e.getName()})],GM.prototype,"startPlugin",1),ob([wM("update"),IM(((e,t)=>e.getAlias()+e.getGroup(t))),OM({namePrefix:e=>e.getName()})],GM.prototype,"updatePlugin",1),ob([wM("stop"),yM(((e,t)=>e.getAlias()+e.getGroup(t))),OM({namePrefix:e=>e.getName()})],GM.prototype,"stopPlugin",1),ob([kM(...uM.TRTC.enableAudioVolumeEvaluation)],GM.prototype,"enableAudioVolumeEvaluation",1),ob([SM((e=>"a".concat(e.userId)),(()=>!0))],GM.prototype,"_startRemoteAudio",1),ob([nL((e=>function(t){return cb(this,null,(function*(){return"*"===t.userId?Promise.all([...this._room.remotePublishedUserMap.values()].map((e=>this._stopRemoteAudio(tb(eb({},t),{userId:e.userId})).catch((()=>{}))))):e.call(this,t)}))})),yM((e=>"a".concat(e.userId)))],GM.prototype,"_stopRemoteAudio",1),ob([yM("room")],GM.prototype,"_exitRoom",1),ob([yM("screen")],GM.prototype,"_stopScreenShare",1),ob([bM(uM.TRTC.sendSEIMessage),function(e){let{timesInSecond:t,maxSizeInSecond:i,getSize:n}=e;return nL(((e,r)=>{let o=new Map;return UO.on(BO.ROOM_DESTROY,(e=>{let{room:t}=e;return o.delete(t)})),function(){let s=o.get(this);for(var a=arguments.length,c=new Array(a),l=0;l<a;l++)c[l]=arguments[l];if(s||(s={callCountInSecond:0,timestamp:0,totalSizeInSecond:0},o.set(this,s)),0===s.timestamp?s.timestamp=Date.now():Date.now()-s.timestamp>1e3&&(s.timestamp=Date.now(),s.callCountInSecond=0,s.totalSizeInSecond=0),n&&(s.totalSizeInSecond+=n(...c)),0!==s.timestamp&&Date.now()-s.timestamp<1e3&&(s.callCountInSecond>=t||s.totalSizeInSecond>i))throw new Tb({code:fb.INVALID_OPERATION,message:QO({key:zO.CALL_FREQUENCY_LIMIT,data:{isTimes:s.callCountInSecond>=t,isSize:s.totalSizeInSecond>i,name:r,timesInSecond:t,maxSizeInSecond:i}})});s.callCountInSecond++,e.call(this,...c)}}))}({timesInSecond:30,maxSizeInSecond:8e3,getSize:function(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];return t[0].byteLength}})],GM.prototype,"sendSEIMessage",1),ob([bM(uM.TRTC.create)],GM,"_create",1);var WM=GM,JM=class{constructor(){this._set=new Set,UO.on(BO.LEAVE_SUCCESS,this.delete,this)}add(e){let{room:t,roomId:i}=e;if("rtc"===t.scene)return;let n=this.getKey(t.userId,i||t.roomId,t.sdkAppId,t.useStringRoomId);this._set.add(n)}delete(e){let{room:t,roomId:i}=e;if("rtc"===t.scene)return;let n=this.getKey(t.userId,t.roomId||i,t.sdkAppId,t.useStringRoomId);this._set.delete(n)}getKey(e,t,i,n){return"".concat(i,"_").concat(t,"_").concat(e,"_").concat(n)}isJoined(e){let{userId:t,roomId:i,sdkAppId:n,room:r}=e;return"rtc"!==r.scene&&this._set.has(this.getKey(t,i,n,r.useStringRoomId))}};function zM(){return cb(this,null,(function*(){let e,t;try{let t=yield JP();e=t&&t.length}catch(h){}try{let e=yield zP();t=e&&e.length}catch(h){}let i={microphone:e,camera:t},{isH264EncodeSupported:n,isVp8EncodeSupported:r,isH264DecodeSupported:o,isVp8DecodeSupported:s}=this.checkSystemResult.detail,a=JO.basis(),c={webRTC:a.isWebRTCSupported,getUserMedia:a.isGetUserMediaSupported,webSocket:a.isWebSocketsSupported,screenShare:a.isScreenShareSupported,webAudio:a.isWebAudioSupported,h264Encode:n,h264Decode:o,vp8Encode:r,vp8Decode:s},l={browser:a.browser,os:a.os,trtc:c,devices:i},d={isWebCodecSupported:a.isWebCodecSupported,isMediaSessionSupported:a.isMediaSessionSupported,isWebTransportSupported:a.isWebTransportSupported};Xw.uploadEvent({log:"trtcstats-".concat(JSON.stringify(l)),userId:this.userId}),this._log.info("TrtcStats-".concat(JSON.stringify(l))),Xw.uploadEvent({log:"trtcadvancedstats-".concat(JSON.stringify(d)),userId:this.userId})}))}var KM=rb(lb()),qM="1",YM="5",QM="2",XM="3",$M="4",ZM="DISCONNECTED",ex="CONNECTING",tx="CONNECTED",ix={CLIENT_BANNED:9,CHANNEL_SETUP_RESULT:19,CHANNEL_RECONNECT_RESULT:514,JOIN_ROOM_RESULT:20,PEER_JOIN:4134,PEER_LEAVE:4135,STREAM_ADDED:16,STREAM_REMOVED:18,UPLINK_NETWORK_STATS:22,UPDATE_REMOTE_MUTE_STAT:23,PUBLISH_RESULT:4098,PUBLISH_STATE_CHANGE_RESULT:4112,UNPUBLISH_RESULT:4100,SUBSCRIBE_RESULT:4102,UNSUBSCRIBE_RESULT:4104,SUBSCRIBE_CHANGE_RESULT:4106,MUTE_RESULT:4108,UPDATE_OFFER_RESULT:4128,START_PUBLISH_TENCENT_CDN_RES:1286,STOP_PUBLISH_TENCENT_CDN_RES:1288,START_PUBLISH_GIVEN_CDN_RES:777,STOP_PUBLISH_GIVEN_CDN_RES:779,START_MIX_TRANSCODE_RES:781,STOP_MIX_TRANSCODE_RES:783,USER_LIST_RES:4137,SWITCH_ROLE_RES:4110,UPDATE_CONSTRAINT_CONFIG_RES:772,REBUILD_PEER_CONNECTION_RES:4150,SPC_PUBLISH_RESULT:4146,SPC_SUBSCRIBE_RESULT:4156,ABILITY_STATUS_REPORT_RESULT:4158},nx=[ix.UPDATE_REMOTE_MUTE_STAT,ix.UPLINK_NETWORK_STATS,ix.USER_LIST_RES,ix.MUTE_RESULT],rx={CLIENT_BANNED:"client-banned",CHANNEL_SETUP_RESULT:"channel-setup-result",CHANNEL_RECONNECT_RESULT:"channel-reconnect-result",JOIN_ROOM_RESULT:"join-room-result",PEER_JOIN:"peer-join",PEER_LEAVE:"peer-leave",STREAM_ADDED:"stream-added",STREAM_REMOVED:"stream-removed",UPLINK_NETWORK_STATS:"uplink-network-stats",UPDATE_REMOTE_MUTE_STAT:"update-remote-mute-stat",PUBLISH_RESULT:"publish-result",PUBLISH_STATE_CHANGE_RESULT:"publish-state-change-result",UNPUBLISH_RESULT:"unpublish-result",SUBSCRIBE_RESULT:"subscribe-result",SUBSCRIBE_CHANGE_RESULT:"subscribe-change-result",UNSUBSCRIBE_RESULT:"unsubscribe-result",UPDATE_OFFER_RESULT:"update-offer-result",START_PUBLISH_TENCENT_CDN_RES:"start-publish-tencent-cdn-res",STOP_PUBLISH_TENCENT_CDN_RES:"stop-publish-tencent-cdn-res",START_PUBLISH_GIVEN_CDN_RES:"start-publish-given-cdn-res",STOP_PUBLISH_GIVEN_CDN_RES:"stop-publish-given-cdn-res",START_MIX_TRANSCODE_RES:"start-mix-transcode-res",STOP_MIX_TRANSCODE_RES:"stop-mix-transcode-res",USER_LIST_RES:"user-list-res",SWITCH_ROLE_RES:"switch_role_res",MUTE_RESULT:"mute-result",UPDATE_CONSTRAINT_CONFIG_RES:"update-contraint-config-res",REBUILD_PEER_CONNECTION_RES:"rebuild-pc-res",SPC_PUBLISH_RESULT:"spc-publish-result",SPC_SUBSCRIBE_RESULT:"spc-subscribe-result",ABILITY_STATUS_REPORT_RESULT:"ability-status-report"},ox="publish_change",sx="join",ax="leave",cx="quality_report",lx="mute_uplink",dx="publish",ux="publish_state_change",hx="unpublish",px="subscribe",mx="unsubscribe",_x="subscribe_change",fx="start_publishing",gx="stop_publishing",Tx="start_push_user_cdn",Ex="stop_push_user_cdn",Sx="start_mcu_mix",Ix="stop_mcu_mix",yx="get_user_list",vx="change_role",Ax="update_constraint_config",Rx="rebuild_pc",Cx="join/v2",bx="publish/v2",kx="subscribe/v3",Nx="ability_status_report",Dx=new Set,Ox=class extends KM.default{constructor(e){var t,i;super(),sb(this,"room"),sb(this,"url"),sb(this,"backupUrl"),sb(this,"_socketInUse"),sb(this,"_socket"),sb(this,"_backupSocket"),sb(this,"_backupTimer",-1),sb(this,"_signalInfo",{tinyId:void 0,clientIp:"",signalIp:"",relayIp:"",relayInnerIp:"",relayPort:0}),sb(this,"_currentState",ZM),sb(this,"_reconnectionCount",0),sb(this,"_reconnectionTimer",-1),sb(this,"_seq",0),sb(this,"_log"),sb(this,"_lastMessageTime",-1),sb(this,"_prevTime",-1),sb(this,"bytesSent",0),sb(this,"bytesReceived",0),sb(this,"keepAlive",!1),this.room=e.room,((null==(i=null==(t=this.room.scheduleResult)?void 0:t.config)?void 0:i.keepAliveClient)||0)-Dx.size>0&&this.room.enableSPC&&(this.keepAlive=!0,Dx.add(this)),this.url=e.url,this.backupUrl=e.backupUrl,this._seq=0,this._log=jO.createLogger({id:"ws",userId:this.userId,sdkAppId:this.sdkAppId})}get urlParam(){return"?sdkAppId=".concat(encodeURIComponent(this.sdkAppId),"&userId=").concat(encodeURIComponent(this.userId),"&userSig=").concat(encodeURIComponent(this.userSig),"&keepAlive=").concat(encodeURIComponent(Number(this.keepAlive)))}get _urlWithParam(){return"".concat(this.url).concat(this.urlParam)}get _backupUrlWithParam(){return"".concat(this.backupUrl).concat(this.urlParam)}get isConnected(){return this._currentState===tx}get isConnecting(){return this._currentState===ex}get sdkAppId(){return this.room.sdkAppId}get userId(){return this.room.userId}get userSig(){return this.room.userSig}get isOnline(){return this._currentState===tx&&Date.now()-this._lastMessageTime<12e3}connect(e){return this.isConnected?Promise.resolve():new Promise(((t,i)=>{this._prevTime<0&&(this._prevTime=gO()),this._log.info("connect to ".concat(this.url).concat(e?" timeout: ".concat(e):""," keepAlive: ").concat(Number(this.keepAlive))),this.emitConnectionStateChanged(ex),this._socket=new WebSocket(this._urlWithParam),this.bindSocket(this._socket),this._backupTimer=setTimeout((()=>{this.isConnected||(this._log.info("trying to connect to backupUrl"),this.tryConnectBackup())}),5e3);let n=-1;e&&(n=setTimeout((()=>{this.close(),i(new Tb({code:fb.JOIN_ROOM_FAILED,message:"join room timeout"}))}),e)),this.once(XM,(()=>{clearTimeout(n),t()})),this.once($M,(e=>{clearTimeout(n),i(e)}))}))}tryConnectBackup(){this._backupSocket||(this.unbindAndCloseSocket(MN.MAIN),this._log.debug("try to connect to url: ".concat(this._backupUrlWithParam)),this._backupSocket=new WebSocket(this._backupUrlWithParam),this.bindSocket(this._backupSocket))}bindSocket(e){e.onopen=this.onopen.bind(this),e.onclose=this.onclose.bind(this),e.onerror=this.onerror.bind(this),e.onmessage=this.onmessage.bind(this)}unbindSocket(e){this.clearBackupTimer(),e.onopen=()=>{},e.onclose=()=>{},e.onerror=()=>{},e.onmessage=()=>{}}unbindAndCloseSocket(e){if(e===MN.MAIN){if(this._socket){this.unbindSocket(this._socket);try{this._socket.close(1e3)}catch(aD){}this._socket=null}}else if(this._backupSocket){this.unbindSocket(this._backupSocket);try{this._backupSocket.close(1e3)}catch(aD){}this._backupSocket=null}}clearBackupTimer(){-1!==this._backupTimer&&(clearTimeout(this._backupTimer),this._backupTimer=-1)}clearReconnectionTimer(){-1!==this._reconnectionTimer&&(clearTimeout(this._reconnectionTimer),this._reconnectionTimer=-1)}onopen(e){this.isConnected||(this.isReconnecting&&!this._signalInfo.tinyId&&this.stopReconnection(),this.clearBackupTimer(),e.target===this._socket?(this.unbindAndCloseSocket(MN.BACKUP),this._socketInUse=this._socket):(this.unbindAndCloseSocket(MN.MAIN),this._socketInUse=this._backupSocket),this.emitConnectionStateChanged(tx),this.emit(XM))}onclose(e){let{url:t}=e.target,i=e.target===this._socketInUse;if(this._log.info("websocket[".concat(t," InUse: ").concat(i,"] is closed with code: ").concat(e.code)),i&&(this.emitConnectionStateChanged(ZM),!e.wasClean||1e3!==e.code)){this._log.warn("onclose code:".concat(e.code," reason:").concat(e.reason)),this._log.warn("close current websocket and schedule a reconnect timeout"),this._socketInUse.onclose=()=>{},this._socketInUse.close(4011);let t=this._socketInUse===this._socket;this._socket=null,this._backupSocket=null,this._socketInUse=null,this.reconnect(t?MN.BACKUP:MN.MAIN)}}onerror(e){let{url:t}=e.target;if(this._log.error("websocket[".concat(t,"] error observed")),this.isConnected){if(e.target===this._socketInUse){this.unbindAndCloseSocket(MN.MAIN),this.unbindAndCloseSocket(MN.BACKUP);let e=this._socketInUse===this._socket;this._socketInUse=null,this.reconnect(e?MN.BACKUP:MN.MAIN)}}else this.isReconnecting||UO.emit(BO.API_SUCCESS_RATE,{room:this.room,apiName:"WebsocketConnect",error:new Error("ws onerror")}),e.target==this._socket?(this.unbindAndCloseSocket(MN.MAIN),this.reconnect(MN.BACKUP)):(this.unbindAndCloseSocket(MN.BACKUP),this.reconnect(MN.MAIN))}onmessage(e){if(!this.isConnected)return;this._lastMessageTime=Date.now(),this.bytesReceived+=PO(e.data);let t=JSON.parse(e.data),{cmd:i,data:n}=t,r=Object.values(ix),o=Object.keys(ix)[r.indexOf(i)],s=rx[o];switch(nx.includes(i)||(this._log.debug("received ".concat(i," msg: ").concat(e.data)),s&&this._log.info("Received event: [ ".concat(s," ]"))),i){case ix.CHANNEL_SETUP_RESULT:if(0===t.code)this._signalInfo.clientIp=n.clientIp,this._signalInfo.signalIp=n.signalInnerIp,this._signalInfo.tinyId=t.tinyId,n.svrTime&&function(e){Eb=e-(new Date).getTime();let t=new Date;t.setTime(e),jO.info("baseTime from server: ".concat(t," offset: ").concat(Eb))}(n.svrTime),this._log.info("ChannelSetup Success"),UO.emit(BO.API_SUCCESS_RATE,{room:this.room,apiName:"WebsocketConnect",cost:gO()-this._prevTime}),this._prevTime=-1,this.emit(qM,{signalInfo:this._signalInfo});else{let e=new Tb({code:fb.SIGNAL_CHANNEL_SETUP_FAILED,extraCode:t.code,message:QO({key:zO.SIGNAL_CHANNEL_SETUP_FAILED,data:{errorCode:t.code,errorMsg:t.message}})});this._log.error("".concat(t.code,", ").concat(t.message)),this.close(),UO.emit(BO.API_SUCCESS_RATE,{room:this.room,apiName:"WebsocketConnect",error:e}),this.emit(YM,e)}break;case ix.JOIN_ROOM_RESULT:0===t.code&&(this._signalInfo.relayIp=n.relayOuterIp,this._signalInfo.relayInnerIp=n.relayInnerIp,this._signalInfo.relayPort=n.relayPort,this._log.info("signalIp:".concat(this._signalInfo.signalIp," clientIp:").concat(this._signalInfo.clientIp," relayIp: ").concat(this._signalInfo.relayIp))),this.emit(s,{data:t});break;case ix.CHANNEL_RECONNECT_RESULT:0===t.code?(this._log.warn("reconnect success"),this.stopReconnection(),UO.emit(BO.API_SUCCESS_RATE,{room:this.room,apiName:"WebsocketReconnect",cost:gO()-this._prevTime}),this._prevTime=-1,this.room.syncUserList(),this.room.checkConnectionsToReconnect()):(this._log.warn("reconnect failed, ".concat(t.code," ").concat(t.message)),this.room.reJoin());break;default:this.emit(s,{data:t})}}reconnect(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:MN.MAIN;if(!this.room.isJoined&&this.keepAlive)return void this.close();if(this.isReconnecting)return;if(this._reconnectionCount>=cD){this._log.warn("SDK has tried reconnect signal channel for ".concat(cD," times, but all failed. please check your network"));let e=new Tb({code:fb.SIGNAL_CHANNEL_RECONNECTION_FAILED,message:QO({key:zO.SIGNAL_CHANNEL_RECONNECTION_FAILED})});return UO.emit(BO.API_SUCCESS_RATE,{room:this.room,apiName:"WebsocketReconnect",error:e}),void this.emit($M,e)}this._reconnectionCount++,this._log.warn("reconnect ".concat(e," [").concat(this._reconnectionCount,"/").concat(cD,"]"));let t=this.getReconnectionUrl(e);this.emitConnectionStateChanged(ex),this._prevTime<0&&(this._prevTime=gO()),e===MN.MAIN?(this._socket=new WebSocket(t),this.bindSocket(this._socket)):(this._backupSocket=new WebSocket(t),this.bindSocket(this._backupSocket));let i=tO(this._reconnectionCount);this._reconnectionTimer=setTimeout((()=>{this._log.warn("reconnect ".concat(e," timeout(").concat(i/1e3,"s), try again")),this.clearReconnectionTimer(),this.unbindAndCloseSocket(MN.MAIN),this.unbindAndCloseSocket(MN.BACKUP),this.reconnect(e===MN.MAIN?MN.BACKUP:MN.MAIN)}),i)}get isReconnecting(){return-1!==this._reconnectionTimer}getReconnectionUrl(e){let t=e===MN.MAIN?this._urlWithParam:this._backupUrlWithParam;if(this._signalInfo.tinyId&&-1===t.indexOf("&rc=1")){let{roomId:e,useStringRoomId:i}=this.room;t+="&rc=1&relayInnerIp=".concat(this._signalInfo.relayInnerIp,"&relayOuterIp=").concat(this._signalInfo.relayIp,"&relayPort=").concat(this._signalInfo.relayPort,"&roomId=").concat(e,"&useStringRoomId=").concat(i)}return t}send(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(this.isConnected&&!this.room.isLeft){let i={cmd:e,data:t,userId:this.userId,tinyId:this._signalInfo.tinyId,seq:++this._seq},n=JSON.stringify(i);return this._socketInUse.send(n),this.bytesSent+=PO(n),i.seq}}sendWaitForResponse(e){let{command:t,data:i,timeout:n=5e3,responseCommand:r,commandDesc:o,enableLog:s=!0}=e;return new Promise(((e,a)=>{let c=setTimeout((()=>{this.off(r,l);let e=new Tb({code:fb.API_CALL_TIMEOUT,message:QO({key:zO.API_CALL_TIMEOUT,data:{commandDesc:o,command:t}})});s&&this._log.warn(e),a(e)}),n),l=t=>{t.data.seq===d&&(clearTimeout(c),this.off(r,l),e(t))};this.on(r,l);let d=this.send(t,i)}))}sendWaitForResponseWithRetry(e){let{commandDesc:t,command:i,retries:n=0,retryTimeout:r=0}=e;return xO({retryFunction:this.sendWaitForResponse,onRetrying:e=>{this._log.warn("".concat(t||i," timeout observed, retrying [").concat(e,"/").concat(n,"]"))},settings:{retries:n,timeout:r},context:this})(e)}getCurrentState(){return this._currentState}getSignalInfo(){return this._signalInfo}stopReconnection(){this.isReconnecting&&(this._reconnectionCount=0,this.clearReconnectionTimer())}close(){this._log.info("closed"),Dx.delete(this),this.clearBackupTimer(),this.stopReconnection(),this._signalInfo={tinyId:void 0,clientIp:"",signalIp:"",relayIp:"",relayInnerIp:"",relayPort:0},this._socketInUse=null,this.bytesSent=0,this.bytesReceived=0,this.unbindAndCloseSocket(MN.MAIN),this.unbindAndCloseSocket(MN.BACKUP),this.emitConnectionStateChanged(ZM)}stopKeepAliveIn(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:3600;if(this.keepAlive){this._log.info("stopKeepAlive in ".concat(e,"s"));let t=setTimeout((()=>{this.keepAlive=!1,this._log.info("close due to not used ".concat(e,"s")),this.close()}),1e3*e),i=e=>{e instanceof Uw&&"join"===e.action&&(this._log.info("stopKeepAlive clear timeout"),clearTimeout(t),this.room.off(Ww.STATECHANGED,i))};this.room.on(Ww.STATECHANGED,i)}}emitConnectionStateChanged(e){e!==this._currentState&&(this._log.info("".concat(this._currentState," -> ").concat(e)),this.emit(QM,{prevState:this._currentState,state:e}),this._currentState=e)}},wx=rb(lb()),Px=class{constructor(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];this.dataView=e,this.isSEI&&(t?this.addPreventionByte():this.removePreventionByte())}addPreventionByte(){let e=this.seiPayloadStartIndex,t=this.dataView.byteLength-2,i=[],n=0;for(let o=e;o<=t;o++){let e=this.dataView.getInt8(o);switch(e){case 0:case 1:case 2:case 3:2===n&&(i.push(3),n=0),0==e?n++:n=0,i.push(e);break;default:n=0,i.push(e)}}i.push(this.dataView.getInt8(this.dataView.byteLength-1));let r=new DataView(new Uint8Array([...new Uint8Array(this.dataView.buffer).slice(0,e),...i]).buffer);this.dataView=r}removePreventionByte(){let e=this.seiPayloadStartIndex,t=this.dataView.byteLength-1,i=[],n=0;for(let o=e;o<=t;o++)switch(this.dataView.getInt8(o)){case 0:n++,i.push(this.dataView.getInt8(o));break;case 3:2!==n&&i.push(this.dataView.getInt8(o)),n=0;break;default:i.push(this.dataView.getInt8(o)),n=0}let r=new DataView(new Uint8Array([...new Uint8Array(this.dataView.buffer).slice(0,e),...i]).buffer);this.dataView=r}get isSEI(){return 6===this.dataView.getUint8(4)}get seiPayloadStartIndex(){let e=6;for(let t=6;t<this.dataView.buffer.byteLength&&(e++,255===this.dataView.getUint8(t));t++);return e}get seiPayloadType(){return this.isSEI?this.dataView.getUint8(5):null}get seiPayload(){if(!this.isSEI)return null;let e=0,t=6;for(let r=6;r<this.dataView.buffer.byteLength;r++){let i=this.dataView.getUint8(r);if(t++,255!==i){e+=i;break}e+=255}let i=new ArrayBuffer(e),n=new DataView(i);for(let r=0;r<i.byteLength;r++,t++)n.setInt8(r,this.dataView.getInt8(t));return n}},Lx=class{constructor(e,t,i){this._connection=e,this._log=t,this._isUplink=i,sb(this,"_seiMessageList",[]),sb(this,"_seiPayloadType",243),sb(this,"_mainVideoSenderOrReceiver",null),sb(this,"_mainVideoAbortController",null),sb(this,"_abortMap",new Map),sb(this,"onSEIMessage")}get isRunning(){return!!this._mainVideoAbortController}start(e){this._mainVideoSenderOrReceiver=e;let t=e.createEncodedStreams(),i=t.readable,n=t.writable,r=new TransformStream({transform:this._isUplink?this.encodeVideoFrame.bind(this):this.decodeVideoFrame.bind(this)});this._mainVideoAbortController=new AbortController,i.pipeThrough(r).pipeTo(n,this._mainVideoAbortController).catch((()=>{}))}restart(e){this.stop(),this.start(e)}stop(){var e;null==(e=this._mainVideoAbortController)||e.abort(),this._mainVideoAbortController=null}destroy(){this.stop(),this._abortMap.forEach((e=>e.abort())),this._abortMap.clear(),this._log=null,this.onSEIMessage=null,this._mainVideoSenderOrReceiver=null,this._connection=null}handleEncodedStreams(){try{let e=this._connection.getPeerConnection();this.clearUnusedSenderOrReceiver(e),this._isUplink?e.getSenders().forEach(((e,t)=>{if(1===t){if(e===this._mainVideoSenderOrReceiver)return;this.isRunning?this.restart(e):this.start(e)}else{if(this._abortMap.has(e))return;this.pipeSenderOrReceiver(e)}})):e.getReceivers().forEach(((e,t)=>{var i;this._abortMap.has(e)||e===this._mainVideoSenderOrReceiver||(1===t&&(null==(i=e.track)?void 0:i.kind)===MN.VIDEO?this.isRunning?this.restart(e):this.start(e):this.pipeSenderOrReceiver(e))}))}catch(FL){this._log.warn(FL)}}pipeSenderOrReceiver(e){let{readable:t,writable:i}=e.createEncodedStreams(),n=new AbortController;this._abortMap.set(e,n),t.pipeTo(i,n).catch((()=>{}))}clearUnusedSenderOrReceiver(e){this._abortMap.forEach(((t,i)=>{(this._isUplink?e.getSenders():e.getReceivers()).find((e=>e===i))||(t.abort(),this._abortMap.delete(i))}))}push(e,t){t&&t.seiPayloadType&&(this._seiPayloadType=t.seiPayloadType),this._seiMessageList.push(e)}hasSEI(e){let t=new DataView(e);return 1===t.getInt32(0)&&6===t.getInt8(4)}isEmptyFrame(e){return"empty"===e.type||0===e.data.byteLength}getNaluCount(e){let t=0,i=0,n=new DataView(e);for(let r=0;r<e.byteLength;r++)switch(n.getUint8(r)){case 0:t++;break;case 1:(2===t||3===t)&&i++,t=0;break;default:t=0}return i}encodeVideoFrame(e,t){try{if(this._connection.isH264&&this._seiMessageList.length>0&&!this.isEmptyFrame(e)){let t=9-this.getNaluCount(e.data);if(t<=0)return;let i=this._seiMessageList.splice(0,t).reverse().map(this.encodeSEINalu.bind(this)),n=i.reduce(((e,t)=>e+t.dataView.byteLength),0),r=new ArrayBuffer(n+e.data.byteLength),o=new DataView(r),s=new DataView(e.data),a=0;for(let e=0;e<i.length;e++)for(let t=0;t<i[e].dataView.byteLength;t++)o.setInt8(a++,i[e].dataView.getInt8(t));for(let c=0;c<e.data.byteLength;c++)o.setInt8(a++,s.getInt8(c));e.data=r,this._log.debug("".concat(i.length," sei sent"))}}catch(aD){this._log.warn(aD)}t.enqueue(e)}decodeVideoFrame(e,t){try{if(this._connection.isH264&&!this.isEmptyFrame(e)&&this.hasSEI(e.data)){let t=[],i=new DataView(e.data),n=0,r=-1,o=-1;for(let s=0;s<e.data.byteLength;s++){let a=i.getUint8(s);if(0===a)n++;else if(1===a){if(2===n||3===n){let a=s-n;if(-1===r?r=a:-1===o&&(o=a,t.push(new Px(new DataView(i.buffer.slice(r,o)))),r=a,o=-1),6!==i.getUint8(s+1)){e.data=new DataView(i.buffer.slice(a)).buffer;break}}n=0}else n=0}this._log.debug("".concat(t.length," sei received")),nO(this.onSEIMessage)&&t.reverse().forEach((e=>{this.onSEIMessage({seiPayloadType:e.seiPayloadType,data:e.seiPayload.buffer})}))}}catch(aD){this._log.warn(aD)}t.enqueue(e)}encodeSEINalu(e){let t=e.byteLength,i=parseInt(t/255),n=t%255,r=[];r.push(0,0,0,1,6,this._seiPayloadType);for(let s=0;s<i;s++)r.push(255);r.push(n);let o=new DataView(e);return r.push(...new Uint8Array(o.buffer)),r.push(128),new Px(new DataView(new Uint8Array(r).buffer),!0)}},Mx=0,xx=!1,Vx=new Set,Ux=!1,Fx=class{constructor(e){sb(this,"userId"),sb(this,"tinyId"),sb(this,"_sdpSemantics"),sb(this,"_isUplink"),sb(this,"_room"),sb(this,"_log"),sb(this,"_signalChannel"),sb(this,"_isErrorObserved",!1),sb(this,"_waitForPeerConnectionConnectedPromise"),sb(this,"_waitForPeerConnectionConnectedPromiseReject",null),sb(this,"_peerConnection",null),sb(this,"_emitter",new wx.default),sb(this,"_currentState","DISCONNECTED"),sb(this,"_isReconnecting",!1),sb(this,"_reconnectionCount",0),sb(this,"_reconnectionTimer",-1),sb(this,"_isFirstConnection",!0),sb(this,"_prevTime",-1),sb(this,"_enableSEI"),sb(this,"_sei"),sb(this,"_localAddress"),sb(this,"_remoteAddress"),this.userId=e.userId,this.tinyId=e.tinyId,this._room=e.room,this._sdpSemantics=e.room.sdpSemantics,this._isUplink=e.isUplink,this._log=jO.createLogger({id:"n",userId:this._room.userId,remoteUserId:this.userId,sdkAppId:this._room.sdkAppId,isLocal:this._isUplink}),this._signalChannel=e.signalChannel,this._enableSEI=e.enableSEI,this._enableSEI&&Nw&&(this._sei=new Lx(this,this._log,this._isUplink))}beforeConnect(){this._prevTime<0&&(this._prevTime=gO())}afterConnect(e){return cb(this,null,(function*(){try{yield e,this._isFirstConnection?(this._isFirstConnection=!1,UO.emit(BO.API_SUCCESS_RATE,{room:this._room,apiName:"PeerConnectionConnect",cost:Math.min(gO()-this._prevTime,3e4)})):this._isReconnecting&&UO.emit(BO.API_SUCCESS_RATE,{room:this._room,apiName:"PeerConnectionReconnect",cost:gO()-this._prevTime}),this._prevTime=-1}catch(aN){throw this._isFirstConnection?(this._isFirstConnection=!1,UO.emit(BO.API_SUCCESS_RATE,{room:this._room,apiName:"PeerConnectionConnect",error:aN})):this._isReconnecting&&this._reconnectionCount>=3&&UO.emit(BO.API_SUCCESS_RATE,{room:this._room,apiName:"PeerConnectionReconnect",error:aN}),aN}}))}initialize(){let e={encodedInsertableStreams:this._enableSEI&&Nw,iceServers:this._room.getIceServers(),iceTransportPolicy:this._room.getIceTransportPolicy(),sdpSemantics:this._sdpSemantics,bundlePolicy:"max-bundle",rtcpMuxPolicy:"require",tcpCandidatePolicy:"disable",IceTransportsType:"nohost"};this._peerConnection=new RTCPeerConnection(e),this._peerConnection.onconnectionstatechange=this.onConnectionStateChange.bind(this)}close(e){this._log.info("close connection"),this._emitter.emit("closed",e),this._isReconnecting&&this.stopReconnection(),this.closePeerConnection(),this._sei&&(this._sei.destroy(),this._sei=null),Vx.delete(this)}closePeerConnection(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];this._peerConnection&&(this._log.info("close pc"),this._peerConnection.onconnectionstatechange=null,this._peerConnection.close(),this._peerConnection=null,e&&this.emitConnectionStateChangedEvent("DISCONNECTED")),this._waitForPeerConnectionConnectedPromiseReject&&this._waitForPeerConnectionConnectedPromiseReject(new Tb({code:fb.API_CALL_ABORTED,message:"connection closed"}))}getDTLSTransportState(){if(!this._peerConnection)return iD;let e=null;if(this._isUplink){if(!Sw()||0===this._peerConnection.getSenders().length)return iD;e=this._peerConnection.getSenders()[0].transport}else{if(!Ew()||0===this._peerConnection.getReceivers().length)return iD;e=this._peerConnection.getReceivers()[0].transport}return e?e.state:iD}onConnectionStateChange(e){let t=this._peerConnection.iceConnectionState,i=this.getDTLSTransportState();if(this._log.info("connectionState: ".concat(e.target.connectionState,", ICE: ").concat(t,", DTLS: ").concat(i)),e.target.connectionState===nD.CONNECTING&&this.emitConnectionStateChangedEvent("CONNECTING"),e.target.connectionState===nD.FAILED||e.target.connectionState===nD.CLOSED){let n="connection ".concat(e.target.connectionState,". ICE Transport state: ").concat(t,", DTLS Transport state: ").concat(i),r=new Tb({message:n,code:fb.ICE_TRANSPORT_ERROR});this.emitConnectionStateChangedEvent("DISCONNECTED"),this.startReconnection(),this._isErrorObserved||this._emitter.emit("error",r)}(e.target.connectionState===nD.CONNECTED||e.target.connectionState===nD.COMPLETED)&&(this.logSelectedCandidate(),Xw.logSuccessEvent({userId:this._room.userId,eventType:lD.ICE_CONNECTION_STATE}),this.emitConnectionStateChangedEvent("CONNECTED"))}emitConnectionStateChangedEvent(e){return e!==this._currentState&&("CONNECTED"===e?(Mx=0,xx=!1,Ux=!0,Vx.add(this)):Vx.delete(this),UO.emit(BO.PEER_CONNECTION_STATE_CHANGED,{room:this._room,prevState:this._currentState,state:e,remoteUserId:this._isUplink?void 0:this.userId}),this._emitter.emit("connection-state-changed",{prevState:this._currentState,state:e}),this._currentState=e,!0)}getPeerConnection(){return this._peerConnection}getRoom(){return this._room}getUserId(){return this.userId}getTinyId(){return this.tinyId}logSelectedCandidate(){return cb(this,null,(function*(){if(!this._peerConnection)return;let e=yield this._peerConnection.getStats();for(let[,t]of e)if(hw(t)){let i=e.get(t.localCandidateId),n=e.get(t.remoteCandidateId);i&&(this._log.info("local candidate: ".concat(i.candidateType," ").concat(i.protocol,":").concat(i.ip||i.address,":").concat(i.port," ").concat(i.networkType||""," ").concat("relay"===i.candidateType?"relayProtocol:".concat(i.relayProtocol):"")),this._localAddress="".concat(i.ip||i.address,":").concat(i.port)),n&&(this._log.info("remote candidate: ".concat(n.candidateType," ").concat(n.protocol,":").concat(n.ip||n.address,":").concat(n.port)),this._remoteAddress="".concat(n.protocol,":").concat(n.ip||n.address));break}}))}getCurrentState(){return this._currentState}waitForPeerConnectionConnected(){return this._waitForPeerConnectionConnectedPromise||(this._waitForPeerConnectionConnectedPromise=new Promise(((e,t)=>{if("CONNECTED"===this._currentState)return e();this._waitForPeerConnectionConnectedPromiseReject=t;let i=t=>{"CONNECTED"===t.state&&(clearTimeout(o),r(),e())},n=e=>{let{room:i}=e;i===this._room&&(clearTimeout(o),r(),t(new Tb({code:fb.API_CALL_ABORTED,message:QO({key:zO.CONNECTION_ABORTED,data:"leave room"})})))},r=()=>{UO.off(BO.LEAVE_SUCCESS,n,this),this._emitter.off("connection-state-changed",i,this)},o=setTimeout((()=>{r();let e=new Tb({code:fb.API_CALL_TIMEOUT,message:"connection timeout"});Mx+=1,(e=>Mx>2&&!xx&&0===Vx.size&&e)(this._signalChannel.isConnected)&&(this._log.warn("firewall restrition"),xx=!0,this._emitter.emit("firewall-restriction")),t(e)}),ID);UO.on(BO.LEAVE_SUCCESS,n,this),this._emitter.on("connection-state-changed",i,this)})),this._waitForPeerConnectionConnectedPromise=this._waitForPeerConnectionConnectedPromise.finally((()=>{this._waitForPeerConnectionConnectedPromise=null,this._waitForPeerConnectionConnectedPromiseReject=null}))),this._waitForPeerConnectionConnectedPromise}getReconnectionCount(){return this._reconnectionCount}startReconnection(){this._isReconnecting=!0,this.reconnect()}clearReconnectionTimer(){-1!==this._reconnectionTimer&&(clearTimeout(this._reconnectionTimer),this._reconnectionTimer=-1)}stopReconnection(){this._log.info("stop reconnection"),this._isReconnecting=!1,this._reconnectionCount=0,this.clearReconnectionTimer(),this._signalChannel.off(XM,this.reconnect,this)}beforeReconnect(){if(-1!==this._reconnectionTimer)return this._log.warn("reconnect() is reconnecting, ignore"),-1;if(this._reconnectionCount>=sD()){this._log.warn("SDK has tried reconnect for ".concat(this._reconnectionCount," times, but all failed, please check your network")),this.stopReconnection();let e=new Tb({code:this._isUplink?fb.UPLINK_RECONNECTION_FAILED:fb.DOWNLINK_RECONNECTION_FAILED,message:QO({key:this._isUplink?zO.UPLINK_RECONNECTION_FAILED:zO.DOWNLINK_RECONNECTION_FAILED})});return this.emitConnectionStateChangedEvent("DISCONNECTED"),this._emitter.emit("error",e),-1}return this._signalChannel.isConnected?(this._reconnectionCount+=1,this._log.warn("reconnect() trying [".concat(this._reconnectionCount,"]")),1):(this._log.warn("reconnect() signal channel is not connected, suspend reconnection until signal is connected"),this._signalChannel.once(XM,this.reconnect,this),-1)}on(e,t,i){this._emitter.on(e,t,i)}off(e,t,i){this._emitter.off(e,t,i)}getIsReconnecting(){return this._isReconnecting}get isH264(){var e,t;return!(null==(t=null==(e=this._peerConnection)?void 0:e.remoteDescription)||!t.sdp.includes("H264"))}},Bx=rb(pb()),Hx=function(e){return Bx.default.parse(e)},jx=function(e){return Bx.default.write(e)};function Gx(e){return Object.keys(e).filter((t=>e[t]))}var Wx=class extends Fx{constructor(e){super(tb(eb({},e),{isUplink:!1})),sb(this,"_flag",0),sb(this,"role","anchor"),sb(this,"remoteAudioTrack"),sb(this,"remoteVideoTrack"),sb(this,"remoteAuxiliaryTrack"),sb(this,"ssrc",{audio:0,video:0,auxiliary:0}),sb(this,"_isSDPExchanging",!1),this.flag=e.flag,this.remoteAudioTrack=e.remoteAudioTrack||new CL(this._room,this),this.remoteVideoTrack=e.remoteVideoTrack||new bL(this._room,this),this.remoteAuxiliaryTrack=e.remoteAuxiliaryTrack||new kL(this._room,this)}get subscribeState(){let e={audio:!1,video:!1,auxiliary:!1,smallVideo:!1};return this.remoteVideoTrack.isSubscribed&&(8&this.remoteVideoTrack.mediaType?e.smallVideo=!0:e.video=!0),this.remoteAudioTrack.isSubscribed&&(e.audio=!0),this.remoteAuxiliaryTrack.isSubscribed&&(e.auxiliary=!0),e}get muteState(){return yO(this.flag,this.userId)}get flag(){return this._flag}set flag(e){var t,i,n;e!==this._flag&&(this._flag=e,null==(t=this.remoteAudioTrack)||t.onFlagChanged(),null==(i=this.remoteVideoTrack)||i.onFlagChanged(),null==(n=this.remoteAuxiliaryTrack)||n.onFlagChanged())}get hasMainStream(){return this.muteState.hasAudio||this.muteState.hasVideo||this.muteState.hasSmall}get hasAuxStream(){return this.muteState.hasAuxiliary}get isMainStreamSubscribed(){return(this.subscribeState.audio||this.subscribeState.video||this.subscribeState.smallVideo)&&(this.muteState.hasAudio||this.muteState.hasVideo||this.muteState.hasSmall)}get isAuxStreamSubscribed(){return this.subscribeState.auxiliary&&this.muteState.hasAuxiliary}get isSmallStreamSubscribed(){return this.subscribeState.smallVideo&&this.muteState.hasSmall}get isBigStreamSubscribed(){return this.subscribeState.video&&this.muteState.hasVideo}isStreamUnpublished(e){return e===MN.MAIN?!this.muteState.hasAudio&&!this.muteState.hasVideo:!this.muteState.hasAuxiliary}initialize(){super.initialize(),this.installEvents(),this._peerConnection.ontrack=this.onTrack.bind(this)}close(e){super.close(e),this.emitConnectionStateChangedEvent("DISCONNECTED"),this.remoteAudioTrack.close(),this.remoteVideoTrack.close(),this.remoteAuxiliaryTrack.close(),this.uninstallEvents()}installEvents(){}uninstallEvents(){this._emitter.removeAllListeners()}emitConnectionStateChangedEvent(e){var t,i;let n=this._currentState,r=super.emitConnectionStateChangedEvent(e);return r&&n!==e&&(null==(t=this.remoteVideoTrack)||t.emit("connection-state-changed",{prevState:n,state:e}),null==(i=this.remoteAuxiliaryTrack)||i.emit("connection-state-changed",{prevState:n,state:e})),r}onTrack(e){let t=e.streams[0],{track:i}=e,n=t.id===JN?MN.MAIN:MN.AUXILIARY;this._log.debug("ontrack ".concat(n," ").concat(i.kind));let r=MN.AUDIO;i.kind===MN.VIDEO&&(r=n===MN.MAIN?MN.VIDEO:MN.AUXILIARY);let o=this.remoteAudioTrack;r===MN.VIDEO?o=this.remoteVideoTrack:r===MN.AUXILIARY&&(o=this.remoteAuxiliaryTrack),o.setInputMediaStreamTrack(i)}addRRTRLine(e){let t=e.split("\r\n"),i=new Map;t.forEach(((e,n)=>{/^a=rtcp-fb:/.test(e)&&t[n+1]&&!/^a=rtcp-fb:/.test(t[n+1])&&i.set(n+1,"".concat(e.match(/^a=rtcp-fb:\d+/)[0]," rrtr"))}));let n=[...i];for(let r=0;r<n.length;r++){let[e,i]=n[r];t.splice(e+r,0,i)}return t.join("\r\n")}addSPSDescription(e){let t=Hx(e);return t.media.forEach((e=>{e.type===MN.VIDEO&&e.fmtp.forEach((e=>{e.config+=";sps-pps-idr-in-keyframe=1"}))})),jx(t)}removeSDESDescription(e){let t=["urn:ietf:params:rtp-hdrext:sdes:mid","urn:ietf:params:rtp-hdrext:sdes:rtp-stream-id","urn:ietf:params:rtp-hdrext:sdes:repaired-rtp-stream-id"],i=Hx(e);return i.media.forEach((e=>{!e.ext||(e.ext=e.ext.filter((e=>!t.includes(e.uri))))})),jx(i)}isSubscriptionStateNotChanged(e){return JSON.stringify(e)===JSON.stringify(this.subscribeState)}subscribe(e,t){return cb(this,null,(function*(){var i,n;try{if(((null==(i=this._peerConnection)?void 0:i.connectionState)===nD.NEW||(null==(n=this._peerConnection)?void 0:n.connectionState)===nD.CONNECTING)&&(yield this.waitForPeerConnectionConnected()),this.isSubscriptionStateNotChanged(e))return void(this._peerConnection||(this.initialize(),yield this.connect(e)));if(this._log.info("subscribe ".concat(t," ").concat(JSON.stringify(e))),this._peerConnection||this._isSDPExchanging){let t="subscribe_change";Object.values(e).find((e=>!0===e))||(t="unsubscribe"),yield this.sendSubscription(t,e)}else this.initialize(),yield this.connect(e)}catch(lN){throw this._room.isJoined&&this.isStreamUnpublished(t)?(this._log.warn("".concat(lN.message," ").concat(JSON.stringify(this.muteState))),new Tb({code:fb.REMOTE_STREAM_NOT_EXIST,message:"remote user ".concat(this.userId," unpublished stream")})):lN}}))}unsubscribe(e){return cb(this,arguments,(function(e){var t=this;let{remoteTracks:i,streamType:n}=e;return function*(){if("CONNECTED"===t._currentState&&("main"===n&&!t.isMainStreamSubscribed||"auxiliary"===n&&!t.isAuxStreamSubscribed))return void t._log.info("".concat(n," stream already unsubscribed"));let e=eb({},t.subscribeState);i.forEach((t=>{switch(t.mediaType){case 1:e.audio=!1;break;case 4:e.video=!1;break;case 8:e.smallVideo=!1;break;case 2:e.auxiliary=!1}}));let r="subscribe_change";Object.values(e).find((e=>!0===e))||(r="unsubscribe"),t._log.info("".concat("unsubscribe"===r?r:"subscribe"," ").concat(n," [").concat(Gx(e),"]")),yield t.sendSubscription(r,e),"unsubscribe"===r&&(t.closePeerConnection(),t.emitConnectionStateChangedEvent("DISCONNECTED"))}()}))}sendSubscription(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.subscribeState,i={srcTinyId:this.tinyId,srcUserId:this.userId},n=mx,r=rx.UNSUBSCRIBE_RESULT;return"subscribe_change"===e&&(i={audio:t.audio,bigVideo:t.video,auxVideo:t.auxiliary,smallVideo:t.smallVideo,srcTinyId:this.tinyId},n=_x,r=rx.SUBSCRIBE_CHANGE_RESULT),this._signalChannel.sendWaitForResponse({command:n,data:i,responseCommand:r,timeout:1e4}).then((t=>{let{data:i}=t;if(0!==i.code){let t=new Tb({code:i.code,message:QO({key:zO.ERROR_MESSAGE,data:{type:e,message:i.message}})});throw this._log.error(t),t}}))}connect(){return cb(this,arguments,(function(){var e=this;let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.subscribeState;return function*(){try{yield e.exchangeSDP(t),yield e.waitForPeerConnectionConnected()}catch(aD){throw e.closePeerConnection(!0),aD}}()}))}exchangeSDP(e){return cb(this,null,(function*(){try{this._isSDPExchanging=!0,yield this.createOffer(),this._log.info("createOffer success, sending offer");let{type:t,sdp:i}=this._peerConnection.localDescription,n={type:t,sdp:i,srcUserId:this.userId,srcTinyId:this.tinyId,audio:e.audio,bigVideo:e.video,auxVideo:e.auxiliary,smallVideo:e.smallVideo},r=yield this._signalChannel.sendWaitForResponse({command:px,commandDesc:"exchange sdp",data:n,responseCommand:rx.SUBSCRIBE_RESULT,timeout:hD});if(!this._peerConnection){let e=new Tb({code:fb.INVALID_OPERATION,message:QO({key:zO.CONNECTION_CLOSED})});throw this._log.warn(e),e}yield this.onSubscribeResult(r),this._isSDPExchanging=!1}catch(aD){throw this._isSDPExchanging=!1,aD}}))}createOffer(){return cb(this,null,(function*(){let e={voiceActivityDetection:!1};yw()&&this._sdpSemantics===pD?(this._peerConnection.addTransceiver(MN.AUDIO,{direction:xN.RECVONLY}),this._peerConnection.addTransceiver(MN.VIDEO,{direction:xN.RECVONLY}),this._peerConnection.addTransceiver(MN.VIDEO,{direction:xN.RECVONLY})):(e.offerToReceiveAudio=!0,e.offerToReceiveVideo=!0);let t=yield this._peerConnection.createOffer(e);if(t.sdp){let{isH264DecodeSupported:e}=yield aw();e||(this._log.warn("remove h264 desc from sdp"),t.sdp=function(e){let t=Hx(e);return t.media.forEach((e=>{var t,i;if(e.type===MN.VIDEO){let n=new Set;e.rtp.forEach((e=>{let{payload:t,codec:i}=e;return"H264"===i&&n.add(t)})),e.fmtp.forEach((e=>{let{payload:t,config:i}=e,r=i.match(/apt=(\d+)/);r&&r[1]&&n.has(Number(r[1]))&&n.add(t)}));let r=e=>{let{payload:t}=e;return!n.has(t)};e.rtp=e.rtp.filter(r),e.rtcpFb=null==(t=e.rtcpFb)?void 0:t.filter(r),e.fmtp=e.fmtp.filter(r),e.payloads=null==(i=e.payloads)?void 0:i.split(" ").filter((e=>!n.has(Number(e)))).join(" ")}})),jx(t)}(t.sdp)),t.sdp=this.addRRTRLine(t.sdp),t.sdp=this.addSPSDescription(t.sdp),t.sdp=function(e){let t=Hx(e);return t.media.forEach((e=>{e.type===MN.AUDIO&&e.fmtp.forEach((e=>{e.config+=";sprop-stereo=1;stereo=1"}))})),jx(t)}(t.sdp),this._sdpSemantics===pD&&(t.sdp=this.removeSDESDescription(t.sdp))}yield this._peerConnection.setLocalDescription(t)}))}onSubscribeResult(e){return cb(this,null,(function*(){let{code:t,message:i=""}=e&&e.data||{},{type:n,sdp:r}=e&&e.data&&e.data.data||{};if(t===_D)throw new Tb({code:fb.NOT_SUPPORTED_H264,message:QO({key:zO.NOT_SUPPORTED_H264DECODE})});try{if(0!==t)throw new Tb({code:t,message:QO({key:zO.EXCHANGE_SDP_FAILED,data:{errMsg:i}})});this._log.debug("accept remote answer: ".concat(r)),yield this._peerConnection.setRemoteDescription({type:n,sdp:r}),this._sei&&(this._sei.handleEncodedStreams(),this._sei.onSEIMessage=e=>{this._emitter.emit("sei-message",tb(eb({},e),{userId:this.userId}))}),this.updateSSRC(r)}catch(JV){throw this._log.error(JV),JV}}))}updateSSRC(e){try{Hx(e).media.forEach((e=>{if(e.ssrcs)if(e.type===MN.AUDIO){let t=e.ssrcs.find((e=>{var t;return null==(t=e.value)?void 0:t.includes(JN)}));t&&(this.ssrc.audio=Number(t.id))}else{let t=e.ssrcs.find((e=>{var t;return null==(t=e.value)?void 0:t.includes(JN)})),i=e.ssrcs.find((e=>{var t;return null==(t=e.value)?void 0:t.includes(zN)}));t&&(this.ssrc.video=Number(t.id)),i&&(this.ssrc.auxiliary=Number(i.id))}}))}catch(aD){}}getMainStreamVideoTrackId(){return this.remoteVideoTrack&&this.remoteVideoTrack.mediaTrack?this.remoteVideoTrack.mediaTrack.id:""}getAuxStreamVideoTrackId(){return this.remoteAuxiliaryTrack&&this.remoteAuxiliaryTrack.mediaTrack?this.remoteAuxiliaryTrack.mediaTrack.id:""}reconnect(){return cb(this,null,(function*(){if(!(ab(Wx.prototype,this,"beforeReconnect").call(this)<0))try{this.closePeerConnection(),this.initialize(),yield this.connect(),this.stopReconnection(),this._log.warn("reconnect() success")}catch(aD){let t=tO(this._reconnectionCount);this._log.warn("reconnect() timeout, try again after ".concat(t/1e3,"s")),this._reconnectionTimer=setTimeout((()=>{this.clearReconnectionTimer(),this.reconnect()}),t)}}))}getIsReconnecting(){return this._isReconnecting}clearReconnectionTimer(){-1!==this._reconnectionTimer&&(clearTimeout(this._reconnectionTimer),this._reconnectionTimer=-1)}getCurrentState(){return this._currentState}setDelay(e){let{audioDelay:t,videoDelay:i}=e;this.remoteAudioTrack.stat.end2EndDelay=t,this.remoteVideoTrack.stat.end2EndDelay=i}},Jx=Wx;ob([nL((e=>function(){for(var t=arguments.length,i=new Array(t),n=0;n<t;n++)i[n]=arguments[n];return new Promise(((t,n)=>{let r=e=>{this._emitter.off("closed",r),n(new Tb({code:fb.API_CALL_ABORTED,message:QO({key:zO.CONNECTION_ABORTED,data:e})}))};this._emitter.on("closed",r),e.apply(this,i).then(t,n).finally((()=>{this._emitter.off("closed",r)}))}))}))],Jx.prototype,"subscribe",1),ob([iL(Fx.prototype.afterConnect),tL(Fx.prototype.beforeConnect)],Jx.prototype,"connect",1);var zx=Jx,Kx={voiceActivityDetection:!1},qx=class extends Fx{constructor(e){super(tb(eb({},e),{isUplink:!0})),sb(this,"localMainAudioTrack",null),sb(this,"localMainVideoTrack",null),sb(this,"localAuxAudioTrack",null),sb(this,"localAuxVideoTrack",null),sb(this,"ssrc",{audio:0,video:0,small:0,auxiliary:0}),sb(this,"_isPublishingAux",!1),sb(this,"_publishingLocalAudioTrack"),sb(this,"_publishingLocalVideoTrack"),sb(this,"_mediaSettings",{videoCodec:"",videoWidth:0,videoHeight:0,videoBps:0,videoFps:0,audioCodec:"opus",audioFs:0,audioChannel:0,audioBps:0,smallVideoWidth:0,smallVideoHeight:0,smallVideoFps:0,smallVideoBps:0,auxVideoWidth:0,auxVideoHeight:0,auxVideoFps:0,auxVideoBps:0}),sb(this,"_audioManager"),this._audioManager=e.audioManager}get isMainStreamPublished(){return!(!this.localMainAudioTrack&&!this.localMainVideoTrack)}get isAuxStreamPublished(){return!(!this.localAuxVideoTrack&&!this.localAuxAudioTrack)}get publishState(){var e,t,i,n;let r={audio:!1,bigVideo:!1,smallVideo:!1,auxVideo:!1};if(this._peerConnection){let o=this._peerConnection.getSenders();o&&(Iw()?(r.audio=!(null==(e=o[0])||!e.track),r.bigVideo=!(null==(t=o[1])||!t.track),r.smallVideo=!(null==(i=o[2])||!i.track),r.auxVideo=!(null==(n=o[3])||!n.track)):o.forEach((e=>{e.track&&(e.track.kind===MN.AUDIO?r.audio=!0:(r.bigVideo=!0,this._room.videoManager.hasSmall&&(r.smallVideo=!0)))})))}return r}initialize(){super.initialize(),this.installEvents()}reset(){this._isReconnecting&&this.stopReconnection(),this.closePeerConnection(),this.uninstallEvents()}close(e){super.close(e),this.reset(),this.emitConnectionStateChangedEvent("DISCONNECTED")}installEvents(){this._emitter.listeners("connection-state-changed").includes(this.handleConnectionStateChange)||this._emitter.on("connection-state-changed",this.handleConnectionStateChange,this)}uninstallEvents(){this._emitter.off("connection-state-changed",this.handleConnectionStateChange,this)}emitConnectionStateChangedEvent(e,t){var i,n,r;let o=this._currentState,s=super.emitConnectionStateChangedEvent(e);return s&&o!==e&&(t?t.emit("connection-state-changed",{prevState:o,state:e}):(null==(i=this.localMainVideoTrack)||i.emit("connection-state-changed",{prevState:o,state:e}),null==(n=this.localAuxVideoTrack)||n.emit("connection-state-changed",{prevState:o,state:e}),null==(r=this._publishingLocalVideoTrack)||r.emit("connection-state-changed",{prevState:o,state:e}))),s}publish(e){return cb(this,arguments,(function(e){var t=this;let{localAudioTrack:i,localVideoTrack:n,isAuxiliary:r}=e;return function*(){var e;let o;t._peerConnection||t.initialize(),i&&(t._publishingLocalAudioTrack=i),n&&(t._publishingLocalVideoTrack=n),t._isPublishingAux=r,n&&!r&&n.small&&(o=t._room.videoManager.smallTrack),t.sendMediaSettings(),yw()?yield t.publishByTransceiver({localAudioTrack:i,localVideoTrack:n,smallTrack:o,isAuxiliary:r}):yield t.publishByAddTrack({localAudioTrack:i,localVideoTrack:n,smallTrack:o}),t._publishingLocalAudioTrack=null,t._publishingLocalVideoTrack=null,t._isPublishingAux=!1,r?(n&&(t.localAuxVideoTrack=n),i&&(t.localAuxAudioTrack=i)):(n&&(t.localMainVideoTrack=n),i&&(t.localMainAudioTrack=i)),null==(e=t._sei)||e.handleEncodedStreams(),t.installTrackMuteEvents(i,n),t.sendMutedFlag()}()}))}publishByTransceiver(e){return cb(this,arguments,(function(e){var t=this;let{localAudioTrack:i,localVideoTrack:n,smallTrack:r,isAuxiliary:o}=e;return function*(){t._log.info("publish by transceiver");let e=new MediaStream,s=null==n?void 0:n.outMediaTrack,a=t._audioManager.mixedAudioTrack;a&&e.addTrack(a),s&&e.addTrack(s);let c=t._peerConnection.getTransceivers();if(0===c.length)t._peerConnection.addTransceiver(a||MN.AUDIO,{direction:xN.SENDONLY,streams:[e]}),t._peerConnection.addTransceiver(o?MN.VIDEO:s||MN.VIDEO,{direction:xN.SENDONLY,streams:[e]}),t._peerConnection.addTransceiver(r||MN.VIDEO,{direction:xN.SENDONLY,streams:[e]}),t._peerConnection.addTransceiver(o&&s||MN.VIDEO,{direction:xN.SENDONLY,streams:[e]}),yield t.connect();else{let e=[];if(a&&(c[0].sender.track||e.push(0),yield c[0].sender.replaceTrack(a),yield t.setBandwidth({bandwidth:(null==i?void 0:i.profile.bitrate)||40,type:MN.AUDIO})),s){let i=o?3:1;yield c[i].sender.replaceTrack(s),yield t.setBandwidth({bandwidth:n.profile.bitrate,type:MN.VIDEO,videoType:o?MN.AUXILIARY:MN.BIG}),e.push(i),r&&(yield c[2].sender.replaceTrack(r),yield t.setBandwidth({bandwidth:n.small.bitrate,type:MN.VIDEO,videoType:MN.SMALL}),e.push(2))}yield t.setTransceiverDirection(xN.SENDONLY,e),yield t.doPublishChange(),null==n||n.emit("connection-state-changed",{prevState:"DISCONNECTED",state:"CONNECTING"}),null==n||n.emit("connection-state-changed",{prevState:"CONNECTING",state:"CONNECTED"})}}()}))}publishByAddTrack(e){return cb(this,arguments,(function(e){var t=this;let{localAudioTrack:i,localVideoTrack:n,smallTrack:r}=e;return function*(){t._log.info("publish by addtrack");let e=null==n?void 0:n.outMediaTrack,o=t._audioManager.mixedAudioTrack;if(t._peerConnection&&"new"!==t._peerConnection.connectionState)return o&&(yield t.addTrack(i)),void(e&&(yield t.addTrack(n)));let s=new MediaStream;if(o&&s.addTrack(o),e&&s.addTrack(e),o&&t._peerConnection.addTrack(o,s),e&&(t._peerConnection.addTrack(e,s),r)){let e=new MediaStream;e.addTrack(r),t._peerConnection.addTrack(r,e)}yield t.connect()}()}))}installTrackMuteEvents(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];t.forEach((e=>{e&&(null==e||e.on("mute",this.sendMutedFlag,this),null==e||e.on("unmute",this.sendMutedFlag,this))}))}uninstallTrackMuteEvents(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];t.forEach((e=>{e&&(null==e||e.off("mute",this.sendMutedFlag,this),null==e||e.off("unmute",this.sendMutedFlag,this))}))}unpublish(e){return cb(this,arguments,(function(e){var t=this;let{localAudioTrack:i,localVideoTrack:n}=e;return function*(){if(!Iw())return i&&i.outMediaTrack&&!n&&t.localMainVideoTrack?(yield t.removeTrack(i),void(t.localMainAudioTrack=null)):n&&n.outMediaTrack&&!i&&t.localMainAudioTrack?(yield t.removeTrack(n),void(t.localMainVideoTrack=null)):(yield t.doUnpublish(),t.uninstallTrackMuteEvents(i,n),void t.emitConnectionStateChangedEvent("DISCONNECTED",n));let e=n&&n===t.localAuxVideoTrack,r=null==n?void 0:n.outMediaTrack,o=t._peerConnection.getSenders(),s=[];i&&(t._audioManager.mixedAudioTrack||(yield o[0].replaceTrack(null),s.push(0)),e?t.localAuxAudioTrack=null:t.localMainAudioTrack=null),r&&(e?(yield o[3].replaceTrack(null),t.localAuxVideoTrack=null,t._mediaSettings=tb(eb({},t._mediaSettings),{auxVideoBps:0,auxVideoFps:0,auxVideoWidth:0,auxVideoHeight:0}),s.push(3)):(yield o[1].replaceTrack(null),yield o[2].replaceTrack(null),t.localMainVideoTrack=null,t._mediaSettings=tb(eb({},t._mediaSettings),{videoWidth:0,videoHeight:0,videoBps:0,videoFps:0,audioFs:0,audioChannel:0,audioBps:0,smallVideoWidth:0,smallVideoHeight:0,smallVideoFps:0,smallVideoBps:0}),s.push(1,2))),t.isMainStreamPublished||t.isAuxStreamPublished?(yield t.setTransceiverDirection(xN.INACTIVE,s),yield t.doPublishChange(!1)):yield t.doUnpublish(),t.uninstallTrackMuteEvents(i,n),null==n||n.emit("connection-state-changed",{prevState:t._currentState,state:"DISCONNECTED"})}()}))}doPublishChange(){let e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];return cb(this,null,(function*(){let t={state:this.publishState,constraintConfig:this._mediaSettings},i=yield this._signalChannel.sendWaitForResponse({command:ux,data:t,responseCommand:rx.PUBLISH_STATE_CHANGE_RESULT,enableLog:e});this.checkPublishResultCode(i.data.code,i.data.message)}))}doUnpublish(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return this._signalChannel.sendWaitForResponse({command:hx,commandDesc:"unpublish",responseCommand:rx.UNPUBLISH_RESULT,enableLog:e}).catch((e=>{if(e.getCode()===fb.API_CALL_TIMEOUT)return Promise.resolve();throw e}))}updateMediaSettings(){let{detail:{isH264EncodeSupported:e,isVp8EncodeSupported:t}}=this._room.checkSystemResult;e?this._mediaSettings.videoCodec="H264":t&&(this._mediaSettings.videoCodec="VP8");let i=this._publishingLocalAudioTrack||this.localMainAudioTrack||this.localAuxAudioTrack,{localMainVideoTrack:n,localAuxVideoTrack:r}=this;if(this._publishingLocalVideoTrack&&(this._isPublishingAux?r=this._publishingLocalVideoTrack:n=this._publishingLocalVideoTrack),bw){if(i&&i.outMediaTrack){let e=i.outMediaTrack.getSettings();this._mediaSettings.audioChannel=e.channelCount||1,this._mediaSettings.audioBps=1e3*i.profile.bitrate,this._mediaSettings.audioFs=e.sampleRate||0}if(n&&n.outMediaTrack){let e=n.outMediaTrack.getSettings();this._mediaSettings.videoWidth=e.width||0,this._mediaSettings.videoHeight=e.height||0,this._mediaSettings.videoFps=e.frameRate||0,this._mediaSettings.videoBps=1e3*n.profile.bitrate,n.small&&(this._mediaSettings.smallVideoWidth=n.small.width,this._mediaSettings.smallVideoHeight=n.small.height,this._mediaSettings.smallVideoFps=n.small.frameRate,this._mediaSettings.smallVideoBps=1e3*n.small.bitrate)}if(r&&r.outMediaTrack){let e=r.outMediaTrack.getSettings();this._mediaSettings.auxVideoWidth=e.width||0,this._mediaSettings.auxVideoHeight=e.height||0,this._mediaSettings.auxVideoFps=e.frameRate||0,this._mediaSettings.auxVideoBps=1e3*r.profile.bitrate}}else i&&i.outMediaTrack&&(this._mediaSettings.audioChannel=i.profile.channelCount,this._mediaSettings.audioBps=1e3*i.profile.bitrate,this._mediaSettings.audioFs=i.profile.sampleRate),n&&n.outMediaTrack&&(this._mediaSettings.videoWidth=n.profile.width,this._mediaSettings.videoHeight=n.profile.height,this._mediaSettings.videoFps=n.profile.frameRate,this._mediaSettings.videoBps=1e3*n.profile.bitrate);this._log.info("updateMediaSettings: ".concat(JSON.stringify(this._mediaSettings)))}sendMediaSettings(){this.updateMediaSettings(),this._signalChannel.sendWaitForResponse({command:Ax,data:this._mediaSettings,responseCommand:rx.UPDATE_CONSTRAINT_CONFIG_RES}).then((e=>{0!==e.data.code&&this._log.warn(e.data.message)})).catch((()=>{}))}addTrack(e){return cb(this,null,(function*(){var t;if(!this._peerConnection)return;let i=e===this.localAuxAudioTrack||e===this.localAuxVideoTrack;this._log.info("is adding ".concat(e.kind," track to current published local ").concat(i?MN.AUXILIARY:MN.MAIN," stream")),null==(t=this._sei)||t.handleEncodedStreams(),yw()?yield this.addTrackByTransceiver(e,i):yield this.addTrackBySender(e)}))}addTrackByTransceiver(e,t){return cb(this,null,(function*(){var i;if(!e.mediaTrack)return;let n=this._peerConnection.getTransceivers();if(e.kind===MN.AUDIO)yield n[0].sender.replaceTrack(this._audioManager.mixedAudioTrack);else{let r=t?3:1;yield n[r].sender.replaceTrack(e.outMediaTrack),1===r&&(null==(i=this.localMainVideoTrack)?void 0:i.small)&&(yield n[2].sender.replaceTrack(this._room.videoManager.smallTrack)),n[r].direction===xN.INACTIVE&&(yield this.setTransceiverDirection(xN.SENDONLY,[r]))}this.updateMediaSettings(),yield this.doPublishChange()}))}addTrackBySender(e){return cb(this,null,(function*(){if(!e.outMediaTrack)return;let t=e.outMediaTrack;Iw()&&this._peerConnection.getTransceivers().findIndex((e=>"stopped"===e.direction))>=0&&(this._log.warn("transceiver is stopping, negotiate sdp first"),yield this.updateOffer("remove",t));let i=this._peerConnection.getSenders().find((e=>e.track&&e.track.kind===t.kind));if(i&&i.track){this._log.warn("sender already exists, remove sender first");let e=i.track;this.removeSender(i),yield this.updateOffer("remove",e)}let n=t.kind===MN.VIDEO?t:this._audioManager.mixedAudioTrack;if(n&&this._peerConnection.addTrack(t,new MediaStream([n])),t.kind===MN.VIDEO&&e instanceof aL&&e.small){let e=new MediaStream,t=this._room.videoManager.smallTrack;e.addTrack(t),this._peerConnection.addTrack(t,e)}yield this.updateOffer("add",t)}))}isNeedToResetOfferOrder(){if(this._sdpSemantics===mD||!this._peerConnection||!this._peerConnection.localDescription)return!1;let{sdp:e}=this._peerConnection.localDescription,t=Hx(e);for(let i=0;i<t.media.length;i++)if(0===Number(t.media[i].mid)&&t.media[i].type===MN.VIDEO)return!0;return!1}removeSender(e){let t=null;Iw()&&(t=this._peerConnection.getTransceivers().find((t=>t.sender&&t.sender.track===e.track))),this._peerConnection.removeTrack(e),t&&nO(t.stop)&&(this._log.info("stop transceiver"),t.stop())}removeTrack(e){return cb(this,null,(function*(){if(!this._peerConnection)return;let t=e===this.localAuxAudioTrack||e===this.localAuxVideoTrack;this._log.info("is removing ".concat(e.kind," track from current published local ").concat(t?MN.AUXILIARY:MN.MAIN," stream")),yw()?yield this.removeTrackByTransceiver(e,t):yield this.removeTrackBySender(e)}))}removeTrackByTransceiver(e,t){return cb(this,null,(function*(){if(!e.outMediaTrack)return;let i=this._peerConnection.getTransceivers();if(e.kind===MN.AUDIO)this._audioManager.mixedAudioTrack||(yield i[0].sender.replaceTrack(null));else{let n=t?3:1;yield i[n].sender.replaceTrack(null),1===n&&e.small&&(yield i[2].sender.replaceTrack(null)),yield this.setTransceiverDirection(xN.INACTIVE,[n])}this.updateMediaSettings(),yield this.doPublishChange()}))}setTransceiverDirection(e,t){return cb(this,null,(function*(){if(!Fb)return;let i=!1,n=!1;this._log.info("setting transceiver ".concat(t.join(",")," direction to ").concat(e));let r=this._peerConnection.getTransceivers();if(t.forEach((t=>{r[t].direction!==e&&(r[t].direction=e,i=!0)})),i){this._log.info("updating offer");let e=yield this._peerConnection.createOffer();yield this._peerConnection.setLocalDescription(e)}let o=-1,s=this._peerConnection.remoteDescription.sdp.split("\r\n").map((i=>{if(i.match(new RegExp("a=(".concat(xN.INACTIVE,"|").concat(xN.RECVONLY,"|").concat(xN.SENDONLY,")")))&&o++,t.includes(o)){if(e===xN.INACTIVE&&i.includes("a=".concat(xN.RECVONLY)))return n=!0,"a=".concat(e);if(e===xN.SENDONLY&&i.includes("a=".concat(xN.INACTIVE)))return n=!0,"a=".concat(xN.RECVONLY)}return i})).join("\r\n");n&&(this._log.info("updating answer"),yield this._peerConnection.setRemoteDescription({type:"answer",sdp:s}))}))}removeTrackBySender(e){return cb(this,null,(function*(){if(!e.outMediaTrack)return;if(e.kind===MN.VIDEO&&this.isNeedToResetOfferOrder()&&this.localMainAudioTrack)return this.reset(),this.initialize(),void(yield this.publish({localAudioTrack:this.localMainAudioTrack,isAuxiliary:!1}));let t=this._peerConnection.getSenders().find((t=>t.track===e.outMediaTrack));t&&(this.removeSender(t),e.kind===MN.VIDEO&&e.small&&this._peerConnection.getSenders().forEach((e=>{e.track&&e.track.kind===MN.VIDEO&&this.removeSender(e)}))),yield this.updateOffer("remove",e.outMediaTrack)}))}replaceTrack(e){return cb(this,null,(function*(){var t;let i,n=null==(t=this._peerConnection)?void 0:t.getSenders();if(!n||0===n.length||!e.mediaTrack)return;if(i=yw()?e.kind===MN.AUDIO?n[0]:n[1]:n.find((t=>t.track&&t.track.kind===e.kind)),!i)return;let r=e===this.localAuxAudioTrack||e===this.localAuxVideoTrack;this._log.info("is replacing ".concat(e.kind," track on ").concat(r?MN.AUXILIARY:MN.MAIN," stream")),e.kind===MN.AUDIO?yield i.replaceTrack(this._audioManager.mixedAudioTrack):e.kind===MN.VIDEO&&(r?n[3]&&(yield n[3].replaceTrack(e.outMediaTrack)):yield i.replaceTrack(e.outMediaTrack))}))}updateOffer(e,t){return cb(this,null,(function*(){try{let i=yield this._peerConnection.createOffer(Kx);Fb&&i.sdp&&(i.sdp=this.setSDPDirection(i.sdp,"sendrecv")),yield this._peerConnection.setLocalDescription(i);let n=this.updateMediaSettings(),r={action:e,trackId:t.id,kind:t.kind===MN.VIDEO?"bigVideo":t.kind,type:"offer",sdp:this._peerConnection.localDescription.sdp,constraintConfig:n,state:this.publishState};this._log.info("createOffer success, sending updated offer to remote server"),this._log.debug("updatedOffer: ".concat(r.sdp));let o=yield this._signalChannel.sendWaitForResponse({command:ox,data:r,responseCommand:rx.UPDATE_OFFER_RESULT,timeout:uD,commandDesc:"update offer"}),{code:s,message:a}=o.data;0!==s&&this.checkPublishResultCode(s,a),yield this.acceptAnswer(o.data.data),i.sdp&&this.updateSSRC(i.sdp)}catch(cN){throw this._log.error(cN),cN}}))}setBandwidth(e){return cb(this,arguments,(function(e){var t=this;let{bandwidth:i,type:n,videoType:r,sdp:o}=e;return function*(){if(!Cw())return o?n===MN.VIDEO?t.updateVideoBandwidthRestriction(o,i,r):t.updateAudioBandwidthRestriction(o,i):void 0;let e=0;n===MN.VIDEO&&(e=r===MN.SMALL?2:r===MN.AUXILIARY?3:1);let s=t._peerConnection.getSenders()[e];if(s){let e=s.getParameters();(!e.encodings||0===e.encodings.length)&&(e.encodings=[{}]),e.encodings[0].maxBitrate=1e3*i;try{return yield s.setParameters(e),t._log.info("".concat(r||"").concat(n," bandwidth ").concat(i," kbps")),o}catch(c){if(t._log.info("failed to set bandwidth by setting maxBitrate: ".concat(c)),o)return n===MN.VIDEO?t.updateVideoBandwidthRestriction(o,i,r):t.updateAudioBandwidthRestriction(o,i)}}return o}()}))}updateVideoBandwidthRestriction(e,t,i){let n="AS";Fb&&(n="TIAS",t*=1e3);let r=0,o=-1;return i===MN.SMALL?r=1:i===MN.AUXILIARY&&(r=2),e.replace(/m=video (.*)\r\nc=IN (.*)\r\n/g,(e=>(o+=1,o===r?"".concat(e,"b=").concat(n,":").concat(t,"\r\n"):e)))}updateAudioBandwidthRestriction(e,t){let i="AS";return Fb&&(i="TIAS",t*=1e3),e.replace(/m=audio (.*)\r\nc=IN (.*)\r\n/,"m=audio $1\r\nc=IN $2\r\nb=".concat(i,":").concat(t,"\r\n"))}removeBandwidthRestriction(e){return e.replace(/b=AS:.*\r\n/,"").replace(/b=TIAS:.*\r\n/,"")}removeVideoOrientation(e){return e.replace(/urn:3gpp:video-orientation/,"")}connect(){return cb(this,null,(function*(){try{yield this.exchangeSDP(),yield this.waitForPeerConnectionConnected()}catch(aN){throw this.closePeerConnection(!0),this.uninstallEvents(),aN}}))}exchangeSDP(){return cb(this,null,(function*(){try{yield this.createOffer(),this._log.info("createOffer success, sending offer to remote server"),yield this.doExchangeSDP()}catch(aN){throw aN}}))}createOffer(){return cb(this,null,(function*(){try{let e=yield this._peerConnection.createOffer(Kx);yield this._peerConnection.setLocalDescription(e),e.sdp&&this.updateSSRC(e.sdp)}catch(aN){throw aN}}))}doExchangeSDP(){let e={command:dx,responseCommand:rx.PUBLISH_RESULT,data:{type:this._peerConnection.localDescription.type,sdp:this.removeVideoOrientation(this._peerConnection.localDescription.sdp),screen:this.localMainVideoTrack instanceof lL||this.localAuxVideoTrack instanceof lL,state:this.publishState,constraintConfig:this._mediaSettings},enableLog:!1};return this._log.debug("sending sdp offer: ".concat(e.data.sdp)),this._signalChannel.sendWaitForResponse(e).then((e=>{let{code:t,message:i,data:n}=e.data;return 0===t?this.acceptAnswer(n):this.checkPublishResultCode(t,i)}))}setSDPDirection(e,t){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"all",n=Hx(e);return n.media.forEach((e=>{("all"===i||e.type===i)&&(e.direction=t)})),jx(n)}acceptAnswer(e){return cb(this,null,(function*(){var t,i,n,r,o;try{let s;if(this._publishingLocalAudioTrack||this._publishingLocalVideoTrack||this.isMainStreamPublished){let e=(null==(t=this._publishingLocalVideoTrack)?void 0:t.profile.bitrate)||(null==(i=this.localMainVideoTrack)?void 0:i.profile.bitrate),o=(null==(n=this._publishingLocalAudioTrack)?void 0:n.profile.bitrate)||(null==(r=this.localMainAudioTrack)?void 0:r.profile.bitrate);if(e){let t=this._isPublishingAux?MN.AUXILIARY:MN.BIG;s=yield this.setBandwidth({bandwidth:e,type:MN.VIDEO,sdp:s,videoType:t})}o&&(s=yield this.setBandwidth({bandwidth:o,type:MN.AUDIO,sdp:s}))}if(s=this.removeVideoOrientation(e.sdp),null!=(o=this._publishingLocalVideoTrack)&&o.small){let{smallStreamConfig:e}=this._room;s=yield this.setBandwidth({bandwidth:this._publishingLocalVideoTrack.small.bitrate||e.bitrate,type:MN.VIDEO,videoType:MN.SMALL,sdp:s})}let a={type:e.type,sdp:s};yield this._peerConnection.setRemoteDescription(a),this._log.debug("accepted answer: ".concat(s))}catch(a){throw this._log.error("failed to accept remote answer ".concat(a)),a}}))}sendMutedFlag(e){var t,i,n;if(e===this.localAuxAudioTrack||e===this.localAuxVideoTrack)return;let r={audio:!(null==(t=this.localMainAudioTrack)||!t.muted),bigVideo:!(null==(i=this.localMainVideoTrack)||!i.muted),auxVideo:!(null==(n=this.localAuxVideoTrack)||!n.muted)};this._log.info("send muted state: ".concat(JSON.stringify(r))),this._signalChannel.send(lx,r)}getIsReconnecting(){return this._isReconnecting}reconnect(){return cb(this,null,(function*(){if(!(ab(qx.prototype,this,"beforeReconnect").call(this)<0))try{yield this._signalChannel.sendWaitForResponse({command:hx,responseCommand:rx.UNPUBLISH_RESULT,enableLog:!1}),this.closePeerConnection(),this.initialize(),this.isMainStreamPublished&&(yield this.publish({localAudioTrack:this.localMainAudioTrack,localVideoTrack:this.localMainVideoTrack,isAuxiliary:!1})),this.isAuxStreamPublished&&(yield this.publish({localAudioTrack:this.localAuxAudioTrack,localVideoTrack:this.localAuxVideoTrack,isAuxiliary:!0})),this._log.warn("reconnect() uplink reconnect successfully"),this.stopReconnection()}catch(aD){let t=tO(this._reconnectionCount);this._log.warn("reconnect() timeout, try again after ".concat(t/1e3,"s")),this._reconnectionTimer=setTimeout((()=>{this.clearReconnectionTimer(),this.reconnect()}),t)}}))}handleConnectionStateChange(e){"CONNECTED"===e.state&&(this.localMainVideoTrack||this._publishingLocalVideoTrack&&!this._isPublishingAux)&&UO.emit(BO.SEND_FIRST_VIDEO_FRAME,{room:this._room})}updateSSRC(e){try{Hx(e).media.forEach(((e,t)=>{if(e.type===MN.AUDIO){let t=e.ssrcs&&e.ssrcs[0];t&&(this.ssrc.audio=Number(t.id))}else{if(this._sdpSemantics===mD&&e.ssrcGroups)return void e.ssrcGroups.forEach(((e,t)=>{let i=Number(e.ssrcs.split(" ")[0]);0===t?this.ssrc.video=i:1===t&&(this.ssrc.small=i)}));let i=e.ssrcs&&e.ssrcs[0];if(!i)return;switch(t){case 1:this.ssrc.video=Number(i.id);break;case 2:this.ssrc.small=Number(i.id);break;case 3:this.ssrc.auxiliary=Number(i.id)}}}))}catch(aD){}}getVideoTrackId(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:MN.VIDEO;if(this._peerConnection){let t=this._peerConnection.getSenders();if(e===MN.AUXILIARY&&t[3]&&t[3].track)return t[3].track.id;if(e===MN.VIDEO&&t[1]&&t[1].track)return t[1].track.id}if(this.localMainVideoTrack&&e===MN.VIDEO){let e=this.localMainVideoTrack.mediaTrack;if(e)return e.id}if(this.localAuxVideoTrack&&e===MN.AUXILIARY){let e=this.localAuxVideoTrack.mediaTrack;if(e)return e.id}return""}getSSRC(){return this.ssrc}checkPublishResultCode(e,t){if(0!==e)throw e===_D?(this._log.error(KO.NOT_SUPPORTED_H264ENCODE),new Tb({code:fb.NOT_SUPPORTED_H264,message:QO({key:zO.NOT_SUPPORTED_H264ENCODE})})):new Tb({code:fb.UNKNOWN,message:QO({key:zO.SIGNAL_RESPONSE_FAILED,data:{signalResponse:rx.PUBLISH_RESULT,code:e,message:t}})})}sendSEI(e,t){var i;null==(i=this._sei)||i.push(e,t)}},Yx=qx;ob([nL((e=>function(){for(var t=arguments.length,i=new Array(t),n=0;n<t;n++)i[n]=arguments[n];return new Promise(((t,n)=>{let r=e=>{this._emitter.off("closed",r),n(new Tb({code:fb.API_CALL_ABORTED,message:QO({key:zO.CONNECTION_ABORTED,data:e})}))};this._emitter.on("closed",r),e.apply(this,i).then(t,n).finally((()=>{this._emitter.off("closed",r)}))}))}))],Yx.prototype,"publish",1),ob([iL(Fx.prototype.afterConnect),tL(Fx.prototype.beforeConnect)],Yx.prototype,"connect",1);var Qx=Yx,Xx=class{constructor(e,t){this.room=e,sb(this,"_log"),sb(this,"_prevReportTime"),sb(this,"_prevReport",{}),sb(this,"_prevEncoderImplementation"),sb(this,"_prevQualityLimitationReason"),sb(this,"_prevAuxQualityLimitationReason"),sb(this,"_prevDecoderImplementationMap",new Map),sb(this,"totalBytesSent",0),sb(this,"totalBytesReceived",0),sb(this,"_spcStats",null),this._log=t,this._prevReportTime=0,this._prevEncoderImplementation="",this._prevQualityLimitationReason="",this._prevAuxQualityLimitationReason=""}get statInterval(){return 0===this._prevReportTime?2:(Date.now()-this._prevReportTime)/1e3}getSenderStats(e){return cb(this,null,(function*(){let t={audio:{bytesSent:0,packetsSent:0,audioLevel:0,totalAudioEnergy:0},video:{bytesSent:0,packetsSent:0,framesEncoded:0,frameWidth:0,frameHeight:0,framesSent:0,fpsCapture:0},small:{bytesSent:0,packetsSent:0,framesEncoded:0,frameWidth:0,frameHeight:0,framesSent:0,fpsCapture:0},auxiliary:{bytesSent:0,packetsSent:0,framesEncoded:0,frameWidth:0,frameHeight:0,framesSent:0,fpsCapture:0},rtt:0},i=e.getPeerConnection(),n=e.getSSRC();if(i)try{if((this._spcStats||(yield i.getStats())).forEach((i=>{if("outbound-rtp"===i.type)if((i.mediaType||i.kind)===MN.VIDEO){let r,o;if(i.ssrc===n.video?(r=MN.VIDEO,o=e.localMainVideoTrack):i.ssrc===n.small?r=MN.SMALL:i.ssrc===n.auxiliary&&(o=e.localAuxVideoTrack,r=MN.AUXILIARY),!r)return;t[r].bytesSent=i.bytesSent,t[r].packetsSent=i.packetsSent,t[r].framesEncoded=i.framesEncoded,rO(i.keyFramesEncoded)||(t[r].keyFramesEncoded=i.keyFramesEncoded),rO(i.nackCount)||(t[r].nackCount=i.nackCount),rO(i.pliCount)||(t[r].pliCount=i.pliCount),rO(i.retransmittedPacketsSent)||(t[r].retransmittedPacketsSent=i.retransmittedPacketsSent),rO(i.totalEncodeTime)||(t[r].totalEncodeTime=i.totalEncodeTime),rO(i.totalPacketSendDelay)||(t[r].totalPacketSendDelay=i.totalPacketSendDelay),i.ssrc===n.video?(!rO(i.encoderImplementation)&&this._prevEncoderImplementation!==i.encoderImplementation&&(this._log.info("encoderImplementation change to ".concat(i.encoderImplementation)),this._prevEncoderImplementation=i.encoderImplementation),!rO(i.qualityLimitationReason)&&0!==i.bytesSent&&this._prevQualityLimitationReason!==i.qualityLimitationReason&&(this._log.info("qualityLimitationReason change to ".concat(i.qualityLimitationReason)),this._prevQualityLimitationReason=i.qualityLimitationReason)):i.ssrc===n.auxiliary&&!rO(i.qualityLimitationReason)&&0!==i.bytesSent&&this._prevAuxQualityLimitationReason!==i.qualityLimitationReason&&(this._log.info("aux qualityLimitationReason change to ".concat(i.qualityLimitationReason)),this._prevAuxQualityLimitationReason=i.qualityLimitationReason)}else t.audio.bytesSent=i.bytesSent,t.audio.packetsSent=i.packetsSent;else"candidate-pair"===i.type?hw(i)&&sO(i.currentRoundTripTime)&&(t.rtt=Math.floor(1e3*i.currentRoundTripTime),this.totalBytesSent=i.bytesSent):"media-source"===i.type&&(i.kind===MN.AUDIO?(t.audio.audioLevel=i.audioLevel||0,t.audio.totalAudioEnergy=i.totalAudioEnergy||0):i.kind===MN.VIDEO&&(i.trackIdentifier===e.getVideoTrackId(MN.VIDEO)?t.video.fpsCapture=i.framesPerSecond:i.trackIdentifier===e.getVideoTrackId(MN.AUXILIARY)?t.auxiliary.fpsCapture=i.framesPerSecond:t.small.fpsCapture=i.framesPerSecond));if(rO(i.audioLevel)||(t.audio.audioLevel=i.audioLevel||0),!rO(i.frameWidth)){let r=MN.SMALL;i.trackIdentifier===e.getVideoTrackId(MN.VIDEO)||i.ssrc===n.video?r=MN.VIDEO:(i.trackIdentifier===e.getVideoTrackId(MN.AUXILIARY)||i.ssrc===n.auxiliary)&&(r=MN.AUXILIARY),t[r].frameWidth=i.frameWidth,t[r].frameHeight=i.frameHeight,t[r].framesSent=i.framesSent}})),e.localMainAudioTrack){let i=e.localMainAudioTrack.getInternalAudioLevel();t.audio.micAudioLevel=i,0===t.audio.audioLevel&&(t.audio.audioLevel=i)}this.totalBytesSent||(this.totalBytesSent+=t.audio.bytesSent+t.video.bytesSent+t.auxiliary.bytesSent)}catch(o){this._log.warn("failed to getStats on sender connection ".concat(o))}return t}))}getReceiverStats(e){return cb(this,null,(function*(){let t={tinyId:e.tinyId,userId:e.userId,rtt:0,hasAudio:!1,hasVideo:!1,hasAuxiliary:!1,isSmallSubscribed:!1,audio:{bytesReceived:0,packetsReceived:0,packetsLost:0,jitter:0,audioLevel:0,totalAudioEnergy:0,insertedSamplesForDeceleration:0,removedSamplesForAcceleration:0},video:{bytesReceived:0,packetsReceived:0,packetsLost:0,framesReceived:0,framesDecoded:0,frameWidth:0,frameHeight:0,fpsDecoded:0},auxiliary:{bytesReceived:0,packetsReceived:0,packetsLost:0,framesReceived:0,framesDecoded:0,frameWidth:0,frameHeight:0,fpsDecoded:0}},i=e.getPeerConnection();if(i)try{let{ssrc:n}=e,{muteState:r,subscribeState:o}=e;(this._spcStats||(yield i.getStats())).forEach((i=>{if("inbound-rtp"===i.type)if((i.mediaType||i.kind)===MN.AUDIO){if(i.ssrc!==n.audio||!r.hasAudio)return;t.audio.packetsReceived=i.packetsReceived,t.audio.bytesReceived=i.bytesReceived,t.audio.packetsLost=i.packetsLost,i.insertedSamplesForDeceleration&&(t.audio.insertedSamplesForDeceleration=i.insertedSamplesForDeceleration),i.removedSamplesForAcceleration&&(t.audio.removedSamplesForAcceleration=i.removedSamplesForAcceleration);let{remoteAudioTrack:o}=e;o.stat.packetsReceived=i.packetsReceived,o.stat.bytesReceived=i.bytesReceived,o.stat.packetsLost=i.packetsLost,i.jitterBufferDelay&&(o.stat.jitterBufferDelay=Math.floor(i.jitterBufferDelay/i.jitterBufferEmittedCount*1e3)),t.hasAudio=!0}else{if(Fb&&0===i.bytesReceived)return;let s;i.ssrc===n.video&&r.hasVideo&&(t.video.packetsReceived=i.packetsReceived,t.video.bytesReceived=i.bytesReceived,t.video.packetsLost=i.packetsLost,t.video.framesReceived=i.framesReceived,t.video.framesDecoded=i.framesDecoded,t.video.fpsDecoded=i.framesPerSecond,t.hasVideo=!0,s=e.remoteVideoTrack,r.hasSmall&&o.smallVideo&&(t.isSmallSubscribed=!0),i.decoderImplementation&&(!this._prevDecoderImplementationMap.has(t.userId)||this._prevDecoderImplementationMap.get(t.userId)!==i.decoderImplementation)&&(this._log.info("".concat(t.userId," decoderImplementation change to ").concat(i.decoderImplementation)),this._prevDecoderImplementationMap.set(t.userId,i.decoderImplementation))),i.ssrc===n.auxiliary&&r.hasAuxiliary&&(t.auxiliary.packetsReceived=i.packetsReceived,t.auxiliary.bytesReceived=i.bytesReceived,t.auxiliary.packetsLost=i.packetsLost,t.auxiliary.framesReceived=i.framesReceived,t.auxiliary.framesDecoded=i.framesDecoded,t.auxiliary.fpsDecoded=i.framesPerSecond,s=e.remoteAuxiliaryTrack,t.hasAuxiliary=!0),s&&(s.stat.packetsReceived=i.packetsReceived,s.stat.bytesReceived=i.bytesReceived,s.stat.packetsLost=i.packetsLost,s.stat.framesReceived=i.framesReceived,s.stat.framesDecoded=i.framesDecoded,i.jitterBufferDelay&&(s.stat.jitterBufferDelay=Math.floor(i.jitterBufferDelay/i.jitterBufferEmittedCount*1e3)))}else"candidate-pair"===i.type&&hw(i)&&sO(i.currentRoundTripTime)&&(t.rtt=Math.floor(1e3*i.currentRoundTripTime),this.totalBytesReceived=i.bytesReceived);rO(i.frameWidth)||((i.trackIdentifier===e.getMainStreamVideoTrackId()||i.ssrc===n.video)&&(t.video.frameWidth=i.frameWidth,t.video.frameHeight=i.frameHeight,e.remoteVideoTrack.stat.frameWidth=i.frameWidth,e.remoteVideoTrack.stat.frameHeight=i.frameHeight),(i.trackIdentifier===e.getAuxStreamVideoTrackId()||i.ssrc===n.auxiliary)&&(t.auxiliary.frameWidth=i.frameWidth,t.auxiliary.frameHeight=i.frameHeight,e.remoteAuxiliaryTrack.stat.frameWidth=i.frameWidth,e.remoteAuxiliaryTrack.stat.frameHeight=i.frameHeight)),rO(i.audioLevel)||(t.audio.audioLevel=i.audioLevel||0,t.audio.totalAudioEnergy=i.totalAudioEnergy||0)})),0===t.audio.audioLevel&&(t.audio.audioLevel=e.remoteAudioTrack.getInternalAudioLevel()||0),this.totalBytesReceived||(this.totalBytesReceived+=t.audio.bytesReceived+t.video.bytesReceived+t.auxiliary.bytesReceived)}catch(cN){this._log.warn("failed to getStats on receiver connection ".concat(cN))}return t}))}getStats(e,t){return cb(this,null,(function*(){let i={},n=[];if(this.room.singlePC){let e=this.room.singlePC.getPeerConnection();if(!e)return{senderStats:i,receiverStats:n};let t=yield e.getStats(),r=[],o=new Set(["inbound-rtp","outbound-rtp","track","candidate-pair","media-source"]);t.forEach((e=>o.has(e.type)&&r.push(e))),this._spcStats=r}e&&(i=yield this.getSenderStats(e));for(let[e,r]of t){let e=yield this.getReceiverStats(r);n.push(e)}return{senderStats:i,receiverStats:n}}))}getDifferenceValue(e,t){if(UP(e))return t;let i=t-e;return i<0?0:i}prepareReport(e){let{stats:t,report:i,freezeMap:n}=e;if(!UP(t.senderStats)){let e={uint32_audio_level:t.senderStats.audio.audioLevel*UD,uint32_audio_energy:1e6*t.senderStats.audio.totalAudioEnergy,uint32_audio_codec_bitrate:t.senderStats.audio.bytesSent};t.senderStats.audio.micAudioLevel&&(e.uint32_mic_audio_level=t.senderStats.audio.micAudioLevel*UD);let n=[];if(t.senderStats.video.bytesSent){let e={uint32_video_stream_type:2,uint32_video_codec_fps:t.senderStats.video.framesSent,uint32_video_capture_fps:t.senderStats.video.fpsCapture,uint32_video_width:t.senderStats.video.frameWidth,uint32_video_height:t.senderStats.video.frameHeight,uint32_video_codec_bitrate:t.senderStats.video.bytesSent,uint32_video_enc_fps:t.senderStats.video.framesEncoded,uint32_key_frame_count:t.senderStats.video.keyFramesEncoded,uint32_nack_count:t.senderStats.video.nackCount,uint32_pli_count:t.senderStats.video.pliCount,uint32_encode_cost:1e3*(t.senderStats.video.totalEncodeTime||0),uint32_send_packet_cost:1e3*(t.senderStats.video.totalPacketSendDelay||0),uint32_video_arq_packets:t.senderStats.video.retransmittedPacketsSent};n.push(e)}if(t.senderStats.small.bytesSent){let e={uint32_video_stream_type:3,uint32_video_codec_fps:t.senderStats.small.framesSent||0,uint32_video_capture_fps:t.senderStats.small.fpsCapture||0,uint32_video_width:t.senderStats.small.frameWidth||0,uint32_video_height:t.senderStats.small.frameHeight||0,uint32_video_codec_bitrate:t.senderStats.small.bytesSent,uint32_video_enc_fps:t.senderStats.small.framesEncoded||0,uint32_key_frame_count:t.senderStats.small.keyFramesEncoded,uint32_nack_count:t.senderStats.small.nackCount,uint32_pli_count:t.senderStats.small.pliCount,uint32_encode_cost:1e3*(t.senderStats.small.totalEncodeTime||0),uint32_send_packet_cost:1e3*(t.senderStats.small.totalPacketSendDelay||0),uint32_video_arq_packets:t.senderStats.small.retransmittedPacketsSent};n.push(e)}if(t.senderStats.auxiliary.bytesSent){let e={uint32_video_stream_type:7,uint32_video_codec_fps:t.senderStats.auxiliary.framesSent||0,uint32_video_capture_fps:t.senderStats.auxiliary.fpsCapture||0,uint32_video_width:t.senderStats.auxiliary.frameWidth||0,uint32_video_height:t.senderStats.auxiliary.frameHeight||0,uint32_video_codec_bitrate:t.senderStats.auxiliary.bytesSent,uint32_video_enc_fps:t.senderStats.auxiliary.framesEncoded||0,uint32_key_frame_count:t.senderStats.auxiliary.keyFramesEncoded,uint32_nack_count:t.senderStats.auxiliary.nackCount,uint32_pli_count:t.senderStats.auxiliary.pliCount,uint32_encode_cost:1e3*(t.senderStats.auxiliary.totalEncodeTime||0),uint32_send_packet_cost:1e3*(t.senderStats.auxiliary.totalPacketSendDelay||0),uint32_video_arq_packets:t.senderStats.auxiliary.retransmittedPacketsSent};n.push(e)}let r={uint32_bitrate:0,uint32_lost:0,uint32_rtt:t.senderStats.rtt};i.msg_up_stream_info={msg_audio_status:e,msg_video_status:n,msg_network_status:r}}let{statInterval:r}=this;i.msg_down_stream_info=[],t.receiverStats.forEach((e=>{let t={msg_user_info:{str_identifier:e.userId,uint64_tinyid:e.tinyId},msg_network_status:{uint32_rtt:e.rtt,uint32_bitrate:0,uint32_lost:0},msg_audio_status:{},msg_video_status:[]};if(e.hasAudio){let i={uint32_audio_codec_bitrate:e.audio.bytesReceived,uint32_audio_total_bitrate:e.audio.bytesReceived,uint32_audio_level:1e8*e.audio.audioLevel,uint32_audio_energy:1e6*e.audio.totalAudioEnergy,uint32_audio_receive:e.audio.packetsReceived,uint32_audio_origin_lost:e.audio.packetsLost};t.msg_audio_status=i}if(e.hasVideo){let i=n.get("".concat(e.userId,"_").concat(KN)),r=i?i.duration:0,o={uint32_video_stream_type:e.isSmallSubscribed?3:2,uint32_video_receive_fps:e.video.framesReceived,uint32_video_width:e.video.frameWidth,uint32_video_height:e.video.frameHeight,uint32_video_codec_bitrate:e.video.bytesReceived,uint32_video_receive:e.video.packetsReceived,uint32_video_origin_lost:e.video.packetsLost,uint32_video_block_time:r,uint32_video_dec_fps:e.video.framesDecoded};t.msg_video_status.push(o)}if(e.hasAuxiliary){let i=n.get("".concat(e.userId,"_").concat(qN)),r=i?i.duration:0,o={uint32_video_stream_type:7,uint32_video_receive_fps:e.auxiliary.framesReceived,uint32_video_width:e.auxiliary.frameWidth,uint32_video_height:e.auxiliary.frameHeight,uint32_video_codec_bitrate:e.auxiliary.bytesReceived,uint32_video_receive:e.auxiliary.packetsReceived+e.auxiliary.packetsLost,uint32_video_origin_lost:e.auxiliary.packetsLost,uint32_video_block_time:r,uint32_video_dec_fps:e.auxiliary.framesDecoded};t.msg_video_status.push(o)}i.msg_down_stream_info.push(t)}));let o=this._prevReport;if(this._prevReport=JSON.parse(JSON.stringify(i)),i.msg_up_stream_info.msg_audio_status&&o.msg_up_stream_info.msg_audio_status){let e=o.msg_up_stream_info.msg_audio_status,t=i.msg_up_stream_info.msg_audio_status;if(0===e.uint32_audio_codec_bitrate)t.uint32_audio_codec_bitrate=0;else{let n=this.getDifferenceValue(e.uint32_audio_codec_bitrate,t.uint32_audio_codec_bitrate);t.uint32_audio_codec_bitrate=Math.round(8*n/r),i.msg_up_stream_info.msg_network_status.uint32_bitrate+=t.uint32_audio_codec_bitrate}}let s=o.msg_up_stream_info.msg_video_status;i.msg_up_stream_info.msg_video_status.forEach((e=>{let t=s.find((t=>t.uint32_video_stream_type===e.uint32_video_stream_type));if(!t||0===t.uint32_video_codec_bitrate)return e.uint32_video_codec_bitrate=0,e.uint32_video_enc_fps=0,void(e.uint32_video_codec_fps=0);let n=0,o=0,a=0;t&&e.uint32_video_codec_bitrate>=t.uint32_video_codec_bitrate&&(n=t.uint32_video_codec_bitrate,o=t.uint32_video_enc_fps,a=t.uint32_video_codec_fps);let c=this.getDifferenceValue(n,e.uint32_video_codec_bitrate);e.uint32_video_codec_bitrate=Math.round(8*c/r),i.msg_up_stream_info.msg_network_status.uint32_bitrate+=e.uint32_video_codec_bitrate,e.uint32_video_enc_fps=Math.round(this.getDifferenceValue(o,e.uint32_video_enc_fps)/r),e.uint32_video_codec_fps=Math.round(this.getDifferenceValue(a,e.uint32_video_codec_fps)/r),_k&&115===Pk()&&0===t.uint32_video_width&&0===t.uint32_video_height&&0===t.uint32_video_codec_fps&&(e.uint32_video_codec_fps=e.uint32_video_enc_fps),rO(t.uint32_key_frame_count)||(e.uint32_key_frame_count=Math.round(this.getDifferenceValue(t.uint32_key_frame_count,e.uint32_key_frame_count))),rO(t.uint32_nack_count)||(e.uint32_nack_count=Math.round(this.getDifferenceValue(t.uint32_nack_count,e.uint32_nack_count))),rO(t.uint32_pli_count)||(e.uint32_pli_count=Math.round(this.getDifferenceValue(t.uint32_pli_count,e.uint32_pli_count))),rO(t.uint32_video_arq_packets)||(e.uint32_video_arq_packets=Math.round(this.getDifferenceValue(t.uint32_video_arq_packets,e.uint32_video_arq_packets))),rO(t.uint32_encode_cost)||(e.uint32_encode_cost=Math.round(this.getDifferenceValue(t.uint32_encode_cost,e.uint32_encode_cost)/r)),rO(t.uint32_send_packet_cost)||(e.uint32_send_packet_cost=Math.round(this.getDifferenceValue(t.uint32_send_packet_cost,e.uint32_send_packet_cost)/r))}));let a=i.msg_down_stream_info,c=o.msg_down_stream_info;return a.forEach((e=>{let t=c.find((t=>t.msg_user_info.uint64_tinyid===e.msg_user_info.uint64_tinyid));if(t){if(UP(e.msg_audio_status)||UP(t.msg_audio_status))e.msg_audio_status={};else{let i=e.msg_audio_status,n=t.msg_audio_status;i.uint32_audio_origin_lost=this.getDifferenceValue(n.uint32_audio_origin_lost,i.uint32_audio_origin_lost),i.uint32_audio_receive=this.getDifferenceValue(n.uint32_audio_receive,i.uint32_audio_receive),i.uint32_audio_receive+=i.uint32_audio_origin_lost;let o=this.getDifferenceValue(n.uint32_audio_codec_bitrate,i.uint32_audio_codec_bitrate);i.uint32_audio_codec_bitrate=Math.round(8*o/r),i.uint32_audio_total_bitrate=Math.round(8*o/r)}if(e.msg_video_status&&t.msg_video_status){let i=t.msg_video_status;e.msg_video_status=e.msg_video_status.filter((e=>i.find((t=>t.uint32_video_stream_type===e.uint32_video_stream_type)))),e.msg_video_status.forEach((e=>{let t=i.find((t=>t.uint32_video_stream_type===e.uint32_video_stream_type)),n=t.uint32_video_receive,o=t.uint32_video_origin_lost,s=t.uint32_video_codec_bitrate,a=t.uint32_video_receive_fps,c=t.uint32_video_dec_fps;e.uint32_video_origin_lost=this.getDifferenceValue(o,e.uint32_video_origin_lost),e.uint32_video_receive=this.getDifferenceValue(n,e.uint32_video_receive)+e.uint32_video_origin_lost;let l=this.getDifferenceValue(s,e.uint32_video_codec_bitrate);e.uint32_video_codec_bitrate=Math.round(8*l/r);let d=this.getDifferenceValue(a,e.uint32_video_receive_fps);e.uint32_video_receive_fps=Math.round(d/r),e.uint32_video_dec_fps=Math.round(this.getDifferenceValue(c,e.uint32_video_dec_fps)/r)}))}}})),i}getStatsReport(e){return cb(this,arguments,(function(e){var t=this;let{uplinkConnection:i,downlinkConnections:n,freezeMap:r}=e;return function*(){let e={msg_up_stream_info:{msg_audio_status:{uint32_audio_format:11,uint32_audio_sample_rate:0,uint32_audio_codec_bitrate:0,uint32_audio_receive:0,uint32_audio_origin_lost:0,uint32_audio_level:0,uint32_audio_energy:0},msg_video_status:[],msg_network_status:{uint32_bitrate:0,uint32_rtt:0,uint32_lost:0}},msg_down_stream_info:[{msg_user_info:{str_identifier:"",uint64_tinyid:0},msg_audio_status:{uint32_audio_format:11,uint32_audio_sample_rate:0,uint32_audio_codec_bitrate:0,uint32_audio_total_bitrate:0,uint32_audio_level:0,uint32_audio_energy:0,uint32_audio_receive:0,uint32_audio_origin_lost:0,uint32_audio_final_lost:0},msg_video_status:[{uint32_video_stream_type:0,uint32_video_receive_fps:0,uint32_video_width:0,uint32_video_height:0,uint32_video_codec_bitrate:0,uint32_video_receive:0,uint32_video_origin_lost:0,uint32_video_block_time:0,uint32_video_dec_fps:0}],msg_network_status:{uint32_bitrate:0,uint32_rtt:0,uint32_lost:0}}]},o=yield t.getStats(i,n);return"{}"===JSON.stringify(t._prevReport)&&(t._prevReport=JSON.parse(JSON.stringify(e))),t.prepareReport({stats:o,report:e,freezeMap:r}),t._prevReportTime=Date.now(),e}()}))}reset(){this._prevReportTime=0,this._prevReport={},this._prevEncoderImplementation="",this._prevQualityLimitationReason="",this._prevDecoderImplementationMap=new Map}},$x=rb(lb()),Zx=class extends $x.default{constructor(e){let{signalChannel:t,room:i}=e;super(),sb(this,"_room"),sb(this,"_signalChannel"),sb(this,"_log"),sb(this,"_uplinkRTT",0),sb(this,"_uplinkLoss",0),sb(this,"_downlinkRTT",0),sb(this,"_downlinkLoss",0),sb(this,"_downlinkPrevStatMap",new Map),sb(this,"_downlinkLossAndRTTMap",new Map),sb(this,"_interval",-1),sb(this,"_uplinkNetworkQuality",0),sb(this,"_downlinkNetworkQuality",0),this._room=i,this._signalChannel=t,this._log=jO.createLogger({id:"q",userId:this._room.userId,sdkAppId:this._room.sdkAppId}),this.initialize()}get uplinkNetworkQuality(){return this._uplinkNetworkQuality}set uplinkNetworkQuality(e){e!==this._uplinkNetworkQuality&&this._log.info("uplink ".concat(this.uplinkNetworkQuality," -> ").concat(e,", rtt: ").concat(this._uplinkRTT,", loss: ").concat(this._uplinkLoss)),this._uplinkNetworkQuality=e}get downlinkNetworkQuality(){return this._downlinkNetworkQuality}set downlinkNetworkQuality(e){if(e!==this._downlinkNetworkQuality){let{rtt:t,loss:i}=this.getAverageLossAndRTT([...this._downlinkLossAndRTTMap.values()]);this._log.info("downlink ".concat(this.downlinkNetworkQuality," -> ").concat(e,", rtt: ").concat(t,", loss: ").concat(i))}this._downlinkNetworkQuality=e}initialize(){this._signalChannel.on(rx.UPLINK_NETWORK_STATS,(e=>{this.handleUplinkNetworkQuality(e)})),this._signalChannel.on(QM,this.handleSignalConnectionStateChange.bind(this)),this.start()}handleUplinkNetworkQuality(e){var t,i;if(0!==e.data.code)return;let n=e.data.data;if(n.delay&&this.updateDelay(n.delay),!this._room.uplinkConnection)return this.uplinkNetworkQuality=0,this._uplinkLoss=0,void(this._uplinkRTT=0);let r=null==(i=null==(t=this._room)?void 0:t.uplinkConnection)?void 0:i.getPeerConnection();if(r&&this.isPeerConnectionDisconnected(r))return this.uplinkNetworkQuality=6,this._uplinkLoss=0,void(this._uplinkRTT=0);let o=n.expectAudPkg+n.expectVidPkg,s=n.recvAudPkg+n.recvVidPkg,a=o-s;0===o&&0===s||(this._uplinkLoss=a<=0?0:Math.round(a/o*100),this._uplinkRTT=n.rtt,this.uplinkNetworkQuality=this.getNetworkQuality(this._uplinkLoss,this._uplinkRTT))}handleDownlinkNetworkQuality(){return cb(this,null,(function*(){if(0===this._room.remotePublishedUserMap.size)return void(this.downlinkNetworkQuality=0);let e=[...this._room.remotePublishedUserMap.values()],t=e.filter((e=>{var t;return(null==(t=e.getPeerConnection())?void 0:t.connectionState)===nD.CONNECTED}));if(e.filter((e=>this.isPeerConnectionDisconnected(e.getPeerConnection()))).length===e.length)return void(this.downlinkNetworkQuality=6);for(let r=0;r<t.length;r++){let e=t[r].getPeerConnection();if(!e)return;let{rtt:i,totalPacketsLost:n,totalPacketsReceived:o}=yield this.getStat(e);if(!this._downlinkPrevStatMap.has(e)){this._downlinkPrevStatMap.set(e,{totalPacketsLost:n,totalPacketsReceived:o});continue}let s=0,a=this._downlinkPrevStatMap.get(e),c=n-a.totalPacketsLost,l=o-a.totalPacketsReceived;s=c<=0||l<0?0:Math.round(c/(c+l)*100),this._downlinkPrevStatMap.set(e,{totalPacketsLost:n,totalPacketsReceived:o}),this._downlinkLossAndRTTMap.set(e,{rtt:i,loss:s,userId:t[r].getUserId(),audioDelay:t[r].remoteAudioTrack.stat.end2EndDelay,videoDelay:t[r].remoteVideoTrack.stat.end2EndDelay})}if([...this._downlinkPrevStatMap.keys()].forEach((e=>{this.isPeerConnectionDisconnected(e)&&(this._downlinkPrevStatMap.delete(e),this._downlinkLossAndRTTMap.delete(e))})),0===this._downlinkLossAndRTTMap.size)return;let{rtt:i,loss:n}=this.getAverageLossAndRTT([...this._downlinkLossAndRTTMap.values()]);this._downlinkRTT=i,this._downlinkLoss=n,this.downlinkNetworkQuality=this.getNetworkQuality(n,i)}))}getStat(e){return cb(this,null,(function*(){let t={rtt:0,totalPacketsLost:0,totalPacketsReceived:0};if(!e||!Ew())return t;let i=e.getReceivers();try{for(let e=0;e<i.length;e++)(yield i[e].getStats()).forEach((e=>{"candidate-pair"===e.type&&sO(e.currentRoundTripTime)&&(t.rtt=Math.round(1e3*e.currentRoundTripTime)),"inbound-rtp"===e.type&&(e.mediaType===MN.AUDIO||e.mediaType===MN.VIDEO)&&(t.totalPacketsLost+=e.packetsLost,t.totalPacketsReceived+=e.packetsReceived)}));return t}catch(r){return t}}))}getAverageLossAndRTT(e){let t={rtt:0,loss:0};return Array.isArray(e)&&e.length>0&&(e.forEach((e=>{t.rtt+=e.rtt,t.loss+=e.loss})),Object.keys(t).forEach((i=>{t[i]=Math.round(t[i]/e.length)}))),t}getNetworkQuality(e,t){return e>50||t>500?5:e>30||t>350?4:e>20||t>200?3:e>10||t>100?2:e>=0||t>=0?1:0}handleSignalConnectionStateChange(e){e.state===ZM?(this._uplinkRTT=0,this._uplinkLoss=0,this.uplinkNetworkQuality=6):e.state===tx&&6===this.uplinkNetworkQuality&&(this.uplinkNetworkQuality=5)}handleUplinkConnectionStateChange(e){let{state:t}=e;"DISCONNECTED"===t?(this._uplinkLoss=0,this._uplinkRTT=0,this.uplinkNetworkQuality=6):"CONNECTED"===t&&6===this.uplinkNetworkQuality&&(this.uplinkNetworkQuality=5)}isPeerConnectionDisconnected(e){return!(!e||e.connectionState!==nD.DISCONNECTED&&e.connectionState!==nD.FAILED&&e.connectionState!==nD.CLOSED)}setUplinkConnection(e){this._room.uplinkConnection=e,this._room.uplinkConnection?this._room.uplinkConnection.on("connection-state-changed",this.handleUplinkConnectionStateChange.bind(this)):(this.uplinkNetworkQuality=0,this._uplinkRTT=0,this._uplinkLoss=0)}start(){-1===this._interval?(this._log.debug("start network quality calculating"),this._interval=Yw.run(PD,(()=>{this.handleDownlinkNetworkQuality();let e=[...this._downlinkLossAndRTTMap.values()];UO.emit(BO.NETWORK_QUALITY,{room:this._room,uplink:{rtt:this._uplinkRTT,loss:this._uplinkLoss},downlinks:e}),this.emit(Zx.EVENT_NETWORK_QUALITY,{uplinkNetworkQuality:this.uplinkNetworkQuality,downlinkNetworkQuality:this.downlinkNetworkQuality,uplinkRTT:this._uplinkRTT,uplinkLoss:this._uplinkLoss,downlinkRTT:this._downlinkRTT,downlinkLoss:this._downlinkLoss,downlinkInfo:e})}),{delay:2e3})):this._log.info("network quality calculating is already started")}stop(){this._log.debug("stopped"),-1!==this._interval&&(Yw.clearTask(this._interval),this._interval=-1),this._downlinkLossAndRTTMap.clear(),this._downlinkPrevStatMap.clear()}updateDelay(e){let{tinyIdToUserIdMap:t}=this._room;e.forEach((e=>{let{srcTinyId:i,videoDelay:n,audioDelay:r}=e,o=t.get(i);if(o){let e=this._room.remotePublishedUserMap.get(o);null==e||e.setDelay({videoDelay:n,audioDelay:r})}}))}},eV=Zx;sb(eV,"EVENT_NETWORK_QUALITY","0");var tV=new WeakMap;function iV(e){let{settings:t={retries:5,timeout:2e3},onError:i,onRetrying:n,onRetryFailed:r}=e;return function(e,o,s){let a=xO({retryFunction:s.value,settings:t,onError(t){let{error:n,retry:r,reject:s,retryFuncArgs:a}=t;i&&i.call(this,n,(()=>{var t;null!=(t=tV.get(e))&&t.has(o)?r():s(n)}),s,a)},onRetrying:(t,i)=>{var r;nO(n)&&n(t,i),null!=(r=tV.get(e))&&r.has(o)&&(tV.get(e).get(o).stopRetry=i)},onRetryFailed:r});return s.value=function(){let t=tV.get(e);for(var i=arguments.length,n=new Array(i),r=0;r<i;r++)n[r]=arguments[r];return t?t.set(o,{args:n}):tV.set(e,new Map([[o,{args:n}]])),a.apply(this,n).finally((()=>{var t;return null==(t=tV.get(e))?void 0:t.delete(o)}))},s}}function nV(e){let{fnName:t,callback:i,validateArgs:n=!0}=e;return function(e,r,o){let s=o.value;return o.value=function(){for(var r,o,a=arguments.length,c=new Array(a),l=0;l<a;l++)c[l]=arguments[l];if(null!=(r=tV.get(e))&&r.has(t)){let{stopRetry:r,args:s}=tV.get(e).get(t),a=!0;if(n)for(let e of s)if(!c.find((t=>t===e))){a=!1;break}a&&(i&&i.apply(this,c),r&&r(),null==(o=tV.get(e))||o.delete(t))}return s.apply(this,c)},o}}var rV=class{constructor(e){this._signalInfo={tinyId:void 0,clientIp:"",signalIp:"",relayIp:"",relayInnerIp:"",relayPort:0},this._apiSuccessRateMap=new Map,this._eventMap=new Map,this._frameWorkType=e.frameWorkType||30,this._component=e.component||0,this.connectionType=e.connectionType||1,this._language=e.language||0,this._room=e.room,this._keyPrefix="key_point",this._log=jO.createLogger({id:"kpm",userId:this._room.userId,sdkAppId:this._room.sdkAppId}),Object.getOwnPropertyNames(this.__proto__).forEach((e=>{e.startsWith("handle")&&nO(this[e])&&(this[e]=function(e){let{fn:t,context:i}=e;return function(){try{for(var e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];let o=t.apply(i,n);return hO(o)?o.catch((e=>jO.error("".concat(t.name,"() error observed ").concat(e)))):o}catch(aD){jO.error("".concat(t.name,"() error observed ").concat(aD))}}}({fn:this[e],context:this}))})),this.initData(),this.installEvents(),this._intervalId=Yw.run(PD,this.setStorage.bind(this),{delay:2e4})}get _storageKey(){return"".concat(this._keyPrefix,"_").concat(this._room.userId)}initData(){this._firstPublishedUserList=[],this._networkQuality={totalUplinkRTT:0,totalUplinkLoss:0,count:0,totalDownlinkRTTAndLossMap:new Map},this._basicInfo={string_sdk_version:oN,uint32_os_type:15,string_device_name:"",string_http_user_agent:navigator.userAgent,string_os_version:"",uint32_avg_rtt:0,uint32_avg_up_loss:0,uint32_scene:"live"===this._room.scene?1:0,uint32_joining_duration:0,uint32_networkType:NN[WD()],uint32_framework:this._frameWorkType,uint32_component:this._component,uint32_connection_type:this.connectionType,uint32_caller_coding_language:this._language,string_domain:location.hostname},this._pathJoinRoom={uint64_start_time:0,uint64_send_request_acc_ip_cmd_start_time:0,uint64_send_request_acc_ip_cmd_end_time:0,uint64_send_request_enter_room_cmd_start_time:0,uint64_send_request_enter_room_cmd_end_time:0,uint64_send_first_video_frame_time:0,uint64_recv_userlist_time:0,uint64_end_time:0,int32_send_request_acc_ip_cmd_ret:0,int32_send_request_enter_room_cmd_ret:0,int32_end_ret:0},this._pathLeaveRoom={uint64_start_time:0,uint64_send_request_exit_room_cmd_start_time:0,uint64_send_request_exit_room_cmd_end_time:0,uint64_end_time:0,int32_send_request_exit_room_cmd_ret:0,int32_end_ret:0},this._localStreamStat={totalVideoBitrate:0,totalVideoFPS:0,totalVideoHeight:0,totalVideoWidth:0,totalAudioLevel:0,videoCount:0,audioLevelCount:0,publishStartTime:0,statsToReport:{uint32_audio_capture_db:0,uint32_video_big_capture_fps:0,uint32_video_big_bitrate:0,uint32_video_big_resolution:0}},this._pathMainVideoMap=new Map,this._pathMainAudioMap=new Map,this._pathAuxiliaryMap=new Map,this._remoteStreamStatMap=new Map,this._apiSuccessRateMap.clear(),Zk().then((e=>{this._basicInfo.string_os_version=iN(),e&&(this._basicInfo.string_device_name=e.model)}))}addEvent(e,t){return this._eventMap.set(e,t),UO.on(e,t),this}installEvents(){this.handleUnload=this.handleUnload.bind(this),window.addEventListener("unload",this.handleUnload),this._room.once("banned",(()=>this.handleLeaveSuccess({room:this._room,roomId:this._room.roomId}))),this.addEvent(BO.JOIN_START,this.handleJoinStart).addEvent(BO.JOIN_SCHEDULE_SUCCESS,this.handleJoinScheduleSuccess).addEvent(BO.JOIN_SIGNAL_CONNECTION_START,this.handleSignalConnectionStart).addEvent(BO.JOIN_SIGNAL_CONNECTION_END,this.handleSignalConnectionEnd).addEvent(BO.JOIN_SEND_CMD,this.handleJoinSendCMD).addEvent(BO.JOIN_RECEIVED_CMD_RES,this.handleJoinReceivedCMDResponce).addEvent(BO.JOIN_SUCCESS,this.handleJoinSuccess).addEvent(BO.JOIN_FAILED,this.handleJoinFailed).addEvent(BO.LEAVE_START,this.handleLeaveStart).addEvent(BO.LEAVE_SUCCESS,this.handleLeaveSuccess).addEvent(BO.LEAVE_SEND_CMD,this.handleLeaveSendCMD).addEvent(BO.LOCAL_TRACK_CAPTURE_START,this.handleTrackCaptureStart).addEvent(BO.LOCAL_TRACK_CAPTURE_SUCCESS,this.handleTrackCaptureSuccess).addEvent(BO.LOCAL_TRACK_CAPTURE_FAILED,this.handleTrackCaptureFailed).addEvent(BO.PUBLISH_START,this.handlePublishStart).addEvent(BO.SEND_FIRST_VIDEO_FRAME,this.handleSendFirstVideoFrame).addEvent(BO.SUBSCRIBE_START,this.handleSubscribeStart).addEvent(BO.SUBSCRIBE_SUCCESS,this.handleSubscribed).addEvent(BO.PLAY_TRACK_START,this.handlePlayStart).addEvent(BO.VIDEO_LOADED_DATA,this.handleVideoLoadedData).addEvent(BO.PLAYER_STATE_CHANGED,(e=>{let{track:t,state:i,type:n}=e;!uO(t)||!this.hitTest(t.room)||"PLAYING"===i&&(n===MN.AUDIO?this.handleAudioPlaying(t):this.handleVideoPlaying(t))})).addEvent(BO.NETWORK_QUALITY,this.handleNetworkQuality).addEvent(BO.HEARTBEAT_REPORT,this.handleHeartbeatStats).addEvent(BO.RECEIVED_PUBLISHED_USER_LIST,this.handleReceivedPublishUserList).addEvent(BO.REMOTE_PUBLISH_STATE_CHANGED,(e=>{let{room:t,prevMuteState:i,muteState:n}=e;if(!this.hitTest(t))return;let r=i.hasAudio||i.hasVideo||i.hasSmall,o=i.hasAuxiliary,s=n.hasAudio||n.hasVideo||n.hasSmall,a=n.hasAuxiliary;!r&&s&&this.handleRemoteStreamAdded(n.userId,"main"),!o&&a&&this.handleRemoteStreamAdded(n.userId,"auxiliary")})).addEvent(BO.API_SUCCESS_RATE,this.handleAPISuccessRate).addEvent(BO.SINGLE_CONNECTION_STAT,(e=>{let{room:t,stat:i}=e;this.hitTest(t)&&(this._pathJoinRoom.int32_ice_cost=i.ice,this._pathJoinRoom.int32_dtls_cost=i.dtls,this._pathJoinRoom.int32_peer_connection_cost=i.peerConnection)}))}uninstallEvents(){window.removeEventListener("unload",this.handleUnload),this._eventMap.forEach(((e,t)=>UO.off(t,e))),this._eventMap.clear()}destroy(){this.uninstallEvents(),Yw.clearTask(this._intervalId)}handleUnload(){this._room.isJoined&&this.handleLeaveSuccess({room:this._room,roomId:this._room.roomId})}handleJoinStart(e){this.hitTest(e.room)&&(0===this._pathJoinRoom.uint64_start_time&&(this._pathJoinRoom.uint64_start_time=Date.now(),this.checkStorage()),e.params&&(rO(e.params.frameWorkType)||(this._frameWorkType=e.params.frameWorkType,this._basicInfo.uint32_framework=this._frameWorkType),rO(e.params.component)||(this._component=e.params.component,this._basicInfo.uint32_component=this._component),rO(e.params.language)||(this._language=e.params.language,this._basicInfo.uint32_caller_coding_language=this._language)))}handleJoinScheduleSuccess(e){let{room:t,detailCost:i}=e;if(this.hitTest(t)&&i){let{totalCost:e,local:t,dns:n,tcp:r,tls:o,request:s,response:a}=i;this._pathJoinRoom.int32_schedule_cost=e,this._pathJoinRoom.int32_schedule_local=t,this._pathJoinRoom.int32_schedule_dns=n,this._pathJoinRoom.int32_schedule_tcp=r,this._pathJoinRoom.int32_schedule_tls=o,this._pathJoinRoom.int32_schedule_request=s,this._pathJoinRoom.int32_schedule_response=a}}handleSignalConnectionStart(e){let{room:t}=e;this.hitTest(t)&&0===this._pathJoinRoom.uint64_send_request_acc_ip_cmd_start_time&&(this._pathJoinRoom.uint64_send_request_acc_ip_cmd_start_time=Date.now())}handleSignalConnectionEnd(e){let{room:t,error:i}=e;this.hitTest(t)&&0===this._pathJoinRoom.uint64_send_request_acc_ip_cmd_end_time&&(this._pathJoinRoom.uint64_send_request_acc_ip_cmd_end_time=Date.now(),i&&(this._pathJoinRoom.int32_send_request_acc_ip_cmd_ret=i instanceof Tb?Number(i.getExtraCode()||i.getCode()):fb.UNKNOWN,this._pathJoinRoom.int32_end_ret=this._pathJoinRoom.int32_send_request_acc_ip_cmd_ret))}handleJoinSendCMD(e){this.hitTest(e.room)&&0===this._pathJoinRoom.uint64_send_request_enter_room_cmd_start_time&&(this._pathJoinRoom.uint64_send_request_enter_room_cmd_start_time=Date.now())}handleJoinReceivedCMDResponce(e){this.hitTest(e.room)&&0===this._pathJoinRoom.uint64_send_request_enter_room_cmd_end_time&&(this._pathJoinRoom.uint64_send_request_enter_room_cmd_end_time=Date.now(),this._pathJoinRoom.int32_send_request_enter_room_cmd_ret=e.code,0!==e.code&&(this._pathJoinRoom.int32_end_ret=this._pathJoinRoom.int32_send_request_enter_room_cmd_ret))}handleJoinSuccess(e){this.hitTest(e.room)&&0===this._pathJoinRoom.uint64_end_time&&(this._pathJoinRoom.uint64_end_time=Date.now(),this._pathJoinRoom.int32_end_ret=0,this._signalInfo=e.room.getSignalInfo())}handleJoinFailed(e){let{room:t,error:i}=e;this.hitTest(t)&&(this._pathJoinRoom.uint64_end_time=Date.now(),0===this._pathJoinRoom.int32_end_ret&&(this._pathJoinRoom.int32_end_ret=i.code||this._pathJoinRoom.int32_send_request_enter_room_cmd_ret||this._pathJoinRoom.int32_send_request_acc_ip_cmd_ret),setTimeout((()=>{this.report()})))}handleReceivedPublishUserList(e){this.hitTest(e.room)&&0===this._pathJoinRoom.uint64_recv_userlist_time&&(this._pathJoinRoom.uint64_recv_userlist_time=Date.now(),this._firstPublishedUserList=e.publishedUserList||[])}handleSendFirstVideoFrame(e){let{room:t}=e;!this.hitTest(t)||0===this._pathJoinRoom.uint64_send_first_video_frame_time&&0!==this._pathJoinRoom.uint64_start_time&&(this._pathJoinRoom.uint64_send_first_video_frame_time=Date.now())}handleLeaveStart(e){this.hitTest(e.room)&&(this._pathLeaveRoom.uint64_start_time=Date.now())}handleLeaveSuccess(e){this.hitTest(e.room)&&0===this._pathLeaveRoom.uint64_end_time&&(this._pathLeaveRoom.uint64_end_time=Date.now(),0!==this._pathJoinRoom.uint64_end_time?this._basicInfo.uint32_joining_duration=this._pathLeaveRoom.uint64_end_time-this._pathJoinRoom.uint64_end_time:this._log.warn("pathJoinRoom endTime is 0"),this.report())}handleLeaveSendCMD(e){this.hitTest(e.room)&&(this._pathLeaveRoom.uint64_send_request_exit_room_cmd_start_time=Date.now(),this._pathLeaveRoom.uint64_send_request_exit_room_cmd_end_time=Date.now())}handleRemoteStreamAdded(e,t){var i;let n="".concat(e,"_").concat(t);if(!this._remoteStreamStatMap.has(n)){let r={userId:e,totalVideoFPS:0,totalVideoBitrate:0,totalAudioLevel:0,totalAudioBitrate:0,totalLoss:0,audioCount:0,audioLevelCount:0,videoCount:0,networkQualityCount:0,streamAddedTime:Date.now(),subscribeStartTime:0,subscribedTime:0,playStreamTime:0,statsToReport:tb(eb({},aV),{msg_user_info:new cV({userId:e,tinyId:null==(i=this._room.remotePublishedUserMap.get(e))?void 0:i.tinyId,role:20})})};r.statsToReport.uint32_stream_type="main"===t?2:7,this._remoteStreamStatMap.set(n,r)}}handleSubscribeStart(e){let{room:t,remotePublishedUser:i,streamType:n,subscribeState:r}=e;if(!this.hitTest(t))return;let{userId:o,tinyId:s,role:a}=i,c=new cV({userId:o,tinyId:s,role:"anchor"===a?20:21}),l=Date.now(),d="".concat(o,"_").concat(n),u=this._remoteStreamStatMap.get(d);u&&0===u.subscribeStartTime&&(u.subscribeStartTime=l),"main"===n?(i.muteState.hasVideo&&(r.video||r.smallVideo)&&!this._pathMainVideoMap.has(d)&&this._pathMainVideoMap.set(d,{statsToReport:{msg_user_info:c,uint64_start_enter_time:this._pathJoinRoom.uint64_start_time,uint64_render_first_frame_time:0,uint64_combine_first_frame_time:0},userId:o,sendSubscribeCMDTime:l}),i.muteState.hasAudio&&r.audio&&!this._pathMainAudioMap.has(d)&&this._pathMainAudioMap.set(d,{statsToReport:{msg_user_info:c,uint64_start_enter_time:this._pathJoinRoom.uint64_start_time,uint64_play_first_frame_time:0},userId:o,sendSubscribeCMDTime:l})):i.muteState.hasAuxiliary&&r.auxiliary&&!this._pathAuxiliaryMap.has(d)&&this._pathAuxiliaryMap.set(d,{sendSubscribeCMDTime:l})}handleSubscribed(e){let{room:t,remotePublishedUser:i,streamType:n}=e;if(this.hitTest(t)){let e="".concat(i.userId,"_").concat(n),t=this._remoteStreamStatMap.get(e);t&&0===t.subscribedTime&&(t.subscribedTime=Date.now())}}handlePlayStart(e){let{track:t}=e;if(!uO(t)||!this.hitTest(t.room))return;let i="".concat(t.userId,"_").concat(t.streamType),n=this._remoteStreamStatMap.get(i);0===(null==n?void 0:n.playStreamTime)&&(n.playStreamTime=Date.now())}handleVideoLoadedData(e){let{track:t}=e;if(!uO(t)||!this.hitTest(t.room))return;let i="".concat(t.userId,"_").concat(t.streamType),n=this._pathMainVideoMap.get(i);n&&0===n.statsToReport.uint64_combine_first_frame_time&&(n.statsToReport.uint64_combine_first_frame_time=Date.now())}handleVideoPlaying(e){let t="".concat(e.userId,"_").concat(e.streamType),i=Date.now(),n=this._pathMainVideoMap.get(t),r=this._remoteStreamStatMap.get(t);if(n&&(0===n.statsToReport.uint64_render_first_frame_time&&(n.statsToReport.uint64_render_first_frame_time=i),r)){let{statsToReport:e,playStreamTime:t,subscribedTime:o}=r;0===e.uint32_video_render_first&&t-o<=100&&(e.uint32_video_render_first=i-n.sendSubscribeCMDTime)}let o=this._pathAuxiliaryMap.get(t);if(o&&r){let{statsToReport:e,playStreamTime:t,subscribedTime:n}=r;0===e.uint32_video_render_first&&t-n<=100&&(e.uint32_video_render_first=i-o.sendSubscribeCMDTime)}}handleAudioPlaying(e){let t="".concat(e.userId,"_").concat(e.streamType),i=this._pathMainAudioMap.get(t);i&&0===i.statsToReport.uint64_play_first_frame_time&&(i.statsToReport.uint64_play_first_frame_time=Date.now())}handleNetworkQuality(e){this.hitTest(e.room)&&(this._networkQuality.totalUplinkLoss+=e.uplink.loss,this._networkQuality.totalUplinkRTT+=e.uplink.rtt,this._networkQuality.count++,e.downlinks.forEach((e=>{let{rtt:t,loss:i,userId:n,videoDelay:r,audioDelay:o}=e,s=this._networkQuality.totalDownlinkRTTAndLossMap.get(n);if(s)s.totalRTT+=t,s.totalLoss+=i,r&&(s.totalVideoDelay=(s.totalVideoDelay||0)+r,s.videoDelayCount=(s.videoDelayCount||0)+1),o&&(s.totalAudioDelay=(s.totalAudioDelay||0)+o,s.audioDelayCount=(s.audioDelayCount||0)+1),s.count++;else{let e,s,a,c;r&&(s=r,a=1),o&&(e=o,c=1),this._networkQuality.totalDownlinkRTTAndLossMap.set(n,{totalRTT:t,totalLoss:i,count:1,totalAudioDelay:e,totalVideoDelay:s,audioDelayCount:c,videoDelayCount:a})}})))}handleHeartbeatStats(e){if(this.hitTest(e.room)){let{msg_up_stream_info:t,msg_down_stream_info:i}=e.report;if(t.msg_video_status[0]){let{uint32_video_codec_bitrate:e,uint32_video_enc_fps:i,uint32_video_width:n,uint32_video_height:r}=t.msg_video_status[0];this._localStreamStat.totalVideoBitrate+=e,this._localStreamStat.totalVideoFPS+=i,this._localStreamStat.totalVideoWidth+=n,this._localStreamStat.totalVideoHeight+=r,this._localStreamStat.videoCount++}if(t.msg_audio_status){let{uint32_audio_level:e}=t.msg_audio_status;Math.floor(e/UD*100)>0&&(this._localStreamStat.totalAudioLevel+=e/UD,this._localStreamStat.audioLevelCount++)}i.forEach((e=>{let{msg_user_info:t,msg_audio_status:i,msg_video_status:n}=e,r=t.str_identifier,o=this._room.remotePublishedUserMap.get(r);if(n.forEach((e=>{let t=2===e.uint32_video_stream_type,i=7===e.uint32_video_stream_type,n="".concat(r,"_").concat(t?"main":"auxiliary"),s=this._remoteStreamStatMap.get(n);if(s&&(t&&(null==o?void 0:o.remoteVideoTrack.isSubscribed)||i&&(null==o?void 0:o.remoteAuxiliaryTrack))){s.totalVideoFPS+=e.uint32_video_receive_fps,s.totalVideoBitrate+=e.uint32_video_codec_bitrate,s.videoCount++,0===s.statsToReport.uint32_video_width&&(s.statsToReport.uint32_video_width=e.uint32_video_width),0===s.statsToReport.uint32_video_height&&(s.statsToReport.uint32_video_height=e.uint32_video_height);let i=t?o.remoteVideoTrack:o.remoteAuxiliaryTrack;i.stat.jitterBufferDelay&&(s.videoJitterBufferDelay=i.stat.jitterBufferDelay),i.stat.framesReceived&&(s.statsToReport.uint32_video_consume_render_rate=Math.floor(i.stat.framesDecoded/i.stat.framesReceived*$C(10,6)))}})),i){let e="".concat(r,"_","main"),t=this._remoteStreamStatMap.get(e);this._remoteStreamStatMap.has(e)&&t&&(null==o?void 0:o.remoteAudioTrack.isSubscribed)&&(t.totalAudioBitrate+=i.uint32_audio_codec_bitrate,t.audioCount++,o.remoteAudioTrack.stat.jitterBufferDelay&&(t.audioJitterBufferDelay=o.remoteAudioTrack.stat.jitterBufferDelay),Math.floor(i.uint32_audio_level/UD*100)>0&&(t.totalAudioLevel+=i.uint32_audio_level/UD,t.audioLevelCount++))}}))}}handlePublishStart(e){let{room:t}=e;this.hitTest(t)&&0===this._localStreamStat.publishStartTime&&(this._localStreamStat.publishStartTime=Date.now())}handleTrackCaptureStart(e){let{track:t}=e;1===t.mediaType&&!this._pathJoinRoom.uint64_init_audio_start_time&&(this._pathJoinRoom.uint64_init_audio_start_time=Date.now()),4===t.mediaType&&!this._pathJoinRoom.uint64_init_camera_start_time&&(this._pathJoinRoom.uint64_init_camera_start_time=Date.now())}handleTrackCaptureSuccess(e){let{track:t}=e;1===t.mediaType&&!this._pathJoinRoom.uint64_init_audio_end_time&&(this._pathJoinRoom.int32_init_audio_ret=0,this._pathJoinRoom.uint64_init_audio_end_time=Date.now()),4===t.mediaType&&!this._pathJoinRoom.uint64_init_camera_end_time&&(this._pathJoinRoom.int32_init_camera_ret=0,this._pathJoinRoom.uint64_init_camera_end_time=Date.now())}handleTrackCaptureFailed(e){let{track:t,error:i}=e,n={NotFoundError:1,NotAllowedError:2,NotReadableError:3,OverConstrainedError:4,AbortError:5,InvalidStateError:6,SecurityError:7,TypeError:8}[i.name]||(i instanceof Tb?i.getExtraCode()||i.getCode():fb.UNKNOWN);1===t.mediaType&&!this._pathJoinRoom.uint64_init_audio_end_time&&(this._pathJoinRoom.int32_init_audio_ret=n,this._pathJoinRoom.uint64_init_audio_end_time=Date.now()),4===t.mediaType&&!this._pathJoinRoom.uint64_init_camera_end_time&&(this._pathJoinRoom.int32_init_camera_ret=n,this._pathJoinRoom.uint64_init_camera_end_time=Date.now())}handleAPISuccessRate(e){let{room:t,apiName:i,error:n,cost:r}=e;if(!this.hitTest(t))return;let o=lV[i],s={uint32_function_request_type:o,uint32_avg_value:0,uint32_max_value:0,uint32_request_count:1,uint32_success_count:0,msg_error_code:[]};if(n){let e=n.extraCode||n.code||fb.UNKNOWN;Xw.logFailedEvent({eventType:i,code:e,userId:this._room.userId,error:n});let t={int32_error_code:e,error_count:1};s.msg_error_code.push(t)}else sO(r)&&(Xw.logSuccessEvent({eventType:i,userId:this._room.userId}),s.uint32_avg_value=r,s.uint32_max_value=r,s.uint32_success_count=1);let a=this._apiSuccessRateMap.get(o);a?(a.uint32_success_count+s.uint32_success_count>0&&(a.uint32_avg_value=(a.uint32_avg_value*a.uint32_success_count+s.uint32_avg_value)/(a.uint32_success_count+s.uint32_success_count)),a.uint32_max_value=Math.max(a.uint32_max_value,s.uint32_max_value),a.uint32_request_count+=1,a.uint32_success_count=a.uint32_success_count+s.uint32_success_count,s.msg_error_code.forEach((e=>{let t=a.msg_error_code.find((t=>t.int32_error_code===e.int32_error_code));t?t.error_count+=1:a.msg_error_code.push(e)}))):this._apiSuccessRateMap.set(o,s)}hasVideoFlag(e){return this._firstPublishedUserList.findIndex((t=>t.userId===e&&t.flag&FN))>=0}hasAudioFlag(e){return this._firstPublishedUserList.findIndex((t=>t.userId===e&&t.flag&jN))>=0}hasAuxFlag(e){return this._firstPublishedUserList.findIndex((t=>t.userId===e&&t.flag&HN))>=0}hitTest(e){return e===this._room}checkStorage(){return cb(this,null,(function*(){try{let e=WO.getItem(this._storageKey);e&&(yield this.upload(e),WO.deleteItem(this._storageKey))}catch(FL){this._log.warn(FL)}}))}setStorage(){this.prepareReport();let e=this.getReportData();0!==e.msg_path_enter_room.uint64_start_time&&WO.setItem(this._storageKey,e)}prepareReport(){if(this._networkQuality.count>0&&(this._basicInfo.uint32_avg_rtt=Math.floor(this._networkQuality.totalUplinkRTT/this._networkQuality.count),this._basicInfo.uint32_avg_up_loss=Math.floor(this._networkQuality.totalUplinkLoss/this._networkQuality.count)),this._localStreamStat.videoCount>0){this._localStreamStat.statsToReport.uint32_video_big_capture_fps=Math.floor(this._localStreamStat.totalVideoFPS/this._localStreamStat.videoCount),this._localStreamStat.statsToReport.uint32_video_big_bitrate=Math.floor(this._localStreamStat.totalVideoBitrate/this._localStreamStat.videoCount);let e=Math.floor(this._localStreamStat.totalVideoWidth/this._localStreamStat.videoCount),t=Math.floor(this._localStreamStat.totalVideoHeight/this._localStreamStat.videoCount);this._localStreamStat.statsToReport.uint32_video_big_resolution=e<<16|t}this._localStreamStat.audioLevelCount>0&&(this._localStreamStat.statsToReport.uint32_audio_capture_db=Math.floor(this._localStreamStat.totalAudioLevel/this._localStreamStat.audioLevelCount*100)),this._remoteStreamStatMap.forEach(((e,t)=>{let{userId:i}=e,n=this._networkQuality.totalDownlinkRTTAndLossMap.get(i);if(n){let{totalLoss:t,count:i,audioDelayCount:r,videoDelayCount:o,totalAudioDelay:s,totalVideoDelay:a}=n;e.statsToReport.uint32_avg_down_loss=Math.floor(t/i),r&&s&&(e.statsToReport.uint32_audio_network_p2p_delay=Math.floor(s/r),e.audioJitterBufferDelay&&(e.statsToReport.uint32_p2p_delay=Math.floor(e.statsToReport.uint32_audio_network_p2p_delay+e.audioJitterBufferDelay))),o&&a&&(e.statsToReport.uint32_video_network_p2p_delay=Math.floor(a/o))}e.videoCount>0&&(e.statsToReport.uint32_video_avg_fps=Math.floor(e.totalVideoFPS/e.videoCount),e.statsToReport.uint32_video_avg_bitrate=Math.floor(e.totalVideoBitrate/e.videoCount)),e.audioCount>0&&(e.statsToReport.uint32_audio_recv_bitrate=e.statsToReport.uint32_audio_bitrate=Math.floor(e.totalAudioBitrate/e.audioCount)),e.audioLevelCount>0&&(e.statsToReport.uint32_audio_play_db=Math.floor(e.totalAudioLevel/e.audioLevelCount*100));let{callDurationCalculator:r}=this._room;r&&(e.statsToReport.uint32_audio_play_time=r.getDuration(t,MN.AUDIO),e.statsToReport.uint32_video_play_time=r.getDuration(t,MN.VIDEO)),e.statsToReport.uint32_video_render_first=Math.min(e.statsToReport.uint32_video_render_first,sV);let{badCaseDetector:o}=this._room,{dataFreeze:s,count:a}=o.getDataFreezeDuration(t),{renderFreeze:c}=o.getRenderFreezeDuration(t);e.statsToReport.uint32_video_block_count=a,e.statsToReport.uint32_video_block_time=Math.min(s,e.statsToReport.uint32_video_play_time),e.statsToReport.uint32_video_external_block_time=Math.min(c,e.statsToReport.uint32_video_play_time),o.isBlackStream(t)&&0===e.statsToReport.uint32_video_avg_fps?e.statsToReport.uint32_video_black_screen_subjective=1:e.statsToReport.uint32_video_black_screen_subjective=0,(0===e.subscribeStartTime||e.subscribeStartTime-e.streamAddedTime>100||0===e.playStreamTime)&&(this._pathMainAudioMap.delete(t),this._pathMainVideoMap.delete(t),e.statsToReport.uint32_video_render_first=0)})),this._pathMainAudioMap.forEach(((e,t)=>{this.hasAudioFlag(e.userId)?e.statsToReport.uint64_play_first_frame_time-e.statsToReport.uint64_start_enter_time>sV&&(e.statsToReport.uint64_play_first_frame_time=e.statsToReport.uint64_start_enter_time+sV):this._pathMainAudioMap.delete(t)})),this._pathMainVideoMap.forEach(((e,t)=>{this.hasVideoFlag(e.userId)?e.statsToReport.uint64_render_first_frame_time-e.statsToReport.uint64_start_enter_time>sV&&(e.statsToReport.uint64_render_first_frame_time=e.statsToReport.uint64_start_enter_time+sV):this._pathMainVideoMap.delete(t)})),this._pathJoinRoom.uint64_end_time-this._pathJoinRoom.uint64_start_time>sV&&(this._pathJoinRoom.uint64_end_time=this._pathJoinRoom.uint64_start_time+sV)}getReportData(){return{uint32_sdk_app_id:Number(this._room.sdkAppId),msg_user_info:new cV({userId:this._room.userId,tinyId:this._room.tinyId,role:"anchor"===this._room.role?20:21}),msg_basic_info:this._basicInfo,uint32_acc_ip:RO(this._signalInfo.relayIp),uint32_client_ip:RO(this._signalInfo.clientIp,!1),uint32_acc_port:this._signalInfo.relayPort||0,uint64_timestamp:Date.now(),uint32_seq:Math.floor(2147483648*Math.random()),msg_path_enter_room:this._pathJoinRoom,msg_path_exit_room:this._pathLeaveRoom,msg_path_recv_video:[...this._pathMainVideoMap.values()].map((e=>e.statsToReport)),msg_quality_statistics:[...this._remoteStreamStatMap.values()].map((e=>e.statsToReport)),str_room_name:String(this._room.roomId||0),msg_path_recv_audio:[...this._pathMainAudioMap.values()].map((e=>e.statsToReport)),uint32_info_client_ip:RO(this._signalInfo.clientIp,!1),error_code:[],msg_local_statistics:this._localStreamStat.statsToReport,msg_function_request_stats:[...this._apiSuccessRateMap.values()]}}report(){try{this.prepareReport();let e=this.getReportData();this.upload(e),WO.deleteItem(this._storageKey),this.initData()}catch(FL){this._log.warn(FL)}}upload(e){if(qk||0===e.msg_path_enter_room.uint64_start_time||[_N,fN,gN].findIndex((e=>e===location.host))>=0)return;let t=Number(this._room.sdkAppId),i=HD(t,AN.KEY_POINT),n=!1;navigator.sendBeacon&&(n=navigator.sendBeacon(i,JSON.stringify(e))),n||LO({url:i,body:JSON.stringify(e)})}setConnectionType(e){this.connectionType=e,this._basicInfo.uint32_connection_type=e}};ob([iV({settings:{timeout:500,retries:3}})],rV.prototype,"upload",1);var oV,sV=5e3,aV={msg_user_info:null,uint32_video_avg_fps:0,uint32_video_width:0,uint32_video_height:0,uint32_video_avg_bitrate:0,uint32_video_block_time:0,uint32_video_play_time:0,uint32_audio_block_time:0,uint32_audio_play_time:0,uint32_audio_play_db:0,uint32_avg_down_loss:0,uint32_stream_type:0,uint32_video_render_first:0,uint32_video_block_count:0,uint32_audio_block_count:0,uint32_audio_bitrate:0,uint32_video_black_screen_subjective:0,uint32_audio_recv_bitrate:0,uint32_video_external_block_time:0,uint32_video_consume_render_rate:0},cV=class{constructor(e){this.str_identifier=String(e.userId),this.str_tinyid=String(e.tinyId||0),this.uint32_role=e.role}},lV=((oV=lV||{})[oV.enterRoom=50001]="enterRoom",oV[oV.exitRoom=50002]="exitRoom",oV[oV.switchRole=50003]="switchRole",oV[oV.destroy=50004]="destroy",oV[oV.startLocalAudio=50005]="startLocalAudio",oV[oV.updateLocalAudio=50006]="updateLocalAudio",oV[oV.stopLocalAudio=50007]="stopLocalAudio",oV[oV.startLocalVideo=50008]="startLocalVideo",oV[oV.updateLocalVideo=50009]="updateLocalVideo",oV[oV.stopLocalVideo=50010]="stopLocalVideo",oV[oV.startScreenShare=50011]="startScreenShare",oV[oV.updateScreenShare=50012]="updateScreenShare",oV[oV.stopScreenShare=50013]="stopScreenShare",oV[oV.enableAudioVolumeEvaluation=50014]="enableAudioVolumeEvaluation",oV[oV.startRemoteVideo=50015]="startRemoteVideo",oV[oV.updateRemoteVideo=50016]="updateRemoteVideo",oV[oV.stopRemoteVideo=50017]="stopRemoteVideo",oV[oV.muteRemoteAudio=50018]="muteRemoteAudio",oV[oV.setRemoteAudioVolume=50019]="setRemoteAudioVolume",oV[oV.startMixTranscode=50020]="startMixTranscode",oV[oV.stopMixTranscode=50021]="stopMixTranscode",oV[oV.startPublishCDNStream=50022]="startPublishCDNStream",oV[oV.stopPublishCDNStream=50023]="stopPublishCDNStream",oV[oV.PeerConnectionConnect=50024]="PeerConnectionConnect",oV[oV.PeerConnectionReconnect=50025]="PeerConnectionReconnect",oV[oV.WebsocketConnect=50026]="WebsocketConnect",oV[oV.WebsocketReconnect=50027]="WebsocketReconnect",oV[oV.schedule=50028]="schedule",oV[oV.SPCConnect=50029]="SPCConnect",oV[oV.SPCReconnect=50030]="SPCReconnect",oV[oV.videoCtxGl=50031]="videoCtxGl",oV[oV.videoCtxGlRecover=50032]="videoCtxGlRecover",oV[oV.videoCtx2d=50033]="videoCtx2d",oV[oV["CDNStreaming.startPlugin"]=50034]="CDNStreaming.startPlugin",oV[oV["CDNStreaming.updatePlugin"]=50035]="CDNStreaming.updatePlugin",oV[oV["CDNStreaming.stopPlugin"]=50036]="CDNStreaming.stopPlugin",oV[oV["AIDenoiser.startPlugin"]=50037]="AIDenoiser.startPlugin",oV[oV["AIDenoiser.updatePlugin"]=50038]="AIDenoiser.updatePlugin",oV[oV["AIDenoiser.stopPlugin"]=50039]="AIDenoiser.stopPlugin",oV[oV["AudioMixer.startPlugin"]=50040]="AudioMixer.startPlugin",oV[oV["AudioMixer.updatePlugin"]=50041]="AudioMixer.updatePlugin",oV[oV["AudioMixer.stopPlugin"]=50042]="AudioMixer.stopPlugin",oV),dV=rV,uV=class{constructor(){sb(this,"_startTime"),sb(this,"_endTime"),this._startTime=0,this._endTime=0,this.start()}start(){0===this._startTime&&(this._startTime=gO())}stop(){0===this._endTime&&(this._endTime=gO())}getDuration(){return 0===this._endTime?gO()-this._startTime:this._endTime-this._startTime}get endTime(){return this._endTime}},hV=class{constructor(e){sb(this,"_room",null),sb(this,"_durationMap"),sb(this,"_eventMap",new Map),this._room=e.room,this._durationMap=new Map,this.installEvents()}installEvents(){this._eventMap.set(BO.SUBSCRIBE_SUCCESS,this.handleSubscribed).set(BO.UNSUBSCRIBE_SUCCESS,this.handleStreamStopped).set(BO.REMOTE_PUBLISH_STATE_CHANGED,(e=>{let{room:t,prevMuteState:i,muteState:n}=e;var r;let{userId:o}=n;if(!this.hitTest(t))return;i.hasAudio&&!n.hasAudio&&this.stopDurationItem("".concat(o,"_","main"),MN.AUDIO),i.hasVideo&&!n.hasVideo&&this.stopDurationItem("".concat(o,"_","main"),MN.VIDEO),i.hasAuxiliary&&!n.hasAuxiliary&&this.stopDurationItem("".concat(o,"_","auxiliary"),MN.VIDEO);let s=null==(r=this._room)?void 0:r.remotePublishedUserMap.get(o);!s||(!i.hasAudio&&n.hasAudio&&s.remoteAudioTrack.isSubscribed&&this.addDuractionItem(o,MN.AUDIO,"main"),!i.hasVideo&&n.hasVideo&&s.remoteVideoTrack.isSubscribed&&this.addDuractionItem(o,MN.VIDEO,"main"),!i.hasAuxiliary&&n.hasAuxiliary&&s.remoteAuxiliaryTrack.isSubscribed&&this.addDuractionItem(o,MN.VIDEO,"auxiliary"))})),this._eventMap.forEach(((e,t)=>UO.on(t,e,this)))}uninstallEvents(){this._eventMap.forEach(((e,t)=>UO.off(t,e,this))),this._eventMap.clear()}handleSubscribed(e){let{room:t,streamType:i,remotePublishedUser:n}=e;if(!this.hitTest(t))return;let{userId:r}=n,o="".concat(r,"_").concat(i);if(n.muteState.hasAudio&&"main"===i)if(n.remoteAudioTrack.isSubscribed){let e=new uV,t=this._durationMap.get(o);t?this.isRecording(t.audio)||t.audio.push(e):this._durationMap.set(o,{userId:r,type:i,audio:[e],video:[]})}else this.stopDurationItem(o,MN.AUDIO);if(n.muteState.hasVideo||n.muteState.hasAuxiliary)if(n.remoteVideoTrack.isSubscribed||n.remoteAuxiliaryTrack.isSubscribed){let e=new uV,t=this._durationMap.get(o);t?this.isRecording(t.video)||t.video.push(e):this._durationMap.set(o,{userId:r,type:i,audio:[],video:[e]})}else this.stopDurationItem(o,MN.VIDEO)}handleStreamStopped(e){let{room:t,streamType:i,remotePublishedUser:n}=e;if(!this.hitTest(t))return;let{userId:r}=n,o="".concat(r,"_").concat(i);this.stopDurationItem(o,MN.AUDIO),this.stopDurationItem(o,MN.VIDEO)}isRecording(e){return e.findIndex((e=>0===e.endTime))>=0}addDuractionItem(e,t,i){let n="".concat(e,"_").concat(i),r=new uV,o=this._durationMap.get(n);o?this.isRecording(o[t])||o[t].push(r):this._durationMap.set(n,{userId:e,type:i,audio:t===MN.AUDIO?[r]:[],video:t===MN.AUDIO?[]:[r]})}stopDurationItem(e,t){if(this._durationMap.has(e)){let i=this._durationMap.get(e)[t].find((e=>0===e.endTime));i&&i.stop()}}hitTest(e){return this._room===e}getDuration(e,t){return this._durationMap.has(e)?this._durationMap.get(e)[t].reduce(((e,t)=>e+t.getDuration()),0):0}getDurationMap(){return this._durationMap}reset(){this._durationMap.clear()}destroy(){this._room=null,this.uninstallEvents()}},pV=class{constructor(e){sb(this,"_room"),sb(this,"_renderFreezeMap",new Map),sb(this,"_isVideoPlayingEventFiredMap",new Map),sb(this,"_dataFreezeMap",new Map),sb(this,"_monitorFreezeData",new Map),sb(this,"_eventMap",new Map),this._room=e.room,this.installEvents()}installEvents(){this._eventMap.set(BO.LEAVE_SUCCESS,(e=>{let{room:t}=e;this.hitTest(t)&&this.stop()})).set(BO.PLAY_TRACK_START,this.onPlayTrackStart).set(BO.UNSUBSCRIBE_SUCCESS,(e=>{let{room:t,streamType:i,remotePublishedUser:n}=e;if(!this.hitTest(t))return;let{userId:r}=n,o="".concat(r,"_").concat(i);this.stopDataFreeze({key:o,userId:r,type:i})})).set(BO.REMOTE_PUBLISH_STATE_CHANGED,(e=>{let{room:t,prevMuteState:i,muteState:n}=e;if(!this.hitTest(t))return;let{userId:r}=n;if(i.hasVideo&&!n.hasVideo){let e="main",t="".concat(n.userId,"_").concat(e);this.stopDataFreeze({key:t,userId:r,type:e})}if(i.hasAuxiliary&&!n.hasAuxiliary){let e="auxiliary",t="".concat(n.userId,"_").concat(e);this.stopDataFreeze({key:t,userId:r,type:e})}})).set(BO.PLAYER_STATE_CHANGED,(e=>{let{track:t,state:i,reason:n,type:r}=e;if(uO(t)&&this.hitTest(t.room)&&r===MN.VIDEO){if("PLAYING"===i){let e="".concat(t.userId,"_").concat(t.streamType);this._isVideoPlayingEventFiredMap.set(e,!0)}n===MN.MUTE?this.onVideoTrackMuted(t):n===MN.UNMUTE&&this.onVideoTrackUnmuted(t)}})).set(BO.HEARTBEAT_REPORT,this.onHearBeatReport),this._eventMap.forEach(((e,t)=>UO.on(t,e,this)))}uninstallEvents(){this._eventMap.forEach(((e,t)=>UO.off(t,e,this))),this._eventMap.clear()}stop(){this._renderFreezeMap.clear(),this._dataFreezeMap.clear(),this._isVideoPlayingEventFiredMap.clear()}onVideoTrackMuted(e){if(!e.isSubscribed)return;let{userId:t,streamType:i}=e,n="".concat(t,"_").concat(i),r=this._dataFreezeMap.get(n),o=new uV;r?r.durationItemList.push(o):this._dataFreezeMap.set(n,{userId:t,type:i,durationItemList:[o],isFreezing(){let e=this.durationItemList[this.durationItemList.length-1];return e&&0===e.endTime}})}onVideoTrackUnmuted(e){if(!e.isSubscribed)return;let{userId:t,streamType:i}=e,n="".concat(t,"_").concat(i);this.stopDataFreeze({key:n,userId:t,type:i})}onHearBeatReport(e){let{room:t,report:i}=e;!this.hitTest(t)||i.msg_down_stream_info.forEach((e=>{let t=this._room.remotePublishedUserMap.get(e.msg_user_info.str_identifier);if(!t)return;let{userId:i,muteState:n}=t;e.msg_video_status.forEach((e=>{2===e.uint32_video_stream_type&&n.hasVideo&&!n.videoMuted&&t.remoteVideoTrack.isSubscribed&&this.handleRenderFreeze({userId:i,fps:e.uint32_video_dec_fps,type:"main"}),7===e.uint32_video_stream_type&&n.hasAuxiliary&&t.remoteAuxiliaryTrack.isSubscribed&&this.handleRenderFreeze({userId:i,fps:e.uint32_video_dec_fps,type:"auxiliary"})}))}))}stopDataFreeze(e){let{key:t,userId:i,type:n}=e,r=this._dataFreezeMap.get(t);if(!r||!r.isFreezing())return;let o=r.durationItemList[r.durationItemList.length-1];o.stop();let s=o.getDuration();s>gD?this._monitorFreezeData.set(t,{userId:i,type:n,duration:s}):r.durationItemList.pop()}getTotalDuration(e){return e.reduce(((e,t)=>{let i=t.getDuration();return e+Math.min(i,5e3)}),0)}handleRenderFreeze(e){return cb(this,arguments,(function(e){var t=this;let{userId:i,fps:n,type:r}=e;return function*(){let e="".concat(i,"_").concat(r),o=t._renderFreezeMap.get(e);if(n<=2){let n=gO();o&&!o.isFreeze&&(o.freezeTimeline.push({startTime:n,endTime:0}),o.isFreeze=!0),o||t._renderFreezeMap.set(e,{userId:i,type:r,isFreeze:!0,freezeTimeline:[{startTime:n,endTime:0}],renderFreezeTotal:0})}else if(o&&o.isFreeze){o.isFreeze=!1;let e=o.freezeTimeline.pop();if(e){e.endTime=gO();let t=e.endTime-e.startTime;o.freezeTimeline.push(e),o.renderFreezeTotal+=Math.min(5e3,t)}}}()}))}onPlayTrackStart(e){let{track:t}=e;if(!uO(t)||!this.hitTest(t.room)||t.kind!==MN.VIDEO||t.hasFlag)return;let i="".concat(t.userId,"_").concat(t.streamType);this._isVideoPlayingEventFiredMap.has(i)||this._isVideoPlayingEventFiredMap.set(i,!1)}getDataFreezeDuration(e){let t={dataFreeze:0,count:0},i=this._dataFreezeMap.get(e);if(i){if(i.isFreezing()){let e=i.durationItemList[i.durationItemList.length-1];e.stop(),e.getDuration()<gD&&i.durationItemList.pop()}t.dataFreeze=this.getTotalDuration(i.durationItemList),t.count=i.durationItemList.length}return t}getRenderFreezeDuration(e){let t=this._renderFreezeMap.get(e),i=0,n=0;if(t)if(t.isFreeze){let e=gO()-t.freezeTimeline[t.freezeTimeline.length-1].startTime;i=t.renderFreezeTotal+Math.min(e,5e3),n=t.freezeTimeline.length}else i=t.renderFreezeTotal;return{renderFreeze:i,count:n}}getMonitorFreeze(){return this._monitorFreezeData}isBlackStream(e){return!!this._isVideoPlayingEventFiredMap.has(e)&&!this._isVideoPlayingEventFiredMap.get(e)}resetMonitor(){this._monitorFreezeData.clear()}hitTest(e){return e===this._room}destroy(){this.uninstallEvents()}},mV=null,_V=!0;function fV(e){aO(e)&&e!==_V&&(_V=e,jO.info("setIsNeedToSchedule ".concat(e)))}function gV(e){return cb(this,arguments,(function(e){let{userId:t,sdkAppId:i,useStringRoomId:n,roomId:r,userSig:o,version:s,frameWorkType:a}=e;return function*(){if(!_V&&mV)return{isCached:!0,result:mV};let e={delta:0,count:[1,1],msg:[],detail:[]};try{let c=new FormData;c.append("userId",String(t)),c.append("sdkAppId",String(i)),c.append("isStrGroupId",String(n)),c.append("groupId",String(r)),c.append("sdkVersion",s),c.append("userSig",String(o)),c.append("frameWorkType",String(a));let l=gO(),d=yield function(e,t,i){return new Promise(((n,r)=>{let o=null;fO([yV((e=>t.count[0]=e+1),(e=>{let{error:i,retry:n}=e;t.msg[0]=i.message,o||n()}))(SV(i,MN.MAIN),e,{get timeout(){return 1e3*eO(2+t.count[0])}}),yV((e=>t.count[1]=e+1),(e=>{let{error:i,retry:n}=e;t.msg[1]=i.message,o||n()}))(SV(i,MN.BACKUP),e,{get timeout(){return 1e3*eO(2+t.count[1])}})]).then((e=>{o=e,n(o)})).catch(r)}))}(c,e,i);d.config&&(d.config.loggerDomain&&mN(d.config.loggerDomain),aO(d.config.scheduleCache)&&fV(!d.config.scheduleCache)),e.delta=gO()-l;let u=function(e,t,i){let n=performance.getEntriesByType("resource"),r=SV(e,MN.MAIN),o=SV(e,MN.BACKUP),s={totalCost:0,local:0,dns:0,tcp:0,tls:0,request:0,response:0};for(let a of n)if(a.startTime>=i&&(a.name===r||a.name===o)&&a.transferSize>0){let e=a.name===r?MN.MAIN:MN.BACKUP,i=Math.round(a.duration),n=Math.round(a.domainLookupStart-a.startTime),o=Math.round(a.domainLookupEnd-a.domainLookupStart),c=Math.round(a.requestStart-a.secureConnectionStart),l=Math.round(a.secureConnectionStart-a.connectStart),d=Math.round(a.responseStart-a.requestStart),u=Math.round(a.responseEnd-a.responseStart),h=[n,o,c,l,d,u];Xw.uploadEvent({log:"stat-schedule-net:".concat(i,"(").concat(h.join("->"),") ").concat(e),userId:t}),s=tb(eb({},s),{totalCost:i,local:n,dns:o,tcp:l,tls:c,request:d,response:u});break}return s}(Number(i),t,l);return mV=d,{isCached:!1,result:d,detailCost:u}}catch(l){let t=lO(l)?l[0]:l,i=sO(t.code)?t.code:0,n="schedule failed".concat(t.message?": ".concat(t.message):""),r=new Tb({code:fb.SCHEDULE_FAILED,extraCode:i,message:QO({key:zO.JOIN_ROOM_FAILED,data:{error:n,code:i}})});throw jO.error(r),r}}()}))}UO.on("28",(()=>fV(!0))),UO.on("63",(()=>fV(!0))),UO.on("84",(()=>fV(!0))),UO.on("201",(e=>{"RECONNECTING"===e.state&&fV(!0)})),UO.on("202",(e=>{"RECONNECTING"===e.state&&fV(!0)}));var TV={main:"",backup:""};function EV(e){lO(e)?(TV.main=e[0],TV.backup=e[1]):TV.main=e}function SV(e){let t,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:MN.MAIN;return t=BD(e)?i===MN.MAIN?yD.MAIN_OVERSEA:yD.BACKUP_OVERSEA:i===MN.MAIN?yD.MAIN:yD.BACKUP,"https://".concat(TV[i]||t,"/api/v1/config")}function IV(e,t,i){return new Promise(((n,r)=>{LO({url:e,body:t,timeout:i.timeout}).then((e=>{0===e.data.code?n(e.data.data):r({code:e.data.code,message:e.data.msg})})).catch(r)}))}var yV=(e,t)=>xO({retryFunction:IV,settings:{retries:3,timeout:0},onError:t,onRetrying:e}),vV=rb(lb(),1),AV=[-1,-1,-1,1,1,-1,1,1],RV=[0,0,0,1,1,0,1,1],CV=class extends Ww{constructor(e,t){super(),this.context=e,sb(this,"name"),sb(this,"input"),sb(this,"output"),sb(this,"texture"),sb(this,"image"),sb(this,"ctx2d",null),sb(this,"fbo"),sb(this,"width",0),sb(this,"height",0),sb(this,"x",0),sb(this,"y",0),sb(this,"program"),sb(this,"vertexShader"),sb(this,"fragmentShader"),sb(this,"totalFrames",0),sb(this,"dropFrames",0),sb(this,"matchInputSize",!0),sb(this,"texCoordBuffer"),sb(this,"positionBuffer"),sb(this,"lastInfo",{timestamp:0,totalFrames:0,x:0,y:0,width:0,height:0,fps:0}),sb(this,"_canvas",null),this.context.once("disconnect",(()=>{"closed"!==this.state&&this.close()})),this.name=t.name,this.matchInputSize=!1!==t.matchInputSize,this.width=t.width||e.width,this.height=t.height||e.height;let i=e._gl;if(i)try{!1!==t.createTexture&&(this.texture=i.createTexture()),this.texCoordBuffer=this.createBuffer(RV),this.positionBuffer=this.createBuffer(AV),this.useTexture((()=>{i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MIN_FILTER,i.LINEAR),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MAG_FILTER,i.LINEAR),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_S,i.CLAMP_TO_EDGE),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_T,i.CLAMP_TO_EDGE)})),t.useFbo&&(this.fbo=i.createFramebuffer(),this.useBufferFrame((()=>{this.useTexture((()=>{i.texImage2D(i.TEXTURE_2D,0,i.RGBA,this.width,this.height,0,i.RGBA,i.UNSIGNED_BYTE,null),i.framebufferTexture2D(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,this.texture,0)}))}))),t.useDefaultProgram&&(this.program=this.context.defaultProgam),t.vertexShaderSource&&t.fragmentShaderSource&&(this.vertexShader=e.createShader(i.VERTEX_SHADER,t.vertexShaderSource),this.fragmentShader=e.createShader(i.FRAGMENT_SHADER,t.fragmentShaderSource),this.program=e.createProgram(this.vertexShader,this.fragmentShader))}catch(r){this.context.destroy("".concat(this.name," init failed"),r)}else if(e.ctx2d&&t.create2d){let e=document.createElement("canvas"),t="function"==typeof e.transferControlToOffscreen?e.transferControlToOffscreen():e;t.width=this.width,t.height=this.height,this.ctx2d=t.getContext("2d"),this.image=t,this._canvas=t}}connect(e){for(var t=arguments.length,i=new Array(t>1?t-1:0),n=1;n<t;n++)i[n-1]=arguments[n];return e.addInput(this,...i),this.output=e,e}addInput(e){this.input=e,this.matchInputSize&&e.width&&e.height&&this.resize(e.width,e.height)}requestFrame(e){return!!(this.context._gl&&this.render(e)||this.context.ctx2d&&this.render2d(e))&&(this.totalFrames++,!0)}render2d(e){var t;return!(null==(t=this.input)||!t.requestFrame(e))&&this.draw2d(this.input.image,0,0,this.width,this.height)}disconnect(){for(var e,t=arguments.length,i=new Array(t),n=0;n<t;n++)i[n]=arguments[n];null==(e=this.output)||e.removeInput(this,...i),delete this.output}removeInput(e){delete this.input}close(){var e,t;null==(e=this.output)||e.removeInput(this),delete this.output,null==(t=this.input)||t.disconnect();let i=this.context._gl;i&&(i.deleteBuffer(this.texCoordBuffer),i.deleteBuffer(this.positionBuffer),this.fbo&&i.deleteFramebuffer(this.fbo),this.texture&&i.deleteTexture(this.texture),this.vertexShader&&i.deleteShader(this.vertexShader),this.fragmentShader&&i.deleteShader(this.fragmentShader),this.program&&this.program!==this.context.defaultProgam&&i.deleteProgram(this.program)),this._canvas&&(this._canvas.width=0,this._canvas.height=0,this.ctx2d=null),this.removeAllListeners()}useTexture(e,t){this.texture&&this.context.useTexture(this.texture,e,t)}useInputTexture(e,t){this.context.useTexture(this.input.texture,e,t)}useProgram(){this.context._gl.useProgram(this.program)}useBufferFrame(e){let t=this.context._gl;t.bindFramebuffer(t.FRAMEBUFFER,this.fbo),e(),t.bindFramebuffer(t.FRAMEBUFFER,null)}createBuffer(e){let t=this.context._gl,i=t.createBuffer();return t.bindBuffer(t.ARRAY_BUFFER,i),t.bufferData(t.ARRAY_BUFFER,new Float32Array(e),t.STATIC_DRAW),i}setTexBuffer(e){let t=this.context._gl,i=this.texCoordBuffer;t.bindBuffer(t.ARRAY_BUFFER,i),t.bufferData(t.ARRAY_BUFFER,new Float32Array(e),t.STATIC_DRAW)}setPosBuffer(e){let t=this.context._gl,i=this.positionBuffer;t.bindBuffer(t.ARRAY_BUFFER,i),t.bufferData(t.ARRAY_BUFFER,new Float32Array(e),t.STATIC_DRAW)}changeBufferData(e,t){let i=this.context._gl;i.bindBuffer(i.ARRAY_BUFFER,e),i.bufferData(i.ARRAY_BUFFER,new Float32Array(t),i.STATIC_DRAW)}setAttributes(e){let t=this.context._gl;for(let i in e){let n=t.getAttribLocation(this.program,i);t.bindBuffer(t.ARRAY_BUFFER,e[i]),t.enableVertexAttribArray(n),t.vertexAttribPointer(n,2,t.FLOAT,!1,0,0)}}getVertexPoint(e,t){return[e/this.width*2-1,t/this.height*2-1]}layout2texCoords(e){return[...this.getVertexPoint(e.x,e.y),...this.getVertexPoint(e.x,e.y+e.height),...this.getVertexPoint(e.x+e.width,e.y),...this.getVertexPoint(e.x+e.width,e.y+e.height)]}resize(e,t){this.width===e&&this.height===t||(this.width=e,this.height=t,this._canvas&&(this._canvas.width=e,this._canvas.height=t),this.texture&&this.fbo&&this.useTexture((i=>i.texImage2D(i.TEXTURE_2D,0,i.RGBA,e,t,0,i.RGBA,i.UNSIGNED_BYTE,null))),this.output&&this.output.matchInputSize&&this.output.resize(e,t))}draw2d(e,t,i,n,r){return!(!this.ctx2d||!e)&&(e instanceof ImageData?this.ctx2d.putImageData(e,t,i):this.ctx2d.drawImage(e,t,i,n,r),!0)}getInfo(){var e;let{totalFrames:t,x:i,y:n,width:r,height:o}=this,s=Date.now(),a=(t-this.lastInfo.totalFrames)/((s-this.lastInfo.timestamp)/1e3)>>0;return this.lastInfo={totalFrames:t,x:i,y:n,width:r,height:o,timestamp:s,fps:a},eb({parent:null==(e=this.input)?void 0:e.getInfo()},this.lastInfo)}};ob([Hw(Ww.INIT,"connected")],CV.prototype,"connect",1),ob([Hw("connected",Ww.INIT,{ignoreError:!0})],CV.prototype,"disconnect",1),ob([Hw([],"closed")],CV.prototype,"close",1);var bV=[0,1,0,0,1,1,1,0],kV=class extends CV{constructor(e,t){super(e,Object.assign({useDefaultProgram:!0,createTexture:!1,name:"destination"},t)),sb(this,"_intervalId",0),sb(this,"_sequence",0),e._gl?this.setTexBuffer(bV):e.ctx2d&&(this.ctx2d=e.ctx2d)}start(e){this._intervalId=Yw.run("intervalInWorker",(()=>{e!==this.context.frameRate&&(Yw.clearTask(this._intervalId),this.start(this.context.frameRate)),this.requestFrame(this._sequence++);let t=this.context._gl;t&&t.getError()!==t.NO_ERROR&&this.context.destroy("".concat(this.name," req ").concat(this._sequence," render ").concat(this.totalFrames," faild ").concat(t.getError()))}),{fps:this.context.frameRate})}render(e){var t;return!(null==(t=this.input)||!t.requestFrame(e))&&(this.useProgram(),this.useInputTexture((e=>{this.setAttributes({a_position:this.positionBuffer,a_texCoord:this.texCoordBuffer}),e.drawArrays(e.TRIANGLE_STRIP,0,4)})),!0)}addInput(e){for(var t=arguments.length,i=new Array(t>1?t-1:0),n=1;n<t;n++)i[n-1]=arguments[n];super.addInput(e,...i),this.start(this.context.frameRate)}removeInput(e){super.removeInput(e),Yw.clearTask(this._intervalId)}},NV=class extends kV{constructor(e,t){super(e,t),sb(this,"_videoTrack"),[this._videoTrack]=e._canvas.captureStream(e.frameRate).getVideoTracks();let i=e=>{let t=()=>this._videoTrack.removeEventListener(e,i),i=()=>{t(),this.context.destroy("video track ".concat(e))};this.once("closed",t),this._videoTrack.addEventListener(e,i)};e._gl&&i("mute"),i("ended")}get videoTrack(){return this._videoTrack}close(){super.close(),this._videoTrack.stop()}resize(e,t){super.resize(e,t),this.context.setSize(e,t)}},DV=class extends NV{constructor(e,t){super(e,{name:"smallDestination"}),this.resolution=t}resize(e,t){let i,n=e*t,r=this.resolution.width*this.resolution.height;jO.info("big res: ".concat(e,"*").concat(t," small res: ").concat(this.resolution.width,"*").concat(this.resolution.height," ")),n>r?i=n/r:(jO.warn("Small stream resolution is not smaller than big stream, which is invalid. big: ".concat(e," * ").concat(t," small: ").concat(this.resolution.width," * ").concat(this.resolution.height)),i=n/19200),super.resize(e/Math.sqrt(i),t/Math.sqrt(i))}},OV=class extends CV{constructor(e,t){super(e,{name:"imageSource"}),this.image=t,sb(this,"_image"),sb(this,"_totalFrames",0)}_render(e,t){let{width:i,height:n}=this;if(this.image instanceof HTMLVideoElement){if(nO(this.image.getVideoPlaybackQuality)&&!Bk){let e=this.image.getVideoPlaybackQuality().totalVideoFrames;if(this._totalFrames===e)return!1;this._totalFrames=e,this.dropFrames=this._totalFrames-this.totalFrames}({videoWidth:i,videoHeight:n}=this.image)}else if(this.image instanceof HTMLImageElement||this.image instanceof ImageData||this.image instanceof ImageBitmap){if(({width:i,height:n}=this.image),this.image!==this._image)this._image=this.image;else if(i===this.width&&n===this.height)return!1}else(this.image instanceof HTMLCanvasElement||this.image instanceof OffscreenCanvas)&&(({width:i,height:n}=this.image),this._image=this.image);return this.width===i&&this.height===n&&this.totalFrames?t&&this.useTexture((e=>{e.texSubImage2D(e.TEXTURE_2D,0,0,0,e.RGBA,e.UNSIGNED_BYTE,this.image)})):(t&&this.useTexture((e=>{e.texImage2D(e.TEXTURE_2D,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,this.image)})),this.resize(i,n)),!0}render(e){return this._render(e,!0)}render2d(e){return this._render(e,!1)}},wV=class extends OV{constructor(e,t){super(e,document.createElement("video")),this._videoTrack=t,sb(this,"_mediaStream"),this.name="videoTrackSource",this._mediaStream=new MediaStream([t]),this.image.srcObject=this._mediaStream,this.image.play()}replaceTrack(e){var t,i;this._videoTrack!==e&&(null==(t=this._mediaStream)||t.removeTrack(this._videoTrack),this._videoTrack=e,null==(i=this._mediaStream)||i.addTrack(this._videoTrack),this.image.play())}close(){super.close(),delete this._mediaStream,this.image.srcObject=null}},PV=class extends Ww{constructor(e){super(),sb(this,"frameRate"),sb(this,"_canvas"),sb(this,"_gl"),sb(this,"ctx2d"),sb(this,"defaultProgam"),sb(this,"log"),sb(this,"hasAlpha",!1),sb(this,"glFaild",!1),sb(this,"name"),this.name=e.name,this.log=e.logger.createChild({id:"vc-".concat(this.name)}),this.frameRate=e.frameRate}create(e){if(this.glFaild=!1,this.hasAlpha=e.alpha,this._canvas=document.createElement("canvas"),e.use2d)return this.ctx2d=this._canvas.getContext("2d",{alpha:e.alpha}),void this.log.info("video context created use 2d");let t=this._canvas.getContext("webgl",{alpha:e.alpha});if(t){this._gl=t;try{let e=this.createShader(t.VERTEX_SHADER,"\n// 顶点着色器\nattribute vec4 a_position;\nattribute vec2 a_texCoord;\nvarying vec2 v_texCoord;\n\nvoid main() {\n gl_Position = a_position;\n v_texCoord = a_texCoord;\n}\n"),i=this.createShader(t.FRAGMENT_SHADER,"\n// 片元着色器\nprecision mediump float;\nvarying vec2 v_texCoord;\nuniform sampler2D u_texture;\n\nvoid main() {\n gl_FragColor = texture2D(u_texture, v_texCoord);\n} ");this.defaultProgam=this.createProgram(e,i),t.enable(t.BLEND),t.blendFunc(t.SRC_ALPHA,t.ONE_MINUS_SRC_ALPHA),this._canvas.addEventListener("webglcontextlost",(()=>{this.destroy("webglcontextlost")})),this.log.info("video context created use webgl")}catch(cN){return this.log.warn("video context create faild use webgl"),cN}}else this.ctx2d=this._canvas.getContext("2d"),this.ctx2d&&this.log.info("video context created downgrade to 2d");!this.ctx2d&&!this._gl&&delete this._canvas}get available(){return!!this._canvas}createVideoTrackSource(e){return new wV(this,e)}createVideoTrackDestination(e){return new NV(this,e)}createVideoImageSource(e){return new OV(this,e)}set width(e){var t;null==(t=this._gl)||t.viewport(0,0,e,this.height),this._canvas&&(this._canvas.width=e)}get width(){var e;return(null==(e=this._canvas)?void 0:e.width)||0}set height(e){var t;null==(t=this._gl)||t.viewport(0,0,this.width,e),this._canvas&&(this._canvas.height=e)}get height(){var e;return(null==(e=this._canvas)?void 0:e.height)||0}setSize(e,t){var i;null==(i=this._gl)||i.viewport(0,0,e,t),this._canvas&&(this._canvas.width=e,this._canvas.height=t)}disconnect(){this.emit("disconnect")}destroy(e,t){var i;return this.disconnect(),this.log.info("video context destroy ".concat(e?":".concat(e):"")),null==(i=this._gl)||i.deleteProgram(this.defaultProgam),delete this._gl,delete this.ctx2d,this._canvas&&(this._canvas.remove(),this._canvas.width=0,this._canvas.height=0,delete this._canvas),[e,t]}createShader(e,t){let i=this._gl,n=i.createShader(e);return i.shaderSource(n,t),i.compileShader(n),n}createProgram(e,t){let i=this._gl,n=i.createProgram();return i.attachShader(n,e),i.attachShader(n,t),i.linkProgram(n),n}useTexture(e,t,i){let n=this._gl;n.activeTexture(n.TEXTURE0+(i||0)),n.bindTexture(n.TEXTURE_2D,e),t(n),n.bindTexture(n.TEXTURE_2D,null)}};ob([Hw(Ww.INIT,"created")],PV.prototype,"create",1),ob([Hw("created",Ww.INIT,{ignoreError:!0,success(e){e[0]&&(this.glFaild=!0,this.emit("unavailable",...e)),this.removeAllListeners()}})],PV.prototype,"destroy",1);var LV=[1,0,1,1,0,0,0,1],MV=class extends CV{constructor(e){if(super(e,{useDefaultProgram:!0,useFbo:!0,create2d:!0,name:"mirror"}),e._gl)try{this.setTexBuffer(LV)}catch(aN){e.destroy("mirror set texCoords faild",aN)}else this.ctx2d&&setTimeout((e=>{e.scale(-1,1),e.translate(-this.width,0)}),0,this.ctx2d)}render(e){var t;return!(null==(t=this.input)||!t.requestFrame(e))&&(this.useProgram(),this.useBufferFrame((()=>{this.useInputTexture((e=>{this.setAttributes({a_position:this.positionBuffer,a_texCoord:this.texCoordBuffer}),e.drawArrays(e.TRIANGLE_STRIP,0,4)}))})),!0)}},xV=class{constructor(e,t){this.node=e,this.layout=t,sb(this,"positionBuffer")}get x(){return this.layout.x||this.node.x}get y(){return this.layout.y||this.node.y}get width(){return this.layout.width||this.node.width}get height(){return this.layout.height||this.node.height}get right(){return this.x+this.width}get bottom(){return this.y+this.height}},VV=class extends CV{constructor(e){super(e,{useDefaultProgram:!0,useFbo:!0,name:"mix",create2d:!0}),sb(this,"inputs",[])}addInput(e,t){if(this.inputs[t.zIndex])throw new Error("input already exists");let i=new xV(e,t);this.inputs[t.zIndex]=i}resize(e,t){let i=this.inputs.reduce(((e,t)=>t?Object.assign(e,{width:Math.max(e.width,t.right),height:Math.max(e.height,t.bottom)}):e),{width:0,height:0});super.resize(i.width,i.height),this.context._gl&&this.inputs.forEach((e=>{if(e){let t=this.layout2texCoords(e);e.positionBuffer?this.changeBufferData(e.positionBuffer,t):e.positionBuffer=this.createBuffer(t)}}))}connect(e){for(var t=arguments.length,i=new Array(t>1?t-1:0),n=1;n<t;n++)i[n-1]=arguments[n];return super.connect(e,...i),this.resize(0,0),e}removeInput(e){this.inputs[this.inputs.findIndex((t=>(null==t?void 0:t.node)===e))]=void 0}render(e){let t=this.context._gl;return!(this.inputs.reduce(((t,i)=>(!i||!i.node.requestFrame(e))&&t),!0)||!t)&&(this.useProgram(),t.clearColor(0,0,0,0),t.clear(t.COLOR_BUFFER_BIT|t.DEPTH_BUFFER_BIT),this.setAttributes({a_texCoord:this.texCoordBuffer}),this.useBufferFrame((()=>{for(let e=0;e<this.inputs.length;e++){let t=this.inputs[e];t&&t.node.useTexture((e=>{this.setAttributes({a_position:t.positionBuffer}),e.drawArrays(e.TRIANGLE_STRIP,0,4)}))}})),!0)}render2d(e){if(!this.inputs.reduce(((t,i)=>(!i||!i.node.requestFrame(e))&&t),!0)&&this.ctx2d){this.ctx2d.clearRect(0,0,this.width,this.height);for(let e=0;e<this.inputs.length;e++){let t=this.inputs[e];t&&this.draw2d(t.node.image,t.x,t.y,t.width,t.height)}return!0}return!1}getInfo(){let{totalFrames:e,x:t,y:i,width:n,height:r}=this,o=Date.now(),s=(e-this.lastInfo.totalFrames)/((o-this.lastInfo.timestamp)/1e3)>>0;return this.lastInfo={totalFrames:e,x:t,y:i,width:n,height:r,timestamp:o,fps:s},eb({parent:this.inputs.filter((e=>e)).map((e=>e.node.getInfo()))},this.lastInfo)}close(){super.close(),this.inputs.forEach((e=>{var t;if(e&&(null==(t=e.node)||t.disconnect(),e.positionBuffer&&this.context._gl))try{this.context._gl.deleteBuffer(e.positionBuffer)}catch(cN){}}))}},UV=class extends vV.EventEmitter{constructor(e){let{room:t}=e;super(),sb(this,"videoContext"),sb(this,"destination"),sb(this,"smallVideoContext"),sb(this,"smallDestination"),sb(this,"smallTrackSource"),sb(this,"smallImageSource"),sb(this,"_isMirror",!1),sb(this,"cameraTrack"),sb(this,"cameraNode"),sb(this,"waterMarkNode"),sb(this,"mirrorNode"),sb(this,"mixNode"),sb(this,"screenTrack"),sb(this,"screenNode"),sb(this,"_isMixScreen",!1),sb(this,"_hasWaterMark",!1),sb(this,"_log"),sb(this,"_checkId",0),sb(this,"_room"),sb(this,"_use2d",!0),sb(this,"_waterMarkOption"),sb(this,"_isOpenVirtualBackground",!1),sb(this,"_virtualBackgroundTrack"),sb(this,"virtualBackgroundInstance"),this._room=t,this._log=jO.createLogger({id:"vm",userId:t.userId,sdkAppId:t.sdkAppId}),this.videoContext=new PV({frameRate:15,logger:this._log,name:"m"}),this.videoContext.on("unavailable",((e,t)=>{this.emit("error",{reason:e,error:t}),this._log.warn("video context unavailable",e,t,"glFaild:".concat(this.videoContext.glFaild)),UO.emit("262",{room:this._room,apiName:"videoCtxGl",error:t||new Error(e)}),this.update()})),this.smallVideoContext=new PV({frameRate:15,logger:this._log,name:"s"}),this.enablePrintDetail()}get renderMode(){return this._use2d?"2d":"webgl"}set renderMode(e){let t="2d"===e;this._use2d!==t&&(this._use2d=t,this.videoContext&&(this.clear(),this.videoContext.destroy(),this.videoContext.create({alpha:this._hasWaterMark,use2d:this._use2d}),this.update()))}enablePrintDetail(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:2e3;this._checkId=Yw.run(MD,(()=>{this.destination&&this._log.debug(this.destination.getInfo())}),{delay:e})}destroy(){this.videoContext.destroy(),this.smallVideoContext.destroy(),Yw.clearTask(this._checkId)}get active(){return(zk&&Jk||this._isMixScreen||this._isMirror||this._hasWaterMark)&&this.checkOrCreateVideoContext()}sendCreateResult(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"videoCtxGl",t=arguments.length>1?arguments[1]:void 0;UO.emit("262",{room:this._room,apiName:e,error:t})}checkOrCreateVideoContext(){if(this.videoContext.available){if(this.videoContext.hasAlpha||!this._hasWaterMark)return!0;this.clear(),this.videoContext.destroy()}else this.videoContext.glFaild&&(this.clear(),this._use2d=!0);let e=this.videoContext.create({alpha:this._hasWaterMark,use2d:this._use2d});return this.videoContext._gl?this.sendCreateResult():(this._use2d||(this.emit("error",{reason:"create",error:e}),this.sendCreateResult("videoCtxGl",e)),this.sendCreateResult("videoCtx2d",this.videoContext.ctx2d?void 0:new Error("create 2d context failed"))),this.videoContext.available}get smallTrack(){return this.smallDestination.videoTrack}get hasSmall(){return!!this.smallTrackSource||!!this.smallImageSource}get initialTrack(){var e;return this._isOpenVirtualBackground&&this._virtualBackgroundTrack?this._virtualBackgroundTrack:null==(e=this.cameraTrack)?void 0:e.mediaTrack}_setMainOutput(e){let t=this.cameraTrack,{small:i,settings:n}=t;return i&&(this.smallVideoContext.available||(this.smallVideoContext.create({alpha:!1,use2d:!0}),this.smallDestination=new DV(this.smallVideoContext,i)),this.smallVideoContext.frameRate=i.frameRate,this.smallDestination.resolution=i,e?(this.smallTrackSource&&(this.smallTrackSource.close(),delete this.smallTrackSource),this.smallImageSource?this.smallImageSource.image=e:(this.smallImageSource=this.smallVideoContext.createVideoImageSource(e),this.smallImageSource.connect(this.smallDestination))):(this.smallImageSource&&(this.smallImageSource.close(),delete this.smallImageSource),this.smallTrackSource?this.smallTrackSource.replaceTrack(this.initialTrack):(this.smallTrackSource=this.smallVideoContext.createVideoTrackSource(this.initialTrack),this.smallTrackSource.width=n.width,this.smallTrackSource.height=n.height,this.smallTrackSource.connect(this.smallDestination)))),t.setOutputMediaStreamTrack(e?this.destination.videoTrack:this.initialTrack)}update(){return cb(this,null,(function*(){var e,t;if(!this.cameraTrack||!this.cameraTrack.mediaTrack)return;if(!this.active)return this.cameraNode&&this.clear(),this._setMainOutput();{let{settings:e,profile:t}=this.cameraTrack;this.destination||(this.destination=this.videoContext.createVideoTrackDestination({name:"mainDestination"})),this.cameraNode?this.cameraNode.replaceTrack(this.initialTrack):(this.cameraNode=this.videoContext.createVideoTrackSource(this.initialTrack),this.cameraNode.resize(e.width,e.height)),this.videoContext.frameRate=t.frameRate}let i=this.cameraNode;return i.disconnect(),this._isMirror&&(this.mirrorNode||(this.mirrorNode=new MV(this.videoContext)),i=i.connect(this.mirrorNode),i.disconnect(),this._log.info("start mirror")),this.mixNode&&this.mixNode.close(),delete this.mixNode,(this._isMixScreen||this._hasWaterMark)&&(this.mixNode=new VV(this.videoContext),i.connect(this.mixNode,{zIndex:1}),this._hasWaterMark&&!this.waterMarkNode&&this._waterMarkOption&&(this.waterMarkNode=this.videoContext.createVideoImageSource(this._waterMarkOption.image),this.waterMarkNode.resize(this._waterMarkOption.width,this._waterMarkOption.height),this.waterMarkNode.x=this._waterMarkOption.x,this.waterMarkNode.y=this._waterMarkOption.y),null==(e=this.waterMarkNode)||e.connect(this.mixNode,{zIndex:2}),this.screenTrack&&!this.screenNode&&(this.screenNode=this.videoContext.createVideoTrackSource(this.screenTrack.mediaTrack)),null==(t=this.screenNode)||t.connect(this.mixNode,{zIndex:0}),i=this.mixNode,this._log.info("start mix","".concat(this.mixNode.width,"x").concat(this.mixNode.height))),i.connect(this.destination),this._setMainOutput(this.videoContext._canvas)}))}changeInput(e,t){return this._log.info("change input"),e instanceof lL?this.setScreenTrack(e):e instanceof aL?this.setCameraTrack(e):e instanceof bL?e.setOutputMediaStreamTrack(e.mediaTrack):void 0}removeInput(e){var t;e instanceof lL?(null==(t=this.screenNode)||t.close(),delete this.screenNode,delete this.screenTrack,this.update()):e instanceof aL&&(this.clear(),delete this.cameraTrack,this.smallImageSource&&(this.smallImageSource.close(),delete this.smallImageSource),this.smallTrackSource&&(this.smallTrackSource.close(),delete this.smallTrackSource))}setCameraTrack(e){return cb(this,null,(function*(){return this.cameraTrack=e,this._isOpenVirtualBackground&&(yield this.updateAr()),this.update()}))}setScreenTrack(e){return this.screenTrack=e,this._isMixScreen&&(this.screenNode?this.screenNode.replaceTrack(e.mediaTrack):this.update()),e.setOutputMediaStreamTrack(e.mediaTrack)}loadImage(e){return new Promise(((t,i)=>{let n=new Image;n.crossOrigin="anonymous",n.src=e,n.onload=()=>t(n),n.onerror=i}))}setWatermark(e){return cb(this,null,(function*(){let t=yield this.loadImage(e.imageUrl),{x:i=0,y:n=0,width:r=t.width,height:o=t.height}=e;this._hasWaterMark=!0,this._waterMarkOption={x:i,y:n,width:r,height:o,image:t},this._log.info("start watermark",JSON.stringify({x:i,y:n,width:r,height:o})),this.update()}))}stopWatermark(){var e;!this._hasWaterMark||(this._hasWaterMark=!1,this._log.info("stop watermark"),null==(e=this.waterMarkNode)||e.close(),delete this.waterMarkNode,this.update())}get mixScreen(){return this._isMixScreen}set mixScreen(e){var t;this._isMixScreen=e,this._isMixScreen||(null==(t=this.screenNode)||t.close(),delete this.screenNode),this.update()}set mirror(e){var t;this._isMirror=e,this._isMirror||(null==(t=this.mirrorNode)||t.close(),delete this.mirrorNode),this.update()}get mirror(){return this._isMirror}enableAr(e){return cb(this,null,(function*(){this.virtualBackgroundInstance=e,this._isOpenVirtualBackground=!0,this.virtualBackgroundInstance.ar.enable(this.cameraTrack.mediaTrack.clone()),this.virtualBackgroundInstance.ar.listen("output",this.handleArOutput.bind(this))}))}handleArOutput(e){this._virtualBackgroundTrack=e,this.update()}updateAr(){return cb(this,null,(function*(){var e;null==(e=this.cameraTrack)||!e.mediaTrack||(yield this.virtualBackgroundInstance.ar.updateInputTrack(this.cameraTrack.mediaTrack.clone()))}))}disableAr(){var e;!this._isOpenVirtualBackground||(this._isOpenVirtualBackground=!1,null==(e=this._virtualBackgroundTrack)||e.stop(),this._virtualBackgroundTrack=null,this.update())}clear(){this.videoContext.disconnect(),delete this.destination,delete this.cameraNode,delete this.mirrorNode,delete this.screenNode,delete this.waterMarkNode}},FV=0,BV=class extends Ww{constructor(e){super("room"),this.seq=++FV,this.role="anchor",this.localTracks=new Set,this.enableAutoPlayDialog=!0,this.autoReceiveAudio=!0,this.autoReceiveVideo=!0,this.scheduleResult={domains:null,iceServers:null,iceTransportPolicy:null,trtcAutoConf:null},this._isUsingCachedSchedule=!1,this._log=jO.createLogger({id:"r".concat(this.seq)}),this._joinedTimestamp=0,this._isDestroyed=!1,this.useStringRoomId=!!e.useStringRoomId,aO(e.autoReceiveAudio)&&(this.autoReceiveAudio=e.autoReceiveAudio),aO(e.autoReceiveVideo)&&(this.autoReceiveVideo=e.autoReceiveVideo),aO(e.enableAutoPlayDialog)&&(this.enableAutoPlayDialog=e.enableAutoPlayDialog),this.keyPointManager=new dV({room:this,frameWorkType:e.frameWorkType,component:e.component,language:e.language}),this.callDurationCalculator=new hV({room:this}),this.badCaseDetector=new pV({room:this}),this.audioManager=new vL({room:this}),this.videoManager=new UV({room:this})}get isMainStreamPublished(){for(let e of this.localTracks)if(4&e.mediaType)return!0;return!1}get isAuxStreamPublished(){for(let e of this.localTracks)if(2&e.mediaType)return!0;return!1}get hasAuxStream(){for(let e of this.remotePublishedUserMap.values())if(e.muteState.hasAuxiliary)return!0;return this.isAuxStreamPublished}getLogger(){return this._log}get isJoined(){return"joined"===this.state}get isLeft(){return"left"===this.state}addTrack(e){return cb(this,null,(function*(){return this.publish(e)}))}removeTrack(e){return cb(this,null,(function*(){return this.unpublish(e)}))}replaceTrack(e){return cb(this,null,(function*(){}))}setEncodedDataProcessingListener(e){throw new Error("Method not implemented.")}enableAIVoice(e){throw new Error("Method not implemented.")}setProxyServer(e){if(oO(e))e.startsWith("wss://")?this.proxy_ws=e:e.startsWith("https://")&&(this.proxy_wt=e);else if(ZD(e)){let{websocketProxy:t,webtransportProxy:i,loggerProxy:n,scheduleProxy:r,unifiedProxy:o}=e;this.proxy_ws=t,this.proxy_wt=i,this.proxy_unified=o,o?(EV([o,o]),mN("https://".concat(o))):(n&&mN(n),r&&EV(r))}}getRemoteAudioStats(){return cb(this,null,(function*(){let e={};return this.remotePublishedUserMap.forEach((t=>{e[t.userId]=t.remoteAudioTrack.stat})),e}))}getTransportStats(){return cb(this,null,(function*(){var e;let t={rtt:(null==(e=this.quality)?void 0:e.uplinkRTT)||0,downlinksRTT:{}};if(this.quality)for(let i of this.quality.downlinkInfo)t.downlinksRTT[i.userId]=i.rtt;return t}))}getRemoteVideoStats(){return cb(this,arguments,(function(){var e=this;let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"main";return function*(){let i={};return e.remotePublishedUserMap.forEach((e=>{let n="auxiliary"===t?e.remoteAuxiliaryTrack:e.remoteVideoTrack;i[e.userId]=n.stat})),i}()}))}checkDestroy(){if(this._isDestroyed)throw new Tb({code:fb.INVALID_OPERATION,message:QO({key:zO.CLIENT_DESTROYED,data:{funName:"join"}})})}destroy(){if(this.isJoined)throw this._log.warn(KO.INVALID_DESTROY),new Tb({code:fb.INVALID_OPERATION,message:QO({key:zO.INVALID_DESTROY})});this._log.info("destroy room"),this.audioManager.destroy(),this.videoManager.destroy(),this.keyPointManager.destroy(),this.callDurationCalculator.destroy(),this.badCaseDetector.destroy(),this._isDestroyed=!0,UO.emit(BO.ROOM_DESTROY,{room:this})}schedule(e,t,i){return cb(this,null,(function*(){var n,r;let o=gO();try{let{isCached:s,result:a,detailCost:c}=yield gV({userId:this.userId,sdkAppId:this.sdkAppId,roomId:e,useStringRoomId:this.useStringRoomId,version:i,userSig:this.userSig,frameWorkType:t});this._isUsingCachedSchedule=s,this._log.info("schedule cache:".concat(+s," ").concat(OO(a,{keysToExclude:["username","credential"]}))),s&&UO.once(BO.JOIN_RECEIVED_CMD_RES,(()=>this.sendAbilityStatus({scheduleCache:1}))),this.scheduleResult=eb(eb({},this.scheduleResult),a),sO(null==(n=a.config)?void 0:n.retryCount)&&oD(a.config.retryCount),oO(null==(r=a.config)?void 0:r.loggerDomain)&&mN(a.config.loggerDomain),UO.emit(BO.JOIN_SCHEDULE_SUCCESS,{room:this,schedule:this.scheduleResult,detailCost:c}),UO.emit(BO.API_SUCCESS_RATE,{room:this,apiName:"schedule",cost:gO()-o})}catch(a){throw UO.emit(BO.API_SUCCESS_RATE,{room:this,apiName:"schedule",error:a}),a}}))}},HV=new WeakMap,jV=new WeakMap;function GV(){return function(e,t,i){let n=i.value,r=e=>{let{fn:t,args:i,context:n,resolve:r,reject:o}=e;t.apply(n,i).then(r,o)};return i.value=function(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];return new Promise(((e,i)=>{if(HV.has(this)){let o=HV.get(this),{length:s}=o;o.push({fn:n,args:t,context:this,resolve:e,reject:i}),0===s&&r({fn:n,args:t,context:this,resolve:e,reject:i})}else HV.set(this,[{fn:n,args:t,context:this,resolve:e,reject:i}]),r({fn:n,args:t,context:this,resolve:e,reject:i})})).finally((()=>{let e=HV.get(this);e&&(e.shift(),e[0]&&r(eb({},e[0])))}))},i}}function WV(e){return function(t,i,n){let r=n.value,o=t=>sO(e)?t[e]:e(...t),s=e=>{let{fn:t,args:i,context:n,resolve:r,reject:a}=e;t.apply(n,i).then(r,a).finally((()=>{if(jV.has(n)&&jV.get(n).has(o(i))){let e=jV.get(n).get(o(i));e&&(e.shift(),e[0]&&s(eb({},e[0])))}}))};return n.value=function(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];return new Promise(((e,i)=>{if(jV.has(this))if(jV.get(this).has(o(t))){let n=jV.get(this).get(o(t));if(n){let{length:o}=n;n.push({fn:r,args:t,context:this,resolve:e,reject:i}),0===o&&s({fn:r,args:t,context:this,resolve:e,reject:i})}}else jV.get(this).set(o(t),[{fn:r,args:t,context:this,resolve:e,reject:i}]),s({fn:r,args:t,context:this,resolve:e,reject:i});else{let n=new Map;n.set(o(t),[{fn:r,args:t,context:this,resolve:e,reject:i}]),jV.set(this,n),s({fn:r,args:t,context:this,resolve:e,reject:i})}}))},n}}var JV,zV=rb(lb()),KV=rb(pb()),qV=e=>{let{serverAbility:t,clientAbility:i,offerSDP:n,enableCustomMessage:r}=e,o=Hx(n),s={extmapAllowMixed:"extmap-allow-mixed",groups:o.groups,icelite:"ice-lite",media:[],msidSemantic:{semantic:"",token:"WMS"},name:"-",origin:{address:"127.0.0.1",username:"-",sessionId:String(Date.now()),sessionVersion:1,netType:"IN",ipVer:4},timing:{start:0,stop:0},version:0},a={candidates:t.candidates.map((e=>({component:1,foundation:"1",generation:0,ip:e.ip,port:e.port,priority:e.priority,transport:e.foundation,type:e.type}))),connection:{version:4,ip:"0.0.0.0"},direction:MN.TRANSCEIVER_DIRECTION_RECVONLY,ext:t.audio.extensions.map((e=>({value:e.id,uri:e.uri}))),fingerprint:{type:t.dtls.hash,hash:t.dtls.fingerprint},fmtp:[{payload:t.audio.codecs[0].payload,config:t.audio.codecs[0].fmtp}],icePwd:t.ice.password,iceUfrag:t.ice.ufrag,mid:"0",payloads:String(t.audio.codecs[0].payload),port:o.media[0].port,protocol:o.media[0].protocol,type:MN.AUDIO,setup:t.dtls.setup,rtcpFb:t.audio.codecs[0].rtcpfb.map((e=>({payload:t.audio.codecs[0].payload,type:e.id,subtype:e.params[0]}))),rtcpMux:"rtcp-mux",rtcpRsize:"rtcp-rsize",rtp:[{payload:t.audio.codecs[0].payload,codec:t.audio.codecs[0].codec,rate:t.audio.codecs[0].rate,encoding:t.audio.codecs[0].channels}]};return s.media.push(a),[1,2,3].forEach((e=>{s.media.push(YV({mid:e,serverAbility:t,clientAbility:i,parsedOffer:o}))})),r&&s.media.push(o.media.find((e=>"dc"===e.mid))),jx(s)},YV=e=>{let{mid:t,serverAbility:i,clientAbility:n,parsedOffer:r,useAllCodec:o=!1}=e,s={candidates:i.candidates.map((e=>({component:1,foundation:"1",generation:0,ip:e.ip,port:e.port,priority:e.priority,transport:e.foundation,type:e.type}))),connection:{version:4,ip:"0.0.0.0"},direction:MN.TRANSCEIVER_DIRECTION_RECVONLY,ext:i.video.extensions.map((e=>({value:e.id,uri:e.uri}))),fingerprint:{type:i.dtls.hash,hash:i.dtls.fingerprint},fmtp:[],icePwd:i.ice.password,iceUfrag:i.ice.ufrag,mid:String(t),payloads:"",port:r.media[0].port,protocol:r.media[0].protocol,type:MN.VIDEO,setup:i.dtls.setup,rtcpFb:[],rtcpMux:"rtcp-mux",rtcpRsize:"rtcp-rsize",rtp:[]};if(i.video.codecs.length>0)if(o)for(let a=0;a<i.video.codecs.length;a++)QV(s,i.video.codecs[a]);else{let e=i.video.codecs.findIndex((e=>e.codec.toLowerCase()===(i.useVp8?"vp8":"h264")));QV(s,i.video.codecs[e])}else if(o)for(let a=0;a<n.video.codecs.length;a++)QV(s,n.video.codecs[a]);else QV(s,n.video.codecs[0]);return s.payloads=s.payloads.trim(),s},QV=(e,t)=>{e.payloads="".concat(e.payloads," ").concat(t.payload),e.fmtp.push({payload:t.payload,config:t.fmtp}),e.rtcpFb=[...e.rtcpFb||[],...(t.rtcpfb||t.rtcpFb).map((e=>({payload:t.payload,type:e.id,subtype:e.params[0]})))],e.rtp.push({payload:t.payload,codec:t.codec.toUpperCase(),rate:t.rate}),t.rtx&&(e.payloads="".concat(e.payloads," ").concat(t.rtx),e.fmtp.push({payload:t.rtx,config:"apt=".concat(t.payload)}),e.rtp.push({payload:t.rtx,codec:"rtx",rate:t.rate}))},XV=e=>{let t=KV.default.parse(e);return t.media.forEach((e=>{var i;(e.type===MN.AUDIO||e.type===MN.VIDEO)&&(function(e){if(!e.rtcpFb)return;let t=[];e.rtcpFb.forEach(((i,n)=>{var r;t.push(i),e.rtcpFb&&(null==(r=e.rtcpFb[n+1])?void 0:r.payload)!==i.payload&&"rrtr"!==i.type&&t.push({payload:i.payload,type:"rrtr"})})),e.rtcpFb=t}(e),function(e){e.type===MN.VIDEO&&e.fmtp&&e.fmtp.forEach((e=>{e.config.includes("apt")||(e.config+=";sps-pps-idr-in-keyframe=1")}))}(e),function(e){e.type===MN.AUDIO&&e.fmtp&&e.fmtp.forEach((e=>{e.config+=";sprop-stereo=1;stereo=1"}))}(e),function(e){let t=new Set(["urn:ietf:params:rtp-hdrext:sdes:mid","urn:ietf:params:rtp-hdrext:sdes:rtp-stream-id","urn:ietf:params:rtp-hdrext:sdes:repaired-rtp-stream-id"]);e.ext&&(e.ext=e.ext.filter((e=>!t.has(e.uri))))}(e)),(null==(i=e.payloads)?void 0:i.includes("datachannel"))&&t.groups&&e.mid&&(t.groups[0].mids=t.groups[0].mids.replace(e.mid,"dc"),e.mid="dc")})),KV.default.write(t)},$V=((JV=$V||{}).TRACK="track",JV.DATA_CHANNEL_MESSAGE="data_channel_msg",JV[JV.CONNECTION_STATE_CHANGED="connection-state-changed"]="CONNECTION_STATE_CHANGED",JV[JV.FIREWALL_RESTRICTION="firewall-restriction"]="FIREWALL_RESTRICTION",JV.RECONNECTED="spc-reconnected",JV.RECONNECT_FAILED="spc-reconnect-failed",JV.ERROR="error",JV),ZV=0,eU=!1,tU=new Set,iU=1,nU=class extends zV.default{constructor(e){let{signalChannel:t,room:i,enableCustomMessage:n}=e;super(),sb(this,"stat",{iceStartTime:0,iceEndTime:0,dtlsStartTime:0,dtlsEndTime:0,peerConnectionStartTime:0,peerConnectionEndTime:0}),sb(this,"currentState","DISCONNECTED"),sb(this,"_room"),sb(this,"_signalChannel"),sb(this,"_peerConnection",null),sb(this,"_datachannel",null),sb(this,"_enableCustomMessage"),sb(this,"_log"),sb(this,"_downlinkMIDMap",new Map),sb(this,"_reconnectionTimer",-1),sb(this,"reconnectionCount",0),sb(this,"_clientAbility",null),sb(this,"_serverAbility",null),sb(this,"addDownlinkQueue",new Set),sb(this,"removeDownlinkQueue",new Set),sb(this,"_parsedAnswer",null),sb(this,"_updateSDPPromise",null),sb(this,"_waitForPCConnectedPromise"),sb(this,"_waitForPCConnectedPromiseReject",null),sb(this,"_isSDPLogged",!1),this._room=i,this._enableCustomMessage=n,this._signalChannel=t,this._log=jO.createLogger({id:"spc".concat(iU++),userId:this._room.userId,sdkAppId:this._room.sdkAppId})}get isH264EncodeSupported(){let e=this._room.checkSystemResult.detail.isH264EncodeSupported;return this._serverAbility&&(e=e&&!!this._serverAbility.video.codecs.find((e=>"h264"===e.codec.toLowerCase()))),e}get isVP8EncodeSupported(){let e=this._room.checkSystemResult.detail.isVp8EncodeSupported;return this._serverAbility&&(e=e&&this._serverAbility.useVp8),e}get uplinkSSRC(){return this._peerConnection&&this._peerConnection.localDescription?(e=>{let t=Hx(e),i={audioSsrc:0,audioRtxSsrc:0,bigVideoSsrc:0,bigVideoRtxSsrc:0,smallVideoSsrc:0,smallVideoRtxSsrc:0,auxVideoSsrc:0,auxVideoRtxSsrc:0};return t.media.forEach(((e,t)=>{var n;if(e.ssrcs&&!rO(e.ssrcs[0].id)){let r=Number(e.ssrcs[0].id),o=Number(null==(n=e.ssrcs.filter((e=>"cname"===e.attribute))[1])?void 0:n.id);switch(t){case 0:i.audioSsrc=r;break;case 1:i.bigVideoSsrc=r,i.bigVideoRtxSsrc=o;break;case 2:i.smallVideoSsrc=r,i.smallVideoRtxSsrc=o;break;case 3:i.auxVideoSsrc=r,i.auxVideoRtxSsrc=o}}})),i})(this._peerConnection.localDescription.sdp):{audioSsrc:0,audioRtxSsrc:0,bigVideoSsrc:0,bigVideoRtxSsrc:0,smallVideoSsrc:0,smallVideoRtxSsrc:0,auxVideoSsrc:0,auxVideoRtxSsrc:0}}get isReconnecting(){return"RECONNECTING"===this.currentState||this._reconnectionTimer>0||this.reconnectionCount>0}get dtlsTransport(){if(!this._peerConnection)return null;let e=this._peerConnection.getSenders();return 0===e.length?null:e[0].transport}initialize(){return cb(this,null,(function*(){try{this._peerConnection=new RTCPeerConnection({offerExtmapAllowMixed:!0,iceServers:this._room.getIceServers(),iceTransportPolicy:this._room.getIceTransportPolicy(),sdpSemantics:this._room.sdpSemantics,bundlePolicy:"max-bundle",rtcpMuxPolicy:"require",tcpCandidatePolicy:"disable",IceTransportsType:"nohost"}),this._peerConnection.oniceconnectionstatechange=()=>{if(!this._peerConnection)return;let e=this._peerConnection.iceConnectionState;this._log.debug("ice state: ".concat(e)),"checking"===e&&0===this.stat.iceStartTime?this.stat.iceStartTime=Date.now():"connected"===e&&0===this.stat.iceEndTime&&(this.stat.iceEndTime=Date.now())},this._peerConnection.onconnectionstatechange=this.onConnectionStateChange.bind(this),this._peerConnection.ontrack=e=>this.emit("track",e),this._enableCustomMessage&&(this._datachannel=this._peerConnection.createDataChannel("".concat(this._room.userId,"dc")),this._datachannel.binaryType="arraybuffer",this._datachannel.onopen=()=>{this._log.info("datachannel open")},this._datachannel.onclose=()=>{this._log.warn("datachannel close")},this._datachannel.onmessage=e=>{let t=new oU(e.data);this.emit("data_channel_msg",{data:t})},this._datachannel.onerror=e=>{this._log.warn("datachannel error",e)}),this._peerConnection.addTransceiver(MN.AUDIO,{direction:MN.TRANSCEIVER_DIRECTION_SENDONLY}),this._peerConnection.addTransceiver(MN.VIDEO,{direction:MN.TRANSCEIVER_DIRECTION_SENDONLY}),this._peerConnection.addTransceiver(MN.VIDEO,{direction:MN.TRANSCEIVER_DIRECTION_SENDONLY}),this._peerConnection.addTransceiver(MN.VIDEO,{direction:MN.TRANSCEIVER_DIRECTION_SENDONLY});let e=yield this._peerConnection.createOffer();return yield this.setOffer(e),this.dtlsTransport&&(this.dtlsTransport.onstatechange=()=>{let{dtlsTransport:e}=this;!e||(this._log.debug("dtls state: ".concat(e.state)),"connecting"===e.state&&0===this.stat.dtlsStartTime?this.stat.dtlsStartTime=Date.now():"connected"===e.state&&0===this.stat.dtlsEndTime&&(this.stat.dtlsEndTime=Date.now()))}),this._clientAbility=((e,t)=>{var i,n;let r=Hx(e),o={ice:{ufrag:"",password:""},dtls:{hash:"",fingerprint:"",setup:""},audio:{codecs:[],extensions:[]},video:{codecs:[],extensions:[]},useDataChannel:t};o.ice.ufrag=String(r.media[0].iceUfrag),o.ice.password=r.media[0].icePwd||"",r.fingerprint&&(o.dtls.hash=r.fingerprint.type,o.dtls.fingerprint=r.fingerprint.hash,o.dtls.setup=r.setup||""),r.media[0].fingerprint&&(o.dtls.hash=r.media[0].fingerprint.type,o.dtls.fingerprint=r.media[0].fingerprint.hash),o.dtls.setup=r.media[0].setup||"";let s=r.media[0],a=r.media[1];s.ext&&(o.audio.extensions=s.ext.map((e=>({id:e.value,uri:e.uri})))),a.ext&&(o.video.extensions=a.ext.map((e=>({id:e.value,uri:e.uri}))));let c={codec:s.rtp[0].codec,fmtp:s.fmtp[0].config,payload:s.fmtp[0].payload,rate:s.rtp[0].rate,channel:s.rtp[0].encoding,rtcpFb:[],rtx:0};null==(i=s.rtcpFb)||i.forEach((e=>{let{payload:t,type:i,subtype:n}=e;if(t===c.payload){let e={id:i,params:[]};n&&e.params.push(n),c.rtcpFb.push(e)}})),o.audio.codecs.push(c);for(let l=0;l<a.rtp.length;l++){if(["rtx","red","ulpfec"].includes(a.rtp[l].codec))continue;let e=a.fmtp.filter((e=>e.payload===a.rtp[l].payload))[0];o.video.codecs.push({payload:a.rtp[l].payload,codec:a.rtp[l].codec,fmtp:e?e.config:"",rate:a.rtp[l].rate,rtx:"rtx"===(null==(n=a.rtp[l+1])?void 0:n.codec)?a.rtp[l+1].payload:0,rtcpFb:((null==a?void 0:a.rtcpFb)||[]).filter((e=>e.payload===a.rtp[l].payload)).map((e=>{let{type:t,subtype:i}=e;return{id:t,params:i?[i]:[]}}))})}return o})(e.sdp,this._enableCustomMessage),this._clientAbility}catch(aN){throw this._log.error("initialize failed ".concat(aN)),aN}}))}connect(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return cb(this,null,(function*(){try{if("CONNECTED"===this.currentState)return;let i=gO(),n={type:"answer",sdp:qV({serverAbility:e,clientAbility:this._clientAbility,offerSDP:this._peerConnection.localDescription.sdp,enableCustomMessage:this._enableCustomMessage})};this._serverAbility=e,yield this.setAnswer(n),yield this.waitForPeerConnectionConnected(),t||UO.emit(BO.API_SUCCESS_RATE,{room:this._room,apiName:"SPCConnect",cost:Math.min(gO()-i,3e4)})}catch(cN){let i=cN instanceof Tb&&cN.code===fb.API_CALL_ABORTED;throw i||this._log.error("connect failed: ".concat(cN),e),this.reset(),!i&&!this.isReconnecting&&(UO.emit(BO.API_SUCCESS_RATE,{room:this._room,apiName:"SPCConnect",error:cN}),this.emitConnectionStateChangedEvent("DISCONNECTED"),this.startReconnection()),cN}}))}reconnect(){return cb(this,null,(function*(){if(-1===this._reconnectionTimer){if(!this._signalChannel.isConnected)return this._log.warn("reconnect() wait signal channel is connected"),void this._signalChannel.once(XM,this.reconnect,this);try{this.reconnectionCount++,this._log.warn("reconnect() trying [".concat(this.reconnectionCount,"]")),this.reset();let e=yield this.initialize(),t=yield this._signalChannel.sendWaitForResponse({command:Rx,responseCommand:rx.REBUILD_PEER_CONNECTION_RES,data:{ability:e},enableLog:!1});yield this.connect(t.data.data.ability,!0),this._log.warn("reconnect() successfully"),this.stopReconnection(),this.emit("spc-reconnected")}catch(aN){if(!this.isReconnecting)return;if(null!=aN&&aN.message.includes("timeout")){let e=tO(this.reconnectionCount);this._log.warn("reconnect() timeout, try again after ".concat(e/1e3,"s")),this._reconnectionTimer=window.setTimeout((()=>{this.clearReconnectionTimer(),this.reconnect()}),e)}else this._log.error("reconnect() failed ".concat(aN)),UO.emit(BO.API_SUCCESS_RATE,{room:this._room,apiName:"SPCReconnect",error:aN}),this.reconnectionCount>=sD()&&this._log.warn("SDK has tried reconnect for ".concat(sD()," times, but all failed, please check your network")),this.stopReconnection(),this.emitConnectionStateChangedEvent("DISCONNECTED"),this.emit("error")}}else this._log.warn("reconnect() is reconnecting, ignore current reconnection")}))}getPeerConnection(){return this._peerConnection}startReconnection(){return cb(this,null,(function*(){this._log.warn("start reconnect"),this.emitConnectionStateChangedEvent("RECONNECTING");let e=gO();yield this.reconnect(),UO.emit(BO.API_SUCCESS_RATE,{room:this._room,apiName:"SPCReconnect",cost:Math.min(gO()-e,3e4)})}))}stopReconnection(){this.isReconnecting&&(this._log.info("stop reconnect"),this.reconnectionCount=0,this.clearReconnectionTimer(),this._signalChannel.off(XM,this.reconnect,this))}checkPeerConnectionToReconnect(){var e;!this.isReconnecting&&(null==(e=this._peerConnection)?void 0:e.connectionState)===nD.CLOSED&&this.startReconnection()}clearReconnectionTimer(){-1!==this._reconnectionTimer&&(clearTimeout(this._reconnectionTimer),this._reconnectionTimer=-1)}onConnectionStateChange(e){let t=this._peerConnection.iceConnectionState,i=this.getDTLSTransportState();this._log.info("connectionState: ".concat(e.target.connectionState," ICE: ").concat(t," DTLS: ").concat(i)),e.target.connectionState===nD.CONNECTING&&(0===this.stat.peerConnectionStartTime&&(this.stat.peerConnectionStartTime=Date.now()),this.emitConnectionStateChangedEvent("CONNECTING")),(e.target.connectionState===nD.FAILED||e.target.connectionState===nD.CLOSED)&&(this.emitConnectionStateChangedEvent("DISCONNECTED"),this.startReconnection()),(e.target.connectionState===nD.CONNECTED||e.target.connectionState===nD.COMPLETED)&&(0===this.stat.peerConnectionEndTime&&(this.stat.peerConnectionEndTime=Date.now()),UO.emit(BO.SINGLE_CONNECTION_STAT,{room:this._room,stat:{ice:this.stat.iceEndTime-this.stat.iceStartTime,dtls:this.stat.dtlsEndTime-this.stat.dtlsStartTime,peerConnection:this.stat.peerConnectionEndTime-this.stat.peerConnectionStartTime}}),this.logSelectedCandidate(),this.emitConnectionStateChangedEvent("CONNECTED"))}getDTLSTransportState(){if(!this._peerConnection)return iD;let e=null;return Sw()&&0!==this._peerConnection.getSenders().length?(e=this._peerConnection.getSenders()[0].transport,Ew()&&0!==this._peerConnection.getReceivers().length&&e?e.state:iD):iD}emitConnectionStateChangedEvent(e){e!==this.currentState&&("RECONNECTING"===this.currentState&&"CONNECTING"===e||(this.emit($V.CONNECTION_STATE_CHANGED,{prevState:this.currentState,state:e}),this.currentState=e))}logSelectedCandidate(){return cb(this,null,(function*(){if(!this._peerConnection)return;let e=yield this._peerConnection.getStats();for(let[t,i]of e)if(hw(i)){let t=e.get(i.localCandidateId),n=e.get(i.remoteCandidateId);t&&this._log.info("local candidate: ".concat(t.candidateType," ").concat(t.protocol,":").concat(t.ip||t.address,":").concat(t.port," ").concat(t.networkType||""," ").concat("relay"===t.candidateType?"relayProtocol:".concat(t.relayProtocol):"")),n&&this._log.info("remote candidate: ".concat(n.candidateType," ").concat(n.protocol,":").concat(n.ip||n.address,":").concat(n.port));break}}))}waitForPeerConnectionConnected(){return this._waitForPCConnectedPromise||(this._waitForPCConnectedPromise=new Promise(((e,t)=>{if("CONNECTED"===this.currentState)return e();this._waitForPCConnectedPromiseReject=t;let i=t=>{"CONNECTED"===t.state&&(clearTimeout(o),r(),e())},n=e=>{let{room:i}=e;i===this._room&&(clearTimeout(o),r(),t(new Tb({code:fb.API_CALL_ABORTED,message:QO({key:zO.CONNECTION_ABORTED,data:"leave room"})})))},r=()=>{UO.off(BO.LEAVE_SUCCESS,n,this),this.off($V.CONNECTION_STATE_CHANGED,i,this)},o=setTimeout((()=>{r();let e=new Tb({code:fb.API_CALL_TIMEOUT,message:"connection timeout"});ZV+=1,(e=>ZV>2&&!eU&&0===tU.size&&e)(this._signalChannel.isConnected)&&(this._log.warn("firewall restrition"),eU=!0,this.emit($V.FIREWALL_RESTRICTION)),t(e)}),ID);UO.on(BO.LEAVE_SUCCESS,n,this),this.on($V.CONNECTION_STATE_CHANGED,i,this)})),this._waitForPCConnectedPromise=this._waitForPCConnectedPromise.finally((()=>{this._waitForPCConnectedPromise=null,this._waitForPCConnectedPromiseReject=null}))),this._waitForPCConnectedPromise}waitForReconnected(){return this.isReconnecting?new Promise(((e,t)=>{this.once("spc-reconnected",e),this.once("error",t)})):Promise.resolve()}addDownlink(e){return cb(this,null,(function*(){if(this._log.info("addDownlink(".concat(e.userId,") trying")),this.isReconnecting&&(yield this.waitForReconnected()),this.updateLocalAndRemoteSDPConfig(e),0===this.addDownlinkQueue.size)try{yield this.updateSDP({isNeedToCreateOffer:!0}),this._log.info("addDownlink(".concat(e.userId,") done"))}catch(aD){this._log.info("addDownlink(".concat(e.userId,") failed")),yield this.startReconnection()}}))}updateLocalAndRemoteSDPConfig(e){let{ssrc:t,userId:i,tinyId:n}=e;if(!this._peerConnection)return;this._log.info("updateLocalAndRemoteSDPConfig ".concat(i," ").concat(JSON.stringify(t)));let r,o,s,a=this._peerConnection.getTransceivers().filter((e=>"inactive"===e.direction)).slice(0,3).map((e=>(e.direction=MN.TRANSCEIVER_DIRECTION_RECVONLY,Number(e.mid))));if(0===a.length&&(this._peerConnection.addTransceiver(MN.AUDIO,{direction:MN.TRANSCEIVER_DIRECTION_RECVONLY}),this._peerConnection.addTransceiver(MN.VIDEO,{direction:MN.TRANSCEIVER_DIRECTION_RECVONLY}),this._peerConnection.addTransceiver(MN.VIDEO,{direction:MN.TRANSCEIVER_DIRECTION_RECVONLY})),this._parsedAnswer||(this._parsedAnswer=Hx(this._peerConnection.remoteDescription.sdp)),3===a.length)r=this._parsedAnswer.media.find((e=>Number(e.mid)===Number(a[0]))),o=this._parsedAnswer.media.find((e=>Number(e.mid)===Number(a[1]))),s=this._parsedAnswer.media.find((e=>Number(e.mid)===Number(a[2])));else{r=JSON.parse(JSON.stringify(this._parsedAnswer.media[0]));let e=YV({mid:1,serverAbility:this._serverAbility,clientAbility:this._clientAbility,parsedOffer:Hx(this._peerConnection.localDescription.sdp),useAllCodec:!0});o=JSON.parse(JSON.stringify(e)),s=JSON.parse(JSON.stringify(e)),r.mid=this._parsedAnswer.media.length,this._parsedAnswer.media.push(r),o.mid=this._parsedAnswer.media.length,this._parsedAnswer.media.push(o),s.mid=this._parsedAnswer.media.length,this._parsedAnswer.media.push(s)}r.direction=MN.TRANSCEIVER_DIRECTION_SENDONLY,r.ssrcs=[{id:t.audio,attribute:"cname",value:"".concat(n)},{id:t.audio,attribute:"msid",value:"".concat(n,"-").concat(MN.MAIN," ").concat(n,"-audio")}],o.direction=MN.TRANSCEIVER_DIRECTION_SENDONLY,o.ssrcs=[{id:t.video,attribute:"cname",value:"".concat(n)},{id:t.video,attribute:"msid",value:"".concat(n,"-").concat(MN.MAIN," ").concat(n,"-bigvideo")},{id:t.videoRtx,attribute:"cname",value:"".concat(n)},{id:t.videoRtx,attribute:"msid",value:"".concat(n,"-").concat(MN.MAIN," ").concat(n,"-bigvideo")}],o.ssrcGroups=[{semantics:"FID",ssrcs:"".concat(t.video," ").concat(t.videoRtx)}],s.direction=MN.TRANSCEIVER_DIRECTION_SENDONLY;let c="".concat(n,"-aux");s.ssrcs=[{id:t.auxiliary,attribute:"cname",value:c},{id:t.auxiliary,attribute:"msid",value:"".concat(c," ").concat(n,"-aux").concat(MN.VIDEO)},{id:t.auxiliaryRtx,attribute:"cname",value:"".concat(c," ").concat(n,"-aux").concat(MN.VIDEO)},{id:t.auxiliaryRtx,attribute:"msid",value:"".concat(c," ").concat(n,"-aux").concat(MN.VIDEO)}],s.ssrcGroups=[{semantics:"FID",ssrcs:"".concat(t.auxiliary," ").concat(t.auxiliaryRtx)}],this._parsedAnswer.groups&&(this._parsedAnswer.groups[0].mids=this._parsedAnswer.media.map((e=>e.mid)).join(" ")),this._downlinkMIDMap.set(n,[r.mid,o.mid,s.mid])}removeDownlink(e,t){return cb(this,null,(function*(){if(!this._downlinkMIDMap.has(e)||!this._peerConnection)return;this._log.info("removeDownlink(".concat(t,") trying")),this.isReconnecting&&(yield this.waitForReconnected());let i=this._downlinkMIDMap.get(e),n=!1;this._peerConnection.getTransceivers().forEach((e=>{null!=i&&i.includes(Number(e.mid))&&(n=!0,e.direction="inactive")})),this._parsedAnswer||(this._parsedAnswer=Hx(this._peerConnection.remoteDescription.sdp)),this._parsedAnswer.media.forEach((e=>{null!=i&&i.includes(Number(e.mid))&&(n=!0,e.direction="inactive",e.ssrcs=[],e.ssrcGroups=[])})),0===this.removeDownlinkQueue.size&&n&&(yield this.updateSDP({isNeedToCreateOffer:!0,tinyIdRemoving:e})),this._downlinkMIDMap.delete(e),this._log.info("removeDownlink(".concat(t,") done"))}))}getDownlinkMids(e){return this._downlinkMIDMap.get(e)}setBandwidth(e){return cb(this,null,(function*(){if(!this._peerConnection)return;let{audio:t,bigVideo:i,smallVideo:n,auxVideo:r}=e;try{if(Cw()){let e=this._peerConnection.getSenders().slice(0,4);for(let o=0;o<e.length;o++){let s,a=e[o];0===o&&t?s=t:1===o&&i?s=i:2===o&&n?s=n:3===o&&r&&(s=r),s&&(yield this.setSenderMaxBitrate(a,s))}}else yield this.setBandwidthBySDP(e);this._log.info("setBandwidth ".concat(JSON.stringify(e)))}catch(JV){this._log.error("failed to set bandwidth".concat(JV))}}))}setSenderMaxBitrate(e,t){let i=e.getParameters();return(!i.encodings||0===i.encodings.length)&&(i.encodings=[{}]),"unlimited"===t?delete i.encodings[0].maxBitrate:i.encodings[0].maxBitrate=1e3*t,e.setParameters(i)}setBandwidthBySDP(e){let{audio:t,bigVideo:i,smallVideo:n,auxVideo:r}=e;if(!this._peerConnection||!this._peerConnection.localDescription)return;let o=Hx(this._peerConnection.localDescription.sdp);this._parsedAnswer||(this._parsedAnswer=Hx(this._peerConnection.remoteDescription.sdp));let s=Fb?"TIAS":"AS";t&&(o.media[0].bandwidth=[{type:s,limit:Fb?1e3*t:t}],this._parsedAnswer.media[0].bandwidth=[{type:s,limit:Fb?1e3*t:t}]),i&&(o.media[1].bandwidth=[{type:s,limit:Fb?1e3*i:i}],this._parsedAnswer.media[1].bandwidth=[{type:s,limit:Fb?1e3*i:i}]),n&&(o.media[2].bandwidth=[{type:s,limit:Fb?1e3*n:n}],this._parsedAnswer.media[2].bandwidth=[{type:s,limit:Fb?1e3*n:n}]),r&&(o.media[3].bandwidth=[{type:s,limit:Fb?1e3*r:r}],this._parsedAnswer.media[3].bandwidth=[{type:s,limit:Fb?1e3*r:r}]);let a={type:"offer",sdp:jx(o)};return this.updateSDP({localDescription:a})}updateSDP(e){let{isNeedToCreateOffer:t=!1,localDescription:i,tinyIdRemoving:n}=e;if(!this._parsedAnswer)return;let r=jx(this._parsedAnswer);return this._updateSDPPromise=new Promise(((e,n)=>cb(this,null,(function*(){try{t&&this._peerConnection&&(this._log.info("creating offer"),i=yield this._peerConnection.createOffer()),i&&(yield this.setOffer(i)),yield this.setAnswer({type:"answer",sdp:r}),this._updateSDPPromise=null,e()}catch(c){this._log.error(c),!this._isSDPLogged&&this._peerConnection&&(this._log.warn("transceivers: ".concat(JSON.stringify(this._peerConnection.getTransceivers().map((e=>{let{mid:t,currentDirection:i,direction:n,stopped:r}=e;return{mid:t,currentDirection:i,direction:n,stopped:r}}))))),this._log.warn("parsedAnswer: ".concat(JSON.stringify(this._parsedAnswer))),this._log.warn("local sdp: ".concat(null==i?void 0:i.sdp)||0),this._log.warn("remote sdp: ".concat(r)||0),this._isSDPLogged=!0),this._updateSDPPromise=null,n(c)}})))),this._updateSDPPromise}setOffer(e){return this._log.info("setting offer"),this._peerConnection.setLocalDescription({type:"offer",sdp:XV(e.sdp)})}setAnswer(e){return this._log.info("setting answer"),this._room.enableHWEncoder&&e.sdp&&(e.sdp=e.sdp.replaceAll("42e01f","42001f")),this._peerConnection.setRemoteDescription(e)}sendDataChannelMessage(e){var t;null==(t=this._datachannel)||t.send(e)}reset(){var e;null==(e=this._peerConnection)||e.close(),this._waitForPCConnectedPromise=null,this._parsedAnswer=null}close(){this._log.info("close pc"),this.reset(),this.emitConnectionStateChangedEvent("DISCONNECTED"),this._downlinkMIDMap.clear(),this.stopReconnection(),this.removeAllListeners()}};ob([GV()],nU.prototype,"updateSDP",1);var rU=class{constructor(e){sb(this,"tag"),sb(this,"len"),sb(this,"data");let t=new DataView(e);this.tag=t.getUint16(),this.len=t.getUint16(2),this.data=new Uint8Array(e).slice(4,4+this.len).buffer}},oU=class{constructor(e){sb(this,"tinyId"),sb(this,"data");let t=new DataView(e),i=0,n=[];for(;i<t.byteLength;){let r=t.getUint16(i+2),o=new rU(new Uint8Array(e).slice(i,i+2+2+r).buffer);n.push(o),i+=4+r}n.forEach((e=>{1===e.tag?this.tinyId=(new TextDecoder).decode(e.data):2===e.tag&&(this.data=e.data)}))}},sU=new Set;function aU(){let e=Math.floor(4294967296*Math.random());return sU.has(e)?aU():(sU.add(e),e)}var cU=rb(lb()),lU=class extends cU.default{constructor(e){super(),sb(this,"userId"),sb(this,"tinyId"),sb(this,"_sdpSemantics"),sb(this,"_isUplink"),sb(this,"_room"),sb(this,"_log"),sb(this,"_signalChannel"),sb(this,"_currentState","DISCONNECTED"),sb(this,"_prevTime",-1),sb(this,"_enableSEI"),sb(this,"_sei"),this.userId=e.userId,this.tinyId=e.tinyId,this._room=e.room,this._sdpSemantics=e.room.sdpSemantics,this._isUplink=e.isUplink,this._log=jO.createLogger({id:"n",userId:this._room.userId,remoteUserId:this._isUplink?void 0:this.userId,sdkAppId:this._room.sdkAppId,isLocal:this._isUplink}),this._signalChannel=e.signalChannel,this._enableSEI=e.enableSEI,this._enableSEI&&Nw&&(this._sei=new Lx(this,this._log,this._isUplink))}get _peerConnection(){var e;return(null==(e=this.singlePC)?void 0:e.getPeerConnection())||null}get singlePC(){return this._room.singlePC}close(e){this._log.info("close connection"),this.emit("closed",e),this._sei&&(this._sei.destroy(),this._sei=null)}emitConnectionStateChangedEvent(e){return e!==this._currentState&&(UO.emit(BO.PEER_CONNECTION_STATE_CHANGED,{room:this._room,prevState:this._currentState,state:e,remoteUserId:this._isUplink?void 0:this.userId}),this.emit("connection-state-changed",{prevState:this._currentState,state:e}),this._currentState=e,!0)}getPeerConnection(){return this._peerConnection}getRoom(){return this._room}getUserId(){return this.userId}getTinyId(){return this.tinyId}getCurrentState(){return this._currentState}get isH264(){var e,t;return!(null==(t=null==(e=this._peerConnection)?void 0:e.remoteDescription)||!t.sdp.includes("H264"))}},dU=class extends lU{constructor(e){super(tb(eb({},e),{isUplink:!0})),sb(this,"localMainAudioTrack",null),sb(this,"localMainVideoTrack",null),sb(this,"localAuxAudioTrack",null),sb(this,"localAuxVideoTrack",null),sb(this,"_isPublishingAux",!1),sb(this,"_publishingLocalAudioTrack"),sb(this,"_publishingLocalVideoTrack"),sb(this,"_mediaSettings",{videoCodec:"",videoWidth:0,videoHeight:0,videoBps:0,videoFps:0,audioCodec:"opus",audioFs:0,audioChannel:0,audioBps:0,smallVideoWidth:0,smallVideoHeight:0,smallVideoFps:0,smallVideoBps:0,auxVideoWidth:0,auxVideoHeight:0,auxVideoFps:0,auxVideoBps:0}),sb(this,"_audioManager"),this._audioManager=e.audioManager,this.initialize()}get ssrc(){if(!this.singlePC)return{audio:0,video:0,videoRtx:0,small:0,smallRtx:0,auxiliary:0,auxiliaryRtx:0};let{audioSsrc:e,bigVideoSsrc:t,bigVideoRtxSsrc:i,smallVideoSsrc:n,smallVideoRtxSsrc:r,auxVideoSsrc:o,auxVideoRtxSsrc:s}=this.singlePC.uplinkSSRC;return{audio:e||0,video:t||0,videoRtx:i||0,small:n||0,smallRtx:r||0,auxiliary:o||0,auxiliaryRtx:s||0}}get isMainStreamPublished(){return!(!this.localMainAudioTrack&&!this.localMainVideoTrack)}get isAuxStreamPublished(){return!(!this.localAuxVideoTrack&&!this.localAuxAudioTrack)}get publishState(){var e,t,i,n;let r={audio:!1,bigVideo:!1,smallVideo:!1,auxVideo:!1};if(this._peerConnection){let o=this._peerConnection.getSenders();o&&(Iw()?(r.audio=!(null==(e=o[0])||!e.track),r.bigVideo=!(null==(t=o[1])||!t.track),r.smallVideo=!(null==(i=o[2])||!i.track),r.auxVideo=!(null==(n=o[3])||!n.track)):o.forEach((e=>{e.track&&(e.track.kind===MN.AUDIO?r.audio=!0:(r.bigVideo=!0,this._room.videoManager.hasSmall&&(r.smallVideo=!0)))})))}return r}initialize(){this.installEvents()}reset(){this.uninstallEvents()}close(e){super.close(e),this.reset(),this.emitConnectionStateChangedEvent("DISCONNECTED")}installEvents(){var e;this.listeners("connection-state-changed").includes(this.handleConnectionStateChange)||this.on("connection-state-changed",this.handleConnectionStateChange,this),this.listeners("spc-reconnected").includes(this.onSinglePCReconnected)||null==(e=this.singlePC)||e.on("spc-reconnected",this.onSinglePCReconnected,this)}uninstallEvents(){var e;this.off("connection-state-changed",this.handleConnectionStateChange,this),null==(e=this.singlePC)||e.off("spc-reconnected",this.onSinglePCReconnected,this)}emitConnectionStateChangedEvent(e,t){var i,n,r;let o=this._currentState,s=super.emitConnectionStateChangedEvent(e);return s&&o!==e&&(t?t.emit("connection-state-changed",{prevState:o,state:e}):(null==(i=this.localMainVideoTrack)||i.emit("connection-state-changed",{prevState:o,state:e}),null==(n=this.localAuxVideoTrack)||n.emit("connection-state-changed",{prevState:o,state:e}),null==(r=this._publishingLocalVideoTrack)||r.emit("connection-state-changed",{prevState:o,state:e}))),s}publish(e){return cb(this,arguments,(function(e){var t=this;let{localAudioTrack:i,localVideoTrack:n,isAuxiliary:r}=e;return function*(){var e,o,s,a,c,l;if(!t.singlePC)return;if(yield t.singlePC.waitForPeerConnectionConnected(),i&&(t._publishingLocalAudioTrack=i),n){if(!t.singlePC.isH264EncodeSupported&&!t.singlePC.isVP8EncodeSupported)throw new Tb({code:fb.NOT_SUPPORTED_H264,message:QO({key:zO.NOT_SUPPORTED_H264ENCODE})});Mb&&115===Pk()&&n.profile.width*n.profile.height<=230400&&(t._log.warn("fallback video to 480p"),n.setProfile(PN["480p_2"]),yield n.applyProfile()),t._publishingLocalVideoTrack=n}let d;t._isPublishingAux=r,n&&!r&&n.small&&(d=t._room.videoManager.smallTrack),yw()&&(yield t.publishByTransceiver({localAudioTrack:i,localVideoTrack:n,smallTrack:d,isAuxiliary:r})),t._publishingLocalAudioTrack=null,t._publishingLocalVideoTrack=null,t._isPublishingAux=!1,r?(n&&(t.localAuxVideoTrack=n),i&&(t.localAuxAudioTrack=i)):(n&&(t.localMainVideoTrack=n),i&&(t.localMainAudioTrack=i)),yield t.singlePC.setBandwidth({audio:(null==(e=t.localMainAudioTrack)?void 0:e.profile.bitrate)||(null==(o=t.localAuxAudioTrack)?void 0:o.profile.bitrate),bigVideo:null==(s=t.localMainVideoTrack)?void 0:s.profile.bitrate,smallVideo:null==(c=null==(a=t.localMainVideoTrack)?void 0:a.small)?void 0:c.bitrate,auxVideo:null==(l=t.localAuxVideoTrack)?void 0:l.profile.bitrate}),yield t._signalChannel.sendWaitForResponse({command:bx,responseCommand:rx.SPC_PUBLISH_RESULT,data:tb(eb({},t.singlePC.uplinkSSRC),{state:t.publishState})}),t.sendMediaSettings(),t.installTrackMuteEvents(i,n),t.sendMutedFlag()}()}))}publishByTransceiver(e){let{localAudioTrack:t,localVideoTrack:i,smallTrack:n,isAuxiliary:r}=e;this._log.info("publish by transceiver");let o=null==i?void 0:i.outMediaTrack,s=this._audioManager.mixedAudioTrack,a=this._peerConnection.getTransceivers(),c=[],l=[];if(s){let e=a[0].sender.replaceTrack(s);l.push(0),c.push(e)}if(o)if(r){let e=a[3].sender.replaceTrack(o);l.push(3),c.push(e)}else{let e=a[1].sender.replaceTrack(o);l.push(1),c.push(e)}if(n){let e=a[2].sender.replaceTrack(n);l.push(2),c.push(e)}let d=this.setTransceiverDirection(xN.SENDONLY,l);return c.push(d),Promise.all(c)}installTrackMuteEvents(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];t.forEach((e=>{e&&(null==e||e.on("mute",this.sendMutedFlag,this),null==e||e.on("unmute",this.sendMutedFlag,this))}))}uninstallTrackMuteEvents(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];t.forEach((e=>{e&&(null==e||e.off("mute",this.sendMutedFlag,this),null==e||e.off("unmute",this.sendMutedFlag,this))}))}unpublish(e){return cb(this,arguments,(function(e){var t=this;let{localAudioTrack:i,localVideoTrack:n}=e;return function*(){let e=n&&n===t.localAuxVideoTrack,r=null==n?void 0:n.outMediaTrack,o=t._peerConnection.getSenders(),s=[];i&&(t._audioManager.mixedAudioTrack||(yield o[0].replaceTrack(null),s.push(0)),e?t.localAuxAudioTrack=null:t.localMainAudioTrack=null),r&&(e?(yield o[3].replaceTrack(null),t.localAuxVideoTrack=null,t._mediaSettings=tb(eb({},t._mediaSettings),{auxVideoBps:0,auxVideoFps:0,auxVideoWidth:0,auxVideoHeight:0}),s.push(3)):(yield o[1].replaceTrack(null),yield o[2].replaceTrack(null),t.localMainVideoTrack=null,t._mediaSettings=tb(eb({},t._mediaSettings),{videoWidth:0,videoHeight:0,videoBps:0,videoFps:0,audioFs:0,audioChannel:0,audioBps:0,smallVideoWidth:0,smallVideoHeight:0,smallVideoFps:0,smallVideoBps:0}),s.push(1,2))),t.isMainStreamPublished||t.isAuxStreamPublished?(yield t.setTransceiverDirection(xN.INACTIVE,s),yield t.doPublishChange(!1)):yield t.doUnpublish(),t.uninstallTrackMuteEvents(i,n),null==n||n.emit("connection-state-changed",{prevState:t._currentState,state:"DISCONNECTED"})}()}))}doPublishChange(){let e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];return cb(this,null,(function*(){let t={state:this.publishState,constraintConfig:this._mediaSettings},i=yield this._signalChannel.sendWaitForResponse({command:ux,data:t,responseCommand:rx.PUBLISH_STATE_CHANGE_RESULT,enableLog:e});this.checkPublishResultCode(i.data.code,i.data.message)}))}doUnpublish(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return this._signalChannel.sendWaitForResponse({command:hx,commandDesc:"unpublish",responseCommand:rx.UNPUBLISH_RESULT,enableLog:e}).catch((e=>{if(e.getCode()===fb.API_CALL_TIMEOUT)return Promise.resolve();throw e}))}updateMediaSettings(){let{detail:{isH264EncodeSupported:e,isVp8EncodeSupported:t}}=this._room.checkSystemResult;e?this._mediaSettings.videoCodec="H264":t&&(this._mediaSettings.videoCodec="VP8");let i=this._publishingLocalAudioTrack||this.localMainAudioTrack||this.localAuxAudioTrack,{localMainVideoTrack:n,localAuxVideoTrack:r}=this;if(this._publishingLocalVideoTrack&&(this._isPublishingAux?r=this._publishingLocalVideoTrack:n=this._publishingLocalVideoTrack),bw){if(i&&i.outMediaTrack){let e=i.outMediaTrack.getSettings();this._mediaSettings.audioChannel=e.channelCount||1,this._mediaSettings.audioBps=1e3*i.profile.bitrate,this._mediaSettings.audioFs=e.sampleRate||0}if(n&&n.outMediaTrack){let e=n.outMediaTrack.getSettings();this._mediaSettings.videoWidth=e.width||0,this._mediaSettings.videoHeight=e.height||0,this._mediaSettings.videoFps=e.frameRate||0,this._mediaSettings.videoBps=1e3*n.profile.bitrate,n.small&&(this._mediaSettings.smallVideoWidth=n.small.width,this._mediaSettings.smallVideoHeight=n.small.height,this._mediaSettings.smallVideoFps=n.small.frameRate,this._mediaSettings.smallVideoBps=1e3*n.small.bitrate)}if(r&&r.outMediaTrack){let e=r.outMediaTrack.getSettings();this._mediaSettings.auxVideoWidth=e.width||0,this._mediaSettings.auxVideoHeight=e.height||0,this._mediaSettings.auxVideoFps=e.frameRate||0,this._mediaSettings.auxVideoBps=1e3*r.profile.bitrate}}else i&&i.outMediaTrack&&(this._mediaSettings.audioChannel=i.profile.channelCount,this._mediaSettings.audioBps=1e3*i.profile.bitrate,this._mediaSettings.audioFs=i.profile.sampleRate),n&&n.outMediaTrack&&(this._mediaSettings.videoWidth=n.profile.width,this._mediaSettings.videoHeight=n.profile.height,this._mediaSettings.videoFps=n.profile.frameRate,this._mediaSettings.videoBps=1e3*n.profile.bitrate);this._log.info("updateMediaSettings: ".concat(JSON.stringify(this._mediaSettings)))}sendMediaSettings(){this.updateMediaSettings(),this._signalChannel.sendWaitForResponse({command:Ax,data:this._mediaSettings,responseCommand:rx.UPDATE_CONSTRAINT_CONFIG_RES}).then((e=>{0!==e.data.code&&this._log.warn(e.data.message)})).catch((()=>{}))}addTrack(e){return cb(this,null,(function*(){var t;if(!this._peerConnection)return;let i=e===this.localAuxAudioTrack||e===this.localAuxVideoTrack;this._log.info("is adding ".concat(e.kind," track to current published local ").concat(i?MN.AUXILIARY:MN.MAIN," stream")),null==(t=this._sei)||t.handleEncodedStreams(),Iw()&&(yield this.addTrackByTransceiver(e,i))}))}addTrackByTransceiver(e,t){return cb(this,null,(function*(){var i;if(!e.mediaTrack)return;let n=this._peerConnection.getTransceivers();if(e.kind===MN.AUDIO)yield n[0].sender.replaceTrack(this._audioManager.mixedAudioTrack);else{let r=t?3:1;yield n[r].sender.replaceTrack(e.outMediaTrack),1===r&&(null==(i=this.localMainVideoTrack)?void 0:i.small)&&(yield n[2].sender.replaceTrack(this._room.videoManager.smallTrack)),n[r].direction===xN.INACTIVE&&(yield this.setTransceiverDirection(xN.SENDONLY,[r]))}this.updateMediaSettings(),yield this.doPublishChange()}))}removeTrack(e){return cb(this,null,(function*(){if(!this._peerConnection)return;let t=e===this.localAuxAudioTrack||e===this.localAuxVideoTrack;this._log.info("is removing ".concat(e.kind," track from current published local ").concat(t?MN.AUXILIARY:MN.MAIN," stream")),Iw()&&(yield this.removeTrackByTransceiver(e,t))}))}removeTrackByTransceiver(e,t){return cb(this,null,(function*(){if(!e.mediaTrack)return;let i=this._peerConnection.getTransceivers();if(e.kind===MN.AUDIO)this._audioManager.mixedAudioTrack||(yield i[0].sender.replaceTrack(null));else{let e=t?3:1;yield i[e].sender.replaceTrack(null),1===e&&this._room.videoManager.hasSmall&&(yield i[2].sender.replaceTrack(null)),yield this.setTransceiverDirection(xN.INACTIVE,[e])}this.updateMediaSettings(),yield this.doPublishChange()}))}setTransceiverDirection(e,t){return cb(this,null,(function*(){if(!Fb)return;let i=!1,n=!1;this._log.info("setting transceiver ".concat(t.join(",")," direction to ").concat(e));let r=this._peerConnection.getTransceivers();if(t.forEach((t=>{r[t].direction!==e&&(r[t].direction=e,i=!0)})),i){this._log.info("updating offer");let e=yield this._peerConnection.createOffer();yield this._peerConnection.setLocalDescription(e)}let o=-1,s=this._peerConnection.remoteDescription.sdp.split("\r\n").map((i=>{if(i.match(new RegExp("a=(".concat(xN.INACTIVE,"|").concat(xN.RECVONLY,"|").concat(xN.SENDONLY,")")))&&o++,t.includes(o)){if(e===xN.INACTIVE&&i.includes("a=".concat(xN.RECVONLY)))return n=!0,"a=".concat(e);if(e===xN.SENDONLY&&i.includes("a=".concat(xN.INACTIVE)))return n=!0,"a=".concat(xN.RECVONLY)}return i})).join("\r\n");n&&(this._log.info("updating answer"),yield this._peerConnection.setRemoteDescription({type:"answer",sdp:s}))}))}replaceTrack(e){return cb(this,null,(function*(){var t;let i=null==(t=this._peerConnection)?void 0:t.getSenders(),n=e.mediaTrack;if(!i||0===i.length||!n)return;let r=e===this.localAuxAudioTrack||e===this.localAuxVideoTrack;this._log.info("is replacing ".concat(n.kind," track on ").concat(r?MN.AUXILIARY:MN.MAIN," stream")),n.kind===MN.AUDIO&&i[0]&&(yield i[0].replaceTrack(this._audioManager.mixedAudioTrack)),n.kind===MN.VIDEO&&(!r&&i[1]&&(yield i[1].replaceTrack(e.outMediaTrack||n)),r&&i[3]&&(yield i[3].replaceTrack(e.outMediaTrack)))}))}setBandwidth(e){return cb(this,arguments,(function(e){var t=this;let{bandwidth:i,type:n,videoType:r}=e;return function*(){if(t.singlePC){let e={};n===MN.AUDIO?e.audio=i:"big"===r?e.bigVideo=i:"small"===r?e.smallVideo=i:e.auxVideo=i,yield t.singlePC.setBandwidth(e)}}()}))}sendMutedFlag(e){var t,i,n;if(e===this.localAuxAudioTrack||e===this.localAuxVideoTrack)return;let r={audio:!(null==(t=this.localMainAudioTrack)||!t.muted),bigVideo:!(null==(i=this.localMainVideoTrack)||!i.muted),auxVideo:!(null==(n=this.localAuxVideoTrack)||!n.muted)};this._log.info("send muted state: ".concat(JSON.stringify(r))),this._signalChannel.send(lx,r)}handleConnectionStateChange(e){"CONNECTED"===e.state&&(this.localMainVideoTrack||this._publishingLocalVideoTrack&&!this._isPublishingAux)&&UO.emit(BO.SEND_FIRST_VIDEO_FRAME,{room:this._room})}getVideoTrackId(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:MN.VIDEO;if(this._peerConnection){let t=this._peerConnection.getSenders();if(e===MN.AUXILIARY&&t[3]&&t[3].track)return t[3].track.id;if(e===MN.VIDEO&&t[1]&&t[1].track)return t[1].track.id}if(this.localMainVideoTrack&&e===MN.VIDEO){let e=this.localMainVideoTrack.mediaTrack;if(e)return e.id}if(this.localAuxVideoTrack&&e===MN.AUXILIARY){let e=this.localAuxVideoTrack.mediaTrack;if(e)return e.id}return""}getSSRC(){return this.ssrc}checkPublishResultCode(e,t){if(0!==e)throw e===_D?(this._log.error(KO.NOT_SUPPORTED_H264ENCODE),new Tb({code:fb.NOT_SUPPORTED_H264,message:QO({key:zO.NOT_SUPPORTED_H264ENCODE})})):new Tb({code:fb.UNKNOWN,message:QO({key:zO.SIGNAL_RESPONSE_FAILED,data:{signalResponse:rx.PUBLISH_RESULT,code:e,message:t}})})}sendSEI(e,t){var i;null==(i=this._sei)||i.push(e,t)}onSinglePCReconnected(){return cb(this,null,(function*(){this.isMainStreamPublished&&(yield this.publish({localAudioTrack:this.localMainAudioTrack,localVideoTrack:this.localMainVideoTrack,isAuxiliary:!1})),this.isAuxStreamPublished&&(yield this.publish({localAudioTrack:this.localAuxAudioTrack,localVideoTrack:this.localAuxVideoTrack,isAuxiliary:!0}))}))}};function uU(e){return Object.keys(e).filter((t=>e[t]))}var hU=class extends lU{constructor(e){super(tb(eb({},e),{isUplink:!1})),sb(this,"_flag",0),sb(this,"role","anchor"),sb(this,"remoteAudioTrack"),sb(this,"remoteVideoTrack"),sb(this,"remoteAuxiliaryTrack"),sb(this,"ssrc",{audio:0,video:0,videoRtx:0,auxiliary:0,auxiliaryRtx:0}),this.flag=e.flag,this.remoteAudioTrack=new CL(this._room,this),this.remoteVideoTrack=new bL(this._room,this),this.remoteAuxiliaryTrack=new kL(this._room,this),this.initialize()}get subscribeState(){let e={audio:!1,video:!1,auxiliary:!1,smallVideo:!1};return this.remoteVideoTrack.isSubscribed&&(8&this.remoteVideoTrack.mediaType?e.smallVideo=!0:e.video=!0),this.remoteAudioTrack.isSubscribed&&(e.audio=!0),this.remoteAuxiliaryTrack.isSubscribed&&(e.auxiliary=!0),e}get muteState(){return yO(this.flag,this.userId)}get flag(){return this._flag}set flag(e){var t,i,n;e!==this._flag&&(this._flag=e,null==(t=this.remoteAudioTrack)||t.onFlagChanged(),null==(i=this.remoteVideoTrack)||i.onFlagChanged(),null==(n=this.remoteAuxiliaryTrack)||n.onFlagChanged())}get hasMainStream(){return this.muteState.hasAudio||this.muteState.hasVideo||this.muteState.hasSmall}get hasAuxStream(){return this.muteState.hasAuxiliary}get isMainStreamSubscribed(){return(this.subscribeState.audio||this.subscribeState.video||this.subscribeState.smallVideo)&&(this.muteState.hasAudio||this.muteState.hasVideo||this.muteState.hasSmall)}get isAuxStreamSubscribed(){return this.subscribeState.auxiliary&&this.muteState.hasAuxiliary}get isSmallStreamSubscribed(){return this.subscribeState.smallVideo&&this.muteState.hasSmall}get isBigStreamSubscribed(){return this.subscribeState.video&&this.muteState.hasVideo}isStreamUnpublished(e){return e===MN.MAIN?!this.muteState.hasAudio&&!this.muteState.hasVideo:!this.muteState.hasAuxiliary}initialize(){this.installEvents()}close(e){super.close(e),this.emitConnectionStateChangedEvent("DISCONNECTED"),this.remoteAudioTrack.close(),this.remoteVideoTrack.close(),this.remoteAuxiliaryTrack.close(),this.uninstallEvents(),this.removeDownlink()}installEvents(){!this.singlePC||(this.listeners("track").includes(this.onTrack)||this.singlePC.on("track",this.onTrack,this),this.listeners("spc-reconnected").includes(this.onSinglePCReconnected)||this.singlePC.on("spc-reconnected",this.onSinglePCReconnected,this))}uninstallEvents(){!this.singlePC||(this.singlePC.off("track",this.onTrack,this),this.singlePC.off("spc-reconnected",this.onSinglePCReconnected,this))}emitConnectionStateChangedEvent(e){var t,i;let n=this._currentState,r=super.emitConnectionStateChangedEvent(e);return r&&n!==e&&(null==(t=this.remoteVideoTrack)||t.emit("connection-state-changed",{prevState:n,state:e}),null==(i=this.remoteAuxiliaryTrack)||i.emit("connection-state-changed",{prevState:n,state:e})),r}onTrack(e){let t=e.streams[0],{track:i}=e;if(t.id.split("-")[0]!==this.tinyId)return;let n=t.id.includes("aux")?"auxiliary":"main";this._log.debug("ontrack ".concat(n," ").concat(i.kind));let r=MN.AUDIO;i.kind===MN.VIDEO&&(r=n===MN.MAIN?MN.VIDEO:MN.AUXILIARY);let o=this.remoteAudioTrack;r===MN.VIDEO?o=this.remoteVideoTrack:r===MN.AUXILIARY&&(o=this.remoteAuxiliaryTrack),o.setInputMediaStreamTrack(i)}isSubscriptionStateNotChanged(e){return JSON.stringify(e)===JSON.stringify(this.subscribeState)}subscribe(e,t){return cb(this,null,(function*(){try{if(this.isSubscriptionStateNotChanged(e))return;if(this._log.info("subscribe ".concat(t," ").concat(uU(e))),this.hasSSRC){let t="subscribe_change";Object.values(e).find((e=>!0===e))||(t="unsubscribe"),yield this.sendSubscription(t,e)}else yield this.doSubscribe(e)}catch(cN){throw this._room.isJoined&&this.isStreamUnpublished(t)?(this._log.warn("".concat(cN.message," ").concat(JSON.stringify(this.muteState))),new Tb({code:fb.REMOTE_STREAM_NOT_EXIST,message:"remote user ".concat(this.userId," unpublished stream")})):cN}}))}unsubscribe(e){return cb(this,arguments,(function(e){var t=this;let{remoteTracks:i,streamType:n}=e;return function*(){var e;if("main"===n&&!t.isMainStreamSubscribed||"auxiliary"===n&&!t.isAuxStreamSubscribed)return void t._log.info("".concat(n," stream already unsubscribed"));let r=eb({},t.subscribeState);i.forEach((e=>{switch(e.mediaType){case 1:r.audio=!1;break;case 4:r.video=!1;break;case 8:r.smallVideo=!1;break;case 2:r.auxiliary=!1}}));let o="subscribe_change";Object.values(r).find((e=>!0===e))||(o="unsubscribe"),t._log.info("".concat("unsubscribe"===o?o:"subscribe"," ").concat(n," [").concat(uU(r),"]")),"unsubscribe"===o&&(null==(e=t.singlePC)||e.removeDownlinkQueue.add(t.tinyId)),yield t.sendSubscription(o,r),"unsubscribe"===o&&(yield t.removeDownlink())}()}))}sendSubscription(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.subscribeState,i={srcTinyId:this.tinyId,srcUserId:this.userId},n=mx,r=rx.UNSUBSCRIBE_RESULT;return"subscribe_change"===e&&(i={audio:t.audio,bigVideo:t.video,auxVideo:t.auxiliary,smallVideo:t.smallVideo,srcTinyId:this.tinyId},n=_x,r=rx.SUBSCRIBE_CHANGE_RESULT),this._signalChannel.sendWaitForResponse({command:n,data:i,responseCommand:r,timeout:1e4}).then((t=>{let{data:i}=t;if(0!==i.code){let t=new Tb({code:i.code,message:QO({key:zO.ERROR_MESSAGE,data:{type:e,message:i.message}})});throw this._log.error(t),t}}))}getMainStreamVideoTrackId(){return this.remoteVideoTrack&&this.remoteVideoTrack.mediaTrack?this.remoteVideoTrack.mediaTrack.id:""}getAuxStreamVideoTrackId(){return this.remoteAuxiliaryTrack&&this.remoteAuxiliaryTrack.mediaTrack?this.remoteAuxiliaryTrack.mediaTrack.id:""}setDelay(e){let{audioDelay:t,videoDelay:i}=e;this.remoteAudioTrack.stat.end2EndDelay=t,this.remoteVideoTrack.stat.end2EndDelay=i}onSinglePCReconnected(){(this.ssrc.audio||this.ssrc.video||this.ssrc.auxiliary)&&this.doSubscribe(this.subscribeState,!1)}get hasSSRC(){return this.ssrc.audio&&this.ssrc.video&&this.ssrc.auxiliary}doSubscribe(){return cb(this,arguments,(function(){var e=this;let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.subscribeState,i=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];return function*(){if(e.singlePC){if(e.singlePC.addDownlinkQueue.add(e.tinyId),yield e.singlePC.waitForPeerConnectionConnected(),i||!e.hasSSRC){let i={audioSsrc:aU(),bigVideoSsrc:aU(),bigVideoRtxSsrc:aU(),auxVideoSsrc:aU(),auxVideoRtxSsrc:aU()},{audioSsrc:n,bigVideoSsrc:r,bigVideoRtxSsrc:o,auxVideoSsrc:s,auxVideoRtxSsrc:a}=i;e.ssrc={audio:n,video:r,videoRtx:o,auxiliary:s,auxiliaryRtx:a},e.singlePC.addDownlinkQueue.delete(e.tinyId),yield e.singlePC.addDownlink({userId:e.userId,tinyId:e.tinyId,ssrc:e.ssrc});let c=yield e._signalChannel.sendWaitForResponse({command:kx,responseCommand:rx.SPC_SUBSCRIBE_RESULT,data:{srcUserId:e.userId,srcTinyId:e.tinyId,audio:t.audio,bigVideo:t.video,auxVideo:t.auxiliary,smallVideo:t.smallVideo,customData:!1,ssrc:i}});if(0!==c.data.code)throw yield e.removeDownlink(),new Tb({code:c.data.code,message:c.data.message});return}e.singlePC.addDownlinkQueue.delete(e.tinyId),yield e.singlePC.addDownlink({userId:e.userId,tinyId:e.tinyId,ssrc:e.ssrc})}}()}))}removeDownlink(){return cb(this,null,(function*(){!this.singlePC||(this.ssrc={audio:0,video:0,videoRtx:0,auxiliary:0,auxiliaryRtx:0},this.singlePC.removeDownlinkQueue.delete(this.tinyId),yield this.singlePC.removeDownlink(this.tinyId,this.userId))}))}};ob([nL((e=>function(){for(var t=arguments.length,i=new Array(t),n=0;n<t;n++)i[n]=arguments[n];return new Promise(((t,n)=>{let r=e=>{this.off("closed",r),n(new Tb({code:fb.API_CALL_ABORTED,message:QO({key:zO.CONNECTION_ABORTED,data:e})}))};this.on("closed",r),e.apply(this,i).then(t,n).finally((()=>{this.off("closed",r)}))}))}))],hU.prototype,"subscribe",1);var pU=hU,{isString:mU,isPlainObject:_U,isUndefined:fU,getNetworkType:gU,getTerminalType:TU,isEmpty:EU}=yb,SU=class extends BV{constructor(e){super(e),this.privateMapKey="",this._heartbeat=-1,this._lastHeartBeatTime=-1,this._joinTimeout=-1,this._firstPublishedList=null,this._joinReject=null,this._isRelayChanged=!1,this._signalChannel=null,this.uplinkConnection=null,this.singlePC=null,this.enableSPC=vw,this._changeBigSmallRecords=new Map,this._networkQuality=null,this._networkType=gU(),this._turnServers=[],this._syncUserListInterval=-1,this._smallStreamConfig={bitrate:100,frameRate:15,height:120,width:160},this.enableSEI=!1,this._enableAudioVolumeEvaluation=!1,this._audioVolumeIntervalId=0,this._enableMultiAuxStream=!1,this._pureAudioPushMode=!1,this.enableHWEncoder=!1,this._stats=new Xx(this,this._log),this.userManager=new qL(this.userId,this._log),this._version=oN,this.sdpSemantics=mD,fU(e.sdpSemantics)?JO.isUnifiedPlanDefault()&&(this.sdpSemantics=pD):this.sdpSemantics=e.sdpSemantics,this._log.info("sdpSemantics: ".concat(this.sdpSemantics,", netType: ").concat(this._networkType)),e.iceTransportPolicy&&(this._iceTransportPolicy=e.iceTransportPolicy),this._enableMultiAuxStream=!fU(e.enableMultiAuxStream)&&e.enableMultiAuxStream,this.enableSEI=e.enableSEI,!fU(e.enableSPC)&&vw&&(this.enableSPC=e.enableSPC),this.enableHWEncoder=e.enableHWEncoder||!1,this._initBusinessInfo(e)}get isMainStreamPublished(){var e;return!(null==(e=this.uplinkConnection)||!e.isMainStreamPublished)}get isMainAudioPublished(){var e;return!(null==(e=this.uplinkConnection)||!e.localMainAudioTrack)}get isAuxStreamPublished(){var e;return!(null==(e=this.uplinkConnection)||!e.isAuxStreamPublished)}get hasAuxStream(){return[...this.remotePublishedUserMap.values()].findIndex((e=>e.muteState.hasAuxiliary))>=0}get userMap(){return this.userManager.userMap}get remotePublishedUserMap(){return this.userManager.remotePublishedUserMap}get tinyIdToUserIdMap(){return new Map([...this.remotePublishedUserMap.values()].map((e=>[e.tinyId,e.userId])))}join(e,t,i){return cb(this,null,(function*(){return this.userManager.mySelfId=this.userId,this.userManager.on("1",(e=>{this.emit("peer-join",e)})),this.userManager.on("2",(e=>{this.closeDownLinkConnection(e,"remote user exitRoom"),this.emit("peer-leave",e)})),this.userManager.on("3",this.createDownlinkConnection,this),this.userManager.on("5",this.closeDownLinkConnection,this),this.userManager.on("6",(e=>{var t=((e,t)=>{var i={};for(var n in e)YC.call(e,n)&&t.indexOf(n)<0&&(i[n]=e[n]);if(null!=e&&KC)for(var n of KC(e))t.indexOf(n)<0&&QC.call(e,n)&&(i[n]=e[n]);return i})(e,[]);UO.emit(BO.REMOTE_PUBLISH_STATE_CHANGED,eb({room:this},t)),this.emit("remote-publish-state-changed",eb({},t))})),this._joinOptions=e,new Promise(((t,i)=>cb(this,null,(function*(){this._joinReject=i;try{this.checkDestroy();let i=yield this.initialize();yield this.doJoin(e,i),t(),this._firstPublishedList&&this.onPublishedUserList({data:{userList:this._firstPublishedList}})}catch(JV){i(JV)}this._joinReject=null}))))}))}doJoin(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return new Promise(((i,n)=>cb(this,null,(function*(){var r,o,s;let a;if(e.privateMapKey&&(this.privateMapKey=e.privateMapKey),this._signalChannel.once(YM,(e=>{this.clearJoinTimeout(),UO.emit(BO.JOIN_SIGNAL_CONNECTION_END,{room:this,error:e}),n(e)})),aO(null==(o=null==(r=this.scheduleResult)?void 0:r.config)?void 0:o.singlePC)&&vw&&(this.enableSPC=this.scheduleResult.config.singlePC),this.enableSPC&&!this.singlePC){this.singlePC=new nU({signalChannel:this._signalChannel,room:this,enableCustomMessage:!1}),this.singlePC.once("error",(()=>this.fallbackToMPC()));try{a=yield this.singlePC.initialize()}catch(u){this.fallbackToMPC()}}this.keyPointManager.setConnectionType(this.singlePC?1:2);let c={roomId:String(e.roomId||e.strRoomId),useStringRoomId:this.useStringRoomId,privateMapKey:this.privateMapKey,trtcRole:e.role,trtcScene:"live"===this.scene?2:1,sdpSemantics:this.sdpSemantics,version:this._version,ua:navigator&&navigator.userAgent||"",terminalType:TU(),netType:NN[this._networkType],bussinessInfo:this._businessInfo,ability:a};t&&(c.userSig=this.userSig),this._log.debug("join room signal data: ".concat(JSON.stringify(c)));let l=5e3;(null==(s=this.scheduleResult.config)?void 0:s.enterRoomTimeout)&&this.scheduleResult.config.enterRoomTimeout>=1&&(l=1e3*this.scheduleResult.config.enterRoomTimeout),this._joinTimeout=window.setTimeout((()=>{n(new Tb({code:fb.JOIN_ROOM_FAILED,message:QO({key:zO.JOIN_ROOM_TIMEOUT})}))}),l),UO.emit(BO.JOIN_SEND_CMD,{room:this}),this._signalChannel.send(this.singlePC?Cx:sx,c),this._signalChannel.once(rx.JOIN_ROOM_RESULT,(e=>{this.clearJoinTimeout();let{code:t,message:r,data:o}=e.data;UO.emit(BO.JOIN_RECEIVED_CMD_RES,{room:this,code:t}),0===t?(this._log.info("Join room success, start heartbeat"),this.startHeartbeat(),this.syncUserList(),this.startSyncUserListInterval(),this._firstPublishedList=o.publishers,this.singlePC&&this.singlePC.connect(o.ability).catch((()=>{})),i()):(this._log.error("Join room failed result: ".concat(t," error: ").concat(r)),n(new Tb({code:fb.JOIN_ROOM_FAILED,extraCode:t,message:QO({key:zO.JOIN_ROOM_FAILED,data:{error:r,code:t}})})))}))}))))}reJoin(){return cb(this,null,(function*(){if(this.isJoined)try{if(this._log.warn("reJoin pending: ".concat(this._joinOptions.roomId)),this.singlePC&&(this.singlePC.close(),this.singlePC=null),this._signalChannel.close(),yield this._signalChannel.connect(),yield this.doJoin(tb(eb({},this._joinOptions),{role:"anchor"===this.role?20:21,privateMapKey:this.privateMapKey})),this._log.warn("reJoin success"),Xw.logSuccessEvent({userId:this.userId,eventType:lD.REJOIN}),this.singlePC){let e=t=>{var i;"CONNECTED"===t.state&&(null==(i=this.singlePC)||i.off($V.CONNECTION_STATE_CHANGED,e),this.uplinkConnection instanceof dU&&this.uplinkConnection.onSinglePCReconnected(),this.remotePublishedUserMap.forEach((e=>{e.installEvents(),e.doSubscribe()})))};this.singlePC.on($V.CONNECTION_STATE_CHANGED,e),this.checkConnectionsToReconnect(),this.uplinkConnection instanceof Qx&&!this.uplinkConnection.getIsReconnecting()&&this.uplinkConnection.startReconnection()}}catch(aN){this._log.warn("reJoin fail ".concat(aN)),this.reset(),Xw.logFailedEvent({userId:this.userId,eventType:lD.REJOIN,error:aN}),this.emit("error",new Tb({code:fb.JOIN_ROOM_FAILED,message:QO({key:zO.REJOIN_ROOM_FAILED,data:{roomId:this._joinOptions.roomId}})}))}else this._log.warn("reJoin abort")}))}initialize(){return cb(this,null,(function*(){let{mainUrl:e,backupUrl:t}=this.getSignalChannelUrl(),i=this._signalChannel||function(e){let t=[...Dx.values()].find((t=>t.room.userId===e&&!t.room.isJoined));return t||null}(this.userId),n=!!(i&&i.isConnected&&i.keepAlive);return this._log.info("setup signal channel. reuse: ".concat(+n)),n?(i.url=e,i.backupUrl=t,i.room=this,this._signalChannel=i):this._signalChannel=new Ox({sdkAppId:this.sdkAppId,userId:this.userId,userSig:this.userSig,url:e,backupUrl:t,room:this}),this._networkQuality||(this._networkQuality=new eV({signalChannel:this._signalChannel,room:this}),this._networkQuality.on(eV.EVENT_NETWORK_QUALITY,(e=>{this.emit("network-quality",e)}))),IP(this,this._signalChannel).add(QM,(e=>{UO.emit(BO.SIGNAL_CONNECTION_STATE_CHANGED,eb({room:this},e)),this.emit("signal-connection-state-changed",e)})).add($M,(e=>{this.reset(),this.emit("error",e)})).add(rx.PEER_JOIN,(e=>{let{srcTinyId:t,userId:i,role:n}=e.data.data;this.userManager.addUser({userId:i,tinyId:t,role:n})})).add(rx.PEER_LEAVE,(e=>{let{userId:t,reason:i=0}=e.data.data;this.userManager.deleteUser(t,i)})).add(rx.UPDATE_REMOTE_MUTE_STAT,(e=>{this._lastHeartBeatTime>0&&Date.now()-this._lastHeartBeatTime>=1e4&&this.doHeartbeat(),this.onPublishedUserList(e.data)})).add(rx.CLIENT_BANNED,(e=>{let t=e.data.data,{reason:i}=t;if(Xw.uploadEvent({log:"stat-banned:".concat(i),userId:this.userId}),"user_time_out"===i)return this._log.warn("".concat(i," last heart beat time: ").concat(this._lastHeartBeatTime," interval: ").concat(Date.now()-this._lastHeartBeatTime,", visibility: ").concat(document.visibilityState)),void this.reJoin();this._log["kick"===i?"error":"info"]("user was banned because of [".concat(i,"]")),this.reset(),this.emit("banned",{reason:i})})),this._signalChannel.once(qM,(e=>{this.tinyId=e.signalInfo.tinyId,UO.emit(BO.JOIN_SIGNAL_CONNECTION_END,{room:this})})),UO.emit(BO.JOIN_SIGNAL_CONNECTION_START,{room:this}),yield this._signalChannel.connect(this._isUsingCachedSchedule?1e4:void 0),n}))}setSignalChannel(e){this._signalChannel=e,e||yP(this)}leave(){return cb(this,null,(function*(){var e;try{yield this.doHeartbeat()}catch(aD){}this._log.info("leave() => leaving room"),UO.emit(BO.LEAVE_SEND_CMD,{room:this}),null==(e=this._signalChannel)||e.send(ax)}))}clearNetworkQuality(){this._networkQuality&&(this._networkQuality.stop(),this._networkQuality=null)}closeConnections(){this.remotePublishedUserMap.forEach((e=>{this.closeDownLinkConnection(e.userId,"you exitRoom")}))}clearJoinTimeout(){clearTimeout(this._joinTimeout),this._joinTimeout=-1}startHeartbeat(){-1===this._heartbeat&&(this._heartbeat=Yw.run(PD,this.doHeartbeat.bind(this),{delay:2e3}))}stopHeartbeat(){-1!==this._heartbeat&&(this._log.info("stopHeartbeat"),Yw.clearTask(this._heartbeat),this._heartbeat=-1,this._lastHeartBeatTime=-1)}doHeartbeat(){return cb(this,null,(function*(){var e;let t=this.badCaseDetector.getMonitorFreeze(),i=yield this._stats.getStatsReport({uplinkConnection:this.uplinkConnection,downlinkConnections:this.remotePublishedUserMap,freezeMap:t});if(this.badCaseDetector.resetMonitor(),null==(e=this._signalChannel)||!e.isConnected)return;let n=this._signalChannel.isConnected?function(e){if(WL.has(e)){let t=WL.get(e).map((e=>({uint32_event_id:e.eventId,uint64_date:e.timestamp,str_userid:e.remoteUserId,str_event_json:e.eventDesc})));return WL.delete(e),t}return[]}(this.userId):[],r=eb({str_sdk_version:rN,uint64_datetime:(new Date).getTime(),msg_user_info:{str_identifier:this.userId,uint64_tinyid:this.tinyId},msg_device_info:{uint32_terminal_type:15,str_device_name:navigator.platform,str_os_version:"",uint32_net_type:NN[this._networkType]},msg_event_msg:n,str_acc_ip:this.getSignalInfo().relayIp,str_client_ip:this.getSignalInfo().clientIp},i);UO.emit(BO.HEARTBEAT_REPORT,{room:this,report:r}),this._signalChannel.send(cx,r),this.emit("heartbeat-report",tb(eb({},r),{bytes_sent:this._stats.totalBytesSent+this._signalChannel.bytesSent,bytes_received:this._stats.totalBytesReceived+this._signalChannel.bytesReceived}));let o=Date.now();this._lastHeartBeatTime>0&&o-this._lastHeartBeatTime>1e4&&this._log.warn("heartbeat took ".concat(o-this._lastHeartBeatTime)),this._signalChannel.isConnected&&(this._lastHeartBeatTime=o),!this._isRelayChanged&&this.isRelayMaybeFailed()&&(this.reJoin(),this._isRelayChanged=!0)}))}onPublishedUserList(e){if(!this.isJoined)return;let t=e.data.userList.map((e=>{let{userId:t,srcTinyId:i,flag:n}=e,r=this.remotePublishedUserMap.get(t);return r&&this._changeBigSmallRecords.has(t)&&this.checkSubscribeBigSmallVideo(r),{userId:t,tinyId:i,flag:n}}));UO.emit(BO.RECEIVED_PUBLISHED_USER_LIST,{room:this,publishedUserList:t}),this.userManager.setRemotePublishedUserList(t)}closeUplink(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"you unpublished";this.uplinkConnection&&(this.localTracks.size>0&&this.uplinkConnection.doUnpublish(),this.uplinkConnection.close(e),this.uplinkConnection=null),this.localTracks.forEach((e=>e.unpublish())),this.localTracks.clear()}createDownlinkConnection(e){let{userId:t,tinyId:i,flag:n}=e,r=new(this.singlePC?pU:zx)({userId:t,tinyId:i,room:this,signalChannel:this._signalChannel,enableSEI:this.enableSEI,flag:n});this.userManager.addRemotePublishedUser(r),this.installDownlinkEvents(r,t),this.emit("remote-published",r)}closeDownLinkConnection(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"remote user unpublished",i=this.remotePublishedUserMap.get(e);i&&(i.close(t),this.emit("remote-unpublished",i))}installDownlinkEvents(e,t){e.on("sei-message",(e=>{this.emit("sei-message",e)})),e.on("error",(e=>{let i=e.getCode();i!==fb.ICE_TRANSPORT_ERROR&&(i===fb.DOWNLINK_RECONNECTION_FAILED&&this.closeDownLinkConnection(t),this.emit("error",e))})),e.on("connection-state-changed",(t=>{this.emit("media-connection-state-changed",tb(eb({},t),{userId:e.userId}))})),e.on("firewall-restriction",(()=>{this.emit("firewall-restriction")}))}startSyncUserListInterval(){-1===this._syncUserListInterval&&(this._syncUserListInterval=Yw.run(PD,this.syncUserList.bind(this)))}stopSyncUserListInterval(){Yw.clearTask(this._syncUserListInterval),this._syncUserListInterval=-1}syncUserList(){return this.getUserList().then((e=>{this.userManager.setUserList(e)})).catch((e=>{this._log.debug("sync user list failed: ".concat(e))}))}getUserList(){var e;return null!=(e=this._signalChannel)&&e.isConnected?this._signalChannel.sendWaitForResponse({command:yx,responseCommand:rx.USER_LIST_RES,enableLog:!1,timeout:2e3}).then((e=>{let{data:t}=e,{code:i,message:n}=t;if(0===i)return(t.data&&t.data.userList||[]).map((e=>{let{userId:t,srcTinyId:i,role:n}=e;return{userId:t,tinyId:i,role:n}}));throw QO({key:zO.SIGNAL_RESPONSE_FAILED,data:{signalResponse:rx.USER_LIST_RES,code:i,message:n}})})):Promise.reject("not connected")}getAllConnections(){let e=[...this.remotePublishedUserMap.values()];return this.uplinkConnection&&e.push(this.uplinkConnection),e}isRelayMaybeFailed(){if(this._signalChannel&&!this._signalChannel.isOnline||!Ux)return!1;if(this.singlePC)return this.singlePC.reconnectionCount>6;let e=this.getAllConnections();if(0===e.length)return!1;for(let t=0;t<e.length;t++)if(e[t].getReconnectionCount()<6)return!1;return!0}checkConnectionsToReconnect(){this.singlePC||this.getAllConnections().forEach((e=>{if(e instanceof Fx&&!e.getIsReconnecting()){let t=e.getPeerConnection();t&&t.connectionState===nD.CLOSED&&(this._log.warn("[".concat(e.getUserId(),"] pc is closed but not reconnect")),e.startReconnection())}}))}fallbackToMPC(){return cb(this,null,(function*(){var e;if(this._log.warn("fallback to multi pc"),Xw.uploadEvent({log:"stat-fallback",userId:this.userId}),this.enableSPC=!1,null==(e=this.singlePC)||e.close(),this.singlePC=null,yield this.reJoin(),this.uplinkConnection){let e=this.uplinkConnection;this.uplinkConnection=new Qx({userId:this.userId,tinyId:this.tinyId,room:this,signalChannel:this._signalChannel,enableSEI:this.enableSEI,audioManager:this.audioManager}),e.isMainStreamPublished&&(yield this.uplinkConnection.publish({localAudioTrack:e.localMainAudioTrack,localVideoTrack:e.localMainVideoTrack,isAuxiliary:!1})),e.isAuxStreamPublished&&(yield this.uplinkConnection.publish({localAudioTrack:e.localAuxAudioTrack,localVideoTrack:e.localAuxVideoTrack,isAuxiliary:!0}))}this.remotePublishedUserMap.forEach((e=>{let t=new zx({userId:e.userId,tinyId:e.tinyId,room:this,signalChannel:this._signalChannel,enableSEI:this.enableSEI,flag:e.flag,remoteAudioTrack:e.remoteAudioTrack,remoteVideoTrack:e.remoteVideoTrack,remoteAuxiliaryTrack:e.remoteAuxiliaryTrack});this.installDownlinkEvents(t,e.userId),this.remotePublishedUserMap.set(e.userId,t),e.isMainStreamSubscribed&&t.subscribe(e.subscribeState,"main"),e.isAuxStreamSubscribed&&t.subscribe(e.subscribeState,"auxiliary")}))}))}destroy(){this._isDestroyed||(this._signalChannel&&(this._log.info("destroying SignalChannel"),this._signalChannel.close(),this._signalChannel=null),super.destroy(),this._joinReject&&(this._joinReject(new Tb({code:fb.INVALID_OPERATION,message:QO({key:zO.CLIENT_DESTROYED,data:{funName:"join"}})})),this.clearJoinTimeout(),this.reset()),this.removeAllListeners())}switchRole(e){return cb(this,null,(function*(){this.role!==e&&("audience"===e&&this.uplinkConnection&&this.closeUplink("you switch role to audience"),yield this.doSwitchRole(e))}))}doSwitchRole(e){let t={command:vx,data:{role:"anchor"===e?20:21,privateMapKey:this.privateMapKey},responseCommand:rx.SWITCH_ROLE_RES,retries:1};return this._log.info("switchRole signal data: ".concat(JSON.stringify(t.data))),this._signalChannel.sendWaitForResponseWithRetry(t).then((t=>{let{code:i,message:n}=t.data;if(0!==i)throw new Tb({code:fb.SWITCH_ROLE_FAILED,message:QO({key:zO.SWITCH_ROLE_FAILED,data:{message:n,code:i}})});this.role=e})).catch((e=>{throw e instanceof Tb&&e.getCode()===fb.API_CALL_TIMEOUT&&(e=new Tb({code:fb.SWITCH_ROLE_FAILED,message:QO({key:zO.SWITCH_ROLE_TIMEOUT})})),this._log.error(e),e}))}publish(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];return cb(this,null,(function*(){let e={},i={};t.forEach((t=>{t instanceof sL&&(t instanceof dL?i.audio=t:e.audio=t),t instanceof aL&&(t instanceof lL&&2===t.mediaType?i.video=t:e.video=t)}));let n=EU(e),r=EU(i);(!n||!r)&&!this.uplinkConnection&&(this.singlePC?this.uplinkConnection=new dU({userId:this.userId,tinyId:this.tinyId,room:this,signalChannel:this._signalChannel,enableSEI:this.enableSEI,audioManager:this.audioManager}):this.uplinkConnection=new Qx({userId:this.userId,tinyId:this.tinyId,room:this,signalChannel:this._signalChannel,enableSEI:this.enableSEI,audioManager:this.audioManager}),this.uplinkConnection.on("connection-state-changed",(e=>{this.emit("media-connection-state-changed",tb(eb({},e),{userId:this.userId}))})),this.uplinkConnection.on("firewall-restriction",(()=>{this.emit("firewall-restriction")})),this.uplinkConnection.on("error",(e=>{let t=e.getCode();t!==fb.ICE_TRANSPORT_ERROR&&(t===fb.UPLINK_RECONNECTION_FAILED&&this.closeUplink(),this.emit("error",e))})));let o=t.map((e=>e.kind)).join(",");n||(this._log.info("publish() => main ".concat(o)),yield this.uplinkConnection.publish({localAudioTrack:e.audio,localVideoTrack:e.video,isAuxiliary:!1}),this._log.info("main is published")),r||(this._log.info("publish() => aux ".concat(o)),yield this.uplinkConnection.publish({localAudioTrack:i.audio,localVideoTrack:i.video,isAuxiliary:!0}),this._log.info("aux is published"))}))}unpublish(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];return cb(this,null,(function*(){if("live"===this.scene&&"anchor"!==this.role||!this.isMainStreamPublished&&!this.isAuxStreamPublished||!this.uplinkConnection)return;let e={},i={};t.forEach((t=>{!t.mediaTrack||(t instanceof sL&&(t instanceof dL?i.audio=t:e.audio=t),t instanceof aL&&(t instanceof lL&&2===t.mediaType?i.video=t:e.video=t))}));try{let n=t.map((e=>e.kind)).join(",");EU(e)||(this._log.info("unpublish() => main ".concat(n)),yield this.uplinkConnection.unpublish({localAudioTrack:e.audio,localVideoTrack:e.video})),EU(i)||(this._log.info("unpublish() => aux ".concat(n)),yield this.uplinkConnection.unpublish({localAudioTrack:i.audio,localVideoTrack:i.video}))}catch(r){}0===this.localTracks.size&&!this.audioManager.mixedAudioTrack&&this.closeUplink("you unpublished")}))}addTrack(e){if(!this.uplinkConnection||!e.mediaTrack)return Promise.resolve();let t=this.uplinkConnection.addTrack(e);return e.publish(this,t),t}removeTrack(e){return this.uplinkConnection&&e.mediaTrack?this.uplinkConnection.removeTrack(e).then((t=>(e.unpublish(),t))):Promise.resolve()}replaceTrack(e){return this.uplinkConnection&&e.mediaTrack?this.uplinkConnection.replaceTrack(e).then((t=>{UO.emit(BO.LOCAL_TRACK_REPLACED,{track:e})})):Promise.resolve()}setBandWidth(e){return cb(this,null,(function*(){!this.uplinkConnection||(yield this.uplinkConnection.setBandwidth(e),yield this.uplinkConnection.sendMediaSettings())}))}subscribe(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];return cb(this,null,(function*(){if(t=t.filter((e=>!e.isSubscribed)),0===t.length)return;let{userId:e}=t[0],i=this.remotePublishedUserMap.get(e);if(!i)return;let n=t.find((e=>2===e.mediaType))?"auxiliary":"main";try{let r=eb({},i.subscribeState);t.forEach((e=>{switch(e.mediaType){case 1:r.audio=!0;break;case 4:r.video=!0;break;case 2:r.auxiliary=!0}}));let o=this._changeBigSmallRecords.get(e);o&&o.options.smallVideo&&i.muteState.hasSmall&&r.video&&(r.video=!1,r.smallVideo=!0),UO.emit(BO.SUBSCRIBE_START,{room:this,streamType:n,remotePublishedUser:i,subscribeState:r}),this._log.info("subscribe() => ".concat(e," ").concat(n," [").concat(Gx(r),"] prev: [").concat(Gx(i.subscribeState),"]")),yield i.subscribe(r,n);for(let e of t)e.mediaTrack||(yield e.waitHasMediaTrack());i.remoteVideoTrack.setMediaType(r.smallVideo?8:4),UO.emit(BO.SUBSCRIBE_SUCCESS,{room:this,streamType:n,remotePublishedUser:i})}catch(lN){let i=lN instanceof Tb?lN.getCode():fb.UNKNOWN,r=lN;throw lN instanceof Tb?i===fb.REMOTE_STREAM_NOT_EXIST&&(r=new Tb({code:fb.API_CALL_ABORTED,message:QO({key:zO.API_CALL_ABORTED,data:{message:lN.message,userId:e,streamType:n}})}),this._log.warn(r)):(r=new Tb({code:i,message:QO({key:zO.SUBSCRIBE_FAILED,data:{message:lN.message,userId:e,streamType:n}})}),this._log.error(r)),r}}))}unsubscribe(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];return cb(this,null,(function*(){let{userId:e}=t[0],i=this.remotePublishedUserMap.get(e);if(!i)return;let n=t.find((e=>2===e.mediaType))?"auxiliary":"main";this._log.info("unsubscribe() => ".concat(e," ").concat(n));try{yield i.unsubscribe({remoteTracks:t,streamType:n})}catch(lN){this._log.warn("unsubscribe() => failed ".concat(lN))}t.forEach((e=>{e.unsubscribe(),8===e.mediaType&&e.setMediaType(4)})),UO.emit(BO.UNSUBSCRIBE_SUCCESS,{room:this,streamType:n,remotePublishedUser:i})}))}setEncodedDataProcessingListener(e){throw new Error("Method not implemented.")}enableAudioVolumeEvaluation(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:2e3,t=arguments.length>1?arguments[1]:void 0;if(e<=0)return this._enableAudioVolumeEvaluation=!1,void Yw.clearTask(this._audioVolumeIntervalId);e=Math.floor(Math.max(e,100)),UO.emit(BO.AUDIO_LEVEL_INTERVAL,{interval:e}),this._audioVolumeIntervalId&&Yw.clearTask(this._audioVolumeIntervalId),this._enableAudioVolumeEvaluation=!0,this._audioVolumeIntervalId=Yw.run(LD,(()=>{var e;let t=[];null==(e=this.remotePublishedUserMap)||e.forEach((e=>{if(e.muteState.hasAudio){let i=Math.floor(100*e.remoteAudioTrack.getAudioLevel());t.push({userId:e.userId,volume:i})}})),this.emit("audio-volume",t)}),{fps:1e3/e,backgroundTask:t})}getLocalAudioStats(){return cb(this,null,(function*(){let e={};if(e[this.userId]={bytesSent:0,packetsSent:0},this.uplinkConnection){let t=yield this._stats.getSenderStats(this.uplinkConnection);e[this.userId]={bytesSent:t.audio.bytesSent,packetsSent:t.audio.packetsSent}}return e}))}getLocalVideoStats(){return cb(this,null,(function*(){let e={};if(e[this.userId]={bytesSent:0,packetsSent:0,framesEncoded:0,framesSent:0,frameWidth:0,frameHeight:0},this.uplinkConnection){let{video:{bytesSent:t,packetsSent:i,framesEncoded:n,framesSent:r,frameWidth:o,frameHeight:s}}=yield this._stats.getSenderStats(this.uplinkConnection);e[this.userId]={bytesSent:t,packetsSent:i,framesEncoded:n,framesSent:r,frameWidth:o,frameHeight:s}}return e}))}getTransportStats(){return cb(this,null,(function*(){let e={rtt:0,downlinksRTT:{}};if(this.uplinkConnection){let t=yield this._stats.getSenderStats(this.uplinkConnection);e.rtt=t.rtt}for(let[,t]of this.remotePublishedUserMap){let i=yield this._stats.getReceiverStats(t);e.downlinksRTT[i.userId]=i.rtt}return e}))}getRemoteVideoStats(e){return cb(this,null,(function*(){let t={};for(let[i,n]of this.remotePublishedUserMap)"main"===e&&n.muteState.hasVideo&&(t[i]=n.remoteVideoTrack.stat),"auxiliary"===e&&n.muteState.hasAuxiliary&&(t[i]=n.remoteAuxiliaryTrack.stat);return t}))}getRemoteAudioStats(){return cb(this,null,(function*(){let e={};for(let[t,i]of this.remotePublishedUserMap)i.muteState.hasAudio&&(e[t]=i.remoteAudioTrack.stat);return e}))}setTurnServer(e,t){this._log.info("set turn server: ".concat(JSON.stringify(e)," ").concat(t||""));let i=[];Array.isArray(e)?e.forEach((e=>i.push(yb.getTurnServer(e)))):yb.isPlainObject(e)&&i.push(yb.getTurnServer(e)),this._turnServers=i,t&&(this._iceTransportPolicy=t)}sendStartMixTranscode(e){return this._signalChannel.sendWaitForResponse({command:Sx,data:e,timeout:5e3,responseCommand:rx.START_MIX_TRANSCODE_RES,commandDesc:"startMixTranscode"})}sendStopMixTranscode(e){return this._signalChannel.sendWaitForResponse({command:Ix,data:e,timeout:5e3,responseCommand:rx.STOP_MIX_TRANSCODE_RES,commandDesc:"stopMixTranscode"})}sendStartPublishCDN(e){let t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];return this._signalChannel.sendWaitForResponse({command:t?fx:Tx,data:e,timeout:5e3,responseCommand:t?rx.START_PUBLISH_TENCENT_CDN_RES:rx.START_PUBLISH_GIVEN_CDN_RES,commandDesc:"startPublishCDN"})}sendStopPublishCDN(e){let t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];return this._signalChannel.sendWaitForResponse({command:t?gx:Ex,data:e,timeout:5e3,responseCommand:t?rx.STOP_PUBLISH_TENCENT_CDN_RES:rx.STOP_PUBLISH_GIVEN_CDN_RES,commandDesc:"stopPublishCDN"})}sendAbilityStatus(e){var t;null==(t=this._signalChannel)||t.sendWaitForResponse({command:Nx,data:e,timeout:5e3,responseCommand:rx.ABILITY_STATUS_REPORT_RESULT,commandDesc:"ability status report"}).catch((e=>{}))}getIceServers(){return 0===this._turnServers.length&&this.scheduleResult.iceServers?this.scheduleResult.iceServers:this._turnServers}getIceTransportPolicy(){return this._iceTransportPolicy||this.scheduleResult.iceTransportPolicy||"all"}getLogger(){return this._log}enableAIVoice(){throw new Error("Method not implemented.")}getSignalChannelUrl(){let e={mainUrl:"",backupUrl:""},t=yb.getEnv();return t?(e.mainUrl="wss://".concat(t,".rtc.qq.com"),e.backupUrl=e.mainUrl):this.proxy_ws?(e.mainUrl=this.proxy_ws,e.backupUrl=e.mainUrl):Array.isArray(this.scheduleResult.domains)&&this.scheduleResult.domains.length>0&&(e.mainUrl="wss://".concat(this.scheduleResult.domains[0]),e.backupUrl=e.mainUrl,this.scheduleResult.domains[1]&&(e.backupUrl="wss://".concat(this.scheduleResult.domains[1]))),e}getSignalInfo(){var e;return(null==(e=this._signalChannel)?void 0:e.getSignalInfo())||{clientIp:"",relayIp:""}}reset(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];this.stopSyncUserListInterval(),this.stopHeartbeat(),this.closeConnections(),this.clearNetworkQuality(),this.closeUplink("you exitRoom"),this._signalChannel&&(e&&this._signalChannel.keepAlive&&this._signalChannel.isConnected?this._signalChannel.stopKeepAliveIn(3600):this._signalChannel.close(),this.setSignalChannel(null)),this._stats.reset(),this.userManager.clear(),this.userManager.removeAllListeners(),this.singlePC&&(this.singlePC.close(),this.singlePC=null),this.scheduleResult={domains:null,iceServers:null,iceTransportPolicy:null,trtcAutoConf:null}}checkSubscribeBigSmallVideo(e){return cb(this,null,(function*(){let t=null==e?void 0:e.muteState.hasSmall,i=null==e?void 0:e.muteState.hasVideo;if(!t&&!i||!e.isBigStreamSubscribed&&!e.isSmallStreamSubscribed)return;let n=e.getUserId(),r=this._changeBigSmallRecords.get(n)||{},{subscribeState:o}=e,{options:s,isSubscribing:a,reSubscribeCount:c}=r;if(s.video&&o.video||s.smallVideo&&o.smallVideo&&t||a)return;let l={audio:e.remoteAudioTrack.isSubscribed||e.remoteAudioTrack.isSubscribing,auxiliary:e.remoteAuxiliaryTrack.isSubscribed||e.remoteAuxiliaryTrack.isSubscribing,video:s.video,smallVideo:s.smallVideo};if(t&&e.isBigStreamSubscribed||e.isSmallStreamSubscribed)try{s&&!a&&c>=1&&(r.isSubscribing=!0,r.reSubscribeCount=c-1,!t&&e.isSmallStreamSubscribed&&(l.video=!0,l.smallVideo=!1),yield null==e?void 0:e.subscribe(l,"main"),e.remoteVideoTrack.setMediaType(l.smallVideo?8:4),this._log.info("change [".concat(n,"] to ").concat(l.smallVideo?"small":"big"," video successfully. count ").concat(OD-r.reSubscribeCount,".")),r.isSubscribing=!1,r.reSubscribeCount=OD)}catch(u){this._log.info("change [".concat(n,"] to ").concat(l.smallVideo?"small":"big"," video failed. count ").concat(OD-r.reSubscribeCount,".")),r.isSubscribing=!1,0===c&&this._changeBigSmallRecords.delete(n)}}))}changeType(e,t){let i={options:{video:!e,smallVideo:e},isSubscribing:!1,reSubscribeCount:OD};this._changeBigSmallRecords.set(t.userId,i),this._log.info("set [".concat(t.userId,"] video prefer type: ").concat(e?"small":"big"))}get smallStreamConfig(){return this._smallStreamConfig}_initBusinessInfo(e){this._businessInfo=e.businessInfo;let t={};if(mU(e.businessInfo)&&(t=JSON.parse(e.businessInfo)),!fU(e.pureAudioPushMode)){if(!Number.isInteger(Number(e.pureAudioPushMode)))throw new Tb({code:fb.INVALID_PARAMETER,message:QO({key:zO.INVALID_PURE_AUDIO})});this._pureAudioPushMode=e.pureAudioPushMode,t.Str_uc_params||(t.Str_uc_params={}),t.Str_uc_params.pure_audio_push_mod=this._pureAudioPushMode}if(!fU(e.userDefineRecordId)){let i=/^[A-Za-z0-9_-]{1,64}$/gi;if(null===e.userDefineRecordId.match(i))throw new Tb({code:fb.INVALID_PARAMETER,message:QO({key:zO.INVALID_USER_DEFINE_RECORDID})});t.Str_uc_params||(t.Str_uc_params={}),t.Str_uc_params.userdefine_record_id=e.userDefineRecordId}if(!fU(e.userDefinePushArgs)){if(!(mU(e.userDefinePushArgs)&&String(e.userDefinePushArgs)&&String(e.userDefinePushArgs).length<=256))throw new Tb({code:fb.INVALID_PARAMETER,message:QO({key:zO.INVALID_USER_DEFINE_PUSH_ARGS})});t.Str_uc_params||(t.Str_uc_params={}),t.Str_uc_params.userdefine_push_args=e.userDefinePushArgs}EU(t)||(this._businessInfo=JSON.stringify(t))}sendSEI(e,t){var i;null==(i=this.uplinkConnection)||i.sendSEI(e,t)}};return ob([Hw(["left",Ww.INIT],"joined"),iV({settings:{retries:1,timeout:0},onError(e,t,i){this._isUsingCachedSchedule&&!this._isDestroyed?(this._log.warn("is using cached schedule, retry join"),fV(!0),this.reset(),t()):this._signalChannel&&this._signalChannel.isConnected&&this._signalChannel.keepAlive?(this._log.warn("is using keepAlive ws, retry join"),this._signalChannel.close(),this.reset(),t()):(this.reset(),this._log.error(e),i(e))}}),nL((e=>{let t=new JM;return function(i,n,r){return cb(this,null,(function*(){let o=String(i.roomId||i.strRoomId);if(this.userId=i.userId,this.sdkAppId=i.sdkAppId,this.userSig=i.userSig,this._log.setSdkAppId(this.sdkAppId),this._log.setUserId(this.userId),this.scene=n,i.privateMapKey=i.privateMapKey||"",this.isJoined)throw new Tb({code:fb.INVALID_OPERATION,message:QO({key:zO.INVALID_JOIN})});if(this.checkDestroy(),t.isJoined({userId:this.userId,roomId:o,sdkAppId:this.sdkAppId,room:this}))throw new Tb({code:fb.INVALID_OPERATION,message:QO({key:zO.REPEAT_JOIN,data:this.userId})});t.add({room:this,roomId:o}),this.role=21===i.role?"audience":"anchor",this._log.info("Join() => joining room: ".concat(o," useStringRoomId: ").concat(this.useStringRoomId," scene: ").concat(this.scene," role: ").concat(this.role)),UO.emit(BO.JOIN_START,{room:this,roomId:o,params:i}),this.checkSystemResult=yield JO.checkSystemRequirementsInternal(),this.checkDestroy();let s=yb.getEnv();s||(s=RN.QCLOUD,this.proxy_ws&&(this.proxy_ws.startsWith(VN.OLD_CLOUD_LADDER)?s=RN.OLD_CLOUD_LADDER:this.proxy_ws.startsWith(VN.WEBRTC)&&(s=RN.WEBRTC))),Xw.setConfig({env:s,sdkAppId:String(this.sdkAppId),userId:this.userId,roomId:o}),zM.call(this);let{isH264EncodeSupported:a,isVp8EncodeSupported:c}=this.checkSystemResult.detail;if(!JO.isWebRTCSupported()||!a&&!c)throw new Tb({code:fb.NOT_SUPPORTED,message:QO({key:zO.NOT_SUPPORTED_WEBRTC})});try{!this.proxy_ws&&!this.proxy_wt&&!this.scheduleResult.domains&&!yb.getEnv()&&(yield this.schedule(o,r,oN));let t=yield e.call(this,i,n,r);return this.roomId=o,this._joinedTimestamp=yb.performanceNow(),UO.emit(BO.JOIN_SUCCESS,{room:this}),Xw.uploadEvent({log:"stat-conv-".concat(Number(qk),"-").concat(location.hostname),userId:this.userId}),t}catch(d){throw t.delete({room:this,roomId:o}),UO.emit(BO.JOIN_FAILED,{room:this,error:d}),d}}))}}))],SU.prototype,"join",1),ob([Hw("joined","left",{ignoreError:!0,success(){this.reset(!0)}}),nL((e=>function(){return cb(this,null,(function*(){UO.emit(BO.LEAVE_START,{room:this}),yield e.call(this),UO.emit(BO.LEAVE_SUCCESS,{room:this,roomId:this.roomId})}))})),function(e){return function(t,i,n){let r=n.value;return n.value=function(){var t,i;let n=[];for(var o=arguments.length,s=new Array(o),a=0;a<o;a++)s[a]=arguments[a];return null==(t=HV.get(this))||t.forEach((e=>n.push(e))),null==(i=jV.get(this))||i.forEach((e=>e.forEach((e=>n.push(e))))),n.forEach((t=>{t.reject(new Tb({code:fb.API_CALL_ABORTED,message:e}))})),HV.delete(this),jV.delete(this),r.apply(this,s)},n}}("leave room"),nV({fnName:"publish",validateArgs:!1}),nV({fnName:"unsubscribe",validateArgs:!1})],SU.prototype,"leave",1),ob([GV(),nL((e=>function(){for(var t=arguments.length,i=new Array(t),n=0;n<t;n++)i[n]=arguments[n];return cb(this,null,(function*(){if("live"===this.scene&&"anchor"!==this.role||(i=i.filter((e=>e.outMediaTrack&&"capture"===e.state)),!i.length))return;UO.emit("61",{room:this}),i.forEach((e=>{"audio"===e.kind&&this.audioManager.addAudioTrack(e)}));let t=e.apply(this,i);return i.forEach((e=>{var i;e.publish(this,t),"audio"===e.kind&&(null==(i=this.audioManager.localMixAudioTrack)||i.publish(this,t))})),t}))})),iV({settings:{retries:sD,timeout:e=>tO(e)},onError(e,t,i){var n;null!=(n=e.message)&&n.includes("timeout")?(this._log.warn("publish timeout"),t()):(this._log.error("publish failed: ".concat(e)),i(e),UO.emit(BO.PUBLISH_FAILED,{room:this}))}})],SU.prototype,"publish",1),ob([nV({fnName:"publish",callback(){for(var e,t=arguments.length,i=new Array(t),n=0;n<t;n++)i[n]=arguments[n];0===this.localTracks.size&&(null==(e=this.uplinkConnection)||e.close("you unpublished"),this.uplinkConnection=null,i.forEach((e=>e.unpublish())))}}),function(e){return function(t,i,n){let r=n.value;return n.value=function(){for(var t=arguments.length,i=new Array(t),n=0;n<t;n++)i[n]=arguments[n];let o=HV.get(this);if(o){let t=o.filter(((t,n)=>{if(0===n)return!0;let r=!0;return t.args.forEach((e=>{i.find((t=>t===e))||(r=!1)})),!r||(t.reject(new Tb({code:fb.API_CALL_ABORTED,message:e})),!1)}));HV.set(this,t)}return r.apply(this,i)},n}}("api-call"),GV(),nL((e=>function(){for(var t=arguments.length,i=new Array(t),n=0;n<t;n++)i[n]=arguments[n];i.forEach((e=>{"audio"===e.kind&&this.audioManager.removeAudioTrack(e)}));let r=e.apply(this,i);return i.forEach((e=>e.unpublish())),r}))],SU.prototype,"unpublish",1),ob([WV((function(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];return t[0].userId})),nL((e=>function(){for(var t=arguments.length,i=new Array(t),n=0;n<t;n++)i[n]=arguments[n];let r=e.apply(this,i);return i.forEach((e=>!e.isSubscribed&&e.subscribe(r))),r})),iV({settings:{retries:sD,timeout:e=>tO(e)},onError(e,t,i,n){e.message.includes("timeout")?(this._log.warn("subscribe timeout"),t()):(this._log.error("subscribe failed: ".concat(e)),i(e),UO.emit(BO.SUBSCRIBE_FAILED,{room:this,remoteTracks:n}))}})],SU.prototype,"subscribe",1),ob([nV({fnName:"subscribe",callback(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];this.singlePC||t.forEach((e=>{let t=this.remotePublishedUserMap.get(e.userId);t&&!t.isMainStreamSubscribed&&!t.isAuxStreamSubscribed&&t.close("you unsubscribed")}))}}),WV((function(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];return t[0].userId}))],SU.prototype,"unsubscribe",1),WM.create=WM._create.bind(WM,SU),WM}))},2268:function(e,t,i){"use strict";i.d(t,{Je:function(){return s},X9:function(){return o}});var n=i(4164);let r="https://api.xayunmei.com/zhongcaiapitest";function o(e){return n.Z.get(`${r}/caseApplication/generateUserSign?userId=${e}`)}function s(e){return n.Z.get(`${r}/caseApplication/reserveConferenceList?caseId=${e}`)}},4164:function(e,t,i){"use strict";i.d(t,{Z:function(){return Wt}});var n={};i.r(n),i.d(n,{hasBrowserEnv:function(){return we},hasStandardBrowserEnv:function(){return Pe},hasStandardBrowserWebWorkerEnv:function(){return Le}});i(4224),i(1121),i(7133),i(560);function r(e,t){return function(){return e.apply(t,arguments)}}const{toString:o}=Object.prototype,{getPrototypeOf:s}=Object,a=(e=>t=>{const i=o.call(t);return e[i]||(e[i]=i.slice(8,-1).toLowerCase())})(Object.create(null)),c=e=>(e=e.toLowerCase(),t=>a(t)===e),l=e=>t=>typeof t===e,{isArray:d}=Array,u=l("undefined");function h(e){return null!==e&&!u(e)&&null!==e.constructor&&!u(e.constructor)&&f(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}const p=c("ArrayBuffer");function m(e){let t;return t="undefined"!==typeof ArrayBuffer&&ArrayBuffer.isView?ArrayBuffer.isView(e):e&&e.buffer&&p(e.buffer),t}const _=l("string"),f=l("function"),g=l("number"),T=e=>null!==e&&"object"===typeof e,E=e=>!0===e||!1===e,S=e=>{if("object"!==a(e))return!1;const t=s(e);return(null===t||t===Object.prototype||null===Object.getPrototypeOf(t))&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)},I=c("Date"),y=c("File"),v=c("Blob"),A=c("FileList"),R=e=>T(e)&&f(e.pipe),C=e=>{let t;return e&&("function"===typeof FormData&&e instanceof FormData||f(e.append)&&("formdata"===(t=a(e))||"object"===t&&f(e.toString)&&"[object FormData]"===e.toString()))},b=c("URLSearchParams"),k=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function N(e,t,{allOwnKeys:i=!1}={}){if(null===e||"undefined"===typeof e)return;let n,r;if("object"!==typeof e&&(e=[e]),d(e))for(n=0,r=e.length;n<r;n++)t.call(null,e[n],n,e);else{const r=i?Object.getOwnPropertyNames(e):Object.keys(e),o=r.length;let s;for(n=0;n<o;n++)s=r[n],t.call(null,e[s],s,e)}}function D(e,t){t=t.toLowerCase();const i=Object.keys(e);let n,r=i.length;while(r-- >0)if(n=i[r],t===n.toLowerCase())return n;return null}const O=(()=>"undefined"!==typeof globalThis?globalThis:"undefined"!==typeof self?self:"undefined"!==typeof window?window:global)(),w=e=>!u(e)&&e!==O;function P(){const{caseless:e}=w(this)&&this||{},t={},i=(i,n)=>{const r=e&&D(t,n)||n;S(t[r])&&S(i)?t[r]=P(t[r],i):S(i)?t[r]=P({},i):d(i)?t[r]=i.slice():t[r]=i};for(let n=0,r=arguments.length;n<r;n++)arguments[n]&&N(arguments[n],i);return t}const L=(e,t,i,{allOwnKeys:n}={})=>(N(t,((t,n)=>{i&&f(t)?e[n]=r(t,i):e[n]=t}),{allOwnKeys:n}),e),M=e=>(65279===e.charCodeAt(0)&&(e=e.slice(1)),e),x=(e,t,i,n)=>{e.prototype=Object.create(t.prototype,n),e.prototype.constructor=e,Object.defineProperty(e,"super",{value:t.prototype}),i&&Object.assign(e.prototype,i)},V=(e,t,i,n)=>{let r,o,a;const c={};if(t=t||{},null==e)return t;do{r=Object.getOwnPropertyNames(e),o=r.length;while(o-- >0)a=r[o],n&&!n(a,e,t)||c[a]||(t[a]=e[a],c[a]=!0);e=!1!==i&&s(e)}while(e&&(!i||i(e,t))&&e!==Object.prototype);return t},U=(e,t,i)=>{e=String(e),(void 0===i||i>e.length)&&(i=e.length),i-=t.length;const n=e.indexOf(t,i);return-1!==n&&n===i},F=e=>{if(!e)return null;if(d(e))return e;let t=e.length;if(!g(t))return null;const i=new Array(t);while(t-- >0)i[t]=e[t];return i},B=(e=>t=>e&&t instanceof e)("undefined"!==typeof Uint8Array&&s(Uint8Array)),H=(e,t)=>{const i=e&&e[Symbol.iterator],n=i.call(e);let r;while((r=n.next())&&!r.done){const i=r.value;t.call(e,i[0],i[1])}},j=(e,t)=>{let i;const n=[];while(null!==(i=e.exec(t)))n.push(i);return n},G=c("HTMLFormElement"),W=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,(function(e,t,i){return t.toUpperCase()+i})),J=(({hasOwnProperty:e})=>(t,i)=>e.call(t,i))(Object.prototype),z=c("RegExp"),K=(e,t)=>{const i=Object.getOwnPropertyDescriptors(e),n={};N(i,((i,r)=>{let o;!1!==(o=t(i,r,e))&&(n[r]=o||i)})),Object.defineProperties(e,n)},q=e=>{K(e,((t,i)=>{if(f(e)&&-1!==["arguments","caller","callee"].indexOf(i))return!1;const n=e[i];f(n)&&(t.enumerable=!1,"writable"in t?t.writable=!1:t.set||(t.set=()=>{throw Error("Can not rewrite read-only method '"+i+"'")}))}))},Y=(e,t)=>{const i={},n=e=>{e.forEach((e=>{i[e]=!0}))};return d(e)?n(e):n(String(e).split(t)),i},Q=()=>{},X=(e,t)=>(e=+e,Number.isFinite(e)?e:t),$="abcdefghijklmnopqrstuvwxyz",Z="0123456789",ee={DIGIT:Z,ALPHA:$,ALPHA_DIGIT:$+$.toUpperCase()+Z},te=(e=16,t=ee.ALPHA_DIGIT)=>{let i="";const{length:n}=t;while(e--)i+=t[Math.random()*n|0];return i};function ie(e){return!!(e&&f(e.append)&&"FormData"===e[Symbol.toStringTag]&&e[Symbol.iterator])}const ne=e=>{const t=new Array(10),i=(e,n)=>{if(T(e)){if(t.indexOf(e)>=0)return;if(!("toJSON"in e)){t[n]=e;const r=d(e)?[]:{};return N(e,((e,t)=>{const o=i(e,n+1);!u(o)&&(r[t]=o)})),t[n]=void 0,r}}return e};return i(e,0)},re=c("AsyncFunction"),oe=e=>e&&(T(e)||f(e))&&f(e.then)&&f(e.catch);var se={isArray:d,isArrayBuffer:p,isBuffer:h,isFormData:C,isArrayBufferView:m,isString:_,isNumber:g,isBoolean:E,isObject:T,isPlainObject:S,isUndefined:u,isDate:I,isFile:y,isBlob:v,isRegExp:z,isFunction:f,isStream:R,isURLSearchParams:b,isTypedArray:B,isFileList:A,forEach:N,merge:P,extend:L,trim:k,stripBOM:M,inherits:x,toFlatObject:V,kindOf:a,kindOfTest:c,endsWith:U,toArray:F,forEachEntry:H,matchAll:j,isHTMLForm:G,hasOwnProperty:J,hasOwnProp:J,reduceDescriptors:K,freezeMethods:q,toObjectSet:Y,toCamelCase:W,noop:Q,toFiniteNumber:X,findKey:D,global:O,isContextDefined:w,ALPHABET:ee,generateString:te,isSpecCompliantForm:ie,toJSONObject:ne,isAsyncFn:re,isThenable:oe};function ae(e,t,i,n,r){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=(new Error).stack,this.message=e,this.name="AxiosError",t&&(this.code=t),i&&(this.config=i),n&&(this.request=n),r&&(this.response=r)}se.inherits(ae,Error,{toJSON:function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:se.toJSONObject(this.config),code:this.code,status:this.response&&this.response.status?this.response.status:null}}});const ce=ae.prototype,le={};["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED","ERR_NOT_SUPPORT","ERR_INVALID_URL"].forEach((e=>{le[e]={value:e}})),Object.defineProperties(ae,le),Object.defineProperty(ce,"isAxiosError",{value:!0}),ae.from=(e,t,i,n,r,o)=>{const s=Object.create(ce);return se.toFlatObject(e,s,(function(e){return e!==Error.prototype}),(e=>"isAxiosError"!==e)),ae.call(s,e.message,t,i,n,r),s.cause=e,s.name=e.name,o&&Object.assign(s,o),s};var de=ae,ue=null;function he(e){return se.isPlainObject(e)||se.isArray(e)}function pe(e){return se.endsWith(e,"[]")?e.slice(0,-2):e}function me(e,t,i){return e?e.concat(t).map((function(e,t){return e=pe(e),!i&&t?"["+e+"]":e})).join(i?".":""):t}function _e(e){return se.isArray(e)&&!e.some(he)}const fe=se.toFlatObject(se,{},null,(function(e){return/^is[A-Z]/.test(e)}));function ge(e,t,i){if(!se.isObject(e))throw new TypeError("target must be an object");t=t||new(ue||FormData),i=se.toFlatObject(i,{metaTokens:!0,dots:!1,indexes:!1},!1,(function(e,t){return!se.isUndefined(t[e])}));const n=i.metaTokens,r=i.visitor||d,o=i.dots,s=i.indexes,a=i.Blob||"undefined"!==typeof Blob&&Blob,c=a&&se.isSpecCompliantForm(t);if(!se.isFunction(r))throw new TypeError("visitor must be a function");function l(e){if(null===e)return"";if(se.isDate(e))return e.toISOString();if(!c&&se.isBlob(e))throw new de("Blob is not supported. Use a Buffer instead.");return se.isArrayBuffer(e)||se.isTypedArray(e)?c&&"function"===typeof Blob?new Blob([e]):Buffer.from(e):e}function d(e,i,r){let a=e;if(e&&!r&&"object"===typeof e)if(se.endsWith(i,"{}"))i=n?i:i.slice(0,-2),e=JSON.stringify(e);else if(se.isArray(e)&&_e(e)||(se.isFileList(e)||se.endsWith(i,"[]"))&&(a=se.toArray(e)))return i=pe(i),a.forEach((function(e,n){!se.isUndefined(e)&&null!==e&&t.append(!0===s?me([i],n,o):null===s?i:i+"[]",l(e))})),!1;return!!he(e)||(t.append(me(r,i,o),l(e)),!1)}const u=[],h=Object.assign(fe,{defaultVisitor:d,convertValue:l,isVisitable:he});function p(e,i){if(!se.isUndefined(e)){if(-1!==u.indexOf(e))throw Error("Circular reference detected in "+i.join("."));u.push(e),se.forEach(e,(function(e,n){const o=!(se.isUndefined(e)||null===e)&&r.call(t,e,se.isString(n)?n.trim():n,i,h);!0===o&&p(e,i?i.concat(n):[n])})),u.pop()}}if(!se.isObject(e))throw new TypeError("data must be an object");return p(e),t}var Te=ge;function Ee(e){const t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,(function(e){return t[e]}))}function Se(e,t){this._pairs=[],e&&Te(e,this,t)}const Ie=Se.prototype;Ie.append=function(e,t){this._pairs.push([e,t])},Ie.toString=function(e){const t=e?function(t){return e.call(this,t,Ee)}:Ee;return this._pairs.map((function(e){return t(e[0])+"="+t(e[1])}),"").join("&")};var ye=Se;function ve(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}function Ae(e,t,i){if(!t)return e;const n=i&&i.encode||ve,r=i&&i.serialize;let o;if(o=r?r(t,i):se.isURLSearchParams(t)?t.toString():new ye(t,i).toString(n),o){const t=e.indexOf("#");-1!==t&&(e=e.slice(0,t)),e+=(-1===e.indexOf("?")?"?":"&")+o}return e}class Re{constructor(){this.handlers=[]}use(e,t,i){return this.handlers.push({fulfilled:e,rejected:t,synchronous:!!i&&i.synchronous,runWhen:i?i.runWhen:null}),this.handlers.length-1}eject(e){this.handlers[e]&&(this.handlers[e]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(e){se.forEach(this.handlers,(function(t){null!==t&&e(t)}))}}var Ce=Re,be={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},ke=(i(8858),i(1318),i(3228),"undefined"!==typeof URLSearchParams?URLSearchParams:ye),Ne="undefined"!==typeof FormData?FormData:null,De="undefined"!==typeof Blob?Blob:null,Oe={isBrowser:!0,classes:{URLSearchParams:ke,FormData:Ne,Blob:De},protocols:["http","https","file","blob","url","data"]};const we="undefined"!==typeof window&&"undefined"!==typeof document,Pe=(e=>we&&["ReactNative","NativeScript","NS"].indexOf(e)<0)("undefined"!==typeof navigator&&navigator.product),Le=(()=>"undefined"!==typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope&&"function"===typeof self.importScripts)();var Me={...n,...Oe};function xe(e,t){return Te(e,new Me.classes.URLSearchParams,Object.assign({visitor:function(e,t,i,n){return Me.isNode&&se.isBuffer(e)?(this.append(t,e.toString("base64")),!1):n.defaultVisitor.apply(this,arguments)}},t))}function Ve(e){return se.matchAll(/\w+|\[(\w*)]/g,e).map((e=>"[]"===e[0]?"":e[1]||e[0]))}function Ue(e){const t={},i=Object.keys(e);let n;const r=i.length;let o;for(n=0;n<r;n++)o=i[n],t[o]=e[o];return t}function Fe(e){function t(e,i,n,r){let o=e[r++];const s=Number.isFinite(+o),a=r>=e.length;if(o=!o&&se.isArray(n)?n.length:o,a)return se.hasOwnProp(n,o)?n[o]=[n[o],i]:n[o]=i,!s;n[o]&&se.isObject(n[o])||(n[o]=[]);const c=t(e,i,n[o],r);return c&&se.isArray(n[o])&&(n[o]=Ue(n[o])),!s}if(se.isFormData(e)&&se.isFunction(e.entries)){const i={};return se.forEachEntry(e,((e,n)=>{t(Ve(e),n,i,0)})),i}return null}var Be=Fe;function He(e,t,i){if(se.isString(e))try{return(t||JSON.parse)(e),se.trim(e)}catch(n){if("SyntaxError"!==n.name)throw n}return(i||JSON.stringify)(e)}const je={transitional:be,adapter:["xhr","http"],transformRequest:[function(e,t){const i=t.getContentType()||"",n=i.indexOf("application/json")>-1,r=se.isObject(e);r&&se.isHTMLForm(e)&&(e=new FormData(e));const o=se.isFormData(e);if(o)return n&&n?JSON.stringify(Be(e)):e;if(se.isArrayBuffer(e)||se.isBuffer(e)||se.isStream(e)||se.isFile(e)||se.isBlob(e))return e;if(se.isArrayBufferView(e))return e.buffer;if(se.isURLSearchParams(e))return t.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),e.toString();let s;if(r){if(i.indexOf("application/x-www-form-urlencoded")>-1)return xe(e,this.formSerializer).toString();if((s=se.isFileList(e))||i.indexOf("multipart/form-data")>-1){const t=this.env&&this.env.FormData;return Te(s?{"files[]":e}:e,t&&new t,this.formSerializer)}}return r||n?(t.setContentType("application/json",!1),He(e)):e}],transformResponse:[function(e){const t=this.transitional||je.transitional,i=t&&t.forcedJSONParsing,n="json"===this.responseType;if(e&&se.isString(e)&&(i&&!this.responseType||n)){const i=t&&t.silentJSONParsing,o=!i&&n;try{return JSON.parse(e)}catch(r){if(o){if("SyntaxError"===r.name)throw de.from(r,de.ERR_BAD_RESPONSE,this,null,this.response);throw r}}}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:Me.classes.FormData,Blob:Me.classes.Blob},validateStatus:function(e){return e>=200&&e<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};se.forEach(["delete","get","head","post","put","patch"],(e=>{je.headers[e]={}}));var Ge=je;const We=se.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]);var Je=e=>{const t={};let i,n,r;return e&&e.split("\n").forEach((function(e){r=e.indexOf(":"),i=e.substring(0,r).trim().toLowerCase(),n=e.substring(r+1).trim(),!i||t[i]&&We[i]||("set-cookie"===i?t[i]?t[i].push(n):t[i]=[n]:t[i]=t[i]?t[i]+", "+n:n)})),t};const ze=Symbol("internals");function Ke(e){return e&&String(e).trim().toLowerCase()}function qe(e){return!1===e||null==e?e:se.isArray(e)?e.map(qe):String(e)}function Ye(e){const t=Object.create(null),i=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;let n;while(n=i.exec(e))t[n[1]]=n[2];return t}const Qe=e=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim());function Xe(e,t,i,n,r){return se.isFunction(n)?n.call(this,t,i):(r&&(t=i),se.isString(t)?se.isString(n)?-1!==t.indexOf(n):se.isRegExp(n)?n.test(t):void 0:void 0)}function $e(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,((e,t,i)=>t.toUpperCase()+i))}function Ze(e,t){const i=se.toCamelCase(" "+t);["get","set","has"].forEach((n=>{Object.defineProperty(e,n+i,{value:function(e,i,r){return this[n].call(this,t,e,i,r)},configurable:!0})}))}class et{constructor(e){e&&this.set(e)}set(e,t,i){const n=this;function r(e,t,i){const r=Ke(t);if(!r)throw new Error("header name must be a non-empty string");const o=se.findKey(n,r);(!o||void 0===n[o]||!0===i||void 0===i&&!1!==n[o])&&(n[o||t]=qe(e))}const o=(e,t)=>se.forEach(e,((e,i)=>r(e,i,t)));return se.isPlainObject(e)||e instanceof this.constructor?o(e,t):se.isString(e)&&(e=e.trim())&&!Qe(e)?o(Je(e),t):null!=e&&r(t,e,i),this}get(e,t){if(e=Ke(e),e){const i=se.findKey(this,e);if(i){const e=this[i];if(!t)return e;if(!0===t)return Ye(e);if(se.isFunction(t))return t.call(this,e,i);if(se.isRegExp(t))return t.exec(e);throw new TypeError("parser must be boolean|regexp|function")}}}has(e,t){if(e=Ke(e),e){const i=se.findKey(this,e);return!(!i||void 0===this[i]||t&&!Xe(this,this[i],i,t))}return!1}delete(e,t){const i=this;let n=!1;function r(e){if(e=Ke(e),e){const r=se.findKey(i,e);!r||t&&!Xe(i,i[r],r,t)||(delete i[r],n=!0)}}return se.isArray(e)?e.forEach(r):r(e),n}clear(e){const t=Object.keys(this);let i=t.length,n=!1;while(i--){const r=t[i];e&&!Xe(this,this[r],r,e,!0)||(delete this[r],n=!0)}return n}normalize(e){const t=this,i={};return se.forEach(this,((n,r)=>{const o=se.findKey(i,r);if(o)return t[o]=qe(n),void delete t[r];const s=e?$e(r):String(r).trim();s!==r&&delete t[r],t[s]=qe(n),i[s]=!0})),this}concat(...e){return this.constructor.concat(this,...e)}toJSON(e){const t=Object.create(null);return se.forEach(this,((i,n)=>{null!=i&&!1!==i&&(t[n]=e&&se.isArray(i)?i.join(", "):i)})),t}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map((([e,t])=>e+": "+t)).join("\n")}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(e){return e instanceof this?e:new this(e)}static concat(e,...t){const i=new this(e);return t.forEach((e=>i.set(e))),i}static accessor(e){const t=this[ze]=this[ze]={accessors:{}},i=t.accessors,n=this.prototype;function r(e){const t=Ke(e);i[t]||(Ze(n,e),i[t]=!0)}return se.isArray(e)?e.forEach(r):r(e),this}}et.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),se.reduceDescriptors(et.prototype,(({value:e},t)=>{let i=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(e){this[i]=e}}})),se.freezeMethods(et);var tt=et;function it(e,t){const i=this||Ge,n=t||i,r=tt.from(n.headers);let o=n.data;return se.forEach(e,(function(e){o=e.call(i,o,r.normalize(),t?t.status:void 0)})),r.normalize(),o}function nt(e){return!(!e||!e.__CANCEL__)}function rt(e,t,i){de.call(this,null==e?"canceled":e,de.ERR_CANCELED,t,i),this.name="CanceledError"}se.inherits(rt,de,{__CANCEL__:!0});var ot=rt;i(3429);function st(e,t,i){const n=i.config.validateStatus;i.status&&n&&!n(i.status)?t(new de("Request failed with status code "+i.status,[de.ERR_BAD_REQUEST,de.ERR_BAD_RESPONSE][Math.floor(i.status/100)-4],i.config,i.request,i)):e(i)}var at=Me.hasStandardBrowserEnv?{write(e,t,i,n,r,o){const s=[e+"="+encodeURIComponent(t)];se.isNumber(i)&&s.push("expires="+new Date(i).toGMTString()),se.isString(n)&&s.push("path="+n),se.isString(r)&&s.push("domain="+r),!0===o&&s.push("secure"),document.cookie=s.join("; ")},read(e){const t=document.cookie.match(new RegExp("(^|;\\s*)("+e+")=([^;]*)"));return t?decodeURIComponent(t[3]):null},remove(e){this.write(e,"",Date.now()-864e5)}}:{write(){},read(){return null},remove(){}};function ct(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function lt(e,t){return t?e.replace(/\/+$/,"")+"/"+t.replace(/^\/+/,""):e}function dt(e,t){return e&&!ct(t)?lt(e,t):t}var ut=Me.hasStandardBrowserEnv?function(){const e=/(msie|trident)/i.test(navigator.userAgent),t=document.createElement("a");let i;function n(i){let n=i;return e&&(t.setAttribute("href",n),n=t.href),t.setAttribute("href",n),{href:t.href,protocol:t.protocol?t.protocol.replace(/:$/,""):"",host:t.host,search:t.search?t.search.replace(/^\?/,""):"",hash:t.hash?t.hash.replace(/^#/,""):"",hostname:t.hostname,port:t.port,pathname:"/"===t.pathname.charAt(0)?t.pathname:"/"+t.pathname}}return i=n(window.location.href),function(e){const t=se.isString(e)?n(e):e;return t.protocol===i.protocol&&t.host===i.host}}():function(){return function(){return!0}}();function ht(e){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}function pt(e,t){e=e||10;const i=new Array(e),n=new Array(e);let r,o=0,s=0;return t=void 0!==t?t:1e3,function(a){const c=Date.now(),l=n[s];r||(r=c),i[o]=a,n[o]=c;let d=s,u=0;while(d!==o)u+=i[d++],d%=e;if(o=(o+1)%e,o===s&&(s=(s+1)%e),c-r<t)return;const h=l&&c-l;return h?Math.round(1e3*u/h):void 0}}var mt=pt;function _t(e,t){let i=0;const n=mt(50,250);return r=>{const o=r.loaded,s=r.lengthComputable?r.total:void 0,a=o-i,c=n(a),l=o<=s;i=o;const d={loaded:o,total:s,progress:s?o/s:void 0,bytes:a,rate:c||void 0,estimated:c&&s&&l?(s-o)/c:void 0,event:r};d[t?"download":"upload"]=!0,e(d)}}const ft="undefined"!==typeof XMLHttpRequest;var gt=ft&&function(e){return new Promise((function(t,i){let n=e.data;const r=tt.from(e.headers).normalize();let o,s,{responseType:a,withXSRFToken:c}=e;function l(){e.cancelToken&&e.cancelToken.unsubscribe(o),e.signal&&e.signal.removeEventListener("abort",o)}if(se.isFormData(n))if(Me.hasStandardBrowserEnv||Me.hasStandardBrowserWebWorkerEnv)r.setContentType(!1);else if(!1!==(s=r.getContentType())){const[e,...t]=s?s.split(";").map((e=>e.trim())).filter(Boolean):[];r.setContentType([e||"multipart/form-data",...t].join("; "))}let d=new XMLHttpRequest;if(e.auth){const t=e.auth.username||"",i=e.auth.password?unescape(encodeURIComponent(e.auth.password)):"";r.set("Authorization","Basic "+btoa(t+":"+i))}const u=dt(e.baseURL,e.url);function h(){if(!d)return;const n=tt.from("getAllResponseHeaders"in d&&d.getAllResponseHeaders()),r=a&&"text"!==a&&"json"!==a?d.response:d.responseText,o={data:r,status:d.status,statusText:d.statusText,headers:n,config:e,request:d};st((function(e){t(e),l()}),(function(e){i(e),l()}),o),d=null}if(d.open(e.method.toUpperCase(),Ae(u,e.params,e.paramsSerializer),!0),d.timeout=e.timeout,"onloadend"in d?d.onloadend=h:d.onreadystatechange=function(){d&&4===d.readyState&&(0!==d.status||d.responseURL&&0===d.responseURL.indexOf("file:"))&&setTimeout(h)},d.onabort=function(){d&&(i(new de("Request aborted",de.ECONNABORTED,e,d)),d=null)},d.onerror=function(){i(new de("Network Error",de.ERR_NETWORK,e,d)),d=null},d.ontimeout=function(){let t=e.timeout?"timeout of "+e.timeout+"ms exceeded":"timeout exceeded";const n=e.transitional||be;e.timeoutErrorMessage&&(t=e.timeoutErrorMessage),i(new de(t,n.clarifyTimeoutError?de.ETIMEDOUT:de.ECONNABORTED,e,d)),d=null},Me.hasStandardBrowserEnv&&(c&&se.isFunction(c)&&(c=c(e)),c||!1!==c&&ut(u))){const t=e.xsrfHeaderName&&e.xsrfCookieName&&at.read(e.xsrfCookieName);t&&r.set(e.xsrfHeaderName,t)}void 0===n&&r.setContentType(null),"setRequestHeader"in d&&se.forEach(r.toJSON(),(function(e,t){d.setRequestHeader(t,e)})),se.isUndefined(e.withCredentials)||(d.withCredentials=!!e.withCredentials),a&&"json"!==a&&(d.responseType=e.responseType),"function"===typeof e.onDownloadProgress&&d.addEventListener("progress",_t(e.onDownloadProgress,!0)),"function"===typeof e.onUploadProgress&&d.upload&&d.upload.addEventListener("progress",_t(e.onUploadProgress)),(e.cancelToken||e.signal)&&(o=t=>{d&&(i(!t||t.type?new ot(null,e,d):t),d.abort(),d=null)},e.cancelToken&&e.cancelToken.subscribe(o),e.signal&&(e.signal.aborted?o():e.signal.addEventListener("abort",o)));const p=ht(u);p&&-1===Me.protocols.indexOf(p)?i(new de("Unsupported protocol "+p+":",de.ERR_BAD_REQUEST,e)):d.send(n||null)}))};const Tt={http:ue,xhr:gt};se.forEach(Tt,((e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch(i){}Object.defineProperty(e,"adapterName",{value:t})}}));const Et=e=>`- ${e}`,St=e=>se.isFunction(e)||null===e||!1===e;var It={getAdapter:e=>{e=se.isArray(e)?e:[e];const{length:t}=e;let i,n;const r={};for(let o=0;o<t;o++){let t;if(i=e[o],n=i,!St(i)&&(n=Tt[(t=String(i)).toLowerCase()],void 0===n))throw new de(`Unknown adapter '${t}'`);if(n)break;r[t||"#"+o]=n}if(!n){const e=Object.entries(r).map((([e,t])=>`adapter ${e} `+(!1===t?"is not supported by the environment":"is not available in the build")));let i=t?e.length>1?"since :\n"+e.map(Et).join("\n"):" "+Et(e[0]):"as no adapter specified";throw new de("There is no suitable adapter to dispatch the request "+i,"ERR_NOT_SUPPORT")}return n},adapters:Tt};function yt(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new ot(null,e)}function vt(e){yt(e),e.headers=tt.from(e.headers),e.data=it.call(e,e.transformRequest),-1!==["post","put","patch"].indexOf(e.method)&&e.headers.setContentType("application/x-www-form-urlencoded",!1);const t=It.getAdapter(e.adapter||Ge.adapter);return t(e).then((function(t){return yt(e),t.data=it.call(e,e.transformResponse,t),t.headers=tt.from(t.headers),t}),(function(t){return nt(t)||(yt(e),t&&t.response&&(t.response.data=it.call(e,e.transformResponse,t.response),t.response.headers=tt.from(t.response.headers))),Promise.reject(t)}))}const At=e=>e instanceof tt?e.toJSON():e;function Rt(e,t){t=t||{};const i={};function n(e,t,i){return se.isPlainObject(e)&&se.isPlainObject(t)?se.merge.call({caseless:i},e,t):se.isPlainObject(t)?se.merge({},t):se.isArray(t)?t.slice():t}function r(e,t,i){return se.isUndefined(t)?se.isUndefined(e)?void 0:n(void 0,e,i):n(e,t,i)}function o(e,t){if(!se.isUndefined(t))return n(void 0,t)}function s(e,t){return se.isUndefined(t)?se.isUndefined(e)?void 0:n(void 0,e):n(void 0,t)}function a(i,r,o){return o in t?n(i,r):o in e?n(void 0,i):void 0}const c={url:o,method:o,data:o,baseURL:s,transformRequest:s,transformResponse:s,paramsSerializer:s,timeout:s,timeoutMessage:s,withCredentials:s,withXSRFToken:s,adapter:s,responseType:s,xsrfCookieName:s,xsrfHeaderName:s,onUploadProgress:s,onDownloadProgress:s,decompress:s,maxContentLength:s,maxBodyLength:s,beforeRedirect:s,transport:s,httpAgent:s,httpsAgent:s,cancelToken:s,socketPath:s,responseEncoding:s,validateStatus:a,headers:(e,t)=>r(At(e),At(t),!0)};return se.forEach(Object.keys(Object.assign({},e,t)),(function(n){const o=c[n]||r,s=o(e[n],t[n],n);se.isUndefined(s)&&o!==a||(i[n]=s)})),i}const Ct="1.6.2",bt={};["object","boolean","number","function","string","symbol"].forEach(((e,t)=>{bt[e]=function(i){return typeof i===e||"a"+(t<1?"n ":" ")+e}}));const kt={};function Nt(e,t,i){if("object"!==typeof e)throw new de("options must be an object",de.ERR_BAD_OPTION_VALUE);const n=Object.keys(e);let r=n.length;while(r-- >0){const o=n[r],s=t[o];if(s){const t=e[o],i=void 0===t||s(t,o,e);if(!0!==i)throw new de("option "+o+" must be "+i,de.ERR_BAD_OPTION_VALUE)}else if(!0!==i)throw new de("Unknown option "+o,de.ERR_BAD_OPTION)}}bt.transitional=function(e,t,i){function n(e,t){return"[Axios v"+Ct+"] Transitional option '"+e+"'"+t+(i?". "+i:"")}return(i,r,o)=>{if(!1===e)throw new de(n(r," has been removed"+(t?" in "+t:"")),de.ERR_DEPRECATED);return t&&!kt[r]&&(kt[r]=!0,console.warn(n(r," has been deprecated since v"+t+" and will be removed in the near future"))),!e||e(i,r,o)}};var Dt={assertOptions:Nt,validators:bt};const Ot=Dt.validators;class wt{constructor(e){this.defaults=e,this.interceptors={request:new Ce,response:new Ce}}request(e,t){"string"===typeof e?(t=t||{},t.url=e):t=e||{},t=Rt(this.defaults,t);const{transitional:i,paramsSerializer:n,headers:r}=t;void 0!==i&&Dt.assertOptions(i,{silentJSONParsing:Ot.transitional(Ot.boolean),forcedJSONParsing:Ot.transitional(Ot.boolean),clarifyTimeoutError:Ot.transitional(Ot.boolean)},!1),null!=n&&(se.isFunction(n)?t.paramsSerializer={serialize:n}:Dt.assertOptions(n,{encode:Ot.function,serialize:Ot.function},!0)),t.method=(t.method||this.defaults.method||"get").toLowerCase();let o=r&&se.merge(r.common,r[t.method]);r&&se.forEach(["delete","get","head","post","put","patch","common"],(e=>{delete r[e]})),t.headers=tt.concat(o,r);const s=[];let a=!0;this.interceptors.request.forEach((function(e){"function"===typeof e.runWhen&&!1===e.runWhen(t)||(a=a&&e.synchronous,s.unshift(e.fulfilled,e.rejected))}));const c=[];let l;this.interceptors.response.forEach((function(e){c.push(e.fulfilled,e.rejected)}));let d,u=0;if(!a){const e=[vt.bind(this),void 0];e.unshift.apply(e,s),e.push.apply(e,c),d=e.length,l=Promise.resolve(t);while(u<d)l=l.then(e[u++],e[u++]);return l}d=s.length;let h=t;u=0;while(u<d){const e=s[u++],t=s[u++];try{h=e(h)}catch(p){t.call(this,p);break}}try{l=vt.call(this,h)}catch(p){return Promise.reject(p)}u=0,d=c.length;while(u<d)l=l.then(c[u++],c[u++]);return l}getUri(e){e=Rt(this.defaults,e);const t=dt(e.baseURL,e.url);return Ae(t,e.params,e.paramsSerializer)}}se.forEach(["delete","get","head","options"],(function(e){wt.prototype[e]=function(t,i){return this.request(Rt(i||{},{method:e,url:t,data:(i||{}).data}))}})),se.forEach(["post","put","patch"],(function(e){function t(t){return function(i,n,r){return this.request(Rt(r||{},{method:e,headers:t?{"Content-Type":"multipart/form-data"}:{},url:i,data:n}))}}wt.prototype[e]=t(),wt.prototype[e+"Form"]=t(!0)}));var Pt=wt;class Lt{constructor(e){if("function"!==typeof e)throw new TypeError("executor must be a function.");let t;this.promise=new Promise((function(e){t=e}));const i=this;this.promise.then((e=>{if(!i._listeners)return;let t=i._listeners.length;while(t-- >0)i._listeners[t](e);i._listeners=null})),this.promise.then=e=>{let t;const n=new Promise((e=>{i.subscribe(e),t=e})).then(e);return n.cancel=function(){i.unsubscribe(t)},n},e((function(e,n,r){i.reason||(i.reason=new ot(e,n,r),t(i.reason))}))}throwIfRequested(){if(this.reason)throw this.reason}subscribe(e){this.reason?e(this.reason):this._listeners?this._listeners.push(e):this._listeners=[e]}unsubscribe(e){if(!this._listeners)return;const t=this._listeners.indexOf(e);-1!==t&&this._listeners.splice(t,1)}static source(){let e;const t=new Lt((function(t){e=t}));return{token:t,cancel:e}}}var Mt=Lt;function xt(e){return function(t){return e.apply(null,t)}}function Vt(e){return se.isObject(e)&&!0===e.isAxiosError}const Ut={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511};Object.entries(Ut).forEach((([e,t])=>{Ut[t]=e}));var Ft=Ut;function Bt(e){const t=new Pt(e),i=r(Pt.prototype.request,t);return se.extend(i,Pt.prototype,t,{allOwnKeys:!0}),se.extend(i,t,null,{allOwnKeys:!0}),i.create=function(t){return Bt(Rt(e,t))},i}const Ht=Bt(Ge);Ht.Axios=Pt,Ht.CanceledError=ot,Ht.CancelToken=Mt,Ht.isCancel=nt,Ht.VERSION=Ct,Ht.toFormData=Te,Ht.AxiosError=de,Ht.Cancel=Ht.CanceledError,Ht.all=function(e){return Promise.all(e)},Ht.spread=xt,Ht.isAxiosError=Vt,Ht.mergeConfig=Rt,Ht.AxiosHeaders=tt,Ht.formToJSON=e=>Be(se.isHTMLForm(e)?new FormData(e):e),Ht.getAdapter=It.getAdapter,Ht.HttpStatusCode=Ft,Ht.default=Ht;var jt=Ht;const Gt=jt.create({baseURL:"",timeout:2e4});Gt.interceptors.request.use((e=>e),(e=>{Promise.reject(e)})),Gt.interceptors.response.use((e=>e.data),(e=>{console.error(e)}));var Wt=Gt},6097:function(e,t,i){"use strict";function n(e){return 1==e.length?"userVideo":2==e.length?"userVideo1":3==e.length?"userVideo2":e.length>3?"userVideo3":0==e.length?"userVideo4":void 0}function r(e){let t=Math.ceil((e.length+1)/3);return 1==t?"100%":1/t*100+"%"}function o(e){return 0==e.length?"userVideoPhone":"userVideoPhone1"}function s(){var e=navigator.userAgent.toLowerCase(),t="ipad"==e.match(/ipad/i),i="iphone os"==e.match(/iphone os/i),n="midp"==e.match(/midp/i),r="rv:1.2.3.4"==e.match(/rv:1.2.3.4/i),o="ucweb"==e.match(/ucweb/i),s="android"==e.match(/android/i),a="windows ce"==e.match(/windows ce/i),c="windows mobile"==e.match(/windows mobile/i);return!(t||i||n||r||o||s||a||c)}i.d(t,{A1:function(){return o},Cr:function(){return r},Qv:function(){return s},dz:function(){return n}})},767:function(e,t,i){"use strict";var n=i(3622),r=TypeError;e.exports=function(e,t){if(n(t,e))return e;throw new r("Incorrect invocation")}},7136:function(e){"use strict";e.exports={IndexSizeError:{s:"INDEX_SIZE_ERR",c:1,m:1},DOMStringSizeError:{s:"DOMSTRING_SIZE_ERR",c:2,m:0},HierarchyRequestError:{s:"HIERARCHY_REQUEST_ERR",c:3,m:1},WrongDocumentError:{s:"WRONG_DOCUMENT_ERR",c:4,m:1},InvalidCharacterError:{s:"INVALID_CHARACTER_ERR",c:5,m:1},NoDataAllowedError:{s:"NO_DATA_ALLOWED_ERR",c:6,m:0},NoModificationAllowedError:{s:"NO_MODIFICATION_ALLOWED_ERR",c:7,m:1},NotFoundError:{s:"NOT_FOUND_ERR",c:8,m:1},NotSupportedError:{s:"NOT_SUPPORTED_ERR",c:9,m:1},InUseAttributeError:{s:"INUSE_ATTRIBUTE_ERR",c:10,m:1},InvalidStateError:{s:"INVALID_STATE_ERR",c:11,m:1},SyntaxError:{s:"SYNTAX_ERR",c:12,m:1},InvalidModificationError:{s:"INVALID_MODIFICATION_ERR",c:13,m:1},NamespaceError:{s:"NAMESPACE_ERR",c:14,m:1},InvalidAccessError:{s:"INVALID_ACCESS_ERR",c:15,m:1},ValidationError:{s:"VALIDATION_ERR",c:16,m:0},TypeMismatchError:{s:"TYPE_MISMATCH_ERR",c:17,m:1},SecurityError:{s:"SECURITY_ERR",c:18,m:1},NetworkError:{s:"NETWORK_ERR",c:19,m:1},AbortError:{s:"ABORT_ERR",c:20,m:1},URLMismatchError:{s:"URL_MISMATCH_ERR",c:21,m:1},QuotaExceededError:{s:"QUOTA_EXCEEDED_ERR",c:22,m:1},TimeoutError:{s:"TIMEOUT_ERR",c:23,m:1},InvalidNodeTypeError:{s:"INVALID_NODE_TYPE_ERR",c:24,m:1},DataCloneError:{s:"DATA_CLONE_ERR",c:25,m:1}}},6610:function(e,t,i){"use strict";var n=i(8844),r=Error,o=n("".replace),s=function(e){return String(new r(e).stack)}("zxcasd"),a=/\n\s*at [^:]*:[^\n]*/,c=a.test(s);e.exports=function(e,t){if(c&&"string"==typeof e&&!r.prepareStackTrace)while(t--)e=o(e,a,"");return e}},3457:function(e,t,i){"use strict";var n=i(9985),r=i(8999),o=i(9385);e.exports=function(e,t,i){var s,a;return o&&n(s=t.constructor)&&s!==i&&r(a=s.prototype)&&a!==i.prototype&&o(e,a),e}},3841:function(e,t,i){"use strict";var n=i(4327);e.exports=function(e,t){return void 0===e?arguments.length<2?"":t:n(e)}},9633:function(e,t,i){"use strict";var n=i(5027);e.exports=function(){var e=n(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}},5847:function(e,t,i){"use strict";var n=i(9037),r=i(7697),o=i(2148),s=i(9633),a=i(3689),c=n.RegExp,l=c.prototype,d=r&&a((function(){var e=!0;try{c(".","d")}catch(d){e=!1}var t={},i="",n=e?"dgimsy":"gimsy",r=function(e,n){Object.defineProperty(t,e,{get:function(){return i+=n,!0}})},o={dotAll:"s",global:"g",ignoreCase:"i",multiline:"m",sticky:"y"};for(var s in e&&(o.hasIndices="d"),o)r(s,o[s]);var a=Object.getOwnPropertyDescriptor(l,"flags").get.call(t);return a!==n||i!==n}));d&&o(l,"flags",{configurable:!0,get:s})},3429:function(e,t,i){"use strict";var n=i(9989),r=i(9037),o=i(6058),s=i(5684),a=i(2560).f,c=i(6812),l=i(767),d=i(3457),u=i(3841),h=i(7136),p=i(6610),m=i(7697),_=i(3931),f="DOMException",g=o("Error"),T=o(f),E=function(){l(this,S);var e=arguments.length,t=u(e<1?void 0:arguments[0]),i=u(e<2?void 0:arguments[1],"Error"),n=new T(t,i),r=new g(t);return r.name=f,a(n,"stack",s(1,p(r.stack,1))),d(n,this,E),n},S=E.prototype=T.prototype,I="stack"in new g(f),y="stack"in new T(1,2),v=T&&m&&Object.getOwnPropertyDescriptor(r,f),A=!!v&&!(v.writable&&v.configurable),R=I&&!A&&!y;n({global:!0,constructor:!0,forced:_||R},{DOMException:R?E:T});var C=o(f),b=C.prototype;if(b.constructor!==C)for(var k in _||a(b,"constructor",s(1,C)),h)if(c(h,k)){var N=h[k],D=N.s;c(C,D)||a(C,D,s(6,N.c))}}}]);
  2. //# sourceMappingURL=315.7612841b.js.map