Files
zyt/server/public/admin/assets/trtc-js-sdk-DYM4KK88.js
T
2026-03-04 15:32:30 +08:00

71 lines
567 KiB
JavaScript
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import{aA as pT}from"./@vue-DqCYILjk.js";var hc={exports:{}},tB=hc.exports,fT;function iB(){return fT||(fT=1,function(mT,nB){(function(pc,te){mT.exports=te()})(tB,function(){function pc(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter(function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable})),n.push.apply(n,i)}return n}function te(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?pc(Object(n),!0).forEach(function(i){Ba(e,i,n[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):pc(Object(n)).forEach(function(i){Object.defineProperty(e,i,Object.getOwnPropertyDescriptor(n,i))})}return e}function M(){M=function(){return e};var e={},t=Object.prototype,n=t.hasOwnProperty,i=typeof Symbol=="function"?Symbol:{},r=i.iterator||"@@iterator",o=i.asyncIterator||"@@asyncIterator",c=i.toStringTag||"@@toStringTag";function a(R,P,y){return Object.defineProperty(R,P,{value:y,enumerable:!0,configurable:!0,writable:!0}),R[P]}try{a({},"")}catch{a=function(P,y,d){return P[y]=d}}function s(R,P,y,d){var _=P&&P.prototype instanceof h?P:h,E=Object.create(_.prototype),C=new m(d||[]);return E._invoke=function(O,L,N){var W="suspendedStart";return function(B,se){if(W==="executing")throw new Error("Generator is already running");if(W==="completed"){if(B==="throw")throw se;return w()}for(N.method=B,N.arg=se;;){var ee=N.delegate;if(ee){var ne=A(ee,N);if(ne){if(ne===u)continue;return ne}}if(N.method==="next")N.sent=N._sent=N.arg;else if(N.method==="throw"){if(W==="suspendedStart")throw W="completed",N.arg;N.dispatchException(N.arg)}else N.method==="return"&&N.abrupt("return",N.arg);W="executing";var _e=l(O,L,N);if(_e.type==="normal"){if(W=N.done?"completed":"suspendedYield",_e.arg===u)continue;return{value:_e.arg,done:N.done}}_e.type==="throw"&&(W="completed",N.method="throw",N.arg=_e.arg)}}}(R,y,C),E}function l(R,P,y){try{return{type:"normal",arg:R.call(P,y)}}catch(d){return{type:"throw",arg:d}}}e.wrap=s;var u={};function h(){}function g(){}function b(){}var T={};a(T,r,function(){return this});var k=Object.getPrototypeOf,p=k&&k(k(v([])));p&&p!==t&&n.call(p,r)&&(T=p);var S=b.prototype=h.prototype=Object.create(T);function f(R){["next","throw","return"].forEach(function(P){a(R,P,function(y){return this._invoke(P,y)})})}function I(R,P){function y(_,E,C,O){var L=l(R[_],R,E);if(L.type!=="throw"){var N=L.arg,W=N.value;return W&&typeof W=="object"&&n.call(W,"__await")?P.resolve(W.__await).then(function(B){y("next",B,C,O)},function(B){y("throw",B,C,O)}):P.resolve(W).then(function(B){N.value=B,C(N)},function(B){return y("throw",B,C,O)})}O(L.arg)}var d;this._invoke=function(_,E){function C(){return new P(function(O,L){y(_,E,O,L)})}return d=d?d.then(C,C):C()}}function A(R,P){var y=R.iterator[P.method];if(y===void 0){if(P.delegate=null,P.method==="throw"){if(R.iterator.return&&(P.method="return",P.arg=void 0,A(R,P),P.method==="throw"))return u;P.method="throw",P.arg=new TypeError("The iterator does not provide a 'throw' method")}return u}var d=l(y,R.iterator,P.arg);if(d.type==="throw")return P.method="throw",P.arg=d.arg,P.delegate=null,u;var _=d.arg;return _?_.done?(P[R.resultName]=_.value,P.next=R.nextLoc,P.method!=="return"&&(P.method="next",P.arg=void 0),P.delegate=null,u):_:(P.method="throw",P.arg=new TypeError("iterator result is not an object"),P.delegate=null,u)}function x(R){var P={tryLoc:R[0]};1 in R&&(P.catchLoc=R[1]),2 in R&&(P.finallyLoc=R[2],P.afterLoc=R[3]),this.tryEntries.push(P)}function D(R){var P=R.completion||{};P.type="normal",delete P.arg,R.completion=P}function m(R){this.tryEntries=[{tryLoc:"root"}],R.forEach(x,this),this.reset(!0)}function v(R){if(R){var P=R[r];if(P)return P.call(R);if(typeof R.next=="function")return R;if(!isNaN(R.length)){var y=-1,d=function _(){for(;++y<R.length;)if(n.call(R,y))return _.value=R[y],_.done=!1,_;return _.value=void 0,_.done=!0,_};return d.next=d}}return{next:w}}function w(){return{value:void 0,done:!0}}return g.prototype=b,a(S,"constructor",b),a(b,"constructor",g),g.displayName=a(b,c,"GeneratorFunction"),e.isGeneratorFunction=function(R){var P=typeof R=="function"&&R.constructor;return!!P&&(P===g||(P.displayName||P.name)==="GeneratorFunction")},e.mark=function(R){return Object.setPrototypeOf?Object.setPrototypeOf(R,b):(R.__proto__=b,a(R,c,"GeneratorFunction")),R.prototype=Object.create(S),R},e.awrap=function(R){return{__await:R}},f(I.prototype),a(I.prototype,o,function(){return this}),e.AsyncIterator=I,e.async=function(R,P,y,d,_){_===void 0&&(_=Promise);var E=new I(s(R,P,y,d),_);return e.isGeneratorFunction(P)?E:E.next().then(function(C){return C.done?C.value:E.next()})},f(S),a(S,c,"Generator"),a(S,r,function(){return this}),a(S,"toString",function(){return"[object Generator]"}),e.keys=function(R){var P=[];for(var y in R)P.push(y);return P.reverse(),function d(){for(;P.length;){var _=P.pop();if(_ in R)return d.value=_,d.done=!1,d}return d.done=!0,d}},e.values=v,m.prototype={constructor:m,reset:function(R){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(D),!R)for(var P in this)P.charAt(0)==="t"&&n.call(this,P)&&!isNaN(+P.slice(1))&&(this[P]=void 0)},stop:function(){this.done=!0;var R=this.tryEntries[0].completion;if(R.type==="throw")throw R.arg;return this.rval},dispatchException:function(R){if(this.done)throw R;var P=this;function y(L,N){return E.type="throw",E.arg=R,P.next=L,N&&(P.method="next",P.arg=void 0),!!N}for(var d=this.tryEntries.length-1;d>=0;--d){var _=this.tryEntries[d],E=_.completion;if(_.tryLoc==="root")return y("end");if(_.tryLoc<=this.prev){var C=n.call(_,"catchLoc"),O=n.call(_,"finallyLoc");if(C&&O){if(this.prev<_.catchLoc)return y(_.catchLoc,!0);if(this.prev<_.finallyLoc)return y(_.finallyLoc)}else if(C){if(this.prev<_.catchLoc)return y(_.catchLoc,!0)}else{if(!O)throw new Error("try statement without catch or finally");if(this.prev<_.finallyLoc)return y(_.finallyLoc)}}}},abrupt:function(R,P){for(var y=this.tryEntries.length-1;y>=0;--y){var d=this.tryEntries[y];if(d.tryLoc<=this.prev&&n.call(d,"finallyLoc")&&this.prev<d.finallyLoc){var _=d;break}}_&&(R==="break"||R==="continue")&&_.tryLoc<=P&&P<=_.finallyLoc&&(_=null);var E=_?_.completion:{};return E.type=R,E.arg=P,_?(this.method="next",this.next=_.finallyLoc,u):this.complete(E)},complete:function(R,P){if(R.type==="throw")throw R.arg;return R.type==="break"||R.type==="continue"?this.next=R.arg:R.type==="return"?(this.rval=this.arg=R.arg,this.method="return",this.next="end"):R.type==="normal"&&P&&(this.next=P),u},finish:function(R){for(var P=this.tryEntries.length-1;P>=0;--P){var y=this.tryEntries[P];if(y.finallyLoc===R)return this.complete(y.completion,y.afterLoc),D(y),u}},catch:function(R){for(var P=this.tryEntries.length-1;P>=0;--P){var y=this.tryEntries[P];if(y.tryLoc===R){var d=y.completion;if(d.type==="throw"){var _=d.arg;D(y)}return _}}throw new Error("illegal catch attempt")},delegateYield:function(R,P,y){return this.delegate={iterator:v(R),resultName:P,nextLoc:y},this.method==="next"&&(this.arg=void 0),u}},e}function bi(e){return bi=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},bi(e)}function Gp(e,t,n,i,r,o,c){try{var a=e[o](c),s=a.value}catch(l){return void n(l)}a.done?t(s):Promise.resolve(s).then(i,r)}function F(e){return function(){var t=this,n=arguments;return new Promise(function(i,r){var o=e.apply(t,n);function c(s){Gp(o,i,r,c,a,"next",s)}function a(s){Gp(o,i,r,c,a,"throw",s)}c(void 0)})}}function ce(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function zp(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}function ue(e,t,n){return t&&zp(e.prototype,t),n&&zp(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}function Ba(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function ki(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&Ii(e,t)}function ve(e){return ve=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},ve(e)}function Ii(e,t){return Ii=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(n,i){return n.__proto__=i,n},Ii(e,t)}function Jp(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function fc(e,t,n){return fc=Jp()?Reflect.construct.bind():function(i,r,o){var c=[null];c.push.apply(c,r);var a=new(Function.bind.apply(i,c));return o&&Ii(a,o.prototype),a},fc.apply(null,arguments)}function mc(e){var t=typeof Map=="function"?new Map:void 0;return mc=function(n){if(n===null||(i=n,Function.toString.call(i).indexOf("[native code]")===-1))return n;var i;if(typeof n!="function")throw new TypeError("Super expression must either be null or a function");if(t!==void 0){if(t.has(n))return t.get(n);t.set(n,r)}function r(){return fc(n,arguments,ve(this).constructor)}return r.prototype=Object.create(n.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),Ii(r,n)},mc(e)}function _T(e,t){if(t&&(typeof t=="object"||typeof t=="function"))return t;if(t!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return function(n){if(n===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return n}(e)}function Ti(e){var t=Jp();return function(){var n,i=ve(e);if(t){var r=ve(this).constructor;n=Reflect.construct(i,arguments,r)}else n=i.apply(this,arguments);return _T(this,n)}}function vT(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&(e=ve(e))!==null;);return e}function Re(){return Re=typeof Reflect<"u"&&Reflect.get?Reflect.get.bind():function(e,t,n){var i=vT(e,t);if(i){var r=Object.getOwnPropertyDescriptor(i,t);return r.get?r.get.call(arguments.length<3?e:n):r.value}},Re.apply(this,arguments)}function lt(e,t){return function(n){if(Array.isArray(n))return n}(e)||function(n,i){var r=n==null?null:typeof Symbol<"u"&&n[Symbol.iterator]||n["@@iterator"];if(r!=null){var o,c,a=[],s=!0,l=!1;try{for(r=r.call(n);!(s=(o=r.next()).done)&&(a.push(o.value),!i||a.length!==i);s=!0);}catch(u){l=!0,c=u}finally{try{s||r.return==null||r.return()}finally{if(l)throw c}}return a}}(e,t)||_c(e,t)||function(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}()}function Se(e){return function(t){if(Array.isArray(t))return vc(t)}(e)||function(t){if(typeof Symbol<"u"&&t[Symbol.iterator]!=null||t["@@iterator"]!=null)return Array.from(t)}(e)||_c(e)||function(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}()}function _c(e,t){if(e){if(typeof e=="string")return vc(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return n==="Object"&&e.constructor&&(n=e.constructor.name),n==="Map"||n==="Set"?Array.from(e):n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?vc(e,t):void 0}}function vc(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,i=new Array(t);n<t;n++)i[n]=e[n];return i}function qt(e,t){var n=typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=_c(e))||t){n&&(e=n);var i=0,r=function(){};return{s:r,n:function(){return i>=e.length?{done:!0}:{done:!1,value:e[i++]}},e:function(s){throw s},f:r}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var o,c=!0,a=!1;return{s:function(){n=n.call(e)},n:function(){var s=n.next();return c=s.done,s},e:function(s){a=!0,o=s},f:function(){try{c||n.return==null||n.return()}finally{if(a)throw o}}}}function ie(e,t,n,i,r){var o={};return Object.keys(i).forEach(function(c){o[c]=i[c]}),o.enumerable=!!o.enumerable,o.configurable=!!o.configurable,("value"in o||o.initializer)&&(o.writable=!0),o=n.slice().reverse().reduce(function(c,a){return a(e,t,c)||c},o),r&&o.initializer!==void 0&&(o.value=o.initializer?o.initializer.call(r):void 0,o.initializer=void 0),o.initializer===void 0&&(Object.defineProperty(e,t,o),o=null),o}var gc=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof pT<"u"?pT:typeof self<"u"?self:{},Ha=function(e){return e&&e.Math==Math&&e},oe=Ha(typeof globalThis=="object"&&globalThis)||Ha(typeof window=="object"&&window)||Ha(typeof self=="object"&&self)||Ha(typeof gc=="object"&&gc)||function(){return this}()||Function("return this")(),hn={},Z=function(e){try{return!!e()}catch{return!0}},Ae=!Z(function(){return Object.defineProperty({},1,{get:function(){return 7}})[1]!=7}),wi=!Z(function(){var e=(function(){}).bind();return typeof e!="function"||e.hasOwnProperty("prototype")}),gT=wi,Wa=Function.prototype.call,we=gT?Wa.bind(Wa):function(){return Wa.apply(Wa,arguments)},Ga={},qp={}.propertyIsEnumerable,Kp=Object.getOwnPropertyDescriptor,yT=Kp&&!qp.call({1:2},1);Ga.f=yT?function(e){var t=Kp(this,e);return!!t&&t.enumerable}:qp;var pn,za,Sr=function(e,t){return{enumerable:!(1&e),configurable:!(2&e),writable:!(4&e),value:t}},Qp=wi,Xp=Function.prototype,yc=Xp.call,ST=Qp&&Xp.bind.bind(yc,yc),Yp=function(e){return Qp?ST(e):function(){return yc.apply(e,arguments)}},$p=Yp,bT=$p({}.toString),kT=$p("".slice),Kt=function(e){return kT(bT(e),8,-1)},IT=Kt,TT=Yp,$=function(e){if(IT(e)==="Function")return TT(e)},wT=Z,ET=Kt,Sc=Object,RT=$("".split),Ei=wT(function(){return!Sc("z").propertyIsEnumerable(0)})?function(e){return ET(e)=="String"?RT(e,""):Sc(e)}:Sc,Lt=function(e){return e==null},CT=Lt,AT=TypeError,dt=function(e){if(CT(e))throw AT("Can't call method on "+e);return e},xT=Ei,PT=dt,kt=function(e){return xT(PT(e))},bc=typeof document=="object"&&document.all,Ja={all:bc,IS_HTMLDDA:bc===void 0&&bc!==void 0},DT=Ja.all,ge=Ja.IS_HTMLDDA?function(e){return typeof e=="function"||e===DT}:function(e){return typeof e=="function"},Zp=ge,OT=Ja.all,xe=Ja.IS_HTMLDDA?function(e){return typeof e=="object"?e!==null:Zp(e)||e===OT}:function(e){return typeof e=="object"?e!==null:Zp(e)},kc=oe,MT=ge,NT=function(e){return MT(e)?e:void 0},Qt=function(e,t){return arguments.length<2?NT(kc[e]):kc[e]&&kc[e][t]},fn=$({}.isPrototypeOf),Xt=Qt("navigator","userAgent")||"",ef=oe,Ic=Xt,tf=ef.process,nf=ef.Deno,rf=tf&&tf.versions||nf&&nf.version,af=rf&&rf.v8;af&&(za=(pn=af.split("."))[0]>0&&pn[0]<4?1:+(pn[0]+pn[1])),!za&&Ic&&(!(pn=Ic.match(/Edge\/(\d+)/))||pn[1]>=74)&&(pn=Ic.match(/Chrome\/(\d+)/))&&(za=+pn[1]);var br=za,of=br,LT=Z,sf=!!Object.getOwnPropertySymbols&&!LT(function(){var e=Symbol();return!String(e)||!(Object(e)instanceof Symbol)||!Symbol.sham&&of&&of<41}),cf=sf&&!Symbol.sham&&typeof Symbol.iterator=="symbol",UT=Qt,VT=ge,jT=fn,FT=Object,qa=cf?function(e){return typeof e=="symbol"}:function(e){var t=UT("Symbol");return VT(t)&&jT(t.prototype,FT(e))},BT=String,kr=function(e){try{return BT(e)}catch{return"Object"}},HT=ge,WT=kr,GT=TypeError,It=function(e){if(HT(e))return e;throw GT(WT(e)+" is not a function")},zT=It,JT=Lt,Ir=function(e,t){var n=e[t];return JT(n)?void 0:zT(n)},Tc=we,wc=ge,Ec=xe,qT=TypeError,Ka={exports:{}},uf=oe,KT=Object.defineProperty,Rc=function(e,t){try{KT(uf,e,{value:t,configurable:!0,writable:!0})}catch{uf[e]=t}return t},QT=Rc,lf="__core-js_shared__",Cc=oe[lf]||QT(lf,{}),df=Cc;(Ka.exports=function(e,t){return df[e]||(df[e]=t!==void 0?t:{})})("versions",[]).push({version:"3.25.5",mode:"global",copyright:"© 2014-2022 Denis Pushkarev (zloirock.ru)",license:"https://github.com/zloirock/core-js/blob/v3.25.5/LICENSE",source:"https://github.com/zloirock/core-js"});var XT=dt,YT=Object,ze=function(e){return YT(XT(e))},$T=ze,ZT=$({}.hasOwnProperty),Le=Object.hasOwn||function(e,t){return ZT($T(e),t)},ew=$,tw=0,nw=Math.random(),rw=ew(1 .toString),Qa=function(e){return"Symbol("+(e===void 0?"":e)+")_"+rw(++tw+nw,36)},iw=oe,aw=Ka.exports,hf=Le,ow=Qa,pf=sf,ff=cf,Ri=aw("wks"),Bn=iw.Symbol,mf=Bn&&Bn.for,sw=ff?Bn:Bn&&Bn.withoutSetter||ow,be=function(e){if(!hf(Ri,e)||!pf&&typeof Ri[e]!="string"){var t="Symbol."+e;pf&&hf(Bn,e)?Ri[e]=Bn[e]:Ri[e]=ff&&mf?mf(t):sw(t)}return Ri[e]},cw=we,_f=xe,vf=qa,uw=Ir,lw=function(e,t){var n,i;if(t==="string"&&wc(n=e.toString)&&!Ec(i=Tc(n,e))||wc(n=e.valueOf)&&!Ec(i=Tc(n,e))||t!=="string"&&wc(n=e.toString)&&!Ec(i=Tc(n,e)))return i;throw qT("Can't convert object to primitive value")},dw=TypeError,hw=be("toPrimitive"),Xa=function(e,t){if(!_f(e)||vf(e))return e;var n,i=uw(e,hw);if(i){if(t===void 0&&(t="default"),n=cw(i,e,t),!_f(n)||vf(n))return n;throw dw("Can't convert object to primitive value")}return t===void 0&&(t="number"),lw(e,t)},pw=Xa,fw=qa,Ya=function(e){var t=pw(e,"string");return fw(t)?t:t+""},gf=xe,Ac=oe.document,mw=gf(Ac)&&gf(Ac.createElement),$a=function(e){return mw?Ac.createElement(e):{}},_w=$a,yf=!Ae&&!Z(function(){return Object.defineProperty(_w("div"),"a",{get:function(){return 7}}).a!=7}),vw=Ae,gw=we,yw=Ga,Sw=Sr,bw=kt,kw=Ya,Iw=Le,Tw=yf,Sf=Object.getOwnPropertyDescriptor;hn.f=vw?Sf:function(e,t){if(e=bw(e),t=kw(t),Tw)try{return Sf(e,t)}catch{}if(Iw(e,t))return Sw(!gw(yw.f,e,t),e[t])};var Ve={},bf=Ae&&Z(function(){return Object.defineProperty(function(){},"prototype",{value:42,writable:!1}).prototype!=42}),ww=xe,Ew=String,Rw=TypeError,Oe=function(e){if(ww(e))return e;throw Rw(Ew(e)+" is not an object")},Cw=Ae,Aw=yf,xw=bf,Za=Oe,kf=Ya,Pw=TypeError,xc=Object.defineProperty,Dw=Object.getOwnPropertyDescriptor,Ow="enumerable",Mw="configurable",Nw="writable";Ve.f=Cw?xw?function(e,t,n){if(Za(e),t=kf(t),Za(n),typeof e=="function"&&t==="prototype"&&"value"in n&&Nw in n&&!n.writable){var i=Dw(e,t);i&&i.writable&&(e[t]=n.value,n={configurable:Mw in n?n.configurable:i.configurable,enumerable:Ow in n?n.enumerable:i.enumerable,writable:!1})}return xc(e,t,n)}:xc:function(e,t,n){if(Za(e),t=kf(t),Za(n),Aw)try{return xc(e,t,n)}catch{}if("get"in n||"set"in n)throw Pw("Accessors not supported");return"value"in n&&(e[t]=n.value),e};var Lw=Ve,Uw=Sr,Ut=Ae?function(e,t,n){return Lw.f(e,t,Uw(1,n))}:function(e,t,n){return e[t]=n,e},Pc={exports:{}},Dc=Ae,Vw=Le,If=Function.prototype,jw=Dc&&Object.getOwnPropertyDescriptor,Oc=Vw(If,"name"),Hn={EXISTS:Oc,PROPER:Oc&&(function(){}).name==="something",CONFIGURABLE:Oc&&(!Dc||Dc&&jw(If,"name").configurable)},Fw=ge,Mc=Cc,Bw=$(Function.toString);Fw(Mc.inspectSource)||(Mc.inspectSource=function(e){return Bw(e)});var eo,Ci,to,Nc=Mc.inspectSource,Hw=ge,Tf=oe.WeakMap,wf=Hw(Tf)&&/native code/.test(String(Tf)),Ww=Ka.exports,Gw=Qa,Ef=Ww("keys"),Lc=function(e){return Ef[e]||(Ef[e]=Gw(e))},no={},zw=wf,Rf=oe,Jw=xe,qw=Ut,Uc=Le,Vc=Cc,Kw=Lc,Qw=no,Cf="Object already initialized",jc=Rf.TypeError,Xw=Rf.WeakMap;if(zw||Vc.state){var Vt=Vc.state||(Vc.state=new Xw);Vt.get=Vt.get,Vt.has=Vt.has,Vt.set=Vt.set,eo=function(e,t){if(Vt.has(e))throw jc(Cf);return t.facade=e,Vt.set(e,t),t},Ci=function(e){return Vt.get(e)||{}},to=function(e){return Vt.has(e)}}else{var Tr=Kw("state");Qw[Tr]=!0,eo=function(e,t){if(Uc(e,Tr))throw jc(Cf);return t.facade=e,qw(e,Tr,t),t},Ci=function(e){return Uc(e,Tr)?e[Tr]:{}},to=function(e){return Uc(e,Tr)}}var Me={set:eo,get:Ci,has:to,enforce:function(e){return to(e)?Ci(e):eo(e,{})},getterFor:function(e){return function(t){var n;if(!Jw(t)||(n=Ci(t)).type!==e)throw jc("Incompatible receiver, "+e+" required");return n}}},Yw=Z,$w=ge,ro=Le,Fc=Ae,Zw=Hn.CONFIGURABLE,eE=Nc,tE=Me.enforce,nE=Me.get,io=Object.defineProperty,rE=Fc&&!Yw(function(){return io(function(){},"length",{value:8}).length!==8}),iE=String(String).split("String"),aE=Pc.exports=function(e,t,n){String(t).slice(0,7)==="Symbol("&&(t="["+String(t).replace(/^Symbol\(([^)]*)\)/,"$1")+"]"),n&&n.getter&&(t="get "+t),n&&n.setter&&(t="set "+t),(!ro(e,"name")||Zw&&e.name!==t)&&(Fc?io(e,"name",{value:t,configurable:!0}):e.name=t),rE&&n&&ro(n,"arity")&&e.length!==n.arity&&io(e,"length",{value:n.arity});try{n&&ro(n,"constructor")&&n.constructor?Fc&&io(e,"prototype",{writable:!1}):e.prototype&&(e.prototype=void 0)}catch{}var i=tE(e);return ro(i,"source")||(i.source=iE.join(typeof t=="string"?t:"")),e};Function.prototype.toString=aE(function(){return $w(this)&&nE(this).source||eE(this)},"toString");var oE=ge,sE=Ve,cE=Pc.exports,uE=Rc,He=function(e,t,n,i){i||(i={});var r=i.enumerable,o=i.name!==void 0?i.name:t;if(oE(n)&&cE(n,o,i),i.global)r?e[t]=n:uE(t,n);else{try{i.unsafe?e[t]&&(r=!0):delete e[t]}catch{}r?e[t]=n:sE.f(e,t,{value:n,enumerable:!1,configurable:!i.nonConfigurable,writable:!i.nonWritable})}return e},mn={},lE=Math.ceil,dE=Math.floor,hE=Math.trunc||function(e){var t=+e;return(t>0?dE:lE)(t)},Tt=function(e){var t=+e;return t!=t||t===0?0:hE(t)},pE=Tt,fE=Math.max,mE=Math.min,_n=function(e,t){var n=pE(e);return n<0?fE(n+t,0):mE(n,t)},_E=Tt,vE=Math.min,jt=function(e){return e>0?vE(_E(e),9007199254740991):0},gE=jt,qe=function(e){return gE(e.length)},yE=kt,SE=_n,bE=qe,Af=function(e){return function(t,n,i){var r,o=yE(t),c=bE(o),a=SE(i,c);if(e&&n!=n){for(;c>a;)if((r=o[a++])!=r)return!0}else for(;c>a;a++)if((e||a in o)&&o[a]===n)return e||a||0;return!e&&-1}},Ai={includes:Af(!0),indexOf:Af(!1)},Bc=Le,kE=kt,IE=Ai.indexOf,TE=no,xf=$([].push),Pf=function(e,t){var n,i=kE(e),r=0,o=[];for(n in i)!Bc(TE,n)&&Bc(i,n)&&xf(o,n);for(;t.length>r;)Bc(i,n=t[r++])&&(~IE(o,n)||xf(o,n));return o},Hc=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"],wE=Pf,EE=Hc.concat("length","prototype");mn.f=Object.getOwnPropertyNames||function(e){return wE(e,EE)};var Wc={};Wc.f=Object.getOwnPropertySymbols;var RE=Qt,CE=mn,AE=Wc,xE=Oe,PE=$([].concat),DE=RE("Reflect","ownKeys")||function(e){var t=CE.f(xE(e)),n=AE.f;return n?PE(t,n(e)):t},OE=Le,ME=DE,NE=hn,LE=Ve,UE=Z,VE=ge,jE=/#|\.prototype\./,xi=function(e,t){var n=BE[FE(e)];return n==WE||n!=HE&&(VE(t)?UE(t):!!t)},FE=xi.normalize=function(e){return String(e).replace(jE,".").toLowerCase()},BE=xi.data={},HE=xi.NATIVE="N",WE=xi.POLYFILL="P",Pi=xi,Gc=oe,GE=hn.f,zE=Ut,JE=He,qE=Rc,KE=function(e,t,n){for(var i=ME(t),r=LE.f,o=NE.f,c=0;c<i.length;c++){var a=i[c];OE(e,a)||n||r(e,a,o(t,a))}},QE=Pi,Y=function(e,t){var n,i,r,o,c,a=e.target,s=e.global,l=e.stat;if(n=s?Gc:l?Gc[a]||qE(a,{}):(Gc[a]||{}).prototype)for(i in t){if(o=t[i],r=e.dontCallGetSet?(c=GE(n,i))&&c.value:n[i],!QE(s?i:a+(l?".":"#")+i,e.forced)&&r!==void 0){if(typeof o==typeof r)continue;KE(o,r)}(e.sham||r&&r.sham)&&zE(o,"sham",!0),JE(n,i,o,e)}},XE=Y,YE=Z,$E=kt,Df=hn.f,Of=Ae,ZE=YE(function(){Df(1)});function zc(e){throw new Error('Could not dynamically require "'+e+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}XE({target:"Object",stat:!0,forced:!Of||ZE,sham:!Of},{getOwnPropertyDescriptor:function(e,t){return Df($E(e),t)}}),function(e,t){e.exports=function(){function n(i,r,o){function c(l,u){if(!r[l]){if(!i[l]){if(!u&&zc)return zc(l);if(a)return a(l,!0);var h=new Error("Cannot find module '"+l+"'");throw h.code="MODULE_NOT_FOUND",h}var g=r[l]={exports:{}};i[l][0].call(g.exports,function(b){return c(i[l][1][b]||b)},g,g.exports,n,i,r,o)}return r[l].exports}for(var a=zc,s=0;s<o.length;s++)c(o[s]);return c}return n}()({1:[function(n,i,r){var o=(0,n("./adapter_factory.js").adapterFactory)({window:typeof window>"u"?void 0:window});i.exports=o},{"./adapter_factory.js":2}],2:[function(n,i,r){function o(k){return o=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(p){return typeof p}:function(p){return p&&typeof Symbol=="function"&&p.constructor===Symbol&&p!==Symbol.prototype?"symbol":typeof p},o(k)}Object.defineProperty(r,"__esModule",{value:!0}),r.adapterFactory=T;var c=b(n("./utils")),a=b(n("./chrome/chrome_shim")),s=b(n("./firefox/firefox_shim")),l=b(n("./safari/safari_shim")),u=b(n("./common_shim")),h=b(n("sdp"));function g(k){if(typeof WeakMap!="function")return null;var p=new WeakMap,S=new WeakMap;return(g=function(f){return f?S:p})(k)}function b(k,p){if(k&&k.__esModule)return k;if(k===null||o(k)!=="object"&&typeof k!="function")return{default:k};var S=g(p);if(S&&S.has(k))return S.get(k);var f={},I=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var A in k)if(A!=="default"&&Object.prototype.hasOwnProperty.call(k,A)){var x=I?Object.getOwnPropertyDescriptor(k,A):null;x&&(x.get||x.set)?Object.defineProperty(f,A,x):f[A]=k[A]}return f.default=k,S&&S.set(k,f),f}function T(){var k=(arguments.length>0&&arguments[0]!==void 0?arguments[0]:{}).window,p=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{shimChrome:!0,shimFirefox:!0,shimSafari:!0},S=c.log,f=c.detectBrowser(k),I={browserDetails:f,commonShim:u,extractVersion:c.extractVersion,disableLog:c.disableLog,disableWarnings:c.disableWarnings,sdp:h};switch(f.browser){case"chrome":if(!a||!a.shimPeerConnection||!p.shimChrome)return S("Chrome shim is not included in this adapter release."),I;if(f.version===null)return S("Chrome shim can not determine version, not shimming."),I;S("adapter.js shimming chrome."),I.browserShim=a,u.shimAddIceCandidateNullOrEmpty(k,f),u.shimParameterlessSetLocalDescription(k,f),a.shimGetUserMedia(k,f),a.shimMediaStream(k,f),a.shimPeerConnection(k,f),a.shimOnTrack(k,f),a.shimAddTrackRemoveTrack(k,f),a.shimGetSendersWithDtmf(k,f),a.shimGetStats(k,f),a.shimSenderReceiverGetStats(k,f),a.fixNegotiationNeeded(k,f),u.shimRTCIceCandidate(k,f),u.shimRTCIceCandidateRelayProtocol(k,f),u.shimConnectionState(k,f),u.shimMaxMessageSize(k,f),u.shimSendThrowTypeError(k,f),u.removeExtmapAllowMixed(k,f);break;case"firefox":if(!s||!s.shimPeerConnection||!p.shimFirefox)return S("Firefox shim is not included in this adapter release."),I;S("adapter.js shimming firefox."),I.browserShim=s,u.shimAddIceCandidateNullOrEmpty(k,f),u.shimParameterlessSetLocalDescription(k,f),s.shimGetUserMedia(k,f),s.shimPeerConnection(k,f),s.shimOnTrack(k,f),s.shimRemoveStream(k,f),s.shimSenderGetStats(k,f),s.shimReceiverGetStats(k,f),s.shimRTCDataChannel(k,f),s.shimAddTransceiver(k,f),s.shimGetParameters(k,f),s.shimCreateOffer(k,f),s.shimCreateAnswer(k,f),u.shimRTCIceCandidate(k,f),u.shimConnectionState(k,f),u.shimMaxMessageSize(k,f),u.shimSendThrowTypeError(k,f);break;case"safari":if(!l||!p.shimSafari)return S("Safari shim is not included in this adapter release."),I;S("adapter.js shimming safari."),I.browserShim=l,u.shimAddIceCandidateNullOrEmpty(k,f),u.shimParameterlessSetLocalDescription(k,f),l.shimRTCIceServerUrls(k,f),l.shimCreateOfferLegacy(k,f),l.shimCallbacksAPI(k,f),l.shimLocalStreamsAPI(k,f),l.shimRemoteStreamsAPI(k,f),l.shimTrackEventTransceiver(k,f),l.shimGetUserMedia(k,f),l.shimAudioContext(k,f),u.shimRTCIceCandidate(k,f),u.shimRTCIceCandidateRelayProtocol(k,f),u.shimMaxMessageSize(k,f),u.shimSendThrowTypeError(k,f),u.removeExtmapAllowMixed(k,f);break;default:S("Unsupported browser!")}return I}},{"./chrome/chrome_shim":3,"./common_shim":6,"./firefox/firefox_shim":7,"./safari/safari_shim":10,"./utils":11,sdp:12}],3:[function(n,i,r){Object.defineProperty(r,"__esModule",{value:!0}),r.fixNegotiationNeeded=D,r.shimAddTrackRemoveTrack=A,r.shimAddTrackRemoveTrackWithNative=I,Object.defineProperty(r,"shimGetDisplayMedia",{enumerable:!0,get:function(){return a.shimGetDisplayMedia}}),r.shimGetSendersWithDtmf=p,r.shimGetStats=S,Object.defineProperty(r,"shimGetUserMedia",{enumerable:!0,get:function(){return c.shimGetUserMedia}}),r.shimMediaStream=T,r.shimOnTrack=k,r.shimPeerConnection=x,r.shimSenderReceiverGetStats=f;var o=l(n("../utils.js")),c=n("./getusermedia"),a=n("./getdisplaymedia");function s(m){if(typeof WeakMap!="function")return null;var v=new WeakMap,w=new WeakMap;return(s=function(R){return R?w:v})(m)}function l(m,v){if(m&&m.__esModule)return m;if(m===null||b(m)!=="object"&&typeof m!="function")return{default:m};var w=s(v);if(w&&w.has(m))return w.get(m);var R={},P=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var y in m)if(y!=="default"&&Object.prototype.hasOwnProperty.call(m,y)){var d=P?Object.getOwnPropertyDescriptor(m,y):null;d&&(d.get||d.set)?Object.defineProperty(R,y,d):R[y]=m[y]}return R.default=m,w&&w.set(m,R),R}function u(m,v,w){return(v=h(v))in m?Object.defineProperty(m,v,{value:w,enumerable:!0,configurable:!0,writable:!0}):m[v]=w,m}function h(m){var v=g(m,"string");return b(v)==="symbol"?v:String(v)}function g(m,v){if(b(m)!=="object"||m===null)return m;var w=m[Symbol.toPrimitive];if(w!==void 0){var R=w.call(m,v);if(b(R)!=="object")return R;throw new TypeError("@@toPrimitive must return a primitive value.")}return(v==="string"?String:Number)(m)}function b(m){return b=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(v){return typeof v}:function(v){return v&&typeof Symbol=="function"&&v.constructor===Symbol&&v!==Symbol.prototype?"symbol":typeof v},b(m)}function T(m){m.MediaStream=m.MediaStream||m.webkitMediaStream}function k(m){if(b(m)==="object"&&m.RTCPeerConnection&&!("ontrack"in m.RTCPeerConnection.prototype)){Object.defineProperty(m.RTCPeerConnection.prototype,"ontrack",{get:function(){return this._ontrack},set:function(w){this._ontrack&&this.removeEventListener("track",this._ontrack),this.addEventListener("track",this._ontrack=w)},enumerable:!0,configurable:!0});var v=m.RTCPeerConnection.prototype.setRemoteDescription;m.RTCPeerConnection.prototype.setRemoteDescription=function(){var w=this;return this._ontrackpoly||(this._ontrackpoly=function(R){R.stream.addEventListener("addtrack",function(P){var y;y=m.RTCPeerConnection.prototype.getReceivers?w.getReceivers().find(function(_){return _.track&&_.track.id===P.track.id}):{track:P.track};var d=new Event("track");d.track=P.track,d.receiver=y,d.transceiver={receiver:y},d.streams=[R.stream],w.dispatchEvent(d)}),R.stream.getTracks().forEach(function(P){var y;y=m.RTCPeerConnection.prototype.getReceivers?w.getReceivers().find(function(_){return _.track&&_.track.id===P.id}):{track:P};var d=new Event("track");d.track=P,d.receiver=y,d.transceiver={receiver:y},d.streams=[R.stream],w.dispatchEvent(d)})},this.addEventListener("addstream",this._ontrackpoly)),v.apply(this,arguments)}}else o.wrapPeerConnectionEvent(m,"track",function(w){return w.transceiver||Object.defineProperty(w,"transceiver",{value:{receiver:w.receiver}}),w})}function p(m){if(b(m)==="object"&&m.RTCPeerConnection&&!("getSenders"in m.RTCPeerConnection.prototype)&&"createDTMFSender"in m.RTCPeerConnection.prototype){var v=function(_,E){return{track:E,get dtmf(){return this._dtmf===void 0&&(E.kind==="audio"?this._dtmf=_.createDTMFSender(E):this._dtmf=null),this._dtmf},_pc:_}};if(!m.RTCPeerConnection.prototype.getSenders){m.RTCPeerConnection.prototype.getSenders=function(){return this._senders=this._senders||[],this._senders.slice()};var w=m.RTCPeerConnection.prototype.addTrack;m.RTCPeerConnection.prototype.addTrack=function(_,E){var C=w.apply(this,arguments);return C||(C=v(this,_),this._senders.push(C)),C};var R=m.RTCPeerConnection.prototype.removeTrack;m.RTCPeerConnection.prototype.removeTrack=function(_){R.apply(this,arguments);var E=this._senders.indexOf(_);E!==-1&&this._senders.splice(E,1)}}var P=m.RTCPeerConnection.prototype.addStream;m.RTCPeerConnection.prototype.addStream=function(_){var E=this;this._senders=this._senders||[],P.apply(this,[_]),_.getTracks().forEach(function(C){E._senders.push(v(E,C))})};var y=m.RTCPeerConnection.prototype.removeStream;m.RTCPeerConnection.prototype.removeStream=function(_){var E=this;this._senders=this._senders||[],y.apply(this,[_]),_.getTracks().forEach(function(C){var O=E._senders.find(function(L){return L.track===C});O&&E._senders.splice(E._senders.indexOf(O),1)})}}else if(b(m)==="object"&&m.RTCPeerConnection&&"getSenders"in m.RTCPeerConnection.prototype&&"createDTMFSender"in m.RTCPeerConnection.prototype&&m.RTCRtpSender&&!("dtmf"in m.RTCRtpSender.prototype)){var d=m.RTCPeerConnection.prototype.getSenders;m.RTCPeerConnection.prototype.getSenders=function(){var _=this,E=d.apply(this,[]);return E.forEach(function(C){return C._pc=_}),E},Object.defineProperty(m.RTCRtpSender.prototype,"dtmf",{get:function(){return this._dtmf===void 0&&(this.track.kind==="audio"?this._dtmf=this._pc.createDTMFSender(this.track):this._dtmf=null),this._dtmf}})}}function S(m){if(m.RTCPeerConnection){var v=m.RTCPeerConnection.prototype.getStats;m.RTCPeerConnection.prototype.getStats=function(){var w=this,R=Array.prototype.slice.call(arguments),P=R[0],y=R[1],d=R[2];if(arguments.length>0&&typeof P=="function")return v.apply(this,arguments);if(v.length===0&&(arguments.length===0||typeof P!="function"))return v.apply(this,[]);var _=function(O){var L={};return O.result().forEach(function(N){var W={id:N.id,timestamp:N.timestamp,type:{localcandidate:"local-candidate",remotecandidate:"remote-candidate"}[N.type]||N.type};N.names().forEach(function(B){W[B]=N.stat(B)}),L[W.id]=W}),L},E=function(O){return new Map(Object.keys(O).map(function(L){return[L,O[L]]}))};if(arguments.length>=2){var C=function(O){y(E(_(O)))};return v.apply(this,[C,P])}return new Promise(function(O,L){v.apply(w,[function(N){O(E(_(N)))},L])}).then(y,d)}}}function f(m){if(b(m)==="object"&&m.RTCPeerConnection&&m.RTCRtpSender&&m.RTCRtpReceiver){if(!("getStats"in m.RTCRtpSender.prototype)){var v=m.RTCPeerConnection.prototype.getSenders;v&&(m.RTCPeerConnection.prototype.getSenders=function(){var y=this,d=v.apply(this,[]);return d.forEach(function(_){return _._pc=y}),d});var w=m.RTCPeerConnection.prototype.addTrack;w&&(m.RTCPeerConnection.prototype.addTrack=function(){var y=w.apply(this,arguments);return y._pc=this,y}),m.RTCRtpSender.prototype.getStats=function(){var y=this;return this._pc.getStats().then(function(d){return o.filterStats(d,y.track,!0)})}}if(!("getStats"in m.RTCRtpReceiver.prototype)){var R=m.RTCPeerConnection.prototype.getReceivers;R&&(m.RTCPeerConnection.prototype.getReceivers=function(){var y=this,d=R.apply(this,[]);return d.forEach(function(_){return _._pc=y}),d}),o.wrapPeerConnectionEvent(m,"track",function(y){return y.receiver._pc=y.srcElement,y}),m.RTCRtpReceiver.prototype.getStats=function(){var y=this;return this._pc.getStats().then(function(d){return o.filterStats(d,y.track,!1)})}}if("getStats"in m.RTCRtpSender.prototype&&"getStats"in m.RTCRtpReceiver.prototype){var P=m.RTCPeerConnection.prototype.getStats;m.RTCPeerConnection.prototype.getStats=function(){if(arguments.length>0&&arguments[0]instanceof m.MediaStreamTrack){var y,d,_,E=arguments[0];return this.getSenders().forEach(function(C){C.track===E&&(y?_=!0:y=C)}),this.getReceivers().forEach(function(C){return C.track===E&&(d?_=!0:d=C),C.track===E}),_||y&&d?Promise.reject(new DOMException("There are more than one sender or receiver for the track.","InvalidAccessError")):y?y.getStats():d?d.getStats():Promise.reject(new DOMException("There is no sender or receiver for the track.","InvalidAccessError"))}return P.apply(this,arguments)}}}}function I(m){m.RTCPeerConnection.prototype.getLocalStreams=function(){var y=this;return this._shimmedLocalStreams=this._shimmedLocalStreams||{},Object.keys(this._shimmedLocalStreams).map(function(d){return y._shimmedLocalStreams[d][0]})};var v=m.RTCPeerConnection.prototype.addTrack;m.RTCPeerConnection.prototype.addTrack=function(y,d){if(!d)return v.apply(this,arguments);this._shimmedLocalStreams=this._shimmedLocalStreams||{};var _=v.apply(this,arguments);return this._shimmedLocalStreams[d.id]?this._shimmedLocalStreams[d.id].indexOf(_)===-1&&this._shimmedLocalStreams[d.id].push(_):this._shimmedLocalStreams[d.id]=[d,_],_};var w=m.RTCPeerConnection.prototype.addStream;m.RTCPeerConnection.prototype.addStream=function(y){var d=this;this._shimmedLocalStreams=this._shimmedLocalStreams||{},y.getTracks().forEach(function(C){if(d.getSenders().find(function(O){return O.track===C}))throw new DOMException("Track already exists.","InvalidAccessError")});var _=this.getSenders();w.apply(this,arguments);var E=this.getSenders().filter(function(C){return _.indexOf(C)===-1});this._shimmedLocalStreams[y.id]=[y].concat(E)};var R=m.RTCPeerConnection.prototype.removeStream;m.RTCPeerConnection.prototype.removeStream=function(y){return this._shimmedLocalStreams=this._shimmedLocalStreams||{},delete this._shimmedLocalStreams[y.id],R.apply(this,arguments)};var P=m.RTCPeerConnection.prototype.removeTrack;m.RTCPeerConnection.prototype.removeTrack=function(y){var d=this;return this._shimmedLocalStreams=this._shimmedLocalStreams||{},y&&Object.keys(this._shimmedLocalStreams).forEach(function(_){var E=d._shimmedLocalStreams[_].indexOf(y);E!==-1&&d._shimmedLocalStreams[_].splice(E,1),d._shimmedLocalStreams[_].length===1&&delete d._shimmedLocalStreams[_]}),P.apply(this,arguments)}}function A(m,v){if(m.RTCPeerConnection){if(m.RTCPeerConnection.prototype.addTrack&&v.version>=65)return I(m);var w=m.RTCPeerConnection.prototype.getLocalStreams;m.RTCPeerConnection.prototype.getLocalStreams=function(){var C=this,O=w.apply(this);return this._reverseStreams=this._reverseStreams||{},O.map(function(L){return C._reverseStreams[L.id]})};var R=m.RTCPeerConnection.prototype.addStream;m.RTCPeerConnection.prototype.addStream=function(C){var O=this;if(this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{},C.getTracks().forEach(function(N){if(O.getSenders().find(function(W){return W.track===N}))throw new DOMException("Track already exists.","InvalidAccessError")}),!this._reverseStreams[C.id]){var L=new m.MediaStream(C.getTracks());this._streams[C.id]=L,this._reverseStreams[L.id]=C,C=L}R.apply(this,[C])};var P=m.RTCPeerConnection.prototype.removeStream;m.RTCPeerConnection.prototype.removeStream=function(C){this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{},P.apply(this,[this._streams[C.id]||C]),delete this._reverseStreams[this._streams[C.id]?this._streams[C.id].id:C.id],delete this._streams[C.id]},m.RTCPeerConnection.prototype.addTrack=function(C,O){var L=this;if(this.signalingState==="closed")throw new DOMException("The RTCPeerConnection's signalingState is 'closed'.","InvalidStateError");var N=[].slice.call(arguments,1);if(N.length!==1||!N[0].getTracks().find(function(se){return se===C}))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(function(se){return se.track===C}))throw new DOMException("Track already exists.","InvalidAccessError");this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{};var W=this._streams[O.id];if(W)W.addTrack(C),Promise.resolve().then(function(){L.dispatchEvent(new Event("negotiationneeded"))});else{var B=new m.MediaStream([C]);this._streams[O.id]=B,this._reverseStreams[B.id]=O,this.addStream(B)}return this.getSenders().find(function(se){return se.track===C})},["createOffer","createAnswer"].forEach(function(C){var O=m.RTCPeerConnection.prototype[C],L=u({},C,function(){var N=this,W=arguments;return arguments.length&&typeof arguments[0]=="function"?O.apply(this,[function(B){var se=_(N,B);W[0].apply(null,[se])},function(B){W[1]&&W[1].apply(null,B)},arguments[2]]):O.apply(this,arguments).then(function(B){return _(N,B)})});m.RTCPeerConnection.prototype[C]=L[C]});var y=m.RTCPeerConnection.prototype.setLocalDescription;m.RTCPeerConnection.prototype.setLocalDescription=function(){return arguments.length&&arguments[0].type?(arguments[0]=E(this,arguments[0]),y.apply(this,arguments)):y.apply(this,arguments)};var d=Object.getOwnPropertyDescriptor(m.RTCPeerConnection.prototype,"localDescription");Object.defineProperty(m.RTCPeerConnection.prototype,"localDescription",{get:function(){var C=d.get.apply(this);return C.type===""?C:_(this,C)}}),m.RTCPeerConnection.prototype.removeTrack=function(C){var O,L=this;if(this.signalingState==="closed")throw new DOMException("The RTCPeerConnection's signalingState is 'closed'.","InvalidStateError");if(!C._pc)throw new DOMException("Argument 1 of RTCPeerConnection.removeTrack does not implement interface RTCRtpSender.","TypeError");if(C._pc!==this)throw new DOMException("Sender was not created by this connection.","InvalidAccessError");this._streams=this._streams||{},Object.keys(this._streams).forEach(function(N){L._streams[N].getTracks().find(function(W){return C.track===W})&&(O=L._streams[N])}),O&&(O.getTracks().length===1?this.removeStream(this._reverseStreams[O.id]):O.removeTrack(C.track),this.dispatchEvent(new Event("negotiationneeded")))}}function _(C,O){var L=O.sdp;return Object.keys(C._reverseStreams||[]).forEach(function(N){var W=C._reverseStreams[N],B=C._streams[W.id];L=L.replace(new RegExp(B.id,"g"),W.id)}),new RTCSessionDescription({type:O.type,sdp:L})}function E(C,O){var L=O.sdp;return Object.keys(C._reverseStreams||[]).forEach(function(N){var W=C._reverseStreams[N],B=C._streams[W.id];L=L.replace(new RegExp(W.id,"g"),B.id)}),new RTCSessionDescription({type:O.type,sdp:L})}}function x(m,v){!m.RTCPeerConnection&&m.webkitRTCPeerConnection&&(m.RTCPeerConnection=m.webkitRTCPeerConnection),m.RTCPeerConnection&&v.version<53&&["setLocalDescription","setRemoteDescription","addIceCandidate"].forEach(function(w){var R=m.RTCPeerConnection.prototype[w],P=u({},w,function(){return arguments[0]=new(w==="addIceCandidate"?m.RTCIceCandidate:m.RTCSessionDescription)(arguments[0]),R.apply(this,arguments)});m.RTCPeerConnection.prototype[w]=P[w]})}function D(m,v){o.wrapPeerConnectionEvent(m,"negotiationneeded",function(w){var R=w.target;if(!(v.version<72||R.getConfiguration&&R.getConfiguration().sdpSemantics==="plan-b")||R.signalingState==="stable")return w})}},{"../utils.js":11,"./getdisplaymedia":4,"./getusermedia":5}],4:[function(n,i,r){function o(c,a){c.navigator.mediaDevices&&"getDisplayMedia"in c.navigator.mediaDevices||c.navigator.mediaDevices&&(typeof a=="function"?c.navigator.mediaDevices.getDisplayMedia=function(s){return a(s).then(function(l){var u=s.video&&s.video.width,h=s.video&&s.video.height,g=s.video&&s.video.frameRate;return s.video={mandatory:{chromeMediaSource:"desktop",chromeMediaSourceId:l,maxFrameRate:g||3}},u&&(s.video.mandatory.maxWidth=u),h&&(s.video.mandatory.maxHeight=h),c.navigator.mediaDevices.getUserMedia(s)})}:console.error("shimGetDisplayMedia: getSourceId argument is not a function"))}Object.defineProperty(r,"__esModule",{value:!0}),r.shimGetDisplayMedia=o},{}],5:[function(n,i,r){function o(u){if(typeof WeakMap!="function")return null;var h=new WeakMap,g=new WeakMap;return(o=function(b){return b?g:h})(u)}function c(u,h){if(u&&u.__esModule)return u;if(u===null||a(u)!=="object"&&typeof u!="function")return{default:u};var g=o(h);if(g&&g.has(u))return g.get(u);var b={},T=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var k in u)if(k!=="default"&&Object.prototype.hasOwnProperty.call(u,k)){var p=T?Object.getOwnPropertyDescriptor(u,k):null;p&&(p.get||p.set)?Object.defineProperty(b,k,p):b[k]=u[k]}return b.default=u,g&&g.set(u,b),b}function a(u){return a=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(h){return typeof h}:function(h){return h&&typeof Symbol=="function"&&h.constructor===Symbol&&h!==Symbol.prototype?"symbol":typeof h},a(u)}Object.defineProperty(r,"__esModule",{value:!0}),r.shimGetUserMedia=l;var s=c(n("../utils.js")).log;function l(u,h){var g=u&&u.navigator;if(g.mediaDevices){var b=function(f){if(a(f)!=="object"||f.mandatory||f.optional)return f;var I={};return Object.keys(f).forEach(function(A){if(A!=="require"&&A!=="advanced"&&A!=="mediaSource"){var x=a(f[A])==="object"?f[A]:{ideal:f[A]};x.exact!==void 0&&typeof x.exact=="number"&&(x.min=x.max=x.exact);var D=function(v,w){return v?v+w.charAt(0).toUpperCase()+w.slice(1):w==="deviceId"?"sourceId":w};if(x.ideal!==void 0){I.optional=I.optional||[];var m={};typeof x.ideal=="number"?(m[D("min",A)]=x.ideal,I.optional.push(m),(m={})[D("max",A)]=x.ideal,I.optional.push(m)):(m[D("",A)]=x.ideal,I.optional.push(m))}x.exact!==void 0&&typeof x.exact!="number"?(I.mandatory=I.mandatory||{},I.mandatory[D("",A)]=x.exact):["min","max"].forEach(function(v){x[v]!==void 0&&(I.mandatory=I.mandatory||{},I.mandatory[D(v,A)]=x[v])})}}),f.advanced&&(I.optional=(I.optional||[]).concat(f.advanced)),I},T=function(f,I){if(h.version>=61)return I(f);if((f=JSON.parse(JSON.stringify(f)))&&a(f.audio)==="object"){var A=function(v,w,R){w in v&&!(R in v)&&(v[R]=v[w],delete v[w])};A((f=JSON.parse(JSON.stringify(f))).audio,"autoGainControl","googAutoGainControl"),A(f.audio,"noiseSuppression","googNoiseSuppression"),f.audio=b(f.audio)}if(f&&a(f.video)==="object"){var x=f.video.facingMode;x=x&&(a(x)==="object"?x:{ideal:x});var D,m=h.version<66;if(x&&(x.exact==="user"||x.exact==="environment"||x.ideal==="user"||x.ideal==="environment")&&(!g.mediaDevices.getSupportedConstraints||!g.mediaDevices.getSupportedConstraints().facingMode||m)&&(delete f.video.facingMode,x.exact==="environment"||x.ideal==="environment"?D=["back","rear"]:x.exact!=="user"&&x.ideal!=="user"||(D=["front"]),D))return g.mediaDevices.enumerateDevices().then(function(v){var w=(v=v.filter(function(R){return R.kind==="videoinput"})).find(function(R){return D.some(function(P){return R.label.toLowerCase().includes(P)})});return!w&&v.length&&D.includes("back")&&(w=v[v.length-1]),w&&(f.video.deviceId=x.exact?{exact:w.deviceId}:{ideal:w.deviceId}),f.video=b(f.video),s("chrome: "+JSON.stringify(f)),I(f)});f.video=b(f.video)}return s("chrome: "+JSON.stringify(f)),I(f)},k=function(f){return h.version>=64?f:{name:{PermissionDeniedError:"NotAllowedError",PermissionDismissedError:"NotAllowedError",InvalidStateError:"NotAllowedError",DevicesNotFoundError:"NotFoundError",ConstraintNotSatisfiedError:"OverconstrainedError",TrackStartError:"NotReadableError",MediaDeviceFailedDueToShutdown:"NotAllowedError",MediaDeviceKillSwitchOn:"NotAllowedError",TabCaptureError:"AbortError",ScreenCaptureError:"AbortError",DeviceCaptureError:"AbortError"}[f.name]||f.name,message:f.message,constraint:f.constraint||f.constraintName,toString:function(){return this.name+(this.message&&": ")+this.message}}},p=function(f,I,A){T(f,function(x){g.webkitGetUserMedia(x,I,function(D){A&&A(k(D))})})};if(g.getUserMedia=p.bind(g),g.mediaDevices.getUserMedia){var S=g.mediaDevices.getUserMedia.bind(g.mediaDevices);g.mediaDevices.getUserMedia=function(f){return T(f,function(I){return S(I).then(function(A){if(I.audio&&!A.getAudioTracks().length||I.video&&!A.getVideoTracks().length)throw A.getTracks().forEach(function(x){x.stop()}),new DOMException("","NotFoundError");return A},function(A){return Promise.reject(k(A))})})}}}}},{"../utils.js":11}],6:[function(n,i,r){Object.defineProperty(r,"__esModule",{value:!0}),r.removeExtmapAllowMixed=p,r.shimAddIceCandidateNullOrEmpty=S,r.shimConnectionState=k,r.shimMaxMessageSize=b,r.shimParameterlessSetLocalDescription=f,r.shimRTCIceCandidate=h,r.shimRTCIceCandidateRelayProtocol=g,r.shimSendThrowTypeError=T;var o=l(n("sdp")),c=s(n("./utils"));function a(I){if(typeof WeakMap!="function")return null;var A=new WeakMap,x=new WeakMap;return(a=function(D){return D?x:A})(I)}function s(I,A){if(I&&I.__esModule)return I;if(I===null||u(I)!=="object"&&typeof I!="function")return{default:I};var x=a(A);if(x&&x.has(I))return x.get(I);var D={},m=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var v in I)if(v!=="default"&&Object.prototype.hasOwnProperty.call(I,v)){var w=m?Object.getOwnPropertyDescriptor(I,v):null;w&&(w.get||w.set)?Object.defineProperty(D,v,w):D[v]=I[v]}return D.default=I,x&&x.set(I,D),D}function l(I){return I&&I.__esModule?I:{default:I}}function u(I){return u=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(A){return typeof A}:function(A){return A&&typeof Symbol=="function"&&A.constructor===Symbol&&A!==Symbol.prototype?"symbol":typeof A},u(I)}function h(I){if(!(!I.RTCIceCandidate||I.RTCIceCandidate&&"foundation"in I.RTCIceCandidate.prototype)){var A=I.RTCIceCandidate;I.RTCIceCandidate=function(x){if(u(x)==="object"&&x.candidate&&x.candidate.indexOf("a=")===0&&((x=JSON.parse(JSON.stringify(x))).candidate=x.candidate.substring(2)),x.candidate&&x.candidate.length){var D=new A(x),m=o.default.parseCandidate(x.candidate);for(var v in m)v in D||Object.defineProperty(D,v,{value:m[v]});return D.toJSON=function(){return{candidate:D.candidate,sdpMid:D.sdpMid,sdpMLineIndex:D.sdpMLineIndex,usernameFragment:D.usernameFragment}},D}return new A(x)},I.RTCIceCandidate.prototype=A.prototype,c.wrapPeerConnectionEvent(I,"icecandidate",function(x){return x.candidate&&Object.defineProperty(x,"candidate",{value:new I.RTCIceCandidate(x.candidate),writable:"false"}),x})}}function g(I){!I.RTCIceCandidate||I.RTCIceCandidate&&"relayProtocol"in I.RTCIceCandidate.prototype||c.wrapPeerConnectionEvent(I,"icecandidate",function(A){if(A.candidate){var x=o.default.parseCandidate(A.candidate.candidate);x.type==="relay"&&(A.candidate.relayProtocol={0:"tls",1:"tcp",2:"udp"}[x.priority>>24])}return A})}function b(I,A){if(I.RTCPeerConnection){"sctp"in I.RTCPeerConnection.prototype||Object.defineProperty(I.RTCPeerConnection.prototype,"sctp",{get:function(){return this._sctp===void 0?null:this._sctp}});var x=function(R){if(!R||!R.sdp)return!1;var P=o.default.splitSections(R.sdp);return P.shift(),P.some(function(y){var d=o.default.parseMLine(y);return d&&d.kind==="application"&&d.protocol.indexOf("SCTP")!==-1})},D=function(R){var P=R.sdp.match(/mozilla...THIS_IS_SDPARTA-(\d+)/);if(P===null||P.length<2)return-1;var y=parseInt(P[1],10);return y!=y?-1:y},m=function(R){var P=65536;return A.browser==="firefox"&&(P=A.version<57?R===-1?16384:2147483637:A.version<60?A.version===57?65535:65536:2147483637),P},v=function(R,P){var y=65536;A.browser==="firefox"&&A.version===57&&(y=65535);var d=o.default.matchPrefix(R.sdp,"a=max-message-size:");return d.length>0?y=parseInt(d[0].substring(19),10):A.browser==="firefox"&&P!==-1&&(y=2147483637),y},w=I.RTCPeerConnection.prototype.setRemoteDescription;I.RTCPeerConnection.prototype.setRemoteDescription=function(){if(this._sctp=null,A.browser==="chrome"&&A.version>=76&&this.getConfiguration().sdpSemantics==="plan-b"&&Object.defineProperty(this,"sctp",{get:function(){return this._sctp===void 0?null:this._sctp},enumerable:!0,configurable:!0}),x(arguments[0])){var R,P=D(arguments[0]),y=m(P),d=v(arguments[0],P);R=y===0&&d===0?Number.POSITIVE_INFINITY:y===0||d===0?Math.max(y,d):Math.min(y,d);var _={};Object.defineProperty(_,"maxMessageSize",{get:function(){return R}}),this._sctp=_}return w.apply(this,arguments)}}}function T(I){if(I.RTCPeerConnection&&"createDataChannel"in I.RTCPeerConnection.prototype){var A=I.RTCPeerConnection.prototype.createDataChannel;I.RTCPeerConnection.prototype.createDataChannel=function(){var D=A.apply(this,arguments);return x(D,this),D},c.wrapPeerConnectionEvent(I,"datachannel",function(D){return x(D.channel,D.target),D})}function x(D,m){var v=D.send;D.send=function(){var w=arguments[0],R=w.length||w.size||w.byteLength;if(D.readyState==="open"&&m.sctp&&R>m.sctp.maxMessageSize)throw new TypeError("Message too large (can send a maximum of "+m.sctp.maxMessageSize+" bytes)");return v.apply(D,arguments)}}}function k(I){if(I.RTCPeerConnection&&!("connectionState"in I.RTCPeerConnection.prototype)){var A=I.RTCPeerConnection.prototype;Object.defineProperty(A,"connectionState",{get:function(){return{completed:"connected",checking:"connecting"}[this.iceConnectionState]||this.iceConnectionState},enumerable:!0,configurable:!0}),Object.defineProperty(A,"onconnectionstatechange",{get:function(){return this._onconnectionstatechange||null},set:function(x){this._onconnectionstatechange&&(this.removeEventListener("connectionstatechange",this._onconnectionstatechange),delete this._onconnectionstatechange),x&&this.addEventListener("connectionstatechange",this._onconnectionstatechange=x)},enumerable:!0,configurable:!0}),["setLocalDescription","setRemoteDescription"].forEach(function(x){var D=A[x];A[x]=function(){return this._connectionstatechangepoly||(this._connectionstatechangepoly=function(m){var v=m.target;if(v._lastConnectionState!==v.connectionState){v._lastConnectionState=v.connectionState;var w=new Event("connectionstatechange",m);v.dispatchEvent(w)}return m},this.addEventListener("iceconnectionstatechange",this._connectionstatechangepoly)),D.apply(this,arguments)}})}}function p(I,A){if(I.RTCPeerConnection&&!(A.browser==="chrome"&&A.version>=71||A.browser==="safari"&&A.version>=605)){var x=I.RTCPeerConnection.prototype.setRemoteDescription;I.RTCPeerConnection.prototype.setRemoteDescription=function(D){if(D&&D.sdp&&D.sdp.indexOf(`
a=extmap-allow-mixed`)!==-1){var m=D.sdp.split(`
`).filter(function(v){return v.trim()!=="a=extmap-allow-mixed"}).join(`
`);I.RTCSessionDescription&&D instanceof I.RTCSessionDescription?arguments[0]=new I.RTCSessionDescription({type:D.type,sdp:m}):D.sdp=m}return x.apply(this,arguments)}}}function S(I,A){if(I.RTCPeerConnection&&I.RTCPeerConnection.prototype){var x=I.RTCPeerConnection.prototype.addIceCandidate;x&&x.length!==0&&(I.RTCPeerConnection.prototype.addIceCandidate=function(){return arguments[0]?(A.browser==="chrome"&&A.version<78||A.browser==="firefox"&&A.version<68||A.browser==="safari")&&arguments[0]&&arguments[0].candidate===""?Promise.resolve():x.apply(this,arguments):(arguments[1]&&arguments[1].apply(null),Promise.resolve())})}}function f(I,A){if(I.RTCPeerConnection&&I.RTCPeerConnection.prototype){var x=I.RTCPeerConnection.prototype.setLocalDescription;x&&x.length!==0&&(I.RTCPeerConnection.prototype.setLocalDescription=function(){var D=this,m=arguments[0]||{};if(u(m)!=="object"||m.type&&m.sdp)return x.apply(this,arguments);if(!(m={type:m.type,sdp:m.sdp}).type)switch(this.signalingState){case"stable":case"have-local-offer":case"have-remote-pranswer":m.type="offer";break;default:m.type="answer"}return m.sdp||m.type!=="offer"&&m.type!=="answer"?x.apply(this,[m]):(m.type==="offer"?this.createOffer:this.createAnswer).apply(this).then(function(v){return x.apply(D,[v])})})}}},{"./utils":11,sdp:12}],7:[function(n,i,r){Object.defineProperty(r,"__esModule",{value:!0}),r.shimAddTransceiver=R,r.shimCreateAnswer=d,r.shimCreateOffer=y,Object.defineProperty(r,"shimGetDisplayMedia",{enumerable:!0,get:function(){return a.shimGetDisplayMedia}}),r.shimGetParameters=P,Object.defineProperty(r,"shimGetUserMedia",{enumerable:!0,get:function(){return c.shimGetUserMedia}}),r.shimOnTrack=A,r.shimPeerConnection=x,r.shimRTCDataChannel=w,r.shimReceiverGetStats=m,r.shimRemoveStream=v,r.shimSenderGetStats=D;var o=l(n("../utils")),c=n("./getusermedia"),a=n("./getdisplaymedia");function s(_){if(typeof WeakMap!="function")return null;var E=new WeakMap,C=new WeakMap;return(s=function(O){return O?C:E})(_)}function l(_,E){if(_&&_.__esModule)return _;if(_===null||I(_)!=="object"&&typeof _!="function")return{default:_};var C=s(E);if(C&&C.has(_))return C.get(_);var O={},L=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var N in _)if(N!=="default"&&Object.prototype.hasOwnProperty.call(_,N)){var W=L?Object.getOwnPropertyDescriptor(_,N):null;W&&(W.get||W.set)?Object.defineProperty(O,N,W):O[N]=_[N]}return O.default=_,C&&C.set(_,O),O}function u(_){return T(_)||b(_)||g(_)||h()}function h(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function g(_,E){if(_){if(typeof _=="string")return k(_,E);var C=Object.prototype.toString.call(_).slice(8,-1);return C==="Object"&&_.constructor&&(C=_.constructor.name),C==="Map"||C==="Set"?Array.from(_):C==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(C)?k(_,E):void 0}}function b(_){if(typeof Symbol<"u"&&_[Symbol.iterator]!=null||_["@@iterator"]!=null)return Array.from(_)}function T(_){if(Array.isArray(_))return k(_)}function k(_,E){(E==null||E>_.length)&&(E=_.length);for(var C=0,O=new Array(E);C<E;C++)O[C]=_[C];return O}function p(_,E,C){return(E=S(E))in _?Object.defineProperty(_,E,{value:C,enumerable:!0,configurable:!0,writable:!0}):_[E]=C,_}function S(_){var E=f(_,"string");return I(E)==="symbol"?E:String(E)}function f(_,E){if(I(_)!=="object"||_===null)return _;var C=_[Symbol.toPrimitive];if(C!==void 0){var O=C.call(_,E);if(I(O)!=="object")return O;throw new TypeError("@@toPrimitive must return a primitive value.")}return(E==="string"?String:Number)(_)}function I(_){return I=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(E){return typeof E}:function(E){return E&&typeof Symbol=="function"&&E.constructor===Symbol&&E!==Symbol.prototype?"symbol":typeof E},I(_)}function A(_){I(_)==="object"&&_.RTCTrackEvent&&"receiver"in _.RTCTrackEvent.prototype&&!("transceiver"in _.RTCTrackEvent.prototype)&&Object.defineProperty(_.RTCTrackEvent.prototype,"transceiver",{get:function(){return{receiver:this.receiver}}})}function x(_,E){if(I(_)==="object"&&(_.RTCPeerConnection||_.mozRTCPeerConnection)){!_.RTCPeerConnection&&_.mozRTCPeerConnection&&(_.RTCPeerConnection=_.mozRTCPeerConnection),E.version<53&&["setLocalDescription","setRemoteDescription","addIceCandidate"].forEach(function(L){var N=_.RTCPeerConnection.prototype[L],W=p({},L,function(){return arguments[0]=new(L==="addIceCandidate"?_.RTCIceCandidate:_.RTCSessionDescription)(arguments[0]),N.apply(this,arguments)});_.RTCPeerConnection.prototype[L]=W[L]});var C={inboundrtp:"inbound-rtp",outboundrtp:"outbound-rtp",candidatepair:"candidate-pair",localcandidate:"local-candidate",remotecandidate:"remote-candidate"},O=_.RTCPeerConnection.prototype.getStats;_.RTCPeerConnection.prototype.getStats=function(){var L=Array.prototype.slice.call(arguments),N=L[0],W=L[1],B=L[2];return O.apply(this,[N||null]).then(function(se){if(E.version<53&&!W)try{se.forEach(function(ee){ee.type=C[ee.type]||ee.type})}catch(ee){if(ee.name!=="TypeError")throw ee;se.forEach(function(ne,_e){se.set(_e,Object.assign({},ne,{type:C[ne.type]||ne.type}))})}return se}).then(W,B)}}}function D(_){if(I(_)==="object"&&_.RTCPeerConnection&&_.RTCRtpSender&&(!_.RTCRtpSender||!("getStats"in _.RTCRtpSender.prototype))){var E=_.RTCPeerConnection.prototype.getSenders;E&&(_.RTCPeerConnection.prototype.getSenders=function(){var O=this,L=E.apply(this,[]);return L.forEach(function(N){return N._pc=O}),L});var C=_.RTCPeerConnection.prototype.addTrack;C&&(_.RTCPeerConnection.prototype.addTrack=function(){var O=C.apply(this,arguments);return O._pc=this,O}),_.RTCRtpSender.prototype.getStats=function(){return this.track?this._pc.getStats(this.track):Promise.resolve(new Map)}}}function m(_){if(I(_)==="object"&&_.RTCPeerConnection&&_.RTCRtpSender&&(!_.RTCRtpSender||!("getStats"in _.RTCRtpReceiver.prototype))){var E=_.RTCPeerConnection.prototype.getReceivers;E&&(_.RTCPeerConnection.prototype.getReceivers=function(){var C=this,O=E.apply(this,[]);return O.forEach(function(L){return L._pc=C}),O}),o.wrapPeerConnectionEvent(_,"track",function(C){return C.receiver._pc=C.srcElement,C}),_.RTCRtpReceiver.prototype.getStats=function(){return this._pc.getStats(this.track)}}}function v(_){_.RTCPeerConnection&&!("removeStream"in _.RTCPeerConnection.prototype)&&(_.RTCPeerConnection.prototype.removeStream=function(E){var C=this;o.deprecated("removeStream","removeTrack"),this.getSenders().forEach(function(O){O.track&&E.getTracks().includes(O.track)&&C.removeTrack(O)})})}function w(_){_.DataChannel&&!_.RTCDataChannel&&(_.RTCDataChannel=_.DataChannel)}function R(_){if(I(_)==="object"&&_.RTCPeerConnection){var E=_.RTCPeerConnection.prototype.addTransceiver;E&&(_.RTCPeerConnection.prototype.addTransceiver=function(){this.setParametersPromises=[];var C=arguments[1]&&arguments[1].sendEncodings;C===void 0&&(C=[]);var O=(C=u(C)).length>0;O&&C.forEach(function(B){if("rid"in B&&!/^[a-z0-9]{0,16}$/i.test(B.rid))throw new TypeError("Invalid RID value provided.");if("scaleResolutionDownBy"in B&&!(parseFloat(B.scaleResolutionDownBy)>=1))throw new RangeError("scale_resolution_down_by must be >= 1.0");if("maxFramerate"in B&&!(parseFloat(B.maxFramerate)>=0))throw new RangeError("max_framerate must be >= 0.0")});var L=E.apply(this,arguments);if(O){var N=L.sender,W=N.getParameters();(!("encodings"in W)||W.encodings.length===1&&Object.keys(W.encodings[0]).length===0)&&(W.encodings=C,N.sendEncodings=C,this.setParametersPromises.push(N.setParameters(W).then(function(){delete N.sendEncodings}).catch(function(){delete N.sendEncodings})))}return L})}}function P(_){if(I(_)==="object"&&_.RTCRtpSender){var E=_.RTCRtpSender.prototype.getParameters;E&&(_.RTCRtpSender.prototype.getParameters=function(){var C=E.apply(this,arguments);return"encodings"in C||(C.encodings=[].concat(this.sendEncodings||[{}])),C})}}function y(_){if(I(_)==="object"&&_.RTCPeerConnection){var E=_.RTCPeerConnection.prototype.createOffer;_.RTCPeerConnection.prototype.createOffer=function(){var C=arguments,O=this;return this.setParametersPromises&&this.setParametersPromises.length?Promise.all(this.setParametersPromises).then(function(){return E.apply(O,C)}).finally(function(){O.setParametersPromises=[]}):E.apply(this,arguments)}}}function d(_){if(I(_)==="object"&&_.RTCPeerConnection){var E=_.RTCPeerConnection.prototype.createAnswer;_.RTCPeerConnection.prototype.createAnswer=function(){var C=arguments,O=this;return this.setParametersPromises&&this.setParametersPromises.length?Promise.all(this.setParametersPromises).then(function(){return E.apply(O,C)}).finally(function(){O.setParametersPromises=[]}):E.apply(this,arguments)}}}},{"../utils":11,"./getdisplaymedia":8,"./getusermedia":9}],8:[function(n,i,r){function o(c,a){c.navigator.mediaDevices&&"getDisplayMedia"in c.navigator.mediaDevices||c.navigator.mediaDevices&&(c.navigator.mediaDevices.getDisplayMedia=function(s){if(!s||!s.video){var l=new DOMException("getDisplayMedia without video constraints is undefined");return l.name="NotFoundError",l.code=8,Promise.reject(l)}return s.video===!0?s.video={mediaSource:a}:s.video.mediaSource=a,c.navigator.mediaDevices.getUserMedia(s)})}Object.defineProperty(r,"__esModule",{value:!0}),r.shimGetDisplayMedia=o},{}],9:[function(n,i,r){Object.defineProperty(r,"__esModule",{value:!0}),r.shimGetUserMedia=l;var o=a(n("../utils"));function c(u){if(typeof WeakMap!="function")return null;var h=new WeakMap,g=new WeakMap;return(c=function(b){return b?g:h})(u)}function a(u,h){if(u&&u.__esModule)return u;if(u===null||s(u)!=="object"&&typeof u!="function")return{default:u};var g=c(h);if(g&&g.has(u))return g.get(u);var b={},T=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var k in u)if(k!=="default"&&Object.prototype.hasOwnProperty.call(u,k)){var p=T?Object.getOwnPropertyDescriptor(u,k):null;p&&(p.get||p.set)?Object.defineProperty(b,k,p):b[k]=u[k]}return b.default=u,g&&g.set(u,b),b}function s(u){return s=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(h){return typeof h}:function(h){return h&&typeof Symbol=="function"&&h.constructor===Symbol&&h!==Symbol.prototype?"symbol":typeof h},s(u)}function l(u,h){var g=u&&u.navigator,b=u&&u.MediaStreamTrack;if(g.getUserMedia=function(f,I,A){o.deprecated("navigator.getUserMedia","navigator.mediaDevices.getUserMedia"),g.mediaDevices.getUserMedia(f).then(I,A)},!(h.version>55&&"autoGainControl"in g.mediaDevices.getSupportedConstraints())){var T=function(f,I,A){I in f&&!(A in f)&&(f[A]=f[I],delete f[I])},k=g.mediaDevices.getUserMedia.bind(g.mediaDevices);if(g.mediaDevices.getUserMedia=function(f){return s(f)==="object"&&s(f.audio)==="object"&&(f=JSON.parse(JSON.stringify(f)),T(f.audio,"autoGainControl","mozAutoGainControl"),T(f.audio,"noiseSuppression","mozNoiseSuppression")),k(f)},b&&b.prototype.getSettings){var p=b.prototype.getSettings;b.prototype.getSettings=function(){var f=p.apply(this,arguments);return T(f,"mozAutoGainControl","autoGainControl"),T(f,"mozNoiseSuppression","noiseSuppression"),f}}if(b&&b.prototype.applyConstraints){var S=b.prototype.applyConstraints;b.prototype.applyConstraints=function(f){return this.kind==="audio"&&s(f)==="object"&&(f=JSON.parse(JSON.stringify(f)),T(f,"autoGainControl","mozAutoGainControl"),T(f,"noiseSuppression","mozNoiseSuppression")),S.apply(this,[f])}}}}},{"../utils":11}],10:[function(n,i,r){Object.defineProperty(r,"__esModule",{value:!0}),r.shimAudioContext=S,r.shimCallbacksAPI=h,r.shimConstraints=b,r.shimCreateOfferLegacy=p,r.shimGetUserMedia=g,r.shimLocalStreamsAPI=l,r.shimRTCIceServerUrls=T,r.shimRemoteStreamsAPI=u,r.shimTrackEventTransceiver=k;var o=a(n("../utils"));function c(f){if(typeof WeakMap!="function")return null;var I=new WeakMap,A=new WeakMap;return(c=function(x){return x?A:I})(f)}function a(f,I){if(f&&f.__esModule)return f;if(f===null||s(f)!=="object"&&typeof f!="function")return{default:f};var A=c(I);if(A&&A.has(f))return A.get(f);var x={},D=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var m in f)if(m!=="default"&&Object.prototype.hasOwnProperty.call(f,m)){var v=D?Object.getOwnPropertyDescriptor(f,m):null;v&&(v.get||v.set)?Object.defineProperty(x,m,v):x[m]=f[m]}return x.default=f,A&&A.set(f,x),x}function s(f){return s=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(I){return typeof I}:function(I){return I&&typeof Symbol=="function"&&I.constructor===Symbol&&I!==Symbol.prototype?"symbol":typeof I},s(f)}function l(f){if(s(f)==="object"&&f.RTCPeerConnection){if("getLocalStreams"in f.RTCPeerConnection.prototype||(f.RTCPeerConnection.prototype.getLocalStreams=function(){return this._localStreams||(this._localStreams=[]),this._localStreams}),!("addStream"in f.RTCPeerConnection.prototype)){var I=f.RTCPeerConnection.prototype.addTrack;f.RTCPeerConnection.prototype.addStream=function(A){var x=this;this._localStreams||(this._localStreams=[]),this._localStreams.includes(A)||this._localStreams.push(A),A.getAudioTracks().forEach(function(D){return I.call(x,D,A)}),A.getVideoTracks().forEach(function(D){return I.call(x,D,A)})},f.RTCPeerConnection.prototype.addTrack=function(A){for(var x=this,D=arguments.length,m=new Array(D>1?D-1:0),v=1;v<D;v++)m[v-1]=arguments[v];return m&&m.forEach(function(w){x._localStreams?x._localStreams.includes(w)||x._localStreams.push(w):x._localStreams=[w]}),I.apply(this,arguments)}}"removeStream"in f.RTCPeerConnection.prototype||(f.RTCPeerConnection.prototype.removeStream=function(A){var x=this;this._localStreams||(this._localStreams=[]);var D=this._localStreams.indexOf(A);if(D!==-1){this._localStreams.splice(D,1);var m=A.getTracks();this.getSenders().forEach(function(v){m.includes(v.track)&&x.removeTrack(v)})}})}}function u(f){if(s(f)==="object"&&f.RTCPeerConnection&&("getRemoteStreams"in f.RTCPeerConnection.prototype||(f.RTCPeerConnection.prototype.getRemoteStreams=function(){return this._remoteStreams?this._remoteStreams:[]}),!("onaddstream"in f.RTCPeerConnection.prototype))){Object.defineProperty(f.RTCPeerConnection.prototype,"onaddstream",{get:function(){return this._onaddstream},set:function(A){var x=this;this._onaddstream&&(this.removeEventListener("addstream",this._onaddstream),this.removeEventListener("track",this._onaddstreampoly)),this.addEventListener("addstream",this._onaddstream=A),this.addEventListener("track",this._onaddstreampoly=function(D){D.streams.forEach(function(m){if(x._remoteStreams||(x._remoteStreams=[]),!x._remoteStreams.includes(m)){x._remoteStreams.push(m);var v=new Event("addstream");v.stream=m,x.dispatchEvent(v)}})})}});var I=f.RTCPeerConnection.prototype.setRemoteDescription;f.RTCPeerConnection.prototype.setRemoteDescription=function(){var A=this;return this._onaddstreampoly||this.addEventListener("track",this._onaddstreampoly=function(x){x.streams.forEach(function(D){if(A._remoteStreams||(A._remoteStreams=[]),!(A._remoteStreams.indexOf(D)>=0)){A._remoteStreams.push(D);var m=new Event("addstream");m.stream=D,A.dispatchEvent(m)}})}),I.apply(A,arguments)}}}function h(f){if(s(f)==="object"&&f.RTCPeerConnection){var I=f.RTCPeerConnection.prototype,A=I.createOffer,x=I.createAnswer,D=I.setLocalDescription,m=I.setRemoteDescription,v=I.addIceCandidate;I.createOffer=function(R,P){var y=arguments.length>=2?arguments[2]:arguments[0],d=A.apply(this,[y]);return P?(d.then(R,P),Promise.resolve()):d},I.createAnswer=function(R,P){var y=arguments.length>=2?arguments[2]:arguments[0],d=x.apply(this,[y]);return P?(d.then(R,P),Promise.resolve()):d};var w=function(R,P,y){var d=D.apply(this,[R]);return y?(d.then(P,y),Promise.resolve()):d};I.setLocalDescription=w,w=function(R,P,y){var d=m.apply(this,[R]);return y?(d.then(P,y),Promise.resolve()):d},I.setRemoteDescription=w,w=function(R,P,y){var d=v.apply(this,[R]);return y?(d.then(P,y),Promise.resolve()):d},I.addIceCandidate=w}}function g(f){var I=f&&f.navigator;if(I.mediaDevices&&I.mediaDevices.getUserMedia){var A=I.mediaDevices,x=A.getUserMedia.bind(A);I.mediaDevices.getUserMedia=function(D){return x(b(D))}}!I.getUserMedia&&I.mediaDevices&&I.mediaDevices.getUserMedia&&(I.getUserMedia=(function(D,m,v){I.mediaDevices.getUserMedia(D).then(m,v)}).bind(I))}function b(f){return f&&f.video!==void 0?Object.assign({},f,{video:o.compactObject(f.video)}):f}function T(f){if(f.RTCPeerConnection){var I=f.RTCPeerConnection;f.RTCPeerConnection=function(A,x){if(A&&A.iceServers){for(var D=[],m=0;m<A.iceServers.length;m++){var v=A.iceServers[m];v.urls===void 0&&v.url?(o.deprecated("RTCIceServer.url","RTCIceServer.urls"),(v=JSON.parse(JSON.stringify(v))).urls=v.url,delete v.url,D.push(v)):D.push(A.iceServers[m])}A.iceServers=D}return new I(A,x)},f.RTCPeerConnection.prototype=I.prototype,"generateCertificate"in I&&Object.defineProperty(f.RTCPeerConnection,"generateCertificate",{get:function(){return I.generateCertificate}})}}function k(f){s(f)==="object"&&f.RTCTrackEvent&&"receiver"in f.RTCTrackEvent.prototype&&!("transceiver"in f.RTCTrackEvent.prototype)&&Object.defineProperty(f.RTCTrackEvent.prototype,"transceiver",{get:function(){return{receiver:this.receiver}}})}function p(f){var I=f.RTCPeerConnection.prototype.createOffer;f.RTCPeerConnection.prototype.createOffer=function(A){if(A){A.offerToReceiveAudio!==void 0&&(A.offerToReceiveAudio=!!A.offerToReceiveAudio);var x=this.getTransceivers().find(function(m){return m.receiver.track.kind==="audio"});A.offerToReceiveAudio===!1&&x?x.direction==="sendrecv"?x.setDirection?x.setDirection("sendonly"):x.direction="sendonly":x.direction==="recvonly"&&(x.setDirection?x.setDirection("inactive"):x.direction="inactive"):A.offerToReceiveAudio!==!0||x||this.addTransceiver("audio",{direction:"recvonly"}),A.offerToReceiveVideo!==void 0&&(A.offerToReceiveVideo=!!A.offerToReceiveVideo);var D=this.getTransceivers().find(function(m){return m.receiver.track.kind==="video"});A.offerToReceiveVideo===!1&&D?D.direction==="sendrecv"?D.setDirection?D.setDirection("sendonly"):D.direction="sendonly":D.direction==="recvonly"&&(D.setDirection?D.setDirection("inactive"):D.direction="inactive"):A.offerToReceiveVideo!==!0||D||this.addTransceiver("video",{direction:"recvonly"})}return I.apply(this,arguments)}}function S(f){s(f)!=="object"||f.AudioContext||(f.AudioContext=f.webkitAudioContext)}},{"../utils":11}],11:[function(n,i,r){function o(D,m,v){return(m=c(m))in D?Object.defineProperty(D,m,{value:v,enumerable:!0,configurable:!0,writable:!0}):D[m]=v,D}function c(D){var m=a(D,"string");return s(m)==="symbol"?m:String(m)}function a(D,m){if(s(D)!=="object"||D===null)return D;var v=D[Symbol.toPrimitive];if(v!==void 0){var w=v.call(D,m);if(s(w)!=="object")return w;throw new TypeError("@@toPrimitive must return a primitive value.")}return(m==="string"?String:Number)(D)}function s(D){return s=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(m){return typeof m}:function(m){return m&&typeof Symbol=="function"&&m.constructor===Symbol&&m!==Symbol.prototype?"symbol":typeof m},s(D)}Object.defineProperty(r,"__esModule",{value:!0}),r.compactObject=I,r.deprecated=p,r.detectBrowser=S,r.disableLog=b,r.disableWarnings=T,r.extractVersion=h,r.filterStats=x,r.log=k,r.walkStats=A,r.wrapPeerConnectionEvent=g;var l=!0,u=!0;function h(D,m,v){var w=D.match(m);return w&&w.length>=v&&parseInt(w[v],10)}function g(D,m,v){if(D.RTCPeerConnection){var w=D.RTCPeerConnection.prototype,R=w.addEventListener;w.addEventListener=function(y,d){if(y!==m)return R.apply(this,arguments);var _=function(E){var C=v(E);C&&(d.handleEvent?d.handleEvent(C):d(C))};return this._eventMap=this._eventMap||{},this._eventMap[m]||(this._eventMap[m]=new Map),this._eventMap[m].set(d,_),R.apply(this,[y,_])};var P=w.removeEventListener;w.removeEventListener=function(y,d){if(y!==m||!this._eventMap||!this._eventMap[m])return P.apply(this,arguments);if(!this._eventMap[m].has(d))return P.apply(this,arguments);var _=this._eventMap[m].get(d);return this._eventMap[m].delete(d),this._eventMap[m].size===0&&delete this._eventMap[m],Object.keys(this._eventMap).length===0&&delete this._eventMap,P.apply(this,[y,_])},Object.defineProperty(w,"on"+m,{get:function(){return this["_on"+m]},set:function(y){this["_on"+m]&&(this.removeEventListener(m,this["_on"+m]),delete this["_on"+m]),y&&this.addEventListener(m,this["_on"+m]=y)},enumerable:!0,configurable:!0})}}function b(D){return typeof D!="boolean"?new Error("Argument type: "+s(D)+". Please use a boolean."):(l=D,D?"adapter.js logging disabled":"adapter.js logging enabled")}function T(D){return typeof D!="boolean"?new Error("Argument type: "+s(D)+". Please use a boolean."):(u=!D,"adapter.js deprecation warnings "+(D?"disabled":"enabled"))}function k(){if((typeof window>"u"?"undefined":s(window))==="object"){if(l)return;typeof console<"u"&&typeof console.log=="function"&&console.log.apply(console,arguments)}}function p(D,m){u&&console.warn(D+" is deprecated, please use "+m+" instead.")}function S(D){var m={browser:null,version:null};if(D===void 0||!D.navigator||!D.navigator.userAgent)return m.browser="Not a browser.",m;var v=D.navigator;if(v.mozGetUserMedia)m.browser="firefox",m.version=h(v.userAgent,/Firefox\/(\d+)\./,1);else if(v.webkitGetUserMedia||D.isSecureContext===!1&&D.webkitRTCPeerConnection)m.browser="chrome",m.version=h(v.userAgent,/Chrom(e|ium)\/(\d+)\./,2);else{if(!D.RTCPeerConnection||!v.userAgent.match(/AppleWebKit\/(\d+)\./))return m.browser="Not a supported browser.",m;m.browser="safari",m.version=h(v.userAgent,/AppleWebKit\/(\d+)\./,1),m.supportsUnifiedPlan=D.RTCRtpTransceiver&&"currentDirection"in D.RTCRtpTransceiver.prototype}return m}function f(D){return Object.prototype.toString.call(D)==="[object Object]"}function I(D){return f(D)?Object.keys(D).reduce(function(m,v){var w=f(D[v]),R=w?I(D[v]):D[v],P=w&&!Object.keys(R).length;return R===void 0||P?m:Object.assign(m,o({},v,R))},{}):D}function A(D,m,v){m&&!v.has(m.id)&&(v.set(m.id,m),Object.keys(m).forEach(function(w){w.endsWith("Id")?A(D,D.get(m[w]),v):w.endsWith("Ids")&&m[w].forEach(function(R){A(D,D.get(R),v)})}))}function x(D,m,v){var w=v?"outbound-rtp":"inbound-rtp",R=new Map;if(m===null)return R;var P=[];return D.forEach(function(y){y.type==="track"&&y.trackIdentifier===m.id&&P.push(y)}),P.forEach(function(y){D.forEach(function(d){d.type===w&&d.trackId===y.id&&A(D,d,R)})}),R}},{}],12:[function(n,i,r){var o=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(a){return typeof a}:function(a){return a&&typeof Symbol=="function"&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a},c={generateIdentifier:function(){return Math.random().toString(36).substring(2,12)}};c.localCName=c.generateIdentifier(),c.splitLines=function(a){return a.trim().split(`
`).map(function(s){return s.trim()})},c.splitSections=function(a){return a.split(`
m=`).map(function(s,l){return(l>0?"m="+s:s).trim()+`\r
`})},c.getDescription=function(a){var s=c.splitSections(a);return s&&s[0]},c.getMediaSections=function(a){var s=c.splitSections(a);return s.shift(),s},c.matchPrefix=function(a,s){return c.splitLines(a).filter(function(l){return l.indexOf(s)===0})},c.parseCandidate=function(a){for(var s=void 0,l={foundation:(s=a.indexOf("a=candidate:")===0?a.substring(12).split(" "):a.substring(10).split(" "))[0],component:{1:"rtp",2:"rtcp"}[s[1]]||s[1],protocol:s[2].toLowerCase(),priority:parseInt(s[3],10),ip:s[4],address:s[4],port:parseInt(s[5],10),type:s[7]},u=8;u<s.length;u+=2)switch(s[u]){case"raddr":l.relatedAddress=s[u+1];break;case"rport":l.relatedPort=parseInt(s[u+1],10);break;case"tcptype":l.tcpType=s[u+1];break;case"ufrag":l.ufrag=s[u+1],l.usernameFragment=s[u+1];break;default:l[s[u]]===void 0&&(l[s[u]]=s[u+1])}return l},c.writeCandidate=function(a){var s=[];s.push(a.foundation);var l=a.component;l==="rtp"?s.push(1):l==="rtcp"?s.push(2):s.push(l),s.push(a.protocol.toUpperCase()),s.push(a.priority),s.push(a.address||a.ip),s.push(a.port);var u=a.type;return s.push("typ"),s.push(u),u!=="host"&&a.relatedAddress&&a.relatedPort&&(s.push("raddr"),s.push(a.relatedAddress),s.push("rport"),s.push(a.relatedPort)),a.tcpType&&a.protocol.toLowerCase()==="tcp"&&(s.push("tcptype"),s.push(a.tcpType)),(a.usernameFragment||a.ufrag)&&(s.push("ufrag"),s.push(a.usernameFragment||a.ufrag)),"candidate:"+s.join(" ")},c.parseIceOptions=function(a){return a.substring(14).split(" ")},c.parseRtpMap=function(a){var s=a.substring(9).split(" "),l={payloadType:parseInt(s.shift(),10)};return s=s[0].split("/"),l.name=s[0],l.clockRate=parseInt(s[1],10),l.channels=s.length===3?parseInt(s[2],10):1,l.numChannels=l.channels,l},c.writeRtpMap=function(a){var s=a.payloadType;a.preferredPayloadType!==void 0&&(s=a.preferredPayloadType);var l=a.channels||a.numChannels||1;return"a=rtpmap:"+s+" "+a.name+"/"+a.clockRate+(l!==1?"/"+l:"")+`\r
`},c.parseExtmap=function(a){var s=a.substring(9).split(" ");return{id:parseInt(s[0],10),direction:s[0].indexOf("/")>0?s[0].split("/")[1]:"sendrecv",uri:s[1],attributes:s.slice(2).join(" ")}},c.writeExtmap=function(a){return"a=extmap:"+(a.id||a.preferredId)+(a.direction&&a.direction!=="sendrecv"?"/"+a.direction:"")+" "+a.uri+(a.attributes?" "+a.attributes:"")+`\r
`},c.parseFmtp=function(a){for(var s={},l=void 0,u=a.substring(a.indexOf(" ")+1).split(";"),h=0;h<u.length;h++)s[(l=u[h].trim().split("="))[0].trim()]=l[1];return s},c.writeFmtp=function(a){var s="",l=a.payloadType;if(a.preferredPayloadType!==void 0&&(l=a.preferredPayloadType),a.parameters&&Object.keys(a.parameters).length){var u=[];Object.keys(a.parameters).forEach(function(h){a.parameters[h]!==void 0?u.push(h+"="+a.parameters[h]):u.push(h)}),s+="a=fmtp:"+l+" "+u.join(";")+`\r
`}return s},c.parseRtcpFb=function(a){var s=a.substring(a.indexOf(" ")+1).split(" ");return{type:s.shift(),parameter:s.join(" ")}},c.writeRtcpFb=function(a){var s="",l=a.payloadType;return a.preferredPayloadType!==void 0&&(l=a.preferredPayloadType),a.rtcpFeedback&&a.rtcpFeedback.length&&a.rtcpFeedback.forEach(function(u){s+="a=rtcp-fb:"+l+" "+u.type+(u.parameter&&u.parameter.length?" "+u.parameter:"")+`\r
`}),s},c.parseSsrcMedia=function(a){var s=a.indexOf(" "),l={ssrc:parseInt(a.substring(7,s),10)},u=a.indexOf(":",s);return u>-1?(l.attribute=a.substring(s+1,u),l.value=a.substring(u+1)):l.attribute=a.substring(s+1),l},c.parseSsrcGroup=function(a){var s=a.substring(13).split(" ");return{semantics:s.shift(),ssrcs:s.map(function(l){return parseInt(l,10)})}},c.getMid=function(a){var s=c.matchPrefix(a,"a=mid:")[0];if(s)return s.substring(6)},c.parseFingerprint=function(a){var s=a.substring(14).split(" ");return{algorithm:s[0].toLowerCase(),value:s[1].toUpperCase()}},c.getDtlsParameters=function(a,s){return{role:"auto",fingerprints:c.matchPrefix(a+s,"a=fingerprint:").map(c.parseFingerprint)}},c.writeDtlsParameters=function(a,s){var l="a=setup:"+s+`\r
`;return a.fingerprints.forEach(function(u){l+="a=fingerprint:"+u.algorithm+" "+u.value+`\r
`}),l},c.parseCryptoLine=function(a){var s=a.substring(9).split(" ");return{tag:parseInt(s[0],10),cryptoSuite:s[1],keyParams:s[2],sessionParams:s.slice(3)}},c.writeCryptoLine=function(a){return"a=crypto:"+a.tag+" "+a.cryptoSuite+" "+(o(a.keyParams)==="object"?c.writeCryptoKeyParams(a.keyParams):a.keyParams)+(a.sessionParams?" "+a.sessionParams.join(" "):"")+`\r
`},c.parseCryptoKeyParams=function(a){if(a.indexOf("inline:")!==0)return null;var s=a.substring(7).split("|");return{keyMethod:"inline",keySalt:s[0],lifeTime:s[1],mkiValue:s[2]?s[2].split(":")[0]:void 0,mkiLength:s[2]?s[2].split(":")[1]:void 0}},c.writeCryptoKeyParams=function(a){return a.keyMethod+":"+a.keySalt+(a.lifeTime?"|"+a.lifeTime:"")+(a.mkiValue&&a.mkiLength?"|"+a.mkiValue+":"+a.mkiLength:"")},c.getCryptoParameters=function(a,s){return c.matchPrefix(a+s,"a=crypto:").map(c.parseCryptoLine)},c.getIceParameters=function(a,s){var l=c.matchPrefix(a+s,"a=ice-ufrag:")[0],u=c.matchPrefix(a+s,"a=ice-pwd:")[0];return l&&u?{usernameFragment:l.substring(12),password:u.substring(10)}:null},c.writeIceParameters=function(a){var s="a=ice-ufrag:"+a.usernameFragment+`\r
a=ice-pwd:`+a.password+`\r
`;return a.iceLite&&(s+=`a=ice-lite\r
`),s},c.parseRtpParameters=function(a){var s={codecs:[],headerExtensions:[],fecMechanisms:[],rtcp:[]},l=c.splitLines(a)[0].split(" ");s.profile=l[2];for(var u=3;u<l.length;u++){var h=l[u],g=c.matchPrefix(a,"a=rtpmap:"+h+" ")[0];if(g){var b=c.parseRtpMap(g),T=c.matchPrefix(a,"a=fmtp:"+h+" ");switch(b.parameters=T.length?c.parseFmtp(T[0]):{},b.rtcpFeedback=c.matchPrefix(a,"a=rtcp-fb:"+h+" ").map(c.parseRtcpFb),s.codecs.push(b),b.name.toUpperCase()){case"RED":case"ULPFEC":s.fecMechanisms.push(b.name.toUpperCase())}}}c.matchPrefix(a,"a=extmap:").forEach(function(p){s.headerExtensions.push(c.parseExtmap(p))});var k=c.matchPrefix(a,"a=rtcp-fb:* ").map(c.parseRtcpFb);return s.codecs.forEach(function(p){k.forEach(function(S){p.rtcpFeedback.find(function(f){return f.type===S.type&&f.parameter===S.parameter})||p.rtcpFeedback.push(S)})}),s},c.writeRtpDescription=function(a,s){var l="";l+="m="+a+" ",l+=s.codecs.length>0?"9":"0",l+=" "+(s.profile||"UDP/TLS/RTP/SAVPF")+" ",l+=s.codecs.map(function(h){return h.preferredPayloadType!==void 0?h.preferredPayloadType:h.payloadType}).join(" ")+`\r
`,l+=`c=IN IP4 0.0.0.0\r
`,l+=`a=rtcp:9 IN IP4 0.0.0.0\r
`,s.codecs.forEach(function(h){l+=c.writeRtpMap(h),l+=c.writeFmtp(h),l+=c.writeRtcpFb(h)});var u=0;return s.codecs.forEach(function(h){h.maxptime>u&&(u=h.maxptime)}),u>0&&(l+="a=maxptime:"+u+`\r
`),s.headerExtensions&&s.headerExtensions.forEach(function(h){l+=c.writeExtmap(h)}),l},c.parseRtpEncodingParameters=function(a){var s=[],l=c.parseRtpParameters(a),u=l.fecMechanisms.indexOf("RED")!==-1,h=l.fecMechanisms.indexOf("ULPFEC")!==-1,g=c.matchPrefix(a,"a=ssrc:").map(function(S){return c.parseSsrcMedia(S)}).filter(function(S){return S.attribute==="cname"}),b=g.length>0&&g[0].ssrc,T=void 0,k=c.matchPrefix(a,"a=ssrc-group:FID").map(function(S){return S.substring(17).split(" ").map(function(f){return parseInt(f,10)})});k.length>0&&k[0].length>1&&k[0][0]===b&&(T=k[0][1]),l.codecs.forEach(function(S){if(S.name.toUpperCase()==="RTX"&&S.parameters.apt){var f={ssrc:b,codecPayloadType:parseInt(S.parameters.apt,10)};b&&T&&(f.rtx={ssrc:T}),s.push(f),u&&((f=JSON.parse(JSON.stringify(f))).fec={ssrc:b,mechanism:h?"red+ulpfec":"red"},s.push(f))}}),s.length===0&&b&&s.push({ssrc:b});var p=c.matchPrefix(a,"b=");return p.length&&(p=p[0].indexOf("b=TIAS:")===0?parseInt(p[0].substring(7),10):p[0].indexOf("b=AS:")===0?1e3*parseInt(p[0].substring(5),10)*.95-16e3:void 0,s.forEach(function(S){S.maxBitrate=p})),s},c.parseRtcpParameters=function(a){var s={},l=c.matchPrefix(a,"a=ssrc:").map(function(g){return c.parseSsrcMedia(g)}).filter(function(g){return g.attribute==="cname"})[0];l&&(s.cname=l.value,s.ssrc=l.ssrc);var u=c.matchPrefix(a,"a=rtcp-rsize");s.reducedSize=u.length>0,s.compound=u.length===0;var h=c.matchPrefix(a,"a=rtcp-mux");return s.mux=h.length>0,s},c.writeRtcpParameters=function(a){var s="";return a.reducedSize&&(s+=`a=rtcp-rsize\r
`),a.mux&&(s+=`a=rtcp-mux\r
`),a.ssrc!==void 0&&a.cname&&(s+="a=ssrc:"+a.ssrc+" cname:"+a.cname+`\r
`),s},c.parseMsid=function(a){var s=void 0,l=c.matchPrefix(a,"a=msid:");if(l.length===1)return{stream:(s=l[0].substring(7).split(" "))[0],track:s[1]};var u=c.matchPrefix(a,"a=ssrc:").map(function(h){return c.parseSsrcMedia(h)}).filter(function(h){return h.attribute==="msid"});return u.length>0?{stream:(s=u[0].value.split(" "))[0],track:s[1]}:void 0},c.parseSctpDescription=function(a){var s=c.parseMLine(a),l=c.matchPrefix(a,"a=max-message-size:"),u=void 0;l.length>0&&(u=parseInt(l[0].substring(19),10)),isNaN(u)&&(u=65536);var h=c.matchPrefix(a,"a=sctp-port:");if(h.length>0)return{port:parseInt(h[0].substring(12),10),protocol:s.fmt,maxMessageSize:u};var g=c.matchPrefix(a,"a=sctpmap:");if(g.length>0){var b=g[0].substring(10).split(" ");return{port:parseInt(b[0],10),protocol:b[1],maxMessageSize:u}}},c.writeSctpDescription=function(a,s){var l=[];return l=a.protocol!=="DTLS/SCTP"?["m="+a.kind+" 9 "+a.protocol+" "+s.protocol+`\r
`,`c=IN IP4 0.0.0.0\r
`,"a=sctp-port:"+s.port+`\r
`]:["m="+a.kind+" 9 "+a.protocol+" "+s.port+`\r
`,`c=IN IP4 0.0.0.0\r
`,"a=sctpmap:"+s.port+" "+s.protocol+` 65535\r
`],s.maxMessageSize!==void 0&&l.push("a=max-message-size:"+s.maxMessageSize+`\r
`),l.join("")},c.generateSessionId=function(){return Math.random().toString().substr(2,22)},c.writeSessionBoilerplate=function(a,s,l){var u=s!==void 0?s:2;return`v=0\r
o=`+(l||"thisisadapterortc")+" "+(a||c.generateSessionId())+" "+u+` IN IP4 127.0.0.1\r
s=-\r
t=0 0\r
`},c.getDirection=function(a,s){for(var l=c.splitLines(a),u=0;u<l.length;u++)switch(l[u]){case"a=sendrecv":case"a=sendonly":case"a=recvonly":case"a=inactive":return l[u].substring(2)}return s?c.getDirection(s):"sendrecv"},c.getKind=function(a){return c.splitLines(a)[0].split(" ")[0].substring(2)},c.isRejected=function(a){return a.split(" ",2)[1]==="0"},c.parseMLine=function(a){var s=c.splitLines(a)[0].substring(2).split(" ");return{kind:s[0],port:parseInt(s[1],10),protocol:s[2],fmt:s.slice(3).join(" ")}},c.parseOLine=function(a){var s=c.matchPrefix(a,"o=")[0].substring(2).split(" ");return{username:s[0],sessionId:s[1],sessionVersion:parseInt(s[2],10),netType:s[3],addressType:s[4],address:s[5]}},c.isValidSDP=function(a){if(typeof a!="string"||a.length===0)return!1;for(var s=c.splitLines(a),l=0;l<s.length;l++)if(s[l].length<2||s[l].charAt(1)!=="=")return!1;return!0},(i===void 0?"undefined":o(i))==="object"&&(i.exports=c)},{}]},{},[1])(1)}({exports:{}});var Wn="4.15.22",Mf={},eR=Pf,tR=Hc,ao=Object.keys||function(e){return eR(e,tR)},nR=Ae,rR=bf,iR=Ve,aR=Oe,oR=kt,sR=ao;Mf.f=nR&&!rR?Object.defineProperties:function(e,t){aR(e);for(var n,i=oR(t),r=sR(t),o=r.length,c=0;o>c;)iR.f(e,n=r[c++],i[n]);return e};var oo,Nf=Qt("document","documentElement"),cR=Oe,uR=Mf,Lf=Hc,lR=no,dR=Nf,hR=$a,Uf=Lc("IE_PROTO"),Jc=function(){},Vf=function(e){return"<script>"+e+"<\/script>"},jf=function(e){e.write(Vf("")),e.close();var t=e.parentWindow.Object;return e=null,t},so=function(){try{oo=new ActiveXObject("htmlfile")}catch{}var e,t;so=typeof document<"u"?document.domain&&oo?jf(oo):((t=hR("iframe")).style.display="none",dR.appendChild(t),t.src="javascript:",(e=t.contentWindow.document).open(),e.write(Vf("document.F=Object")),e.close(),e.F):jf(oo);for(var n=Lf.length;n--;)delete so.prototype[Lf[n]];return so()};lR[Uf]=!0;var wr=Object.create||function(e,t){var n;return e!==null?(Jc.prototype=cR(e),n=new Jc,Jc.prototype=null,n[Uf]=e):n=so(),t===void 0?n:uR.f(n,t)},pR=be,fR=wr,mR=Ve.f,qc=pR("unscopables"),Kc=Array.prototype;Kc[qc]==null&&mR(Kc,qc,{configurable:!0,value:fR(null)});var Gn,Ff,Bf,co=function(e){Kc[qc][e]=!0},Di={},Hf=!Z(function(){function e(){}return e.prototype.constructor=null,Object.getPrototypeOf(new e)!==e.prototype}),_R=Le,vR=ge,gR=ze,yR=Hf,Wf=Lc("IE_PROTO"),Qc=Object,SR=Qc.prototype,Oi=yR?Qc.getPrototypeOf:function(e){var t=gR(e);if(_R(t,Wf))return t[Wf];var n=t.constructor;return vR(n)&&t instanceof n?n.prototype:t instanceof Qc?SR:null},bR=Z,kR=ge,IR=xe,Gf=Oi,TR=He,Xc=be("iterator"),zf=!1;[].keys&&("next"in(Bf=[].keys())?(Ff=Gf(Gf(Bf)))!==Object.prototype&&(Gn=Ff):zf=!0);var wR=!IR(Gn)||bR(function(){var e={};return Gn[Xc].call(e)!==e});wR&&(Gn={}),kR(Gn[Xc])||TR(Gn,Xc,function(){return this});var Yc={IteratorPrototype:Gn,BUGGY_SAFARI_ITERATORS:zf},ER=Ve.f,RR=Le,Jf=be("toStringTag"),zn=function(e,t,n){e&&!n&&(e=e.prototype),e&&!RR(e,Jf)&&ER(e,Jf,{configurable:!0,value:t})},CR=Yc.IteratorPrototype,AR=wr,xR=Sr,PR=zn,DR=Di,OR=function(){return this},qf=function(e,t,n,i){var r=t+" Iterator";return e.prototype=AR(CR,{next:xR(+!i,n)}),PR(e,r,!1),DR[r]=OR,e},MR=ge,NR=String,LR=TypeError,UR=$,VR=Oe,jR=function(e){if(typeof e=="object"||MR(e))return e;throw LR("Can't set "+NR(e)+" as a prototype")},Er=Object.setPrototypeOf||("__proto__"in{}?function(){var e,t=!1,n={};try{(e=UR(Object.getOwnPropertyDescriptor(Object.prototype,"__proto__").set))(n,[]),t=n instanceof Array}catch{}return function(i,r){return VR(i),jR(r),t?e(i,r):i.__proto__=r,i}}():void 0),FR=Y,BR=we,HR=ge,WR=qf,Kf=Oi,Qf=Er,GR=zn,zR=Ut,$c=He,JR=Di,qR=Hn.PROPER,KR=Hn.CONFIGURABLE,Xf=Yc.IteratorPrototype,uo=Yc.BUGGY_SAFARI_ITERATORS,Mi=be("iterator"),Yf="keys",Ni="values",$f="entries",QR=function(){return this},Zc=function(e,t,n,i,r,o,c){WR(n,t,i);var a,s,l,u=function(S){if(S===r&&k)return k;if(!uo&&S in b)return b[S];switch(S){case Yf:case Ni:case $f:return function(){return new n(this,S)}}return function(){return new n(this)}},h=t+" Iterator",g=!1,b=e.prototype,T=b[Mi]||b["@@iterator"]||r&&b[r],k=!uo&&T||u(r),p=t=="Array"&&b.entries||T;if(p&&(a=Kf(p.call(new e)))!==Object.prototype&&a.next&&(Kf(a)!==Xf&&(Qf?Qf(a,Xf):HR(a[Mi])||$c(a,Mi,QR)),GR(a,h,!0)),qR&&r==Ni&&T&&T.name!==Ni&&(KR?zR(b,"name",Ni):(g=!0,k=function(){return BR(T,this)})),r)if(s={values:u(Ni),keys:o?k:u(Yf),entries:u($f)},c)for(l in s)(uo||g||!(l in b))&&$c(b,l,s[l]);else FR({target:t,proto:!0,forced:uo||g},s);return b[Mi]!==k&&$c(b,Mi,k,{name:r}),JR[t]=k,s},eu=function(e,t){return{value:e,done:t}},XR=kt,tu=co,Zf=Di,em=Me,YR=Ve.f,$R=Zc,tm=eu,ZR=Ae,nm="Array Iterator",eC=em.set,tC=em.getterFor(nm),rm=$R(Array,"Array",function(e,t){eC(this,{type:nm,target:XR(e),index:0,kind:t})},function(){var e=tC(this),t=e.target,n=e.kind,i=e.index++;return!t||i>=t.length?(e.target=void 0,tm(void 0,!0)):tm(n=="keys"?i:n=="values"?t[i]:[i,t[i]],!1)},"values"),im=Zf.Arguments=Zf.Array;if(tu("keys"),tu("values"),tu("entries"),ZR&&im.name!=="values")try{YR(im,"name",{value:"values"})}catch{}var am={};am[be("toStringTag")]="z";var nu=String(am)==="[object z]",nC=nu,rC=ge,lo=Kt,iC=be("toStringTag"),aC=Object,oC=lo(function(){return arguments}())=="Arguments",Yt=nC?lo:function(e){var t,n,i;return e===void 0?"Undefined":e===null?"Null":typeof(n=function(r,o){try{return r[o]}catch{}}(t=aC(e),iC))=="string"?n:oC?lo(t):(i=lo(t))=="Object"&&rC(t.callee)?"Arguments":i},sC=Yt,cC=nu?{}.toString:function(){return"[object "+sC(this)+"]"};nu||He(Object.prototype,"toString",cC,{unsafe:!0});var Li={exports:{}},ru={},uC=Ya,lC=Ve,dC=Sr,Ui=function(e,t,n){var i=uC(t);i in e?lC.f(e,i,dC(0,n)):e[i]=n},om=_n,hC=qe,pC=Ui,fC=Array,mC=Math.max,ho=function(e,t,n){for(var i=hC(e),r=om(t,i),o=om(n===void 0?i:n,i),c=fC(mC(o-r,0)),a=0;r<o;r++,a++)pC(c,a,e[r]);return c.length=a,c},_C=Kt,vC=kt,sm=mn.f,gC=ho,cm=typeof window=="object"&&window&&Object.getOwnPropertyNames?Object.getOwnPropertyNames(window):[];ru.f=function(e){return cm&&_C(e)=="Window"?function(t){try{return sm(t)}catch{return gC(cm)}}(e):sm(vC(e))};var yC=Z(function(){if(typeof ArrayBuffer=="function"){var e=new ArrayBuffer(8);Object.isExtensible(e)&&Object.defineProperty(e,"a",{value:8})}}),SC=Z,bC=xe,kC=Kt,um=yC,po=Object.isExtensible,lm=SC(function(){po(1)})||um?function(e){return!!bC(e)&&(!um||kC(e)!="ArrayBuffer")&&(!po||po(e))}:po,IC=!Z(function(){return Object.isExtensible(Object.preventExtensions({}))}),TC=Y,wC=$,EC=no,RC=xe,iu=Le,CC=Ve.f,dm=mn,AC=ru,au=lm,xC=IC,hm=!1,$t=Qa("meta"),PC=0,ou=function(e){CC(e,$t,{value:{objectID:"O"+PC++,weakData:{}}})},DC=Li.exports={enable:function(){DC.enable=function(){},hm=!0;var e=dm.f,t=wC([].splice),n={};n[$t]=1,e(n).length&&(dm.f=function(i){for(var r=e(i),o=0,c=r.length;o<c;o++)if(r[o]===$t){t(r,o,1);break}return r},TC({target:"Object",stat:!0,forced:!0},{getOwnPropertyNames:AC.f}))},fastKey:function(e,t){if(!RC(e))return typeof e=="symbol"?e:(typeof e=="string"?"S":"P")+e;if(!iu(e,$t)){if(!au(e))return"F";if(!t)return"E";ou(e)}return e[$t].objectID},getWeakData:function(e,t){if(!iu(e,$t)){if(!au(e))return!0;if(!t)return!1;ou(e)}return e[$t].weakData},onFreeze:function(e){return xC&&hm&&au(e)&&!iu(e,$t)&&ou(e),e}};EC[$t]=!0;var OC=It,MC=wi,NC=$($.bind),Zt=function(e,t){return OC(e),t===void 0?e:MC?NC(e,t):function(){return e.apply(t,arguments)}},LC=Di,UC=be("iterator"),VC=Array.prototype,su=function(e){return e!==void 0&&(LC.Array===e||VC[UC]===e)},jC=Yt,pm=Ir,FC=Lt,BC=Di,HC=be("iterator"),Vi=function(e){if(!FC(e))return pm(e,HC)||pm(e,"@@iterator")||BC[jC(e)]},WC=we,GC=It,zC=Oe,JC=kr,qC=Vi,KC=TypeError,fo=function(e,t){var n=arguments.length<2?qC(e):t;if(GC(n))return zC(WC(n,e));throw KC(JC(e)+" is not iterable")},QC=we,fm=Oe,XC=Ir,mm=function(e,t,n){var i,r;fm(e);try{if(!(i=XC(e,"return"))){if(t==="throw")throw n;return n}i=QC(i,e)}catch(o){r=!0,i=o}if(t==="throw")throw n;if(r)throw i;return fm(i),n},YC=Zt,$C=we,ZC=Oe,e1=kr,t1=su,n1=qe,_m=fn,r1=fo,i1=Vi,vm=mm,a1=TypeError,mo=function(e,t){this.stopped=e,this.result=t},gm=mo.prototype,ji=function(e,t,n){var i,r,o,c,a,s,l,u=n&&n.that,h=!(!n||!n.AS_ENTRIES),g=!(!n||!n.IS_RECORD),b=!(!n||!n.IS_ITERATOR),T=!(!n||!n.INTERRUPTED),k=YC(t,u),p=function(f){return i&&vm(i,"normal",f),new mo(!0,f)},S=function(f){return h?(ZC(f),T?k(f[0],f[1],p):k(f[0],f[1])):T?k(f,p):k(f)};if(g)i=e.iterator;else if(b)i=e;else{if(!(r=i1(e)))throw a1(e1(e)+" is not iterable");if(t1(r)){for(o=0,c=n1(e);c>o;o++)if((a=S(e[o]))&&_m(gm,a))return a;return new mo(!1)}i=r1(e,r)}for(s=g?e.next:i.next;!(l=$C(s,i)).done;){try{a=S(l.value)}catch(f){vm(i,"throw",f)}if(typeof a=="object"&&a&&_m(gm,a))return a}return new mo(!1)},o1=fn,s1=TypeError,vn=function(e,t){if(o1(t,e))return e;throw s1("Incorrect invocation")},ym=be("iterator"),Sm=!1;try{var c1=0,bm={next:function(){return{done:!!c1++}},return:function(){Sm=!0}};bm[ym]=function(){return this},Array.from(bm,function(){throw 2})}catch{}var _o=function(e,t){if(!t&&!Sm)return!1;var n=!1;try{var i={};i[ym]=function(){return{next:function(){return{done:n=!0}}}},e(i)}catch{}return n},u1=ge,l1=xe,km=Er,vo=function(e,t,n){var i,r;return km&&u1(i=t.constructor)&&i!==n&&l1(r=i.prototype)&&r!==n.prototype&&km(e,r),e},d1=Y,h1=oe,p1=$,Im=Pi,f1=He,m1=Li.exports,_1=ji,v1=vn,g1=ge,y1=Lt,cu=xe,uu=Z,S1=_o,b1=zn,k1=vo,lu=function(e,t,n){var i=e.indexOf("Map")!==-1,r=e.indexOf("Weak")!==-1,o=i?"set":"add",c=h1[e],a=c&&c.prototype,s=c,l={},u=function(p){var S=p1(a[p]);f1(a,p,p=="add"?function(f){return S(this,f===0?0:f),this}:p=="delete"?function(f){return!(r&&!cu(f))&&S(this,f===0?0:f)}:p=="get"?function(f){return r&&!cu(f)?void 0:S(this,f===0?0:f)}:p=="has"?function(f){return!(r&&!cu(f))&&S(this,f===0?0:f)}:function(f,I){return S(this,f===0?0:f,I),this})};if(Im(e,!g1(c)||!(r||a.forEach&&!uu(function(){new c().entries().next()}))))s=n.getConstructor(t,e,i,o),m1.enable();else if(Im(e,!0)){var h=new s,g=h[o](r?{}:-0,1)!=h,b=uu(function(){h.has(1)}),T=S1(function(p){new c(p)}),k=!r&&uu(function(){for(var p=new c,S=5;S--;)p[o](S,S);return!p.has(-0)});T||((s=t(function(p,S){v1(p,a);var f=k1(new c,p,s);return y1(S)||_1(S,f[o],{that:f,AS_ENTRIES:i}),f})).prototype=a,a.constructor=s),(b||k)&&(u("delete"),u("has"),i&&u("get")),(k||g)&&u(o),r&&a.clear&&delete a.clear}return l[e]=s,d1({global:!0,constructor:!0,forced:s!=c},l),b1(s,e),r||n.setStrong(s,e,i),s},I1=He,Fi=function(e,t,n){for(var i in t)I1(e,i,t[i],n);return e},T1=Qt,w1=Ve,E1=Ae,Tm=be("species"),Bi=function(e){var t=T1(e),n=w1.f;E1&&t&&!t[Tm]&&n(t,Tm,{configurable:!0,get:function(){return this}})},R1=Ve.f,C1=wr,wm=Fi,A1=Zt,x1=vn,P1=Lt,D1=ji,O1=Zc,Em=eu,M1=Bi,Hi=Ae,Rm=Li.exports.fastKey,Cm=Me.set,du=Me.getterFor,Am={getConstructor:function(e,t,n,i){var r=e(function(l,u){x1(l,o),Cm(l,{type:t,index:C1(null),first:void 0,last:void 0,size:0}),Hi||(l.size=0),P1(u)||D1(u,l[i],{that:l,AS_ENTRIES:n})}),o=r.prototype,c=du(t),a=function(l,u,h){var g,b,T=c(l),k=s(l,u);return k?k.value=h:(T.last=k={index:b=Rm(u,!0),key:u,value:h,previous:g=T.last,next:void 0,removed:!1},T.first||(T.first=k),g&&(g.next=k),Hi?T.size++:l.size++,b!=="F"&&(T.index[b]=k)),l},s=function(l,u){var h,g=c(l),b=Rm(u);if(b!=="F")return g.index[b];for(h=g.first;h;h=h.next)if(h.key==u)return h};return wm(o,{clear:function(){for(var l=c(this),u=l.index,h=l.first;h;)h.removed=!0,h.previous&&(h.previous=h.previous.next=void 0),delete u[h.index],h=h.next;l.first=l.last=void 0,Hi?l.size=0:this.size=0},delete:function(l){var u=this,h=c(u),g=s(u,l);if(g){var b=g.next,T=g.previous;delete h.index[g.index],g.removed=!0,T&&(T.next=b),b&&(b.previous=T),h.first==g&&(h.first=b),h.last==g&&(h.last=T),Hi?h.size--:u.size--}return!!g},forEach:function(l){for(var u,h=c(this),g=A1(l,arguments.length>1?arguments[1]:void 0);u=u?u.next:h.first;)for(g(u.value,u.key,this);u&&u.removed;)u=u.previous},has:function(l){return!!s(this,l)}}),wm(o,n?{get:function(l){var u=s(this,l);return u&&u.value},set:function(l,u){return a(this,l===0?0:l,u)}}:{add:function(l){return a(this,l=l===0?0:l,l)}}),Hi&&R1(o,"size",{get:function(){return c(this).size}}),r},setStrong:function(e,t,n){var i=t+" Iterator",r=du(t),o=du(i);O1(e,t,function(c,a){Cm(this,{type:i,target:c,state:r(c),kind:a,last:void 0})},function(){for(var c=o(this),a=c.kind,s=c.last;s&&s.removed;)s=s.previous;return c.target&&(c.last=s=s?s.next:c.state.first)?Em(a=="keys"?s.key:a=="values"?s.value:[s.key,s.value],!1):(c.target=void 0,Em(void 0,!0))},n?"entries":"values",!n,!0),M1(t)}};lu("Set",function(e){return function(){return e(this,arguments.length?arguments[0]:void 0)}},Am);var N1=Yt,L1=String,Fe=function(e){if(N1(e)==="Symbol")throw TypeError("Cannot convert a Symbol value to a string");return L1(e)},hu=$,U1=Tt,V1=Fe,j1=dt,F1=hu("".charAt),xm=hu("".charCodeAt),B1=hu("".slice),Pm=function(e){return function(t,n){var i,r,o=V1(j1(t)),c=U1(n),a=o.length;return c<0||c>=a?e?"":void 0:(i=xm(o,c))<55296||i>56319||c+1===a||(r=xm(o,c+1))<56320||r>57343?e?F1(o,c):i:e?B1(o,c,c+2):r-56320+(i-55296<<10)+65536}},pu={codeAt:Pm(!1),charAt:Pm(!0)},H1=pu.charAt,W1=Fe,Dm=Me,G1=Zc,Om=eu,Mm="String Iterator",z1=Dm.set,J1=Dm.getterFor(Mm);G1(String,"String",function(e){z1(this,{type:Mm,string:W1(e),index:0})},function(){var e,t=J1(this),n=t.string,i=t.index;return i>=n.length?Om(void 0,!0):(e=H1(n,i),t.index+=e.length,Om(e,!1))});var Nm={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},fu=$a("span").classList,Lm=fu&&fu.constructor&&fu.constructor.prototype,Um=Lm===Object.prototype?void 0:Lm,Vm=oe,jm=Nm,q1=Um,Wi=rm,mu=Ut,Fm=be,_u=Fm("iterator"),Bm=Fm("toStringTag"),vu=Wi.values,Hm=function(e,t){if(e){if(e[_u]!==vu)try{mu(e,_u,vu)}catch{e[_u]=vu}if(e[Bm]||mu(e,Bm,t),jm[t]){for(var n in Wi)if(e[n]!==Wi[n])try{mu(e,n,Wi[n])}catch{e[n]=Wi[n]}}}};for(var gu in jm)Hm(Vm[gu]&&Vm[gu].prototype,gu);Hm(q1,"DOMTokenList");var K1=wi,Wm=Function.prototype,Gm=Wm.apply,zm=Wm.call,Jn=typeof Reflect=="object"&&Reflect.apply||(K1?zm.bind(Gm):function(){return zm.apply(Gm,arguments)}),Rr=$([].slice),Q1=TypeError,go=function(e,t){if(e<t)throw Q1("Not enough arguments");return e},yu=oe,X1=Jn,Y1=ge,$1=Rr,Z1=go,eA=/MSIE .\./.test(Xt),tA=yu.Function,Jm=function(e){return eA?function(t,n){var i=Z1(arguments.length,1)>2,r=Y1(t)?t:tA(t),o=i?$1(arguments,2):void 0;return e(i?function(){X1(r,this,o)}:r,n)}:e},qm={setTimeout:Jm(yu.setTimeout),setInterval:Jm(yu.setInterval)},Km=qm.setInterval;Y({global:!0,bind:!0,forced:oe.setInterval!==Km},{setInterval:Km});var Qm=qm.setTimeout;Y({global:!0,bind:!0,forced:oe.setTimeout!==Qm},{setTimeout:Qm}),lu("Map",function(e){return function(){return e(this,arguments.length?arguments[0]:void 0)}},Am);var nA=Kt,Cr=Array.isArray||function(e){return nA(e)=="Array"},rA=$,iA=Z,Xm=ge,aA=Yt,oA=Nc,Ym=function(){},sA=[],$m=Qt("Reflect","construct"),Su=/^\s*(?:class|function)\b/,cA=rA(Su.exec),uA=!Su.exec(Ym),Gi=function(e){if(!Xm(e))return!1;try{return $m(Ym,sA,e),!0}catch{return!1}},Zm=function(e){if(!Xm(e))return!1;switch(aA(e)){case"AsyncFunction":case"GeneratorFunction":case"AsyncGeneratorFunction":return!1}try{return uA||!!cA(Su,oA(e))}catch{return!0}};Zm.sham=!0;var yo=!$m||iA(function(){var e;return Gi(Gi.call)||!Gi(Object)||!Gi(function(){e=!0})||e})?Zm:Gi,e_=Cr,lA=yo,dA=xe,hA=be("species"),t_=Array,pA=function(e){var t;return e_(e)&&(t=e.constructor,(lA(t)&&(t===t_||e_(t.prototype))||dA(t)&&(t=t[hA])===null)&&(t=void 0)),t===void 0?t_:t},bu=function(e,t){return new(pA(e))(t===0?0:t)},fA=Zt,mA=Ei,_A=ze,vA=qe,gA=bu,n_=$([].push),qn=function(e){var t=e==1,n=e==2,i=e==3,r=e==4,o=e==6,c=e==7,a=e==5||o;return function(s,l,u,h){for(var g,b,T=_A(s),k=mA(T),p=fA(l,u),S=vA(k),f=0,I=h||gA,A=t?I(s,S):n||c?I(s,0):void 0;S>f;f++)if((a||f in k)&&(b=p(g=k[f],f,T),e))if(t)A[f]=b;else if(b)switch(e){case 3:return!0;case 5:return g;case 6:return f;case 2:n_(A,g)}else switch(e){case 4:return!1;case 7:n_(A,g)}return o?-1:i||r?r:A}},Ke={forEach:qn(0),map:qn(1),filter:qn(2),some:qn(3),every:qn(4),find:qn(5),findIndex:qn(6)},yA=Z,SA=br,bA=be("species"),zi=function(e){return SA>=51||!yA(function(){var t=[];return(t.constructor={})[bA]=function(){return{foo:1}},t[e](Boolean).foo!==1})},kA=Ke.map;Y({target:"Array",proto:!0,forced:!zi("map")},{map:function(e){return kA(this,e,arguments.length>1?arguments[1]:void 0)}});var IA=Ae,TA=Cr,wA=TypeError,EA=Object.getOwnPropertyDescriptor,RA=IA&&!function(){if(this!==void 0)return!0;try{Object.defineProperty([],"length",{writable:!1}).length=1}catch(e){return e instanceof TypeError}}(),CA=TypeError,r_=function(e){if(e>9007199254740991)throw CA("Maximum allowed index exceeded");return e},i_=kr,AA=TypeError,a_=function(e,t){if(!delete e[t])throw AA("Cannot delete property "+i_(t)+" of "+i_(e))},xA=Y,PA=ze,DA=_n,OA=Tt,MA=qe,NA=RA?function(e,t){if(TA(e)&&!EA(e,"length").writable)throw wA("Cannot set read only .length");return e.length=t}:function(e,t){return e.length=t},LA=r_,UA=bu,VA=Ui,ku=a_,jA=zi("splice"),FA=Math.max,BA=Math.min;xA({target:"Array",proto:!0,forced:!jA},{splice:function(e,t){var n,i,r,o,c,a,s=PA(this),l=MA(s),u=DA(e,l),h=arguments.length;for(h===0?n=i=0:h===1?(n=0,i=l-u):(n=h-2,i=BA(FA(OA(t),0),l-u)),LA(l+n-i),r=UA(s,i),o=0;o<i;o++)(c=u+o)in s&&VA(r,o,s[c]);if(r.length=i,n<i){for(o=u;o<l-i;o++)a=o+n,(c=o+i)in s?s[a]=s[c]:ku(s,a);for(o=l;o>l-i+n;o--)ku(s,o-1)}else if(n>i)for(o=l-i;o>u;o--)a=o+n-1,(c=o+i-1)in s?s[a]=s[c]:ku(s,a);for(o=0;o<n;o++)s[o+u]=arguments[o+2];return NA(s,l-i+n),r}});var HA=Z,Ji=function(e,t){var n=[][e];return!!n&&HA(function(){n.call(null,t||function(){return 1},1)})},WA=Ke.forEach,Iu=Ji("forEach")?[].forEach:function(e){return WA(this,e,arguments.length>1?arguments[1]:void 0)};Y({target:"Array",proto:!0,forced:[].forEach!=Iu},{forEach:Iu});var o_=oe,s_=Nm,GA=Um,Tu=Iu,zA=Ut,c_=function(e){if(e&&e.forEach!==Tu)try{zA(e,"forEach",Tu)}catch{e.forEach=Tu}};for(var wu in s_)s_[wu]&&c_(o_[wu]&&o_[wu].prototype);c_(GA);var JA=Y,qA=Z,KA=Cr,QA=xe,XA=ze,YA=qe,u_=r_,l_=Ui,$A=bu,ZA=zi,ex=br,d_=be("isConcatSpreadable"),tx=ex>=51||!qA(function(){var e=[];return e[d_]=!1,e.concat()[0]!==e}),nx=ZA("concat"),rx=function(e){if(!QA(e))return!1;var t=e[d_];return t!==void 0?!!t:KA(e)};JA({target:"Array",proto:!0,arity:1,forced:!tx||!nx},{concat:function(e){var t,n,i,r,o,c=XA(this),a=$A(c,0),s=0;for(t=-1,i=arguments.length;t<i;t++)if(rx(o=t===-1?c:arguments[t]))for(r=YA(o),u_(s+r),n=0;n<r;n++,s++)n in o&&l_(a,s,o[n]);else u_(s+1),l_(a,s++,o);return a.length=s,a}});var ix=Y,ax=Ei,ox=kt,sx=Ji,cx=$([].join),ux=ax!=Object,lx=sx("join",",");ix({target:"Array",proto:!0,forced:ux||!lx},{join:function(e){return cx(ox(this),e===void 0?",":e)}});var dx=Ke.filter;Y({target:"Array",proto:!0,forced:!zi("filter")},{filter:function(e){return dx(this,e,arguments.length>1?arguments[1]:void 0)}});var h_=$,hx=He,Eu=Date.prototype,p_="Invalid Date",px="toString",fx=h_(Eu.toString),mx=h_(Eu.getTime);String(new Date(NaN))!=p_&&hx(Eu,px,function(){var e=mx(this);return e==e?fx(this):p_});var _x=Tt,vx=Fe,gx=dt,yx=RangeError,f_=function(e){var t=vx(gx(this)),n="",i=_x(e);if(i<0||i==1/0)throw yx("Wrong number of repetitions");for(;i>0;(i>>>=1)&&(t+=t))1&i&&(n+=t);return n},m_=$,Sx=jt,__=Fe,bx=dt,kx=m_(f_),Ix=m_("".slice),Tx=Math.ceil,wx=function(e){return function(t,n,i){var r,o,c=__(bx(t)),a=Sx(n),s=c.length,l=i===void 0?" ":__(i);return a<=s||l==""?c:((o=kx(l,Tx((r=a-s)/l.length))).length>r&&(o=Ix(o,0,r)),e?c+o:o+c)}},Ex={start:wx(!1)},Rx=/Version\/10(?:\.\d+){1,2}(?: [\w./]+)?(?: Mobile\/\w+)? Safari\//.test(Xt),Cx=Ex.start;Y({target:"String",proto:!0,forced:Rx},{padStart:function(e){return Cx(this,e,arguments.length>1?arguments[1]:void 0)}});var Ax=Oe,v_=function(){var e=Ax(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},Ru=Z,Cu=oe.RegExp,Au=Ru(function(){var e=Cu("a","y");return e.lastIndex=2,e.exec("abcd")!=null}),xx=Au||Ru(function(){return!Cu("a","y").sticky}),g_={BROKEN_CARET:Au||Ru(function(){var e=Cu("^r","gy");return e.lastIndex=2,e.exec("str")!=null}),MISSED_STICKY:xx,UNSUPPORTED_Y:Au},Px=Z,Dx=oe.RegExp,y_=Px(function(){var e=Dx(".","s");return!(e.dotAll&&e.exec(`
`)&&e.flags==="s")}),Ox=Z,Mx=oe.RegExp,S_=Ox(function(){var e=Mx("(?<a>b)","g");return e.exec("b").groups.a!=="b"||"b".replace(e,"$<a>c")!=="bc"}),Ar=we,So=$,Nx=Fe,Lx=v_,Ux=g_,Vx=Ka.exports,jx=wr,Fx=Me.get,Bx=y_,Hx=S_,Wx=Vx("native-string-replace",String.prototype.replace),bo=RegExp.prototype.exec,xu=bo,Gx=So("".charAt),zx=So("".indexOf),Jx=So("".replace),Pu=So("".slice),Du=function(){var e=/a/,t=/b*/g;return Ar(bo,e,"a"),Ar(bo,t,"a"),e.lastIndex!==0||t.lastIndex!==0}(),b_=Ux.BROKEN_CARET,Ou=/()??/.exec("")[1]!==void 0;(Du||Ou||b_||Bx||Hx)&&(xu=function(e){var t,n,i,r,o,c,a,s=this,l=Fx(s),u=Nx(e),h=l.raw;if(h)return h.lastIndex=s.lastIndex,t=Ar(xu,h,u),s.lastIndex=h.lastIndex,t;var g=l.groups,b=b_&&s.sticky,T=Ar(Lx,s),k=s.source,p=0,S=u;if(b&&(T=Jx(T,"y",""),zx(T,"g")===-1&&(T+="g"),S=Pu(u,s.lastIndex),s.lastIndex>0&&(!s.multiline||s.multiline&&Gx(u,s.lastIndex-1)!==`
`)&&(k="(?: "+k+")",S=" "+S,p++),n=new RegExp("^(?:"+k+")",T)),Ou&&(n=new RegExp("^"+k+"$(?!\\s)",T)),Du&&(i=s.lastIndex),r=Ar(bo,b?n:s,S),b?r?(r.input=Pu(r.input,p),r[0]=Pu(r[0],p),r.index=s.lastIndex,s.lastIndex+=r[0].length):s.lastIndex=0:Du&&r&&(s.lastIndex=s.global?r.index+r[0].length:i),Ou&&r&&r.length>1&&Ar(Wx,r[0],n,function(){for(o=1;o<arguments.length-2;o++)arguments[o]===void 0&&(r[o]=void 0)}),r&&g)for(r.groups=c=jx(null),o=0;o<g.length;o++)c[(a=g[o])[0]]=r[a[1]];return r});var ko=xu;Y({target:"RegExp",proto:!0,forced:/./.exec!==ko},{exec:ko});var k_=$,I_=He,qx=ko,T_=Z,w_=be,Kx=Ut,Qx=w_("species"),Mu=RegExp.prototype,Nu=function(e,t,n,i){var r=w_(e),o=!T_(function(){var l={};return l[r]=function(){return 7},""[e](l)!=7}),c=o&&!T_(function(){var l=!1,u=/a/;return e==="split"&&((u={}).constructor={},u.constructor[Qx]=function(){return u},u.flags="",u[r]=/./[r]),u.exec=function(){return l=!0,null},u[r](""),!l});if(!o||!c||n){var a=k_(/./[r]),s=t(r,""[e],function(l,u,h,g,b){var T=k_(l),k=u.exec;return k===qx||k===Mu.exec?o&&!b?{done:!0,value:a(u,h,g)}:{done:!0,value:T(h,u,g)}:{done:!1}});I_(String.prototype,e,s[0]),I_(Mu,r,s[1])}i&&Kx(Mu[r],"sham",!0)},Xx=pu.charAt,E_=function(e,t,n){return t+(n?Xx(e,t).length:1)},Lu=$,Yx=ze,$x=Math.floor,Uu=Lu("".charAt),Zx=Lu("".replace),Vu=Lu("".slice),eP=/\$([$&'`]|\d{1,2}|<[^>]*>)/g,tP=/\$([$&'`]|\d{1,2})/g,R_=we,nP=Oe,rP=ge,iP=Kt,aP=ko,oP=TypeError,ju=function(e,t){var n=e.exec;if(rP(n)){var i=R_(n,e,t);return i!==null&&nP(i),i}if(iP(e)==="RegExp")return R_(aP,e,t);throw oP("RegExp#exec called on incompatible receiver")},sP=Jn,C_=we,Io=$,cP=Nu,uP=Z,lP=Oe,dP=ge,hP=Lt,pP=Tt,fP=jt,xr=Fe,mP=dt,_P=E_,vP=Ir,gP=function(e,t,n,i,r,o){var c=n+e.length,a=i.length,s=tP;return r!==void 0&&(r=Yx(r),s=eP),Zx(o,s,function(l,u){var h;switch(Uu(u,0)){case"$":return"$";case"&":return e;case"`":return Vu(t,0,n);case"'":return Vu(t,c);case"<":h=r[Vu(u,1,-1)];break;default:var g=+u;if(g===0)return l;if(g>a){var b=$x(g/10);return b===0?l:b<=a?i[b-1]===void 0?Uu(u,1):i[b-1]+Uu(u,1):l}h=i[g-1]}return h===void 0?"":h})},yP=ju,Fu=be("replace"),SP=Math.max,bP=Math.min,kP=Io([].concat),Bu=Io([].push),A_=Io("".indexOf),x_=Io("".slice),IP="a".replace(/./,"$0")==="$0",P_=!!/./[Fu]&&/./[Fu]("a","$0")==="",TP=!uP(function(){var e=/./;return e.exec=function(){var t=[];return t.groups={a:"7"},t},"".replace(e,"$<a>")!=="7"});cP("replace",function(e,t,n){var i=P_?"$":"$0";return[function(r,o){var c=mP(this),a=hP(r)?void 0:vP(r,Fu);return a?C_(a,r,c,o):C_(t,xr(c),r,o)},function(r,o){var c=lP(this),a=xr(r);if(typeof o=="string"&&A_(o,i)===-1&&A_(o,"$<")===-1){var s=n(t,c,a,o);if(s.done)return s.value}var l=dP(o);l||(o=xr(o));var u=c.global;if(u){var h=c.unicode;c.lastIndex=0}for(var g=[];;){var b=yP(c,a);if(b===null||(Bu(g,b),!u))break;xr(b[0])===""&&(c.lastIndex=_P(a,fP(c.lastIndex),h))}for(var T,k="",p=0,S=0;S<g.length;S++){for(var f=xr((b=g[S])[0]),I=SP(bP(pP(b.index),a.length),0),A=[],x=1;x<b.length;x++)Bu(A,(T=b[x])===void 0?T:String(T));var D=b.groups;if(l){var m=kP([f],A,I,a);D!==void 0&&Bu(m,D);var v=xr(sP(o,void 0,m))}else v=gP(f,a,I,A,D,o);I>=p&&(k+=x_(a,p,I)+v,p=I+f.length)}return k+x_(a,p)}]},!TP||!IP||P_);var wP=we,EP=Le,RP=fn,CP=v_,D_=RegExp.prototype,O_=function(e){var t=e.flags;return t!==void 0||"flags"in D_||EP(e,"flags")||!RP(D_,e)?t:wP(CP,e)},AP=Hn.PROPER,xP=He,PP=Oe,M_=Fe,DP=Z,OP=O_,N_="toString",L_=RegExp.prototype.toString,MP=DP(function(){return L_.call({source:"a",flags:"b"})!="/a/b"}),NP=AP&&L_.name!=N_;(MP||NP)&&xP(RegExp.prototype,N_,function(){var e=PP(this);return"/"+M_(e.source)+"/"+M_(OP(e))},{unsafe:!0});var LP=Z,UP=be("iterator"),U_=!LP(function(){var e=new URL("b?a=1&b=2&c=3","http://a"),t=e.searchParams,n="";return e.pathname="c%20d",t.forEach(function(i,r){t.delete("b"),n+=r+i}),!t.sort||e.href!=="http://a/c%20d?a=1&c=3"||t.get("c")!=="3"||String(new URLSearchParams("?a=1"))!=="a=1"||!t[UP]||new URL("https://a@b").username!=="a"||new URLSearchParams(new URLSearchParams("a=b")).get("a")!=="b"||new URL("http://тест").host!=="xn--e1aybc"||new URL("http://a#б").hash!=="#%D0%B1"||n!=="a1c3"||new URL("http://x",void 0).host!=="x"}),V_=ho,VP=Math.floor,Hu=function(e,t){var n=e.length,i=VP(n/2);return n<8?jP(e,t):FP(e,Hu(V_(e,0,i),t),Hu(V_(e,i),t),t)},jP=function(e,t){for(var n,i,r=e.length,o=1;o<r;){for(i=o,n=e[o];i&&t(e[i-1],n)>0;)e[i]=e[--i];i!==o++&&(e[i]=n)}return e},FP=function(e,t,n,i){for(var r=t.length,o=n.length,c=0,a=0;c<r||a<o;)e[c+a]=c<r&&a<o?i(t[c],n[a])<=0?t[c++]:n[a++]:c<r?t[c++]:n[a++];return e},j_=Hu,Wu=Y,Pr=oe,To=we,Ft=$,BP=Ae,F_=U_,B_=He,HP=Fi,WP=zn,GP=qf,Gu=Me,H_=vn,zu=ge,zP=Le,JP=Zt,qP=Yt,KP=Oe,W_=xe,ot=Fe,QP=wr,G_=Sr,Ju=fo,XP=Vi,Dr=go,YP=j_,$P=be("iterator"),wo="URLSearchParams",z_="URLSearchParamsIterator",J_=Gu.set,wt=Gu.getterFor(wo),ZP=Gu.getterFor(z_),eD=Object.getOwnPropertyDescriptor,qu=function(e){if(!BP)return Pr[e];var t=eD(Pr,e);return t&&t.value},q_=qu("fetch"),Eo=qu("Request"),qi=qu("Headers"),Ku=Eo&&Eo.prototype,K_=qi&&qi.prototype,tD=Pr.RegExp,nD=Pr.TypeError,Q_=Pr.decodeURIComponent,rD=Pr.encodeURIComponent,iD=Ft("".charAt),X_=Ft([].join),Kn=Ft([].push),Qu=Ft("".replace),aD=Ft([].shift),Y_=Ft([].splice),$_=Ft("".split),oD=Ft("".slice),sD=/\+/g,Z_=Array(4),cD=function(e){return Z_[e-1]||(Z_[e-1]=tD("((?:%[\\da-f]{2}){"+e+"})","gi"))},uD=function(e){try{return Q_(e)}catch{return e}},ev=function(e){var t=Qu(e,sD," "),n=4;try{return Q_(t)}catch{for(;n;)t=Qu(t,cD(n--),uD);return t}},lD=/[!'()~]|%20/g,dD={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+"},hD=function(e){return dD[e]},tv=function(e){return Qu(rD(e),lD,hD)},Xu=GP(function(e,t){J_(this,{type:z_,iterator:Ju(wt(e).entries),kind:t})},"Iterator",function(){var e=ZP(this),t=e.kind,n=e.iterator.next(),i=n.value;return n.done||(n.value=t==="keys"?i.key:t==="values"?i.value:[i.key,i.value]),n},!0),nv=function(e){this.entries=[],this.url=null,e!==void 0&&(W_(e)?this.parseObject(e):this.parseQuery(typeof e=="string"?iD(e,0)==="?"?oD(e,1):e:ot(e)))};nv.prototype={type:wo,bindURL:function(e){this.url=e,this.update()},parseObject:function(e){var t,n,i,r,o,c,a,s=XP(e);if(s)for(n=(t=Ju(e,s)).next;!(i=To(n,t)).done;){if(o=(r=Ju(KP(i.value))).next,(c=To(o,r)).done||(a=To(o,r)).done||!To(o,r).done)throw nD("Expected sequence with length 2");Kn(this.entries,{key:ot(c.value),value:ot(a.value)})}else for(var l in e)zP(e,l)&&Kn(this.entries,{key:l,value:ot(e[l])})},parseQuery:function(e){if(e)for(var t,n,i=$_(e,"&"),r=0;r<i.length;)(t=i[r++]).length&&(n=$_(t,"="),Kn(this.entries,{key:ev(aD(n)),value:ev(X_(n,"="))}))},serialize:function(){for(var e,t=this.entries,n=[],i=0;i<t.length;)e=t[i++],Kn(n,tv(e.key)+"="+tv(e.value));return X_(n,"&")},update:function(){this.entries.length=0,this.parseQuery(this.url.query)},updateURL:function(){this.url&&this.url.update()}};var Ro=function(){H_(this,Ki);var e=arguments.length>0?arguments[0]:void 0;J_(this,new nv(e))},Ki=Ro.prototype;if(HP(Ki,{append:function(e,t){Dr(arguments.length,2);var n=wt(this);Kn(n.entries,{key:ot(e),value:ot(t)}),n.updateURL()},delete:function(e){Dr(arguments.length,1);for(var t=wt(this),n=t.entries,i=ot(e),r=0;r<n.length;)n[r].key===i?Y_(n,r,1):r++;t.updateURL()},get:function(e){Dr(arguments.length,1);for(var t=wt(this).entries,n=ot(e),i=0;i<t.length;i++)if(t[i].key===n)return t[i].value;return null},getAll:function(e){Dr(arguments.length,1);for(var t=wt(this).entries,n=ot(e),i=[],r=0;r<t.length;r++)t[r].key===n&&Kn(i,t[r].value);return i},has:function(e){Dr(arguments.length,1);for(var t=wt(this).entries,n=ot(e),i=0;i<t.length;)if(t[i++].key===n)return!0;return!1},set:function(e,t){Dr(arguments.length,1);for(var n,i=wt(this),r=i.entries,o=!1,c=ot(e),a=ot(t),s=0;s<r.length;s++)(n=r[s]).key===c&&(o?Y_(r,s--,1):(o=!0,n.value=a));o||Kn(r,{key:c,value:a}),i.updateURL()},sort:function(){var e=wt(this);YP(e.entries,function(t,n){return t.key>n.key?1:-1}),e.updateURL()},forEach:function(e){for(var t,n=wt(this).entries,i=JP(e,arguments.length>1?arguments[1]:void 0),r=0;r<n.length;)i((t=n[r++]).value,t.key,this)},keys:function(){return new Xu(this,"keys")},values:function(){return new Xu(this,"values")},entries:function(){return new Xu(this,"entries")}},{enumerable:!0}),B_(Ki,$P,Ki.entries,{name:"entries"}),B_(Ki,"toString",function(){return wt(this).serialize()},{enumerable:!0}),WP(Ro,wo),Wu({global:!0,constructor:!0,forced:!F_},{URLSearchParams:Ro}),!F_&&zu(qi)){var pD=Ft(K_.has),fD=Ft(K_.set),rv=function(e){if(W_(e)){var t,n=e.body;if(qP(n)===wo)return t=e.headers?new qi(e.headers):new qi,pD(t,"content-type")||fD(t,"content-type","application/x-www-form-urlencoded;charset=UTF-8"),QP(e,{body:G_(0,ot(n)),headers:G_(0,t)})}return e};if(zu(q_)&&Wu({global:!0,enumerable:!0,dontCallGetSet:!0,forced:!0},{fetch:function(e){return q_(e,arguments.length>1?rv(arguments[1]):{})}}),zu(Eo)){var Yu=function(e){return H_(this,Ku),new Eo(e,arguments.length>1?rv(arguments[1]):{})};Ku.constructor=Yu,Yu.prototype=Ku,Wu({global:!0,constructor:!0,dontCallGetSet:!0,forced:!0},{Request:Yu})}}var mD={URLSearchParams:Ro,getState:wt},_D=Object.is||function(e,t){return e===t?e!==0||1/e==1/t:e!=e&&t!=t},vD=we,gD=Oe,yD=Lt,SD=dt,iv=_D,av=Fe,bD=Ir,kD=ju;Nu("search",function(e,t,n){return[function(i){var r=SD(this),o=yD(i)?void 0:bD(i,e);return o?vD(o,i,r):new RegExp(i)[e](av(r))},function(i){var r=gD(this),o=av(i),c=n(t,r,o);if(c.done)return c.value;var a=r.lastIndex;iv(a,0)||(r.lastIndex=0);var s=kD(r,o);return iv(r.lastIndex,a)||(r.lastIndex=a),s===null?-1:s.index}]}),new Date().getTime();var $u=0,Qe=function(){return new Date().getTime()+$u},ov=function(){var e=new Date;return e.setTime(Qe()),e.toLocaleString()},ID=we,TD=Oe,wD=Lt,ED=jt,Zu=Fe,RD=dt,CD=Ir,AD=E_,sv=ju;Nu("match",function(e,t,n){return[function(i){var r=RD(this),o=wD(i)?void 0:CD(i,e);return o?ID(o,i,r):new RegExp(i)[e](Zu(r))},function(i){var r=TD(this),o=Zu(i),c=n(t,r,o);if(c.done)return c.value;if(!r.global)return sv(r,o);var a=r.unicode;r.lastIndex=0;for(var s,l=[],u=0;(s=sv(r,o))!==null;){var h=Zu(s[0]);l[u]=h,h===""&&(r.lastIndex=AD(o,ED(r.lastIndex),a)),u++}return u===0?null:l}]});var xD=xe,PD=Kt,DD=be("match"),cv=function(e){var t;return xD(e)&&((t=e[DD])!==void 0?!!t:PD(e)=="RegExp")},OD=Ve.f,MD=Ae,el=oe,Qi=$,ND=Pi,LD=vo,UD=Ut,VD=mn.f,uv=fn,jD=cv,lv=Fe,FD=O_,dv=g_,BD=function(e,t,n){n in e||OD(e,n,{configurable:!0,get:function(){return t[n]},set:function(i){t[n]=i}})},HD=He,WD=Z,GD=Le,zD=Me.enforce,JD=Bi,hv=y_,pv=S_,qD=be("match"),gn=el.RegExp,Or=gn.prototype,KD=el.SyntaxError,QD=Qi(Or.exec),Co=Qi("".charAt),fv=Qi("".replace),mv=Qi("".indexOf),XD=Qi("".slice),YD=/^\?<[^\s\d!#%&*+<=>@^][^\s!#%&*+<=>@^]*>/,Qn=/a/g,tl=/a/g,$D=new gn(Qn)!==Qn,_v=dv.MISSED_STICKY,ZD=dv.UNSUPPORTED_Y,eO=MD&&(!$D||_v||hv||pv||WD(function(){return tl[qD]=!1,gn(Qn)!=Qn||gn(tl)==tl||gn(Qn,"i")!="/a/i"}));if(ND("RegExp",eO)){for(var Xn=function(e,t){var n,i,r,o,c,a,s=uv(Or,this),l=jD(e),u=t===void 0,h=[],g=e;if(!s&&l&&u&&e.constructor===Xn)return e;if((l||uv(Or,e))&&(e=e.source,u&&(t=FD(g))),e=e===void 0?"":lv(e),t=t===void 0?"":lv(t),g=e,hv&&"dotAll"in Qn&&(i=!!t&&mv(t,"s")>-1)&&(t=fv(t,/s/g,"")),n=t,_v&&"sticky"in Qn&&(r=!!t&&mv(t,"y")>-1)&&ZD&&(t=fv(t,/y/g,"")),pv&&(o=function(b){for(var T,k=b.length,p=0,S="",f=[],I={},A=!1,x=!1,D=0,m="";p<=k;p++){if((T=Co(b,p))==="\\")T+=Co(b,++p);else if(T==="]")A=!1;else if(!A)switch(!0){case T==="[":A=!0;break;case T==="(":QD(YD,XD(b,p+1))&&(p+=2,x=!0),S+=T,D++;continue;case(T===">"&&x):if(m===""||GD(I,m))throw new KD("Invalid capture group name");I[m]=!0,f[f.length]=[m,D],x=!1,m="";continue}x?m+=T:S+=T}return[S,f]}(e),e=o[0],h=o[1]),c=LD(gn(e,t),s?this:Or,Xn),(i||r||h.length)&&(a=zD(c),i&&(a.dotAll=!0,a.raw=Xn(function(b){for(var T,k=b.length,p=0,S="",f=!1;p<=k;p++)(T=Co(b,p))!=="\\"?f||T!=="."?(T==="["?f=!0:T==="]"&&(f=!1),S+=T):S+="[\\s\\S]":S+=T+Co(b,++p);return S}(e),n)),r&&(a.sticky=!0),h.length&&(a.groups=h)),e!==g)try{UD(c,"source",g===""?"(?:)":g)}catch{}return c},vv=VD(gn),gv=0;vv.length>gv;)BD(Xn,gn,vv[gv++]);Or.constructor=Xn,Xn.prototype=Or,HD(el,"RegExp",Xn,{constructor:!0})}JD("RegExp");var yv=$(1 .valueOf),Sv=`
\v\f\r    \u2028\u2029\uFEFF`,tO=dt,nO=Fe,bv=$("".replace),Ao=`[
\v\f\r    \u2028\u2029\uFEFF]`,rO=RegExp("^"+Ao+Ao+"*"),iO=RegExp(Ao+Ao+"*$"),aO=function(e){return function(t){var n=nO(tO(t));return 1&e&&(n=bv(n,rO,"")),2&e&&(n=bv(n,iO,"")),n}},xo={trim:aO(3)},oO=Ae,nl=oe,kv=$,sO=Pi,cO=He,Iv=Le,uO=vo,lO=fn,dO=qa,Tv=Xa,hO=Z,pO=mn.f,fO=hn.f,mO=Ve.f,_O=yv,vO=xo.trim,wv="Number",yn=nl.Number,rl=yn.prototype,gO=nl.TypeError,yO=kv("".slice),Po=kv("".charCodeAt),SO=function(e){var t=Tv(e,"number");return typeof t=="bigint"?t:bO(t)},bO=function(e){var t,n,i,r,o,c,a,s,l=Tv(e,"number");if(dO(l))throw gO("Cannot convert a Symbol value to a number");if(typeof l=="string"&&l.length>2){if(l=vO(l),(t=Po(l,0))===43||t===45){if((n=Po(l,2))===88||n===120)return NaN}else if(t===48){switch(Po(l,1)){case 66:case 98:i=2,r=49;break;case 79:case 111:i=8,r=55;break;default:return+l}for(c=(o=yO(l,2)).length,a=0;a<c;a++)if((s=Po(o,a))<48||s>r)return NaN;return parseInt(o,i)}}return+l};if(sO(wv,!yn(" 0o1")||!yn("0b1")||yn("+0x1"))){for(var Do,Mr=function(e){var t=arguments.length<1?0:yn(SO(e)),n=this;return lO(rl,n)&&hO(function(){_O(n)})?uO(Object(t),n,Mr):t},Ev=oO?pO(yn):"MAX_VALUE,MIN_VALUE,NaN,NEGATIVE_INFINITY,POSITIVE_INFINITY,EPSILON,MAX_SAFE_INTEGER,MIN_SAFE_INTEGER,isFinite,isInteger,isNaN,isSafeInteger,parseFloat,parseInt,fromString,range".split(","),il=0;Ev.length>il;il++)Iv(yn,Do=Ev[il])&&!Iv(Mr,Do)&&mO(Mr,Do,fO(yn,Do));Mr.prototype=rl,rl.constructor=Mr,cO(nl,wv,Mr,{constructor:!0})}var kO=Ai.includes,IO=co;Y({target:"Array",proto:!0,forced:Z(function(){return!Array(1).includes()})},{includes:function(e){return kO(this,e,arguments.length>1?arguments[1]:void 0)}}),IO("includes");var TO=cv,wO=TypeError,Rv=function(e){if(TO(e))throw wO("The method doesn't accept regular expressions");return e},EO=be("match"),Cv=function(e){var t=/./;try{"/./"[e](t)}catch{try{return t[EO]=!1,"/./"[e](t)}catch{}}return!1},RO=Y,CO=Rv,AO=dt,Av=Fe,xO=Cv,PO=$("".indexOf);RO({target:"String",proto:!0,forced:!xO("includes")},{includes:function(e){return!!~PO(Av(AO(this)),Av(CO(e)),arguments.length>1?arguments[1]:void 0)}});var DO=Y,OO=Ai.indexOf,MO=Ji,al=$([].indexOf),xv=!!al&&1/al([1],1,-0)<0,NO=MO("indexOf");DO({target:"Array",proto:!0,forced:xv||!NO},{indexOf:function(e){var t=arguments.length>1?arguments[1]:void 0;return xv?al(this,e,t)||0:OO(this,e,t)}});var LO=ze,Pv=Oi,UO=Hf;Y({target:"Object",stat:!0,forced:Z(function(){Pv(1)}),sham:!UO},{getPrototypeOf:function(e){return Pv(LO(e))}});var VO=Jn,jO=It,FO=Oe;Y({target:"Reflect",stat:!0,forced:!Z(function(){Reflect.apply(function(){})})},{apply:function(e,t,n){return VO(jO(e),t,FO(n))}});var BO=Ae,HO=Hn.EXISTS,Dv=$,WO=Ve.f,Ov=Function.prototype,GO=Dv(Ov.toString),Mv=/function\b(?:\s|\/\*[\S\s]*?\*\/|\/\/[^\n\r]*[\n\r]+)*([^\s(/]*)/,zO=Dv(Mv.exec);BO&&!HO&&WO(Ov,"name",{configurable:!0,get:function(){try{return zO(Mv,GO(this))[1]}catch{return""}}});var JO=Y,Nv=Date,qO=$(Nv.prototype.getTime);JO({target:"Date",stat:!0},{now:function(){return qO(new Nv)}});var Xi,Nr,Lv,ol,Yi=Kt(oe.process)=="process",KO=yo,QO=kr,XO=TypeError,Uv=function(e){if(KO(e))return e;throw XO(QO(e)+" is not a constructor")},Vv=Oe,YO=Uv,$O=Lt,ZO=be("species"),Oo=function(e,t){var n,i=Vv(e).constructor;return i===void 0||$O(n=Vv(i)[ZO])?t:YO(n)},jv=/(?:ipad|iphone|ipod).*applewebkit/i.test(Xt),st=oe,e2=Jn,t2=Zt,Fv=ge,n2=Le,r2=Z,Bv=Nf,i2=Rr,Hv=$a,a2=go,o2=jv,s2=Yi,sl=st.setImmediate,Wv=st.clearImmediate,c2=st.process,cl=st.Dispatch,u2=st.Function,Gv=st.MessageChannel,l2=st.String,ul=0,$i={},d2="onreadystatechange";try{Xi=st.location}catch{}var ll=function(e){if(n2($i,e)){var t=$i[e];delete $i[e],t()}},dl=function(e){return function(){ll(e)}},zv=function(e){ll(e.data)},Jv=function(e){st.postMessage(l2(e),Xi.protocol+"//"+Xi.host)};sl&&Wv||(sl=function(e){a2(arguments.length,1);var t=Fv(e)?e:u2(e),n=i2(arguments,1);return $i[++ul]=function(){e2(t,void 0,n)},Nr(ul),ul},Wv=function(e){delete $i[e]},s2?Nr=function(e){c2.nextTick(dl(e))}:cl&&cl.now?Nr=function(e){cl.now(dl(e))}:Gv&&!o2?(ol=(Lv=new Gv).port2,Lv.port1.onmessage=zv,Nr=t2(ol.postMessage,ol)):st.addEventListener&&Fv(st.postMessage)&&!st.importScripts&&Xi&&Xi.protocol!=="file:"&&!r2(Jv)?(Nr=Jv,st.addEventListener("message",zv,!1)):Nr=d2 in Hv("script")?function(e){Bv.appendChild(Hv("script")).onreadystatechange=function(){Bv.removeChild(this),ll(e)}}:function(e){setTimeout(dl(e),0)});var Zi,Yn,ea,Lr,hl,pl,fl,qv,Kv={set:sl},h2=oe,p2=/ipad|iphone|ipod/i.test(Xt)&&h2.Pebble!==void 0,f2=/web0s(?!.*chrome)/i.test(Xt),$n=oe,Qv=Zt,m2=hn.f,ml=Kv.set,_2=jv,v2=p2,g2=f2,_l=Yi,Xv=$n.MutationObserver||$n.WebKitMutationObserver,Yv=$n.document,$v=$n.process,Mo=$n.Promise,Zv=m2($n,"queueMicrotask"),eg=Zv&&Zv.value;eg||(Zi=function(){var e,t;for(_l&&(e=$v.domain)&&e.exit();Yn;){t=Yn.fn,Yn=Yn.next;try{t()}catch(n){throw Yn?Lr():ea=void 0,n}}ea=void 0,e&&e.enter()},_2||_l||g2||!Xv||!Yv?!v2&&Mo&&Mo.resolve?((fl=Mo.resolve(void 0)).constructor=Mo,qv=Qv(fl.then,fl),Lr=function(){qv(Zi)}):_l?Lr=function(){$v.nextTick(Zi)}:(ml=Qv(ml,$n),Lr=function(){ml(Zi)}):(hl=!0,pl=Yv.createTextNode(""),new Xv(Zi).observe(pl,{characterData:!0}),Lr=function(){pl.data=hl=!hl}));var y2=eg||function(e){var t={fn:e,next:void 0};ea&&(ea.next=t),Yn||(Yn=t,Lr()),ea=t},S2=oe,vl=function(e){try{return{error:!1,value:e()}}catch(t){return{error:!0,value:t}}},tg=function(){this.head=null,this.tail=null};tg.prototype={add:function(e){var t={item:e,next:null};this.head?this.tail.next=t:this.head=t,this.tail=t},get:function(){var e=this.head;if(e)return this.head=e.next,this.tail===e&&(this.tail=null),e.item}};var b2=tg,ta=oe.Promise,ng=typeof Deno=="object"&&Deno&&typeof Deno.version=="object",k2=!ng&&!Yi&&typeof window=="object"&&typeof document=="object",I2=oe,na=ta,T2=ge,w2=Pi,E2=Nc,R2=be,C2=k2,A2=ng,gl=br;na&&na.prototype;var x2=R2("species"),rg=!1,ig=T2(I2.PromiseRejectionEvent),P2=w2("Promise",function(){var e=E2(na),t=e!==String(na);if(!t&&gl===66)return!0;if(!gl||gl<51||!/native code/.test(e)){var n=new na(function(r){r(1)}),i=function(r){r(function(){},function(){})};if((n.constructor={})[x2]=i,!(rg=n.then(function(){})instanceof i))return!0}return!t&&(C2||A2)&&!ig}),Zn={CONSTRUCTOR:P2,REJECTION_EVENT:ig,SUBCLASSING:rg},Ur={},ag=It,D2=TypeError,O2=function(e){var t,n;this.promise=new e(function(i,r){if(t!==void 0||n!==void 0)throw D2("Bad Promise constructor");t=i,n=r}),this.resolve=ag(t),this.reject=ag(n)};Ur.f=function(e){return new O2(e)};var yl,og,sg,M2=Y,No=Yi,Sn=oe,Vr=we,cg=He,ug=Er,N2=zn,L2=Bi,U2=It,Lo=ge,V2=xe,j2=vn,F2=Oo,lg=Kv.set,Sl=y2,B2=function(e,t){var n=S2.console;n&&n.error&&(arguments.length==1?n.error(e):n.error(e,t))},H2=vl,W2=b2,dg=Me,Uo=ta,hg=Ur,Vo="Promise",pg=Zn.CONSTRUCTOR,G2=Zn.REJECTION_EVENT,z2=Zn.SUBCLASSING,bl=dg.getterFor(Vo),J2=dg.set,jr=Uo&&Uo.prototype,Fr=Uo,jo=jr,fg=Sn.TypeError,kl=Sn.document,Il=Sn.process,Tl=hg.f,q2=Tl,K2=!!(kl&&kl.createEvent&&Sn.dispatchEvent),mg="unhandledrejection",_g=function(e){var t;return!(!V2(e)||!Lo(t=e.then))&&t},vg=function(e,t){var n,i,r,o=t.value,c=t.state==1,a=c?e.ok:e.fail,s=e.resolve,l=e.reject,u=e.domain;try{a?(c||(t.rejection===2&&X2(t),t.rejection=1),a===!0?n=o:(u&&u.enter(),n=a(o),u&&(u.exit(),r=!0)),n===e.promise?l(fg("Promise-chain cycle")):(i=_g(n))?Vr(i,n,s,l):s(n)):l(o)}catch(h){u&&!r&&u.exit(),l(h)}},gg=function(e,t){e.notified||(e.notified=!0,Sl(function(){for(var n,i=e.reactions;n=i.get();)vg(n,e);e.notified=!1,t&&!e.rejection&&Q2(e)}))},yg=function(e,t,n){var i,r;K2?((i=kl.createEvent("Event")).promise=t,i.reason=n,i.initEvent(e,!1,!0),Sn.dispatchEvent(i)):i={promise:t,reason:n},!G2&&(r=Sn["on"+e])?r(i):e===mg&&B2("Unhandled promise rejection",n)},Q2=function(e){Vr(lg,Sn,function(){var t,n=e.facade,i=e.value;if(Sg(e)&&(t=H2(function(){No?Il.emit("unhandledRejection",i,n):yg(mg,n,i)}),e.rejection=No||Sg(e)?2:1,t.error))throw t.value})},Sg=function(e){return e.rejection!==1&&!e.parent},X2=function(e){Vr(lg,Sn,function(){var t=e.facade;No?Il.emit("rejectionHandled",t):yg("rejectionhandled",t,e.value)})},Br=function(e,t,n){return function(i){e(t,i,n)}},Hr=function(e,t,n){e.done||(e.done=!0,n&&(e=n),e.value=t,e.state=2,gg(e,!0))},wl=function(e,t,n){if(!e.done){e.done=!0,n&&(e=n);try{if(e.facade===t)throw fg("Promise can't be resolved itself");var i=_g(t);i?Sl(function(){var r={done:!1};try{Vr(i,t,Br(wl,r,e),Br(Hr,r,e))}catch(o){Hr(r,o,e)}}):(e.value=t,e.state=1,gg(e,!1))}catch(r){Hr({done:!1},r,e)}}};if(pg&&(jo=(Fr=function(e){j2(this,jo),U2(e),Vr(yl,this);var t=bl(this);try{e(Br(wl,t),Br(Hr,t))}catch(n){Hr(t,n)}}).prototype,(yl=function(e){J2(this,{type:Vo,done:!1,notified:!1,parent:!1,reactions:new W2,rejection:!1,state:0,value:void 0})}).prototype=cg(jo,"then",function(e,t){var n=bl(this),i=Tl(F2(this,Fr));return n.parent=!0,i.ok=!Lo(e)||e,i.fail=Lo(t)&&t,i.domain=No?Il.domain:void 0,n.state==0?n.reactions.add(i):Sl(function(){vg(i,n)}),i.promise}),og=function(){var e=new yl,t=bl(e);this.promise=e,this.resolve=Br(wl,t),this.reject=Br(Hr,t)},hg.f=Tl=function(e){return e===Fr||e===void 0?new og(e):q2(e)},Lo(Uo)&&jr!==Object.prototype)){sg=jr.then,z2||cg(jr,"then",function(e,t){var n=this;return new Fr(function(i,r){Vr(sg,n,i,r)}).then(e,t)},{unsafe:!0});try{delete jr.constructor}catch{}ug&&ug(jr,jo)}M2({global:!0,constructor:!0,wrap:!0,forced:pg},{Promise:Fr}),N2(Fr,Vo,!1),L2(Vo);var Y2=ta,bg=Zn.CONSTRUCTOR||!_o(function(e){Y2.all(e).then(void 0,function(){})}),$2=we,Z2=It,eM=Ur,tM=vl,nM=ji;Y({target:"Promise",stat:!0,forced:bg},{all:function(e){var t=this,n=eM.f(t),i=n.resolve,r=n.reject,o=tM(function(){var c=Z2(t.resolve),a=[],s=0,l=1;nM(e,function(u){var h=s++,g=!1;l++,$2(c,t,u).then(function(b){g||(g=!0,a[h]=b,--l||i(a))},r)}),--l||i(a)});return o.error&&r(o.value),n.promise}});var rM=Y,iM=Zn.CONSTRUCTOR,El=ta,aM=Qt,oM=ge,sM=He,kg=El&&El.prototype;if(rM({target:"Promise",proto:!0,forced:iM,real:!0},{catch:function(e){return this.then(void 0,e)}}),oM(El)){var Ig=aM("Promise").prototype.catch;kg.catch!==Ig&&sM(kg,"catch",Ig,{unsafe:!0})}var cM=we,uM=It,lM=Ur,dM=vl,hM=ji;Y({target:"Promise",stat:!0,forced:bg},{race:function(e){var t=this,n=lM.f(t),i=n.reject,r=dM(function(){var o=uM(t.resolve);hM(e,function(c){cM(o,t,c).then(n.resolve,i)})});return r.error&&i(r.value),n.promise}});var pM=we,fM=Ur;Y({target:"Promise",stat:!0,forced:Zn.CONSTRUCTOR},{reject:function(e){var t=fM.f(this);return pM(t.reject,void 0,e),t.promise}});var mM=Oe,_M=xe,vM=Ur,Tg=function(e,t){if(mM(e),_M(t)&&t.constructor===e)return t;var n=vM.f(e);return(0,n.resolve)(t),n.promise},gM=Y,yM=Zn.CONSTRUCTOR,SM=Tg;Qt("Promise"),gM({target:"Promise",stat:!0,forced:yM},{resolve:function(e){return SM(this,e)}});var bM=ze,wg=ao;Y({target:"Object",stat:!0,forced:Z(function(){wg(1)})},{keys:function(e){return wg(bM(e))}});var Eg="canvas",K="audio",q="video",Rl="screen",en="small",Fo="big",ke="auxiliary",ht="aux",Bo="smallVideo",Rg="user",Cg="environment",Je="mute",Bt="unmute",Ue="ended",bn="playing",kn="pause",Wr="error",Cl="loadeddata",ra="audioinput",Ho="videoinput",Ag="detail",kM="text",le="main",Et="backup",IM="banned",TM="kick",wM="user_time_out",EM="room_disband",xg="sei-message",Gr="PLAYING",Ht="PAUSED",In="STOPPED",zr="inactive",Tn="sendonly",Al="recvonly",Pg="add",Dg="remove",RM="replace",xl="track",CM="wss://trtc.rtc.qq.com",AM="wss://webrtc.qq.com",Wo="qcloud",xM="trtc",PM="webrtc",ia="",Og="jssdk_log",DM="jssdk_event",OM="jssdk_new_endreport",Pl=function(e){return ia=e},MM=1,NM=2,Go="live",Jr=20,Dl=21,Wt="anchor",er="audience",Gt="5Y2wZK8nANNAoVw6dSAHVjNxrD1ObBM2kBPV",aa="224d130c-7b5c-415b-aaa2-79c2eb5a6df2",LM=2,Te=le,Ne=ke,zo="unknown",Xe="DISCONNECTED",Mg="CONNECTING",Ol="RECONNECTING",Ye="CONNECTED",UM="new",Jo="connecting",Ng="failed",Ml="closed",VM="disconnected",Lg="connected",jM="completed",Nl=30,Ug="join",FM="delta-join",Vg="rejoin",BM="leave",HM="delta-leave",jg="publish",WM="delta-publish",Fg="unpublish",Bg="subscribe",Hg="unsubscribe",Wg="uplink-connection",Gg="uplink-reconnection",zg="downlink-connection",Jg="downlink-reconnection",qo="setLocalDescription",qg="setRemoteDescription",Kg="iceConnectionState",oa="stream-initialize",Ll="websocketConnectionState",Qg="websocketReconnectionState",Xg="update-stream",Yg="recover-subscription",$g="start-mix-transcode",Zg="stop-mix-transcode",ey="player-error",ty="schedule",Ul="unsubscribe",Vl="subscribe_change",sa="unified-plan",jl="plan-b",Fl={MANUAL:"manual",PRESET_LAYOUT:"preset-layout"},ny={REMOTE:"$PLACE_HOLDER_REMOTE$"},ry={IT_AUDIO_VIDEO:0,IT_PURE_AUDIO:4},me="string",Pe="number",Be="boolean",iy="array",ct="object",$e={ADD:Pg,REMOVE:Dg},Bl={unknown:0,wifi:1,"4g":2,"3g":3,"2g":4,wired:5},ay=-1,ca=0,GM=1,oy=Fo,sy=en,cy=6048e5,zM="schedule.cloud-rtc.com",JM="schedule.rtc.qcloud.com",qM="schedule.rtc.tencentcloud.com",KM="schedule-ecdn.rtc.tencentcloud.com",Hl="",uy=function(e){return Hl=e},ua="TRTC",Ze="Client",wn="LocalStream",Wl="RemoteStream",QM="Stream",Gl="web.sdk.qcloud.com",ly="web.sdk.tencent.cn",dy="web.sdk.cloud.tencent.cn",hy="https://console.cloud.tencent.com/trtc",qr="https://".concat(Gl,"/trtc/webrtc/doc"),zl="".concat(qr,"/zh-cn/"),Jl="trtc_error_assistance",Ko="default",py="communications",pt={TRACE:0,DEBUG:1,INFO:2,WARN:3,ERROR:4,NONE:5},XM=1,fy=2,YM=1,my=2,tr=Object.keys(pt),$M=["normal leave","timeout leave","kick","role change"],Qo=2e3,Kr="ric",Xo="raf",ZM="interval",_y="timeout",vy="Resolution reset to 1080p, need to upgrade ability here https://cloud.tencent.com/document/product/647/85386",eN={"TRTC.checkSystemRequirements":40001,"TRTC.isScreenShareSupported":40002,"TRTC.isSmallStreamSupported":40003,"TRTC.createClient.rtc":40004,"TRTC.createClient.live":40005,"TRTC.createClient.intRoomId":40006,"TRTC.createClient.stringRoomId":40007,"TRTC.createClient.autoSubscribe":40008,"TRTC.createClient.manualSubscribe":40009,"TRTC.enableUploadLog":40010,"TRTC.disableUploadLog":40011,"Client.publish":40012,"Client.publish.isAuxiliary":40013,"Client.switchRole":40014,"Client.startPublishCDNStream":40015,"Client.stopPublishCDNStream":40016,"Client.startMixTranscode":40017,"Client.stopMixTranscode":40018,"Client.enableAudioVolumeEvaluation":40019,"Client.enableSmallStream":40020,"Client.disableSmallStream":40021,"Client.setSmallStreamProfile":40022,"Client.setRemoteVideoStreamType":40023,"Client.sendSEIMessage":40024,"Client.setProxyServer":40025,"Client.setTurnServer":40026,"LocalStream.setAudioProfile.standard":40027,"LocalStream.setAudioProfile.high":40028,"LocalStream.setAudioProfile.standard-stereo":40029,"LocalStream.setAudioProfile.high-stereo":40030,"LocalStream.setVideoProfile.120p":40031,"LocalStream.setVideoProfile.120p_2":40032,"LocalStream.setVideoProfile.180p":40033,"LocalStream.setVideoProfile.180p_2":40034,"LocalStream.setVideoProfile.240p":40035,"LocalStream.setVideoProfile.240p_2":40036,"LocalStream.setVideoProfile.360p":40037,"LocalStream.setVideoProfile.360p_2":40038,"LocalStream.setVideoProfile.480p":40039,"LocalStream.setVideoProfile.480p_2":40040,"LocalStream.setVideoProfile.720p":40041,"LocalStream.setVideoProfile.1080p":40042,"LocalStream.setVideoProfile.1440p":40043,"LocalStream.setVideoProfile.4K":40044,"LocalStream.setScreenProfile.480p":40045,"LocalStream.setScreenProfile.480p_2":40046,"LocalStream.setScreenProfile.720p":40047,"LocalStream.setScreenProfile.720p_2":40048,"LocalStream.setScreenProfile.1080p":40049,"LocalStream.setScreenProfile.1080p_2":40050,"LocalStream.setVideoContentHint.motion":40051,"LocalStream.setVideoContentHint.detail":40052,"LocalStream.setVideoContentHint.text":40053,"LocalStream.setAudioCaptureVolume":40054,"LocalStream.getVideoFrame":40055,"RemoteStream.setAudioOutput":40056,"RemoteStream.getVideoFrame":40057,AI_DENOISER:1700,SPATIAL_AUDIO:1701,"2K_4K":1704},ql=["width","height","frameRate","facingMode","sampleRate","sampleSize","channelCount","deviceId"],tN=dt,gy=Fe,nN=/"/g,rN=$("".replace),yy=function(e,t,n,i){var r=gy(tN(e)),o="<"+t;return n!==""&&(o+=" "+n+'="'+rN(gy(i),nN,"&quot;")+'"'),o+">"+r+"</"+t+">"},iN=Z,Sy=function(e){return iN(function(){var t=""[e]('"');return t!==t.toLowerCase()||t.split('"').length>3})},aN=yy;Y({target:"String",proto:!0,forced:Sy("link")},{link:function(e){return aN(this,"a","href",e)}}),Y({target:"Array",stat:!0},{isArray:Cr});var oN="AVOID_REPEATED_CALL",sN="INVALID_PARAMETER_REQUIRED",by="INVALID_PARAMETER_TYPE",cN="INVALID_PARAMETER_EMPTY",ky="INVALID_PARAMETER_INSTANCE",uN="INVALID_PARAMETER_RANGE",lN="API_CALL_TIMEOUT",dN="SIGNAL_CHANNEL_RECONNECTION_FAILED",hN="SIGNAL_CHANNEL_SETUP_FAILED",pN="ERROR_MESSAGE",fN="EXCHANGE_SDP_TIMEOUT",mN="DOWNLINK_RECONNECTION_FAILED",_N="EXCHANGE_SDP_FAILED",vN="UPLINK_RECONNECTION_FAILED",gN="INVALID_PURE_AUDIO",yN="INVALID_STREAMID",SN="INVALID_USER_DEFINE_RECORDID",bN="INVALID_USER_DEFINE_PUSH_ARGS",kN="INVALID_PROXY",IN="INVALID_JOIN",TN="INVALID_ROOMID_STRING",wN="INVALID_ROOMID_INTEGER",EN="JOIN_ROOM_TIMEOUT",Iy="JOIN_ROOM_FAILED",RN="REJOIN_ROOM_FAILED",CN="INVALID_DESTROY",AN="INVALID_PUBLISH",xN="INVALID_UNPUBLISH",PN="INVALID_AUDIENCE",DN="INVALID_INITIALIZE",ON="INVALID_DUPLICATE_PUBLISHING",Kl="INVALID_REMOTE_STREAM",MN="SUBSCRIBE_FAILED",NN="INVALID_ROLE",LN="INVALID_OPERATION_SWITCH_ROLE",UN="SWITCH_ROLE_TIMEOUT",VN="SWITCH_ROLE_FAILED",jN="CLIENT_BANNED",Ty="INVALID_OPERATION_START_PUBLISH_CDN",FN="INVALID_OPERATION_STOP_PUBLISH_CDN",BN="INVALID_STREAM_ID",wy="START_PUBLISH_CDN_FAILED",Ey="STOP_PUBLISH_CDN_FAILED",HN="START_MIX_TRANSCODE",WN="STOP_MIX_TRANSCODE",GN="INVALID_AUDIO_VOLUME",zN="ENABLE_SMALL_STREAM_PUBLISHED",JN="DISABLE_SMALL_STREAM_PUBLISHED",qN="NOT_SUPPORTED_SMALL_STREAM",KN="INVALID_SMALL_STREAM_PROFILE",QN="INVALID_PARAMETER_REMOTE_STREAM",XN="INVALID_SWITCH_DEVICE",YN="INVALID_SWITCH_DEVICE_PUBLISHING",Ry="INVALID_REPLACE_TRACK",$N="INVALID_INITIALIZE_LOCAL_STREAM",ZN="INVALID_ADD_TRACK_REPETITIVE",eL="INVALID_ADD_TRACK_REMOVING",tL="INVALID_ADD_TRACK_PUBLISHING",Cy="INVALID_STREAM_INITIALIZED",nL="INVALID_ADD_TRACK_NUMBER",rL="INVALID_REMOVE_AUDIO_TRACK",iL="INVALID_REMOVE_AUDIO_ADDING",aL="INVALID_REMOVE_AUDIO_ON",oL="INVALID_REMOVE_TRACK_PUBLISHING",sL="INVALID_REMOVE_TRACK_NOT_PUBLISHING",cL="INVALID_REMOVE_TRACK_NUMBER",uL="INVALID_REPLACE_TRACK_NO_TRACK",lL="REPEAT_JOIN",Ql="CLIENT_DESTROYED",dL="START_MIX_TRANSCODE_FAILED",hL="STOP_MIX_TRANSCODE_FAILED",pL="MIX_TRANSCODE_NOT_STARTED",fL="CANNOT_LESS_THAN_ZERO",mL="MIX_PARAMS_VIDEO_FRAMERATE",_L="MIX_PARAMS_VIDEO_GOP",vL="MIX_PARAMS_AUDIO_BITRATE",gL="MIX_PARAMS_USER_Z_ORDER",yL="MIX_PARAMS_NOT_SELF",SL="MIX_PARAMS_USER_STREAM",bL="INVALID_ELEMENT_ID",kL="INVALID_ELEMENT_ID_TYPE",Xl="PLAY_FAILED",IL="INVALID_CREATE_STREAM_SOURCE",TL="INVALID_CREATE_STREAM_SCREEN",wL="INVALID_CREATE_STREAM_AUDIO",EL="INVALID_CREATE_STREAM_SCREEN_AUDIO",Ay="NOT_SUPPORTED_HTTP",xy="NOT_SUPPORTED_WEBRTC",RL="NOT_SUPPORTED_PROFILE",Py="NOT_SUPPORTED_H264ENCODE",Dy="NOT_SUPPORTED_H264DECODE",Yl="NOT_SUPPORTED_TRACK",CL="NOT_SUPPORTED_SWITCH_DEVICE",AL="NOT_SUPPORTED_CAPTURE",xL="NOT_SUPPORTED_AUX",PL="MICROPHONE_NOT_FOUND",DL="CAMERA_NOT_FOUND",Oy="SIGNAL_RESPONSE_FAILED",OL="CATCH_HANDLER_ERROR",ML="API_NOT_EXIST",NL="CONNECTION_CLOSED",LL="SUBSCRIBE_ALL_FALSE",My="SEI_NOT_SUPPORT",UL="SEI_DISABLED",VL="SEI_EMPTY",jL="SEI_OVERSIZE",FL="SEI_BEFORE_PUBLISH",BL="SEI_NOT_VIDEO",HL="CALL_FREQUENCY_LIMIT",WL="CONNECTION_ABORTED",$l="API_CALL_ABORTED",GL="DUPLICATE_AUX",En={AVOID_REPEATED_CALL:function(e){return"previous ".concat(e.name,"() is ongoing, please avoid repeated calls.")},INVALID_PARAMETER_REQUIRED:function(e){var t=e.key,n=e.rule,i=e.fnName,r=e.value;return"'".concat(t||n.name,"' is a required param when calling ").concat(i,"(), received: ").concat(r,".")},INVALID_PARAMETER_TYPE:function(e){var t=e.key,n=e.rule,i=e.fnName,r=e.value,o="".concat(t||n.name),c="";return c=Array.isArray(n.type)?n.type.join("|"):n.type,"'".concat(o,"' must be type of ").concat(c," when calling ").concat(i,"(), received type: ").concat(xn(r),".")},INVALID_PARAMETER_EMPTY:function(e){var t=e.key,n=e.rule,i=e.fnName,r=e.value;return"'".concat(t||n.name,"' cannot be '").concat(r,"' when calling ").concat(i,"().")},INVALID_PARAMETER_INSTANCE:function(e){var t=e.key,n=e.rule,i=e.fnName,r=e.value,o="".concat(t||n.name),c="".concat(n.instanceOf.name||n.instanceOf);return"'".concat(o,"' must be instanceof ").concat(c," when calling ").concat(i,"(), received type: ").concat(xn(r),".")},INVALID_PARAMETER_RANGE:function(e){var t=e.key,n=e.rule,i=e.fnName,r=e.value;return"'".concat(t||n.name,"' must be one of ").concat(n.values.join("|")," when calling ").concat(i,"(), received: ").concat(r,".")},API_CALL_TIMEOUT:function(e){return"".concat(e.commandDesc||e.command," timeout observed.")},SIGNAL_CHANNEL_RECONNECTION_FAILED:"signal channel reconnection failed, please check your network.",SIGNAL_CHANNEL_SETUP_FAILED:function(e){return"SignalChannel setup failure: (errorCode: ".concat(e.errorCode,", errorMsg: ").concat(e.errorMsg," }).")},ERROR_MESSAGE:function(e){var 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:function(e){return"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:function(e){return"'".concat(e,"' must be validate string when useStringRoomId is true.")},INVALID_ROOMID_INTEGER:function(e){return"'".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:function(e){var t=e.error,n=e.code;return"Failed to join room - ".concat(t," code: ").concat(n)},REJOIN_ROOM_FAILED:function(e){return"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(er,', please call switchRole("').concat(Wt,'") firstly before publish().'),INVALID_INITIALIZE:"cannot publish stream because stream is not initialized, is switching device, or has been closed.",INVALID_DUPLICATE_PUBLISHING:function(e){return"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:function(e){var t=e.message,n=e.stream;return"failed to subscribe ".concat(n.getUserId()," ").concat(n.getType()," 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(Wt," or ").concat(er,"."),INVALID_OPERATION_SWITCH_ROLE:"please call join() before switchRole().",SWITCH_ROLE_TIMEOUT:"switchRole timeout.",SWITCH_ROLE_FAILED:function(e){return"switchRole failed, errCode: ".concat(e.code," errMsg: ").concat(e.message,".")},CLIENT_BANNED:function(e){return"client was banned because of "+e.message+"."},INVALID_OPERATION_START_PUBLISH_CDN:"please call startPublishCDNStream() before client join the room or after client join the room and successfully publish the local stream.",INVALID_OPERATION_STOP_PUBLISH_CDN:"please call startPublishCDNStream() before stopPublishCDNStream().",START_PUBLISH_CDN_FAILED:function(e){return"startPublishCDNStream failed, errMsg: ".concat(e.message,".")},STOP_PUBLISH_CDN_FAILED:function(e){return"stopPublishCDNStream failed, errMsg: ".concat(e.message,".")},INVALID_STREAM_ID:function(e){return"'".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_PUBLISHING:"the track to be removed is not being publishing.",INVALID_REMOVE_TRACK_NUMBER:"remove the only video track is not supported, please use replaceTrack or muteVideo.",INVALID_REPLACE_TRACK_NO_TRACK:function(e){return"cannot replace ".concat(e.kind," track because stream has not ").concat(e.kind," track")},START_MIX_TRANSCODE_FAILED:function(e){return"startMixTranscode failed, errMsg: ".concat(e.message,".")},STOP_MIX_TRANSCODE_FAILED:function(e){return"stopMixTranscode failed, errMsg: ".concat(e.message,".")},MIX_TRANSCODE_NOT_STARTED:"mixTranscode has not been started.",CANNOT_LESS_THAN_ZERO:function(e){var t=e.key,n=e.rule,i=e.fnName;return e.value,"'".concat(t||n.name,"' cannot be less than 0 when calling ").concat(i,"().")},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:function(e){return"'".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:function(e){var t=e.key,n=e.fnName;return"'".concat(t,"' is not found in the document object when calling ").concat(n,"().")},INVALID_ELEMENT_ID_TYPE:function(e){var t=e.key,n=e.fnName,i=e.type;return"the element corresponding to '".concat(t,"' must be instanceof HTMLDivElement when calling ").concat(n,"(), received: ").concat(i,".")},PLAY_FAILED:function(e){return"".concat(e.media," play failedbrowser 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 and publish streams, please use the https protocol.",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:function(e){return"".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 and the configuration on TRTC.createStream.",CAMERA_NOT_FOUND:"no camera detected, please check your camera and the configuration on TRTC.createStream.",SIGNAL_RESPONSE_FAILED:function(e){return"".concat(e.signalResponse," failed, response code is ").concat(e.code," , errMsg: ").concat(e.message,".")},CATCH_HANDLER_ERROR:function(e){var t=e.name,n=e.event;return"an error was caught on ".concat(t,".on('").concat(n,"', handler), please check your code on 'handler'.")},API_NOT_EXIST:function(e){var t=e.name;return"experimental api ".concat(t," does not exist.")},REPEAT_JOIN:function(e){return"[".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:function(e){var t=e.funName;return"failed to call ".concat(t,"() because client was destroyed.")},SEI_NOT_SUPPORT:function(e){return"not support to sendSEIMessage".concat(e===!1?" without using h264 codec":"")},SEI_DISABLED:"SEI is disabled, to enable SEI: TRTC.createClient({ enableSEI: true })",SEI_EMPTY:"buffer cannot be empty",SEI_OVERSIZE:function(e){return"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:function(e){var t=e.isSize,n=e.name,i=e.timesInSecond,r=e.maxSizeInSecond;return"api ".concat(n," call ").concat(t?"size":"times"," is over ").concat(t?r+" bytes":i," in a second.")},CONNECTION_ABORTED:function(e){return"connection aborted due to: "+e},API_CALL_ABORTED:function(e){return e.message.includes("REMOTE_STREAM_NOT_EXIST")?"Subscribe ".concat(e.stream.getUserId()," ").concat(e.stream.getType()," stream aborted, reason: remote user ").concat(e.stream.getUserId()," unpublished stream."):"API aborted, reason: ".concat(e.message)},DUPLICATE_AUX:"only one auxiliary stream can be published in a room.",NOT_SUPPORTED_AUX:"publish auxiliary stream is not supported on your browser."},Ny=oe,zL=Z,JL=Fe,qL=xo.trim,KL=$("".charAt),Yo=Ny.parseFloat,Ly=Ny.Symbol,Uy=Ly&&Ly.iterator,Vy=1/Yo(`
\v\f\r    \u2028\u2029\uFEFF-0`)!=-1/0||Uy&&!zL(function(){Yo(Object(Uy))})?function(e){var t=qL(JL(e)),n=Yo(t);return n===0&&KL(t,0)=="-"?-0:n}:Yo;Y({global:!0,forced:parseFloat!=Vy},{parseFloat:Vy});var X=window.navigator&&window.navigator.userAgent||"",jy=/AppleWebKit\/([\d.]+)/i.exec(X);jy&&parseFloat(jy.pop());var Zl=/iPad/i.test(X),Fy=navigator.maxTouchPoints&&navigator.maxTouchPoints>2&&/Macintosh/.test(X),ed=/iPhone/i.test(X)&&!Zl,QL=/iPod/i.test(X),Rn=ed||Zl||QL||Fy,Qr=/Android/i.test(X);Qr&&function(){var e=X.match(/Android (\d+)(?:\.(\d+))?(?:\.(\d+))*/i);if(!e)return null;var t=e[1]&&parseFloat(e[1]),n=e[2]&&parseFloat(e[2]);t&&n&&parseFloat(e[1]+"."+e[2])}();var ft=/Firefox/i.test(X),By=ft&&function(){var e=X.match(/Firefox\/(\d+)/);return e&&e[1]?parseFloat(e[1]):null}(),$o=/Edge\//i.test(X),XL=$o&&function(){var e=X.match(/Edge\/(\d+)/i);if(e&&e[1])return e[1]}(),Zo=/Edg\//i.test(X),Hy=Zo&&function(){var e=X.match(/Edg\/(\d+)/);return e&&e[1]?parseFloat(e[1]):null}(),td=/SogouMobileBrowser\//i.test(X),YL=td&&function(){var e=X.match(/SogouMobileBrowser\/(\d+)/);return e&&e[1]?parseFloat(e[1]):null}(),nd=/MetaSr\s/i.test(X),$L=nd&&function(){var e=X.match(/MetaSr(\s\d+(\.\d+)+)/);return e&&e[1]?parseFloat(e[1]):null}(),tn=/TBS\/\d+/i.test(X),ZL=tn&&function(){var e=X.match(/TBS\/(\d+)/i);if(e&&e[1])return e[1]}(),rd=/XWEB\/\d+/i.test(X),e3=rd&&function(){var e=X.match(/XWEB\/(\d+)/i);if(e&&e[1])return e[1]}();/MSIE\/\d+/i.test(X)&&function(){var e=/MSIE\s(\d+)\.\d/.exec(X);e&&parseFloat(e[1])}();var id=/(micromessenger|webbrowser)/i.test(X),t3=id&&function(){var e=X.match(/MicroMessenger\/(\d+)/i);if(e&&e[1])return e[1]}(),ad=!tn&&/MQQBrowser\/\d+/i.test(X)&&/COVC\/\d+/i.test(X),od=!tn&&/MQQBrowser\/\d+/i.test(X)&&!/COVC\/\d+/i.test(X),Wy=(od||ad)&&function(){var e=X.match(/ MQQBrowser\/([\d.]+)/);return e&&e[1]?e[1]:null}(),sd=!tn&&/ QQBrowser\/\d+/i.test(X),n3=sd&&function(){var e=X.match(/ QQBrowser\/([\d.]+)/);return e&&e[1]?e[1]:null}(),cd=!tn&&/QQBrowserLite\/\d+/i.test(X),r3=cd&&function(){var e=X.match(/QQBrowserLite\/([\d.]+)/);return e&&e[1]?e[1]:null}(),ud=!tn&&/MQBHD\/\d+/i.test(X),i3=ud&&function(){var e=X.match(/MQBHD\/([\d.]+)/);return e&&e[1]?e[1]:null}(),Gy=/Windows/i.test(X),la=!Rn&&/MAC OS X/i.test(X),zy=!Qr&&/Linux/i.test(X),a3=/UCBrowser/i.test(X),Jy,es,ld=/MiuiBrowser/i.test(X),o3=ld&&function(){var e=X.match(/MiuiBrowser\/([\d.]+)/);return e&&e[1]?e[1]:null}(),dd=/HuaweiBrowser/i.test(X),hd=/Huawei/i.test(X),s3=dd&&function(){var e=X.match(/HuaweiBrowser\/([\d.]+)/);return e&&e[1]?e[1]:null}(),pd=/SamsungBrowser/i.test(X),c3=pd&&function(){var e=X.match(/SamsungBrowser\/([\d.]+)/);return e&&e[1]?e[1]:null}(),ts=/HeyTapBrowser/i.test(X),u3=ts&&function(){var e=X.match(/HeyTapBrowser\/([\d.]+)/);return e&&e[1]?e[1]:null}(),ns=/VivoBrowser/i.test(X),l3=ns&&function(){var e=X.match(/VivoBrowser\/([\d.]+)/);return e&&e[1]?e[1]:null}(),Xr=function(){var e=X.match(/Chrome\/(\d+)/);return e&&e[1]?Number(e[1]):null},d3=/Chrome/i.test(X),rs=!$o&&!nd&&!td&&!tn&&!rd&&!Zo&&!sd&&!ld&&!dd&&!pd&&!ts&&!ns&&/Chrome/i.test(X),fd=rs&&Xr(),h3=rs&&function(){var e=X.match(/Chrome\/([\d.]+)/);return e&&e[1]?e[1]:null}(),nr=!d3&&!od&&!ad&&!cd&&!ud&&/Safari/i.test(X),md=function(){if(nr){var e=X.match(/Version\/([\d.]+)/);if(e&&e[1])return e[1]}return""}(),p3=/Android.*(wv|.0.0.0)/.test(X),Cn=function(){if(Fy)return md;if(Rn){var e=X.match(/OS (\d+)_(\d+)/i);if(e&&e[1]){var t=e[1];return e[2]&&(t+=".".concat(e[2])),t}}return""}(),qy=Number(Cn.split(".")[0]),is=md==="15.1",as=Cn==="15.1",f3=(Jy=Number(Cn.split(".")[0]))===14||Jy===13,rr=location.protocol==="file:"||location.hostname==="localhost"||location.hostname==="127.0.0.1",ir=function(){if(G(es))try{es=window.localStorage}catch(e){z.warn(e),es=!1}return es},_d=new Map([[ft,["Firefox",By]],[Zo,["Edg",Hy]],[rs,["Chrome",h3]],[nr,["Safari",md]],[tn,["TBS",ZL]],[rd,["XWEB",e3]],[id&&ed,["WeChat",t3]],[sd,["QQ(Win)",n3]],[od,["QQ(Mobile)",Wy]],[ad,["QQ(Mobile X5)",Wy]],[cd,["QQ(Mac)",r3]],[ud,["QQ(iPad)",i3]],[ld,["MI",o3]],[dd,["HW",s3]],[pd,["Samsung",c3]],[ts,["OPPO",u3]],[ns,["VIVO",l3]],[$o,["EDGE",XL]],[td,["SogouMobile",YL]],[nd,["Sogou",$L]]]);function ar(){var e="unknown",t="unknown";return _d.get(!0)&&(e=_d.get(!0)[0],t=_d.get(!0)[1]),{name:e,version:t}}var Ky=function(e,t){return t?qr+"/"+e+"/"+t:qr+"/"+e+"/index.html"},m3=function(){if(!ir())return!1;var e=localStorage.getItem(Jl);e&&!function(t){var n=t.saveTime&&new Date().getTime()-t.saveTime>=cy,i=!t.saveVersion||t.saveVersion!==Wn;return n||i}(JSON.parse(e))||(z.info("init debug info"),function(){var t=new XMLHttpRequest;if(t.open("GET","https://web.sdk.qcloud.com/trtc/webrtc/download/error-message/0.0.3/script.js",!1),t.send(null),t.readyState===4&&t.status===200){var n=document.createElement("script");n.type="text/javascript",n.text=t.responseText,document.body.appendChild(n),localStorage.setItem(Jl,JSON.stringify({message:t.responseText,saveTime:new Date().getTime(),saveVersion:Wn})),document.body.removeChild(n)}}())};function H(e){var t=e.key,n=e.data,i=e.link,r=e.addDocLink,o=r===void 0||r,c="",a="",s="";et(En[t])?c=En[t](n):je(En[t])&&(c=En[t]);var l=function(){if(window.TRTC_ERROR_INFO&&window.TRTC_ERROR_LINK)return{TRTC_ERROR_INFO:window.TRTC_ERROR_INFO,TRTC_ERROR_LINK:window.TRTC_ERROR_LINK};var b=localStorage.getItem(Jl);if(b){b=JSON.parse(b);var T=document.createElement("script");T.type="text/javascript",T.text=b.message,document.body.appendChild(T);var k=window.TRTC_ERROR_INFO,p=window.TRTC_ERROR_LINK;return document.body.removeChild(T),{TRTC_ERROR_INFO:k,TRTC_ERROR_LINK:p}}return{}}(),u=l.TRTC_ERROR_INFO,h=l.TRTC_ERROR_LINK;i?s="".concat(i.className,".html#").concat(i.fnName):h&&h[t]&&(et(h[t])?s=h[t](n):je(h[t])&&(s=h[t]));var g=c;return or()&&(u&&u[t]&&(et(u[t])?a=u[t](n):je(u[t])&&(a=u[t])),a&&(g=o?a+`
请查看文档: `+Ky("zh-cn",s)+`
`:a+`
`,g+=c)),o&&(g+=`
Refer to: `+Ky("en",s)+`
`),g}var Qy=function(){return function(e){var t=window.location.search.match(new RegExp("(\\?|&)"+e+"=([^&]*)(&|$)"));return t?decodeURIComponent(t[2]):""}("trtc_env")},Xy=function(e){return(e=Number(e))>0&&e<14e8},os=function(e,t){var n;n=ia?ia.includes("http")?ia:"https://"+ia:Xy(e)?"https://apisgp.my-imcloud.com":"https://yun.tim.qq.com";var i=Math.floor(Math.random()*Math.pow(2,31));return"".concat(n,"/v5/AVQualityReportSvc/C2S?random=").concat(i,"&sdkappid=").concat(e,"&cmdtype=").concat(t)};function vd(){var e=navigator.userAgent,t=navigator.connection,n=e.match(/NetType\/\w+/)?e.match(/NetType\/\w+/)[0]:"";(n=n.toLowerCase().replace("nettype/",""))==="3gnet"&&(n="3g");var i=t&&t.type&&t.type.toLowerCase(),r=t&&t.effectiveType&&t.effectiveType.toLowerCase();r==="slow-2"&&(r="2g");var o=n||"unknown";if(i)switch(i){case"cellular":case"wimax":o=r||"unknown";break;case"wifi":o="wifi";break;case"ethernet":o="wired";break;case"none":case"other":case"unknown":o="unknown"}return o}var An=function(e){if(!e||bi(e)!=="object"||Object.prototype.toString.call(e)!="[object Object]")return!1;var t=Object.getPrototypeOf(e);if(t===null)return!0;var n=Object.prototype.hasOwnProperty.call(t,"constructor")&&t.constructor;return typeof n=="function"&&n instanceof n&&Function.prototype.toString.call(n)===Function.prototype.toString.call(Object)};function ss(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:1,n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:1;return e<=1?n:ss(e-1,n,t+n)}function gd(e){var t=Math.round(e/2)+1;return t>6?13e3:1e3*ss(t)}var et=function(e){return typeof e=="function"},G=function(e){return e===void 0},je=function(e){return typeof e=="string"},Rt=function(e){return typeof e=="number"},Ct=function(e){return typeof e=="boolean"},Yy=function(e){return xn(e)==="object"},Yr=function(e){return xn(e)==="array"},$y=function(e){return xn(e)==="MediaStreamTrack".toLowerCase()};function xn(e){return Reflect.apply(Object.prototype.toString,e,[]).replace(/^\[object\s(\w+)\]$/,"$1").toLowerCase()}function Zy(e){var t={};return t.urls="turn:".concat(e.url),G(e.username)||G(e.credential)||(t.username=e.username,t.credential=e.credential,t.credentialType="password",G(e.credentialType)||(t.credentialType=e.credentialType)),t}function De(){return performance&&performance.now?Math.floor(performance.now()):Date.now()}function yd(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"big";if(!je(e))return 0;var n=e.split(".");return t==="big"?(Number(n[0])<<24|Number(n[1])<<16|Number(n[2])<<8|Number(n[3]))>>>0:(Number(n[3])<<24|Number(n[2])<<16|Number(n[1])<<8|Number(n[0]))>>>0}var Sd,bd,or=function(){var e=navigator.language||navigator.userLanguage;return(e=e.substr(0,2))==="zh"},eS=(Sd=!1,bd=document.visibilityState,function(){document.visibilityState!==bd&&z.info("visibility change: ".concat(document.visibilityState)),Sd||(document.addEventListener("visibilitychange",function(){z.info("visibility change: "+document.visibilityState),bd=document.visibilityState}),Sd=!0)});window.AudioContext=window.AudioContext||window.webkitAudioContext||window.mozAudioContext;var tS=function(){return new window.AudioContext},nS=function(){var e;return function(){return e||(e=new window.AudioContext,e.onstatechange=function(){z.info("gain context state: ".concat(e.state)),e.state==="suspended"?(e.resume(),document.addEventListener("click",e.resume)):e.state==="interrupted"?e.resume():document.removeEventListener("click",e.resume)},e)}}(),_3=!!window.AudioWorkletNode,rS=function(e,t){var n=e.emit;return e.emit=function(){for(var i=arguments.length,r=new Array(i),o=0;o<i;o++)r[o]=arguments[o];try{n.apply(e,r)}catch(a){var c=H({key:OL,data:{name:t,event:r[0]},addDocLink:!1});z.warn(c+`
`+a.stack)}},e},iS=function(e){return+e<10?"0".concat(e):e},v3=function(e){var t=e.match(/^\d+\.\d+\.\d+/)[0];if(!t)return e;var n=t.split("."),i=iS(n[1])+iS(n[2]);return n[1]-15>0&&(n[1]="15"),n[2]-15>0&&(n[2]="15"),n.join(".")+"."+i};function $r(e,t){try{if(Yr(e))return"[".concat(e.map(function(r){return $r(r,t)}).join(","),"]");if(!An(e)||!Yr(t))return JSON.stringify(e);var n={},i=new Set(t);return Object.keys(e).forEach(function(r){i.has(r)&&(n[r]=e[r])}),JSON.stringify(n)}catch{return"{}"}}function cs(e){var t=e.url,n=e.body,i=e.method,r=e.timeout,o=new XMLHttpRequest;return new Promise(function(c,a){o.onload=function(l){if(o.status>=200&&o.status<300&&o.responseText.length>0)try{var u=JSON.parse(o.response);c({data:u})}catch{c({data:o.response})}else o.status>0&&a({code:o.status,message:"request failed, readyState:".concat(o.readyState," status:").concat(o.status," loaded size:").concat(l.loaded)})};var s=function(l){a({code:o.readyState,message:"request ".concat(l.type,", readyState:").concat(o.readyState," status:").concat(o.status," loaded size:").concat(l.loaded)})};o.onerror=s,o.onabort=s,o.ontimeout=s,o.timeout=r||5e3,o.open(i||"POST",t,!0),o.send(n)})}var aS={exports:{}};(function(e){var t=Object.prototype.hasOwnProperty,n="~";function i(){}function r(s,l,u){this.fn=s,this.context=l,this.once=u||!1}function o(s,l,u,h,g){if(typeof u!="function")throw new TypeError("The listener must be a function");var b=new r(u,h||s,g),T=n?n+l:l;return s._events[T]?s._events[T].fn?s._events[T]=[s._events[T],b]:s._events[T].push(b):(s._events[T]=b,s._eventsCount++),s}function c(s,l){--s._eventsCount==0?s._events=new i:delete s._events[l]}function a(){this._events=new i,this._eventsCount=0}Object.create&&(i.prototype=Object.create(null),new i().__proto__||(n=!1)),a.prototype.eventNames=function(){var s,l,u=[];if(this._eventsCount===0)return u;for(l in s=this._events)t.call(s,l)&&u.push(n?l.slice(1):l);return Object.getOwnPropertySymbols?u.concat(Object.getOwnPropertySymbols(s)):u},a.prototype.listeners=function(s){var l=n?n+s:s,u=this._events[l];if(!u)return[];if(u.fn)return[u.fn];for(var h=0,g=u.length,b=new Array(g);h<g;h++)b[h]=u[h].fn;return b},a.prototype.listenerCount=function(s){var l=n?n+s:s,u=this._events[l];return u?u.fn?1:u.length:0},a.prototype.emit=function(s,l,u,h,g,b){var T=n?n+s:s;if(!this._events[T])return!1;var k,p,S=this._events[T],f=arguments.length;if(S.fn){switch(S.once&&this.removeListener(s,S.fn,void 0,!0),f){case 1:return S.fn.call(S.context),!0;case 2:return S.fn.call(S.context,l),!0;case 3:return S.fn.call(S.context,l,u),!0;case 4:return S.fn.call(S.context,l,u,h),!0;case 5:return S.fn.call(S.context,l,u,h,g),!0;case 6:return S.fn.call(S.context,l,u,h,g,b),!0}for(p=1,k=new Array(f-1);p<f;p++)k[p-1]=arguments[p];S.fn.apply(S.context,k)}else{var I,A=S.length;for(p=0;p<A;p++)switch(S[p].once&&this.removeListener(s,S[p].fn,void 0,!0),f){case 1:S[p].fn.call(S[p].context);break;case 2:S[p].fn.call(S[p].context,l);break;case 3:S[p].fn.call(S[p].context,l,u);break;case 4:S[p].fn.call(S[p].context,l,u,h);break;default:if(!k)for(I=1,k=new Array(f-1);I<f;I++)k[I-1]=arguments[I];S[p].fn.apply(S[p].context,k)}}return!0},a.prototype.on=function(s,l,u){return o(this,s,l,u,!1)},a.prototype.once=function(s,l,u){return o(this,s,l,u,!0)},a.prototype.removeListener=function(s,l,u,h){var g=n?n+s:s;if(!this._events[g])return this;if(!l)return c(this,g),this;var b=this._events[g];if(b.fn)b.fn!==l||h&&!b.once||u&&b.context!==u||c(this,g);else{for(var T=0,k=[],p=b.length;T<p;T++)(b[T].fn!==l||h&&!b[T].once||u&&b[T].context!==u)&&k.push(b[T]);k.length?this._events[g]=k.length===1?k[0]:k:c(this,g)}return this},a.prototype.removeAllListeners=function(s){var l;return s?(l=n?n+s:s,this._events[l]&&c(this,l)):(this._events=new i,this._eventsCount=0),this},a.prototype.off=a.prototype.removeListener,a.prototype.addListener=a.prototype.on,a.prefixed=n,a.EventEmitter=a,e.exports=a})(aS);var Pn=aS.exports,U=new Pn,us=1,kd=2,Id=3,Zr=4,sr=5,Td=20,wd=21,ei=22,Ed=23,Rd=24,Cd=27,Ad=28,ls=29,oS=30,sS=31,xd=32,Pd=33,cS=40,g3=41,y3=52,S3=100,uS=101,da=102,Dd=103,mt=110,ds=111,Od=112,nn=113,rn=114,b3=115,cr=116,k3=120,Md=121,Nd=122,Ld=123,ha=130,Ud=131,Vd=132,jd=133,Fd=134,Bd=135,Hd=136,Wd=137,hs=200,Gd=201,zd=300,pa=301,Jd=302,qd=303;function fa(e){var t=e.retryFunction,n=e.settings,i=e.onError,r=e.onRetrying,o=e.onRetryFailed,c=e.onRetrySuccess,a=e.context;return function(){for(var s=this,l=arguments.length,u=new Array(l),h=0;h<l;h++)u[h]=arguments[h];var g=n.retries||5,b=0,T=-1,k=0,p=function(){var S=F(M().mark(function f(I,A){var x,D,m,v;return M().wrap(function(w){for(;;)switch(w.prev=w.next){case 0:return x=a||s,w.prev=1,w.next=4,t.apply(x,u);case 4:D=w.sent,b!==0&&et(c)&&c.call(x,b),b=0,I(D),w.next=15;break;case 10:w.prev=10,w.t0=w.catch(1),m=function(){clearTimeout(T),b=0,k=2,A(w.t0)},v=function(){k!==2&&b<g?(b++,k=1,et(r)&&r.call(x,b,m),T=setTimeout(function(){T=-1,p(I,A)},G(n.timeout)?1e3:n.timeout)):(m(),et(o)&&o.call(x,w.t0))},et(i)?i.call(x,w.t0,v,A,u,b):v();case 15:case"end":return w.stop()}},f,null,[[1,10]])}));return function(f,I){return S.apply(this,arguments)}}();return new Promise(p)}}var I3=ue(function e(t){ce(this,e),this.log=t.log,this.level=t.level,this.userId=t.userId,this.sdkAppId=t.sdkAppId,this.forAllJoinedClients=t.forAllJoinedClients,this.uploaded=!1}),T3=function(){function e(t){ce(this,e),this.id_=t.id,this.userId_=t.userId,this.sdkAppId_=t.sdkAppId,this.type_=t.type,this.isLocal_=!Ct(t.isLocal)||t.isLocal}return ue(e,[{key:"setUserId",value:function(t){this.userId_=t}},{key:"setSdkAppId",value:function(t){this.sdkAppId_=t}},{key:"log",value:function(t,n){z.log({log:"[".concat(this.isLocal_?"↑":"↓").concat(this.id_,"] ").concat(this.type_?this.type_+" ":"").concat(n),level:t,forAllJoinedClients:G(this.userId_),userId:this.userId_,sdkAppId:this.sdkAppId_})}},{key:"info",value:function(t){this.log(pt.INFO,t)}},{key:"debug",value:function(t){this.log(pt.DEBUG,t)}},{key:"warn",value:function(t){this.log(pt.WARN,t)}},{key:"error",value:function(t){this.log(pt.ERROR,t)}}]),e}(),w3=!(Rn||Qr),E3=function(){function e(){var i=this;ce(this,e),this.clients_=new Set,this.queue_=[],this.timeoutId_=-1,this.logLevel_=pt.DEBUG,this.logLevelToUpload_=pt.INFO,this.enableUploadLog_=!0,this.isAbleToUpload_=!1,this.checkURLParam(),U.on(oS,function(r){var o=r.client;i.timeoutId_===-1&&i.startUpload(),i.clients_.add(o)}),U.on(Pd,function(r){var o=r.client;return i.clients_.delete(o)}),U.on(sS,function(r){r&&An(r.config)&&tr[r.config.logLevelToUpload]&&(i.logLevelToUpload_=r.config.logLevelToUpload)}),U.on(Zr,this.setIsAbleToUpload,this),U.on(sr,this.setIsAbleToUpload,this)}var t,n;return ue(e,[{key:"getIsAbleToUpload",value:function(){return this.isAbleToUpload_}},{key:"setIsAbleToUpload",value:function(){this.isAbleToUpload_=!0,U.off(Zr,this.setIsAbleToUpload,this),U.off(sr,this.setIsAbleToUpload,this)}},{key:"startUpload",value:(n=F(M().mark(function i(){var r=this;return M().wrap(function(o){for(;;)switch(o.prev=o.next){case 0:return o.prev=0,o.next=3,this.upload();case 3:o.next=7;break;case 5:o.prev=5,o.t0=o.catch(0);case 7:this.timeoutId_=setTimeout(function(){return r.startUpload()},2e3);case 8:case"end":return o.stop()}},i,this,[[0,5]])})),function(){return n.apply(this,arguments)})},{key:"getLogsToUpload",value:function(){var i=this,r={map:new Map,splicedQueue:[]};if(this.queue_[0].forAllJoinedClients&&this.clients_.size===0)return r;for(var o=0,c=function(){if(o===50)return"break";var a=i.queue_[o];if(a.forAllJoinedClients){var s=new Set;i.clients_.forEach(function(l){if(l.getIsJoined()){var u=l.getUserId(),h=l.getSDKAppId();s.has("".concat(u,"-").concat(h))||(s.add("".concat(u,"-").concat(h)),r.map.has(u)?r.map.get(u).logs.push(a):r.map.set(u,{userId:u,sdkAppId:h,logs:[a]}))}})}else r.map.has(a.userId)?r.map.get(a.userId).logs.push(a):r.map.set(a.userId,{userId:a.userId,sdkAppId:a.sdkAppId,logs:[a]})};o<this.queue_.length&&c()!=="break";o++);return r.map.size>0&&(r.splicedQueue=this.queue_.splice(0,o)),r}},{key:"upload",value:(t=F(M().mark(function i(){var r,o,c,a,s,l,u,h,g,b;return M().wrap(function(T){for(;;)switch(T.prev=T.next){case 0:if(this.queue_.length!==0&&this.isAbleToUpload_){T.next=2;break}return T.abrupt("return");case 2:if(r=this.getLogsToUpload(),o=r.map,c=r.splicedQueue,o.size!==0){T.next=5;break}return T.abrupt("return");case 5:T.prev=5,a=Se(o.values()),s=0;case 8:if(!(s<a.length)){T.next=16;break}return l=a[s],u=l.userId,h=l.sdkAppId,g=l.logs,T.next=12,this.uploadLogWithRetry(JSON.stringify({timestamp:ov(),sdkAppId:String(h),userId:u,version:Wn,log:g.map(function(k){return k.log}).join(`
`)}),h);case 12:g.forEach(function(k){return k.uploaded=!0});case 13:s++,T.next=8;break;case 16:T.next=20;break;case 18:T.prev=18,T.t0=T.catch(5);case 20:b=c.filter(function(k){return!k.uploaded}),b.length>0&&(this.queue_=b.concat(this.queue_));case 22:case"end":return T.stop()}},i,this,[[5,18]])})),function(){return t.apply(this,arguments)})},{key:"uploadLogWithRetry",value:function(i,r){return fa({retryFunction:function(){return cs({url:os(r,Og),body:i,timeout:5e3})},settings:{retries:3,timeout:1e3},onError:function(o,c){c()}})()}},{key:"getPrefix",value:function(i){var r=new Date;return r.setTime(Qe()),String.prototype.padStart?"[".concat(r.toTimeString().replace(/.*(\d{2}:\d{2}:\d{2}).*/,"$1"),":").concat(r.getMilliseconds().toString().padStart(3,"0"),"] <").concat(tr[i],">"):"[".concat(r.toTimeString().replace(/.*(\d{2}:\d{2}:\d{2}).*/,"$1"),":").concat(r.getMilliseconds(),"] <").concat(tr[i],">")}},{key:"getLogLevel",value:function(){return this.logLevel_}},{key:"setLogLevel",value:function(i){G(tr[i])||(this.logLevel_!==i&&this.info("setLogLevel ".concat(i)),this.logLevel_=i)}},{key:"enableUploadLog",value:function(){this.enableUploadLog_=!0}},{key:"disableUploadLog",value:function(){this.enableUploadLog_=!1}},{key:"log",value:function(i){var r=i.log,o=i.level,c=i.forAllJoinedClients,a=c===void 0||c,s=i.userId,l=i.sdkAppId;if(r="".concat(this.getPrefix(o)," ").concat(r),this.enableUploadLog_&&o>=this.logLevelToUpload_&&this.queue_.push(new I3({log:r,level:o,userId:s,sdkAppId:l,forAllJoinedClients:a})),!(o<this.logLevel_)){var u=tr[o]?tr[o].toLowerCase():"info";w3?console[u]("%cTRTC%c%s","padding: 1px 4px;border-radius: 3px;color: #fff;background: #1E88E5;","display: inline",r):console[u](r)}}},{key:"debug",value:function(i){this.log({log:i,level:pt.DEBUG})}},{key:"info",value:function(i){this.log({log:i,level:pt.INFO})}},{key:"warn",value:function(i){this.log({log:i,level:pt.WARN})}},{key:"error",value:function(i){this.log({log:i,level:pt.ERROR})}},{key:"createLogger",value:function(i){return new T3(i)}},{key:"checkURLParam",value:function(){var i=new URLSearchParams(location.search).get("logLevelToUpload");tr[i]&&(this.logLevelToUpload_=i)}}]),e}(),z=new E3,lS=!0,R3=xe,C3=Math.floor,dS=Number.isInteger||function(e){return!R3(e)&&isFinite(e)&&C3(e)===e};Y({target:"Number",stat:!0},{isInteger:dS});var Kd,A3=Y,hS=$,x3=hn.f,P3=jt,pS=Fe,D3=Rv,O3=dt,M3=Cv,fS=hS("".startsWith),N3=hS("".slice),L3=Math.min,mS=M3("startsWith");A3({target:"String",proto:!0,forced:!!(mS||(Kd=x3(String.prototype,"startsWith"),!Kd||Kd.writable))&&!mS},{startsWith:function(e){var t=pS(O3(this));D3(e);var n=P3(L3(arguments.length>1?arguments[1]:void 0,t.length)),i=pS(e);return fS?fS(t,i,n):N3(t,n,n+i.length)===i}});var _S=Ae,U3=$,V3=we,j3=Z,Qd=ao,F3=Wc,B3=Ga,H3=ze,W3=Ei,ti=Object.assign,vS=Object.defineProperty,G3=U3([].concat),gS=!ti||j3(function(){if(_S&&ti({b:1},ti(vS({},"a",{enumerable:!0,get:function(){vS(this,"b",{value:3,enumerable:!1})}}),{b:2})).b!==1)return!0;var e={},t={},n=Symbol(),i="abcdefghijklmnopqrst";return e[n]=7,i.split("").forEach(function(r){t[r]=r}),ti({},e)[n]!=7||Qd(ti({},t)).join("")!=i})?function(e,t){for(var n=H3(e),i=arguments.length,r=1,o=F3.f,c=B3.f;i>r;)for(var a,s=W3(arguments[r++]),l=o?G3(Qd(s),o(s)):Qd(s),u=l.length,h=0;u>h;)a=l[h++],_S&&!V3(c,s,a)||(n[a]=s[a]);return n}:ti,yS=gS;Y({target:"Object",stat:!0,arity:2,forced:Object.assign!==yS},{assign:yS});var SS=$,z3=It,J3=xe,q3=Le,bS=Rr,K3=wi,kS=Function,Q3=SS([].concat),X3=SS([].join),Xd={},Y3=function(e,t,n){if(!q3(Xd,t)){for(var i=[],r=0;r<t;r++)i[r]="a["+r+"]";Xd[t]=kS("C,a","return new C("+X3(i,",")+")")}return Xd[t](e,n)},$3=K3?kS.bind:function(e){var t=z3(this),n=t.prototype,i=bS(arguments,1),r=function(){var o=Q3(i,bS(arguments));return this instanceof r?Y3(t,o.length,o):t.apply(e,o)};return J3(n)&&(r.prototype=n),r},IS=$3;Y({target:"Function",proto:!0,forced:Function.bind!==IS},{bind:IS});var Z3=Y,eU=Ke.findIndex,tU=co,TS="findIndex",wS=!0;TS in[]&&Array(1).findIndex(function(){wS=!1}),Z3({target:"Array",proto:!0,forced:wS},{findIndex:function(e){return eU(this,e,arguments.length>1?arguments[1]:void 0)}}),tU(TS);var nU=Ae,ES=$,rU=ao,iU=kt,aU=ES(Ga.f),oU=ES([].push),sU=function(e){return function(t){for(var n,i=iU(t),r=rU(i),o=r.length,c=0,a=[];o>c;)n=r[c++],nU&&!aU(i,n)||oU(a,e?[n,i[n]]:i[n]);return a}},cU={values:sU(!1)}.values;Y({target:"Object",stat:!0},{values:function(e){return cU(e)}});var RS=1,CS=5,Yd=2,ma=3,$d=4,ps="DISCONNECTED",AS="CONNECTING",Zd="RECONNECTING",_a="CONNECTED",an={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,CONNECT_OTHER_ROOM_RES:8209,DISCONNECT_OTHER_ROOM_RES:8211,UPDATE_OTHER_ROOM_FORWARD_MODE_RES:8213},uU=[an.UPDATE_REMOTE_MUTE_STAT,an.UPLINK_NETWORK_STATS,an.USER_LIST_RES,an.MUTE_RESULT],pe={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",CONNECT_OTHER_ROOM_RES:"connect_other_room_res",UPDATE_OTHER_ROOM_FORWARD_MODE_RES:"update_other_room_forward_mode_res",DISCONNECT_OTHER_ROOM_RES:"disconnect_other_room_res"},lU="publish_change",dU="publish_state_change",hU="join",pU="leave",fU="quality_report",mU="mute_uplink",_U="publish",xS="unpublish",vU="subscribe",gU="unsubscribe",yU="subscribe_change",SU="start_publishing",bU="stop_publishing",kU="start_push_user_cdn",IU="stop_push_user_cdn",TU="start_mcu_mix",wU="stop_mcu_mix",EU="get_user_list",RU="change_role",CU="update_constraint_config",AU="connect_other_room",xU="update_other_room_forward_mode",PU="disconnect_other_room",V={INVALID_PARAMETER:4096,INVALID_OPERATION:4097,NOT_SUPPORTED:4098,DEVICE_NOT_FOUND:4099,INITIALIZE_FAILED:4100,SIGNAL_CHANNEL_SETUP_FAILED:16385,SIGNAL_CHANNEL_ERROR:16386,ICE_TRANSPORT_ERROR:16387,JOIN_ROOM_FAILED:16388,CREATE_OFFER_FAILED:16389,SIGNAL_CHANNEL_RECONNECTION_FAILED:16390,UPLINK_RECONNECTION_FAILED:16391,DOWNLINK_RECONNECTION_FAILED:16392,REMOTE_STREAM_NOT_EXIST:16400,CLIENT_BANNED:16448,SERVER_TIMEOUT:16449,SUBSCRIPTION_TIMEOUT:16450,PLAY_NOT_ALLOWED:16451,DEVICE_AUTO_RECOVER_FAILED:16452,START_PUBLISH_CDN_FAILED:16453,STOP_PUBLISH_CDN_FAILED:16454,START_MIX_TRANSCODE_FAILED:16455,STOP_MIX_TRANSCODE_FAILED:16456,NOT_SUPPORTED_H264:16457,SWITCH_ROLE_FAILED:16458,API_CALL_TIMEOUT:16459,SCHEDULE_FAILED:16460,API_CALL_ABORTED:16461,UNKNOWN:65535},j=function(e){ki(n,e);var t=Ti(n);function n(i){var r,o=i.name,c=o===void 0?"RtcError":o,a=i.message,s=i.code,l=s===void 0?V.UNKNOWN:s,u=i.extraCode,h=u===void 0?0:u,g=i.constraint;ce(this,n);var b="<".concat(function(T){for(var k in V)if(V[k]===T)return k;return"UNKNOWN"}(l)," 0x").concat(l.toString(16),">");return(r=t.call(this,a+"".concat(g?" constraint: ".concat(g):"")+"".concat(a!=null&&a.includes(b)?"":" "+b))).code_=l,r.extraCode_=h,r.name=c,r.message_=a,g&&(r.constraint=g),r}return ue(n,[{key:"getCode",value:function(){return this.code_}},{key:"getExtraCode",value:function(){return this.extraCode_}}]),n}(mc(Error)),PS=32768,DS=32769,OS=32770,MS=32771,DU=32772,OU=32773,MU=32774,NU=32775,NS=32777,LU=32778,eh=32779,UU=32780,VU=32781,jU=32782,FU=32783,BU=32784,HU=32785,WU=32786,GU=32787,zU=32788,JU=32789,qU=32790,KU=32791,QU=32792,XU=32793,YU=32794,$U=32795,ZU=32796,eV=32797,tV=32798,nV=32799,rV=32800,iV=32801,aV=32802,oV=32803,sV=32804,va=new Map,rt=function(e,t){var n=va.get(e);n||(va.set(e,[]),n=va.get(e)),n.push(t)},cV=function(e){var t=va.get(e),n=[];return t?(va.delete(e),n=t.map(function(i){return{uint32_event_id:i.eventId,uint64_date:i.timestamp,str_userid:i.remoteUserId,str_event_json:i.eventDesc}})):n=[],n},uV=Object.prototype.hasOwnProperty;function on(e){if(e==null)return!0;if(typeof e=="boolean")return!1;if(typeof e=="number")return e===0;if(typeof e=="string"||typeof e=="function"||Array.isArray(e))return e.length===0;if(e instanceof Error)return e.message==="";if(An(e))switch(Object.prototype.toString.call(e)){case"[object File]":case"[object Map]":case"[object Set]":return e.size===0;case"[object Object]":for(var t in e)if(uV.call(e,t))return!1;return!0}return!1}var lV=function(){function e(){ce(this,e);var t=ar(),n=t.name,i=t.version;this.roomIdMap_=new Map,this.configs_={sdkAppId:"",userId:"",version:Wn,env:Wo,browserVersion:n+i,ua:navigator.userAgent}}return ue(e,[{key:"setConfig",value:function(t){var n=t.sdkAppId,i=t.env,r=t.userId,o=t.roomId;n!==this.configs_.sdkAppId&&(this.configs_.sdkAppId=String(n)),this.configs_.env=i,this.configs_.userId=r,this.roomIdMap_.set(r,String(o))}},{key:"logEvent",value:function(t){if(!rr){var n=te(te(te({},t),this.configs_),{},{userId:t.userId||this.configs_.userId});G(n.code)&&(n.code=n.result==="failed"?V.UNKNOWN:0),this.sendRequest(os(this.configs_.sdkAppId,DM),n)}}},{key:"logSuccessEvent",value:function(t){rr||(this.logEvent(te(te({},t),{},{result:"success",roomId:this.roomIdMap_.get(t.userId)})),this.configs_.env===Wo&&this.uploadEventToKibana(te(te({},t),{},{result:"success"})))}},{key:"logFailedEvent",value:function(t){if(!rr){var n=t.eventType,i=t.code,r=t.error,o=t.userId,c={roomId:this.roomIdMap_.get(o),userId:o,eventType:n,result:"failed",code:i||(r instanceof j?r.getExtraCode()||r.getCode():V.UNKNOWN)};this.logEvent(c),this.configs_.env===Wo&&this.uploadEventToKibana(te(te({},c),{},{error:r}))}}},{key:"uploadEventToKibana",value:function(t){var n="stat-".concat(t.eventType,"-").concat(t.result);t.eventType!=="delta-join"&&t.eventType!=="delta-leave"&&t.eventType!=="delta-publish"||(n="".concat(t.eventType,":").concat(t.delta)),this.uploadEvent({log:n,userId:t.userId}),t.result==="failed"&&(n="stat-".concat(t.eventType,"-").concat(t.result,"-").concat(t.code),this.uploadEvent({log:n,userId:t.userId,error:t.error}))}},{key:"uploadEvent",value:function(t){var n=t.log,i=t.userId,r=t.error,o={timestamp:ov(),sdkAppId:this.configs_.sdkAppId,userId:i||this.configs_.userId,version:this.configs_.version,log:n};r&&(o.errorInfo=r.message),this.sendRequest(os(this.configs_.sdkAppId,Og),o)}},{key:"sendRequest",value:function(t,n){var i=this;z.getIsAbleToUpload()?cs({url:t,body:JSON.stringify(n)}).catch(function(){}):setTimeout(function(){i.sendRequest(t,n)},1e3)}}]),e}(),J=new lV,dV=ze,hV=Xa;Y({target:"Date",proto:!0,arity:1,forced:Z(function(){return new Date(NaN).toJSON()!==null||Date.prototype.toJSON.call({toISOString:function(){return 1}})!==1})},{toJSON:function(e){var t=dV(this),n=hV(t,"number");return typeof n!="number"||isFinite(n)?t.toISOString():null}});var pV=we;Y({target:"URL",proto:!0,enumerable:!0},{toJSON:function(){return pV(URL.prototype.toString,this)}});var fV=Y,th=$,mV=Tt,_V=yv,vV=f_,LS=Z,gV=RangeError,US=String,VS=Math.floor,nh=th(vV),jS=th("".slice),ga=th(1 .toFixed),ni=function(e,t,n){return t===0?n:t%2==1?ni(e,t-1,n*e):ni(e*e,t/2,n)},ri=function(e,t,n){for(var i=-1,r=n;++i<6;)r+=t*e[i],e[i]=r%1e7,r=VS(r/1e7)},rh=function(e,t){for(var n=6,i=0;--n>=0;)i+=e[n],e[n]=VS(i/t),i=i%t*1e7},FS=function(e){for(var t=6,n="";--t>=0;)if(n!==""||t===0||e[t]!==0){var i=US(e[t]);n=n===""?i:n+nh("0",7-i.length)+i}return n};fV({target:"Number",proto:!0,forced:LS(function(){return ga(8e-5,3)!=="0.000"||ga(.9,0)!=="1"||ga(1.255,2)!=="1.25"||ga(0xde0b6b3a7640080,0)!=="1000000000000000128"})||!LS(function(){ga({})})},{toFixed:function(e){var t,n,i,r,o=_V(this),c=mV(e),a=[0,0,0,0,0,0],s="",l="0";if(c<0||c>20)throw gV("Incorrect fraction digits");if(o!=o)return"NaN";if(o<=-1e21||o>=1e21)return US(o);if(o<0&&(s="-",o=-o),o>1e-21)if(n=(t=function(u){for(var h=0,g=u;g>=4096;)h+=12,g/=4096;for(;g>=2;)h+=1,g/=2;return h}(o*ni(2,69,1))-69)<0?o*ni(2,-t,1):o/ni(2,t,1),n*=4503599627370496,(t=52-t)>0){for(ri(a,0,n),i=c;i>=7;)ri(a,1e7,0),i-=7;for(ri(a,ni(10,i,1),0),i=t-1;i>=23;)rh(a,1<<23),i-=23;rh(a,1<<i),ri(a,1,1),rh(a,2),l=FS(a)}else ri(a,0,n),ri(a,1<<-t,0),l=FS(a)+nh("0",c);return l=c>0?s+((r=l.length)<=c?"0."+nh("0",c-r)+l:jS(l,0,r-c)+"."+jS(l,r-c)):s+l}});var ih=null,ah=!0;function Dn(e){Ct(e)&&e!==ah&&(ah=e,z.info("setIsNeedToSchedule "+e))}function yV(e,t){try{if(PerformanceObserver){var n=De(),i=fs(e,le),r=fs(e,Et),o=new PerformanceObserver(function(c){c.getEntries().forEach(function(a){if(a.startTime>=n&&(a.name===i||a.name===r)){var s=a.name===i?le:Et;if(a.code&&a.code!==200)return void z.warn("".concat(s," schedule with code ").concat(a.code,", ").concat(JSON.stringify(a.toJSON())));var l=a.responseEnd-a.startTime,u=[a.domainLookupStart-a.startTime,a.domainLookupEnd-a.domainLookupStart,a.requestStart-a.secureConnectionStart,a.secureConnectionStart-a.connectStart,a.responseStart-a.requestStart,a.responseEnd-a.responseStart].map(function(h){return h.toFixed(1)});o.disconnect(),J.uploadEvent({log:"stat-schedule-net:".concat(l.toFixed(1),"(").concat(u.join("->"),") ").concat(s),userId:t})}})});o.observe({type:"resource",buffered:!0})}}catch{}}function SV(e){return oh.apply(this,arguments)}function oh(){return oh=F(M().mark(function e(t){var n,i,r,o,c,a,s,l,u,h,g,b,T;return M().wrap(function(k){for(;;)switch(k.prev=k.next){case 0:if(n=t.userId,i=t.sdkAppId,r=t.useStringRoomId,o=t.roomId,c=t.userSig,ah||!ih){k.next=3;break}return k.abrupt("return",{isCached:!0,result:ih});case 3:return a={delta:0,count:[1,1],msg:[]},k.prev=4,(s=new FormData).append("userId",String(n)),s.append("sdkAppId",String(i)),s.append("isStrGroupId",r),s.append("groupId",String(o)),s.append("sdkVersion",Wn),s.append("userSig",String(c)),Hl&&s.append("oversea",!0),yV(i,n),l=De(),k.next=17,kV(s,a,i);case 17:return(u=k.sent).config&&(u.config.loggerDomain&&Pl(u.config.loggerDomain),Ct(u.config.scheduleCache)&&Dn(!u.config.scheduleCache)),a.delta=De()-l,BS({stat:a,userId:n}),ih=u,k.abrupt("return",{isCached:!1,result:u});case 25:throw k.prev=25,k.t0=k.catch(4),h=Yr(k.t0)?k.t0[0]:k.t0,g=Rt(h.code)?h.code:0,b="schedule failed".concat(h.message?": ".concat(h.message):""),T=new j({code:V.SCHEDULE_FAILED,extraCode:g,message:H({key:Iy,data:{error:b,code:g}})}),z.error(T),BS({stat:a,userId:n,error:T}),T;case 34:case"end":return k.stop()}},e,null,[[4,25]])})),oh.apply(this,arguments)}function BS(e){var t=e.stat,n=e.userId,i=e.error;i?J.logFailedEvent({eventType:ty,error:i,userId:n}):J.logSuccessEvent({eventType:ty,delta:t.delta,userId:n}),J.uploadEvent({log:"stat-schedule:"+JSON.stringify(t),userId:n})}function fs(e){var t,n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:le;return t=Hl||(Xy(e)?n===le?qM:KM:n===le?zM:JM),"https://".concat(t,"/api/v1/config")}function bV(e,t,n){return new Promise(function(i,r){cs({url:e,body:t,timeout:n.timeout}).then(function(o){o.data.code===0?i(o.data.data):r({code:o.data.code,message:o.data.msg})}).catch(r)})}U.on(sr,function(){return Dn(!0)}),U.on(g3,function(){return Dn(!0)}),U.on(y3,function(){return Dn(!0)}),U.on(cS,function(){return Dn(!0)}),U.on(hs,function(e){e.state===Ol&&Dn(!0)});var HS=function(e,t){return fa({retryFunction:bV,settings:{retries:3,timeout:0},onError:t,onRetrying:e})};function kV(e,t,n){return new Promise(function(i,r){var o,c=null;(o=[HS(function(a){return t.count[0]=a+1},function(a,s){t.msg[0]=a.message,c||s()})(fs(n,le),e,{get timeout(){return 1e3*ss(2+t.count[0])}}),HS(function(a){return t.count[1]=a+1},function(a,s){t.msg[1]=a.message,c||s()})(fs(n,Et),e,{get timeout(){return 1e3*ss(2+t.count[1])}})],new Promise(function(a,s){var l=[];o.forEach(function(u){u.then(a).catch(function(h){l.push(h),l.length===o.length&&s(l)})})})).then(function(a){i(c=a)}).catch(r)})}var IV=function(){function e(i){ce(this,e),this.client_=i.client,this.sdkAppId_=i.sdkAppId,this.userId_=i.userId,this.userSig_=i.userSig,this.url_=i.url,this.backupUrl_=i.backupUrl;var r="?sdkAppId=".concat(encodeURIComponent(this.sdkAppId_),"&userId=").concat(encodeURIComponent(this.userId_),"&userSig=").concat(encodeURIComponent(this.userSig_),"&roomId=").concat(encodeURIComponent(i.roomId)),o=this.client_.getSystemResult();if(o&&o.detail){var c=o.detail,a=c.isH264EncodeSupported,s=c.isVp8EncodeSupported,l=c.isH264DecodeSupported,u=c.isVp8DecodeSupported;r+="&enc264=".concat(Number(a),"&dec264=").concat(Number(l),"&encVp8=").concat(Number(s),"&decVp8=").concat(Number(u))}i.signalDomainWhenUnifiedProxy&&(r+="&signalDomain=".concat(encodeURIComponent(i.signalDomainWhenUnifiedProxy))),this.urlParams=r,this.isConnected_=!1,this.isConnecting_=!1,this.socketInUse_=null,this.socket_=null,this.backupSocket_=null,this.backupTimer_=-1,this.signalInfo_={},this.currentState_=ps,this.reconnectionCount_=0,this.reconnectionTimer_=-1,this.lastMessageTime_=-1,this.seq_=0,this.log_=z.createLogger({id:"ws|"+this.userId_,userId:this.userId_,sdkAppId:this.sdkAppId_}),this.emitter_=new Pn}var t,n;return ue(e,[{key:"urlWithParam_",get:function(){return"".concat(this.url_).concat(this.urlParams)}},{key:"backupUrlWithParam_",get:function(){return"".concat(this.backupUrl_).concat(this.urlParams)}},{key:"isOnline",get:function(){return this.currentState_===_a&&Date.now()-this.lastMessageTime_<12e3}},{key:"connect",value:function(){var i=this;return new Promise(function(r,o){i.log_.info("connect to url: ".concat(i.urlWithParam_)),i.emitConnectionStateChanged(AS),i.socket_=new WebSocket(i.urlWithParam_),i.bindSocket(i.socket_),i.backupTimer_=setTimeout(function(){i.isConnected_||(i.log_.info("trying to connect to backupUrl"),i.tryConnectBackup())},5e3);var c=setTimeout(function(){i.close(),o(new j({code:V.JOIN_ROOM_FAILED,message:"join room timeout"}))},1e4);i.once(ma,function(){clearTimeout(c),r()}),i.once($d,function(a){clearTimeout(c),o(a)})})}},{key:"tryConnectBackup",value:function(){this.backupSocket_||(this.unbindAndCloseSocket(le),this.log_.debug("try to connect to url: ".concat(this.backupUrlWithParam_)),this.backupSocket_=new WebSocket(this.backupUrlWithParam_),this.bindSocket(this.backupSocket_))}},{key:"bindSocket",value:function(i){i.onopen=this.onopen.bind(this),i.onclose=this.onclose.bind(this),i.onerror=this.onerror.bind(this),i.onmessage=this.onmessage.bind(this)}},{key:"unbindSocket",value:function(i){i.onopen=function(){},i.onclose=function(){},i.onerror=function(){},i.onmessage=function(){}}},{key:"unbindAndCloseSocket",value:function(i){if(i===le){if(this.socket_){this.unbindSocket(this.socket_);try{this.socket_.close(1e3)}catch{}this.socket_=null}}else if(this.backupSocket_){this.unbindSocket(this.backupSocket_);try{this.backupSocket_.close(1e3)}catch{}this.backupSocket_=null}}},{key:"clearBackupTimer",value:function(){this.backupTimer_!==-1&&(clearTimeout(this.backupTimer_),this.backupTimer_=-1)}},{key:"clearReconnectionTimer",value:function(){this.reconnectionTimer_!==-1&&(clearTimeout(this.reconnectionTimer_),this.reconnectionTimer_=-1)}},{key:"onopen",value:function(i){if(!this.isConnected_){this.isConnected_=!0,this.isConnecting_=!1,this.isReconnecting_&&on(this.signalInfo_)&&this.stopReconnection(),this.clearBackupTimer(),i.target===this.socket_?(this.unbindAndCloseSocket(Et),this.socketInUse_=this.socket_):(this.unbindAndCloseSocket(le),this.socketInUse_=this.backupSocket_);var r=i.target.url;this.log_.info("websocket[".concat(r,"] is connected")),this.currentState_===AS?this.addSignalEvent(KU,"signal channel is connected"):this.currentState_===Zd&&this.addSignalEvent($U,"signal channel reconnect success"),this.emitConnectionStateChanged(_a),this.emitter_.emit(ma)}}},{key:"onclose",value:function(i){var r=i.target.url,o=i.target===this.socketInUse_;if(this.log_.info("websocket[".concat(r," InUse: ").concat(o,"] is closed with code: ").concat(i.code)),o&&(this.isConnected_=!1,this.emitConnectionStateChanged(ps),this.addSignalEvent(qU,"signal channel is disconnected"),!i.wasClean||i.code!==1e3)){this.log_.warn("onclose code:".concat(i.code," reason:").concat(i.reason)),this.log_.warn("close current websocket and schedule a reconnect timeout"),this.socketInUse_.onclose=function(){},this.socketInUse_.close(4011);var c=this.socketInUse_===this.socket_;this.socket_=this.backupSocket_=this.socketInUse_=null,this.reconnect(c?Et:le)}}},{key:"onerror",value:function(i){var r=i.target.url;if(this.log_.error("websocket[".concat(r,"] error observed")),this.isConnected_){if(i.target===this.socketInUse_){this.isConnected_=!1,this.unbindAndCloseSocket(le),this.unbindAndCloseSocket(Et);var o=this.socketInUse_===this.socket_;this.socketInUse_=null,this.reconnect(o?Et:le)}}else this.isReconnecting_||J.logFailedEvent({userId:this.client_.getUserId(),eventType:Ll,code:V.UNKNOWN}),i.target==this.socket_?(this.unbindAndCloseSocket(le),this.reconnect(Et)):(this.unbindAndCloseSocket(Et),this.reconnect(le));this.isConnecting_=!1,this.isConnected_=!1}},{key:"onmessage",value:function(i){if(this.isConnected_){this.lastMessageTime_=Date.now();var r=JSON.parse(i.data),o=r.cmd,c=r.data,a=Object.values(an),s=Object.keys(an)[a.indexOf(o)],l=pe[s];switch(uU.includes(o)||(this.log_.debug("received msg: ".concat(i.data)),this.log_.info("Received event: [ ".concat(l||"unknown cmd: "+o," ]"))),o){case an.CHANNEL_SETUP_RESULT:if(r.code===0)this.signalInfo_.clientIp=c.clientIp,this.signalInfo_.signalIp=c.signalInnerIp,this.signalInfo_.tinyId=r.tinyId,c.svrTime&&function(h){$u=h-new Date().getTime();var g=new Date;g.setTime(h),z.info("baseTime from server: "+g+" offset: "+$u)}(c.svrTime),this.log_.info("ChannelSetup Success"),J.logSuccessEvent({userId:this.userId_,eventType:Ll}),this.emitter_.emit(RS,{signalInfo:this.signalInfo_});else{var u=new j({code:V.SIGNAL_CHANNEL_SETUP_FAILED,extraCode:r.code,message:H({key:hN,data:{errorCode:r.code,errorMsg:r.message}})});this.log_.error("".concat(r.code,", ").concat(r.message)),this.close(),J.logFailedEvent({userId:this.userId_,eventType:Ll,error:u}),this.emitter_.emit(CS,u)}break;case an.JOIN_ROOM_RESULT:r.code===0&&(this.signalInfo_.relayIp=c.relayOuterIp,this.signalInfo_.relayInnerIp=c.relayInnerIp,this.signalInfo_.relayPort=c.relayPort,this.log_.info("signalIp:".concat(this.signalInfo_.signalIp," clientIp:").concat(this.signalInfo_.clientIp," relayIp: ").concat(this.signalInfo_.relayIp))),this.emitter_.emit(l,{data:r});break;case an.CHANNEL_RECONNECT_RESULT:r.code===0?(this.log_.warn("reconnect success"),this.stopReconnection(),J.logSuccessEvent({userId:this.userId_,eventType:Qg}),this.client_.syncUserList(),this.client_.checkConnectionsToReconnect()):(this.log_.warn("reconnect failed, ".concat(r.code," ").concat(r.message)),this.client_.reJoin());break;default:this.emitter_.emit(l,{data:r})}}}},{key:"addSignalEvent",value:function(i,r){rt(this.userId_,{eventId:i,eventDesc:r,timestamp:Qe(),userId:this.userId_,tinyId:this.signalInfo_.tinyId})}},{key:"reconnect",value:(n=F(M().mark(function i(){var r,o,c,a,s=this,l=arguments;return M().wrap(function(u){for(;;)switch(u.prev=u.next){case 0:if(r=l.length>0&&l[0]!==void 0?l[0]:le,!this.isConnecting_&&this.reconnectionTimer_===-1){u.next=4;break}return this.log_.info("signal channel is reconnecting, ignoring current reconnection"),u.abrupt("return");case 4:if(U.emit(cS,this.client_),!(this.reconnectionCount_>=Nl)){u.next=12;break}return this.log_.warn("SDK has tried reconnect signal channel for ".concat(Nl," times, but all failed. please check your network")),o=new j({code:V.SIGNAL_CHANNEL_RECONNECTION_FAILED,message:H({key:dN})}),J.logFailedEvent({userId:this.client_.getUserId(),eventType:Qg,error:o}),this.addSignalEvent(ZU,"signal channel reconnect fail"),this.emitter_.emit($d,o),u.abrupt("return");case 12:if(this.isConnecting_=!0,this.reconnectionCount_++,this.currentState_!==Zd&&(this.emitConnectionStateChanged(Zd),this.addSignalEvent(YU,"signal channel is reconnecting")),this.log_.warn("reconnecting to ".concat(r," signal channel [").concat(this.reconnectionCount_,"/").concat(Nl,"]")),!(this.reconnectionCount_>=3&&this.reconnectionCount_%3==0)){u.next=20;break}return this.log_.warn("re-schedule to get new ws url"),u.next=20,this.reGetSignalChannelUrl();case 20:c=this.getReconnectionUrl(r),r===le?(this.socket_=new WebSocket(c),this.bindSocket(this.socket_)):(this.backupSocket_=new WebSocket(c),this.bindSocket(this.backupSocket_)),a=gd(this.reconnectionCount_),this.reconnectionTimer_=setTimeout(function(){s.log_.warn("reconnect ".concat(r," signal channel timeout(").concat(a/1e3,"s), close and try again")),s.isConnecting_=!1,s.clearReconnectionTimer(),s.unbindAndCloseSocket(r),s.reconnect(r===le?Et:le)},a);case 24:case"end":return u.stop()}},i,this)})),function(){return n.apply(this,arguments)})},{key:"reGetSignalChannelUrl",value:(t=F(M().mark(function i(){var r,o,c,a;return M().wrap(function(s){for(;;)switch(s.prev=s.next){case 0:if(s.prev=0,!this.client_.getWSProxy()&&!this.client_.getUnifiedProxy()){s.next=3;break}return s.abrupt("return");case 3:return Dn(!0),s.next=6,this.client_.schedule(this.client_.getRoomId());case 6:r=this.client_.getSignalChannelUrl(),o=r.mainUrl,c=r.backupUrl,this.url_=o,this.backupUrl_=c,(a=new URLSearchParams(this.urlParams)).has("signalDomain")&&(a.set("signalDomain",o),this.urlParams=a.toString()),s.next=15;break;case 13:s.prev=13,s.t0=s.catch(0);case 15:case"end":return s.stop()}},i,this,[[0,13]])})),function(){return t.apply(this,arguments)})},{key:"isConnected",value:function(){return this.isConnected_}},{key:"isReconnecting_",get:function(){return this.reconnectionTimer_!==-1}},{key:"getReconnectionUrl",value:function(i){var r=i===le?this.urlWithParam_:this.backupUrlWithParam_;if(!on(this.signalInfo_)&&r.indexOf("&rc=1")===-1){var o=this.client_.getRoomId(),c=this.client_.getUseStringRoomId();r+="&rc=1&relayInnerIp=".concat(this.signalInfo_.relayInnerIp,"&relayOuterIp=").concat(this.signalInfo_.relayIp,"&relayPort=").concat(this.signalInfo_.relayPort,"&roomId=").concat(o,"&useStringRoomId=").concat(c)}return r}},{key:"send",value:function(i){var r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(this.isConnected_){var o={cmd:i,data:r,userId:this.userId_,tinyId:this.signalInfo_.tinyId,seq:++this.seq_};return this.socketInUse_.send(JSON.stringify(o)),o.seq}}},{key:"sendWaitForResponse",value:function(i){var r=this,o=i.command,c=i.data,a=i.timeout,s=a===void 0?5e3:a,l=i.responseCommand,u=i.commandDesc,h=i.enableLog,g=h===void 0||h;return new Promise(function(b,T){var k=setTimeout(function(){r.off(l,p);var f=new j({code:V.API_CALL_TIMEOUT,message:H({key:lN,data:{commandDesc:u,command:o}})});g&&r.log_.warn(f),T(f)},s),p=function f(I){I.data.seq===S&&(clearTimeout(k),r.off(l,f),b(I))};r.on(l,p);var S=r.send(o,c)})}},{key:"sendWaitForResponseWithRetry",value:function(){var i=this,r=arguments.length<=0?void 0:arguments[0],o=r.commandDesc,c=r.command,a=r.retries,s=a===void 0?0:a,l=r.retryTimeout,u=l===void 0?0:l;return fa({retryFunction:this.sendWaitForResponse,onRetrying:function(h){i.log_.warn("".concat(o||c," timeout observed, retrying [").concat(h,"/").concat(s,"]"))},settings:{retries:s,timeout:u},context:this}).apply(void 0,arguments)}},{key:"getCurrentState",value:function(){return this.currentState_}},{key:"getSignalInfo",value:function(){return this.signalInfo_}},{key:"stopReconnection",value:function(){this.isReconnecting_&&(this.reconnectionCount_=0,this.clearReconnectionTimer())}},{key:"close",value:function(){this.log_.info("close SignalChannel"),this.clearBackupTimer(),this.stopReconnection(),this.signalInfo_={},this.isConnecting_=!1,this.isConnected_=!1,this.socketInUse_=null,this.unbindAndCloseSocket(le),this.unbindAndCloseSocket(Et),this.emitConnectionStateChanged(ps)}},{key:"on",value:function(i,r,o){this.emitter_.on(i,r,o)}},{key:"removeListener",value:function(i,r,o){this.emitter_.removeListener(i,r,o)}},{key:"once",value:function(i,r,o){this.emitter_.once(i,r,o)}},{key:"off",value:function(i,r,o){this.emitter_.off(i,r,o)}},{key:"emitConnectionStateChanged",value:function(i){i!==this.currentState_&&(this.emitter_.emit(Yd,{prevState:this.currentState_,state:i}),this.currentState_=i)}}]),e}(),TV=Y,wV=Ke.find,EV=co,WS="find",GS=!0;WS in[]&&Array(1).find(function(){GS=!1}),TV({target:"Array",proto:!0,forced:GS},{find:function(e){return wV(this,e,arguments.length>1?arguments[1]:void 0)}}),EV(WS);var At={},zS={},sh={exports:{}},JS=sh.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 e.address!=null?"rtcp:%d %s IP%d %s":"rtcp:%d"}},{push:"rtcpFbTrrInt",reg:/^rtcp-fb:(\*|\d*) trr-int (\d*)/,names:["payload","value"],format:"rtcp-fb:%s trr-int %d"},{push:"rtcpFb",reg:/^rtcp-fb:(\*|\d*) ([\w-_]*)(?: ([\w-_]*))?/,names:["payload","type","subtype"],format:function(e){return e.subtype!=null?"rtcp-fb:%s %s %s":"rtcp-fb:%s %s"}},{push:"ext",reg:/^extmap:(\d+)(?:\/(\w+))?(?: (urn:ietf:params:rtp-hdrext:encrypt))? (\S*)(?: (\S*))?/,names:["value","direction","encrypt-uri","uri","config"],format:function(e){return"extmap:%d"+(e.direction?"/%s":"%v")+(e["encrypt-uri"]?" %s":"%v")+" %s"+(e.config?" %s":"")}},{name:"extmapAllowMixed",reg:/^(extmap-allow-mixed)/},{push:"crypto",reg:/^crypto:(\d*) ([\w_]*) (\S*)(?: (\S*))?/,names:["id","suite","config","sessionConfig"],format:function(e){return e.sessionConfig!=null?"crypto:%d %s %s %s":"crypto:%d %s %s"}},{name:"setup",reg:/^setup:(\w*)/,format:"setup:%s"},{name:"connectionType",reg:/^connection:(new|existing)/,format:"connection:%s"},{name:"mid",reg:/^mid:([^\s]*)/,format:"mid:%s"},{name:"msid",reg:/^msid:(.*)/,format:"msid:%s"},{name:"ptime",reg:/^ptime:(\d*(?:\.\d*)*)/,format:"ptime:%d"},{name:"maxptime",reg:/^maxptime:(\d*(?:\.\d*)*)/,format:"maxptime:%d"},{name:"direction",reg:/^(sendrecv|recvonly|sendonly|inactive)/},{name:"icelite",reg:/^(ice-lite)/},{name:"iceUfrag",reg:/^ice-ufrag:(\S*)/,format:"ice-ufrag:%s"},{name:"icePwd",reg:/^ice-pwd:(\S*)/,format:"ice-pwd:%s"},{name:"fingerprint",reg:/^fingerprint:(\S*) (\S*)/,names:["type","hash"],format:"fingerprint:%s %s"},{push:"candidates",reg:/^candidate:(\S*) (\d*) (\S*) (\d*) (\S*) (\d*) typ (\S*)(?: raddr (\S*) rport (\d*))?(?: tcptype (\S*))?(?: generation (\d*))?(?: network-id (\d*))?(?: network-cost (\d*))?/,names:["foundation","component","transport","priority","ip","port","type","raddr","rport","tcptype","generation","network-id","network-cost"],format:function(e){var t="candidate:%s %d %s %d %s %d typ %s";return t+=e.raddr!=null?" raddr %s rport %d":"%v%v",t+=e.tcptype!=null?" tcptype %s":"%v",e.generation!=null&&(t+=" generation %d"),t+=e["network-id"]!=null?" network-id %d":"%v",t+=e["network-cost"]!=null?" 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 e.attribute!=null&&(t+=" %s",e.value!=null&&(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 e.maxMessageSize!=null?"sctpmap:%s %s %s":"sctpmap:%s %s"}},{name:"xGoogleFlag",reg:/^x-google-flag:([^\s]*)/,format:"x-google-flag:%s"},{push:"rids",reg:/^rid:([\d\w]+) (\w+)(?: ([\S| ]*))?/,names:["id","direction","params"],format:function(e){return e.params?"rid:%s %s %s":"rid:%s %s"}},{push:"imageattrs",reg:new RegExp("^imageattr:(\\d+|\\*)[\\s\\t]+(send|recv)[\\s\\t]+(\\*|\\[\\S+\\](?:[\\s\\t]+\\[\\S+\\])*)(?:[\\s\\t]+(recv|send)[\\s\\t]+(\\*|\\[\\S+\\](?:[\\s\\t]+\\[\\S+\\])*))?"),names:["pt","dir1","attrs1","dir2","attrs2"],format:function(e){return"imageattr:%s %s %s"+(e.dir2?" %s %s":"")}},{name:"simulcast",reg:new RegExp("^simulcast:(send|recv) ([a-zA-Z0-9\\-_~;,]+)(?:\\s?(send|recv) ([a-zA-Z0-9\\-_~;,]+))?$"),names:["dir1","list1","dir2","list2"],format:function(e){return"simulcast:%s %s"+(e.dir2?" %s %s":"")}},{name:"simulcast_03",reg:/^simulcast:[\s\t]+([\S+\s\t]+)$/,names:["value"],format:"simulcast: %s"},{name:"framerate",reg:/^framerate:(\d+(?:$|\.\d+))/,format:"framerate:%s"},{name:"sourceFilter",reg:/^source-filter: *(excl|incl) (\S*) (IP4|IP6|\*) (\S*) (.*)/,names:["filterMode","netType","addressTypes","destAddress","srcList"],format:"source-filter: %s %s %s %s %s"},{name:"bundleOnly",reg:/^(bundle-only)/},{name:"label",reg:/^label:(.+)/,format:"label:%s"},{name:"sctpPort",reg:/^sctp-port:(\d+)$/,format:"sctp-port:%s"},{name:"maxMessageSize",reg:/^max-message-size:(\d+)$/,format:"max-message-size:%s"},{push:"tsRefClocks",reg:/^ts-refclk:([^\s=]*)(?:=(\S*))?/,names:["clksrc","clksrcExt"],format:function(e){return"ts-refclk:%s"+(e.clksrcExt!=null?"=%s":"")}},{name:"mediaClk",reg:/^mediaclk:(?:id=(\S*))? *([^\s=]*)(?:=(\S*))?(?: *rate=(\d+)\/(\d+))?/,names:["id","mediaClockName","mediaClockValue","rateNumerator","rateDenominator"],format:function(e){var t="mediaclk:";return t+=e.id!=null?"id=%s %s":"%v%s",t+=e.mediaClockValue!=null?"=%s":"",t+=e.rateNumerator!=null?" rate=%s":"",t+=e.rateDenominator!=null?"/%s":""}},{name:"keywords",reg:/^keywds:(.+)$/,format:"keywds:%s"},{name:"content",reg:/^content:(.+)/,format:"content:%s"},{name:"bfcpFloorCtrl",reg:/^floorctrl:(c-only|s-only|c-s)/,format:"floorctrl:%s"},{name:"bfcpConfId",reg:/^confid:(\d+)/,format:"confid:%s"},{name:"bfcpUserId",reg:/^userid:(\d+)/,format:"userid:%s"},{name:"bfcpFloorId",reg:/^floorid:(.+) (?:m-stream|mstrm):(.+)/,names:["id","mStream"],format:"floorid:%s mstrm:%s"},{push:"invalid",names:["value"]}]};Object.keys(JS).forEach(function(e){JS[e].forEach(function(t){t.reg||(t.reg=/(.*)/),t.format||(t.format="%s")})}),function(e){var t=function(c){return String(Number(c))===c?Number(c):c},n=function(c,a,s){var l=c.name&&c.names;c.push&&!a[c.push]?a[c.push]=[]:l&&!a[c.name]&&(a[c.name]={});var u=c.push?{}:l?a[c.name]:a;(function(h,g,b,T){if(T&&!b)g[T]=t(h[1]);else for(var k=0;k<b.length;k+=1)h[k+1]!=null&&(g[b[k]]=t(h[k+1]))})(s.match(c.reg),u,c.names,c.name),c.push&&a[c.push].push(u)},i=sh.exports,r=RegExp.prototype.test.bind(/^([a-z])=(.*)/);e.parse=function(c){var a={},s=[],l=a;return c.split(/(\r\n|\r|\n)/).filter(r).forEach(function(u){var h=u[0],g=u.slice(2);h==="m"&&(s.push({rtp:[],fmtp:[]}),l=s[s.length-1]);for(var b=0;b<(i[h]||[]).length;b+=1){var T=i[h][b];if(T.reg.test(g))return n(T,l,g)}}),a.media=s,a};var o=function(c,a){var s=a.split(/=(.+)/,2);return s.length===2?c[s[0]]=t(s[1]):s.length===1&&a.length>1&&(c[s[0]]=void 0),c};e.parseParams=function(c){return c.split(/;\s?/).reduce(o,{})},e.parseFmtpConfig=e.parseParams,e.parsePayloads=function(c){return c.toString().split(" ").map(Number)},e.parseRemoteCandidates=function(c){for(var a=[],s=c.split(" ").map(t),l=0;l<s.length;l+=3)a.push({component:s[l],ip:s[l+1],port:s[l+2]});return a},e.parseImageAttributes=function(c){return c.split(" ").map(function(a){return a.substring(1,a.length-1).split(",").reduce(o,{})})},e.parseSimulcastStreamList=function(c){return c.split(";").map(function(a){return a.split(",").map(function(s){var l,u=!1;return s[0]!=="~"?l=t(s):(l=t(s.substring(1,s.length)),u=!0),{scid:l,paused:u}})})}}(zS);var ch=sh.exports,RV=/%[sdv%]/g,CV=function(e){var t=1,n=arguments,i=n.length;return e.replace(RV,function(r){if(t>=i)return r;var o=n[t];switch(t+=1,r){case"%%":return"%";case"%s":return String(o);case"%d":return Number(o);case"%v":return""}})},ya=function(e,t,n){var i=[e+"="+(t.format instanceof Function?t.format(t.push?n:n[t.name]):t.format)];if(t.names)for(var r=0;r<t.names.length;r+=1){var o=t.names[r];t.name?i.push(n[t.name][o]):i.push(n[t.names[r]])}else i.push(n[t.name]);return CV.apply(null,i)},AV=["v","o","s","i","u","e","p","c","b","t","r","z","a"],xV=["i","c","b","a"],ur=zS,PV=function(e,t){t=t||{},e.version==null&&(e.version=0),e.name==null&&(e.name=" "),e.media.forEach(function(o){o.payloads==null&&(o.payloads="")});var n=t.outerOrder||AV,i=t.innerOrder||xV,r=[];return n.forEach(function(o){ch[o].forEach(function(c){c.name in e&&e[c.name]!=null?r.push(ya(o,c,e)):c.push in e&&e[c.push]!=null&&e[c.push].forEach(function(a){r.push(ya(o,c,a))})})}),e.media.forEach(function(o){r.push(ya("m",ch.m[0],o)),i.forEach(function(c){ch[c].forEach(function(a){a.name in o&&o[a.name]!=null?r.push(ya(c,a,o)):a.push in o&&o[a.push]!=null&&o[a.push].forEach(function(s){r.push(ya(c,a,s))})})})}),r.join(`\r
`)+`\r
`};At.write=PV,At.parse=ur.parse,At.parseParams=ur.parseParams,At.parseFmtpConfig=ur.parseFmtpConfig,At.parsePayloads=ur.parsePayloads,At.parseRemoteCandidates=ur.parseRemoteCandidates,At.parseImageAttributes=ur.parseImageAttributes,At.parseSimulcastStreamList=ur.parseSimulcastStreamList;var uh,lh,dh,hh,sn=function(e){return At.parse(e)},ii=function(e){return At.write(e)},DV=function(e){var t=sn(e);return t.media.forEach(function(n){n.type===K&&n.fmtp.forEach(function(i){i.config+=";sprop-stereo=1;stereo=1"})}),ii(t)},qS=((uh=window)===null||uh===void 0?void 0:uh.requestIdleCallback)||function(e){var t=Date.now();return setTimeout(function(){e({didTimeout:!1,timeRemaining:function(){return Math.max(0,50-(Date.now()-t))}})},1e3)},OV=((lh=window)===null||lh===void 0?void 0:lh.cancelIdleCallback)||function(e){clearTimeout(e)},MV=((dh=window)===null||dh===void 0?void 0:dh.cancelAnimationFrame)||((hh=window)===null||hh===void 0?void 0:hh.mozCancelAnimationFrame),ye=function(){function e(){ce(this,e)}return ue(e,null,[{key:"generateTaskID",value:function(){return this.currentTaskID++}},{key:"run",value:function(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:_y,n=arguments.length>1?arguments[1]:void 0,i=arguments.length>2?arguments[2]:void 0;i=te(te({},t===ZM?{delay:2e3,count:0,backgroundTask:!0}:t===Kr?{delay:1e4,count:0}:t===Xo?{fps:60,delay:16.6,count:0,backgroundTask:!0}:{delay:2e3,count:0,backgroundTask:!0}),i),Yy(n)&&(i=te(te({},i),n)),et(t)&&(n=t,t=_y);var r=te({taskID:this.generateTaskID(),loopCount:0,intervalID:null,timeoutID:null,rafID:null,ricID:null,taskName:t,callback:n},i);return this.taskMap.set(r.taskID,r),this[t](r),r.taskID}},{key:"interval",value:function(t){var n=this;return t.intervalID=setInterval(function(){t.callback(),t.loopCount+=1,n.isBreakLoop(t)},t.delay)}},{key:"timeout",value:function(t){var n=this;return t.timeoutID=setTimeout(function i(){if(t.callback(),t.loopCount+=1,!n.isBreakLoop(t))return t.timeoutID=setTimeout(i,t.delay)},t.delay)}},{key:"ric",value:function(t){var n,i=this,r=De();return t.ricID=qS(function o(){if((n=De()-r)>=t.delay&&(r=De()-Math.floor(n%t.delay),t.callback(),t.loopCount+=1),!i.isBreakLoop(t))return t.ricID=qS(o,{timeout:t.delay})},{timeout:t.delay})}},{key:"raf",value:function(t){var n=this;t.delay=(1e3/t.fps).toFixed(2);var i,r=De(),o=function a(){if(document.hidden&&t.backgroundTask)return i=De()-r,r=De(),t.callback(),t.loopCount+=1,n.isBreakLoop(t)?void 0:t.timeoutID=setTimeout(a,t.delay-Math.floor(i%t.delay));if((i=De()-r)>=t.delay&&(r=De()-Math.floor(i%t.delay),t.callback(),t.loopCount+=1),!n.isBreakLoop(t))return t.rafID=requestAnimationFrame(a)};if(t.rafID=requestAnimationFrame(o),t.backgroundTask){var c=function(){if(document.hidden){var a=De()-r;a>=t.delay?o():t.timeoutID=setTimeout(o,t.delay-a)}};document.addEventListener("visibilitychange",c),t.onVisibilitychange=c,document.hidden&&c()}return t.taskID}},{key:"hasTask",value:function(t){return this.taskMap.has(t)}},{key:"clearTask",value:function(t){if(!this.taskMap.has(t))return!0;var n=this.taskMap.get(t),i=n.intervalID,r=n.timeoutID,o=n.rafID,c=n.ricID,a=n.onVisibilitychange;return i&&clearInterval(i),r&&clearTimeout(r),o&&MV(o),c&&OV(c),a&&document.removeEventListener("visibilitychange",a),this.taskMap.delete(t),!0}},{key:"isBreakLoop",value:function(t){return!this.taskMap.has(t.taskID)||t.count!==0&&t.loopCount>=t.count&&(this.clearTask(t.taskID),!0)}}]),e}();Ba(ye,"taskMap",new Map),Ba(ye,"currentTaskID",1);var NV=function(){function e(){ce(this,e),this.prefix_="TRTC",this.queue_=new Map,this.checkStorage()}return ue(e,[{key:"getRealKey",value:function(t){return"".concat(this.prefix_,"_").concat(t)}},{key:"checkStorage",value:function(){var t=this;if(ir()){var n=Object.keys(localStorage).filter(function(i){if(i.startsWith(t.prefix_)){var r=JSON.parse(localStorage.getItem(i));if(r&&r.expiresIn<Date.now())return!0}return!1});n.forEach(function(i){return localStorage.removeItem(i)})}}},{key:"doFlush",value:function(){if(ir())try{var t,n=qt(this.queue_);try{for(n.s();!(t=n.n()).done;){var i=lt(t.value,2),r=i[0],o=i[1];localStorage.setItem(r,JSON.stringify(o))}}catch(c){n.e(c)}finally{n.f()}}catch(c){z.warn(c)}}},{key:"getItem",value:function(t){if(!ir())return null;try{var n=JSON.parse(localStorage.getItem(this.getRealKey(t)));return n&&n.expiresIn>=Date.now()?n.value:null}catch(i){z.warn(i)}}},{key:"setItem",value:function(t,n){var i=arguments.length>2&&arguments[2]!==void 0&&arguments[2];if(ir())try{var r={expiresIn:Date.now()+cy,value:n};i?localStorage.setItem(this.getRealKey(t),JSON.stringify(r)):(this.queue_.set(this.getRealKey(t),r),ye.hasTask(this.intervalId_)||(this.intervalId_=ye.run(Kr,this.doFlush.bind(this),{count:1})))}catch(o){z.warn(o)}}},{key:"deleteItem",value:function(t){if(!ir())return!1;try{return t=this.getRealKey(t),this.queue_.delete(t),localStorage.removeItem(t),!0}catch(n){return z.warn(n),!1}}},{key:"clear",value:function(){if(ir())try{localStorage.clear()}catch(t){z.warn(t)}}}]),e}(),ai=new NV,Ie={result:!1,detail:{isBrowserSupported:!1,isWebRTCSupported:!1,isMediaDevicesSupported:!1,isH264EncodeSupported:!1,isVp8EncodeSupported:!1,isH264DecodeSupported:!1,isVp8DecodeSupported:!1}},KS="checkResult",QS=function(){return!a3&&!$o&&!(Zo&&Hy<80)&&!(ft&&By<56)},ph=function(){return["RTCPeerConnection","webkitRTCPeerConnection","RTCIceGatherer"].filter(function(e){return e in window}).length>0},LV=function(){if(!navigator.mediaDevices)return!1;var e=["getUserMedia","enumerateDevices"];return e.filter(function(t){return t in navigator.mediaDevices}).length===e.length},XS=function(){var e=F(M().mark(function t(){var n,i,r,o,c,a;return M().wrap(function(s){for(;;)switch(s.prev=s.next){case 0:if(!Ie.detail.isH264EncodeSupported||!Ie.detail.isVp8EncodeSupported){s.next=2;break}return s.abrupt("return",{isH264EncodeSupported:Ie.detail.isH264EncodeSupported,isVp8EncodeSupported:Ie.detail.isVp8EncodeSupported});case 2:return n="",i=!1,r=!1,s.prev=5,o=new RTCPeerConnection,(c=document.createElement(Eg)).getContext("2d"),a=c.captureStream(0),o.addTrack(a.getVideoTracks()[0],a),s.next=13,o.createOffer();case 13:return(n=s.sent).sdp.toLowerCase().indexOf("h264")!==-1&&(i=!0),n.sdp.toLowerCase().indexOf("vp8")!==-1&&(r=!0),o.close(),Ie.detail.isH264EncodeSupported=i,Ie.detail.isVp8EncodeSupported=r,s.abrupt("return",{isH264EncodeSupported:Ie.detail.isH264EncodeSupported,isVp8EncodeSupported:Ie.detail.isVp8EncodeSupported});case 22:return s.prev=22,s.t0=s.catch(5),s.abrupt("return",{isH264EncodeSupported:!1,isVp8EncodeSupported:!1});case 25:case"end":return s.stop()}},t,null,[[5,22]])}));return function(){return e.apply(this,arguments)}}();function UV(){return fh.apply(this,arguments)}function fh(){return fh=F(M().mark(function e(){return M().wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",new Promise(function(){var n=F(M().mark(function i(r){var o,c,a,s,l,u,h,g,b,T,k,p,S,f;return M().wrap(function(I){for(;;)switch(I.prev=I.next){case 0:return o={encode:!1,decode:!1},c=null,I.prev=2,a=document.createElement("canvas"),s=a.getContext("2d"),a.width=640,a.height=480,l=setInterval(function(){s.fillText("test",Math.floor(640*Math.random()),Math.floor(480*Math.random()))},33),u=-1,h=-1,c=function(){clearInterval(u),clearInterval(l),clearTimeout(h),b.close(),T.close(),g.getTracks().forEach(function(A){return A.stop()})},h=setTimeout(function(){c(),r(o)},3e3),g=a.captureStream(),b=new RTCPeerConnection({}),T=new RTCPeerConnection({offerToReceiveAudio:!0,offerToReceiveVideo:!0}),b.addEventListener("icecandidate",function(A){return T.addIceCandidate(A.candidate)}),T.addEventListener("icecandidate",function(A){return b.addIceCandidate(A.candidate)}),b.addTrack(g.getVideoTracks()[0],g),I.next=20,b.createOffer();case 20:return k=I.sent,I.next=23,b.setLocalDescription(k);case 23:return I.next=25,T.setRemoteDescription(k);case 25:return I.next=27,T.createAnswer();case 27:return p=I.sent,S=sn(p.sdp),f=S.media[0].rtp.findIndex(function(A){return A.codec==="H264"}),S.media[0].rtp=[S.media[0].rtp[f]],S.media[0].fmtp=S.media[0].fmtp.filter(function(A){return A.payload===S.media[0].rtp[0].payload}),S.media[0].rtcpFb=S.media[0].rtcpFb.filter(function(A){return A.payload===S.media[0].rtp[0].payload}),p.sdp=ii(S),I.next=36,T.setLocalDescription(p);case 36:return I.next=38,b.setRemoteDescription(p);case 38:u=setInterval(F(M().mark(function A(){var x,D;return M().wrap(function(m){for(;;)switch(m.prev=m.next){case 0:return o.encode&&o.decode&&(c(),r(o)),m.next=3,b.getStats();case 3:return x=m.sent,m.next=6,T.getStats();case 6:D=m.sent,o.encode||x.forEach(function(v){v.type==="outbound-rtp"&&v.mediaType===q&&v.framesEncoded>0&&(o.encode=!0)}),o.decode||D.forEach(function(v){v.type==="inbound-rtp"&&v.mediaType===q&&v.framesDecoded>0&&(o.decode=!0)});case 9:case"end":return m.stop()}},A)})),500),I.next=46;break;case 41:I.prev=41,I.t0=I.catch(2),c(),z.warn(I.t0),r(o);case 46:case"end":return I.stop()}},i,null,[[2,41]])}));return function(i){return n.apply(this,arguments)}}()));case 1:case"end":return t.stop()}},e)})),fh.apply(this,arguments)}var YS=function(){var e=F(M().mark(function t(){var n,i,r,o;return M().wrap(function(c){for(;;)switch(c.prev=c.next){case 0:if(!Ie.detail.isH264DecodeSupported||!Ie.detail.isVp8DecodeSupported){c.next=2;break}return c.abrupt("return",{isH264DecodeSupported:Ie.detail.isH264DecodeSupported,isVp8DecodeSupported:Ie.detail.isVp8DecodeSupported});case 2:return n="",i=!1,r=!1,c.prev=5,o=new RTCPeerConnection,c.next=9,o.createOffer({offerToReceiveAudio:1,offerToReceiveVideo:1});case 9:return(n=c.sent).sdp.toLowerCase().indexOf("h264")!==-1&&(i=!0),n.sdp.toLowerCase().indexOf("vp8")!==-1&&(r=!0),o.close(),c.abrupt("return",{isH264DecodeSupported:i,isVp8DecodeSupported:r});case 16:return c.prev=16,c.t0=c.catch(5),c.abrupt("return",{isH264DecodeSupported:!1,isVp8DecodeSupported:!1});case 19:case"end":return c.stop()}},t,null,[[5,16]])}));return function(){return e.apply(this,arguments)}}(),VV=function(){var e=F(M().mark(function t(){var n,i,r,o,c,a,s,l,u,h,g,b,T;return M().wrap(function(k){for(;;)switch(k.prev=k.next){case 0:if($S()){k.next=2;break}return k.abrupt("return",Ie);case 2:return n=QS(),i=ph(),r=LV(),k.next=7,XS();case 7:return o=k.sent,c=o.isH264EncodeSupported,a=o.isVp8EncodeSupported,k.next=12,YS();case 12:if(s=k.sent,l=s.isH264DecodeSupported,u=s.isVp8DecodeSupported,c&&a){k.next=21;break}return k.next=18,XS();case 18:h=k.sent,c=h.isH264EncodeSupported,a=h.isVp8EncodeSupported;case 21:if(!(c&&l&&(ts||ns||p3)&&!tn&&Xr()<79)){k.next=29;break}return k.next=24,UV();case 24:g=k.sent,b=g.encode,T=g.decode,c=b,l=T;case 29:return Ie.result=n&&i&&r&&(c||a)&&(l||u),Ie.detail.isBrowserSupported=n,Ie.detail.isWebRTCSupported=i,Ie.detail.isMediaDevicesSupported=r,Ie.detail.isH264EncodeSupported=c,Ie.detail.isVp8EncodeSupported=a,Ie.detail.isH264DecodeSupported=l,Ie.detail.isVp8DecodeSupported=u,jV(),ai.setItem(KS,{ua:navigator.userAgent,checkResult:Ie},!0),k.abrupt("return",Ie);case 40:case"end":return k.stop()}},t)}));return function(){return e.apply(this,arguments)}}(),mh=function(e,t){var n=null;return function(){if(n)return n;for(var i=arguments.length,r=new Array(i),o=0;o<i;o++)r[o]=arguments[o];return(n=e.apply(this,r)).then(function(c){return n=null,c}).catch(function(c){throw n=null,c}),n}}(VV);function $S(){return Object.keys(Ie.detail).findIndex(function(e){return!Ie.detail[e]})>=0}function jV(){$S()&&(z.warn(H({key:xy})),z.info("".concat(navigator.userAgent," ").concat(JSON.stringify(Ie.detail))))}function ZS(){return!(!navigator.mediaDevices||!navigator.mediaDevices.getDisplayMedia)}function eb(){return"RTCPeerConnection"in window&&"getReceivers"in window.RTCPeerConnection.prototype}function ms(){return"RTCPeerConnection"in window&&"getSenders"in window.RTCPeerConnection.prototype}function On(){return"RTCPeerConnection"in window&&"getTransceivers"in window.RTCPeerConnection.prototype}function _s(){return"RTCPeerConnection"in window&&"addTransceiver"in window.RTCPeerConnection.prototype}function _h(){return"RTCRtpSender"in window&&"replaceTrack"in window.RTCRtpSender.prototype}function tb(){return"RTCRtpSender"in window&&"setParameters"in window.RTCRtpSender.prototype&&ms()}function vs(){return!!G(navigator.mediaDevices)&&(z.error(En.NOT_SUPPORTED_MEDIA),!0)}function gs(){return location.protocol==="http:"&&!rr&&(z.warn(H({key:Ay})),!0)}var vh="RTCRtpSender"in window&&"createEncodedStreams"in window.RTCRtpSender.prototype&&Xr()>=86;function gh(e){return!(e.type!=="candidate-pair"||!e.nominated||e.state!=="in-progress"&&e.state!=="succeeded")&&!(Ct(e.selected)&&!e.selected)}var nb=new Map([[Qr,"Android"],[Rn,"iOS"],[Gy,"Windows"],[la,"MacOS"],[zy,"Linux"]]);function yh(){var e="unknown";return nb.get(!0)&&(e=nb.get(!0)),e}function FV(){var e="";return screen.width&&(e+=(screen.width?screen.width*window.devicePixelRatio:"")+" * "+(screen.height?screen.height*window.devicePixelRatio:"")),e}function BV(){var e=!1;return(navigator.getUserMedia||navigator.mediaDevices&&navigator.mediaDevices.getUserMedia)&&(e=!0),e}function HV(){for(var e={isSupported:!1},t=["AudioContext","webkitAudioContext","mozAudioContext","msAudioContext"],n=0;n<t.length;n++)if(t[n]in window){e.isSupported=!0;break}return e.isSupported}function rb(){return!(id&&Xr()<86)&&!(Rn&&Rt(Cn)&&Cn<15)&&!(fd&&fd<63)&&!(!QS()||!("captureStream"in HTMLCanvasElement.prototype))}var lr=window.MediaStreamTrack&&"getSettings"in MediaStreamTrack.prototype,WV=window.MediaStreamTrack&&"getCapabilities"in MediaStreamTrack.prototype,GV=function(){var e,t,n;return((e=window)===null||e===void 0?void 0:e.OffscreenCanvas)&&((t=window)===null||t===void 0?void 0:t.MediaStreamTrackProcessor)&&((n=window)===null||n===void 0?void 0:n.MediaStreamTrackGenerator)};(function(){gs();var e=ai.getItem(KS);e&&e.ua===navigator.userAgent&&(Ie=e.checkResult),mh()})();var de={STREAM_ADDED:"stream-added",STREAM_REMOVED:"stream-removed",STREAM_UPDATED:"stream-updated",STREAM_SUBSCRIBED:"stream-subscribed",ERROR:"error",CONNECTION_STATE_CHANGED:"connection-state-changed",SEI_MESSAGE:xg},fe={STREAM_ADDED:"stream-added",STREAM_REMOVED:"stream-removed",STREAM_UPDATED:"stream-updated",STREAM_SUBSCRIBED:"stream-subscribed",CONNECTION_STATE_CHANGED:"connection-state-changed",PEER_JOIN:"peer-join",PEER_LEAVE:"peer-leave",MUTE_AUDIO:"mute-audio",MUTE_VIDEO:"mute-video",UNMUTE_AUDIO:"unmute-audio",UNMUTE_VIDEO:"unmute-video",CLIENT_BANNED:"client-banned",NETWORK_QUALITY:"network-quality",AUDIO_VOLUME:"audio-volume",SEI_MESSAGE:xg,ERROR:"error"},ib="player-state-changed",zV="screen-sharing-stopped",JV="connection-state-changed",qV="device-auto-recovered",Sh="error",it="player-state-changed",ab="error",KV=yy;Y({target:"String",proto:!0,forced:Sy("small")},{small:function(){return KV(this,"small","","")}});var QV=function(){function e(o){ce(this,e);var c=o.getUserId();this.log_=z.createLogger({id:c,userId:c,sdkAppId:o.getSDKAppId()}),this.prevReportTime_=0,this.prevReport_={},this.prevEncoderImplementation_="",this.prevQualityLimitationReason_="",this.prevDecoderImplementationMap_=new Map}var t,n,i,r;return ue(e,[{key:"statInterval",get:function(){return this.prevReportTime_===0?2:(Date.now()-this.prevReportTime_)/1e3}},{key:"getSenderStats",value:(r=F(M().mark(function o(c){var a,s,l,u,h=this;return M().wrap(function(g){for(;;)switch(g.prev=g.next){case 0:if(a={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},s=c.getPeerConnection(),l=c.getSSRC(),!s){g.next=15;break}return g.prev=4,g.next=7,s.getStats();case 7:g.sent.forEach(function(b){var T;if(b.type==="outbound-rtp")if((b.mediaType||b.kind)===q){if(!ft&&b.bytesSent===0)return;b.ssrc!==l.video||G(b.encoderImplementation)||h.prevEncoderImplementation_===b.encoderImplementation||(h.log_.info("encoderImplementation change to ".concat(b.encoderImplementation)),h.prevEncoderImplementation_=b.encoderImplementation),b.ssrc!==l.video||G(b.qualityLimitationReason)||h.prevQualityLimitationReason_===b.qualityLimitationReason||(h.log_.info("qualityLimitationReason change to ".concat(b.qualityLimitationReason)),h.prevQualityLimitationReason_=b.qualityLimitationReason);var k=q;b.ssrc===l.small?k=en:b.ssrc===l.auxiliary&&(k=ke),a[k].bytesSent=b.bytesSent,a[k].packetsSent=b.packetsSent,a[k].framesEncoded=b.framesEncoded}else a.audio.bytesSent=b.bytesSent,a.audio.packetsSent=b.packetsSent;else b.type==="candidate-pair"?gh(b)&&Rt(b.currentRoundTripTime)&&(a.rtt=Math.floor(1e3*b.currentRoundTripTime)):b.type==="media-source"&&(b.kind===K?(a.audio.audioLevel=b.audioLevel||0,a.audio.totalAudioEnergy=b.totalAudioEnergy||0):b.kind===q&&(b.trackIdentifier===c.getVideoTrackId(q)?a.video.fpsCapture=b.framesPerSecond:b.trackIdentifier===c.getVideoTrackId(ke)?a.auxiliary.fpsCapture=b.framesPerSecond:a.small.fpsCapture=b.framesPerSecond));G(b.audioLevel)||(a.audio.audioLevel=b.audioLevel||0,a.audio.totalAudioEnergy=b.totalAudioEnergy||0),G(b.frameWidth)||(b.trackIdentifier===c.getVideoTrackId(q)||b.ssrc===l.video?T=q:b.trackIdentifier===c.getVideoTrackId(ke)||b.ssrc===l.auxiliary?T=ke:b.trackIdentifier!==c.getVideoTrackId(en)&&b.ssrc!==l.small||(T=en),T&&(a[T].frameWidth=b.frameWidth,a[T].frameHeight=b.frameHeight,a[T].framesSent=b.framesSent))}),a.audio.audioLevel===0&&(a.audio.audioLevel=((u=c.getLocalStream())===null||u===void 0?void 0:u.getInternalAudioLevel())||0),g.next=15;break;case 12:g.prev=12,g.t0=g.catch(4),this.log_.warn("failed to getStats on sender connection "+g.t0);case 15:return g.abrupt("return",a);case 16:case"end":return g.stop()}},o,this,[[4,12]])})),function(o){return r.apply(this,arguments)})},{key:"getReceiverStats",value:(i=F(M().mark(function o(c){var a,s,l,u,h,g=this;return M().wrap(function(b){for(;;)switch(b.prev=b.next){case 0:if(a={tinyId:c.getTinyId(),userId:c.getUserId(),rtt:0,hasAudio:!1,hasVideo:!1,hasAuxiliary:!1,audio:{bytesReceived:0,packetsReceived:0,packetsLost:0,jitter:0,audioLevel:0,totalAudioEnergy:0},video:{bytesReceived:0,packetsReceived:0,packetsLost:0,framesReceived:0,framesDecoded:0,frameWidth:0,frameHeight:0},auxiliary:{bytesReceived:0,packetsReceived:0,packetsLost:0,framesReceived:0,framesDecoded:0,frameWidth:0,frameHeight:0}},!(s=c.getPeerConnection())){b.next=16;break}return b.prev=3,l=c.getSSRC(),u=c.getTrackState(),b.next=8,s.getStats();case 8:b.sent.forEach(function(T){if(T.type==="inbound-rtp")if((T.mediaType||T.kind)===K){if(T.ssrc!==l.audio||!u.audio)return;a.audio.packetsReceived=T.packetsReceived,a.audio.bytesReceived=T.bytesReceived,a.audio.packetsLost=T.packetsLost,a.audio.jitter=T.jitter,a.hasAudio=!0}else{if(ft&&T.bytesReceived===0)return;T.ssrc===l.video&&u.video&&(a.video.packetsReceived=T.packetsReceived,a.video.bytesReceived=T.bytesReceived,a.video.packetsLost=T.packetsLost,a.video.framesReceived=T.framesReceived,a.video.framesDecoded=T.framesDecoded,a.video.fpsDecoded=T.framesPerSecond,a.hasVideo=!0,!T.decoderImplementation||g.prevDecoderImplementationMap_.has(a.userId)&&g.prevDecoderImplementationMap_.get(a.userId)===T.decoderImplementation||(g.log_.info("".concat(a.userId," decoderImplementation change to ").concat(T.decoderImplementation)),g.prevDecoderImplementationMap_.set(a.userId,T.decoderImplementation))),T.ssrc===l.auxiliary&&u.auxiliary&&(a.auxiliary.packetsReceived=T.packetsReceived,a.auxiliary.bytesReceived=T.bytesReceived,a.auxiliary.packetsLost=T.packetsLost,a.auxiliary.framesReceived=T.framesReceived,a.auxiliary.framesDecoded=T.framesDecoded,a.auxiliary.fpsDecoded=T.framesPerSecond,a.hasAuxiliary=!0)}else T.type==="candidate-pair"&&gh(T)&&Rt(T.currentRoundTripTime)&&(a.rtt=Math.floor(1e3*T.currentRoundTripTime));G(T.frameWidth)||(T.trackIdentifier!==c.getMainStreamVideoTrackId()&&T.ssrc!==l.video||(a.video.frameWidth=T.frameWidth,a.video.frameHeight=T.frameHeight),T.trackIdentifier!==c.getAuxStreamVideoTrackId()&&T.ssrc!==l.auxiliary||(a.auxiliary.frameWidth=T.frameWidth,a.auxiliary.frameHeight=T.frameHeight)),G(T.audioLevel)||(a.audio.audioLevel=T.audioLevel||0,a.audio.totalAudioEnergy=T.totalAudioEnergy||0)}),a.audio.audioLevel===0&&(a.audio.audioLevel=((h=c.getMainStream())===null||h===void 0?void 0:h.getInternalAudioLevel())||0),b.next=16;break;case 13:b.prev=13,b.t0=b.catch(3),this.log_.warn("failed to getStats on receiver connection "+b.t0);case 16:return b.abrupt("return",a);case 17:case"end":return b.stop()}},o,this,[[3,13]])})),function(o){return i.apply(this,arguments)})},{key:"getStats",value:(n=F(M().mark(function o(c,a){var s,l,u,h,g,b,T;return M().wrap(function(k){for(;;)switch(k.prev=k.next){case 0:if(s={},!c){k.next=5;break}return k.next=4,this.getSenderStats(c);case 4:s=k.sent;case 5:l=[],u=qt(a),k.prev=7,u.s();case 9:if((h=u.n()).done){k.next=17;break}return(g=lt(h.value,2))[0],b=g[1],k.next=13,this.getReceiverStats(b);case 13:T=k.sent,l.push(T);case 15:k.next=9;break;case 17:k.next=22;break;case 19:k.prev=19,k.t0=k.catch(7),u.e(k.t0);case 22:return k.prev=22,u.f(),k.finish(22);case 25:return k.abrupt("return",{senderStats:s,receiverStats:l});case 26:case"end":return k.stop()}},o,this,[[7,19,22,25]])})),function(o,c){return n.apply(this,arguments)})},{key:"getDifferenceValue",value:function(o,c){if(on(o))return c;var a=c-o;return a<0?0:a}},{key:"prepareReport",value:function(o){var c=this,a=o.stats,s=o.report,l=o.freezeMap;if(!on(a.senderStats)){var u;u={uint32_audio_level:1e8*a.senderStats.audio.audioLevel,uint32_audio_energy:1e6*a.senderStats.audio.totalAudioEnergy,uint32_audio_codec_bitrate:a.senderStats.audio.bytesSent,audioLevel:a.senderStats.audio.audioLevel};var h=[],g={uint32_video_stream_type:2,uint32_video_codec_fps:a.senderStats.video.framesSent,uint32_video_capture_fps:a.senderStats.video.fpsCapture,uint32_video_width:a.senderStats.video.frameWidth,uint32_video_height:a.senderStats.video.frameHeight,uint32_video_codec_bitrate:a.senderStats.video.bytesSent,uint32_video_enc_fps:a.senderStats.video.framesEncoded};if(h.push(g),a.senderStats.small.bytesSent){var b={uint32_video_stream_type:3,uint32_video_codec_fps:a.senderStats.small.framesSent||0,uint32_video_capture_fps:a.senderStats.small.fpsCapture||0,uint32_video_width:a.senderStats.small.frameWidth||0,uint32_video_height:a.senderStats.small.frameHeight||0,uint32_video_codec_bitrate:a.senderStats.small.bytesSent,uint32_video_enc_fps:a.senderStats.small.framesEncoded||0};h.push(b)}if(a.senderStats.auxiliary.bytesSent){var T={uint32_video_stream_type:7,uint32_video_codec_fps:a.senderStats.auxiliary.framesSent||0,uint32_video_capture_fps:a.senderStats.auxiliary.fpsCapture||0,uint32_video_width:a.senderStats.auxiliary.frameWidth||0,uint32_video_height:a.senderStats.auxiliary.frameHeight||0,uint32_video_codec_bitrate:a.senderStats.auxiliary.bytesSent,uint32_video_enc_fps:a.senderStats.auxiliary.framesEncoded||0};h.push(T)}var k={uint32_bitrate:0,uint32_rtt:a.senderStats.rtt};s.msg_up_stream_info={msg_audio_status:u,msg_video_status:h,msg_network_status:k}}var p=this.statInterval;s.msg_down_stream_info=[],a.receiverStats.forEach(function(v){var w={};if(w.msg_user_info={str_identifier:v.userId,uint64_tinyid:v.tinyId},w.msg_network_status={uint32_rtt:v.rtt},w.msg_video_status={},v.hasAudio){var R={uint32_audio_codec_bitrate:v.audio.bytesReceived,uint32_audio_total_bitrate:v.audio.bytesReceived,uint32_audio_level:1e8*v.audio.audioLevel,uint32_audio_energy:1e6*v.audio.totalAudioEnergy,uint32_audio_receive:v.audio.packetsReceived,uint32_audio_origin_lost:v.audio.packetsLost,audioLevel:v.audio.audioLevel};w.msg_audio_status=R}if(w.msg_video_status=[],v.hasVideo){var P=l.get(v.userId+"_"+Te),y=P?P.duration:0,d={uint32_video_stream_type:2,uint32_video_receive_fps:v.video.framesReceived,uint32_video_width:v.video.frameWidth,uint32_video_height:v.video.frameHeight,uint32_video_codec_bitrate:v.video.bytesReceived,uint32_video_receive:v.video.packetsReceived,uint32_video_origin_lost:v.video.packetsLost,uint32_video_block_time:y,uint32_video_dec_fps:v.video.framesDecoded};w.msg_video_status.push(d)}if(v.hasAuxiliary){var _=l.get(v.userId+"_"+Ne),E=_?_.duration:0,C={uint32_video_stream_type:7,uint32_video_receive_fps:v.auxiliary.framesReceived,uint32_video_width:v.auxiliary.frameWidth,uint32_video_height:v.auxiliary.frameHeight,uint32_video_codec_bitrate:v.auxiliary.bytesReceived,uint32_video_receive:v.auxiliary.packetsReceived+v.auxiliary.packetsLost,uint32_video_origin_lost:v.auxiliary.packetsLost,uint32_video_block_time:E,uint32_video_dec_fps:v.auxiliary.framesDecoded};w.msg_video_status.push(C)}s.msg_down_stream_info.push(w)});var S=this.prevReport_;if(this.prevReport_=JSON.parse(JSON.stringify(s)),s.msg_up_stream_info.msg_audio_status&&S.msg_up_stream_info.msg_audio_status){var f=S.msg_up_stream_info.msg_audio_status,I=s.msg_up_stream_info.msg_audio_status,A=this.getDifferenceValue(f.uint32_audio_codec_bitrate,I.uint32_audio_codec_bitrate);I.uint32_audio_codec_bitrate=Math.round(8*A/p),s.msg_up_stream_info.msg_network_status.uint32_bitrate+=I.uint32_audio_codec_bitrate}var x=S.msg_up_stream_info.msg_video_status;s.msg_up_stream_info.msg_video_status.forEach(function(v){var w=x.find(function(_){return _.uint32_video_stream_type===v.uint32_video_stream_type});if(!w||w.uint32_video_codec_bitrate===0)return v.uint32_video_codec_bitrate=0,v.uint32_video_enc_fps=0,void(v.uint32_video_codec_fps=0);var R=w.uint32_video_codec_bitrate,P=w.uint32_video_enc_fps,y=w.uint32_video_codec_fps,d=c.getDifferenceValue(R,v.uint32_video_codec_bitrate);v.uint32_video_codec_bitrate=Math.round(8*d/p),s.msg_up_stream_info.msg_network_status.uint32_bitrate+=v.uint32_video_codec_bitrate,v.uint32_video_enc_fps=Math.round(c.getDifferenceValue(P,v.uint32_video_enc_fps)/p),v.uint32_video_codec_fps=Math.round(c.getDifferenceValue(y,v.uint32_video_codec_fps)/p)});var D=s.msg_down_stream_info,m=S.msg_down_stream_info;return D.forEach(function(v){var w=m.find(function(E){return E.msg_user_info.uint64_tinyid===v.msg_user_info.uint64_tinyid});if(w){if(v.msg_audio_status&&w.msg_audio_status){var R=v.msg_audio_status,P=w.msg_audio_status;R.uint32_audio_origin_lost=c.getDifferenceValue(P.uint32_audio_origin_lost,R.uint32_audio_origin_lost),R.uint32_audio_receive=c.getDifferenceValue(P.uint32_audio_receive,R.uint32_audio_receive),R.uint32_audio_receive+=R.uint32_audio_origin_lost;var y=c.getDifferenceValue(P.uint32_audio_codec_bitrate,R.uint32_audio_codec_bitrate);R.uint32_audio_codec_bitrate=Math.round(8*y/p),R.uint32_audio_total_bitrate=Math.round(8*y/p)}if(v.msg_video_status&&w.msg_video_status){var d=v.msg_video_status,_=w.msg_video_status;d.forEach(function(E){var C=_.find(function(ne){return ne.uint32_video_stream_type===E.uint32_video_stream_type});if(!C)return E.uint32_video_receive=0,E.uint32_video_origin_lost=0,E.uint32_video_codec_bitrate=0,E.uint32_video_receive_fps=0,void(E.uint32_video_dec_fps=0);var O=C.uint32_video_receive,L=C.uint32_video_origin_lost,N=C.uint32_video_codec_bitrate,W=C.uint32_video_receive_fps,B=C.uint32_video_dec_fps;E.uint32_video_origin_lost=c.getDifferenceValue(L,E.uint32_video_origin_lost),E.uint32_video_receive=c.getDifferenceValue(O,E.uint32_video_receive)+E.uint32_video_origin_lost;var se=c.getDifferenceValue(N,E.uint32_video_codec_bitrate);E.uint32_video_codec_bitrate=Math.round(8*se/p);var ee=c.getDifferenceValue(W,E.uint32_video_receive_fps);E.uint32_video_receive_fps=Math.round(ee/p),E.uint32_video_dec_fps=Math.round(c.getDifferenceValue(B,E.uint32_video_dec_fps)/p)})}}}),s}},{key:"getStatsReport",value:(t=F(M().mark(function o(c){var a,s,l,u,h;return M().wrap(function(g){for(;;)switch(g.prev=g.next){case 0:return a=c.uplinkConnection,s=c.downlinkConnections,l=c.freezeMap,u={msg_up_stream_info:{msg_audio_status:{uint32_audio_format:0,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,audioLevel:0},msg_video_status:[{uint32_video_stream_type:0,uint32_video_codec_fps:0,uint32_video_capture_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_final_lost:0,uint32_video_enc_fps:0}],msg_network_status:{uint32_bitrate:0,uint32_rtt:0,uint32_lost:0}},msg_down_stream_info:[{msg_user_info:{str_identifier:"",uint64_tinyid:""},msg_audio_status:{uint32_audio_format:0,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,audioLevel: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,uint32_jitter:0}}]},g.next=4,this.getStats(a,s);case 4:return h=g.sent,JSON.stringify(this.prevReport_)==="{}"&&(this.prevReport_=JSON.parse(JSON.stringify(u))),this.prepareReport({stats:h,report:u,freezeMap:l,uplinkConnection:a,downlinkConnections:s}),this.prevReportTime_=Date.now(),g.abrupt("return",u);case 9:case"end":return g.stop()}},o,this)})),function(o){return t.apply(this,arguments)})},{key:"reset",value:function(){this.prevReportTime_=0,this.prevReport_={},this.prevEncoderImplementation_="",this.prevQualityLimitationReason_="",this.prevDecoderImplementationMap_=new Map}}]),e}(),XV=function(){function e(i){var r=i.signalChannel,o=i.connections,c=i.client;ce(this,e),this.client_=c,this.signalChannel_=r,this.connections_=o,this.client_=c,this.log_=z.createLogger({id:"q|"+this.client_.getUserId(),userId:this.client_.getUserId(),sdkAppId:this.client_.getSDKAppId()}),this.uplinkConnection_=null,this.uplinkNetworkQuality_=0,this.uplinkRTT_=0,this.uplinkLoss_=0,this.downlinkNetworkQuality_=0,this.downlinkRTT_=0,this.downlinkLoss_=0,this.downlinkPrevStatMap_=new Map,this.downlinkLossAndRTTMap_=new Map,this.interval_=-1,this.emitter_=new Pn,this.initialize()}var t,n;return ue(e,[{key:"uplinkNetworkQuality",get:function(){return this.uplinkNetworkQuality_},set:function(i){i!==this.uplinkNetworkQuality_&&this.log_.info("uplink network quality change ".concat(this.uplinkNetworkQuality," -> ").concat(i,", rtt: ").concat(this.uplinkRTT_,", loss: ").concat(this.uplinkLoss_)),this.uplinkNetworkQuality_=i}},{key:"downlinkNetworkQuality",get:function(){return this.downlinkNetworkQuality_},set:function(i){if(i!==this.downlinkNetworkQuality_){var r=this.getAverageLossAndRTT(Se(this.downlinkLossAndRTTMap_.values())),o=r.rtt,c=r.loss;this.log_.info("downlink network quality change ".concat(this.downlinkNetworkQuality," -> ").concat(i,", rtt: ").concat(o,", loss: ").concat(c))}this.downlinkNetworkQuality_=i}},{key:"initialize",value:function(){var i=this;this.signalChannel_.on(pe.UPLINK_NETWORK_STATS,function(r){i.handleUplinkNetworkQuality(r)}),this.signalChannel_.on(Yd,this.handleSignalConnectionStateChange.bind(this)),this.start()}},{key:"handleUplinkNetworkQuality",value:function(i){if(!this.uplinkConnection_)return this.uplinkNetworkQuality=0,this.uplinkLoss_=0,void(this.uplinkRTT_=0);var r=this.uplinkConnection_.getPeerConnection();if(r&&this.isPeerConnectionDisconnected(r))return this.uplinkNetworkQuality=6,this.uplinkLoss_=0,void(this.uplinkRTT_=0);if(i.data.code===0){var o=i.data.data,c=o.expectAudPkg+o.expectVidPkg,a=o.recvAudPkg+o.recvVidPkg,s=c-a,l=o.delay;if(l&&this.updateDelay(l),c===0&&a===0)return;this.uplinkLoss_=s<=0?0:Math.round(s/c*100),this.uplinkRTT_=o.rtt,this.uplinkNetworkQuality=this.getNetworkQuality(this.uplinkLoss_,this.uplinkRTT_)}}},{key:"handleDownlinkNetworkQuality",value:(n=F(M().mark(function i(){var r,o,c,a,s,l,u,h,g,b,T,k,p,S,f,I=this;return M().wrap(function(A){for(;;)switch(A.prev=A.next){case 0:if(this.connections_&&this.connections_.size!==0){A.next=3;break}return this.downlinkNetworkQuality=0,A.abrupt("return");case 3:if(r=Se(this.connections_.values()),o=r.filter(function(x){return x.getPeerConnection()&&x.getPeerConnection().connectionState===Lg}),r.filter(function(x){return x.getPeerConnection()&&I.isPeerConnectionDisconnected(x.getPeerConnection())}).length!==r.length){A.next=9;break}return this.downlinkNetworkQuality=6,A.abrupt("return");case 9:c=0;case 10:if(!(c<o.length)){A.next=31;break}return a=o[c].getPeerConnection(),A.next=14,this.getStat(a);case 14:if(s=A.sent,l=s.rtt,u=s.totalPacketsLost,h=s.totalPacketsReceived,this.downlinkPrevStatMap_.has(a)){A.next=21;break}return this.downlinkPrevStatMap_.set(a,{totalPacketsLost:u,totalPacketsReceived:h}),A.abrupt("continue",28);case 21:g=0,b=this.downlinkPrevStatMap_.get(a),T=u-b.totalPacketsLost,k=h-b.totalPacketsReceived,g=T<=0||k<0?0:Math.round(T/(T+k)*100),this.downlinkPrevStatMap_.set(a,{totalPacketsLost:u,totalPacketsReceived:h}),this.downlinkLossAndRTTMap_.set(a,{rtt:l,loss:g,userId:o[c].getUserId()});case 28:c++,A.next=10;break;case 31:if(Se(this.downlinkPrevStatMap_.keys()).forEach(function(x){I.isPeerConnectionDisconnected(x)&&(I.downlinkPrevStatMap_.delete(x),I.downlinkLossAndRTTMap_.delete(x))}),this.downlinkLossAndRTTMap_.size!==0){A.next=34;break}return A.abrupt("return");case 34:p=this.getAverageLossAndRTT(Se(this.downlinkLossAndRTTMap_.values())),S=p.rtt,f=p.loss,this.downlinkRTT_=S,this.downlinkLoss_=f,this.downlinkNetworkQuality=this.getNetworkQuality(f,S);case 38:case"end":return A.stop()}},i,this)})),function(){return n.apply(this,arguments)})},{key:"getStat",value:(t=F(M().mark(function i(r){var o,c,a,s;return M().wrap(function(l){for(;;)switch(l.prev=l.next){case 0:if(o={rtt:0,totalPacketsLost:0,totalPacketsReceived:0},r&&eb()){l.next=3;break}return l.abrupt("return",o);case 3:c=r.getReceivers(),l.prev=4,a=0;case 6:if(!(a<c.length)){l.next=15;break}return s=c[a],l.next=10,s.getStats();case 10:l.sent.forEach(function(u){u.type==="candidate-pair"&&Rt(u.currentRoundTripTime)&&(o.rtt=Math.round(1e3*u.currentRoundTripTime)),u.type!=="inbound-rtp"||u.mediaType!==K&&u.mediaType!==q||(o.totalPacketsLost+=u.packetsLost,o.totalPacketsReceived+=u.packetsReceived)});case 12:a++,l.next=6;break;case 15:return l.abrupt("return",o);case 18:return l.prev=18,l.t0=l.catch(4),l.abrupt("return",o);case 21:case"end":return l.stop()}},i,null,[[4,18]])})),function(i){return t.apply(this,arguments)})},{key:"getAverageLossAndRTT",value:function(i){var r={rtt:0,loss:0};return Array.isArray(i)&&i.length>0&&(i.forEach(function(o){r.rtt+=o.rtt,r.loss+=o.loss}),Object.keys(r).forEach(function(o){r[o]=Math.round(r[o]/i.length)})),r}},{key:"getNetworkQuality",value:function(i,r){return i>50||r>500?5:i>30||r>350?4:i>20||r>200?3:i>10||r>100?2:i>=0||r>=0?1:0}},{key:"handleSignalConnectionStateChange",value:function(i){i.state===ps?(this.uplinkRTT_=0,this.uplinkLoss_=0,this.uplinkNetworkQuality=6):i.state===_a&&this.uplinkNetworkQuality===6&&(this.uplinkNetworkQuality=5)}},{key:"handleUplinkConnectionStateChange",value:function(i){var r=i.state;r===Xe?(this.uplinkLoss_=0,this.uplinkRTT_=0,this.uplinkNetworkQuality=6):r===Ye&&this.uplinkNetworkQuality===6&&(this.uplinkNetworkQuality=5)}},{key:"isPeerConnectionDisconnected",value:function(i){return!(!i||i.connectionState!==VM&&i.connectionState!==Ng&&i.connectionState!==Ml)}},{key:"setUplinkConnection",value:function(i){this.uplinkConnection_=i,this.uplinkConnection_?this.uplinkConnection_.on(de.CONNECTION_STATE_CHANGED,this.handleUplinkConnectionStateChange.bind(this)):(this.uplinkNetworkQuality=0,this.uplinkRTT_=0,this.uplinkLoss_=0)}},{key:"start",value:function(){var i=this;this.interval_===-1?(this.log_.info("start network quality calculating"),this.interval_=ye.run(Kr,function(){i.handleDownlinkNetworkQuality(),U.emit(zd,{client:i.client_,uplinkNetworkQuality:i.uplinkNetworkQuality,downlinkNetworkQuality:i.downlinkNetworkQuality,uplinkRTT:i.uplinkRTT_,uplinkLoss:i.uplinkLoss_,downlinkRTT:i.downlinkRTT_,downlinkLoss:i.downlinkLoss_,downlinkLossAndRTTMap:i.downlinkLossAndRTTMap_}),i.emitter_.emit(fe.NETWORK_QUALITY,{uplinkNetworkQuality:i.uplinkNetworkQuality,downlinkNetworkQuality:i.downlinkNetworkQuality,uplinkRTT:i.uplinkRTT_,uplinkLoss:i.uplinkLoss_,downlinkRTT:i.downlinkRTT_,downlinkLoss:i.downlinkLoss_})},{delay:2e3})):this.log_.info("network quality calculating is already started")}},{key:"stop",value:function(){this.log_.info("stop network quality calculating"),this.interval_!==-1&&(ye.clearTask(this.interval_),this.interval_=-1),this.downlinkLossAndRTTMap_.clear(),this.downlinkPrevStatMap_.clear()}},{key:"on",value:function(i,r){this.emitter_.on(i,r)}},{key:"updateDelay",value:function(i){var r=this;i.forEach(function(o){var c=o.srcTinyId,a=o.videoDelay,s=o.audioDelay,l=r.connections_.get(c);l&&l.setDelay({videoDelay:a,audioDelay:s})})}}]),e}(),YV=function(){function e(i){ce(this,e),this.log_=z.createLogger({id:i.client.getUserId(),userId:i.client.getUserId(),sdkAppId:i.client.getSDKAppId()}),this.localStream_=null,this.prevDevices_=[],this.initialize()}var t,n;return ue(e,[{key:"initialize",value:function(){navigator.mediaDevices&&navigator.mediaDevices.addEventListener&&(this.onDeviceChange=this.onDeviceChange.bind(this),navigator.mediaDevices.addEventListener("devicechange",this.onDeviceChange))}},{key:"destroy",value:function(){navigator.mediaDevices&&navigator.mediaDevices.removeEventListener&&navigator.mediaDevices.removeEventListener("devicechange",this.onDeviceChange)}},{key:"onDeviceChange",value:(n=F(M().mark(function i(){var r,o,c,a=this;return M().wrap(function(s){for(;;)switch(s.prev=s.next){case 0:if(this.localStream_&&this.localStream_.getMediaStream()&&!this.localStream_.getScreen()){s.next=2;break}return s.abrupt("return");case 2:return s.next=4,kh();case 4:r=s.sent,o=r.filter(function(l){return a.prevDevices_.findIndex(function(u){var h=u.deviceId;return l.deviceId===h})<0}),c=this.prevDevices_.filter(function(l){return r.findIndex(function(u){var h=u.deviceId;return l.deviceId===h})<0}),o.length>0&&this.handleDeviceAdded(this.prevDevices_,o),c.length>0&&this.handleDeviceRemoved(r,c),this.prevDevices_=r;case 10:case"end":return s.stop()}},i,this)})),function(){return n.apply(this,arguments)})},{key:"setLocalStream",value:(t=F(M().mark(function i(r){return M().wrap(function(o){for(;;)switch(o.prev=o.next){case 0:if(!r){o.next=4;break}return o.next=3,kh();case 3:this.prevDevices_=o.sent;case 4:this.localStream_=r;case 5:case"end":return o.stop()}},i,this)})),function(i){return t.apply(this,arguments)})},{key:"handleDeviceAdded",value:function(i,r){var o,c;if(this.localStream_){this.log_.warn("devicesAdded: ".concat(JSON.stringify(r))),this.localStream_.updateDeviceIdInUse();var a=r.filter(function(b){return b.kind===Ho}),s=r.filter(function(b){return b.kind===ra}),l=i.filter(function(b){return b.kind===Ho}),u=i.filter(function(b){return b.kind===ra}),h=a.length>0&&l.length===0&&((o=this.localStream_.getVideoTrack())===null||o===void 0?void 0:o.readyState)!=="live",g=s.length>0&&u.length===0&&((c=this.localStream_.getAudioTrack())===null||c===void 0?void 0:c.readyState)!=="live";if(g&&h)return this.log_.info("new microphone and camera detected, but there was no device before."),void this.localStream_.recoverCapture({audio:!0,video:!0,cameraId:a[0].deviceId,microphoneId:s[0].deviceId});h&&(this.log_.info("new camera detected, but there was no camera before."),this.localStream_.recoverCapture({audio:!1,video:!0,cameraId:a[0].deviceId})),g&&(this.log_.info("new microphone detected, but there was no microphone before."),this.localStream_.recoverCapture({audio:!0,video:!1,microphoneId:s[0].deviceId}))}}},{key:"handleDeviceRemoved",value:function(i,r){if(this.localStream_){this.log_.warn("devicesRemoved: ".concat(JSON.stringify(r))),this.localStream_.updateDeviceIdInUse();var o=!1,c=!1,a=this.localStream_.getCameraId(),s=this.localStream_.getMicrophoneId();if(s===Ko){var l=this.localStream_.getMicrophoneGroupId(),u=i.filter(function(h){return h.deviceId===Ko&&h.kind===ra})[0];u&&u.groupId!==l&&(c=!0)}if(r.forEach(function(h){var g=h.deviceId;a.length>0&&g===a?o=!0:s.length>0&&g===s&&(c=!0)}),o&&c)return this.log_.warn("current camera and microphone in use is lost, cameraId: ".concat(a,", microphoneId: ").concat(s)),void((this.localStream_.getAudio()||this.localStream_.getVideo())&&this.localStream_.recoverCapture({video:!0,audio:!0}));o&&(this.log_.warn("current camera in use is lost, deviceId: ".concat(a)),this.localStream_.getVideo()&&this.localStream_.recoverCapture({video:!0,audio:!1})),c&&(this.log_.warn("current microphone in use is lost, deviceId: ".concat(s)),this.localStream_.getAudio()&&this.localStream_.recoverCapture({video:!1,audio:!0}))}}}]),e}();function bh(){return bh=F(M().mark(function e(){var t;return M().wrap(function(n){for(;;)switch(n.prev=n.next){case 0:if(!gs()&&!vs()){n.next=2;break}return n.abrupt("return",[]);case 2:return n.next=4,ys();case 4:return t=n.sent,n.abrupt("return",t.filter(function(i){return i.kind===Ho}).map(function(i,r){var o=i.label;i.label||(o="camera_"+r);var c={label:o,deviceId:i.deviceId,kind:i.kind};return i.groupId&&(c.groupId=i.groupId),i.getCapabilities&&(c.getCapabilities=function(){return i.getCapabilities()}),c}));case 6:case"end":return n.stop()}},e)})),bh.apply(this,arguments)}var ob=new Set;function ys(){return sb.apply(this,arguments)}function sb(){return(sb=F(M().mark(function e(){var t;return M().wrap(function(n){for(;;)switch(n.prev=n.next){case 0:if(!gs()&&!vs()){n.next=2;break}return n.abrupt("return",[]);case 2:return n.next=4,navigator.mediaDevices.enumerateDevices();case 4:return(t=n.sent).forEach(function(i){ob.add("".concat(i.deviceId,"_").concat(i.kind))}),n.abrupt("return",t);case 7:case"end":return n.stop()}},e)}))).apply(this,arguments)}function kh(){return Ih.apply(this,arguments)}function Ih(){return Ih=F(M().mark(function e(){var t;return M().wrap(function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,ys();case 2:return t=n.sent,n.abrupt("return",t.filter(function(i){return i.kind!==ra||i.deviceId!=py}).map(function(i,r){var o=i.label;i.label||(o=i.kind+"_"+r);var c={label:o,deviceId:i.deviceId,kind:i.kind};return i.groupId&&(c.groupId=i.groupId),i.getCapabilities&&(c.getCapabilities=function(){return i.getCapabilities()}),c}));case 4:case"end":return n.stop()}},e)})),Ih.apply(this,arguments)}function cb(){return Th.apply(this,arguments)}function Th(){return Th=F(M().mark(function e(){var t;return M().wrap(function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,ys();case 2:return t=n.sent,n.abrupt("return",t.filter(function(i){return i.kind===ra&&i.deviceId!==py}).map(function(i,r){var o=i.label;i.label||(o="microphone_"+r);var c={label:o,deviceId:i.deviceId,kind:i.kind};return i.groupId&&(c.groupId=i.groupId),i.getCapabilities&&(c.getCapabilities=function(){return i.getCapabilities()}),c}));case 4:case"end":return n.stop()}},e)})),Th.apply(this,arguments)}function ub(){return wh.apply(this,arguments)}function wh(){return wh=F(M().mark(function e(){var t;return M().wrap(function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,ys();case 2:return t=n.sent,n.abrupt("return",t.filter(function(i){return i.kind==="audiooutput"}).map(function(i,r){var o=i.label;i.label||(o="speaker_"+r);var c={label:o,deviceId:i.deviceId,kind:i.kind};return i.groupId&&(c.groupId=i.groupId),c}));case 4:case"end":return n.stop()}},e)})),wh.apply(this,arguments)}function $V(e){var t;if(e instanceof CanvasCaptureMediaStreamTrack||!(e instanceof window.MediaStreamTrack))return!1;var n=e.label.toLocaleLowerCase();if(n.includes("camera")||n.includes("webcam"))return!0;var i="".concat((t=e.getSettings())===null||t===void 0?void 0:t.deviceId,"_").concat(Ho);return!!ob.has(i)}function ZV(e,t){return lb.apply(this,arguments)}function lb(){return(lb=F(M().mark(function e(t,n){var i,r;return M().wrap(function(o){for(;;)switch(o.prev=o.next){case 0:return o.next=2,cb();case 2:if(i=o.sent,((r=i.find(function(c){return c.deviceId===Ko}))==null?void 0:r.groupId)!==t||r.label!==n){o.next=6;break}return o.abrupt("return",!0);case 6:return o.abrupt("return",!1);case 7:case"end":return o.stop()}},e)}))).apply(this,arguments)}var _t,db=Pc.exports,e4=Ve,t4=Oe,n4=mm,r4=Zt,i4=we,a4=ze,o4=function(e,t,n,i){try{return i?t(t4(n)[0],n[1]):t(n)}catch(r){n4(e,"throw",r)}},s4=su,c4=yo,u4=qe,hb=Ui,l4=fo,d4=Vi,pb=Array,fb=function(e){var t=a4(e),n=c4(this),i=arguments.length,r=i>1?arguments[1]:void 0,o=r!==void 0;o&&(r=r4(r,i>2?arguments[2]:void 0));var c,a,s,l,u,h,g=d4(t),b=0;if(!g||this===pb&&s4(g))for(c=u4(t),a=n?new this(c):pb(c);c>b;b++)h=o?r(t[b],b):t[b],hb(a,b,h);else for(u=(l=l4(t,g)).next,a=n?new this:[];!(s=i4(u,l)).done;b++)h=o?o4(l,r,[s.value,b],!0):s.value,hb(a,b,h);return a.length=b,a},dr=$,Eh=2147483647,h4=/[^\0-\u007E]/,mb=/[.\u3002\uFF0E\uFF61]/g,_b="Overflow: input needs wider integers to process",vb=RangeError,p4=dr(mb.exec),oi=Math.floor,Rh=String.fromCharCode,gb=dr("".charCodeAt),yb=dr([].join),Mn=dr([].push),f4=dr("".replace),m4=dr("".split),_4=dr("".toLowerCase),Sb=function(e){return e+22+75*(e<26)},v4=function(e,t,n){var i=0;for(e=n?oi(e/700):e>>1,e+=oi(e/t);e>455;)e=oi(e/35),i+=36;return oi(i+36*e/(e+38))},g4=function(e){var t=[];e=function(S){for(var f=[],I=0,A=S.length;I<A;){var x=gb(S,I++);if(x>=55296&&x<=56319&&I<A){var D=gb(S,I++);(64512&D)==56320?Mn(f,((1023&x)<<10)+(1023&D)+65536):(Mn(f,x),I--)}else Mn(f,x)}return f}(e);var n,i,r=e.length,o=128,c=0,a=72;for(n=0;n<e.length;n++)(i=e[n])<128&&Mn(t,Rh(i));var s=t.length,l=s;for(s&&Mn(t,"-");l<r;){var u=Eh;for(n=0;n<e.length;n++)(i=e[n])>=o&&i<u&&(u=i);var h=l+1;if(u-o>oi((Eh-c)/h))throw vb(_b);for(c+=(u-o)*h,o=u,n=0;n<e.length;n++){if((i=e[n])<o&&++c>Eh)throw vb(_b);if(i==o){for(var g=c,b=36;;){var T=b<=a?1:b>=a+26?26:b-a;if(g<T)break;var k=g-T,p=36-T;Mn(t,Rh(Sb(T+k%p))),g=oi(k/p),b+=36}Mn(t,Rh(Sb(g))),a=v4(c,h,l==s),c=0,l++}}c++,o++}return yb(t,"")},y4=Y,Ch=Ae,S4=U_,Ah=oe,bb=Zt,vt=$,Ss=He,gt=function(e,t,n){return n.get&&db(n.get,t,{getter:!0}),n.set&&db(n.set,t,{setter:!0}),e4.f(e,t,n)},b4=vn,xh=Le,Ph=gS,si=fb,xt=ho,k4=pu.codeAt,I4=function(e){var t,n,i=[],r=m4(f4(_4(e),mb,"."),".");for(t=0;t<r.length;t++)n=r[t],Mn(i,p4(h4,n)?"xn--"+g4(n):n);return yb(i,".")},cn=Fe,T4=zn,w4=go,kb=mD,Ib=Me,E4=Ib.set,bs=Ib.getterFor("URL"),R4=kb.URLSearchParams,C4=kb.getState,Sa=Ah.URL,Dh=Ah.TypeError,ks=Ah.parseInt,A4=Math.floor,Tb=Math.pow,yt=vt("".charAt),Pt=vt(/./.exec),ba=vt([].join),x4=vt(1 .toString),P4=vt([].pop),ci=vt([].push),wb=vt("".replace),D4=vt([].shift),O4=vt("".split),ka=vt("".slice),Is=vt("".toLowerCase),M4=vt([].unshift),Oh="Invalid scheme",hr="Invalid host",Eb="Invalid port",Rb=/[a-z]/i,N4=/[\d+-.a-z]/i,Mh=/\d/,L4=/^0x/i,U4=/^[0-7]+$/,V4=/^\d+$/,Cb=/^[\da-f]+$/i,j4=/[\0\t\n\r #%/:<>?@[\\\]^|]/,F4=/[\0\t\n\r #/:<>?@[\\\]^|]/,B4=/^[\u0000-\u0020]+|[\u0000-\u0020]+$/g,H4=/[\t\n\r]/g,Ia=function(e){var t,n,i,r;if(typeof e=="number"){for(t=[],n=0;n<4;n++)M4(t,e%256),e=A4(e/256);return ba(t,".")}if(typeof e=="object"){for(t="",i=function(o){for(var c=null,a=1,s=null,l=0,u=0;u<8;u++)o[u]!==0?(l>a&&(c=s,a=l),s=null,l=0):(s===null&&(s=u),++l);return l>a&&(c=s,a=l),c}(e),n=0;n<8;n++)r&&e[n]===0||(r&&(r=!1),i===n?(t+=n?":":"::",r=!0):(t+=x4(e[n],16),n<7&&(t+=":")));return"["+t+"]"}return e},Ts={},Ab=Ph({},Ts,{" ":1,'"':1,"<":1,">":1,"`":1}),xb=Ph({},Ab,{"#":1,"?":1,"{":1,"}":1}),Nh=Ph({},xb,{"/":1,":":1,";":1,"=":1,"@":1,"[":1,"\\":1,"]":1,"^":1,"|":1}),Nn=function(e,t){var n=k4(e,0);return n>32&&n<127&&!xh(t,e)?e:encodeURIComponent(e)},ws={ftp:21,file:null,http:80,https:443,ws:80,wss:443},Ta=function(e,t){var n;return e.length==2&&Pt(Rb,yt(e,0))&&((n=yt(e,1))==":"||!t&&n=="|")},Pb=function(e){var t;return e.length>1&&Ta(ka(e,0,2))&&(e.length==2||(t=yt(e,2))==="/"||t==="\\"||t==="?"||t==="#")},W4=function(e){return e==="."||Is(e)==="%2e"},Lh={},Db={},Uh={},Ob={},Mb={},Vh={},Nb={},Lb={},Es={},Rs={},jh={},Fh={},Bh={},Hh={},Ub={},Wh={},ui={},zt={},Vb={},pr={},un={},Gh=function(e,t,n){var i,r,o,c=cn(e);if(t){if(r=this.parse(c))throw Dh(r);this.searchParams=null}else{if(n!==void 0&&(i=new Gh(n,!0)),r=this.parse(c,null,i))throw Dh(r);(o=C4(new R4)).bindURL(this),this.searchParams=o}};Gh.prototype={type:"URL",parse:function(e,t,n){var i,r,o,c,a,s=this,l=t||Lh,u=0,h="",g=!1,b=!1,T=!1;for(e=cn(e),t||(s.scheme="",s.username="",s.password="",s.host=null,s.port=null,s.path=[],s.query=null,s.fragment=null,s.cannotBeABaseURL=!1,e=wb(e,B4,"")),e=wb(e,H4,""),i=si(e);u<=i.length;){switch(r=i[u],l){case Lh:if(!r||!Pt(Rb,r)){if(t)return Oh;l=Uh;continue}h+=Is(r),l=Db;break;case Db:if(r&&(Pt(N4,r)||r=="+"||r=="-"||r=="."))h+=Is(r);else{if(r!=":"){if(t)return Oh;h="",l=Uh,u=0;continue}if(t&&(s.isSpecial()!=xh(ws,h)||h=="file"&&(s.includesCredentials()||s.port!==null)||s.scheme=="file"&&!s.host))return;if(s.scheme=h,t)return void(s.isSpecial()&&ws[s.scheme]==s.port&&(s.port=null));h="",s.scheme=="file"?l=Hh:s.isSpecial()&&n&&n.scheme==s.scheme?l=Ob:s.isSpecial()?l=Lb:i[u+1]=="/"?(l=Mb,u++):(s.cannotBeABaseURL=!0,ci(s.path,""),l=Vb)}break;case Uh:if(!n||n.cannotBeABaseURL&&r!="#")return Oh;if(n.cannotBeABaseURL&&r=="#"){s.scheme=n.scheme,s.path=xt(n.path),s.query=n.query,s.fragment="",s.cannotBeABaseURL=!0,l=un;break}l=n.scheme=="file"?Hh:Vh;continue;case Ob:if(r!="/"||i[u+1]!="/"){l=Vh;continue}l=Es,u++;break;case Mb:if(r=="/"){l=Rs;break}l=zt;continue;case Vh:if(s.scheme=n.scheme,r==_t)s.username=n.username,s.password=n.password,s.host=n.host,s.port=n.port,s.path=xt(n.path),s.query=n.query;else if(r=="/"||r=="\\"&&s.isSpecial())l=Nb;else if(r=="?")s.username=n.username,s.password=n.password,s.host=n.host,s.port=n.port,s.path=xt(n.path),s.query="",l=pr;else{if(r!="#"){s.username=n.username,s.password=n.password,s.host=n.host,s.port=n.port,s.path=xt(n.path),s.path.length--,l=zt;continue}s.username=n.username,s.password=n.password,s.host=n.host,s.port=n.port,s.path=xt(n.path),s.query=n.query,s.fragment="",l=un}break;case Nb:if(!s.isSpecial()||r!="/"&&r!="\\"){if(r!="/"){s.username=n.username,s.password=n.password,s.host=n.host,s.port=n.port,l=zt;continue}l=Rs}else l=Es;break;case Lb:if(l=Es,r!="/"||yt(h,u+1)!="/")continue;u++;break;case Es:if(r!="/"&&r!="\\"){l=Rs;continue}break;case Rs:if(r=="@"){g&&(h="%40"+h),g=!0,o=si(h);for(var k=0;k<o.length;k++){var p=o[k];if(p!=":"||T){var S=Nn(p,Nh);T?s.password+=S:s.username+=S}else T=!0}h=""}else if(r==_t||r=="/"||r=="?"||r=="#"||r=="\\"&&s.isSpecial()){if(g&&h=="")return"Invalid authority";u-=si(h).length+1,h="",l=jh}else h+=r;break;case jh:case Fh:if(t&&s.scheme=="file"){l=Wh;continue}if(r!=":"||b){if(r==_t||r=="/"||r=="?"||r=="#"||r=="\\"&&s.isSpecial()){if(s.isSpecial()&&h=="")return hr;if(t&&h==""&&(s.includesCredentials()||s.port!==null))return;if(c=s.parseHost(h))return c;if(h="",l=ui,t)return;continue}r=="["?b=!0:r=="]"&&(b=!1),h+=r}else{if(h=="")return hr;if(c=s.parseHost(h))return c;if(h="",l=Bh,t==Fh)return}break;case Bh:if(!Pt(Mh,r)){if(r==_t||r=="/"||r=="?"||r=="#"||r=="\\"&&s.isSpecial()||t){if(h!=""){var f=ks(h,10);if(f>65535)return Eb;s.port=s.isSpecial()&&f===ws[s.scheme]?null:f,h=""}if(t)return;l=ui;continue}return Eb}h+=r;break;case Hh:if(s.scheme="file",r=="/"||r=="\\")l=Ub;else{if(!n||n.scheme!="file"){l=zt;continue}if(r==_t)s.host=n.host,s.path=xt(n.path),s.query=n.query;else if(r=="?")s.host=n.host,s.path=xt(n.path),s.query="",l=pr;else{if(r!="#"){Pb(ba(xt(i,u),""))||(s.host=n.host,s.path=xt(n.path),s.shortenPath()),l=zt;continue}s.host=n.host,s.path=xt(n.path),s.query=n.query,s.fragment="",l=un}}break;case Ub:if(r=="/"||r=="\\"){l=Wh;break}n&&n.scheme=="file"&&!Pb(ba(xt(i,u),""))&&(Ta(n.path[0],!0)?ci(s.path,n.path[0]):s.host=n.host),l=zt;continue;case Wh:if(r==_t||r=="/"||r=="\\"||r=="?"||r=="#"){if(!t&&Ta(h))l=zt;else if(h==""){if(s.host="",t)return;l=ui}else{if(c=s.parseHost(h))return c;if(s.host=="localhost"&&(s.host=""),t)return;h="",l=ui}continue}h+=r;break;case ui:if(s.isSpecial()){if(l=zt,r!="/"&&r!="\\")continue}else if(t||r!="?")if(t||r!="#"){if(r!=_t&&(l=zt,r!="/"))continue}else s.fragment="",l=un;else s.query="",l=pr;break;case zt:if(r==_t||r=="/"||r=="\\"&&s.isSpecial()||!t&&(r=="?"||r=="#")){if((a=Is(a=h))===".."||a==="%2e."||a===".%2e"||a==="%2e%2e"?(s.shortenPath(),r=="/"||r=="\\"&&s.isSpecial()||ci(s.path,"")):W4(h)?r=="/"||r=="\\"&&s.isSpecial()||ci(s.path,""):(s.scheme=="file"&&!s.path.length&&Ta(h)&&(s.host&&(s.host=""),h=yt(h,0)+":"),ci(s.path,h)),h="",s.scheme=="file"&&(r==_t||r=="?"||r=="#"))for(;s.path.length>1&&s.path[0]==="";)D4(s.path);r=="?"?(s.query="",l=pr):r=="#"&&(s.fragment="",l=un)}else h+=Nn(r,xb);break;case Vb:r=="?"?(s.query="",l=pr):r=="#"?(s.fragment="",l=un):r!=_t&&(s.path[0]+=Nn(r,Ts));break;case pr:t||r!="#"?r!=_t&&(r=="'"&&s.isSpecial()?s.query+="%27":s.query+=r=="#"?"%23":Nn(r,Ts)):(s.fragment="",l=un);break;case un:r!=_t&&(s.fragment+=Nn(r,Ab))}u++}},parseHost:function(e){var t,n,i;if(yt(e,0)=="["){if(yt(e,e.length-1)!="]"||(t=function(r){var o,c,a,s,l,u,h,g=[0,0,0,0,0,0,0,0],b=0,T=null,k=0,p=function(){return yt(r,k)};if(p()==":"){if(yt(r,1)!=":")return;k+=2,T=++b}for(;p();){if(b==8)return;if(p()!=":"){for(o=c=0;c<4&&Pt(Cb,p());)o=16*o+ks(p(),16),k++,c++;if(p()=="."){if(c==0||(k-=c,b>6))return;for(a=0;p();){if(s=null,a>0){if(!(p()=="."&&a<4))return;k++}if(!Pt(Mh,p()))return;for(;Pt(Mh,p());){if(l=ks(p(),10),s===null)s=l;else{if(s==0)return;s=10*s+l}if(s>255)return;k++}g[b]=256*g[b]+s,++a!=2&&a!=4||b++}if(a!=4)return;break}if(p()==":"){if(k++,!p())return}else if(p())return;g[b++]=o}else{if(T!==null)return;k++,T=++b}}if(T!==null)for(u=b-T,b=7;b!=0&&u>0;)h=g[b],g[b--]=g[T+u-1],g[T+--u]=h;else if(b!=8)return;return g}(ka(e,1,-1)),!t))return hr;this.host=t}else if(this.isSpecial()){if(e=I4(e),Pt(j4,e)||(t=function(r){var o,c,a,s,l,u,h,g=O4(r,".");if(g.length&&g[g.length-1]==""&&g.length--,(o=g.length)>4)return r;for(c=[],a=0;a<o;a++){if((s=g[a])=="")return r;if(l=10,s.length>1&&yt(s,0)=="0"&&(l=Pt(L4,s)?16:8,s=ka(s,l==8?1:2)),s==="")u=0;else{if(!Pt(l==10?V4:l==8?U4:Cb,s))return r;u=ks(s,l)}ci(c,u)}for(a=0;a<o;a++)if(u=c[a],a==o-1){if(u>=Tb(256,5-o))return null}else if(u>255)return null;for(h=P4(c),a=0;a<c.length;a++)h+=c[a]*Tb(256,3-a);return h}(e),t===null))return hr;this.host=t}else{if(Pt(F4,e))return hr;for(t="",n=si(e),i=0;i<n.length;i++)t+=Nn(n[i],Ts);this.host=t}},cannotHaveUsernamePasswordPort:function(){return!this.host||this.cannotBeABaseURL||this.scheme=="file"},includesCredentials:function(){return this.username!=""||this.password!=""},isSpecial:function(){return xh(ws,this.scheme)},shortenPath:function(){var e=this.path,t=e.length;!t||this.scheme=="file"&&t==1&&Ta(e[0],!0)||e.length--},serialize:function(){var e=this,t=e.scheme,n=e.username,i=e.password,r=e.host,o=e.port,c=e.path,a=e.query,s=e.fragment,l=t+":";return r!==null?(l+="//",e.includesCredentials()&&(l+=n+(i?":"+i:"")+"@"),l+=Ia(r),o!==null&&(l+=":"+o)):t=="file"&&(l+="//"),l+=e.cannotBeABaseURL?c[0]:c.length?"/"+ba(c,"/"):"",a!==null&&(l+="?"+a),s!==null&&(l+="#"+s),l},setHref:function(e){var t=this.parse(e);if(t)throw Dh(t);this.searchParams.update()},getOrigin:function(){var e=this.scheme,t=this.port;if(e=="blob")try{return new li(e.path[0]).origin}catch{return"null"}return e!="file"&&this.isSpecial()?e+"://"+Ia(this.host)+(t!==null?":"+t:""):"null"},getProtocol:function(){return this.scheme+":"},setProtocol:function(e){this.parse(cn(e)+":",Lh)},getUsername:function(){return this.username},setUsername:function(e){var t=si(cn(e));if(!this.cannotHaveUsernamePasswordPort()){this.username="";for(var n=0;n<t.length;n++)this.username+=Nn(t[n],Nh)}},getPassword:function(){return this.password},setPassword:function(e){var t=si(cn(e));if(!this.cannotHaveUsernamePasswordPort()){this.password="";for(var n=0;n<t.length;n++)this.password+=Nn(t[n],Nh)}},getHost:function(){var e=this.host,t=this.port;return e===null?"":t===null?Ia(e):Ia(e)+":"+t},setHost:function(e){this.cannotBeABaseURL||this.parse(e,jh)},getHostname:function(){var e=this.host;return e===null?"":Ia(e)},setHostname:function(e){this.cannotBeABaseURL||this.parse(e,Fh)},getPort:function(){var e=this.port;return e===null?"":cn(e)},setPort:function(e){this.cannotHaveUsernamePasswordPort()||((e=cn(e))==""?this.port=null:this.parse(e,Bh))},getPathname:function(){var e=this.path;return this.cannotBeABaseURL?e[0]:e.length?"/"+ba(e,"/"):""},setPathname:function(e){this.cannotBeABaseURL||(this.path=[],this.parse(e,ui))},getSearch:function(){var e=this.query;return e?"?"+e:""},setSearch:function(e){(e=cn(e))==""?this.query=null:(yt(e,0)=="?"&&(e=ka(e,1)),this.query="",this.parse(e,pr)),this.searchParams.update()},getSearchParams:function(){return this.searchParams.facade},getHash:function(){var e=this.fragment;return e?"#"+e:""},setHash:function(e){(e=cn(e))!=""?(yt(e,0)=="#"&&(e=ka(e,1)),this.fragment="",this.parse(e,un)):this.fragment=null},update:function(){this.query=this.searchParams.serialize()||null}};var li=function(e){var t=b4(this,tt),n=w4(arguments.length,1)>1?arguments[1]:void 0,i=E4(t,new Gh(e,!1,n));Ch||(t.href=i.serialize(),t.origin=i.getOrigin(),t.protocol=i.getProtocol(),t.username=i.getUsername(),t.password=i.getPassword(),t.host=i.getHost(),t.hostname=i.getHostname(),t.port=i.getPort(),t.pathname=i.getPathname(),t.search=i.getSearch(),t.searchParams=i.getSearchParams(),t.hash=i.getHash())},tt=li.prototype,St=function(e,t){return{get:function(){return bs(this)[e]()},set:t&&function(n){return bs(this)[t](n)},configurable:!0,enumerable:!0}};if(Ch&&(gt(tt,"href",St("serialize","setHref")),gt(tt,"origin",St("getOrigin")),gt(tt,"protocol",St("getProtocol","setProtocol")),gt(tt,"username",St("getUsername","setUsername")),gt(tt,"password",St("getPassword","setPassword")),gt(tt,"host",St("getHost","setHost")),gt(tt,"hostname",St("getHostname","setHostname")),gt(tt,"port",St("getPort","setPort")),gt(tt,"pathname",St("getPathname","setPathname")),gt(tt,"search",St("getSearch","setSearch")),gt(tt,"searchParams",St("getSearchParams")),gt(tt,"hash",St("getHash","setHash"))),Ss(tt,"toJSON",function(){return bs(this).serialize()},{enumerable:!0}),Ss(tt,"toString",function(){return bs(this).serialize()},{enumerable:!0}),Sa){var jb=Sa.createObjectURL,Fb=Sa.revokeObjectURL;jb&&Ss(li,"createObjectURL",bb(jb,Sa)),Fb&&Ss(li,"revokeObjectURL",bb(Fb,Sa))}T4(li,"URL"),y4({global:!0,constructor:!0,forced:!S4,sham:!Ch},{URL:li});var fr,Cs,G4=new Blob(["class VolumeMeter extends AudioWorkletProcessor{constructor(){super();this.volume=0;this.intervalTime=200;this.tick=this.intervalTime;this.isStop=false;this.port.onmessage=event=>{const{data}=event;switch(data.name){case'setIntervalTime':this.intervalTime=data.intervalTime;break;case'stop':this.isStop=true;break}}}process(inputs){const input=inputs[0];if(this.isStop){return false}if(input.length>0){const firstChannel=input[0];let sum=0;let rms;for(let i=0;i<firstChannel.length;++i){sum+=firstChannel[i]*firstChannel[i]}rms=Math.sqrt(sum/firstChannel.length);this.volume=Math.max(rms,this.volume*0.95);this.tick-=firstChannel.length;if(this.tick<0){this.tick+=(this.intervalTime/1000)*sampleRate;this.port.postMessage({volume:this.volume})}}return true}}registerProcessor('volume-meter',VolumeMeter);"],{type:"application/javascript"}),Bb=!1,z4=function(){function e(n){ce(this,e),this.context_=n.context,this.addModuleToContext()}var t;return ue(e,[{key:"addModuleToContext",value:(t=F(M().mark(function n(){return M().wrap(function(i){for(;;)switch(i.prev=i.next){case 0:return i.prev=0,i.next=3,this.context_.audioWorklet.addModule(URL.createObjectURL(G4));case 3:z.info("worklet addModule success"),U.emit(Jd),Bb=!0,i.next=12;break;case 8:i.prev=8,i.t0=i.catch(0),z.info("worklet addModule catch error. ".concat(i.t0.message)),U.emit(qd);case 12:case"end":return i.stop()}},n,this,[[0,8]])})),function(){return t.apply(this,arguments)})},{key:"initWorkletSuccess",get:function(){return Bb}}]),e}(),wa=0,J4=function(){function e(t){ce(this,e);var n=t.track,i=t.log,r=t.stream;this.volume_=0,this.log_=i,this.track_=n,this.stream_=r,wa+=1,fr||(fr=tS()),this.audioCtx_=fr,this.destination_=this.audioCtx_.destination;var o=new MediaStream;o.addTrack(this.track_),this.streamSource_=this.audioCtx_.createMediaStreamSource(o),this.audioWorkletNode_=null,this.scriptProcessorNode_=null,this.interval_=200,U.on(pa,this.resume,this),U.on(xd,this.handleAudioLevelInterval,this),_3?(U.on(Jd,this.initAudioWorklet,this),U.on(qd,this.initScriptProcessor,this),this.preload()):this.initScriptProcessor()}return ue(e,[{key:"preload",value:function(){Cs?Cs.initWorkletSuccess&&this.initAudioWorklet():Cs=new z4({context:fr})}},{key:"initAudioWorklet",value:function(){var t=this;if(!this.audioWorkletNode_)try{this.audioWorkletNode_=new AudioWorkletNode(this.audioCtx_,"volume-meter"),this.audioWorkletNode_.port.onmessage=function(n){t.volume_=n.data.volume||0},this.streamSource_.connect(this.audioWorkletNode_).connect(this.destination_),this.handleAudioLevelInterval({interval:this.interval_})}catch(n){this.log_.warn("load volume meter failed, load again. error: "+n),this.initScriptProcessor()}}},{key:"initScriptProcessor",value:function(){var t=this;if(!this.scriptProcessorNode_)try{this.scriptProcessorNode_=this.audioCtx_.createScriptProcessor(2048,1,1),this.scriptProcessorNode_.onaudioprocess=function(n){for(var i=n.inputBuffer.getChannelData(0),r=0,o=0;o<i.length;++o)r+=i[o]*i[o];t.volume_=Math.sqrt(r/i.length)||0},this.streamSource_.connect(this.scriptProcessorNode_),this.scriptProcessorNode_.connect(this.destination_)}catch(n){this.log_.error("volumeMeter init script processor error: "+n),wa-=1}}},{key:"destroy",value:function(){var t;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,U.off(pa,this.resume,this),U.off(xd,this.handleAudioLevelInterval,this),U.off(Jd,this.initAudioWorklet,this),U.off(qd,this.initScriptProcessor,this),wa>0&&(wa-=1),wa===0&&((t=fr)===null||t===void 0||t.close(),fr=null,Cs=null)}},{key:"resume",value:function(){var t;(t=fr)===null||t===void 0||t.resume()}},{key:"getInternalAudioLevel",value:function(){return this.volume_}},{key:"getCalculatedVolume",value:function(){return this.volume_.toFixed(2)}},{key:"handleAudioLevelInterval",value:function(t){var n,i=t.interval;this.interval_=i,(n=this.audioWorkletNode_)===null||n===void 0||n.port.postMessage({name:"setIntervalTime",intervalTime:i})}}]),e}(),q4=function(){function e(o){ce(this,e),this.stream_=o.stream,this.userId_=o.stream.getUserId(),this.log_=this.stream_.getLogger(),this.track_=o.track,o.gainedTrack&&(this.gainedTrack_=o.gainedTrack),this.div_=o.div,this.muted_=o.muted,this.outputDeviceId_=o.outputDeviceId,this.volume_=o.volume,this.pausedRetryCount_=5,this.emitter_=new Pn,this.initializeElement(),this.state_="NONE",this.volumeMeter_=new J4({stream:this.stream_,track:this.gainedTrack_||this.track_,log:this.log_})}var t,n,i,r;return ue(e,[{key:"isPlaying",get:function(){return this.state_===Gr}},{key:"initializeElement",value:function(){if(this.isAudioElementInit()){var o=new MediaStream;o.addTrack(this.gainedTrack_||this.track_);var c=document.createElement(K);c.srcObject=o,c.muted=this.muted_,c.setAttribute("id","audio_".concat(this.stream_.getId())),c.setAttribute("autoplay","autoplay"),c.setAttribute("playsinline","playsinline"),this.div_.appendChild(c),this.element_=c}this.handleEvents()}},{key:"setMuted",value:function(o){this.element_&&(this.element_.muted=o,this.muted_=o)}},{key:"play",value:(r=F(M().mark(function o(){var c;return M().wrap(function(a){for(;;)switch(a.prev=a.next){case 0:if(!this.outputDeviceId_||!this.element_){a.next=3;break}return a.next=3,this.element_.setSinkId(this.outputDeviceId_);case 3:if(this.setVolume(this.volume_),a.prev=4,!this.element_){a.next=8;break}return a.next=8,this.element_.play();case 8:a.next=16;break;case 10:if(a.prev=10,a.t0=a.catch(4),c=H({key:Xl,data:{media:"Audio",error:a.t0}}),this.log_.warn(c),!c.includes("NotAllowedError")){a.next=16;break}throw new j({code:V.PLAY_NOT_ALLOWED,message:c});case 16:case"end":return a.stop()}},o,this,[[4,10]])})),function(){return r.apply(this,arguments)})},{key:"handleEvents",value:function(){this.handleElementEvent=this.handleElementEvent.bind(this),this.handleTrackEvent=this.handleTrackEvent.bind(this),this.element_&&(this.element_.addEventListener(bn,this.handleElementEvent),this.element_.addEventListener(Ue,this.handleElementEvent),this.element_.addEventListener(kn,this.handleElementEvent),this.element_.addEventListener(Wr,this.handleElementEvent)),this.track_.addEventListener(Ue,this.handleTrackEvent),this.track_.addEventListener(Je,this.handleTrackEvent),this.track_.addEventListener(Bt,this.handleTrackEvent),this.track_.readyState===Ue&&this.handleTrackEvent({type:Ue}),this.track_.muted&&this.handleTrackEvent({type:Je})}},{key:"handleElementEvent",value:(i=F(M().mark(function o(c){var a,s,l,u,h,g,b,T=this;return M().wrap(function(k){for(;;)switch(k.prev=k.next){case 0:a=c.type,k.t0=a,k.next=k.t0===bn?4:k.t0===Ue?9:k.t0===kn?12:k.t0===Wr?21:33;break;case 4:return this.log_.info("audio player is playing"),this.state_=Gr,U.emit(Dd,{stream:this.stream_}),this.emitter_.emit(it,{state:this.state_,reason:bn}),k.abrupt("break",33);case 9:return this.log_.info("audio player is ended"),this.state_!==In&&(this.state_=In,this.emitter_.emit(it,{state:this.state_,reason:Ue})),k.abrupt("break",33);case 12:return this.log_.info("audio player is paused"),this.state_=Ht,this.emitter_.emit(it,{state:this.state_,reason:kn}),(s=this.div_&&document.getElementById(this.div_.id))||this.log_.warn("audio player has been remove, element ID: ".concat(this.div_.id)),l=Xr(),this.pausedRetryCount_>0&&(Rt(l)&&l<=70||!s)&&(this.resume(),this.pausedRetryCount_--),Rn&&(this.interval_=ye.run(function(){T.element_&&T.state_===Ht&&T.resume()},{delay:3e3})),k.abrupt("break",33);case 21:if(!this.element_||!this.element_.error){k.next=32;break}return u="".concat(yh(),"/").concat(ar().name,"/").concat(ar().version),k.next=25,Ce.getSpeakers();case 25:h=k.sent,g=h[0].label,(b=h.find(function(p){return p.deviceId===T.outputDeviceId_}))&&(g=b.label),this.log_.error("audio player error observed. code: ".concat(this.element_.error.code," message: ").concat(this.element_.error.message," deviceInfo: ").concat(u," speaker: ").concat(g)),J.uploadEvent({log:"stat-".concat(this.stream_.getType(),"-audio-").concat(ey,"-").concat(this.element_.error.code,"-").concat(u,"-").concat(g),userId:this.userId_,error:this.element_.error}),this.emitter_.emit(ab,this.element_.error);case 32:return k.abrupt("break",33);case 33:case"end":return k.stop()}},o,this)})),function(o){return i.apply(this,arguments)})},{key:"handleTrackEvent",value:function(o){var c=o.type;switch(c){case Ue:this.log_.info("audio track is ended"),this.state_!==In&&(this.state_=In,this.emitter_.emit(it,{state:this.state_,reason:Ue})),U.emit(Wd,{stream:this.stream_,type:c});break;case Je:this.log_.info("audio track is unable to provide media output"),this.stream_.isRemote()||eS(),this.state_!==Ht&&(this.state_=Ht,this.emitter_.emit(it,{state:this.state_,reason:Je})),U.emit(Hd,{stream:this.stream_,type:c});break;case Bt:this.log_.info("audio track is able to provide media output"),this.state_===Ht&&(this.state_=Gr,this.emitter_.emit(it,{state:this.state_,reason:Bt}))}}},{key:"unbindEvents",value:function(){this.element_&&(this.element_.removeEventListener(bn,this.handleElementEvent),this.element_.removeEventListener(Ue,this.handleElementEvent),this.element_.removeEventListener(kn,this.handleElementEvent),this.element_.removeEventListener(Wr,this.handleElementEvent)),this.track_&&(this.track_.removeEventListener(Ue,this.handleTrackEvent),this.track_.removeEventListener(Je,this.handleTrackEvent),this.track_.removeEventListener(Bt,this.handleTrackEvent))}},{key:"setSinkId",value:(n=F(M().mark(function o(c){return M().wrap(function(a){for(;;)switch(a.prev=a.next){case 0:if(this.outputDeviceId_===c){a.next=5;break}if(!this.element_){a.next=4;break}return a.next=4,this.element_.setSinkId(c);case 4:this.outputDeviceId_=c;case 5:case"end":return a.stop()}},o,this)})),function(o){return n.apply(this,arguments)})},{key:"setVolume",value:function(o){this.element_&&(this.log_.info("audioElement setVolume to : ".concat(o)),this.element_.volume=o)}},{key:"getAudioLevel",value:function(){return this.volumeMeter_.getCalculatedVolume()}},{key:"getInternalAudioLevel",value:function(){return this.volumeMeter_.getInternalAudioLevel()}},{key:"stop",value:function(){this.unbindEvents(),this.element_&&(this.div_.removeChild(this.element_),this.element_.srcObject=null,this.element_=null),this.volumeMeter_&&(this.volumeMeter_.destroy(),this.volumeMeter_=null),this.interval_>0&&ye.clearTask(this.interval_)}},{key:"resume",value:(t=F(M().mark(function o(){var c;return M().wrap(function(a){for(;;)switch(a.prev=a.next){case 0:if(a.prev=0,this.volumeMeter_&&this.volumeMeter_.resume(),!this.element_){a.next=5;break}return a.next=5,this.element_.play();case 5:a.next=13;break;case 7:if(a.prev=7,a.t0=a.catch(0),c=H({key:Xl,data:{media:"Audio",error:a.t0}}),this.log_.warn(c),!c.includes("NotAllowedError")){a.next=13;break}throw new j({code:V.PLAY_NOT_ALLOWED,message:c});case 13:case"end":return a.stop()}},o,this,[[0,7]])})),function(){return t.apply(this,arguments)})},{key:"on",value:function(o,c){this.emitter_.on(o,c)}},{key:"isAudioElementInit",value:function(){return!(Cn==="15.2"||Cn==="15.3"||Cn==="15.4")||this.stream_.getType()!=="local"||!this.muted_||(this.log_.info("audioElement is muted."),!1)}},{key:"getTrack",value:function(){return this.track_}}]),e}(),K4=Hn.PROPER,Q4=Z,Hb=Sv,X4=xo.trim;Y({target:"String",proto:!0,forced:function(e){return Q4(function(){return!!Hb[e]()||"​…᠎"[e]()!=="​…᠎"||K4&&Hb[e].name!==e})}("trim")},{trim:function(){return X4(this)}});var ln="trtc_autoplay",zh="".concat(ln,"_mask"),di="".concat(ln,"_wrapper"),Wb="".concat(ln,"_header"),Jh="".concat(ln,"_content"),As="".concat(ln,"_action_wrapper"),qh="".concat(ln,"_question"),Kh="".concat(ln,"_collapse"),xs="".concat(ln,"_action_confirm"),Gb="".concat(ln,"_detail"),zb="#2473E8",Qh="dialog",Y4="".concat(Qh,"-show"),$4="".concat(Qh,"-1"),Z4="".concat(Qh,"-2"),Jb=!1,qb=function(){return!!document.querySelector(".".concat(di))},Kb="".concat(qr,"/").concat(or()?"zh-cn":"en","/tutorial-21-advanced-auto-play-policy.html"),Qb="<br><a href='".concat(Kb,"' target='_blank'>").concat(or()?"其他方案?":"Any other solution?","</a>"),ej="".concat(or()?"浏览器自动播放策略:在用户与页面产生交互(点击、触摸)之前,浏览器禁止播放有声媒体。该弹窗用于帮助用户恢复音视频播放。".concat(Qb):"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(Qb)),Xb=function(){function e(){if(ce(this,e),this.dialogNode_=null,this.bodyPosition_="",this.content="音视频播放被浏览器拦截,请点击“恢复播放”。",or()||(this.content='Media playback failed. Click the "Resume" to resume playback.'),!Jb){var t=document.createElement("style");t.innerHTML=".".concat(zh,"{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(zh," div:not(.").concat(As,"){display:block !important;}.").concat(di,"{padding:14px;background:#fff;border-radius:3px;box-shadow:0px 3px 15px #434343;border:1px solid #d1cfcf;max-width:500px;}.").concat(di," a{color:").concat(zb,";}.").concat(Wb,"{overflow:hidden;text-overflow:ellipsis;font-size:16px;font-weight:600;}.").concat(Jh,"{margin:8px 0;}.").concat(As,"{width:100%;display:flex !important;align-items:center;justify-content:right;float:right;}.").concat(Kh,"{margin-right:auto;cursor:pointer}.").concat(qh,"{height:100%;line-height:16px;cursor:pointer;}.").concat(xs,"{margin-left:8px;color:#fff;background:").concat(zb,";padding:4px 12px;outline:none;border:1px solid;border-radius:3px;font-weight:bold;}.").concat(xs,":hover{opacity:0.9;}.").concat(Kh,",.").concat(xs,",.").concat(Jh,",.").concat(qh,"{font-size:14px;}@media screen and (max-width:750px){.").concat(di,"{width:80vw;}}"),document.head.appendChild(t),Jb=!0}this.showDetail_=!1,this.isCollapseClicked_=!1,this.isQuestionClicked_=!1,this.addDiaLog()}return ue(e,[{key:"createDiaLog",value:function(){var t=document.createElement("template");t.innerHTML='<div class="'.concat(zh,`"><div class='`).concat(di,"'><div class='").concat(Wb,"'>").concat(location.host,"</div><div class='").concat(Jh,"'>").concat(this.content,"</div><div class='").concat(Gb,`' style="visibility:hidden;width:100%;height:0;font-size:12px;color:gray;">`).concat(ej,"</div><div class='").concat(As,"'></div></div></div>").trim();var n=document.createElement("button");n.className=xs,n.innerText=or()?"恢复播放":"Resume",n.onclick=this.onConfirm.bind(this);var i=document.createElement("div");i.className=qh,i.innerHTML=`<?xml version="1.0" encoding="UTF-8"?>
<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">
<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"/>
<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"/>
<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"/>
</svg>
`,i.onclick=this.onQuestionClick.bind(this);var r=document.createElement("div");r.className=Kh,r.innerText="".concat(or()?"详情 >":"Detail >"),r.onclick=this.onCollapseClick.bind(this);var o=t.content.firstChild,c=o.querySelector(".".concat(As));return c.appendChild(r),c.appendChild(i),c.appendChild(n),o}},{key:"addDiaLog",value:function(){qb()||(this.dialogNode_=this.createDiaLog(),document.body.appendChild(this.dialogNode_),this.dialogNode_.onclick=this.onConfirm.bind(this),this.dialogNode_.querySelector(".".concat(di)).onclick=function(t){return t.stopPropagation()},this.bodyPosition_=document.body.style.position,document.body.style.position="fixed",z.info("show autoplay dialog"),J.uploadEvent({log:Y4}))}},{key:"deleteDiaLog",value:function(){this.dialogNode_&&(document.body.removeChild(this.dialogNode_),document.body.style.position=this.bodyPosition_,this.dialogNode_=null)}},{key:"onConfirm",value:function(){z.warn("confirm clicked, try resume stream"),U.emit(pa),this.deleteDiaLog()}},{key:"onCollapseClick",value:function(){var t=this.dialogNode_.querySelector(".".concat(Gb));t.style.visibility="".concat(this.showDetail_?"hidden":"visible"),t.style.height="".concat(this.showDetail_?0:"fit-content"),this.showDetail_=!this.showDetail_,this.isCollapseClicked_||J.uploadEvent({log:$4}),this.isCollapseClicked_=!0}},{key:"onQuestionClick",value:function(){window.open(Kb,"_blank"),this.isQuestionClicked_||J.uploadEvent({log:Z4}),this.isQuestionClicked_=!0}}]),e}(),Yb=function(){function e(n){ce(this,e),this.stream_=n.stream,this.userId_=n.stream.getUserId(),this.log_=this.stream_.getLogger(),this.track_=n.track,this.div_=n.div,this.muted_=n.muted,this.objectFit_=n.objectFit,this.mirror_=n.mirror,this.emitter_=new Pn,this.initializeElement(),this.state_="NONE",this.pausedRetryCount_=5}var t;return ue(e,[{key:"isPlaying",get:function(){return this.state_===Gr}},{key:"initializeElement",value:function(){var n=new MediaStream;n.addTrack(this.track_);var i=document.createElement(q);i.srcObject=n,i.muted=!0;var r="width: 100%; height: 100%; object-fit: ".concat(this.objectFit_,";");this.mirror_&&(r+="transform: scaleX(-1);"),i.setAttribute("id","video_".concat(this.stream_.getId())),i.setAttribute("style",r),i.setAttribute("autoplay","autoplay"),i.setAttribute("playsinline","playsinline"),this.element_=i,qy===17&&this.initCanvasElement(r),this.div_&&this.div_.appendChild(this.canvas_||i),this.handleEvents()}},{key:"initCanvasElement",value:function(n){var i=this;if(this.track_&&!this.stream_.isRemote()){var r=document.createElement("canvas"),o=function(){var a,s=(a=i.track_)===null||a===void 0?void 0:a.getSettings();s&&s.width&&s.height&&(r.width=s.width,r.height=s.height)};o(),r.setAttribute("style",n);var c=r.getContext("2d");this.canvasTimerId_=ye.run("raf",function(){i.element_&&c&&(o(),c.drawImage(i.element_,0,0,r.width,r.height))},{backgroundTask:!1}),this.log_.warn("use canvas for playback"),this.canvas_=r}}},{key:"setRect",value:function(n){var i=n.width,r=n.height;this.element_&&(this.element_.style.width=i+"px",this.element_.style.height=r+"px")}},{key:"setMirror",value:function(n){this.element_&&(this.element_.style.transform=n?"scaleX(-1)":"",this.mirror_=n)}},{key:"setObjectFit",value:function(n){this.element_&&(this.element_.style.objectFit="".concat(n),this.objectFit_=n)}},{key:"play",value:(t=F(M().mark(function n(){var i;return M().wrap(function(r){for(;;)switch(r.prev=r.next){case 0:return r.prev=0,r.next=3,this.element_.play();case 3:r.next=11;break;case 5:if(r.prev=5,r.t0=r.catch(0),i=H({key:Xl,data:{media:"Video",error:r.t0}}),this.log_.warn(i),!i.includes("NotAllowedError")){r.next=11;break}throw new j({code:V.PLAY_NOT_ALLOWED,message:i});case 11:case"end":return r.stop()}},n,this,[[0,5]])})),function(){return t.apply(this,arguments)})},{key:"handleEvents",value:function(){this.handleElementEvent=this.handleElementEvent.bind(this),this.handleTrackEvent=this.handleTrackEvent.bind(this),this.element_.addEventListener(bn,this.handleElementEvent),this.element_.addEventListener(Ue,this.handleElementEvent),this.element_.addEventListener(kn,this.handleElementEvent),this.element_.addEventListener(Wr,this.handleElementEvent),this.element_.addEventListener(Cl,this.handleElementEvent),this.track_.addEventListener(Ue,this.handleTrackEvent),this.track_.addEventListener(Je,this.handleTrackEvent),this.track_.addEventListener(Bt,this.handleTrackEvent),this.track_.readyState===Ue&&this.handleTrackEvent({type:Ue}),this.track_.muted&&this.handleTrackEvent({type:Je})}},{key:"handleElementEvent",value:function(n){var i=this;switch(n.type){case bn:this.log_.info("video player is playing"),this.state_=Gr,U.emit(da,{stream:this.stream_}),this.emitter_.emit(it,{state:this.state_,reason:bn}),this.interval_&&(ye.clearTask(this.interval_),this.interval_=null);break;case Ue:this.log_.info("video player is ended"),this.state_!==In&&(this.state_=In,this.emitter_.emit(it,{state:this.state_,reason:Ue}));break;case kn:this.log_.info("video player is paused"),this.div_&&!document.getElementById(this.div_.id)&&this.log_.warn("video player has been remove, element ID: ".concat(this.div_.id)),this.state_=Ht,this.emitter_.emit(it,{state:this.state_,reason:kn}),this.pausedRetryCount_>0&&!qb()&&(this.log_.info("video player auto resume when video paused"),this.resume(),this.pausedRetryCount_--),Rn&&(this.interval_=ye.run(function(){i.element_&&i.state_===Ht&&i.resume()},{delay:3e3}));break;case Wr:if(this.element_&&this.element_.error){var r="".concat(yh(),"/").concat(ar().name,"/").concat(ar().version);this.log_.error("video player error observed. code: ".concat(this.element_.error.code," message: ").concat(this.element_.error.message," deviceInfo: ").concat(r)),J.uploadEvent({log:"stat-".concat(this.stream_.getType(),"-video-").concat(ey,"-").concat(this.element_.error.code,"-").concat(r),userId:this.userId_,error:this.element_.error})}break;case Cl:U.emit(jd,{stream:this.stream_})}}},{key:"handleTrackEvent",value:function(n){var i=n.type;switch(i){case Ue:this.log_.info("video track is ended"),U.emit(Bd,{stream:this.stream_,type:i}),this.state_!==In&&(this.state_=In,this.emitter_.emit(it,{state:this.state_,reason:Ue}));break;case Je:this.log_.info("video track is unable to provide media output"),this.stream_.isRemote()||eS(),U.emit(ha,{stream:this.stream_,type:i}),this.state_!==Ht&&(this.state_=Ht,this.emitter_.emit(it,{state:this.state_,reason:Je}));break;case Bt:this.log_.info("video track is able to provide media output"),U.emit(Ud,{stream:this.stream_}),this.state_===Ht&&(this.state_=Gr,this.emitter_.emit(it,{state:this.state_,reason:Bt}))}}},{key:"unbindEvents",value:function(){this.element_&&(this.element_.removeEventListener(bn,this.handleElementEvent),this.element_.removeEventListener(Ue,this.handleElementEvent),this.element_.removeEventListener(kn,this.handleElementEvent),this.element_.removeEventListener(Wr,this.handleElementEvent),this.element_.removeEventListener(Cl,this.handleElementEvent)),this.track_&&(this.track_.removeEventListener(Ue,this.handleTrackEvent),this.track_.removeEventListener(Je,this.handleTrackEvent),this.track_.removeEventListener(Bt,this.handleTrackEvent))}},{key:"stop",value:function(){this.unbindEvents(),this.element_&&(this.element_.remove(),this.element_.srcObject=null,this.element_=null),this.interval_&&ye.clearTask(this.interval_),this.canvasTimerId_&&ye.clearTask(this.canvasTimerId_),this.canvas_&&(this.canvas_.remove(),this.canvas_=null)}},{key:"resume",value:function(){return this.play()}},{key:"getVideoFrame",value:function(){var n=document.createElement("canvas");return n.width=this.element_.videoWidth,n.height=this.element_.videoHeight,n.getContext("2d").drawImage(this.element_,0,0),n.toDataURL("image/png")}},{key:"on",value:function(n,i){this.emitter_.on(n,i)}},{key:"getElement",value:function(){return this.element_?this.element_:null}},{key:"getTrack",value:function(){return this.track_}}]),e}(),Xh=typeof ArrayBuffer<"u"&&typeof DataView<"u",tj=Tt,nj=jt,rj=RangeError,$b=function(e){if(e===void 0)return 0;var t=tj(e),n=nj(t);if(t!==n)throw rj("Wrong length or index");return n},ij=Array,aj=Math.abs,dn=Math.pow,oj=Math.floor,sj=Math.log,cj=Math.LN2,uj={pack:function(e,t,n){var i,r,o,c=ij(n),a=8*n-t-1,s=(1<<a)-1,l=s>>1,u=t===23?dn(2,-24)-dn(2,-77):0,h=e<0||e===0&&1/e<0?1:0,g=0;for((e=aj(e))!=e||e===1/0?(r=e!=e?1:0,i=s):(i=oj(sj(e)/cj),e*(o=dn(2,-i))<1&&(i--,o*=2),(e+=i+l>=1?u/o:u*dn(2,1-l))*o>=2&&(i++,o/=2),i+l>=s?(r=0,i=s):i+l>=1?(r=(e*o-1)*dn(2,t),i+=l):(r=e*dn(2,l-1)*dn(2,t),i=0));t>=8;)c[g++]=255&r,r/=256,t-=8;for(i=i<<t|r,a+=t;a>0;)c[g++]=255&i,i/=256,a-=8;return c[--g]|=128*h,c},unpack:function(e,t){var n,i=e.length,r=8*i-t-1,o=(1<<r)-1,c=o>>1,a=r-7,s=i-1,l=e[s--],u=127&l;for(l>>=7;a>0;)u=256*u+e[s--],a-=8;for(n=u&(1<<-a)-1,u>>=-a,a+=t;a>0;)n=256*n+e[s--],a-=8;if(u===0)u=1-c;else{if(u===o)return n?NaN:l?-1/0:1/0;n+=dn(2,t),u-=c}return(l?-1:1)*n*dn(2,u-t)}},lj=ze,Zb=_n,dj=qe,ek=function(e){for(var t=lj(this),n=dj(t),i=arguments.length,r=Zb(i>1?arguments[1]:void 0,n),o=i>2?arguments[2]:void 0,c=o===void 0?n:Zb(o,n);c>r;)t[r++]=e;return t},Ps=oe,Yh=$,$h=Ae,hj=Xh,tk=Hn,nk=Ut,rk=Fi,Zh=Z,Ds=vn,pj=Tt,fj=jt,Os=$b,ik=uj,mj=Oi,ak=Er,_j=mn.f,vj=Ve.f,gj=ek,yj=ho,ok=zn,Sj=tk.PROPER,sk=tk.CONFIGURABLE,hi=Me.get,ck=Me.set,ep="ArrayBuffer",bj="DataView",uk="Wrong index",bt=Ps.ArrayBuffer,Dt=bt,pi=Dt&&Dt.prototype,Jt=Ps.DataView,mr=Jt&&Jt.prototype,lk=Object.prototype,kj=Ps.Array,Ms=Ps.RangeError,Ij=Yh(gj),Tj=Yh([].reverse),dk=ik.pack,hk=ik.unpack,pk=function(e){return[255&e]},fk=function(e){return[255&e,e>>8&255]},mk=function(e){return[255&e,e>>8&255,e>>16&255,e>>24&255]},_k=function(e){return e[3]<<24|e[2]<<16|e[1]<<8|e[0]},wj=function(e){return dk(e,23,4)},Ej=function(e){return dk(e,52,8)},Ns=function(e,t){vj(e.prototype,t,{get:function(){return hi(this)[t]}})},Ln=function(e,t,n,i){var r=Os(n),o=hi(e);if(r+t>o.byteLength)throw Ms(uk);var c=hi(o.buffer).bytes,a=r+o.byteOffset,s=yj(c,a,a+t);return i?s:Tj(s)},Un=function(e,t,n,i,r,o){var c=Os(n),a=hi(e);if(c+t>a.byteLength)throw Ms(uk);for(var s=hi(a.buffer).bytes,l=c+a.byteOffset,u=i(+r),h=0;h<t;h++)s[l+h]=u[o?h:t-h-1]};if(hj){var vk=Sj&&bt.name!==ep;if(Zh(function(){bt(1)})&&Zh(function(){new bt(-1)})&&!Zh(function(){return new bt,new bt(1.5),new bt(NaN),bt.length!=1||vk&&!sk}))vk&&sk&&nk(bt,"name",ep);else{(Dt=function(e){return Ds(this,pi),new bt(Os(e))}).prototype=pi;for(var tp,gk=_j(bt),yk=0;gk.length>yk;)(tp=gk[yk++])in Dt||nk(Dt,tp,bt[tp]);pi.constructor=Dt}ak&&mj(mr)!==lk&&ak(mr,lk);var Ls=new Jt(new Dt(2)),Sk=Yh(mr.setInt8);Ls.setInt8(0,2147483648),Ls.setInt8(1,2147483649),!Ls.getInt8(0)&&Ls.getInt8(1)||rk(mr,{setInt8:function(e,t){Sk(this,e,t<<24>>24)},setUint8:function(e,t){Sk(this,e,t<<24>>24)}},{unsafe:!0})}else pi=(Dt=function(e){Ds(this,pi);var t=Os(e);ck(this,{bytes:Ij(kj(t),0),byteLength:t}),$h||(this.byteLength=t)}).prototype,Jt=function(e,t,n){Ds(this,mr),Ds(e,pi);var i=hi(e).byteLength,r=pj(t);if(r<0||r>i)throw Ms("Wrong offset");if(r+(n=n===void 0?i-r:fj(n))>i)throw Ms("Wrong length");ck(this,{buffer:e,byteLength:n,byteOffset:r}),$h||(this.buffer=e,this.byteLength=n,this.byteOffset=r)},mr=Jt.prototype,$h&&(Ns(Dt,"byteLength"),Ns(Jt,"buffer"),Ns(Jt,"byteLength"),Ns(Jt,"byteOffset")),rk(mr,{getInt8:function(e){return Ln(this,1,e)[0]<<24>>24},getUint8:function(e){return Ln(this,1,e)[0]},getInt16:function(e){var t=Ln(this,2,e,arguments.length>1?arguments[1]:void 0);return(t[1]<<8|t[0])<<16>>16},getUint16:function(e){var t=Ln(this,2,e,arguments.length>1?arguments[1]:void 0);return t[1]<<8|t[0]},getInt32:function(e){return _k(Ln(this,4,e,arguments.length>1?arguments[1]:void 0))},getUint32:function(e){return _k(Ln(this,4,e,arguments.length>1?arguments[1]:void 0))>>>0},getFloat32:function(e){return hk(Ln(this,4,e,arguments.length>1?arguments[1]:void 0),23)},getFloat64:function(e){return hk(Ln(this,8,e,arguments.length>1?arguments[1]:void 0),52)},setInt8:function(e,t){Un(this,1,e,pk,t)},setUint8:function(e,t){Un(this,1,e,pk,t)},setInt16:function(e,t){Un(this,2,e,fk,t,arguments.length>2?arguments[2]:void 0)},setUint16:function(e,t){Un(this,2,e,fk,t,arguments.length>2?arguments[2]:void 0)},setInt32:function(e,t){Un(this,4,e,mk,t,arguments.length>2?arguments[2]:void 0)},setUint32:function(e,t){Un(this,4,e,mk,t,arguments.length>2?arguments[2]:void 0)},setFloat32:function(e,t){Un(this,4,e,wj,t,arguments.length>2?arguments[2]:void 0)},setFloat64:function(e,t){Un(this,8,e,Ej,t,arguments.length>2?arguments[2]:void 0)}});ok(Dt,ep),ok(Jt,bj);var Ea={ArrayBuffer:Dt,DataView:Jt},Rj=Y,np=$,Cj=Z,bk=Oe,kk=_n,Aj=jt,xj=Oo,rp=Ea.ArrayBuffer,ip=Ea.DataView,Ik=ip.prototype,Tk=np(rp.prototype.slice),Pj=np(Ik.getUint8),Dj=np(Ik.setUint8);Rj({target:"ArrayBuffer",proto:!0,unsafe:!0,forced:Cj(function(){return!new rp(2).slice(1,void 0).byteLength})},{slice:function(e,t){if(Tk&&t===void 0)return Tk(bk(this),e);for(var n=bk(this).byteLength,i=kk(e,n),r=kk(t===void 0?n:t,n),o=new(xj(this,rp))(Aj(r-i)),c=new ip(this),a=new ip(o),s=0;i<r;)Dj(a,s++,Pj(c,i++));return o}}),Y({global:!0,constructor:!0,forced:!Xh},{DataView:Ea.DataView});var Oj=Y,Mj=Cr,Nj=$([].reverse),wk=[1,2];Oj({target:"Array",proto:!0,forced:String(wk)===String(wk.reverse())},{reverse:function(){return Mj(this)&&(this.length=this.length),Nj(this)}});var Lj=It,Uj=ze,Vj=Ei,jj=qe,Fj=TypeError,Ek=function(e){return function(t,n,i,r){Lj(n);var o=Uj(t),c=Vj(o),a=jj(o),s=e?a-1:0,l=e?-1:1;if(i<2)for(;;){if(s in c){r=c[s],s+=l;break}if(s+=l,e?s<0:a<=s)throw Fj("Reduce of empty array with no initial value")}for(;e?s>=0:a>s;s+=l)s in c&&(r=n(r,c[s],s,o));return r}},ap={left:Ek(!1),right:Ek(!0)},Bj=ap.left,Rk=br,Hj=Yi;Y({target:"Array",proto:!0,forced:!Ji("reduce")||!Hj&&Rk>79&&Rk<83},{reduce:function(e){var t=arguments.length;return Bj(this,e,t,t>1?arguments[1]:void 0)}});var Wj=Bi,Gj="ArrayBuffer",Ck=Ea.ArrayBuffer;Y({global:!0,constructor:!0,forced:oe.ArrayBuffer!==Ck},{ArrayBuffer:Ck}),Wj(Gj);var zj=Y,Ak=Cr,Jj=yo,qj=xe,xk=_n,Kj=qe,Qj=kt,Xj=Ui,Yj=be,$j=Rr,Zj=zi("slice"),e6=Yj("species"),op=Array,t6=Math.max;zj({target:"Array",proto:!0,forced:!Zj},{slice:function(e,t){var n,i,r,o=Qj(this),c=Kj(o),a=xk(e,c),s=xk(t===void 0?c:t,c);if(Ak(o)&&(n=o.constructor,(Jj(n)&&(n===op||Ak(n.prototype))||qj(n)&&(n=n[e6])===null)&&(n=void 0),n===op||n===void 0))return $j(o,a,s);for(i=new(n===void 0?op:n)(t6(s-a,0)),r=0;a<s;a++,r++)a in o&&Xj(i,r,o[a]);return i.length=r,i}});var Pk=oe,n6=Z,r6=$,i6=Fe,a6=xo.trim,Dk=Sv,Ra=Pk.parseInt,Ok=Pk.Symbol,Mk=Ok&&Ok.iterator,Nk=/^[+-]?0x/i,o6=r6(Nk.exec),Lk=Ra(Dk+"08")!==8||Ra(Dk+"0x16")!==22||Mk&&!n6(function(){Ra(Object(Mk))})?function(e,t){var n=a6(i6(e));return Ra(n,t>>>0||(o6(Nk,n)?16:10))}:Ra;Y({global:!0,forced:parseInt!=Lk},{parseInt:Lk});var at,fi,Us,sp={exports:{}},s6=Xh,Uk=Ae,ut=oe,Vk=ge,cp=xe,Ca=Le,jk=Yt,c6=kr,u6=Ut,l6=He,d6=Ve.f,h6=fn,Vs=Oi,Aa=Er,p6=be,f6=Qa,Fk=Me.enforce,m6=Me.get,js=ut.Int8Array,up=js&&js.prototype,Bk=ut.Uint8ClampedArray,Hk=Bk&&Bk.prototype,_r=js&&Vs(js),Ot=up&&Vs(up),_6=Object.prototype,lp=ut.TypeError,Wk=p6("toStringTag"),dp=f6("TYPED_ARRAY_TAG"),v6="TypedArrayConstructor",Vn=s6&&!!Aa&&jk(ut.opera)!=="Opera",Gk=!1,mi={Int8Array:1,Uint8Array:1,Uint8ClampedArray:1,Int16Array:2,Uint16Array:2,Int32Array:4,Uint32Array:4,Float32Array:4,Float64Array:8},zk={BigInt64Array:8,BigUint64Array:8},Jk=function(e){var t=Vs(e);if(cp(t)){var n=m6(t);return n&&Ca(n,v6)?n.TypedArrayConstructor:Jk(t)}},qk=function(e){if(!cp(e))return!1;var t=jk(e);return Ca(mi,t)||Ca(zk,t)};for(at in mi)(Us=(fi=ut[at])&&fi.prototype)?Fk(Us).TypedArrayConstructor=fi:Vn=!1;for(at in zk)(Us=(fi=ut[at])&&fi.prototype)&&(Fk(Us).TypedArrayConstructor=fi);if((!Vn||!Vk(_r)||_r===Function.prototype)&&(_r=function(){throw lp("Incorrect invocation")},Vn))for(at in mi)ut[at]&&Aa(ut[at],_r);if((!Vn||!Ot||Ot===_6)&&(Ot=_r.prototype,Vn))for(at in mi)ut[at]&&Aa(ut[at].prototype,Ot);if(Vn&&Vs(Hk)!==Ot&&Aa(Hk,Ot),Uk&&!Ca(Ot,Wk))for(at in Gk=!0,d6(Ot,Wk,{get:function(){return cp(this)?this[dp]:void 0}}),mi)ut[at]&&u6(ut[at],dp,at);var re={NATIVE_ARRAY_BUFFER_VIEWS:Vn,TYPED_ARRAY_TAG:Gk&&dp,aTypedArray:function(e){if(qk(e))return e;throw lp("Target is not a typed array")},aTypedArrayConstructor:function(e){if(Vk(e)&&(!Aa||h6(_r,e)))return e;throw lp(c6(e)+" is not a typed array constructor")},exportTypedArrayMethod:function(e,t,n,i){if(Uk){if(n)for(var r in mi){var o=ut[r];if(o&&Ca(o.prototype,e))try{delete o.prototype[e]}catch{try{o.prototype[e]=t}catch{}}}Ot[e]&&!n||l6(Ot,e,n?t:Vn&&up[e]||t,i)}},getTypedArrayConstructor:Jk,isTypedArray:qk,TypedArray:_r,TypedArrayPrototype:Ot},Kk=oe,hp=Z,g6=_o,y6=re.NATIVE_ARRAY_BUFFER_VIEWS,S6=Kk.ArrayBuffer,vr=Kk.Int8Array,b6=!y6||!hp(function(){vr(1)})||!hp(function(){new vr(-1)})||!g6(function(e){new vr,new vr(null),new vr(1.5),new vr(e)},!0)||hp(function(){return new vr(new S6(2),1,void 0).length!==1}),k6=Tt,I6=RangeError,T6=function(e){var t=k6(e);if(t<0)throw I6("The argument can't be less than 0");return t},w6=RangeError,Qk=function(e,t){var n=T6(e);if(n%t)throw w6("Wrong offset");return n},E6=Yt,R6=$("".slice),C6=Xa,A6=TypeError,Xk=function(e){var t=C6(e,"number");if(typeof t=="number")throw A6("Can't convert number to bigint");return BigInt(t)},x6=Zt,P6=we,D6=Uv,O6=ze,M6=qe,N6=fo,L6=Vi,U6=su,V6=function(e){return R6(E6(e),0,3)==="Big"},j6=re.aTypedArrayConstructor,F6=Xk,Yk=Y,$k=oe,Zk=we,B6=Ae,H6=b6,_i=re,e0=Ea,t0=vn,W6=Sr,xa=Ut,G6=dS,z6=jt,n0=$b,pp=Qk,r0=Ya,Pa=Le,J6=Yt,fp=xe,q6=qa,K6=wr,Q6=fn,Fs=Er,X6=mn.f,i0=function(e){var t,n,i,r,o,c,a,s,l=D6(this),u=O6(e),h=arguments.length,g=h>1?arguments[1]:void 0,b=g!==void 0,T=L6(u);if(T&&!U6(T))for(s=(a=N6(u,T)).next,u=[];!(c=P6(s,a)).done;)u.push(c.value);for(b&&h>2&&(g=x6(g,arguments[2])),n=M6(u),i=new(j6(l))(n),r=V6(i),t=0;n>t;t++)o=b?g(u[t],t):u[t],i[t]=r?F6(o):+o;return i},Y6=Ke.forEach,$6=Bi,a0=Ve,o0=hn,Z6=vo,mp=Me.get,eF=Me.set,tF=Me.enforce,_p=a0.f,nF=o0.f,rF=Math.round,vp=$k.RangeError,s0=e0.ArrayBuffer,iF=s0.prototype,aF=e0.DataView,Bs=_i.NATIVE_ARRAY_BUFFER_VIEWS,c0=_i.TYPED_ARRAY_TAG,u0=_i.TypedArray,Da=_i.TypedArrayPrototype,oF=_i.aTypedArrayConstructor,gp=_i.isTypedArray,Hs="BYTES_PER_ELEMENT",yp="Wrong length",l0=function(e,t){oF(e);for(var n=0,i=t.length,r=new e(i);i>n;)r[n]=t[n++];return r},Ws=function(e,t){_p(e,t,{get:function(){return mp(this)[t]}})},d0=function(e){var t;return Q6(iF,e)||(t=J6(e))=="ArrayBuffer"||t=="SharedArrayBuffer"},h0=function(e,t){return gp(e)&&!q6(t)&&t in e&&G6(+t)&&t>=0},p0=function(e,t){return t=r0(t),h0(e,t)?W6(2,e[t]):nF(e,t)},f0=function(e,t,n){return t=r0(t),!(h0(e,t)&&fp(n)&&Pa(n,"value"))||Pa(n,"get")||Pa(n,"set")||n.configurable||Pa(n,"writable")&&!n.writable||Pa(n,"enumerable")&&!n.enumerable?_p(e,t,n):(e[t]=n.value,e)};B6?(Bs||(o0.f=p0,a0.f=f0,Ws(Da,"buffer"),Ws(Da,"byteOffset"),Ws(Da,"byteLength"),Ws(Da,"length")),Yk({target:"Object",stat:!0,forced:!Bs},{getOwnPropertyDescriptor:p0,defineProperty:f0}),sp.exports=function(e,t,n){var i=e.match(/\d+$/)[0]/8,r=e+(n?"Clamped":"")+"Array",o="get"+e,c="set"+e,a=$k[r],s=a,l=s&&s.prototype,u={},h=function(b,T){_p(b,T,{get:function(){return function(k,p){var S=mp(k);return S.view[o](p*i+S.byteOffset,!0)}(this,T)},set:function(k){return function(p,S,f){var I=mp(p);n&&(f=(f=rF(f))<0?0:f>255?255:255&f),I.view[c](S*i+I.byteOffset,f,!0)}(this,T,k)},enumerable:!0})};Bs?H6&&(s=t(function(b,T,k,p){return t0(b,l),Z6(fp(T)?d0(T)?p!==void 0?new a(T,pp(k,i),p):k!==void 0?new a(T,pp(k,i)):new a(T):gp(T)?l0(s,T):Zk(i0,s,T):new a(n0(T)),b,s)}),Fs&&Fs(s,u0),Y6(X6(a),function(b){b in s||xa(s,b,a[b])}),s.prototype=l):(s=t(function(b,T,k,p){t0(b,l);var S,f,I,A=0,x=0;if(fp(T)){if(!d0(T))return gp(T)?l0(s,T):Zk(i0,s,T);S=T,x=pp(k,i);var D=T.byteLength;if(p===void 0){if(D%i||(f=D-x)<0)throw vp(yp)}else if((f=z6(p)*i)+x>D)throw vp(yp);I=f/i}else I=n0(T),S=new s0(f=I*i);for(eF(b,{buffer:S,byteOffset:x,byteLength:f,length:I,view:new aF(S)});A<I;)h(b,A++)}),Fs&&Fs(s,u0),l=s.prototype=K6(Da)),l.constructor!==s&&xa(l,"constructor",s),tF(l).TypedArrayConstructor=s,c0&&xa(l,c0,r);var g=s!=a;u[r]=s,Yk({global:!0,constructor:!0,forced:g,sham:!Bs},u),Hs in s||xa(s,Hs,i),Hs in l||xa(l,Hs,i),$6(r)}):sp.exports=function(){},(0,sp.exports)("Uint8",function(e){return function(t,n,i){return e(this,t,n,i)}});var sF=ze,Sp=_n,cF=qe,uF=a_,lF=Math.min,dF=[].copyWithin||function(e,t){var n=sF(this),i=cF(n),r=Sp(e,i),o=Sp(t,i),c=arguments.length>2?arguments[2]:void 0,a=lF((c===void 0?i:Sp(c,i))-o,i-r),s=1;for(o<r&&r<o+a&&(s=-1,o+=a-1,r+=a-1);a-- >0;)o in n?n[r]=n[o]:uF(n,r),r+=s,o+=s;return n},m0=re,hF=$(dF),pF=m0.aTypedArray;(0,m0.exportTypedArrayMethod)("copyWithin",function(e,t){return hF(pF(this),e,t,arguments.length>2?arguments[2]:void 0)});var fF=Ke.every,mF=re.aTypedArray;(0,re.exportTypedArrayMethod)("every",function(e){return fF(mF(this),e,arguments.length>1?arguments[1]:void 0)});var _F=ek,vF=Xk,gF=Yt,yF=we,SF=Z,bF=re.aTypedArray,kF=re.exportTypedArrayMethod,IF=$("".slice);kF("fill",function(e){var t=arguments.length;bF(this);var n=IF(gF(this),0,3)==="Big"?vF(e):+e;return yF(_F,this,n,t>1?arguments[1]:void 0,t>2?arguments[2]:void 0)},SF(function(){var e=0;return new Int8Array(2).fill({valueOf:function(){return e++}}),e!==1}));var TF=qe,wF=Oo,EF=re.aTypedArrayConstructor,RF=re.getTypedArrayConstructor,Gs=function(e){return EF(wF(e,RF(e)))},CF=function(e,t){for(var n=0,i=TF(t),r=new e(i);i>n;)r[n]=t[n++];return r},AF=Gs,xF=Ke.filter,PF=function(e,t){return CF(AF(e),t)},DF=re.aTypedArray;(0,re.exportTypedArrayMethod)("filter",function(e){var t=xF(DF(this),e,arguments.length>1?arguments[1]:void 0);return PF(this,t)});var OF=Ke.find,MF=re.aTypedArray;(0,re.exportTypedArrayMethod)("find",function(e){return OF(MF(this),e,arguments.length>1?arguments[1]:void 0)});var NF=Ke.findIndex,LF=re.aTypedArray;(0,re.exportTypedArrayMethod)("findIndex",function(e){return NF(LF(this),e,arguments.length>1?arguments[1]:void 0)});var UF=Ke.forEach,VF=re.aTypedArray;(0,re.exportTypedArrayMethod)("forEach",function(e){UF(VF(this),e,arguments.length>1?arguments[1]:void 0)});var jF=Ai.includes,FF=re.aTypedArray;(0,re.exportTypedArrayMethod)("includes",function(e){return jF(FF(this),e,arguments.length>1?arguments[1]:void 0)});var BF=Ai.indexOf,HF=re.aTypedArray;(0,re.exportTypedArrayMethod)("indexOf",function(e){return BF(HF(this),e,arguments.length>1?arguments[1]:void 0)});var WF=oe,GF=Z,bp=$,_0=re,kp=rm,Ip=be("iterator"),v0=WF.Uint8Array,zF=bp(kp.values),JF=bp(kp.keys),qF=bp(kp.entries),Tp=_0.aTypedArray,zs=_0.exportTypedArrayMethod,vi=v0&&v0.prototype,Js=!GF(function(){vi[Ip].call([1])}),g0=!!vi&&vi.values&&vi[Ip]===vi.values&&vi.values.name==="values",y0=function(){return zF(Tp(this))};zs("entries",function(){return qF(Tp(this))},Js),zs("keys",function(){return JF(Tp(this))},Js),zs("values",y0,Js||!g0,{name:"values"}),zs(Ip,y0,Js||!g0,{name:"values"});var KF=re.aTypedArray,QF=re.exportTypedArrayMethod,XF=$([].join);QF("join",function(e){return XF(KF(this),e)});var YF=Jn,$F=kt,ZF=Tt,e5=qe,t5=Ji,n5=Math.min,wp=[].lastIndexOf,S0=!!wp&&1/[1].lastIndexOf(1,-0)<0,r5=t5("lastIndexOf"),i5=S0||!r5?function(e){if(S0)return YF(wp,this,arguments)||0;var t=$F(this),n=e5(t),i=n-1;for(arguments.length>1&&(i=n5(i,ZF(arguments[1]))),i<0&&(i=n+i);i>=0;i--)if(i in t&&t[i]===e)return i||0;return-1}:wp,a5=Jn,o5=i5,s5=re.aTypedArray;(0,re.exportTypedArrayMethod)("lastIndexOf",function(e){var t=arguments.length;return a5(o5,s5(this),t>1?[e,arguments[1]]:[e])});var c5=Ke.map,u5=Gs,l5=re.aTypedArray;(0,re.exportTypedArrayMethod)("map",function(e){return c5(l5(this),e,arguments.length>1?arguments[1]:void 0,function(t,n){return new(u5(t))(n)})});var d5=ap.left,h5=re.aTypedArray;(0,re.exportTypedArrayMethod)("reduce",function(e){var t=arguments.length;return d5(h5(this),e,t,t>1?arguments[1]:void 0)});var p5=ap.right,f5=re.aTypedArray;(0,re.exportTypedArrayMethod)("reduceRight",function(e){var t=arguments.length;return p5(f5(this),e,t,t>1?arguments[1]:void 0)});var m5=re.aTypedArray,_5=re.exportTypedArrayMethod,v5=Math.floor;_5("reverse",function(){for(var e,t=this,n=m5(t).length,i=v5(n/2),r=0;r<i;)e=t[r],t[r++]=t[--n],t[n]=e;return t});var b0=oe,k0=we,Ep=re,g5=qe,y5=Qk,S5=ze,I0=Z,b5=b0.RangeError,Rp=b0.Int8Array,T0=Rp&&Rp.prototype,w0=T0&&T0.set,k5=Ep.aTypedArray,I5=Ep.exportTypedArrayMethod,Cp=!I0(function(){var e=new Uint8ClampedArray(2);return k0(w0,e,{length:1,0:3},1),e[1]!==3}),T5=Cp&&Ep.NATIVE_ARRAY_BUFFER_VIEWS&&I0(function(){var e=new Rp(2);return e.set(1),e.set("2",1),e[0]!==0||e[1]!==2});I5("set",function(e){k5(this);var t=y5(arguments.length>1?arguments[1]:void 0,1),n=S5(e);if(Cp)return k0(w0,this,n,t);var i=this.length,r=g5(n),o=0;if(r+t>i)throw b5("Wrong length");for(;o<r;)this[t+o]=n[o++]},!Cp||T5);var w5=Gs,E5=Rr,R5=re.aTypedArray;(0,re.exportTypedArrayMethod)("slice",function(e,t){for(var n=E5(R5(this),e,t),i=w5(this),r=0,o=n.length,c=new i(o);o>r;)c[r]=n[r++];return c},Z(function(){new Int8Array(1).slice()}));var C5=Ke.some,A5=re.aTypedArray;(0,re.exportTypedArrayMethod)("some",function(e){return C5(A5(this),e,arguments.length>1?arguments[1]:void 0)});var E0=Xt.match(/firefox\/(\d+)/i),x5=!!E0&&+E0[1],P5=/MSIE|Trident/.test(Xt),R0=Xt.match(/AppleWebKit\/(\d+)\./),D5=!!R0&&+R0[1],O5=$,Ap=Z,M5=It,N5=j_,C0=x5,L5=P5,A0=br,x0=D5,U5=re.aTypedArray,V5=re.exportTypedArrayMethod,Oa=oe.Uint16Array,gi=Oa&&O5(Oa.prototype.sort),j5=!(!gi||Ap(function(){gi(new Oa(2),null)})&&Ap(function(){gi(new Oa(2),{})})),P0=!!gi&&!Ap(function(){if(A0)return A0<74;if(C0)return C0<67;if(L5)return!0;if(x0)return x0<602;var e,t,n=new Oa(516),i=Array(516);for(e=0;e<516;e++)t=e%4,n[e]=515-e,i[e]=e-2*t+3;for(gi(n,function(r,o){return(r/4|0)-(o/4|0)}),e=0;e<516;e++)if(n[e]!==i[e])return!0});V5("sort",function(e){return e!==void 0&&M5(e),P0?gi(this,e):N5(U5(this),function(t){return function(n,i){return t!==void 0?+t(n,i)||0:i!=i?-1:n!=n?1:n===0&&i===0?1/n>0&&1/i<0?1:-1:n>i}}(e))},!P0||j5);var F5=jt,D0=_n,B5=Gs,H5=re.aTypedArray;(0,re.exportTypedArrayMethod)("subarray",function(e,t){var n=H5(this),i=n.length,r=D0(e,i);return new(B5(n))(n.buffer,n.byteOffset+r*n.BYTES_PER_ELEMENT,F5((t===void 0?i:D0(t,i))-r))});var W5=Jn,O0=re,xp=Z,M0=Rr,qs=oe.Int8Array,N0=O0.aTypedArray,G5=O0.exportTypedArrayMethod,L0=[].toLocaleString,z5=!!qs&&xp(function(){L0.call(new qs(1))});G5("toLocaleString",function(){return W5(L0,z5?M0(N0(this)):N0(this),M0(arguments))},xp(function(){return[1,2].toLocaleString()!=new qs([1,2]).toLocaleString()})||!xp(function(){qs.prototype.toLocaleString.call([1,2])}));var J5=re.exportTypedArrayMethod,q5=Z,K5=$,U0=oe.Uint8Array,Q5=U0&&U0.prototype||{},Ks=[].toString,X5=K5([].join);q5(function(){Ks.call({})})&&(Ks=function(){return X5(this)});var Y5=Q5.toString!=Ks;J5("toString",Ks,Y5);var $5=function(){function e(t,n,i){ce(this,e),this.isUplink_=i,this.connection_=t,this.log_=n,this.seiMessageList_=[],this.smallVideoSeiMessageList_=[],this.seiPayloadType_=243,this.runningAbortMap_=new Map,this.abortMap_=new Map,this.onSEIMessage=null}return ue(e,[{key:"isRunning",get:function(){return!!this.runningAbortMap_.size>0}},{key:"start",value:function(t){var n=this,i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:this.seiMessageList_,r=t.createEncodedStreams(),o=r.readable,c=r.writable,a=new TransformStream({transform:this.isUplink_?function(l,u){return n.encodeVideoFrame(l,u,i)}:function(l,u){var h,g;return n.decodeVideoFrame(l,u,t===((h=n.connection_)===null||h===void 0||(g=h.getPeerConnection())===null||g===void 0?void 0:g.getReceivers()[my]))}}),s=new AbortController;o.pipeThrough(a).pipeTo(c,{signal:s.signal}).catch(function(){}),this.runningAbortMap_.set(t,s)}},{key:"restart",value:function(t,n){this.stop(),this.start(t,n)}},{key:"stop",value:function(t){var n;(n=this.runningAbortMap_.get(t))===null||n===void 0||n.abort(),this.runningAbortMap_.delete(t)}},{key:"destroy",value:function(){this.stop(),this.runningAbortMap_.forEach(function(t){return t.abort()}),this.runningAbortMap_.clear(),this.abortMap_.forEach(function(t){return t.abort()}),this.abortMap_.clear(),this.log_=null,this.onSEIMessage=null,this.connection_=null}},{key:"handleEncodedStreams",value:function(){var t=this;try{var n=this.connection_.getPeerConnection();this.clearUnusedSenderOrReceiver(n),this.isUplink_?n.getSenders().forEach(function(i,r){if(!t.runningAbortMap_.has(i)&&!t.abortMap_.has(i))if(r===XM||r===fy){var o=r===fy?t.smallVideoSeiMessageList_:t.seiMessageList_;t.isRunning?t.restart(i,o):t.start(i,o)}else t.pipeSenderOrReceiver(i)}):n.getReceivers().forEach(function(i,r){var o;t.runningAbortMap_.has(i)||t.abortMap_.has(i)||(r!==YM&&r!==my||((o=i.track)===null||o===void 0?void 0:o.kind)!==q?t.pipeSenderOrReceiver(i):t.isRunning?t.restart(i):t.start(i))})}catch(i){this.log_.warn(i)}}},{key:"pipeSenderOrReceiver",value:function(t){var n=t.createEncodedStreams(),i=n.readable,r=n.writable,o=new AbortController;this.abortMap_.set(t,o),i.pipeTo(r,{signal:o.signal}).catch(function(){})}},{key:"clearUnusedSenderOrReceiver",value:function(t){var n=this;this.abortMap_.forEach(function(i,r){(n.isUplink_?t.getSenders():t.getReceivers()).find(function(o){return o===r})||(i.abort(),n.abortMap_.delete(r))})}},{key:"push",value:function(t,n){n&&n.seiPayloadType&&(this.seiPayloadType_=n.seiPayloadType),this.seiMessageList_.push(t),this.smallVideoSeiMessageList_.push(t)}},{key:"hasSEI",value:function(t){var n=new DataView(t);return n.getInt32(0)===1&&n.getInt8(4)===6}},{key:"isEmptyFrame",value:function(t){return t.type==="empty"||t.data.byteLength===0}},{key:"getNaluCount",value:function(t){for(var n=0,i=0,r=new DataView(t),o=0;o<t.byteLength;o++)switch(r.getUint8(o)){case 0:n++;break;case 1:n!==2&&n!==3||i++,n=0;break;default:n=0}return i}},{key:"encodeVideoFrame",value:function(t,n,i){try{if(this.connection_.isH264&&i.length>0&&!this.isEmptyFrame(t)){var r=9-this.getNaluCount(t.data);if(r<=0)return;for(var o=i.splice(0,r).reverse().map(this.encodeSEINalu.bind(this)),c=o.reduce(function(T,k){return T+k.dataView.byteLength},0),a=new ArrayBuffer(c+t.data.byteLength),s=new DataView(a),l=new DataView(t.data),u=0,h=0;h<o.length;h++)for(var g=0;g<o[h].dataView.byteLength;g++)s.setInt8(u++,o[h].dataView.getInt8(g));for(var b=0;b<t.data.byteLength;b++)s.setInt8(u++,l.getInt8(b));t.data=a,this.log_.debug("".concat(o.length," sei sent"))}}catch(T){this.log_.warn(T)}n.enqueue(t)}},{key:"decodeVideoFrame",value:function(t,n){var i=this,r=arguments.length>2&&arguments[2]!==void 0&&arguments[2];try{if(this.connection_.isH264&&!this.isEmptyFrame(t)&&this.hasSEI(t.data)){for(var o=[],c=new DataView(t.data),a=0,s=-1,l=-1,u=0;u<t.data.byteLength;u++){var h=c.getUint8(u);if(h===0)a++;else if(h===1){if(a===2||a===3){var g=u-a;s===-1?s=g:l===-1&&(l=g,o.push(new V0(new DataView(c.buffer.slice(s,l)))),s=g,l=-1);var b=c.getUint8(u+1)===6;if(!b){t.data=new DataView(c.buffer.slice(g)).buffer;break}}a=0}else a=0}this.log_.debug("".concat(o.length," sei received")),et(this.onSEIMessage)&&o.reverse().forEach(function(T){i.onSEIMessage({seiPayloadType:T.seiPayloadType,data:T.seiPayload.buffer,isFromAuxiliary:r})})}}catch(T){this.log_.warn(T)}n.enqueue(t)}},{key:"encodeSEINalu",value:function(t){var n=t.byteLength,i=parseInt(n/255),r=n%255,o=[];o.push(0,0,0,1,6,this.seiPayloadType_);for(var c=0;c<i;c++)o.push(255);o.push(r);var a=new DataView(t);return o.push.apply(o,Se(new Uint8Array(a.buffer))),o.push(128),new V0(new DataView(new Uint8Array(o).buffer),!0)}}]),e}(),V0=function(){function e(t){var n=arguments.length>1&&arguments[1]!==void 0&&arguments[1];ce(this,e),this.dataView=t,this.isSEI&&(n?this.addPreventionByte():this.removePreventionByte())}return ue(e,[{key:"addPreventionByte",value:function(){for(var t=this.seiPayloadStartIndex,n=this.dataView.byteLength-2,i=[],r=0,o=t;o<=n;o++){var c=this.dataView.getInt8(o);switch(c){case 0:case 1:case 2:case 3:r===2&&(i.push(3),r=0),c==0?r++:r=0,i.push(c);break;default:r=0,i.push(c)}}i.push(this.dataView.getInt8(this.dataView.byteLength-1));var a=new DataView(new Uint8Array([].concat(Se(new Uint8Array(this.dataView.buffer).slice(0,t)),i)).buffer);this.dataView=a}},{key:"removePreventionByte",value:function(){for(var t=this.seiPayloadStartIndex,n=this.dataView.byteLength-1,i=[],r=0,o=t;o<=n;o++)switch(this.dataView.getInt8(o)){case 0:r++,i.push(this.dataView.getInt8(o));break;case 3:r!==2&&i.push(this.dataView.getInt8(o)),r=0;break;default:i.push(this.dataView.getInt8(o)),r=0}var c=new DataView(new Uint8Array([].concat(Se(new Uint8Array(this.dataView.buffer).slice(0,t)),i)).buffer);this.dataView=c}},{key:"isSEI",get:function(){return this.dataView.getUint8(4)===6}},{key:"seiPayloadStartIndex",get:function(){for(var t=6,n=6;n<this.dataView.buffer.byteLength&&(t++,this.dataView.getUint8(n)===255);n++);return t}},{key:"seiPayloadType",get:function(){return this.isSEI?this.dataView.getUint8(5):null}},{key:"seiPayload",get:function(){if(!this.isSEI)return null;for(var t=0,n=6,i=6;i<this.dataView.buffer.byteLength;i++){var r=this.dataView.getUint8(i);if(n++,r!==255){t+=r;break}t+=255}for(var o=new ArrayBuffer(t),c=new DataView(o),a=0;a<o.byteLength;a++,n++)c.setInt8(a,this.dataView.getInt8(n));return c}}]),e}(),Pp=function(){function e(n){ce(this,e),this.userId_=n.userId,this.tinyId_=n.tinyId,this.client_=n.client,this.sdpSemantics_=n.client.getSdpSemantics(),this.isUplink_=n.isUplink,this.log_=z.createLogger({id:"n|"+this.userId_,userId:this.client_.getUserId(),sdkAppId:this.client_.getSDKAppId(),isLocal:this.isUplink_}),this.signalChannel_=n.signalChannel,this.peerConnection_=null,this.isErrorObserved_=!1,this.emitter_=new Pn,this.currentState_=Xe,this.waitForPeerConnectionConnectedPromise_=null,this.isReconnecting_=!1,this.reconnectionCount_=0,this.reconnectionTimer_=-1,this.isFirstConnection_=!0,this.delay_={audioDelay:0,videoDelay:0},this.enableSEI_=n.enableSEI,this.enableSEI_&&vh&&(this.sei_=new $5(this,this.log_,this.isUplink_))}var t;return ue(e,[{key:"initialize",value:function(){var n={encodedInsertableStreams:this.enableSEI_&&vh,iceServers:this.client_.getIceServers(),iceTransportPolicy:this.client_.getIceTransportPolicy(),sdpSemantics:this.sdpSemantics_,bundlePolicy:"max-bundle",rtcpMuxPolicy:"require",tcpCandidatePolicy:"disable",IceTransportsType:"nohost"};this.peerConnection_=new RTCPeerConnection(n),this.peerConnection_.onconnectionstatechange=this.onConnectionStateChange.bind(this)}},{key:"close",value:function(){this.log_.info("closing connection"),this.closePeerConnection(),this.sei_&&(this.sei_.destroy(),this.sei_=null)}},{key:"closePeerConnection",value:function(){var n=arguments.length>0&&arguments[0]!==void 0&&arguments[0];this.peerConnection_&&(this.peerConnection_.onconnectionstatechange=function(){},this.peerConnection_.close(),this.peerConnection_=null,n&&this.emitConnectionStateChangedEvent(Xe))}},{key:"getDTLSTransportState",value:function(){if(!this.peerConnection_)return zo;var n=null;if(this.isUplink_){if(!ms()||this.peerConnection_.getSenders().length===0)return zo;n=this.peerConnection_.getSenders()[0].transport}else{if(!eb()||this.peerConnection_.getReceivers().length===0)return zo;n=this.peerConnection_.getReceivers()[0].transport}return n?n.state:zo}},{key:"onConnectionStateChange",value:function(n){var i=this.peerConnection_.iceConnectionState,r=this.getDTLSTransportState();if(this.log_.info("onConnectionStateChange() connectionState: "+n.target.connectionState),this.log_.info("ICE Transport state: ".concat(i,", DTLS Transport state: ").concat(r)),n.target.connectionState===Jo&&this.emitConnectionStateChangedEvent(Mg),n.target.connectionState===Ng||n.target.connectionState===Ml){var o="".concat(this.isUplink_?"uplink":"downlink"," ICE/DTLS Transport connection ").concat(n.target.connectionState,". ICE Transport state: ").concat(i,", DTLS Transport state: ").concat(r),c=new j({message:o,code:V.ICE_TRANSPORT_ERROR});J.logFailedEvent({userId:this.client_.getUserId(),eventType:Kg,error:c}),this.emitConnectionStateChangedEvent(Xe),this.isErrorObserved_||this.emitter_.emit(de.ERROR,c)}n.target.connectionState!==Lg&&n.target.connectionState!==jM||(this.logSelectedCandidate(),J.logSuccessEvent({userId:this.client_.getUserId(),eventType:Kg}),this.emitConnectionStateChangedEvent(Ye))}},{key:"emitConnectionStateChangedEvent",value:function(n){n!==this.currentState_&&(this.currentState_===Ol&&n===Mg||(U.emit(hs,{client:this.client_,connection:this,prevState:this.currentState_,state:n}),this.emitter_.emit(de.CONNECTION_STATE_CHANGED,{prevState:this.currentState_,state:n}),this.currentState_=n))}},{key:"hitTest",value:function(n){return(n===0||n==="0")&&this.isUplink_||n===this.tinyId_}},{key:"addEventInternal",value:function(n,i){var r=this.client_.getUserId(),o={eventId:n,eventDesc:i,timestamp:Qe(),userId:r,tinyId:this.client_.getTinyId()};this.isUplink_||(o.remoteUserId=this.userId_,o.remoteTinyId=this.tinyId_),rt(r,o)}},{key:"getPeerConnection",value:function(){return this.peerConnection_}},{key:"getClient",value:function(){return this.client_}},{key:"getUserId",value:function(){return this.userId_}},{key:"getTinyId",value:function(){return this.tinyId_}},{key:"logSelectedCandidate",value:(t=F(M().mark(function n(){var i,r,o,c,a,s,l;return M().wrap(function(u){for(;;)switch(u.prev=u.next){case 0:if(this.peerConnection_){u.next=2;break}return u.abrupt("return");case 2:return u.next=4,this.peerConnection_.getStats();case 4:i=u.sent,r=qt(i),u.prev=6,r.s();case 8:if((o=r.n()).done){u.next=18;break}if((c=lt(o.value,2))[0],!gh(a=c[1])){u.next=16;break}return s=i.get(a.localCandidateId),l=i.get(a.remoteCandidateId),s&&this.log_.info("local candidate: ".concat(s.candidateType," ").concat(s.protocol,":").concat(s.ip||s.address,":").concat(s.port," ").concat(s.networkType||""," ").concat(s.candidateType==="relay"?"relayProtocol:"+s.relayProtocol:"")),l&&this.log_.info("remote candidate: ".concat(l.candidateType," ").concat(l.protocol,":").concat(l.ip||l.address,":").concat(l.port)),u.abrupt("break",18);case 16:u.next=8;break;case 18:u.next=23;break;case 20:u.prev=20,u.t0=u.catch(6),r.e(u.t0);case 23:return u.prev=23,r.f(),u.finish(23);case 26:case"end":return u.stop()}},n,this,[[6,20,23,26]])})),function(){return t.apply(this,arguments)})},{key:"getCurrentState",value:function(){return this.currentState_}},{key:"waitForPeerConnectionConnected",value:function(){var n=this;return this.waitForPeerConnectionConnectedPromise_||(this.waitForPeerConnectionConnectedPromise_=new Promise(function(i,r){if(n.currentState_===Ye)return i();var o=-1,c=function(l){l.state===Ye&&(clearTimeout(o),s(),i())},a=function(l){l.client===n.client_&&(clearTimeout(o),s(),r(new j({code:V.API_CALL_ABORTED,message:H({key:WL,data:"leave room"})})))},s=function(){U.off(ei,a,n),n.emitter_.off(de.CONNECTION_STATE_CHANGED,c,n)};o=setTimeout(function(){s();var l=new j({code:V.API_CALL_TIMEOUT,message:"connection timeout"});r(l)},1e4),U.on(ei,a,n),n.emitter_.on(de.CONNECTION_STATE_CHANGED,c,n)}),this.waitForPeerConnectionConnectedPromise_=this.waitForPeerConnectionConnectedPromise_.then(function(i){return n.waitForPeerConnectionConnectedPromise_=null,i}).catch(function(i){throw n.waitForPeerConnectionConnectedPromise_=null,i})),this.waitForPeerConnectionConnectedPromise_}},{key:"getReconnectionCount",value:function(){return this.reconnectionCount_}},{key:"startReconnection",value:function(){this.isReconnecting_=!0,this.emitConnectionStateChangedEvent(Ol),this.reconnect(),this.addEventInternal(this.isUplink_?eV:rV,"".concat(this.isUplink_?"uplink":"downlink","-connection is reconnecting"))}},{key:"stopReconnection",value:function(){this.log_.info("stop reconnection"),this.isReconnecting_=!1,this.reconnectionCount_=0,this.clearReconnectionTimer(),this.signalChannel_.off(ma,this.reconnect,this)}},{key:"on",value:function(n,i,r){this.emitter_.on(n,i,r)}},{key:"off",value:function(n,i,r){this.emitter_.off(n,i,r)}},{key:"setDelay",value:function(n){var i=n.audioDelay,r=n.videoDelay;this.delay_={audioDelay:i,videoDelay:r}}},{key:"getDelay",value:function(){return this.delay_}},{key:"isH264",get:function(){var n,i;if((n=this.peerConnection_)!==null&&n!==void 0&&(i=n.remoteDescription)!==null&&i!==void 0&&i.sdp)return!!this.peerConnection_.remoteDescription.sdp.includes("H264");var r=this.client_.getSystemResult().detail,o=r.isH264EncodeSupported,c=r.isH264DecodeSupported;return this.isUplink_?o:c}}]),e}(),Z5=function(){function e(){ce(this,e),this.set_=new Set,U.on(us,this.add,this),U.on(Zr,this.add,this),U.on(sr,this.delete,this),U.on(ei,this.delete,this)}return ue(e,[{key:"add",value:function(t){var n=t.client,i=t.roomId,r=this.getKey(n.getUserId(),i||n.getRoomId(),n.getSDKAppId(),n.getUseStringRoomId());this.set_.add(r)}},{key:"delete",value:function(t){var n=t.client,i=this.getKey(n.getUserId(),n.getRoomId(),n.getSDKAppId(),n.getUseStringRoomId());this.set_.delete(i)}},{key:"getKey",value:function(t,n,i,r){return"".concat(i,"_").concat(n,"_").concat(t,"_").concat(r)}},{key:"isJoined",value:function(t){var n=t.userId,i=t.roomId,r=t.sdkAppId,o=t.client;return this.set_.has(this.getKey(n,i,r,o.getUseStringRoomId()))}}]),e}(),e8=new Z5;function j0(e,t,n,i){if(this.useStringRoomId_){if(!(je(e)&&/^[A-Za-z\d\s!#$%&()+\-:;<=.>?@[\]^_{}|~,]{1,64}$/.test(e)))throw new j({code:V.INVALID_PARAMETER,message:H({key:TN,data:t,link:{className:i,fnName:n}})})}else if(!(Rt(e)&&/^[1-9]\d*$/.test(String(e))&&e<4294967295))throw new j({code:V.INVALID_PARAMETER,message:H({key:wN,data:t,link:{className:i,fnName:n}})})}function F0(e,t,n,i){if(!/^[A-Za-z\d_-]*$/.test(e))throw new j({code:V.INVALID_PARAMETER,message:H({key:BN,data:t,link:{className:i,fnName:n}})})}var t8={createClient:{name:"clientConfig",required:!0,type:ct,properties:{sdkAppId:{required:!0,type:Pe,allowEmpty:!1},userId:{required:!0,type:me,allowEmpty:!1},userSig:{required:!0,type:me,allowEmpty:!1},mode:{required:!0,type:me,values:["rtc",Go]},useStringRoomId:{type:Be},autoSubscribe:{type:Be},enableAutoPlayDialog:{type:Be},streamId:{type:me},userDefineRecordId:{type:me},pureAudioPushMode:{type:Pe,values:[1,2]},enableSEI:{type:Be}}},createStream:{name:"streamConfig",required:!0,type:ct,properties:{userId:{type:me},audio:{type:Be},video:{type:Be},screen:{type:Be},screenAudio:{type:Be},microphoneId:{type:me},cameraId:{type:me},facingMode:{type:[me,ct]},audioSource:{instanceOf:window.MediaStreamTrack},videoSource:{instanceOf:window.MediaStreamTrack}},validate:function(e){if(!G(e.screen)&&e.screen&&G(e.audio)&&(e.audio=!1),!(G(e.audio)&&G(e.video)||G(e.audioSource)&&G(e.videoSource)))throw new j({code:V.INVALID_PARAMETER,message:H({key:IL})});if(!G(e.screen)&&e.screen===!0&&e.video===!0)throw new j({code:V.INVALID_PARAMETER,message:H({key:TL})});if(e.audio&&e.screenAudio)throw new j({code:V.INVALID_PARAMETER,message:H({key:wL})});if(e.screen!==!0&&e.screenAudio===!0)throw new j({code:V.INVALID_PARAMETER,message:H({key:EL})});if(!G(e.screen)&&e.screen===!0&&!this.isScreenShareSupported())throw new j({code:V.INVALID_OPERATION,message:H({key:AL})})}}},n8={join:{name:"options",required:!0,type:ct,properties:{roomId:{required:!0,type:[Pe,me],allowEmpty:!1,validate:j0},role:{type:[me],values:[Wt,er]},privateMapKey:{type:[me]}},validate:function(e){if(this.isJoined_)throw new j({code:V.INVALID_OPERATION,message:H({key:IN})});if(this.checkDestroy(),e8.isJoined({userId:this.userId_,roomId:e.roomId,sdkAppId:this.sdkAppId_,client:this}))throw new j({code:V.INVALID_OPERATION,message:H({key:lL,data:this.userId_})})}},publish:[{name:"stream",required:!0,instanceOf:wn,validate:function(e){if(!this.isJoined_)throw new j({code:V.INVALID_OPERATION,message:H({key:AN})});if(this.mode_===Go&&this.role_===er)throw new j({code:V.INVALID_OPERATION,message:H({key:PN})});if(!e.getIsReadyToPublish())throw new j({code:V.INVALID_OPERATION,message:H({key:DN})});if(this.notPublishWithoutH264Supported_)throw new j({code:V.NOT_SUPPORTED_H264,message:H({key:Py})})}},{name:"options",type:ct,defaultValue:{isAuxiliary:!1},properties:{isAuxiliary:{type:Be,defaultValue:!1,validate:function(){var e=arguments.length>0&&arguments[0]!==void 0&&arguments[0];if(e&&!_s())throw new j({code:V.NOT_SUPPORTED,message:H({key:xL})});if(this.uplinkConnection_&&(e&&this.uplinkConnection_.isAuxStreamPublished||!e&&this.uplinkConnection_.isMainStreamPublished))throw new j({code:V.INVALID_OPERATION,message:H({key:ON,data:e?ke:"local"})});var t=this.localScreenStream_||Se(this.connections_.values()).findIndex(function(n){return n.getTrackState().auxiliary})>=0;if(!this.enableMultiAuxStream_&&e&&t)throw new j({code:V.INVALID_OPERATION,message:H({key:GL})})}}}}],unpublish:{name:"stream",required:!0,instanceOf:wn,validate:function(e){if(e!==this.localStream_&&e!==this.localAuxStream_){if(this.localStream_||this.localAuxStream_)throw new j({code:V.INVALID_PARAMETER,message:H({key:xN})});this.log_.warn("Client currently has no published stream, please call publish() first.")}}},subscribe:[{name:"stream",required:!0,instanceOf:Wl,validate:function(e){if(!e.getConnection())throw new j({code:V.INVALID_OPERATION,message:H({key:Kl})});if(this.notSubscribeWithoutH264Supported_)throw new j({code:V.NOT_SUPPORTED_H264,message:H({key:Dy})})}},{name:"options",type:ct,properties:{audio:{type:Be},video:{type:Be},smallVideo:{type:Be}},validate:function(e){var t=e.audio,n=e.video,i=e.smallVideo;if(t===!1&&n===!1&&(G(i)||i===!1))throw new j({code:V.INVALID_OPERATION,message:H({key:LL})})}}],unsubscribe:{name:"stream",required:!0,instanceOf:Wl,validate:function(e){if(!e.getConnection())throw new j({code:V.INVALID_OPERATION,message:H({key:Kl})})}},switchRole:{name:"role",required:!0,values:[Wt,er],validate:function(){if(this.mode_!==Go)throw new j({code:V.INVALID_PARAMETER,message:H({key:NN})});if(!this.isJoined_)throw new j({code:V.INVALID_OPERATION,message:H({key:LN})})}},startPublishCDNStream:{name:"options",required:!1,properties:{streamId:{type:me,validate:F0},streamType:{type:me,values:["main","auxiliary"]},appId:{type:Pe,allowEmpty:!1},bizId:{type:Pe,allowEmpty:!1},url:{type:me,allowEmpty:!1}},validate:function(){if(this.isDestroyed_)throw new j({code:V.INVALID_OPERATION,message:H({key:Ql,data:{funName:"startPublishCDNStream"}})})}},startMixTranscode:{name:"config",required:!0,type:ct,properties:{mode:{type:me,values:["preset-layout","manual"]},streamId:{type:me,validate:F0},videoWidth:{type:Pe,notLessThanZero:!0},videoHeight:{type:Pe,notLessThanZero:!0},videoBitrate:{type:Pe,notLessThanZero:!0,allowEmpty:!1},videoFramerate:{type:Pe,validate:function(e,t,n,i){if(e<=0||e>30)throw new j({code:V.INVALID_PARAMETER,message:H({key:mL,link:{className:i,fnName:n}})})}},videoGOP:{type:Pe,validate:function(e,t,n,i){if(e<1||e>8)throw new j({code:V.INVALID_PARAMETER,message:H({key:_L,link:{className:i,fnName:n}})})}},audioSampleRate:{type:Pe,notLessThanZero:!0},audioBitrate:{type:Pe,validate:function(e,t,n,i){if(e<32||e>192)throw new j({code:V.INVALID_PARAMETER,message:H({key:vL,link:{className:i,fnName:n}})})}},audioChannels:{type:Pe,values:[1,2]},backgroundColor:{type:Pe},backgroundImage:{type:me},mixUsers:{required:!0,type:iy,arrayItem:{require:!0,type:ct,properties:{userId:{required:!0,type:me},roomId:{type:[me,Pe],validate:j0},pureAudio:{type:Be},width:{type:Pe,notLessThanZero:!0},height:{type:Pe,notLessThanZero:!0},locationX:{type:Pe,notLessThanZero:!0},locationY:{type:Pe,notLessThanZero:!0},zOrder:{type:Pe},streamType:{type:me,values:["main","auxiliary"]},renderMode:{type:Pe,values:[0,1,2,4]}}}}},validate:function(e,t,n,i,r){var o=0,c=0,a=e.mixUsers,s=[];if(a.forEach(function(l,u){if(s.push(l.userId),!l.pureAudio){if(!l.zOrder||l.zOrder<1||l.zOrder>15)throw new j({code:V.INVALID_PARAMETER,message:H({key:gL,data:"config.mixUsers[".concat(u,"].zOrder"),link:{className:i,fnName:n}})});l.width+l.locationX>o&&(o=l.width+l.locationX),l.height+l.locationY>c&&(c=l.height+l.locationY)}}),s.indexOf(this.getUserId())<0)throw new j({code:V.INVALID_PARAMETER,message:H({key:yL,link:{className:i,fnName:n}})});if(e.videoWidth<o||e.videoHeight<c)throw new j({code:V.INVALID_PARAMETER,message:H({key:SL,link:{className:i,fnName:n}})})}},sendSEIMessage:[{name:"buffer",required:!0,instanceOf:ArrayBuffer,validate:function(e){if(!vh)throw new j({code:V.NOT_SUPPORTED,message:H({key:My})});if(!this.enableSEI_)throw new j({code:V.INVALID_OPERATION,message:H({key:UL})});if(e.byteLength>1e3)throw new j({code:V.INVALID_PARAMETER,message:H({key:jL,data:e.byteLength})});if(e.byteLength===0)throw new j({code:V.INVALID_PARAMETER,message:H({key:VL})});if(!this.uplinkConnection_||!this.localStream_)throw new j({code:V.INVALID_PARAMETER,message:H({key:FL})});if(!this.localStream_.hasVideo())throw new j({code:V.INVALID_OPERATION,message:H({key:BL})});var t=this.uplinkConnection_.isH264;if(!t)throw new j({code:V.NOT_SUPPORTED,message:H({key:My,data:t})})}},{name:"options",type:ct,properties:{seiPayloadType:{type:Pe,values:[5,243]}}}]},r8={switchDevice:[{name:"type",required:!0,type:me,values:[K,q]},{name:"deviceId",required:!0,type:me,validate:function(){if(this.screen_&&!this.audio_||this.audioSource_||this.videoSource_)throw new j({code:V.INVALID_OPERATION,message:H({key:XN})});if(this.publishState_===ca)throw new j({code:V.INVALID_OPERATION,message:H({key:YN})});if(!_h())throw new j({code:V.NOT_SUPPORTED,message:H({key:CL})})}}],setAudioCaptureVolume:{name:"volume",type:Pe}},i8={play:[{name:"elementId",required:!0,type:[me,"HTMLDivElement"],validate:function(e,t,n){if(je(e)){var i=document.getElementById(e);if(!i)throw new j({code:V.INVALID_PARAMETER,message:H({key:bL,data:{key:t,fnName:n}})});if(!(i instanceof HTMLDivElement))throw new j({code:V.INVALID_PARAMETER,message:H({key:kL,data:{key:t,fnName:n,type:xn(i)}})})}}},{name:"options",type:ct,properties:{objectFit:{type:me,values:["contain","cover","fill"]},muted:{type:Be},mirror:{type:Be}}}],addTrack:{name:xl,instanceOf:window.MediaStreamTrack,validate:function(e){if(this.isAddingTrack_)throw new j({code:V.INVALID_OPERATION,message:H({key:ZN})});if(this.isRemovingTrack_)throw new j({code:V.INVALID_OPERATION,message:H({key:eL})});if(this.publishState_===ca)throw new j({code:V.INVALID_OPERATION,message:H({key:tL})});var t=this.getMediaStream();if(!t)throw new j({code:V.INVALID_OPERATION,message:H({key:Cy})});if(e.kind===K&&t.getAudioTracks().length>0||e.kind===q&&t.getVideoTracks().length>0)throw new j({code:V.INVALID_OPERATION,message:H({key:nL})});if(!On()&&!ms())throw new j({code:V.NOT_SUPPORTED,message:H({key:Yl,data:Pg})})}},removeTrack:{name:xl,instanceOf:window.MediaStreamTrack,validate:function(e){if(this.isAddingTrack_)throw new j({code:V.INVALID_OPERATION,message:H({key:iL})});if(this.isRemovingTrack_)throw new j({code:V.INVALID_OPERATION,message:H({key:aL})});if(this.publishState_===ca)throw new j({code:V.INVALID_OPERATION,message:H({key:oL})});var t=this.getMediaStream();if(!t)throw new j({code:V.INVALID_OPERATION,message:H({key:Cy})});if(t.getTracks().indexOf(e)===-1)throw new j({code:V.INVALID_PARAMETER,message:H({key:sL})});if(!On()){if(t.getTracks().length===1)throw new j({code:V.INVALID_OPERATION,message:H({key:cL})});if(e.kind===K)throw new j({code:V.INVALID_PARAMETER,message:H({key:rL})});if(!ms())throw new j({code:V.NOT_SUPPORTED,message:H({key:Yl,data:Dg})})}}},replaceTrack:{name:xl,instanceOf:window.MediaStreamTrack,validate:function(e){var t=this.getMediaStream();if(!t)throw new j({code:V.INVALID_OPERATION,message:H({key:$N})});if(this.publishState_===ca)throw new j({code:V.INVALID_OPERATION,message:H({key:Ry})});if(e.kind===K&&t.getAudioTracks().length<=0||e.kind===q&&t.getVideoTracks().length<=0)throw new j({code:V.INVALID_PARAMETER,message:H({key:uL,data:e})});if(!_h())throw new j({code:V.NOT_SUPPORTED,message:H({key:Yl,data:RM})})}}},We={TRTC:t8,CLIENT:n8,LOCAL_STREAM:r8,STREAM:i8};function Qs(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return function(i,r,o){var c=o.value;return o.value=function(){for(var a=arguments.length,s=new Array(a),l=0;l<a;l++)s[l]=arguments[l];return B0.call(this,t,s,r,this.name_),c.apply(this,s)},o}}function nt(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return function(i,r,o){var c=o.value;return o.value=F(M().mark(function a(){var s,l,u,h=arguments;return M().wrap(function(g){for(;;)switch(g.prev=g.next){case 0:for(s=h.length,l=new Array(s),u=0;u<s;u++)l[u]=h[u];return B0.call(this,t,l,r,this.name_),g.abrupt("return",c.apply(this,l));case 3:case"end":return g.stop()}},a,this)})),o}}function B0(e,t,n,i){try{for(var r=0;r<e.length;r++)Dp.call(this,{rule:e[r],value:t[r],key:e[r].name,fnName:n,className:i})}catch(o){throw z.error(o),o}}function Dp(e){var t=this,n=e.rule,i=e.value,r=e.key,o=e.fnName,c=e.className;if(G(i)){if(n.required)throw new j({code:V.INVALID_PARAMETER,message:H({key:sN,data:{key:r,rule:n,fnName:o,value:i},link:{className:c,fnName:o}})});if(G(n.defaultValue))return;i=n.defaultValue}if(Array.isArray(n.type)){if(!n.type.map(function(h){return h.toLowerCase()}).includes(xn(i)))throw new j({code:V.INVALID_PARAMETER,message:H({key:by,data:{key:r,rule:n,fnName:o,value:i},link:{className:c,fnName:o}})})}else if(!G(n.type)&&xn(i)!==n.type)throw new j({code:V.INVALID_PARAMETER,message:H({key:by,data:{key:r,rule:n,fnName:o,value:i},link:{className:c,fnName:o}})});if(n.allowEmpty===!1){var a=Rt(i)&&(i===0||Number.isNaN(i)),s=je(i)&&i.trim()==="";if(a||s)throw new j({code:V.INVALID_PARAMETER,message:H({key:cN,data:{key:r,rule:n,fnName:o,value:i},link:{className:c,fnName:o}})})}if(n.notLessThanZero&&Rt(i)&&i<0)throw new j({code:V.INVALID_PARAMETER,message:H({key:fL,data:{key:r,rule:n,fnName:o,value:i},link:{className:c,fnName:o}})});if(je(n.instanceOf)){if(!i||i.name_!==n.instanceOf)throw new j({code:V.INVALID_PARAMETER,message:H({key:ky,data:{key:r,rule:n,fnName:o,value:i},link:{className:c,fnName:o}})})}else if(et(n.instanceOf)&&!(i instanceof n.instanceOf))throw new j({code:V.INVALID_PARAMETER,message:H({key:ky,data:{key:r,rule:n,fnName:o,value:i},link:{className:c,fnName:o}})});if(n.values&&!n.values.includes(i))throw new j({code:V.INVALID_PARAMETER,message:H({key:uN,data:{key:r,rule:n,fnName:o,value:i},link:{className:c,fnName:o}})});var l=n.properties;An(l)&&Yy(i)&&Object.keys(l).forEach(function(h){Dp.call(t,{rule:l[h],value:i&&i[h],key:"".concat(r,".").concat(h),fnName:o,className:c})});var u=n.arrayItem;An(u)&&Yr(i)&&i.forEach(function(h,g){Dp.call(t,{rule:u,value:h,key:"".concat(r,"[").concat(g,"]"),fnName:o,className:c})}),et(n.validate)&&n.validate.call(this,i,r,o,c,this)}Y({target:"Number",stat:!0},{isNaN:function(e){return e!=e}});var a8=Y,o8=Z,s8=ru.f;a8({target:"Object",stat:!0,forced:o8(function(){return!Object.getOwnPropertyNames(1)})},{getOwnPropertyNames:s8});var H0,Ma,c8=fb;function yi(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{retries:5,timeout:2e3};return function(t,n,i){var r=fa({retryFunction:i.value,settings:e,onError:e.onError,onRetrying:e.onRetrying,onRetryFailed:e.onRetryFailed});return i.value=function(){for(var o=arguments.length,c=new Array(o),a=0;a<o;a++)c[a]=arguments[a];return r.apply(this,c)},i}}Y({target:"Array",stat:!0,forced:!_o(function(e){Array.from(e)})},{from:c8});var W0,G0,z0,Mt,gr=5e3,u8={msg_user_info:0,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},Op=ue(function e(t){ce(this,e),this.str_identifier=String(t.userId),this.uint64_tinyid=Number(t.tinyId),this.uint32_role=t.role}),l8=(H0=yi({timeout:500,retries:3}),Ma=function(){function e(r){var o=this;ce(this,e),this.frameWorkType_=r.frameWorkType||30,this.component_=r.component||0,this.client_=r.client,this.keyPrefix_="key_point",this.storageKey_="".concat(this.keyPrefix_,"_").concat(this.client_.getUserId()),this.log_=z.createLogger({id:"kpm|"+this.client_.getUserId(),userId:this.client_.getUserId(),sdkAppId:this.client_.getSDKAppId()}),Object.getOwnPropertyNames(this.__proto__).forEach(function(c){c.startsWith("handle")&&et(o[c])&&(o[c]=function(a){var s=a.fn,l=a.context;return F(M().mark(function u(){var h,g,b,T=arguments;return M().wrap(function(k){for(;;)switch(k.prev=k.next){case 0:for(k.prev=0,h=T.length,g=new Array(h),b=0;b<h;b++)g[b]=T[b];return k.next=4,s.apply(l||this,g);case 4:return k.abrupt("return",k.sent);case 7:k.prev=7,k.t0=k.catch(0),z.error("".concat(s.name,"() error observed ")+k.t0);case 10:case"end":return k.stop()}},u,this,[[0,7]])}))}({fn:o[c],context:o}))}),this.initData(),this.installEvents(),this.intervalId_=ye.run(Kr,this.setStorage.bind(this),{delay:2e4})}var t,n,i;return ue(e,[{key:"initData",value:function(){var r;this.firstPublishedUserList_=[],this.networkQuality_={totalUplinkRTT:0,totalUplinkLoss:0,count:0,totalDownlinkRTTAndLossMap:new Map},this.basicInfo={string_sdk_version:Wn,uint32_os_type:15,string_device_name:"",string_http_user_agent:navigator.userAgent,string_os_version:"",string_domain:location.host,uint32_avg_rtt:0,uint32_avg_up_loss:0,uint32_scene:((r=this.client_)===null||r===void 0?void 0:r.getMode())==="live"?1:0,uint32_joining_duration:0,uint32_networkType:Bl[vd()],uint32_framework:this.frameWorkType_,uint32_component:this.component_},this.pathJoinRoom_={uint64_start_time:0,uint64_init_audio_start_time:0,uint64_init_audio_end_time:0,uint64_init_camera_start_time:0,uint64_init_camera_end_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_init_audio_ret:0,int32_init_camera_ret: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.pathMainVideoMap_=new Map,this.pathMainAudioMap_=new Map,this.pathAuxiliaryMap_=new Map,this.localStreamStats_={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.remoteStreamStatsMap_=new Map}},{key:"installEvents",value:function(){U.on(us,this.handleJoinStart,this),U.on(Ad,this.handleWSStart,this),U.on(ls,this.handleWSEnd,this),U.on(kd,this.handleJoinSendCMD,this),U.on(Id,this.handleJoinReceivedCMDResponce,this),U.on(Zr,this.handleJoinSuccess,this),U.on(sr,this.handleJoinFailed,this),U.on(Rd,this.handleReceivedPublishUserList,this),U.on(hs,this.handleConnectionStateChanged,this),U.on(Td,this.handleLeaveStart,this),U.on(ei,this.handleLeaveSuccess,this),U.on(wd,this.handleLeaveSendCMD,this),U.on(Gd,this.handleSendSubscribeCMD,this),U.on(da,this.handleVideoPlaying,this),U.on(Dd,this.handleAudioPlaying,this),U.on(zd,this.handleNetworkQuality,this),U.on(Ed,this.handleHeartbeatStats,this),U.on(ds,this.handleRemoteStreamAdded,this),U.on(Od,this.handleRemoteStreamSubscribeStart,this),U.on(nn,this.handleRemoteStreamSubscribed,this),U.on(cr,this.handleRemoteStreamRemoved,this),U.on(jd,this.handleVideoLoadedData,this),U.on(Vd,this.handlePlayStream,this),U.on(Cd,this.handlePublishStart,this),U.on(Md,this.handleLocalStreamInitStart,this),U.on(Nd,this.handleLocalStreamInitEnd,this),U.on(Ld,this.handleLocalStreamInitFailed,this)}},{key:"uninstallEvents",value:function(){U.off(us,this.handleJoinStart,this),U.off(Ad,this.handleWSStart,this),U.off(ls,this.handleWSEnd,this),U.off(kd,this.handleJoinSendCMD,this),U.off(Id,this.handleJoinReceivedCMDResponce,this),U.off(Rd,this.handleReceivedPublishUserList,this),U.off(hs,this.handleConnectionStateChanged,this),U.off(Td,this.handleLeaveStart,this),U.off(ei,this.handleLeaveSuccess,this),U.off(Zr,this.handleJoinSuccess,this),U.off(sr,this.handleJoinFailed,this),U.off(wd,this.handleLeaveSendCMD,this),U.off(Gd,this.handleSendSubscribeCMD,this),U.off(da,this.handleVideoPlaying,this),U.off(Dd,this.handleAudioPlaying,this),U.off(zd,this.handleNetworkQuality,this),U.off(Ed,this.handleHeartbeatStats,this),U.off(ds,this.handleRemoteStreamAdded,this),U.off(Od,this.handleRemoteStreamSubscribeStart,this),U.off(nn,this.handleRemoteStreamSubscribed,this),U.off(cr,this.handleRemoteStreamRemoved,this),U.off(jd,this.handleVideoLoadedData,this),U.off(Vd,this.handlePlayStream,this),U.off(Cd,this.handlePublishStart,this),U.off(Md,this.handleLocalStreamInitStart,this),U.off(Nd,this.handleLocalStreamInitEnd,this),U.off(Ld,this.handleLocalStreamInitFailed,this)}},{key:"destroy",value:function(){this.uninstallEvents(),ye.clearTask(this.intervalId_),this.client_=null}},{key:"handleJoinStart",value:function(r){this.hitTest(r.client)&&this.pathJoinRoom_.uint64_start_time===0&&(this.pathJoinRoom_.uint64_start_time=Date.now(),this.checkStorage())}},{key:"handleWSStart",value:function(r){var o=r.client;this.hitTest(o)&&this.pathJoinRoom_.uint64_send_request_acc_ip_cmd_start_time===0&&(this.pathJoinRoom_.uint64_send_request_acc_ip_cmd_start_time=Date.now())}},{key:"handleWSEnd",value:function(r){var o=r.client,c=r.error;this.hitTest(o)&&this.pathJoinRoom_.uint64_send_request_acc_ip_cmd_end_time===0&&(this.pathJoinRoom_.uint64_send_request_acc_ip_cmd_end_time=Date.now(),c&&(this.pathJoinRoom_.int32_send_request_acc_ip_cmd_ret=c instanceof j?Number(c.getExtraCode()||c.getCode()):V.UNKNOWN,this.pathJoinRoom_.int32_end_ret=2))}},{key:"handleJoinSendCMD",value:function(r){this.hitTest(r.client)&&this.pathJoinRoom_.uint64_send_request_enter_room_cmd_start_time===0&&(this.pathJoinRoom_.uint64_send_request_enter_room_cmd_start_time=Date.now())}},{key:"handleJoinReceivedCMDResponce",value:function(r){this.hitTest(r.client)&&this.pathJoinRoom_.uint64_send_request_enter_room_cmd_end_time===0&&(this.pathJoinRoom_.uint64_send_request_enter_room_cmd_end_time=Date.now(),this.pathJoinRoom_.int32_send_request_enter_room_cmd_ret=r.code,r.code!==0&&(this.pathJoinRoom_.int32_end_ret=3))}},{key:"handleJoinSuccess",value:function(r){this.hitTest(r.client)&&this.pathJoinRoom_.uint64_end_time===0&&(this.pathJoinRoom_.uint64_end_time=Date.now(),this.pathJoinRoom_.int32_end_ret=0)}},{key:"handleJoinFailed",value:function(r){var o=r.client;this.hitTest(o)&&(this.pathJoinRoom_.uint64_end_time=Date.now(),this.pathJoinRoom_.int32_end_ret===0&&(this.pathJoinRoom_.int32_end_ret=3),this.prepareReport(),this.report())}},{key:"handleReceivedPublishUserList",value:function(r){this.hitTest(r.client)&&this.pathJoinRoom_.uint64_recv_userlist_time===0&&(this.pathJoinRoom_.uint64_recv_userlist_time=Date.now(),this.firstPublishedUserList_=r.data.data&&r.data.data.userList||[])}},{key:"handleConnectionStateChanged",value:function(r){var o=r.client,c=r.state,a=r.connection;if(this.hitTest(o)&&c===Ye){this.client_.getUplinkConnection()===a&&this.pathJoinRoom_.uint64_send_first_video_frame_time===0&&this.localStreamStats_.publishStartTime>this.pathJoinRoom_.uint64_end_time&&this.localStreamStats_.publishStartTime-this.pathJoinRoom_.uint64_end_time<=100&&(this.pathJoinRoom_.uint64_send_first_video_frame_time=Date.now());var s=this.pathMainVideoMap_.get("".concat(a.getUserId(),"_").concat(Te));s&&s.statsToReport.uint64_pc_connected_time===0&&(s.statsToReport.uint64_pc_connected_time=Date.now())}}},{key:"handleLeaveStart",value:function(r){this.hitTest(r.client)&&(this.pathLeaveRoom_.uint64_start_time=Date.now())}},{key:"handleLeaveSuccess",value:function(r){this.hitTest(r.client)&&this.pathLeaveRoom_.uint64_end_time===0&&(this.pathLeaveRoom_.uint64_end_time=Date.now(),this.pathJoinRoom_.uint64_end_time!==0?this.basicInfo.uint32_joining_duration=this.pathLeaveRoom_.uint64_end_time-this.pathJoinRoom_.uint64_end_time:this.log_.warn("pathJoinRoom endTime is 0"),this.report())}},{key:"handleLeaveSendCMD",value:function(r){this.hitTest(r.client)&&(this.pathLeaveRoom_.uint64_send_request_exit_room_cmd_start_time=Date.now(),this.pathLeaveRoom_.uint64_send_request_exit_room_cmd_end_time=Date.now())}},{key:"handleRemoteStreamAdded",value:function(r){var o=r.client,c=r.stream;if(this.hitTest(o)){var a=c.getUserId(),s=c.getType(),l="".concat(a,"_").concat(s),u=this.remoteStreamStatsMap_.get(l);if(u)u.stream=c;else{var h={userId:a,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:te({},u8),stream:c};h.statsToReport.msg_user_info=new Op({userId:a,tinyId:c.getTinyId(),role:Jr}),h.statsToReport.uint32_stream_type=s===Te?2:7,this.remoteStreamStatsMap_.set(l,h)}}}},{key:"handleRemoteStreamSubscribeStart",value:function(r){var o=r.client,c=r.stream;if(this.hitTest(o)){var a=c.getUserId(),s=c.getType(),l="".concat(a,"_").concat(s),u=this.remoteStreamStatsMap_.get(l);u&&u.subscribeStartTime===0&&(u.subscribeStartTime=Date.now())}}},{key:"handleSendSubscribeCMD",value:function(r){if(this.hitTest(r.client)){var o=new Op(r),c=Date.now(),a="".concat(r.userId,"_").concat(Te);r.trackState.video&&r.subscribeState.video&&!this.pathMainVideoMap_.has(a)&&this.pathMainVideoMap_.set(a,{statsToReport:{msg_user_info:o,uint64_start_enter_time:this.pathJoinRoom_.uint64_start_time,uint64_render_first_frame_time:0,uint64_combine_first_frame_time:0,uint64_pc_connected_time:0},userId:r.userId,sendSubscribeCMDTime:c}),r.trackState.audio&&r.subscribeState.audio&&!this.pathMainAudioMap_.has(a)&&this.pathMainAudioMap_.set(a,{statsToReport:{msg_user_info:o,uint64_start_enter_time:this.pathJoinRoom_.uint64_start_time,uint64_play_first_frame_time:0},userId:r.userId,sendSubscribeCMDTime:c});var s="".concat(r.userId,"_").concat(Ne);r.trackState.auxiliary&&r.subscribeState.auxiliary&&!this.pathAuxiliaryMap_.has(s)&&this.pathAuxiliaryMap_.set(s,{sendSubscribeCMDTime:c})}}},{key:"handleRemoteStreamSubscribed",value:function(r){var o=r.client,c=r.stream;if(this.hitTest(o)){var a=c.getUserId(),s=c.getType(),l="".concat(a,"_").concat(s),u=this.remoteStreamStatsMap_.get(l);u&&u.subscribedTime===0&&(u.subscribedTime=Date.now(),u.stream=c)}}},{key:"handleRemoteStreamRemoved",value:function(r){var o=r.client,c=r.stream;if(this.hitTest(o)){var a=c.getUserId(),s=c.getType(),l=this.remoteStreamStatsMap_.get("".concat(a,"_").concat(s));l&&(l.stream=null)}}},{key:"handlePlayStream",value:function(r){var o=r.stream;if(o.isRemote()&&o.getConnection()&&this.hitTest(o.getConnection().getClient())){var c=o.getConnection().getUserId(),a="".concat(c,"_").concat(o.getType());if(this.remoteStreamStatsMap_.has(a)){var s=this.remoteStreamStatsMap_.get(a);s.playStreamTime===0&&(s.playStreamTime=Date.now())}}}},{key:"handleVideoLoadedData",value:function(r){var o=r.stream;if(o.isRemote()&&o.getConnection()&&this.hitTest(o.getConnection().getClient())){var c=o.getConnection().getUserId(),a="".concat(c,"_").concat(o.getType());if(this.pathMainVideoMap_.has(a)){var s=this.pathMainVideoMap_.get(a);s.statsToReport.uint64_combine_first_frame_time===0&&(s.statsToReport.uint64_combine_first_frame_time=Date.now())}}}},{key:"handleVideoPlaying",value:function(r){var o=r.stream;if(o.isRemote()&&o.getConnection()&&this.hitTest(o.getConnection().getClient())){var c=o.getConnection().getUserId(),a="".concat(c,"_").concat(o.getType()),s=Date.now();if(this.pathMainVideoMap_.has(a)){var l=this.pathMainVideoMap_.get(a);if(l.statsToReport.uint64_render_first_frame_time===0&&(l.statsToReport.uint64_render_first_frame_time=s),this.remoteStreamStatsMap_.has(a)){var u=this.remoteStreamStatsMap_.get(a),h=u.statsToReport,g=u.playStreamTime,b=u.subscribedTime;h.uint32_video_render_first===0&&g-b<=100&&(h.uint32_video_render_first=s-l.sendSubscribeCMDTime)}}if(o.getType()===Ne&&this.pathAuxiliaryMap_.has(a)&&this.remoteStreamStatsMap_.has(a)){var T=this.remoteStreamStatsMap_.get(a),k=T.statsToReport,p=T.playStreamTime,S=T.subscribedTime;k.uint32_video_render_first===0&&p-S<=100&&(k.uint32_video_render_first=s-this.pathAuxiliaryMap_.get(a).sendSubscribeCMDTime)}}}},{key:"handleAudioPlaying",value:function(r){if(r.stream.isRemote()&&r.stream.getConnection()&&this.hitTest(r.stream.getConnection().getClient())){var o=r.stream.getConnection().getUserId(),c="".concat(o,"_").concat(r.stream.getType());if(this.pathMainAudioMap_.has(c)){var a=this.pathMainAudioMap_.get(c);a.statsToReport.uint64_play_first_frame_time===0&&(a.statsToReport.uint64_play_first_frame_time=Date.now())}}}},{key:"handleNetworkQuality",value:function(r){var o=this;this.hitTest(r.client)&&(this.networkQuality_.totalUplinkLoss+=r.uplinkLoss,this.networkQuality_.totalUplinkRTT+=r.uplinkRTT,this.networkQuality_.count++,r.downlinkLossAndRTTMap.forEach(function(c){var a=c.rtt,s=c.loss,l=c.userId,u=o.networkQuality_.totalDownlinkRTTAndLossMap.get(l);u?(u.totalRTT+=a,u.totalLoss+=s,u.count++):o.networkQuality_.totalDownlinkRTTAndLossMap.set(l,{totalRTT:a,totalLoss:s,count:1})}))}},{key:"handleHeartbeatStats",value:function(r){var o=this;if(this.hitTest(r.client)){var c=r.stats,a=c.msg_up_stream_info,s=c.msg_down_stream_info;if(a.msg_video_status[0]){var l=a.msg_video_status[0],u=l.uint32_video_codec_bitrate,h=l.uint32_video_enc_fps,g=l.uint32_video_width,b=l.uint32_video_height;this.localStreamStats_.totalVideoBitrate+=u,this.localStreamStats_.totalVideoFPS+=h,this.localStreamStats_.totalVideoWidth+=g,this.localStreamStats_.totalVideoHeight+=b,this.localStreamStats_.videoCount++}if(a.msg_audio_status){var T=a.msg_audio_status.audioLevel;Math.floor(100*T)>0&&(this.localStreamStats_.totalAudioLevel+=T,this.localStreamStats_.audioLevelCount++)}s.forEach(function(k){var p=k.msg_user_info,S=k.msg_audio_status,f=k.msg_video_status,I=p.str_identifier;if(f.forEach(function(m){var v=m.uint32_video_stream_type===2,w=m.uint32_video_stream_type===7,R="".concat(I,"_").concat(v?Te:Ne);if(o.remoteStreamStatsMap_.has(R)){var P,y,d=o.remoteStreamStatsMap_.get(R);(v&&(P=d.stream)!==null&&P!==void 0&&P.isMainVideoSubscribed||w&&(y=d.stream)!==null&&y!==void 0&&y.isAuxVideoSubscribed)&&(d.totalVideoFPS+=m.uint32_video_receive_fps,d.totalVideoBitrate+=m.uint32_video_codec_bitrate,d.videoCount++,d.statsToReport.uint32_video_width===0&&(d.statsToReport.uint32_video_width=m.uint32_video_width),d.statsToReport.uint32_video_height===0&&(d.statsToReport.uint32_video_height=m.uint32_video_height))}}),S){var A="".concat(I,"_").concat(Te);if(o.remoteStreamStatsMap_.has(A)){var x,D=o.remoteStreamStatsMap_.get(A);(x=D.stream)!==null&&x!==void 0&&x.isMainAudioSubscribed&&(D.totalAudioBitrate+=S.uint32_audio_codec_bitrate,D.audioCount++,Math.floor(100*S.audioLevel)>0&&(D.totalAudioLevel+=S.audioLevel,D.audioLevelCount++))}}})}}},{key:"handlePublishStart",value:function(r){var o=r.client;this.hitTest(o)&&this.localStreamStats_.publishStartTime===0&&(this.localStreamStats_.publishStartTime=Date.now())}},{key:"handleLocalStreamInitStart",value:function(r){var o=r.audio,c=r.video;o&&this.pathJoinRoom_.uint64_init_audio_start_time===0&&(this.pathJoinRoom_.uint64_init_audio_start_time=Date.now()),c&&this.pathJoinRoom_.uint64_init_camera_start_time===0&&(this.pathJoinRoom_.uint64_init_camera_start_time=Date.now())}},{key:"handleLocalStreamInitEnd",value:function(r){var o=r.audio,c=r.video;o&&this.pathJoinRoom_.uint64_init_audio_end_time===0&&(this.pathJoinRoom_.uint64_init_audio_end_time=Date.now()),c&&this.pathJoinRoom_.uint64_init_camera_end_time===0&&(this.pathJoinRoom_.uint64_init_camera_end_time=Date.now())}},{key:"handleLocalStreamInitFailed",value:function(r){var o=r.audio,c=r.video,a=r.error,s=a instanceof j?a.getExtraCode()||a.getCode():{NotFoundError:1,NotAllowedError:2,NotReadableError:3,OverConstrainedError:4,AbortError:5}[a.name]||V.UNKNOWN;o&&this.pathJoinRoom_.uint64_init_audio_end_time===0&&(this.pathJoinRoom_.int32_init_audio_ret=s,this.pathJoinRoom_.uint64_init_audio_end_time=Date.now()),c&&this.pathJoinRoom_.uint64_init_camera_end_time===0&&(this.pathJoinRoom_.int32_init_camera_ret=s,this.pathJoinRoom_.uint64_init_camera_end_time=Date.now())}},{key:"hasVideoFlag",value:function(r){return this.firstPublishedUserList_.findIndex(function(o){return o.userId===r&&1&o.flag})>=0}},{key:"hasAudioFlag",value:function(r){return this.firstPublishedUserList_.findIndex(function(o){return o.userId===r&&8&o.flag})>=0}},{key:"hasAuxFlag",value:function(r){return this.firstPublishedUserList_.findIndex(function(o){return o.userId===r&&4&o.flag})>=0}},{key:"hitTest",value:function(r){return r===this.client_}},{key:"checkStorage",value:(i=F(M().mark(function r(){var o;return M().wrap(function(c){for(;;)switch(c.prev=c.next){case 0:if(c.prev=0,!(o=ai.getItem(this.storageKey_))){c.next=6;break}return c.next=5,this.upload(o);case 5:ai.deleteItem(this.storageKey_);case 6:c.next=11;break;case 8:c.prev=8,c.t0=c.catch(0),this.log_.warn(c.t0);case 11:case"end":return c.stop()}},r,this,[[0,8]])})),function(){return i.apply(this,arguments)})},{key:"setStorage",value:function(){this.prepareReport();var r=this.getReportData();r.msg_path_enter_room.uint64_start_time!==0&&ai.setItem(this.storageKey_,r)}},{key:"prepareReport",value:function(){var r=this;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.localStreamStats_.videoCount>0){this.localStreamStats_.statsToReport.uint32_video_big_capture_fps=Math.floor(this.localStreamStats_.totalVideoFPS/this.localStreamStats_.videoCount),this.localStreamStats_.statsToReport.uint32_video_big_bitrate=Math.floor(this.localStreamStats_.totalVideoBitrate/this.localStreamStats_.videoCount);var o=Math.floor(this.localStreamStats_.totalVideoWidth/this.localStreamStats_.videoCount),c=Math.floor(this.localStreamStats_.totalVideoHeight/this.localStreamStats_.videoCount);this.localStreamStats_.statsToReport.uint32_video_big_resolution=o<<16|c}this.localStreamStats_.audioLevelCount>0&&(this.localStreamStats_.statsToReport.uint32_audio_capture_db=Math.floor(this.localStreamStats_.totalAudioLevel/this.localStreamStats_.audioLevelCount*100)),this.remoteStreamStatsMap_.forEach(function(a,s){var l=a.userId;if(r.networkQuality_.totalDownlinkRTTAndLossMap.has(l)){var u=r.networkQuality_.totalDownlinkRTTAndLossMap.get(l),h=u.totalLoss,g=u.count;a.statsToReport.uint32_avg_down_loss=Math.floor(h/g)}a.videoCount>0&&(a.statsToReport.uint32_video_avg_fps=Math.floor(a.totalVideoFPS/a.videoCount),a.statsToReport.uint32_video_avg_bitrate=Math.floor(a.totalVideoBitrate/a.videoCount)),a.audioCount>0&&(a.statsToReport.uint32_audio_recv_bitrate=a.statsToReport.uint32_audio_bitrate=Math.floor(a.totalAudioBitrate/a.audioCount)),a.audioLevelCount>0&&(a.statsToReport.uint32_audio_play_db=Math.floor(a.totalAudioLevel/a.audioLevelCount*100));var b=r.client_.getCallDurationCalculator();b&&(a.statsToReport.uint32_audio_play_time=b.getDuration(s,K),a.statsToReport.uint32_video_play_time=b.getDuration(s,q)),a.statsToReport.uint32_video_render_first=Math.min(a.statsToReport.uint32_video_render_first,gr);var T=r.client_.getBadCaseDetector();if(T){var k=T.getDataFreezeDuration(s),p=k.dataFreeze,S=k.count,f=T.getRenderFreezeDuration(s).renderFreeze;a.statsToReport.uint32_video_block_count=S,a.statsToReport.uint32_video_block_time=Math.min(p,a.statsToReport.uint32_video_play_time),a.statsToReport.uint32_video_external_block_time=Math.min(f,a.statsToReport.uint32_video_play_time),T.isBlackStream(s)&&a.statsToReport.uint32_video_avg_fps===0?a.statsToReport.uint32_video_black_screen_subjective=1:a.statsToReport.uint32_video_black_screen_subjective=0}(a.subscribeStartTime===0||a.subscribeStartTime-a.streamAddedTime>100||a.playStreamTime===0)&&(r.pathMainAudioMap_.delete(s),r.pathMainVideoMap_.delete(s),a.statsToReport.uint32_video_render_first=0)}),this.pathMainAudioMap_.forEach(function(a,s){r.hasAudioFlag(a.userId)?a.statsToReport.uint64_play_first_frame_time-a.statsToReport.uint64_start_enter_time>gr&&(a.statsToReport.uint64_play_first_frame_time=a.statsToReport.uint64_start_enter_time+gr):r.pathMainAudioMap_.delete(s)}),this.pathMainVideoMap_.forEach(function(a,s){r.hasVideoFlag(a.userId)?a.statsToReport.uint64_render_first_frame_time-a.statsToReport.uint64_start_enter_time>gr&&(a.statsToReport.uint64_render_first_frame_time=a.statsToReport.uint64_start_enter_time+gr):r.pathMainVideoMap_.delete(s)}),this.pathJoinRoom_.uint64_end_time-this.pathJoinRoom_.uint64_start_time>gr&&(this.pathJoinRoom_.uint64_end_time=this.pathJoinRoom_.uint64_start_time+gr)}},{key:"getReportData",value:function(){var r=this.client_.getSignalInfo();return{uint32_sdk_app_id:Number(this.client_.getSDKAppId()),msg_user_info:new Op({userId:this.client_.getUserId(),tinyId:this.client_.getTinyId(),role:this.client_.getRole()===Wt?Jr:Dl}),msg_basic_info:this.basicInfo,uint32_acc_ip:yd(r.relayIp),uint32_client_ip:yd(r.clientIp,"small"),uint32_acc_port:0,uint64_timestamp:Date.now(),uint32_seq:Math.floor(Math.random()*Math.pow(2,31)),msg_path_enter_room:this.pathJoinRoom_,msg_path_exit_room:this.pathLeaveRoom_,msg_path_recv_video:Se(this.pathMainVideoMap_.values()).map(function(o){return o.statsToReport}),msg_quality_statistics:Se(this.remoteStreamStatsMap_.values()).map(function(o){return o.statsToReport}),str_room_name:String(this.client_.getRoomId()),msg_path_recv_audio:Se(this.pathMainAudioMap_.values()).map(function(o){return o.statsToReport}),uint32_info_client_ip:yd(r.clientIp,"small"),error_code:[],msg_local_statistics:this.localStreamStats_.statsToReport,msg_function_state:jn.getStateArray()}}},{key:"report",value:(n=F(M().mark(function r(){var o;return M().wrap(function(c){for(;;)switch(c.prev=c.next){case 0:return c.prev=0,o=this.getReportData(),c.next=4,this.upload(o);case 4:ai.deleteItem(this.storageKey_),jn.clearStateArray(),this.initData(),c.next=12;break;case 9:c.prev=9,c.t0=c.catch(0),this.log_.warn(c.t0);case 12:case"end":return c.stop()}},r,this,[[0,9]])})),function(){return n.apply(this,arguments)})},{key:"upload",value:(t=F(M().mark(function r(o){var c,a,s;return M().wrap(function(l){for(;;)switch(l.prev=l.next){case 0:if(!(rr||o.msg_path_enter_room.uint64_start_time===0||[Gl,ly,dy].findIndex(function(u){return u===location.host})>=0)){l.next=2;break}return l.abrupt("return");case 2:return c=Number(this.client_.getSDKAppId()),a=os(c,OM),l.next=6,cs({url:a,body:JSON.stringify(o)});case 6:if((s=l.sent).data==="ok"){l.next=9;break}throw"key point upload failed: ".concat(s.data);case 9:case"end":return l.stop()}},r,this)})),function(r){return t.apply(this,arguments)})}]),e}(),ie(Ma.prototype,"upload",[H0],Object.getOwnPropertyDescriptor(Ma.prototype,"upload"),Ma.prototype),Ma),jn=function(){function e(){ce(this,e)}return ue(e,null,[{key:"handleFunctionState",value:function(t){var n,i,r,o,c=t.className,a=t.fnName,s=t.params;if(!(rr||[Gl,ly,dy].findIndex(function(g){return g===location.host})>=0)){var l,u=[];if(c)switch(a){case"createClient":(n=s[0])!==null&&n!==void 0&&n.mode&&u.push("".concat(c,".").concat(a,".").concat(s[0].mode)),(i=s[0])!==null&&i!==void 0&&i.useStringRoomId?u.push("".concat(c,".").concat(a,".stringRoomId")):u.push("".concat(c,".").concat(a,".intRoomId")),(r=s[0])!==null&&r!==void 0&&r.autoSubscribe?u.push("".concat(c,".").concat(a,".autoSubscribe")):u.push("".concat(c,".").concat(a,".manualSubscribe"));break;case"publish":(o=s[1])!==null&&o!==void 0&&o.isAuxiliary?u.push("".concat(c,".").concat(a,".isAuxiliary")):u.push("".concat(c,".").concat(a));break;case"setAudioProfile":case"setVideoProfile":case"setScreenProfile":case"setVideoContentHint":je(s[0])&&u.push("".concat(c,".").concat(a,".").concat(s[0]));break;default:u.push("".concat(c,".").concat(a))}else u.push(a);for(var h=0;h<u.length;h++){if(!(l=eN[u[h]]))return;this.stateMap.has(l)?this.stateMap.get(l).int32_call_times+=1:this.stateMap.set(l,{int32_id:l,int32_call_times:1})}}}},{key:"getStateArray",value:function(){return Array.from(this.stateMap.values())}},{key:"clearStateArray",value:function(){this.stateMap.clear()}}]),e}();function Ee(e){return function(t,n,i){var r=i.value;return i.value=function(){for(var o=arguments.length,c=new Array(o),a=0;a<o;a++)c[a]=arguments[a];try{e||(e=this.name_),jn.handleFunctionState({className:e,fnName:n,params:c}),e=void 0}catch(s){this.log_.info(s)}return r.apply(this,c)},i}}Ba(jn,"stateMap",new Map);var J0=(W0=nt.apply(void 0,Se(We.STREAM.play)),G0=Ee(),z0=Ee(),Mt=function(){function e(c){ce(this,e),this.name_=QM,this.userId_=c.userId,this.isRemote_=c.isRemote,this.type_=c.type,this.log_=z.createLogger({id:"s".concat(c.seq?c.seq:"","|").concat(this.userId_),userId:G(c.client)?void 0:c.client.getUserId(),sdkAppId:G(c.client)?void 0:c.client.getSDKAppId(),isLocal:!this.isRemote_,type:this.isRemote_?this.type_:""}),this.client_=null,G(c.client)||(this.client_=c.client),this.mediaStream_=null,this.div_=null,this.isPlaying_=!1,this.connection_=null,this.audioPlayer_=null,this.videoPlayer_=null,this.muted_=!1,this.objectFit_="cover",this.mirror_=!1,this.id_="xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(a){var s=16*Math.random()|0;return(a=="x"?s:3&s|8).toString(16)}),this.audioOutputDeviceId_=0,this.audioVolume_=1,this.emitter_=rS(new Pn,this.name_),this.connectionState_=Xe,this.installEvents(),G(c.mirror)||this.log_.warn('TRTC.createStream "mirror" option was deprecated since v4.12.1please use localStream.play to set up preview mirror. refer to '.concat(qr,"/en/LocalStream.html#play. TRTC.createStream 接口的 mirror 选项从 v4.12.1 开始被废弃,请使用 localStream.play 设置本地流预览镜像,参考文档:").concat(qr,"/zh-cn/LocalStream.html#play。")),this.audioPlayerRetryCount_=3}var t,n,i,r,o;return ue(e,[{key:"installEvents",value:function(){U.on(pa,this.restartPlayback,this)}},{key:"uninstallEvents",value:function(){U.off(pa,this.restartPlayback,this)}},{key:"getType",value:function(){return this.type_}},{key:"getLogger",value:function(){return this.log_}},{key:"isSubscribed",get:function(){return this.type_===Te&&this.connection_.isMainStreamSubscribed||this.type_===Ne&&this.connection_.isAuxStreamSubscribed}},{key:"isMainVideoSubscribed",get:function(){var c=this.getSubscribedState();return this.type_===Te&&c&&c.video}},{key:"isMainAudioSubscribed",get:function(){var c=this.getSubscribedState();return this.type_===Te&&c&&c.audio}},{key:"isAuxVideoSubscribed",get:function(){var c=this.getSubscribedState();return this.type_===Ne&&c&&c.auxiliary}},{key:"isSmallVideoSubscribed",get:function(){var c=this.getSubscribedState();return this.type_===Te&&c&&c.smallVideo}},{key:"emitConnectionStateChanged",value:function(c){c.state!==this.connectionState_&&(c.state!==Xe&&this.isRemote_&&!this.isSubscribed||(this.emitter_.emit(JV,c),this.connectionState_=c.state))}},{key:"setConnection",value:function(c){this.connection_!==c&&(c instanceof Pp?(this.connection_!==null&&this.connection_.off(de.CONNECTION_STATE_CHANGED,this.emitConnectionStateChanged,this),c.on(de.CONNECTION_STATE_CHANGED,this.emitConnectionStateChanged,this)):c===null&&this.connection_.off(de.CONNECTION_STATE_CHANGED,this.emitConnectionStateChanged,this),this.connection_=c)}},{key:"getConnection",value:function(){return this.connection_}},{key:"play",value:(o=F(M().mark(function c(a,s){var l,u,h;return M().wrap(function(g){for(;;)switch(g.prev=g.next){case 0:if(this.log_.info("stream ".concat(this.isPlaying_?"update":"start to"," play with elementId: ").concat(a," and options: ").concat(JSON.stringify(s),".")),!this.isPlaying_){g.next=9;break}return s&&!G(s.muted)&&(this.muted_=s.muted),s&&!G(s.objectFit)&&(this.objectFit_=s.objectFit),this.isScreenShare()?this.mirror_=!1:s&&!G(s.mirror)&&(this.mirror_=s.mirror),this.audioPlayer_&&this.audioPlayer_.setMuted(this.muted_),this.videoPlayer_&&(this.videoPlayer_.setObjectFit(this.objectFit_),this.videoPlayer_.setMirror(this.mirror_)),this.elementId_!==a&&(l=a,je(a)&&(l=document.getElementById(a)),l.appendChild(this.div_),this.elementId_=a),g.abrupt("return");case 9:return this.isPlaying_=!0,(u=document.createElement("div")).setAttribute("id","player_".concat(this.id_)),u.setAttribute("style","width: 100%; height: 100%; position: relative; background-color: black; overflow: hidden;"),h=a,je(a)&&(h=document.getElementById(a)),h.appendChild(u),this.elementId_=a,this.div_=u,this.isRemote_||(this.muted_=!0),s&&!G(s.muted)&&(this.muted_=s.muted),this.isScreenShare()&&(this.objectFit_="contain"),s&&!G(s.objectFit)&&(this.objectFit_=s.objectFit),this.isScreenShare()?this.mirror_=!1:(this.isRemote_||(this.mirror_=!0),s&&!G(s.mirror)&&(this.mirror_=s.mirror)),U.emit(Vd,{stream:this}),g.next=26,Promise.all([this.playAudio(),this.playVideo()]);case 26:U.emit(S3,{stream:this});case 27:case"end":return g.stop()}},c,this)})),function(c,a){return o.apply(this,arguments)})},{key:"playAudio",value:(r=F(M().mark(function c(){var a,s,l=this;return M().wrap(function(u){for(;;)switch(u.prev=u.next){case 0:if(this.hasAudio()&&(!this.isRemote_||this.isMainAudioSubscribed)){u.next=2;break}return u.abrupt("return");case 2:if(a=this.getAudioTrack(),this.audioPlayer_||!a){u.next=18;break}return this.log_.info("create AudioPlayer and play"),this.audioPlayer_=new q4({stream:this,track:a,gainedTrack:(s=this.gain_)===null||s===void 0?void 0:s.audioTrack,div:this.div_,muted:this.muted_,outputDeviceId:this.audioOutputDeviceId_,volume:this.audioVolume_}),this.audioPlayer_.on(it,function(h){var g={type:K,state:h.state,reason:h.reason};U.emit(uS,te({stream:l},g)),l.emitter_.emit(ib,g)}),this.audioPlayer_.on(ab,function(h){l.audioPlayerRetryCount_>0&&(l.audioPlayerRetryCount_--,l.restartAudio())}),u.prev=8,u.next=11,this.audioPlayer_.play();case 11:u.next=18;break;case 13:throw u.prev=13,u.t0=u.catch(8),this.client_&&this.client_.getEnableAutoPlayDialog()&&new Xb,this.emitter_.emit(Sh,u.t0),u.t0;case 18:case"end":return u.stop()}},c,this,[[8,13]])})),function(){return r.apply(this,arguments)})},{key:"playVideo",value:(i=F(M().mark(function c(){var a,s=this;return M().wrap(function(l){for(;;)switch(l.prev=l.next){case 0:if(this.hasVideo()&&(!this.isRemote_||this.isMainVideoSubscribed||this.isAuxVideoSubscribed||this.isSmallVideoSubscribed)){l.next=2;break}return l.abrupt("return");case 2:if(a=this.getVideoTrack(),this.videoPlayer_||!a){l.next=18;break}return U.emit(Fd,{stream:this}),this.log_.info("create VideoPlayer and play"),this.videoPlayer_=new Yb({stream:this,track:a,div:this.div_,muted:this.muted_,objectFit:this.objectFit_,mirror:this.mirror_}),this.videoPlayer_.on(it,function(u){var h={type:q,state:u.state,reason:u.reason};U.emit(uS,te({stream:s},h)),s.emitter_.emit(ib,h)}),l.prev=8,l.next=11,this.videoPlayer_.play();case 11:l.next=18;break;case 13:throw l.prev=13,l.t0=l.catch(8),this.client_&&this.client_.getEnableAutoPlayDialog()&&new Xb,this.emitter_.emit(Sh,l.t0),l.t0;case 18:case"end":return l.stop()}},c,this,[[8,13]])})),function(){return i.apply(this,arguments)})},{key:"stopAudio",value:function(){this.audioPlayer_&&(this.log_.info("stop AudioPlayer"),this.audioPlayer_.stop(),this.audioPlayer_=null)}},{key:"stopVideo",value:function(){this.videoPlayer_&&(this.log_.info("stop VideoPlayer"),this.videoPlayer_.stop(),this.videoPlayer_=null)}},{key:"restartPlayback",value:function(){this.audioPlayer_&&!this.audioPlayer_.isPlaying&&this.restartAudio(),this.videoPlayer_&&!this.videoPlayer_.isPlaying&&this.restartVideo()}},{key:"restartAudio",value:function(){this.isPlaying_&&(this.stopAudio(),this.playAudio().catch(function(c){}))}},{key:"restartVideo",value:function(){this.isPlaying_&&(this.stopVideo(),this.playVideo().catch(function(c){}))}},{key:"stop",value:function(){this.isPlaying_&&(this.isPlaying_=!1,this.stopAudio(),this.stopVideo(),this.div_.parentNode.removeChild(this.div_))}},{key:"resume",value:(n=F(M().mark(function c(){return M().wrap(function(a){for(;;)switch(a.prev=a.next){case 0:if(this.isPlaying_){a.next=2;break}return a.abrupt("return");case 2:if(this.log_.info("resume"),!this.audioPlayer_){a.next=6;break}return a.next=6,this.audioPlayer_.resume();case 6:if(!this.videoPlayer_){a.next=9;break}return a.next=9,this.videoPlayer_.resume();case 9:case"end":return a.stop()}},c,this)})),function(){return n.apply(this,arguments)})},{key:"close",value:function(){this.log_.info("close stream"),this.isPlaying_&&this.stop(),this.isRemote_||(this.mediaStream_&&(this.mediaStream_.preventEvent=1,this.mediaStream_.getTracks().forEach(function(c){c.stop()}),this.mediaStream_=null),this.uninstallEvents())}},{key:"muteAudio",value:function(){return this.addRemoteEvent(!0,K),this.doEnableTrack(K,!1)}},{key:"muteVideo",value:function(){return this.addRemoteEvent(!0,q),this.doEnableTrack(q,!1)}},{key:"unmuteAudio",value:function(){return this.addRemoteEvent(!1,K),this.doEnableTrack(K,!0)}},{key:"unmuteVideo",value:function(){return this.addRemoteEvent(!1,q),this.doEnableTrack(q,!0)}},{key:"addRemoteEvent",value:function(c,a){if(this.isRemote_&&this.client_){var s=this.client_.getUserId(),l="".concat(c?Je:Bt," remote ").concat(a);rt(s,{eventId:a===K?c?HU:GU:c?BU:WU,eventDesc:l,timestamp:new Date().getTime(),userId:s,tinyId:this.client_.getTinyId(),remoteUserId:this.userId_,remoteTinyId:this.connection_.getTinyId()})}}},{key:"doEnableTrack",value:function(c,a){var s=!1;return c===K?this.mediaStream_.getAudioTracks().forEach(function(l){s=!0,l.enabled=a}):this.mediaStream_.getVideoTracks().forEach(function(l){s=!0,l.enabled=a}),s}},{key:"getId",value:function(){return this.id_}},{key:"getUserId",value:function(){return this.userId_}},{key:"getTinyId",value:function(){return this.connection_?this.connection_.getTinyId():""}},{key:"isPlaying",value:function(){return this.isPlaying_}},{key:"setAudioOutput",value:(t=F(M().mark(function c(a){var s;return M().wrap(function(l){for(;;)switch(l.prev=l.next){case 0:if(this.log_.info("setAudioOutput ".concat(a)),this.audioOutputDeviceId_=a,!this.audioPlayer_){l.next=5;break}return l.next=5,this.audioPlayer_.setSinkId(a);case 5:return l.next=7,ub();case 7:s=l.sent,this.log_.info("speakers: ".concat(JSON.stringify(s)));case 9:case"end":return l.stop()}},c,this)})),function(c){return t.apply(this,arguments)})},{key:"setAudioVolume",value:function(c){this.audioVolume_=c,this.log_.info("setAudioVolume to ".concat(c)),this.audioPlayer_&&this.audioPlayer_.setVolume(c)}},{key:"getAudioLevel",value:function(){var c=0;return this.audioPlayer_&&(c=this.audioPlayer_.getAudioLevel()),c}},{key:"getInternalAudioLevel",value:function(){var c=0;return this.audioPlayer_&&(c=this.audioPlayer_.getInternalAudioLevel()),c}},{key:"hasAudio",value:function(){if(this.isRemote_){if(!this.connection_)return!1;var c=this.connection_.getTrackState();return this.type_===Te&&c.audio}return!!this.getAudioTrack()}},{key:"hasVideo",value:function(){if(this.isRemote_){if(!this.connection_)return!1;var c=this.connection_.getTrackState();return this.type_===Ne?c.auxiliary:c.video}return!!this.getVideoTrack()}},{key:"getSubscribedState",value:function(){return this.isRemote_&&this.connection_?this.connection_.getSubscribeState():null}},{key:"getAudioTrack",value:function(){var c=null;if(this.mediaStream_){var a=this.mediaStream_.getAudioTracks();a.length>0&&(c=a[0])}return c}},{key:"getVideoTrack",value:function(){var c=null;if(this.mediaStream_){var a=this.mediaStream_.getVideoTracks();a.length>0&&(c=a[0])}return c}},{key:"getVideoFrame",value:function(){return this.videoPlayer_?this.videoPlayer_.getVideoFrame():null}},{key:"getMediaStream",value:function(){return this.mediaStream_}},{key:"setMediaStream",value:function(c){c!==this.mediaStream_&&(this.mediaStream_&&this.mediaStream_.getTracks().forEach(function(a){return a.stop()}),this.mediaStream_=c)}},{key:"updateVideoPlayingState",value:function(c){if(this.isPlaying_)if(c){if(this.log_.info("playing state updated, play video"),this.videoPlayer_&&this.videoPlayer_.getTrack()!==this.getVideoTrack())return this.log_.warn("audio track changed, restart playback"),this.restartVideo();this.playVideo().catch(function(a){})}else this.log_.info("playing state updated, stop video"),this.stopVideo()}},{key:"updateAudioPlayingState",value:function(c){if(this.isPlaying_)if(c){if(this.log_.info("playing state updated, play audio"),this.audioPlayer_&&this.audioPlayer_.getTrack()!==this.getAudioTrack())return this.log_.warn("audio track changed, restart playback"),this.restartAudio();this.playAudio().catch(function(a){})}else this.log_.info("playing state updated, stop audio"),this.stopAudio()}},{key:"on",value:function(c,a,s){this.emitter_.on(c,a,s)}},{key:"off",value:function(c,a,s){c==="*"?this.emitter_.removeAllListeners():this.emitter_.off(c,a,s)}},{key:"isRemote",value:function(){return this.isRemote_}},{key:"isScreenShare",value:function(){return!this.isRemote_&&this.screen_||this.isRemote_&&this.getType()===ke}},{key:"getDiv",value:function(){return this.div_}},{key:"getObjectFit",value:function(){return this.objectFit_}},{key:"getMuted",value:function(){return this.muted_}},{key:"getClient",value:function(){return this.client_}}]),e}(),ie(Mt.prototype,"play",[W0],Object.getOwnPropertyDescriptor(Mt.prototype,"play"),Mt.prototype),ie(Mt.prototype,"setAudioOutput",[G0],Object.getOwnPropertyDescriptor(Mt.prototype,"setAudioOutput"),Mt.prototype),ie(Mt.prototype,"getVideoFrame",[z0],Object.getOwnPropertyDescriptor(Mt.prototype,"getVideoFrame"),Mt.prototype),Mt),Mp=function(e){ki(n,e);var t=Ti(n);function n(i){var r;ce(this,n);var o={isRemote:!0,type:i.type},c=te(te({},i),o);return(r=t.call(this,c)).name_=Wl,r.isStreamAddedEventEmitted_=!1,r.isAbleToCallSubscription_=!0,r}return ue(n,[{key:"installEvents",value:function(){Re(ve(n.prototype),"installEvents",this).call(this),U.on(nn,this.handleStreamSubscribed,this),U.on(rn,this.handleStreamUnsubscribed,this)}},{key:"uninstallEvents",value:function(){Re(ve(n.prototype),"uninstallEvents",this).call(this),U.off(nn,this.handleStreamSubscribed,this),U.off(rn,this.handleStreamUnsubscribed,this)}},{key:"handleStreamSubscribed",value:function(i){i.client===this.client_&&i.stream===this&&this.connection_.getCurrentState()===Ye&&this.emitConnectionStateChanged({prevState:Xe,state:Ye})}},{key:"handleStreamUnsubscribed",value:function(i){i.client===this.client_&&i.stream===this&&this.emitConnectionStateChanged({prevState:Ye,state:Xe})}},{key:"getType",value:function(){return Re(ve(n.prototype),"getType",this).call(this)}},{key:"getIsAbleToCallSubscription",value:function(){return this.isAbleToCallSubscription_}},{key:"setIsAbleToCallSubscription",value:function(i){this.isAbleToCallSubscription_=i}},{key:"setIsStreamAddedEventEmitted",value:function(i){this.isStreamAddedEventEmitted_=i}},{key:"getIsStreamAddedEventEmitted",value:function(){return this.isStreamAddedEventEmitted_}},{key:"getAudioTrack",value:function(){return this.connection_&&this.connection_.getTrackState().audio?Re(ve(n.prototype),"getAudioTrack",this).call(this):null}},{key:"getVideoTrack",value:function(){if(!this.connection_)return null;var i=this.connection_.getTrackState();return(this.type_!==Te||i.video)&&(this.type_!==Ne||i.auxiliary)?Re(ve(n.prototype),"getVideoTrack",this).call(this):null}},{key:"close",value:function(){Re(ve(n.prototype),"close",this).call(this)}}]),n}(J0),d8=function(){function e(r){ce(this,e),this.client_=r.client,this.subscribedStreams_=new Map,this.unsubscribedStreams_=new Map,this.subscriptedOptions_=new Map,this.autoRecoveryFlags_=new Map}var t,n,i;return ue(e,[{key:"isEnabled",get:function(){return this.client_.getEnv()!=="webrtc"}},{key:"recover",value:(i=F(M().mark(function r(o){var c,a,s;return M().wrap(function(l){for(;;)switch(l.prev=l.next){case 0:if(c=o.getUserId(),a=o.getType(),this.hasAutoRecoveryFlag(c,a)){l.next=5;break}return l.abrupt("return");case 5:if(s=this.getUnsubscribedStream(c,a)?"unsubscribe":"subscribe",l.prev=6,z.warn("recover() try to recover subscription [".concat(s,"][").concat(c,"][").concat(a,"]")),s!=="subscribe"){l.next=13;break}return l.next=11,this.recoverSubscription(c,o);case 11:l.next=15;break;case 13:return l.next=15,this.recoverUnsubscription(c,o);case 15:J.logSuccessEvent({userId:this.client_.getUserId(),eventType:Yg}),z.warn("recover() recover successfully [".concat(s,"][").concat(c,"][").concat(a,"]")),l.next=23;break;case 19:l.prev=19,l.t0=l.catch(6),z.error("recover() recover failed [".concat(s,"][").concat(c,"][").concat(a,"]"),l.t0),J.logFailedEvent({userId:this.client_.getUserId(),eventType:Yg,error:l.t0});case 23:this.deleteAutoRecoveryFlag(c,a);case 24:case"end":return l.stop()}},r,this,[[6,19]])})),function(r){return i.apply(this,arguments)})},{key:"recoverSubscription",value:(n=F(M().mark(function r(o,c){var a,s,l,u,h;return M().wrap(function(g){for(;;)switch(g.prev=g.next){case 0:if(a=this.getOptions(o,c.getType()),s=this.getSubscribedStream(o,c.getType()),a&&s){g.next=4;break}return g.abrupt("return");case 4:l=this.getStreamMuteState(s),u=l.isAudioMuted,h=l.isVideoMuted,this.mergeStream(s,c),this.recoverPlayingState(s),u&&s.doEnableTrack(K,!1),h&&s.doEnableTrack(q,!1);case 9:case"end":return g.stop()}},r,this)})),function(r,o){return n.apply(this,arguments)})},{key:"recoverUnsubscription",value:(t=F(M().mark(function r(o,c){var a;return M().wrap(function(s){for(;;)switch(s.prev=s.next){case 0:if(a=this.getUnsubscribedStream(o,c.getType())){s.next=3;break}return s.abrupt("return");case 3:this.mergeStream(a,c);case 4:case"end":return s.stop()}},r,this)})),function(r,o){return t.apply(this,arguments)})},{key:"getStreamMuteState",value:function(r){var o={isAudioMuted:!1,isVideoMuted:!1},c=r.getMediaStream();return c&&(o.isAudioMuted=c.getAudioTracks().map(function(a){return a.enabled}).includes(!1),o.isVideoMuted=c.getVideoTracks().map(function(a){return a.enabled}).includes(!1)),o}},{key:"recoverPlayingState",value:function(r){var o=r.isPlaying(),c=r.getDiv();if(o&&c){var a=c.parentNode;r.stop(),r.play(a,{objectFit:r.getObjectFit(),muted:r.getMuted()})}}},{key:"mergeStream",value:function(r,o){var c=o.getConnection(),a=o.getMediaStream();r.setConnection(c),c.setRemoteStream(a.id,r),r.setMediaStream(a),r.updateAudioPlayingState(o.hasAudio()),r.updateVideoPlayingState(o.hasVideo())}},{key:"addSubscriptionRecord",value:function(r,o,c){var a=o.getType();if(this.subscribedStreams_.has(r))this.subscribedStreams_.get(r).set(a,o);else{var s=new Map;s.set(o.getType(),o),this.subscribedStreams_.set(r,s)}if(this.subscriptedOptions_.has(r))this.subscriptedOptions_.get(r).set(a,c);else{var l=new Map;l.set(o.getType(),c),this.subscriptedOptions_.set(r,l)}this.deleteUnsubscriptionRecord(r,a)}},{key:"addUnsubscriptionRecord",value:function(r,o){if(this.unsubscribedStreams_.has(r))this.unsubscribedStreams_.get(r).set(o.getType(),o);else{var c=new Map;c.set(o.getType(),o),this.unsubscribedStreams_.set(r,c)}this.deleteSubscriptionRecord(r,o.getType())}},{key:"getSubscribedStream",value:function(r,o){return this.subscribedStreams_.has(r)&&this.subscribedStreams_.get(r).has(o)?this.subscribedStreams_.get(r).get(o):null}},{key:"getOptions",value:function(r,o){return this.subscriptedOptions_.has(r)&&this.subscriptedOptions_.get(r).has(o)?this.subscriptedOptions_.get(r).get(o):null}},{key:"getUnsubscribedStream",value:function(r,o){return this.unsubscribedStreams_.has(r)&&this.unsubscribedStreams_.get(r).has(o)?this.unsubscribedStreams_.get(r).get(o):null}},{key:"deleteSubscriptionRecord",value:function(r,o){this.subscribedStreams_.has(r)&&this.subscribedStreams_.get(r).delete(o),this.subscriptedOptions_.has(r)&&this.subscriptedOptions_.get(r).delete(o)}},{key:"deleteUnsubscriptionRecord",value:function(r,o){this.unsubscribedStreams_.has(r)&&this.unsubscribedStreams_.get(r).delete(o)}},{key:"markAllStream",value:function(){for(var r=0,o=Se(this.subscribedStreams_.entries());r<o.length;r++)for(var c=lt(o[r],2),a=c[0],s=0,l=Se(c[1].entries());s<l.length;s++){var u=lt(l[s],1)[0];this.setAutoRecoveryFlag(a,u)}for(var h=0,g=Se(this.unsubscribedStreams_.entries());h<g.length;h++)for(var b=lt(g[h],2),T=b[0],k=0,p=Se(b[1].entries());k<p.length;k++){var S=lt(p[k],1)[0];this.setAutoRecoveryFlag(T,S)}}},{key:"setAutoRecoveryFlag",value:function(r,o){if(z.info("setAutoRecoveryFlag() mark [".concat(r,"][").concat(o,"]")),this.autoRecoveryFlags_.has(r))this.autoRecoveryFlags_.get(r).set(o);else{var c=new Map;c.set(o),this.autoRecoveryFlags_.set(r,c)}}},{key:"hasAutoRecoveryFlag",value:function(r,o){return!!this.isEnabled&&this.autoRecoveryFlags_.has(r)&&this.autoRecoveryFlags_.get(r).has(o)}},{key:"deleteAutoRecoveryFlag",value:function(r,o){this.autoRecoveryFlags_.has(r)&&this.autoRecoveryFlags_.get(r).delete(o)}},{key:"delete",value:function(r){this.unsubscribedStreams_.delete(r),this.subscribedStreams_.delete(r),this.subscriptedOptions_.delete(r),this.autoRecoveryFlags_.delete(r)}}]),e}(),h8=function(){function e(t){ce(this,e),this.player_=t,this.canvas_=document.createElement(Eg),this.canvasCtx_=this.canvas_.getContext("2d")}return ue(e,[{key:"setCanvasRect",value:function(t,n){this.canvas_.width=t,this.canvas_.height=n}},{key:"drawVideoToCanvas",value:function(){var t=this.player_.getElement(),n=t.videoHeight,i=t.videoWidth,r=i*this.canvas_.height/(n*this.canvas_.width);if(r>1.05||r<.95){var o=i*n/(this.canvas_.width*this.canvas_.height);this.setCanvasRect(i/Math.sqrt(o),n/Math.sqrt(o))}this.canvasCtx_.drawImage(t,0,0,this.canvas_.width,this.canvas_.height)}},{key:"generateVideoTrackFromCanvasCapture",value:function(t){return this.canvas_.captureStream(t).getVideoTracks()[0]}},{key:"generateStreamFromTrack",value:function(t){var n=new MediaStream;return n.addTrack(t),n}},{key:"destroy",value:function(){this.player_.stop(),this.canvas_.width=0,this.canvas_.height=0,this.canvas_=null,this.canvasCtx_=null}},{key:"canvas",get:function(){return this.canvas_}},{key:"canvasCtx",get:function(){return this.canvasCtx_}},{key:"canDrawVideoToCanvas",get:function(){if(this.player_){var t=this.player_.getElement();if(t)return t.readyState===t.HAVE_ENOUGH_DATA}return!1}}]),e}(),p8=new Blob(['let t,e,a,i;onmessage=function(n){const{action:h,data:s}=n.data;switch(h){case"render":a=s.canvas,t=a.width,e=a.height,i=a.getContext("2d"),function(t,e){const n=new TransformStream({async transform(t,e){const n=t.displayWidth,h=t.displayHeight,s=n*a.height/(h*a.width);if(s>1.05||s<.95){const t=n*h/(a.width*a.height);a.width=n/Math.sqrt(t),a.height=h/Math.sqrt(t)}i.drawImage(t,0,0,a.width,a.height);const o=new VideoFrame(a,{timestamp:t.timestamp});t.close(),e.enqueue(o)}});t.pipeThrough(n).pipeTo(e)}(s.readable,s.writable)}}'],{type:"application/javascript"}),f8=function(){function e(t){ce(this,e);var n=t.videoTrack;this.width=void 0,this.height=void 0,this.canvas=document.createElement("canvas"),this.offscreen=null,this.smallGenerator=new MediaStreamTrackGenerator({kind:"video"}),this.smallWritable=this.smallGenerator.writable,this.bigProcessor=new MediaStreamTrackProcessor({track:n}),this.bigReadable=this.bigProcessor.readable,this.initWorker()}return ue(e,[{key:"initWorker",value:function(){try{this.worker=new Worker(URL.createObjectURL(p8)),z.info("init worker processor success")}catch(t){z.warn("init worker processor failed. ".concat(t.error))}}},{key:"setCanvasRect",value:function(t,n){this.width=t,this.height=n,this.canvas.width=t,this.canvas.height=n,this.offscreen=this.canvas.transferControlToOffscreen(),this.worker.postMessage({action:"render",data:{canvas:this.offscreen,readable:this.bigReadable,writable:this.smallWritable}},[this.offscreen,this.bigReadable,this.smallWritable])}},{key:"generatorVideoTrack",value:function(){var t=new MediaStream([this.smallGenerator]);return t==null?void 0:t.getTracks()[0]}},{key:"destroy",value:function(){this.worker.terminate()}}]),e}(),Xs=function(){function e(n){ce(this,e),this.localStream_=n,this.player_=null,this.processor_=null,this.initOffscreenSuccess_=!1}var t;return ue(e,[{key:"initialize",value:(t=F(M().mark(function n(){var i;return M().wrap(function(r){for(;;)switch(r.prev=r.next){case 0:if(!(GV()&&((i=navigator)===null||i===void 0?void 0:i.hardwareConcurrency)>=6)){r.next=13;break}return r.prev=1,r.next=4,this.initOffscreen();case 4:this.initOffscreenSuccess_=!0,z.info("Initialize VideoGenerator successfully!"),r.next=11;break;case 8:r.prev=8,r.t0=r.catch(1),this.initCanvas();case 11:r.next=14;break;case 13:this.initCanvas();case 14:case"end":return r.stop()}},n,this,[[1,8]])})),function(){return t.apply(this,arguments)})},{key:"generateSmallVideoTrack",value:function(n){var i,r=n.height,o=n.width,c=n.frameRate,a=this.getSmallVideoProfile(o,r);return this.initOffscreenSuccess_?(this.processor_.setCanvasRect(a.width,a.height),i=this.processor_.generatorVideoTrack()):(this.processor_.setCanvasRect(a.width,a.height),this.player_.setRect({width:a.width,height:a.height}),i=this.processor_.generateVideoTrackFromCanvasCapture(c),this.interval_=ye.run(Xo,this.render.bind(this),{fps:c})),i}},{key:"render",value:function(){this.processor_.canDrawVideoToCanvas&&this.processor_.drawVideoToCanvas()}},{key:"destroy",value:function(){ye.clearTask(this.interval_),this.processor_&&this.processor_.destroy()}},{key:"initOffscreen",value:function(){this.processor_=new f8({videoTrack:this.localStream_.getVideoTrack()})}},{key:"initCanvas",value:function(){this.player_=new Yb({stream:this.localStream_,track:this.localStream_.getVideoTrack(),muted:!0,objectFit:"cover",mirror:!1}),this.player_.play().then(function(){z.info("VideoGenerator: play local video success")}).catch(function(){z.error("VideoGenerator: Failed to play local video")}),this.processor_=new h8(this.player_)}},{key:"getSmallVideoProfile",value:function(n,i){var r,o=this.localStream_.getVideoTrack(),c=te({},this.localStream_.getVideoProfile());if(lr){var a=o.getSettings();a&&a.width&&a.height&&(c.width=a.width,c.height=a.height)}var s=c.width*c.height,l=n*i;return z.info("big stream resolution: ".concat(c.width,"*").concat(c.height," small stream resolution: ").concat(n,"*").concat(i," ")),r=s>l?s/l:s/19200,{width:parseInt(c.width/Math.sqrt(r)),height:parseInt(c.height/Math.sqrt(r))}}}]),e}(),Ys=new Map,m8=function(){var e=F(M().mark(function t(n){var i,r,o,c,a,s,l;return M().wrap(function(u){for(;;)switch(u.prev=u.next){case 0:if(!vs()){u.next=2;break}return u.abrupt("return");case 2:return u.next=4,_8(n);case 4:if(i=u.sent,z.info("getUserMedia with constraints: "+JSON.stringify(i)),!i.audio){u.next=11;break}return u.next=9,Ce.getMicrophones();case 9:r=u.sent,z.info("microphones: ".concat($r(r,["deviceId","label"])));case 11:if(!i.video){u.next=16;break}return u.next=14,Ce.getCameras();case 14:o=u.sent,z.info("cameras: ".concat($r(o,["deviceId","label"])));case 16:return u.prev=16,u.next=19,navigator.mediaDevices.getUserMedia(i);case 19:return u.abrupt("return",u.sent);case 22:if(u.prev=22,u.t0=u.catch(16),u.t0.name!=="NotFoundError"){u.next=29;break}if(!o||o.length!==0){u.next=27;break}throw new j({code:V.DEVICE_NOT_FOUND,message:H({key:DL})});case 27:if(!r||r.length!==0){u.next=29;break}throw new j({code:V.DEVICE_NOT_FOUND,message:H({key:PL})});case 29:throw i.audio&&((c=r)===null||c===void 0?void 0:c.length)>0&&(s=r.find(function(h){return h.deviceId===n.microphoneId}))&&s.getCapabilities&&z.warn($r(s.getCapabilities(),ql)),i.video&&((a=o)===null||a===void 0?void 0:a.length)>0&&(l=o.find(function(h){return h.deviceId===n.cameraId}))&&l.getCapabilities&&z.warn($r(l.getCapabilities(),ql)),new j({code:V.INITIALIZE_FAILED,name:u.t0.name,message:u.t0.message,constraint:u.t0.constraint});case 32:case"end":return u.stop()}},t,null,[[16,22]])}));return function(t){return e.apply(this,arguments)}}(),Np=fa({retryFunction:m8,settings:{retries:3,timeout:500},onError:function(e,t,n,i,r){var o=r+1;z.warn("getUserMedia error: ".concat(e)),e.name==="NotReadableError"||e.name==="OverconstrainedError"?(o===1&&i[0].video?(i[0].maxResoution=!1,i[0].frameRate=i[0].frameRate>10?10:5):o===2?i[0].useDeviceIdOnly=!0:o!==3||i[0].useExact&&!i[0].retryWhenExactFailed||(i[0].useTrueAsConstraint=!0),e.message.includes("deviceId")&&i[0].retryWhenExactFailed&&(i[0].useExact=!1),t()):n(e)},onRetrying:function(e){z.warn("getUserMedia retrying [".concat(e,"/3]"))},onRetryFailed:function(){J.uploadEvent({log:"stat-getUserMedia-retry-failed"})},onRetrySuccess:function(e){J.uploadEvent({log:"stat-getUserMedia-retry-success-"+e})}});function _8(e){return{audio:v8(e),video:g8(e)}}function v8(e){if(!e.audio)return!1;if(e.useTrueAsConstraint)return!0;var t={};return!on(e.microphoneId)&&(t.deviceId=e.useExact?{exact:e.microphoneId}:e.microphoneId,e.useDeviceIdOnly)?t:(t.echoCancellation=!0,t.noiseSuppression=!0,t.autoGainControl=!0,t.sampleRate=e.sampleRate,Rt(e.channelCount)&&e.channelCount>1&&(t.channelCount=e.channelCount),Ct(e.echoCancellation)&&!e.echoCancellation&&(t.echoCancellation=!1),Ct(e.noiseSuppression)&&!e.noiseSuppression&&(t.noiseSuppression=!1),Ct(e.autoGainControl)&&!e.autoGainControl&&(t.autoGainControl=!1),!!on(t)||t)}function g8(e){if(!e.video)return!1;if(e.useTrueAsConstraint)return!0;var t=e.maxResoution,n=t===void 0||t,i={};return e.facingMode?i.facingMode=e.facingMode:e.cameraId&&(i.deviceId=e.useExact?{exact:e.cameraId}:e.cameraId),e.useDeviceIdOnly&&!on(i)?i:(e.width&&(i.width={ideal:e.width},n&&!ft&&(i.width.max=e.width)),e.height&&(i.height={ideal:e.height},n&&!ft&&(i.height.max=e.height)),ft&&la&&e.width&&e.height&&e.width*e.height<101376&&(i.width=e.width,i.height=e.height),e.frameRate&&(i.frameRate=e.frameRate),!!on(i)||i)}var y8=function(){var e=F(M().mark(function t(n){var i,r,o,c,a,s,l,u,h;return M().wrap(function(g){for(;;)switch(g.prev=g.next){case 0:if(!vs()){g.next=2;break}return g.abrupt("return");case 2:if(i=null,!(rs&&fd<74||nr)){g.next=27;break}return r=Lp(n),z.info("getDisplayMedia with constraints: "+JSON.stringify(r)),g.next=8,navigator.mediaDevices.getDisplayMedia(r);case 8:if(o=g.sent,!n.screenAudio){g.next=14;break}return z.warn("Your browser not support capture system audio"),g.abrupt("return",o);case 14:if(!n.audio){g.next=24;break}return c=q0(n),z.info("getUserMedia with constraints: "+JSON.stringify(c)),g.next=19,navigator.mediaDevices.getUserMedia(c);case 19:return i=g.sent,o.addTrack(i.getAudioTracks()[0]),g.abrupt("return",o);case 24:return g.abrupt("return",o);case 25:g.next=53;break;case 27:if(!n.screenAudio){g.next=37;break}return n.audioConstraints={echoCancellation:n.echoCancellation,autoGainControl:n.autoGainControl,noiseSuppression:n.noiseSuppression,sampleRate:44100},a=Lp(n),z.info("getDisplayMedia with constraints: "+JSON.stringify(a)),g.next=33,navigator.mediaDevices.getDisplayMedia(a);case 33:return s=g.sent,g.abrupt("return",s);case 37:return l=Lp(n),z.info("getDisplayMedia with constraints: "+JSON.stringify(l)),g.next=41,navigator.mediaDevices.getDisplayMedia(l);case 41:if(u=g.sent,!n.audio){g.next=52;break}return h=q0(n),z.info("getUserMedia with constraints: "+JSON.stringify(h)),g.next=47,navigator.mediaDevices.getUserMedia(h);case 47:return i=g.sent,u.addTrack(i.getAudioTracks()[0]),g.abrupt("return",u);case 52:return g.abrupt("return",u);case 53:case"end":return g.stop()}},t)}));return function(t){return e.apply(this,arguments)}}();function q0(e){var t={echoCancellation:e.echoCancellation,autoGainControl:e.autoGainControl,noiseSuppression:e.noiseSuppression,sampleRate:e.sampleRate,channelCount:e.channelCount};return G(e.microphoneId)||(t.deviceId=e.microphoneId),{audio:t,video:!1}}function Lp(e){var t={systemAudio:"include",selfBrowserSurface:"include",surfaceSwitching:"include"},n={width:nr?{max:e.width}:{ideal:e.width,max:e.width},height:nr?{max:e.height}:{ideal:e.height,max:e.height},frameRate:e.frameRate,displaySurface:"monitor"};return t.video=n,G(e.audioConstraints)||(t.audio=e.audioConstraints),t}var K0,Q0,X0,Y0,$0,Z0,eI,tI,nI,rI,iI,he,aI,Na,Up=new Map([["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}]]),Vp=new Map([["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}]]),oI=new Map([["standard",{sampleRate:48e3,channelCount:1,bitrate:40}],["standard-stereo",{sampleRate:48e3,channelCount:2,bitrate:64}],["high",{sampleRate:48e3,channelCount:1,bitrate:128}],["high-stereo",{sampleRate:48e3,channelCount:2,bitrate:192}]]),yr=new Map,S8=(K0=Ee(wn),Q0=Ee(wn),X0=Ee(wn),Y0=Ee(wn),$0=nt.apply(void 0,Se(We.LOCAL_STREAM.switchDevice)),Z0=nt(We.STREAM.addTrack),eI=nt(We.STREAM.removeTrack),tI=nt(We.STREAM.replaceTrack),nI=yi({retries:10,timeout:3e3,onRetryFailed:function(e){J.logFailedEvent({userId:this.client_?this.client_.getUserId():this.userId_,eventType:Xg,error:e}),this.emitter_.emit(Sh,new j({code:V.DEVICE_AUTO_RECOVER_FAILED,message:e.message}))}}),rI=Qs(We.LOCAL_STREAM.setAudioCaptureVolume),iI=Ee(wn),he=function(e){ki(k,e);var t,n,i,r,o,c,a,s,l,u,h,g,b,T=Ti(k);function k(p){var S;ce(this,k);var f=te(te({},p),{isRemote:!1,type:"local"});return(S=T.call(this,f)).name_=wn,S.client_=null,S.video_=p.video,S.audio_=p.audio,S.cameraId_=p.cameraId,S.cameraGroupId_="",S.facingMode_=p.facingMode,S.microphoneId_=p.microphoneId,S.microphoneGroupId_="",S.microphoneLabel_="",S.videoSource_=p.videoSource,S.audioSource_=p.audioSource,S.screen_=p.screen,S.screenAudio_=p.screenAudio,S.audioProfile_={echoCancellation:!0,autoGainControl:!0,noiseSuppression:!0,sampleRate:48e3,channelCount:1,bitrate:40},S.screenAudio_&&(S.audioProfile_.echoCancellation=!0,S.audioProfile_.autoGainControl=!1,S.audioProfile_.noiseSuppression=!1),Ct(p.echoCancellation)&&(S.audioProfile_.echoCancellation=p.echoCancellation),Ct(p.autoGainControl)&&(S.audioProfile_.autoGainControl=p.autoGainControl),Ct(p.noiseSuppression)&&(S.audioProfile_.noiseSuppression=p.noiseSuppression),S.videoProfile_=Up.get("480p_2"),S.screenProfile_=Vp.get("1080p"),S.videoSetting_=null,S.muteState_={video:!1,audio:!1,auxVideo:!1},S.beautyStatus_=!1,S.prevAudioRecoverTime_=0,S.prevVideoRecoverTime_=0,S.isAudioRecovering_=!1,S.isVideoRecovering_=!1,S.initState(),S.canvas_=null,S.canvasInterval_=null,S.canvasTrack_=null,S.gain_={audioTrack:null,source:null,gainNode:null},S.captureVolume_=100,S.enableAutoRecoverCapture_=!!G(p.enableAutoRecoverCapture)||p.enableAutoRecoverCapture,S.enableAutoRecoverOther_=!Ct(p.enableAutoRecoverOther)||p.enableAutoRecoverOther,S.log_.info("stream created: ".concat(S.id_," autoRecover: ").concat(S.enableAutoRecoverCapture_)),S.isAIDenoiser=!1,S}return ue(k,[{key:"scaleResolutionDownBy",get:function(){var p=this.getVideoTrack();if(!p||!lr||this.isScreenShare())return 1;var S,f,I,A=p.getSettings();return A.width===this.videoProfile_.width&&A.height===this.videoProfile_.height?1:(S=window.screen)!==null&&S!==void 0&&(f=S.orientation)!==null&&f!==void 0&&(I=f.type)!==null&&I!==void 0&&I.includes("portrait")&&this.videoProfile_.width>this.videoProfile_.height&&A.height>A.width?Math.max(A.width/this.videoProfile_.height,A.height/this.videoProfile_.width,1):Math.max(A.width/this.videoProfile_.width,A.height/this.videoProfile_.height,1)}},{key:"initState",value:function(){this.isAddingTrack_=!1,this.isRemovingTrack_=!1,this.setIsReadyToPublish(!1),this.setPublishState(ay)}},{key:"installEvents",value:function(){Re(ve(k.prototype),"installEvents",this).call(this),U.on(Bd,this.onVideoTrackStopped,this),U.on(ha,this.onVideoTrackStopped,this),U.on(Wd,this.onAudioTrackStopped,this),U.on(Hd,this.onAudioTrackStopped,this)}},{key:"uninstallEvents",value:function(){Re(ve(k.prototype),"uninstallEvents",this).call(this),U.off(Bd,this.onVideoTrackStopped,this),U.off(ha,this.onVideoTrackStopped,this),U.off(Wd,this.onAudioTrackStopped,this),U.off(Hd,this.onAudioTrackStopped,this)}},{key:"initialize",value:function(){var p=this;return new Promise(function(S,f){if(gs())f(new j({code:V.INVALID_OPERATION,message:H({key:Ay})}));else{if(G(p.audio_)){var I=new MediaStream;return G(p.audioSource_)||(I.addTrack(p.audioSource_),p.updateAudioPlayingState(!0)),G(p.videoSource_)||(I.addTrack(p.videoSource_),p.updateVideoPlayingState(!0)),p.setMediaStream(I),J.logSuccessEvent({userId:p.client_?p.client_.getUserId():p.userId_,eventType:oa,kind:"custom"}),p.setIsReadyToPublish(!0),S()}p.screen_?(p.log_.info("initialize stream audio: "+p.audio_+" screenAudio: "+p.screenAudio_+" screen: "+p.screen_),y8({audio:p.audio_,screenAudio:p.screenAudio_,microphoneId:p.microphoneId_,width:p.screenProfile_.width,height:p.screenProfile_.height,frameRate:p.screenProfile_.frameRate,sampleRate:p.audioProfile_.sampleRate,channelCount:p.audioProfile_.channelCount,autoGainControl:p.audioProfile_.autoGainControl,noiseSuppression:p.audioProfile_.noiseSuppression,echoCancellation:p.audioProfile_.echoCancellation}).then(function(A){p.setMediaStream(A),p.updateAudioPlayingState(p.audio_||p.screenAudio_),p.updateVideoPlayingState(!0);var x=p.getVideoTrack();return x.applyConstraints&&x.applyConstraints({frameRate:{min:p.screenProfile_.frameRate,ideal:p.screenProfile_.frameRate},width:p.screenProfile_.width,height:p.screenProfile_.height}).catch(function(D){p.warn("screen applyConstraints failed: ".concat(D))}),p.listenForScreenSharingStopped(x),p.setVideoContentHint(Ag),p.updateDeviceIdInUse(),p.setIsReadyToPublish(!0),p.log_.info(JSON.stringify(x.getSettings())),J.logSuccessEvent({userId:p.client_?p.client_.getUserId():p.userId_,eventType:oa,kind:"getDisplayMedia"}),S()}).catch(function(A){J.logFailedEvent({userId:p.client_?p.client_.getUserId():p.userId_,eventType:oa,kind:"getDisplayMedia",error:A}),p.log_.error("getDisplayMedia error observed "+A),f(A instanceof j?A:new j({code:V.INITIALIZE_FAILED,name:A.name,message:A.message}))})):(U.emit(Md,{stream:p,audio:p.audio_,video:p.video_}),p.log_.info("initialize stream audio: "+p.audio_+" video: "+p.video_),Np({audio:p.audio_,video:p.video_,facingMode:p.facingMode_,cameraId:p.cameraId_,microphoneId:p.microphoneId_,width:p.videoProfile_.width,height:p.videoProfile_.height,frameRate:p.videoProfile_.frameRate,sampleRate:p.audioProfile_.sampleRate,channelCount:p.audioProfile_.channelCount,autoGainControl:p.audioProfile_.autoGainControl,noiseSuppression:p.audioProfile_.noiseSuppression,echoCancellation:p.audioProfile_.echoCancellation,useExact:!0,retryWhenExactFailed:!0}).then(function(A){return U.emit(Nd,{stream:p,audio:p.audio_,video:p.video_}),p.setMediaStream(A),A.getTracks().forEach(function(x){if(lr){var D=x.getSettings();p.log_.debug("".concat(x.kind," settings: ").concat(JSON.stringify(D))),x.kind===q&&(p.videoSetting_=D)}WV&&p.log_.info("".concat(x.kind," capabilities: ").concat($r(x.getCapabilities(),ql)))}),p.updateAudioPlayingState(p.audio_),p.updateVideoPlayingState(p.video_),p.updateDeviceIdInUse(),p.log_.info("gotStream hasAudio: "+p.hasAudio()+" hasVideo: "+p.hasVideo()),p.setIsReadyToPublish(!0),J.logSuccessEvent({userId:p.client_?p.client_.getUserId():p.userId_,eventType:oa,kind:"getUserMedia"}),S()}).catch(function(A){U.emit(Ld,{stream:p,audio:p.audio_,video:p.video_,error:A}),J.logFailedEvent({userId:p.client_?p.client_.getUserId():p.userId_,eventType:oa,kind:"getUserMedia",error:A}),p.log_.error("getUserMedia error observed "+A),f(A)}))}})}},{key:"listenForScreenSharingStopped",value:function(p){var S=this;p.addEventListener("ended",function(f){S.log_.info("screen sharing was stopped because the video track is ended"),S.emitter_.emit(zV)})}},{key:"muteAudio",value:function(){var p=Re(ve(k.prototype),"muteAudio",this).call(this);return p&&(this.log_.info("localStream mute audio"),this.sendMutedFlag(K,!0)),p}},{key:"muteVideo",value:function(){var p=Re(ve(k.prototype),"muteVideo",this).call(this);return p&&(this.log_.info("localStream mute video"),this.sendMutedFlag(q,!0)),p}},{key:"unmuteAudio",value:function(){var p=Re(ve(k.prototype),"unmuteAudio",this).call(this);return p&&(this.log_.info("localStream unmute audio"),this.sendMutedFlag(K,!1)),p}},{key:"unmuteVideo",value:function(){var p=Re(ve(k.prototype),"unmuteVideo",this).call(this);return p&&(this.log_.info("localStream unmute video"),this.sendMutedFlag(q,!1)),p}},{key:"sendMutedFlag",value:function(p,S){this.setMuteState(p,S);var f=this.getConnection();if(f){f.sendMutedFlag(this.muteState_,this);var I=f.getUserId(),A=f.getTinyId(),x="".concat(S?Je:Bt," local ").concat(p," track");rt(I,{eventId:p===K?S?DU:MU:S?OU:NU,eventDesc:x,timestamp:Qe(),userId:I,tinyId:A})}}},{key:"setMuteState",value:function(p,S){this.muteState_[p]=S,this.log_.info("set ".concat(p," muted state: [").concat(S?"mute":"unmute","]"))}},{key:"setAudioProfile",value:(b=F(M().mark(function p(S){var f,I,A;return M().wrap(function(x){for(;;)switch(x.prev=x.next){case 0:if(bi(S)==="object"?f=S:(f=oI.get(S))===void 0&&(f=oI.get("standard")),this.log_.info("setAudioProfile: "+JSON.stringify(f)),!(I=this.getAudioTrack())){x.next=6;break}return x.next=6,I.applyConstraints(f);case 6:if(A=this.audioProfile_.bitrate!==f.bitrate,this.audioProfile_=te(te({},this.audioProfile_),f),!A||!this.connection_){x.next=12;break}return x.next=11,this.connection_.setBandwidth({bandwidth:this.audioProfile_.bitrate,type:K});case 11:this.connection_.sendMediaSettings(this);case 12:case"end":return x.stop()}},p,this)})),function(p){return b.apply(this,arguments)})},{key:"setVideoProfile",value:(g=F(M().mark(function p(S){var f,I,A,x;return M().wrap(function(D){for(;;)switch(D.prev=D.next){case 0:if(!this.connection_||tb()){D.next=2;break}throw new j({code:V.NOT_SUPPORTED,message:H({key:RL})});case 2:if(An(S)?I=te(te({},this.videoProfile_),S):je(S)&&(I=Up.get(S),G(I)&&(I=Up.get("480p_2"))),(f=this.client_)!==null&&f!==void 0&&f.get2k4kFlag()&&(this.client_.get2k4kFlag()!==1&&!this.screen_&&I.height*I.width>=3686400?(I.width=1920,I.height=1080,this.log_.warn(vy)):jn.handleFunctionState({fnName:"2K_4K"})),I&&I.width*I.height>921600&&f3&&(I.width=1280,I.height=720,this.log_.warn("reset to 1280 * 720 on iOS 13~14")),this.log_.info("setVideoProfile "+JSON.stringify(I)),!(A=this.getVideoTrack())){D.next=10;break}return D.next=10,A.applyConstraints(I);case 10:if(x=this.videoProfile_.bitrate!==I.bitrate,this.videoProfile_=I,!x||!this.connection_){D.next=16;break}return D.next=15,this.connection_.setBandwidth({bandwidth:I.bitrate,type:q,videoType:Fo});case 15:this.connection_.sendMediaSettings(this);case 16:case"end":return D.stop()}},p,this)})),function(p){return g.apply(this,arguments)})},{key:"getVideoBitrate",value:function(){return this.screen_?this.screenProfile_.bitrate:this.videoProfile_.bitrate}},{key:"getAudioBitrate",value:function(){return this.audioProfile_.bitrate}},{key:"setScreenProfile",value:function(p){var S=p;je(p)&&(S=Vp.get(p)||Vp.get("1080p")),this.log_.info("setScreenProfile "+JSON.stringify(p)),this.screenProfile_=S}},{key:"getVideoProfile",value:function(){return this.screen_?this.screenProfile_:this.videoProfile_}},{key:"getAudioProfile",value:function(){return this.audioProfile_}},{key:"setVideoContentHint",value:function(p){var S=this.getVideoTrack();S&&"contentHint"in S&&(this.log_.info("set video track contentHint to: "+p),S.contentHint=p,S.contentHint!==p&&this.log_.warn("Invalid video track contentHint: "+p))}},{key:"switchDevice",value:(h=F(M().mark(function p(S,f){var I,A,x,D,m,v,w,R,P,y,d,_,E,C,O,L,N,W;return M().wrap(function(B){for(;;)switch(B.prev=B.next){case 0:if(this.mediaStream_&&this.cameraId_!==f&&this.facingMode_!==f){B.next=2;break}return B.abrupt("return");case 2:if(A=S===q,!(I=S===K)||f!==this.microphoneId_){B.next=11;break}if(f===Ko){B.next=7;break}return B.abrupt("return");case 7:return B.next=9,ZV(this.microphoneGroupId_,this.microphoneLabel_);case 9:if(!B.sent){B.next=11;break}return B.abrupt("return");case 11:return this.setIsReadyToPublish(!1),this.log_.info("switchDevice "+S+" to: "+f),I&&(x=this.getAudioTrack(),D=this.getMicrophoneTrackMixed(),x&&x.stop(),D&&D.stop()),A&&((m=this.getVideoTrack())&&m.stop(),hd&&(v=this.getAudioTrack())&&(this.log_.info("stop audio track first in huawei env"),v.stop())),B.prev=15,B.next=18,Np({audio:I||hd,video:A,facingMode:f===Rg||f===Cg?f:void 0,cameraId:A?f:this.cameraId_,microphoneId:I?f:this.microphoneId_,width:this.videoProfile_.width,height:this.videoProfile_.height,frameRate:this.videoProfile_.frameRate,sampleRate:this.audioProfile_.sampleRate,channelCount:this.audioProfile_.channelCount,autoGainControl:this.audioProfile_.autoGainControl,noiseSuppression:this.audioProfile_.noiseSuppression,echoCancellation:this.audioProfile_.echoCancellation,useExact:!0,retryWhenExactFailed:!1});case 18:if(w=B.sent,R=null,!I){B.next=34;break}if(!(P=w.getAudioTracks()[0])||!this.isAudioTrackMixed()){B.next=31;break}return y=this.getAudioTrack(),d=Ce.AudioMixerPlugin.getAudioTrackMap(),B.next=27,Ce.AudioMixerPlugin.mix({targetTrack:P,sourceList:d.get(y.id).sourceList,trackList:d.get(y.id).trackList});case 27:_=B.sent,R=_,B.next=32;break;case 31:R=P;case 32:B.next=43;break;case 34:if(!(R=w.getVideoTracks()[0])||!this.isVideoTrackBeautified()){B.next=39;break}return B.next=38,this.generateBeautyTrack(R);case 38:R=B.sent;case 39:if(!(E=w.getAudioTracks()[0])||!hd){B.next=43;break}return B.next=43,this.replaceTrack(E);case 43:return B.next=45,this.replaceTrack(R);case 45:(C=this.getConnection())&&(O=C.getUserId(),L=C.getTinyId(),N=UU,W="switch camera",I&&(N=VU,W="switch microphone"),rt(O,{eventId:N,eventDesc:W,timestamp:Qe(),userId:O,tinyId:L})),this.log_.info("switch ".concat(I?"microphone":"camera"," success ")),I&&(this.audio_=!0),A&&(this.video_=!0,this.facingMode_=f===Cg||f===Rg?f:""),this.updateDeviceIdInUse(),this.setIsReadyToPublish(!0),B.next=59;break;case 54:throw B.prev=54,B.t0=B.catch(15),this.log_.error(B.t0),I?this.recoverCapture({audio:!0,video:!1,microphoneId:this.microphoneId_}):this.recoverCapture({audio:!1,video:!0,cameraId:this.cameraId_,facingMode:this.facingMode_}),B.t0;case 59:case"end":return B.stop()}},p,this,[[15,54]])})),function(p,S){return h.apply(this,arguments)})},{key:"addTrack",value:(u=F(M().mark(function p(S){var f,I,A;return M().wrap(function(x){for(;;)switch(x.prev=x.next){case 0:if(x.prev=0,S.kind===q&&lr&&(f=S.getSettings(),!this.videoSetting_||f.width===this.videoSetting_.width&&f.height===this.videoSetting_.height||this.log_.warn("video resolution of the track (".concat(f.width," x ").concat(f.height,") shall be kept the same as the previous: ").concat(this.videoSetting_.width," x ").concat(this.videoSetting_.height,". It may cause abnormal Cloud Recording."))),this.isAddingTrack_=!0,this.keepMuteState(S),this.mediaStream_.addTrack(S),!(I=this.getConnection())){x.next=11;break}return A=null,S.kind===q&&(as||is)&&$y(S)&&(A=this.getCanvasTrack()),x.next=11,I.addTrack(A||S,this);case 11:S.kind===K?(this.audio_=!0,this.updateAudioPlayingState(!0),this.captureVolume_!==100&&this.setAudioCaptureVolume(this.captureVolume_)):(this.video_=!0,this.updateVideoPlayingState(!0)),this.isAddingTrack_=!1,x.next=20;break;case 15:throw x.prev=15,x.t0=x.catch(0),this.mediaStream_.removeTrack(S),this.isAddingTrack_=!1,x.t0;case 20:case"end":return x.stop()}},p,this,[[0,15]])})),function(p){return u.apply(this,arguments)})},{key:"removeTrack",value:(l=F(M().mark(function p(S){var f;return M().wrap(function(I){for(;;)switch(I.prev=I.next){case 0:if(I.prev=0,this.isRemovingTrack_=!0,!(f=this.getConnection())){I.next=17;break}if(S.kind!==q||!as&&!is||!this.canvasTrack_){I.next=10;break}return I.next=7,f.removeTrack(this.canvasTrack_,this);case 7:this.clearCanvas(),I.next=17;break;case 10:if(S.kind!==K||!this.gain_.audioTrack){I.next=15;break}return I.next=13,f.removeTrack(this.gain_.audioTrack,this);case 13:I.next=17;break;case 15:return I.next=17,f.removeTrack(S,this);case 17:this.mediaStream_.removeTrack(S),S.kind===K?(this.audio_=!1,this.updateAudioPlayingState(!1),this.stopGainNode()):(this.video_=!1,this.updateVideoPlayingState(!1)),this.isRemovingTrack_=!1,I.next=26;break;case 22:throw I.prev=22,I.t0=I.catch(0),this.isRemovingTrack_=!1,I.t0;case 26:case"end":return I.stop()}},p,this,[[0,22]])})),function(p){return l.apply(this,arguments)})},{key:"replaceTrack",value:(s=F(M().mark(function p(S){var f,I,A;return M().wrap(function(x){for(;;)switch(x.prev=x.next){case 0:if(S.kind===q&&lr&&(f=S.getSettings(),!this.videoSetting_||f.width===this.videoSetting_.width&&f.height===this.videoSetting_.height||this.log_.warn("video resolution of the track (".concat(f.width," x ").concat(f.height,") shall be kept the same as the previous: ").concat(this.videoSetting_.width," x ").concat(this.videoSetting_.height,". It may cause abnormal Cloud Recording."))),this.keepMuteState(S),I=this.mediaStream_,S.kind!==K){x.next=12;break}if(I.removeTrack(I.getAudioTracks()[0]),I.addTrack(S),Re(ve(k.prototype),"restartAudio",this).call(this),!this.gain_.gainNode){x.next=10;break}return this.reconnectGainNode(S),x.abrupt("return");case 10:x.next=15;break;case 12:I.removeTrack(I.getVideoTracks()[0]),I.addTrack(S),Re(ve(k.prototype),"restartVideo",this).call(this);case 15:if(!(A=this.getConnection())){x.next=21;break}if(S.kind!==q||!as&&!is||!this.canvasTrack_){x.next=19;break}return x.abrupt("return");case 19:return x.next=21,A.replaceTrack(S,this);case 21:case"end":return x.stop()}},p,this)})),function(p){return s.apply(this,arguments)})},{key:"recoverCapture",value:(a=F(M().mark(function p(S){var f,I,A,x,D,m,v,w,R,P,y,d,_,E,C,O,L;return M().wrap(function(N){for(;;)switch(N.prev=N.next){case 0:if(!(!this.mediaStream_||!this.enableAutoRecoverCapture_||S.audio&&!S.video&&this.isAudioRecovering_||S.video&&!S.audio&&this.isVideoRecovering_)){N.next=2;break}return N.abrupt("return");case 2:return S.audio&&(this.isAudioRecovering_=!0),S.video&&(this.isVideoRecovering_=!0),this.log_.warn("recoverCapture() trying "+JSON.stringify(S)),f=this.audio_&&S.audio,I=this.video_&&S.video,N.prev=7,N.next=10,Ce.getCameras();case 10:return A=N.sent,N.next=13,Ce.getMicrophones();case 13:if(x=N.sent,I&&A.length===0&&(I=!1,this.log_.warn("recoverCapture() video flag is true, but no camera detected, set video to false")),f&&x.length===0&&(f=!1,this.log_.warn("recoverCapture() audio flag is true, but no microphone detected, set audio to false")),f||I){N.next=21;break}return S.audio&&(this.isAudioRecovering_=!1),S.video&&(this.isVideoRecovering_=!1),this.log_.warn("recoverCapture() both audio and video are false, aborted"),N.abrupt("return");case 21:return D=S&&A.findIndex(function(W){return W.deviceId===S.cameraId})>=0,m=S&&x.findIndex(function(W){return W.deviceId===S.microphoneId})>=0,f&&((v=this.getAudioTrack())===null||v===void 0||v.stop()),I&&((w=this.getVideoTrack())===null||w===void 0||w.stop()),N.next=27,Np({audio:f,video:I,cameraId:D?S.cameraId:void 0,microphoneId:m?S.microphoneId:void 0,facingMode:this.facingMode_,width:this.videoProfile_.width,height:this.videoProfile_.height,frameRate:this.videoProfile_.frameRate,sampleRate:this.audioProfile_.sampleRate,channelCount:this.audioProfile_.channelCount,autoGainControl:this.audioProfile_.autoGainControl,noiseSuppression:this.audioProfile_.noiseSuppression,echoCancellation:this.audioProfile_.echoCancellation});case 27:R=N.sent,P=R.getTracks(),y=0;case 30:if(!(y<P.length)){N.next=59;break}if((d=P[y]).kind!==K||!this.isAudioTrackMixed()){N.next=45;break}if(_=this.getAudioTrack(),E=Ce.AudioMixerPlugin.getAudioTrackMap(),(C=E.get(_.id)).hasMicrophone){N.next=39;break}return d.stop(),N.abrupt("continue",56);case 39:return N.next=41,Ce.AudioMixerPlugin.mix({targetTrack:d,sourceList:C.sourceList,trackList:C.trackList});case 41:return O=N.sent,N.next=44,this.replaceTrack(O);case 44:return N.abrupt("continue",56);case 45:if(d.kind!==q||!this.isVideoTrackBeautified()){N.next=52;break}return N.next=48,this.generateBeautyTrack(d);case 48:return L=N.sent,N.next=51,this.replaceTrack(L);case 51:return N.abrupt("continue",56);case 52:return N.next=54,this.replaceTrack(d);case 54:if(d.readyState!=="ended"){N.next=56;break}throw new Error("new track is failed, muted ".concat(d.muted," readyState ").concat(d.readyState));case 56:y++,N.next=30;break;case 59:this.updateDeviceIdInUse(),J.logSuccessEvent({userId:this.client_?this.client_.getUserId():this.userId_,eventType:Xg}),S.audio&&(this.isAudioRecovering_=!1),S.video&&(this.isVideoRecovering_=!1),this.log_.warn("recoverCapture() successfully"),this.emitter_.emit(qV,{isCamera:S.video,isMicrophone:S.audio,cameraId:this.cameraId_,microphoneId:this.microphoneId_}),N.next=73;break;case 67:throw N.prev=67,N.t0=N.catch(7),S.audio&&(this.isAudioRecovering_=!1),S.video&&(this.isVideoRecovering_=!1),this.log_.warn("recoverCapture() failed, "+N.t0),N.t0;case 73:case"end":return N.stop()}},p,this,[[7,67]])})),function(p){return a.apply(this,arguments)})},{key:"updateDeviceIdInUse",value:function(){var p=this;if(!this.mediaStream_)return this.cameraId_="",this.cameraGroupId_="",this.microphoneId_="",void(this.microphoneGroupId_="");lr&&this.mediaStream_.getTracks().forEach(function(I){if(I.kind===K&&p.isAudioTrackMixed()){var A=p.getMicrophoneTrackMixed();if(A){var x=A.getSettings(),D=x.deviceId,m=x.groupId;D&&(p.microphoneId_=D,p.microphoneGroupId_=m,p.microphoneLabel_=A.label)}}else if(I.kind===q&&p.isVideoTrackBeautified()){var v=p.getBeautyOriginTrack();if(v){var w=v.getSettings(),R=w.deviceId,P=w.groupId,y=w.facingMode;R&&(p.cameraId_=R,p.cameraGroupId_=P),y&&(p.facingMode_=y)}}else{var d=I.getSettings(),_=d.deviceId,E=d.groupId,C=d.facingMode;_&&(I.kind===K?(p.microphoneId_=_,p.microphoneGroupId_=E,p.microphoneLabel_=I.label):I.kind!==q||p.screen_||(p.cameraId_=_,p.cameraGroupId_=E,C&&(p.facingMode_=C)))}});var S=this.mediaStream_.getAudioTracks(),f=this.mediaStream_.getVideoTracks();S&&S.length===0&&(this.microphoneId_="",this.microphoneGroupId_=""),f&&f.length===0&&(this.cameraId_="",this.cameraGroupId_="")}},{key:"isAudioTrackMixed",value:function(){if(Ce.AudioMixerPlugin){var p=Ce.AudioMixerPlugin.getAudioTrackMap(),S=this.getAudioTrack();if(p&&S&&p.has(S.id))return!0}return!1}},{key:"getMicrophoneTrackMixed",value:function(){if(Ce.AudioMixerPlugin){var p=Ce.AudioMixerPlugin.getAudioTrackMap(),S=this.getAudioTrack();if(p&&S&&p.has(S.id)){var f=p.get(S.id);return f.hasMicrophone?f.microphoneTrack:null}}return null}},{key:"isVideoTrackBeautified",value:function(){if(Ce.beautyTrackMap){var p=Ce.beautyTrackMap,S=this.getVideoTrack();if(S&&p.has(S.id))return!0}return!1}},{key:"getBeautyOriginTrack",value:function(){if(Ce.beautyTrackMap){var p=Ce.beautyTrackMap,S=this.getVideoTrack();if(S&&p.has(S.id)){var f=p.get(S.id);if(f.originTrack)return f.originTrack}}return null}},{key:"generateBeautyTrack",value:(c=F(M().mark(function p(S){var f,I,A,x;return M().wrap(function(D){for(;;)switch(D.prev=D.next){case 0:if(f=null,I=this.getVideoTrack(),A=Ce.beautyTrackMap.get(I.id),x=A.param,A.type){D.next=8;break}f=A.pluginInstance.generateBeautyTrack(S),D.next=22;break;case 8:D.t0=A.type,D.next=D.t0==="beauty"?11:D.t0==="virtual"?13:D.t0==="mixed"?17:21;break;case 11:return f=A.pluginInstance.generateBeautyTrack(S),D.abrupt("break",22);case 13:return D.next=15,A.pluginInstance.generateVirtualTrack({videoTrack:S,type:x.type,img:x.img});case 15:case 19:return f=D.sent,D.abrupt("break",22);case 17:return D.next=19,A.pluginInstance.generateMixedTrack({videoTrack:S,type:x.type,img:x.img});case 21:return D.abrupt("break",22);case 22:return A.pluginInstance.deleteSource(I.id),this.log_.info("regenerate beauty track, track id = ".concat(S.id)),D.abrupt("return",f);case 25:case"end":return D.stop()}},p,this)})),function(p){return c.apply(this,arguments)})},{key:"getScreen",value:function(){return this.screen_}},{key:"hasScreenTrack",value:function(){if(this.screen_)return!0;var p=this.getVideoTrack();return!!p&&(p.contentHint===Ag||p.contentHint===kM)}},{key:"getVideo",value:function(){return this.video_}},{key:"getAudio",value:function(){return this.audio_}},{key:"getCameraId",value:function(){return this.cameraId_}},{key:"getMicrophoneId",value:function(){return this.microphoneId_}},{key:"getMicrophoneGroupId",value:function(){return this.microphoneGroupId_}},{key:"getIsReadyToPublish",value:function(){return this.isReadyToPublish_}},{key:"setIsReadyToPublish",value:function(p){this.isReadyToPublish_=p}},{key:"setPublishState",value:function(p){this.publishState_=p}},{key:"setBeautyStatus",value:function(p){this.beautyStatus_=!!p}},{key:"getBeautyStatus",value:function(){return this.beautyStatus_}},{key:"syncMuteState",value:function(){var p=this.getAudioTrack(),S=this.getVideoTrack();if(p){var f=!p.enabled;this.setMuteState(K,f)}if(S){var I=!S.enabled;this.setMuteState(q,I)}this.connection_&&this.connection_.sendMutedFlag(this.muteState_,this)}},{key:"keepMuteState",value:function(p){p instanceof window.MediaStreamTrack&&this.muteState_[p.kind]&&(p.enabled=!1,this.log_.warn("prev ".concat(p.kind," track is muted, keep mute state")))}},{key:"onVideoTrackStopped",value:(o=F(M().mark(function p(S){var f,I,A=this;return M().wrap(function(x){for(;;)switch(x.prev=x.next){case 0:if(f=S.stream,I=S.type,f===this&&this.video_&&this.cameraId_&&$V(this.getVideoTrack())&&!this.isVideoRecovering_&&(I!==Je||!la||!nr)){x.next=3;break}return x.abrupt("return");case 3:if(!(Date.now()-this.prevVideoRecoverTime_<Qo)){x.next=6;break}return setTimeout(function(){return A.onVideoTrackStopped({stream:f,type:I})},Qo),x.abrupt("return");case 6:I===Je?setTimeout(function(){var D=A.getVideoTrack();D!=null&&D.muted&&document.visibilityState==="visible"&&A.recoverVideoCapture(I)},5e3):this.recoverVideoCapture(I);case 7:case"end":return x.stop()}},p,this)})),function(p){return o.apply(this,arguments)})},{key:"onAudioTrackStopped",value:(r=F(M().mark(function p(S){var f,I,A=this;return M().wrap(function(x){for(;;)switch(x.prev=x.next){case 0:if(f=S.stream,I=S.type,!(f!==this||!this.audio_||!this.microphoneId_||this.isAudioRecovering_||I===Je&&la&&nr)){x.next=3;break}return x.abrupt("return");case 3:if(!(Date.now()-this.prevAudioRecoverTime_<Qo)){x.next=6;break}return setTimeout(function(){return A.onAudioTrackStopped({stream:f,type:I})},Qo),x.abrupt("return");case 6:I===Je?setTimeout(function(){var D=A.getAudioTrack();D!=null&&D.muted&&document.visibilityState==="visible"&&A.recoverAudioCapture(I)},5e3):this.recoverAudioCapture(I);case 7:case"end":return x.stop()}},p,this)})),function(p){return r.apply(this,arguments)})},{key:"recoverAudioCapture",value:(i=F(M().mark(function p(S){return M().wrap(function(f){for(;;)switch(f.prev=f.next){case 0:return this.prevAudioRecoverTime_=Date.now(),J.uploadEvent({log:"stat-local-audio-".concat(S),userId:this.userId_}),f.t0=this,f.next=5,this.getRecoverCaptureDeviceId(!1);case 5:f.t1=f.sent,f.t2={audio:!0,video:!1,microphoneId:f.t1},f.t0.recoverCapture.call(f.t0,f.t2);case 8:case"end":return f.stop()}},p,this)})),function(p){return i.apply(this,arguments)})},{key:"recoverVideoCapture",value:(n=F(M().mark(function p(S){return M().wrap(function(f){for(;;)switch(f.prev=f.next){case 0:return this.prevVideoRecoverTime_=Date.now(),J.uploadEvent({log:"stat-local-video-".concat(S),userId:this.userId_}),f.t0=this,f.next=5,this.getRecoverCaptureDeviceId(!0);case 5:f.t1=f.sent,f.t2={audio:!1,video:!0,cameraId:f.t1},f.t0.recoverCapture.call(f.t0,f.t2);case 8:case"end":return f.stop()}},p,this)})),function(p){return n.apply(this,arguments)})},{key:"getRecoverCaptureDeviceId",value:(t=F(M().mark(function p(){var S,f,I,A,x=arguments;return M().wrap(function(D){for(;;)switch(D.prev=D.next){case 0:if(S=!(x.length>0&&x[0]!==void 0)||x[0],!(f=S?this.cameraId_:this.microphoneId_)||!this.enableAutoRecoverOther_){D.next=17;break}if(yr.has(f)?yr.set(f,yr.get(f)+1):yr.set(f,1),!((I=yr.get(f))>=3)){D.next=17;break}if(!S){D.next=12;break}return D.next=9,Ce.getCameras();case 9:D.t0=D.sent.find(function(m){return!yr.has(m.deviceId)}),D.next=15;break;case 12:return D.next=14,Ce.getMicrophones();case 14:D.t0=D.sent.find(function(m){return!yr.has(m.deviceId)});case 15:(A=D.t0)&&(this.log_.warn("".concat(S?"camera":"mic"," ").concat(f," capture fail ").concat(I," times, change new ").concat(A.deviceId)),f=A.deviceId);case 17:return D.abrupt("return",f);case 18:case"end":return D.stop()}},p,this)})),function(){return t.apply(this,arguments)})},{key:"setAudioVolume",value:function(p){Re(ve(k.prototype),"setAudioVolume",this).call(this,p)}},{key:"clearCanvas",value:function(){this.canvasInterval_&&(ye.clearTask(this.canvasInterval_),this.canvasInterval_=null,this.canvas_=null,this.canvasTrack_=null)}},{key:"getCanvasTrack",value:function(){var p=this;if(this.canvasTrack_)return this.canvasTrack_;this.log_.info("gen canvas track");var S=this.getVideoTrack().getSettings(),f=S.width,I=S.height,A=S.frameRate;this.canvas_=document.createElement("canvas");var x=this.canvas_.getContext("2d");this.canvas_.width=f,this.canvas_.height=I,this.canvasInterval_=ye.run(Xo,function(){if(p.hasVideo()){var m=p.getVideoTrack().getSettings();m.width===p.canvas_.width&&m.height===p.canvas_.height||(p.canvas_.width=m.width,p.canvas_.height=m.height)}p.videoPlayer_&&p.videoPlayer_.element_&&x.drawImage(p.videoPlayer_.element_,0,0,p.canvas_.width,p.canvas_.height)},{fps:Math.max(15,A)});var D=this.canvas_.captureStream();return this.canvasTrack_=D.getVideoTracks()[0],this.canvasTrack_}},{key:"setClient",value:function(p,S){p&&(this.log_.setUserId(p.getUserId()),this.log_.setSdkAppId(p.getSDKAppId()),S||this.syncMuteState()),this.client_=p}},{key:"setAudioCaptureVolume",value:function(){var p=this,S=arguments.length>0&&arguments[0]!==void 0?arguments[0]:100;if(!this.hasAudio()||S<0||!_h())return!1;if(this.captureVolume_===S)return!0;this.captureVolume_=S,this.log_.info("setCaptureVolume "+S),S/=100;var f=nS();if(this.gain_.gainNode)this.gain_.gainNode.gain.value=S;else{var I,A=new MediaStream;A.addTrack(this.getAudioTrack());var x=f.createMediaStreamDestination(),D=f.createMediaStreamSource(A),m=f.createGain();m.gain.value=S,D.connect(m),m.connect(x);var v=x.stream.getAudioTracks()[0],w=function(R){return p.log_.info("gained audio track ".concat(R))};v.onmute=function(){return w("muted")},v.onunmute=function(){return w("unmuted")},v.onended=function(){return w("ended")},this.gain_={source:D,audioTrack:v,gainNode:m},(I=this.connection_)===null||I===void 0||I.replaceTrack(v),Re(ve(k.prototype),"restartAudio",this).call(this)}return!0}},{key:"getGainedTrack",value:function(){return this.gain_.audioTrack}},{key:"reconnectGainNode",value:function(p){this.log_.warn("reconnect gain node");var S=new MediaStream;S.addTrack(p);var f=nS().createMediaStreamSource(S);f.connect(this.gain_.gainNode),this.gain_.source.disconnect(),this.gain_.source=f}},{key:"stopGainNode",value:function(){var p=this.gain_,S=p.audioTrack,f=p.source,I=p.gainNode;I&&(f.disconnect(),I.disconnect(),S.onmute=null,S.onunmute=null,S.onended=null,S.stop(),this.gain_={source:null,gainNode:null,audioTrack:null}),this.captureVolume_=100}},{key:"close",value:function(){this.setIsReadyToPublish(!1),this.stopGainNode(),Re(ve(k.prototype),"close",this).call(this)}},{key:"setIsAIDenoiser",value:function(p){this.isAIDenoiser=p}}]),k}(J0),ie(he.prototype,"setAudioProfile",[K0],Object.getOwnPropertyDescriptor(he.prototype,"setAudioProfile"),he.prototype),ie(he.prototype,"setVideoProfile",[Q0],Object.getOwnPropertyDescriptor(he.prototype,"setVideoProfile"),he.prototype),ie(he.prototype,"setScreenProfile",[X0],Object.getOwnPropertyDescriptor(he.prototype,"setScreenProfile"),he.prototype),ie(he.prototype,"setVideoContentHint",[Y0],Object.getOwnPropertyDescriptor(he.prototype,"setVideoContentHint"),he.prototype),ie(he.prototype,"switchDevice",[$0],Object.getOwnPropertyDescriptor(he.prototype,"switchDevice"),he.prototype),ie(he.prototype,"addTrack",[Z0],Object.getOwnPropertyDescriptor(he.prototype,"addTrack"),he.prototype),ie(he.prototype,"removeTrack",[eI],Object.getOwnPropertyDescriptor(he.prototype,"removeTrack"),he.prototype),ie(he.prototype,"replaceTrack",[tI],Object.getOwnPropertyDescriptor(he.prototype,"replaceTrack"),he.prototype),ie(he.prototype,"recoverCapture",[nI],Object.getOwnPropertyDescriptor(he.prototype,"recoverCapture"),he.prototype),ie(he.prototype,"setAudioCaptureVolume",[rI,iI],Object.getOwnPropertyDescriptor(he.prototype,"setAudioCaptureVolume"),he.prototype),he),sI={voiceActivityDetection:!1},b8=(aI=yi({retries:1,timeout:0,onRetrying:function(e){this.log_.warn("connection timeout, retrying [".concat(e,"]"))},onError:function(e,t,n){e.message.includes("timeout")?(this.reset(),this.initialize(),t()):n(e)}}),Na=function(e){ki(D,e);var t,n,i,r,o,c,a,s,l,u,h,g,b,T,k,p,S,f,I,A,x=Ti(D);function D(m){var v;return ce(this,D),(v=x.call(this,m)).localStream_=null,v.exchangeSDPTimeout_=-1,v.localAuxStream_=null,v.publishingStream_=null,v.isPublishingAuxStream_=!1,v.smallGenerator_=null,v.isSDPExchanging_=!1,v.ssrc_={audio:0,video:0,small:0,auxiliary:0},v.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},v.mixedAudioTrack_=null,v}return ue(D,[{key:"isMainStreamPublished",get:function(){return!!this.localStream_}},{key:"isAuxStreamPublished",get:function(){return!!this.localAuxStream_}},{key:"publishState",get:function(){var m=this,v={audio:!1,bigVideo:!1,smallVideo:!1,auxVideo:!1};if(this.peerConnection_){var w,R,P,y,d=this.peerConnection_.getSenders();d&&(On()?(v.audio=!((w=d[0])===null||w===void 0||!w.track),v.bigVideo=!((R=d[1])===null||R===void 0||!R.track),v.smallVideo=!((P=d[2])===null||P===void 0||!P.track),v.auxVideo=!((y=d[3])===null||y===void 0||!y.track)):d.forEach(function(_){_.track&&(_.track.kind===K?v.audio=!0:(v.bigVideo=!0,m.smallGenerator_&&(v.smallVideo=!0)))}))}return v}},{key:"initialize",value:function(){Re(ve(D.prototype),"initialize",this).call(this),this.installEvents()}},{key:"reset",value:function(){this.isReconnecting_&&this.stopReconnection(),this.closePeerConnection(),this.uninstallEvents(),this.clearExchangeSDPTimeout(),this.localStream_&&this.localStream_.clearCanvas()}},{key:"close",value:function(){Re(ve(D.prototype),"close",this).call(this),this.reset(),this.emitConnectionStateChangedEvent(Xe),this.smallGenerator_&&(this.smallGenerator_.destroy(),this.smallGenerator_=null)}},{key:"installEvents",value:function(){this.emitter_.on(de.ERROR,this.handleError,this),this.emitter_.on(de.CONNECTION_STATE_CHANGED,this.handleConnectionStateChange,this)}},{key:"uninstallEvents",value:function(){this.emitter_.off(de.ERROR,this.handleError,this),this.emitter_.off(de.CONNECTION_STATE_CHANGED,this.handleConnectionStateChange,this)}},{key:"publish",value:(A=F(M().mark(function m(v,w){var R,P,y,d;return M().wrap(function(_){for(;;)switch(_.prev=_.next){case 0:if(this.publishingStream_=v,this.isPublishingAuxStream_=w,P=v.getVideoTrack(),y=null,!P||w||!this.client_.getIsEnableSmallStream()){_.next=9;break}return this.smallGenerator_=new Xs(v),_.next=8,this.smallGenerator_.initialize();case 8:y=this.smallGenerator_.generateSmallVideoTrack(this.client_.smallStreamConfig_);case 9:if(d=v.getVideoProfile(),!this.client_.get2k4kFlag()){_.next=18;break}if(this.client_.get2k4kFlag()===1||v.getScreen()||!(d.height*d.width>=3686400)){_.next=18;break}return d.width=1920,d.height=1080,this.log_.warn(vy),_.next=18,v.setVideoProfile(d);case 18:if(!(Qr&&Xr()===115&&d.width*d.height<=230400)){_.next=22;break}return this.log_.warn("fallback video to 480p"),_.next=22,v.setVideoProfile("480p_2");case 22:if(this.updateMediaSettings(v,w),!_s()){_.next=33;break}if(!Rn||qy!==11){_.next=29;break}return _.next=27,this.publishByAddTrack(v,y);case 27:_.next=31;break;case 29:return _.next=31,this.publishByTransceiver(v,y,w);case 31:_.next=35;break;case 33:return _.next=35,this.publishByAddTrack(v,y);case 35:return this.publishingStream_=null,this.isPublishingAuxStream_=!1,w?this.localAuxStream_=v:this.localStream_=v,(R=this.sei_)===null||R===void 0||R.handleEncodedStreams(),_.abrupt("return",v);case 40:case"end":return _.stop()}},m,this)})),function(m,v){return A.apply(this,arguments)})},{key:"publishByTransceiver",value:(I=F(M().mark(function m(v,w,R){var P,y,d,_,E,C,O;return M().wrap(function(L){for(;;)switch(L.prev=L.next){case 0:if(this.log_.info("publish by transceiver"),P=v.getMediaStream(),y=v.getAudioTrack(),d=v.getVideoTrack(),_=null,(as||is)&&$y(d)&&(_=v.getCanvasTrack()),(E=this.peerConnection_.getTransceivers()).length!==0){L.next=16;break}return this.peerConnection_.addTransceiver(y||K,{direction:Tn,streams:[P]}),this.peerConnection_.addTransceiver(R?q:_||d||q,{direction:Tn,streams:[P]}),this.peerConnection_.addTransceiver(w||q,{direction:Tn,streams:[P]}),this.peerConnection_.addTransceiver(R?_||d:q,{direction:Tn,streams:[P]}),L.next=14,this.connect();case 14:L.next=46;break;case 16:if(C=[],!y){L.next=29;break}if(!E[0].sender.track){L.next=24;break}return this.mixAudioTrack(E[0].sender.track,y),L.next=22,E[0].sender.replaceTrack(this.mixedAudioTrack_);case 22:L.next=27;break;case 24:return L.next=26,E[0].sender.replaceTrack(y);case 26:C.push(0);case 27:return L.next=29,this.setBandwidth({bandwidth:v.getAudioBitrate(),type:K});case 29:if(!d){L.next=42;break}return O=R?3:1,L.next=33,E[O].sender.replaceTrack(_||d);case 33:return L.next=35,this.setBandwidth({bandwidth:v.getVideoBitrate(),type:q,videoType:R?ke:Fo,scaleResolutionDownBy:v.scaleResolutionDownBy});case 35:if(C.push(O),!w){L.next=42;break}return L.next=39,E[2].sender.replaceTrack(w);case 39:return L.next=41,this.setBandwidth({bandwidth:this.client_.smallStreamConfig.bitrate,type:q,videoType:en});case 41:C.push(2);case 42:return L.next=44,this.setTransceiverDirection(Tn,C);case 44:return L.next=46,this.doPublishChange();case 46:case"end":return L.stop()}},m,this)})),function(m,v,w){return I.apply(this,arguments)})},{key:"publishByAddTrack",value:(f=F(M().mark(function m(v,w){var R,P,y,d;return M().wrap(function(_){for(;;)switch(_.prev=_.next){case 0:return this.log_.info("publish by addtrack"),R=v.getMediaStream(),P=v.getAudioTrack(),y=v.getVideoTrack(),P&&this.peerConnection_.addTrack(P,R),y&&(this.peerConnection_.addTrack(y,R),w&&((d=new MediaStream).addTrack(w),this.peerConnection_.addTrack(w,d))),_.next=8,this.connect();case 8:case"end":return _.stop()}},m,this)})),function(m,v){return f.apply(this,arguments)})},{key:"unpublish",value:(S=F(M().mark(function m(v){var w,R,P,y;return M().wrap(function(d){for(;;)switch(d.prev=d.next){case 0:if(On()){d.next=2;break}return d.abrupt("return",this.doUnpublish());case 2:if(w=v.getAudioTrack(),R=v===this.localAuxStream_,P=[],!this.peerConnection_){d.next=33;break}if(y=this.peerConnection_.getSenders(),!w){d.next=18;break}if(!this.mixedAudioTrack_){d.next=15;break}return this.log_.info("has mixed audioTrack, use another audioTrack"),d.next=12,y[0].replaceTrack(R?this.localStream_.getAudioTrack():this.localAuxStream_.getAudioTrack());case 12:this.destroyMixedAudioTrack(),d.next=18;break;case 15:return d.next=17,y[0].replaceTrack(null);case 17:P.push(0);case 18:if(!R){d.next=26;break}return d.next=21,y[3].replaceTrack(null);case 21:this.localAuxStream_=null,this.mediaSettings_=te(te({},this.mediaSettings_),{},{auxVideoBps:0,auxVideoFps:0,auxVideoWidth:0,auxVideoHeight:0}),P.push(3),d.next=33;break;case 26:return d.next=28,y[1].replaceTrack(null);case 28:return d.next=30,y[2].replaceTrack(null);case 30:this.localStream_=null,this.mediaSettings_=te(te({},this.mediaSettings_),{},{videoWidth:0,videoHeight:0,videoBps:0,videoFps:0,audioFs:0,audioChannel:0,audioBps:0,smallVideoWidth:0,smallVideoHeight:0,smallVideoFps:0,smallVideoBps:0}),P.push(1,2);case 33:if(!this.localStream_&&!this.localAuxStream_){d.next=40;break}return d.next=36,this.setTransceiverDirection(zr,P);case 36:return d.next=38,this.doPublishChange();case 38:d.next=42;break;case 40:return d.next=42,this.doUnpublish();case 42:case"end":return d.stop()}},m,this)})),function(m){return S.apply(this,arguments)})},{key:"doPublishChange",value:(p=F(M().mark(function m(){var v,w;return M().wrap(function(R){for(;;)switch(R.prev=R.next){case 0:return v={state:this.publishState,constraintConfig:this.mediaSettings_},R.next=3,this.signalChannel_.sendWaitForResponse({command:dU,data:v,responseCommand:pe.PUBLISH_STATE_CHANGE_RESULT});case 3:w=R.sent,this.checkPublishResultCode(w.data.code,w.data.message);case 5:case"end":return R.stop()}},m,this)})),function(){return p.apply(this,arguments)})},{key:"doUnpublish",value:function(){var m=this;return this.signalChannel_.sendWaitForResponse({command:xS,commandDesc:"unpublish",responseCommand:pe.UNPUBLISH_RESULT}).then(function(){m.close()}).catch(function(){m.close()})}},{key:"updateMediaSettings",value:function(m,v){var w=this;this.localAuxStream_&&m===this.localAuxStream_&&(v=!0);var R=this.client_.getSystemResult().detail,P=R.isH264EncodeSupported,y=R.isVp8EncodeSupported;if(P?this.mediaSettings_.videoCodec="H264":y&&(this.mediaSettings_.videoCodec="VP8"),lr){var d=m.getMediaStream();d==null||d.getTracks().forEach(function(_){var E=_.getSettings();if(_.kind===K){var C=1;E.channelCount&&(C=E.channelCount),w.mediaSettings_.audioChannel=C,w.mediaSettings_.audioBps=1e3*m.getAudioBitrate(),w.mediaSettings_.audioFs=E.sampleRate}else if(_.kind===q){if(v)return w.mediaSettings_.auxVideoWidth=E.width,w.mediaSettings_.auxVideoHeight=E.height,w.mediaSettings_.auxVideoFps=E.frameRate,void(w.mediaSettings_.auxVideoBps=1e3*m.getVideoBitrate());w.client_.getIsEnableSmallStream()&&(w.mediaSettings_.smallVideoWidth=w.client_.smallStreamConfig.width,w.mediaSettings_.smallVideoHeight=w.client_.smallStreamConfig.height,w.mediaSettings_.smallVideoFps=w.client_.smallStreamConfig.frameRate,w.mediaSettings_.smallVideoBps=1e3*w.client_.smallStreamConfig.bitrate),w.mediaSettings_.videoWidth=E.width,w.mediaSettings_.videoHeight=E.height,w.mediaSettings_.videoFps=E.frameRate,w.mediaSettings_.videoBps=1e3*m.getVideoBitrate()}})}else this.updateMediaSettingsFromProfile(m);this.log_.info("updateMediaSettings: "+JSON.stringify(this.mediaSettings_))}},{key:"updateMediaSettingsFromProfile",value:function(m){if(m){if(m.hasAudio()){var v=m.getAudioProfile();this.mediaSettings_.audioChannel=v.channelCount,this.mediaSettings_.audioBps=1e3*v.bitrate,this.mediaSettings_.audioFs=v.sampleRate}if(m.hasVideo()){var w=m.getVideoProfile();this.mediaSettings_.videoWidth=w.width,this.mediaSettings_.videoHeight=w.height,this.mediaSettings_.videoFps=w.frameRate,this.mediaSettings_.videoBps=1e3*w.bitrate}}}},{key:"sendMediaSettings",value:function(m){var v=this;this.updateMediaSettings(m),this.signalChannel_.sendWaitForResponse({command:CU,data:this.mediaSettings_,responseCommand:pe.UPDATE_CONSTRAINT_CONFIG_RES}).then(function(w){w.data.code!==0&&v.log_.warn(w.data.message)}).catch(this.log_.warn)}},{key:"addTrack",value:(k=F(M().mark(function m(v,w){var R,P;return M().wrap(function(y){for(;;)switch(y.prev=y.next){case 0:if(this.peerConnection_){y.next=2;break}return y.abrupt("return");case 2:if(P=w===this.localAuxStream_,this.log_.info("is adding ".concat(v.kind," track to current published local ").concat(P?ke:le," stream")),(R=this.sei_)===null||R===void 0||R.handleEncodedStreams(),!On()){y.next=10;break}return y.next=8,this.addTrackByTransceiver(v,w);case 8:y.next=12;break;case 10:return y.next=12,this.addTrackBySender(v);case 12:rt(this.userId_,{eventId:v.kind===K?DS:PS,eventDesc:"add ".concat(v.kind," track to current published stream"),timestamp:Qe(),userId:this.userId_,tinyId:this.tinyId_});case 13:case"end":return y.stop()}},m,this)})),function(m,v){return k.apply(this,arguments)})},{key:"addTrackByTransceiver",value:(T=F(M().mark(function m(v,w){var R,P,y,d;return M().wrap(function(_){for(;;)switch(_.prev=_.next){case 0:if(R=w===this.localAuxStream_,P=this.peerConnection_.getTransceivers(),v.kind!==K){_.next=13;break}if(!P[0].sender.track){_.next=9;break}return this.mixAudioTrack(P[0].sender.track,v),_.next=7,P[0].sender.replaceTrack(this.mixedAudioTrack_);case 7:_.next=11;break;case 9:return _.next=11,P[0].sender.replaceTrack(v);case 11:_.next=26;break;case 13:return y=R?3:1,_.next=16,P[y].sender.replaceTrack(v);case 16:if(y!==1||!this.client_.getIsEnableSmallStream()){_.next=23;break}return this.smallGenerator_=new Xs(this.localStream_),_.next=20,this.smallGenerator_.initialize();case 20:return d=this.smallGenerator_.generateSmallVideoTrack(this.client_.smallStreamConfig_),_.next=23,P[2].sender.replaceTrack(d);case 23:if(P[y].direction!==zr){_.next=26;break}return _.next=26,this.setTransceiverDirection(Tn,[y]);case 26:return this.updateMediaSettings(w,R),_.next=29,this.doPublishChange();case 29:case"end":return _.stop()}},m,this)})),function(m,v){return T.apply(this,arguments)})},{key:"addTrackBySender",value:(b=F(M().mark(function m(v){var w,R,P,y,d;return M().wrap(function(_){for(;;)switch(_.prev=_.next){case 0:if(!(On()&&this.peerConnection_.getTransceivers().findIndex(function(E){return E.direction==="stopped"})>=0)){_.next=4;break}return this.log_.warn("transceiver is stopping, negotiate sdp first"),_.next=4,this.updateOffer($e.REMOVE,v);case 4:if(!(w=this.peerConnection_.getSenders().find(function(E){return E.track&&E.track.kind===v.kind}))){_.next=11;break}return this.log_.warn("sender already exists, remove sender first"),R=w.track,this.removeSender(w),_.next=11,this.updateOffer($e.REMOVE,R);case 11:if(P=this.localStream_.getMediaStream(),this.peerConnection_.addTrack(v,P),v.kind!==q||!this.client_.getIsEnableSmallStream()){_.next=21;break}return this.smallGenerator_=new Xs(this.localStream_),_.next=17,this.smallGenerator_.initialize();case 17:y=this.smallGenerator_.generateSmallVideoTrack(this.client_.smallStreamConfig_),(d=new MediaStream).addTrack(y),this.peerConnection_.addTrack(y,d);case 21:return _.next=23,this.updateOffer($e.ADD,v);case 23:case"end":return _.stop()}},m,this)})),function(m){return b.apply(this,arguments)})},{key:"isNeedToResetOfferOrder",value:function(){if(this.sdpSemantics_===jl||!this.peerConnection_||!this.peerConnection_.localDescription)return!1;for(var m=this.peerConnection_.localDescription.sdp,v=sn(m),w=0;w<v.media.length;w++)if(v.media[w].mid===0&&v.media[w].type===q)return!0;return!1}},{key:"removeSender",value:function(m){var v=null;On()&&(v=this.peerConnection_.getTransceivers().find(function(w){return w.sender&&w.sender.track===m.track})),this.peerConnection_.removeTrack(m),v&&et(v.stop)&&(this.log_.info("stop transceiver"),v.stop())}},{key:"removeTrack",value:(g=F(M().mark(function m(v,w){return M().wrap(function(R){for(;;)switch(R.prev=R.next){case 0:if(this.peerConnection_){R.next=2;break}return R.abrupt("return");case 2:if(this.log_.info("is removing ".concat(v.kind," track from current published local ").concat(w===this.localAuxStream_?ke:le," stream")),!On()){R.next=8;break}return R.next=6,this.removeTrackByTransceiver(v,w);case 6:R.next=10;break;case 8:return R.next=10,this.removeTrackBySender(v);case 10:rt(this.userId_,{eventId:v.kind===K?MS:OS,eventDesc:"remove ".concat(v.kind," track from current published stream"),timestamp:Qe(),userId:this.userId_,tinyId:this.tinyId_});case 11:case"end":return R.stop()}},m,this)})),function(m,v){return g.apply(this,arguments)})},{key:"removeTrackByTransceiver",value:(h=F(M().mark(function m(v,w){var R,P,y;return M().wrap(function(d){for(;;)switch(d.prev=d.next){case 0:if(R=w===this.localAuxStream_,P=this.peerConnection_.getTransceivers(),v.kind!==K){d.next=13;break}if(!this.mixedAudioTrack_){d.next=9;break}return d.next=6,P[0].sender.replaceTrack(R?this.localStream_.getAudioTrack():this.localAuxStream_.getAudioTrack());case 6:this.destroyMixedAudioTrack(),d.next=11;break;case 9:return d.next=11,P[0].sender.replaceTrack(null);case 11:d.next=23;break;case 13:return y=R?3:1,d.next=16,P[y].sender.replaceTrack(null);case 16:if(y!==1||!this.smallGenerator_){d.next=21;break}return this.smallGenerator_.destroy(),this.smallGenerator_=null,d.next=21,P[2].sender.replaceTrack(null);case 21:return d.next=23,this.setTransceiverDirection(zr,[y]);case 23:return this.updateMediaSettings(w,R),d.next=26,this.doPublishChange();case 26:case"end":return d.stop()}},m,this)})),function(m,v){return h.apply(this,arguments)})},{key:"setTransceiverDirection",value:(u=F(M().mark(function m(v,w){var R,P,y,d,_,E;return M().wrap(function(C){for(;;)switch(C.prev=C.next){case 0:if(ft){C.next=2;break}return C.abrupt("return");case 2:if(R=!1,P=!1,this.log_.info("setting transceiver ".concat(w.join(",")," direction to ").concat(v)),y=this.peerConnection_.getTransceivers(),w.forEach(function(O){y[O].direction!==v&&(y[O].direction=v,R=!0)}),!R){C.next=14;break}return this.log_.info("updating offer"),C.next=11,this.peerConnection_.createOffer();case 11:return d=C.sent,C.next=14,this.peerConnection_.setLocalDescription(d);case 14:if(_=-1,E=this.peerConnection_.remoteDescription.sdp.split(`\r
`).map(function(O){if(O.match(new RegExp("a=(".concat(zr,"|").concat(Al,"|").concat(Tn,")")))&&_++,w.includes(_)){if(v===zr&&O.includes("a=".concat(Al)))return P=!0,"a=".concat(v);if(v===Tn&&O.includes("a=".concat(zr)))return P=!0,"a=".concat(Al)}return O}).join(`\r
`),!P){C.next=20;break}return this.log_.info("updating answer"),C.next=20,this.peerConnection_.setRemoteDescription({type:"answer",sdp:E});case 20:case"end":return C.stop()}},m,this)})),function(m,v){return u.apply(this,arguments)})},{key:"removeTrackBySender",value:(l=F(M().mark(function m(v){var w,R,P=this;return M().wrap(function(y){for(;;)switch(y.prev=y.next){case 0:if(v.kind!==q||!this.isNeedToResetOfferOrder()){y.next=7;break}return this.reset(),this.initialize(),(w=this.localStream_.getMediaStream())===null||w===void 0||w.removeTrack(v),y.next=6,this.publish(this.localStream_);case 6:return y.abrupt("return");case 7:return(R=this.peerConnection_.getSenders().find(function(d){return d.track===v}))&&(this.removeSender(R),v.kind===q&&this.smallGenerator_&&(this.smallGenerator_.destroy(),this.smallGenerator_=null,this.peerConnection_.getSenders().forEach(function(d){d.track&&d.track.kind===q&&P.removeSender(d)}))),y.next=11,this.updateOffer($e.REMOVE,v);case 11:case"end":return y.stop()}},m,this)})),function(m){return l.apply(this,arguments)})},{key:"replaceTrack",value:(s=F(M().mark(function m(v,w){var R,P,y,d,_,E,C;return M().wrap(function(O){for(;;)switch(O.prev=O.next){case 0:if((P=(R=this.peerConnection_)===null||R===void 0?void 0:R.getSenders())&&P.length!==0){O.next=3;break}throw new j({code:V.INVALID_OPERATION,message:H({key:Ry})});case 3:if(y=w===this.localAuxStream_,this.log_.info("is replacing ".concat(v.kind," track to current published local ").concat(y?ke:le," stream")),v.kind!==K||!P[0]){O.next=16;break}if(!(this.mixedAudioTrack_&&(d=this.localStream_)!==null&&d!==void 0&&d.hasAudio()&&(_=this.localAuxStream_)!==null&&_!==void 0&&_.hasAudio())){O.next=14;break}return this.destroyMixedAudioTrack(),E=y?this.localStream_.getAudioTrack():this.localAuxStream_.getAudioTrack(),this.mixAudioTrack(v,E),O.next=12,P[0].replaceTrack(this.mixedAudioTrack_);case 12:O.next=16;break;case 14:return O.next=16,P[0].replaceTrack(v);case 16:if(v.kind!==q){O.next=32;break}if(w!==this.localStream_||!P[1]){O.next=29;break}return O.next=20,P[1].replaceTrack(v);case 20:if(!this.smallGenerator_||!P[2]){O.next=29;break}return this.log_.info("replacing smallVideo"),this.smallGenerator_.destroy(),this.smallGenerator_=new Xs(this.localStream_),O.next=26,this.smallGenerator_.initialize();case 26:return C=this.smallGenerator_.generateSmallVideoTrack(this.client_.smallStreamConfig_),O.next=29,P[2].replaceTrack(C);case 29:if(w!==this.localAuxStream_||!P[3]){O.next=32;break}return O.next=32,P[3].replaceTrack(v);case 32:rt(this.userId_,{eventId:v.kind===K?FU:jU,eventDesc:"replace ".concat(v.kind," track from current published stream"),timestamp:Qe(),userId:this.userId_,tinyId:this.tinyId_});case 33:case"end":return O.stop()}},m,this)})),function(m,v){return s.apply(this,arguments)})},{key:"updateOffer",value:(a=F(M().mark(function m(v,w){var R,P,y,d,_,E,C;return M().wrap(function(O){for(;;)switch(O.prev=O.next){case 0:return O.prev=0,O.next=3,this.peerConnection_.createOffer(sI);case 3:return R=O.sent,ft&&(R.sdp=this.setSDPDirection(R.sdp,"sendrecv")),O.next=7,this.peerConnection_.setLocalDescription(R);case 7:return P=this.updateMediaSettings(this.localStream_||this.localAuxStream_),y={action:v,trackId:w.id,kind:w.kind===q?"bigVideo":w.kind,type:"offer",sdp:this.peerConnection_.localDescription.sdp,constraintConfig:P,state:this.publishState},this.log_.info("createOffer success, sending updated offer to remote server"),this.log_.debug("updatedOffer: "+y.sdp),O.next=13,this.signalChannel_.sendWaitForResponse({command:lU,data:y,responseCommand:pe.UPDATE_OFFER_RESULT,timeout:1e4,commandDesc:"update offer"});case 13:return d=O.sent,_=d.data,E=_.code,C=_.message,E!==0&&this.checkPublishResultCode(E,C),O.next=18,this.acceptAnswer(d.data.data);case 18:this.updateSSRC(R.sdp),J.logSuccessEvent({userId:this.client_.getUserId(),eventType:qo,kind:"offer"}),O.next=27;break;case 22:throw O.prev=22,O.t0=O.catch(0),this.log_.error(O.t0),J.logFailedEvent({userId:this.client_.getUserId(),eventType:qo,kind:"offer",error:O.t0}),O.t0;case 27:case"end":return O.stop()}},m,this,[[0,22]])})),function(m,v){return a.apply(this,arguments)})},{key:"setBandwidth",value:(c=F(M().mark(function m(v){var w,R,P,y,d,_,E,C,O,L;return M().wrap(function(N){for(;;)switch(N.prev=N.next){case 0:if(w=v.bandwidth,R=v.type,P=v.videoType,y=P===void 0?"":P,d=v.sdp,_=v.scaleResolutionDownBy,E=_===void 0?1:_,tb()||!d){N.next=3;break}return N.abrupt("return",R===q?this.updateVideoBandwidthRestriction(d,w,y):this.updateAudioBandwidthRestriction(d,w));case 3:if(C=null,_s()?(O=0,R===q&&(O=y===en?2:y===ke?3:1),C=this.peerConnection_.getSenders()[O]):C=this.peerConnection_.getSenders().find(function(W){return W.track&&W.track.kind===R}),!C){N.next=23;break}return(L=C.getParameters()).encodings&&L.encodings.length!==0||(L.encodings=[{}]),w==="unlimited"?delete L.encodings[0].maxBitrate:L.encodings[0].maxBitrate=1e3*w,delete L.encodings[0].scaleResolutionDownBy,E>1&&(this.log_.warn("".concat(y," scaleResolutionDownBy ").concat(E)),L.encodings[0].scaleResolutionDownBy=E),N.prev=11,N.next=14,C.setParameters(L);case 14:return this.log_.info(y+R+" bandwidth was set to "+w+" kbps"),N.abrupt("return",d);case 18:if(N.prev=18,N.t0=N.catch(11),this.log_.info("failed to set bandwidth by setting maxBitrate: "+N.t0),!d){N.next=23;break}return N.abrupt("return",R===q?this.updateVideoBandwidthRestriction(d,w,y):this.updateAudioBandwidthRestriction(d,w));case 23:return N.abrupt("return",d);case 24:case"end":return N.stop()}},m,this,[[11,18]])})),function(m){return c.apply(this,arguments)})},{key:"updateVideoBandwidthRestriction",value:function(m,v,w){var R="AS";ft&&(R="TIAS",v*=1e3);var P=0,y=-1;return w===en?P=1:w===ke&&(P=2),m=m.replace(/m=video (.*)\r\nc=IN (.*)\r\n/g,function(d){return++y===P?"".concat(d,"b=").concat(R,":").concat(v,`\r
`):d}),m}},{key:"updateAudioBandwidthRestriction",value:function(m,v){var w="AS";return ft&&(w="TIAS",v*=1e3),m=m.replace(/m=audio (.*)\r\nc=IN (.*)\r\n/,`m=audio $1\r
c=IN $2\r
b=`+w+":"+v+`\r
`)}},{key:"removeBandwidthRestriction",value:function(m){return m.replace(/b=AS:.*\r\n/,"").replace(/b=TIAS:.*\r\n/,"")}},{key:"removeVideoOrientation",value:function(m){return m.replace(/urn:3gpp:video-orientation/,"")}},{key:"connect",value:(o=F(M().mark(function m(){return M().wrap(function(v){for(;;)switch(v.prev=v.next){case 0:return v.prev=0,v.next=3,this.exchangeSDP();case 3:return v.next=5,this.waitForPeerConnectionConnected();case 5:v.next=11;break;case 7:throw v.prev=7,v.t0=v.catch(0),this.closePeerConnection(!0),v.t0;case 11:case"end":return v.stop()}},m,this,[[0,7]])})),function(){return o.apply(this,arguments)})},{key:"exchangeSDP",value:(r=F(M().mark(function m(){return M().wrap(function(v){for(;;)switch(v.prev=v.next){case 0:return v.prev=0,this.isSDPExchanging_=!0,v.next=4,this.createOffer();case 4:return this.log_.info("createOffer success, sending offer to remote server"),v.next=7,this.doExchangeSDP();case 7:this.isSDPExchanging_=!1,v.next=14;break;case 10:throw v.prev=10,v.t0=v.catch(0),this.isSDPExchanging_=!1,v.t0;case 14:case"end":return v.stop()}},m,this,[[0,10]])})),function(){return r.apply(this,arguments)})},{key:"createOffer",value:(i=F(M().mark(function m(){var v;return M().wrap(function(w){for(;;)switch(w.prev=w.next){case 0:return w.prev=0,w.next=3,this.peerConnection_.createOffer(sI);case 3:return v=w.sent,w.next=6,this.peerConnection_.setLocalDescription(v);case 6:this.updateSSRC(v.sdp),J.logSuccessEvent({userId:this.client_.getUserId(),eventType:qo,kind:"offer"}),w.next=14;break;case 10:throw w.prev=10,w.t0=w.catch(0),J.logFailedEvent({userId:this.client_.getUserId(),eventType:qo,kind:"offer",error:w.t0}),w.t0;case 14:case"end":return w.stop()}},m,this,[[0,10]])})),function(){return i.apply(this,arguments)})},{key:"doExchangeSDP",value:function(){var m=this;return new Promise(function(v,w){m.exchangeSDPTimeout_=setTimeout(function(){m.signalChannel_.off(pe.PUBLISH_RESULT,R),m.clearExchangeSDPTimeout();var y=new j({code:V.API_CALL_TIMEOUT,message:H({key:fN})});w(y)},1e4);var R=function(){var y=F(M().mark(function d(_){var E,C,O;return M().wrap(function(L){for(;;)switch(L.prev=L.next){case 0:if(L.prev=0,m.clearExchangeSDPTimeout(),E=_.data,C=E.code,O=E.message,C!==0){L.next=9;break}return L.next=6,m.acceptAnswer(_.data.data);case 6:v(),L.next=10;break;case 9:m.checkPublishResultCode(C,O);case 10:L.next=15;break;case 12:L.prev=12,L.t0=L.catch(0),w(L.t0);case 15:case"end":return L.stop()}},d,null,[[0,12]])}));return function(d){return y.apply(this,arguments)}}(),P={type:m.peerConnection_.localDescription.type,sdp:m.removeVideoOrientation(m.peerConnection_.localDescription.sdp),screen:(m.publishingStream_||m.localStream_).hasScreenTrack(),state:m.publishState,constraintConfig:m.mediaSettings_};m.signalChannel_.once(pe.PUBLISH_RESULT,R),m.log_.debug("sending sdp offer: "+P.sdp),m.signalChannel_.send(_U,P)})}},{key:"setSDPDirection",value:function(m,v){var w=arguments.length>2&&arguments[2]!==void 0?arguments[2]:"all",R=sn(m);return R.media.forEach(function(P){w!=="all"&&P.type!==w||(P.direction=v)}),ii(R)}},{key:"acceptAnswer",value:(n=F(M().mark(function m(v){var w,R,P,y,d,_,E;return M().wrap(function(C){for(;;)switch(C.prev=C.next){case 0:if(C.prev=0,w=this.removeVideoOrientation(v.sdp),!(R=this.publishingStream_||this.localStream_)){C.next=15;break}if(P=R.getVideoBitrate(),y=R.getAudioBitrate(),!P){C.next=11;break}return d=this.isPublishingAuxStream_?ke:Fo,C.next=10,this.setBandwidth({sdp:w,videoType:d,type:q,bandwidth:P,scaleResolutionDownBy:R.scaleResolutionDownBy});case 10:w=C.sent;case 11:if(!y){C.next=15;break}return C.next=14,this.setBandwidth({bandwidth:y,type:K,sdp:w});case 14:w=C.sent;case 15:if(!this.client_.getIsEnableSmallStream()){C.next=20;break}return _=this.client_.smallStreamConfig,C.next=19,this.setBandwidth({bandwidth:_.bitrate,type:q,videoType:en,sdp:w});case 19:w=C.sent;case 20:return E={type:v.type,sdp:w},C.next=23,this.peerConnection_.setRemoteDescription(E);case 23:this.log_.debug("accepted answer: "+w),J.logSuccessEvent({userId:this.client_.getUserId(),eventType:qg,kind:"answer"}),C.next=32;break;case 27:throw C.prev=27,C.t0=C.catch(0),J.logFailedEvent({userId:this.client_.getUserId(),eventType:qg,kind:"answer",error:C.t0}),this.log_.error("failed to accept remote answer "+C.t0),C.t0;case 32:case"end":return C.stop()}},m,this,[[0,27]])})),function(m){return n.apply(this,arguments)})},{key:"sendMutedFlag",value:function(m,v){if(v!==this.localAuxStream_){var w={audio:m.audio,bigVideo:m.video,auxVideo:m.auxVideo};this.log_.info("send muted state: ".concat(JSON.stringify(w))),this.signalChannel_.send(mU,w)}}},{key:"getIsReconnecting",value:function(){return this.isReconnecting_}},{key:"reconnect",value:(t=F(M().mark(function m(){var v,w,R=this;return M().wrap(function(P){for(;;)switch(P.prev=P.next){case 0:if(this.reconnectionTimer_===-1){P.next=3;break}return this.log_.warn("reconnect() uplink is reconnecting, ignore current reconnection"),P.abrupt("return");case 3:if(!(this.reconnectionCount_>=30)){P.next=12;break}return this.log_.warn("SDK has tried reconnect uplink for ".concat(30," times, but all failed, please check your network")),this.stopReconnection(),v=new j({code:V.UPLINK_RECONNECTION_FAILED,message:H({key:vN})}),J.logFailedEvent({userId:this.client_.getUserId(),eventType:Gg,error:v}),this.addEventInternal(nV,"uplink-connection reconnect fail"),this.emitConnectionStateChangedEvent(Xe),this.emitter_.emit(de.ERROR,v),P.abrupt("return");case 12:if(this.signalChannel_.getCurrentState()===_a){P.next=16;break}return this.log_.warn("reconnect() signal channel is not connected, suspend reconnection until signal is connected"),this.signalChannel_.once(ma,this.reconnect,this),P.abrupt("return");case 16:if(this.reconnectionCount_++,P.prev=17,this.log_.warn("reconnect() try to reconnect uplink [".concat(this.reconnectionCount_,"/").concat(30,"]")),w=gd(this.reconnectionCount_),this.reconnectionTimer_=setTimeout(function(){R.log_.warn("reconnect() uplink reconnect timeout(".concat(w/1e3,"s), try again")),R.clearReconnectionTimer(),R.reconnect()},w),!(this.isSDPExchanging_||this.peerConnection_&&this.peerConnection_.connectionState===Jo)){P.next=23;break}return P.abrupt("return");case 23:return P.next=25,this.signalChannel_.sendWaitForResponse({command:xS,responseCommand:pe.UNPUBLISH_RESULT,enableLog:!1});case 25:if(this.reset(),this.initialize(),!this.localStream_){P.next=30;break}return P.next=30,this.publish(this.localStream_);case 30:if(!this.localAuxStream_){P.next=33;break}return P.next=33,this.publish(this.localAuxStream_,!0);case 33:J.logSuccessEvent({userId:this.client_.getUserId(),eventType:Gg}),this.log_.warn("reconnect() uplink reconnect successfully"),this.addEventInternal(tV,"uplink-connection reconnect success"),this.stopReconnection(),this.localStream_.syncMuteState(),P.next=42;break;case 40:P.prev=40,P.t0=P.catch(17);case 42:case"end":return P.stop()}},m,this,[[17,40]])})),function(){return t.apply(this,arguments)})},{key:"clearExchangeSDPTimeout",value:function(){this.exchangeSDPTimeout_!==-1&&(clearTimeout(this.exchangeSDPTimeout_),this.exchangeSDPTimeout_=-1)}},{key:"clearReconnectionTimer",value:function(){this.reconnectionTimer_!==-1&&(clearTimeout(this.reconnectionTimer_),this.reconnectionTimer_=-1)}},{key:"handleError",value:function(m){m.getCode()===V.ICE_TRANSPORT_ERROR&&(this.isFirstConnection_&&(this.isFirstConnection_=!1,J.logFailedEvent({userId:this.client_.getUserId(),eventType:Wg,error:m})),this.isReconnecting_||this.startReconnection())}},{key:"handleConnectionStateChange",value:function(m){m.state===Ye&&this.isFirstConnection_&&(this.isFirstConnection_=!1,J.logSuccessEvent({userId:this.client_.getUserId(),eventType:Wg}),this.addEventInternal(QU,"uplink-connection is connected"))}},{key:"updateSSRC",value:function(m){var v=this;try{sn(m).media.forEach(function(w,R){if(w.type===K){var P=w.ssrcs[0];P&&(v.ssrc_.audio=P.id)}else{if(v.sdpSemantics_===jl)return void w.ssrcGroups.forEach(function(d,_){var E=Number(d.ssrcs.split(" ")[0]);_===0?v.ssrc_.video=E:_===1&&(v.ssrc_.small=E)});var y=w.ssrcs[0];if(!y)return;switch(R){case 1:v.ssrc_.video=y.id;break;case 2:v.ssrc_.small=y.id;break;case 3:v.ssrc_.auxiliary=y.id}}})}catch{}}},{key:"getVideoTrackId",value:function(){var m=arguments.length>0&&arguments[0]!==void 0?arguments[0]:q;if(this.peerConnection_){var v=this.peerConnection_.getSenders();if(m===q&&v[1]&&v[1].track)return v[1].track.id;if(m===en&&v[2]&&v[2].track)return v[2].track.id;if(m===ke&&v[3]&&v[3].track)return v[3].track.id}if(this.localStream_&&m===q){var w=this.localStream_.getVideoTrack();if(w)return w.id}if(this.localAuxStream_&&m===ke){var R=this.localAuxStream_.getVideoTrack();if(R)return R.id}return""}},{key:"getSSRC",value:function(){return this.ssrc_}},{key:"checkPublishResultCode",value:function(m,v){if(m!==0)throw m===1028?(this.log_.error(En.NOT_SUPPORTED_H264ENCODE),new j({code:V.NOT_SUPPORTED_H264,message:H({key:Py})})):new j({code:V.UNKNOWN,message:H({key:Oy,data:{signalResponse:pe.PUBLISH_RESULT,code:m,message:v}})})}},{key:"getLocalStream",value:function(){return this.localStream_}},{key:"sendSEI",value:function(m,v){this.sei_.push(m,v)}},{key:"mixAudioTrack",value:function(m,v){this.log_.info("mix audio track"),this.mixedAudioTrack_=function(w){var R=tS(),P=R.createMediaStreamDestination(),y=[];w.forEach(function(_){var E=new MediaStream;E.addTrack(_);var C=R.createMediaStreamSource(E);C.connect(P),y.push(C)});var d=P.stream.getAudioTracks()[0];return Ys.set(d,{destination:P,track:d,mediaStreamSourceList:y}),d}([m,v])}},{key:"destroyMixedAudioTrack",value:function(){this.mixedAudioTrack_&&(this.log_.info("destroy audio track"),function(m){if(Ys.has(m)){var v=Ys.get(m),w=v.destination,R=v.track,P=v.mediaStreamSourceList;R.stop(),w.disconnect(),P.forEach(function(y){y.disconnect()}),Ys.delete(m)}}(this.mixedAudioTrack_),this.mixedAudioTrack_=null)}}]),D}(Pp),ie(Na.prototype,"publish",[aI],Object.getOwnPropertyDescriptor(Na.prototype,"publish"),Na.prototype),Na),k8=$,cI=Fi,$s=Li.exports.getWeakData,I8=vn,T8=Oe,w8=Lt,jp=xe,E8=ji,uI=Le,R8=Me.set,C8=Me.getterFor,A8=Ke.find,x8=Ke.findIndex,P8=k8([].splice),D8=0,Zs=function(e){return e.frozen||(e.frozen=new lI)},lI=function(){this.entries=[]},Fp=function(e,t){return A8(e.entries,function(n){return n[0]===t})};lI.prototype={get:function(e){var t=Fp(this,e);if(t)return t[1]},has:function(e){return!!Fp(this,e)},set:function(e,t){var n=Fp(this,e);n?n[1]=t:this.entries.push([e,t])},delete:function(e){var t=x8(this.entries,function(n){return n[0]===e});return~t&&P8(this.entries,t,1),!!~t}};var La,O8={getConstructor:function(e,t,n,i){var r=e(function(s,l){I8(s,o),R8(s,{type:t,id:D8++,frozen:void 0}),w8(l)||E8(l,s[i],{that:s,AS_ENTRIES:n})}),o=r.prototype,c=C8(t),a=function(s,l,u){var h=c(s),g=$s(T8(l),!0);return g===!0?Zs(h).set(l,u):g[h.id]=u,s};return cI(o,{delete:function(s){var l=c(this);if(!jp(s))return!1;var u=$s(s);return u===!0?Zs(l).delete(s):u&&uI(u,l.id)&&delete u[l.id]},has:function(s){var l=c(this);if(!jp(s))return!1;var u=$s(s);return u===!0?Zs(l).has(s):u&&uI(u,l.id)}}),cI(o,n?{get:function(s){var l=c(this);if(jp(s)){var u=$s(s);return u===!0?Zs(l).get(s):u?u[l.id]:void 0}},set:function(s,l){return a(this,s,l)}}:{add:function(s){return a(this,s,!0)}}),r}},dI=oe,ec=$,M8=Fi,N8=Li.exports,L8=lu,hI=O8,tc=xe,nc=lm,rc=Me.enforce,U8=wf,V8=!dI.ActiveXObject&&"ActiveXObject"in dI,pI=function(e){return function(){return e(this,arguments.length?arguments[0]:void 0)}},j8=L8("WeakMap",pI,hI);if(U8&&V8){La=hI.getConstructor(pI,"WeakMap",!0),N8.enable();var Ua=j8.prototype,fI=ec(Ua.delete),ic=ec(Ua.has),mI=ec(Ua.get),_I=ec(Ua.set);M8(Ua,{delete:function(e){if(tc(e)&&!nc(e)){var t=rc(this);return t.frozen||(t.frozen=new La),fI(this,e)||t.frozen.delete(e)}return fI(this,e)},has:function(e){if(tc(e)&&!nc(e)){var t=rc(this);return t.frozen||(t.frozen=new La),ic(this,e)||t.frozen.has(e)}return ic(this,e)},get:function(e){if(tc(e)&&!nc(e)){var t=rc(this);return t.frozen||(t.frozen=new La),ic(this,e)?mI(this,e):t.frozen.get(e)}return mI(this,e)},set:function(e,t){if(tc(e)&&!nc(e)){var n=rc(this);n.frozen||(n.frozen=new La),ic(this,e)?_I(this,e,t):n.frozen.set(e,t)}else _I(this,e,t);return this}})}var F8=Y,ac=ta,B8=Z,vI=Qt,gI=ge,H8=Oo,yI=Tg,W8=He,Bp=ac&&ac.prototype;if(F8({target:"Promise",proto:!0,real:!0,forced:!!ac&&B8(function(){Bp.finally.call({then:function(){}},function(){})})},{finally:function(e){var t=H8(this,vI("Promise")),n=gI(e);return this.then(n?function(i){return yI(t,e()).then(function(){return i})}:e,n?function(i){return yI(t,e()).then(function(){throw i})}:e)}}),gI(ac)){var SI=vI("Promise").prototype.finally;Bp.finally!==SI&&W8(Bp,"finally",SI,{unsafe:!0})}var bI,kI,II,TI,Nt,Si=new WeakMap;function wI(){return function(e,t,n){var i=n.value,r=function o(c){var a=c.fn,s=c.args,l=c.context,u=c.resolve,h=c.reject;a.apply(l,s).then(u,h).finally(function(){var g=Si.get(l);g&&(g.shift(),g[0]&&o(te({},g[0])))})};return n.value=function(){for(var o=this,c=arguments.length,a=new Array(c),s=0;s<c;s++)a[s]=arguments[s];return new Promise(function(l,u){if(Si.has(o)){var h=Si.get(o),g=h.length;h.push({fn:i,args:a,context:o,resolve:l,reject:u,name:t}),g===0&&r({fn:i,args:a,context:o,resolve:l,reject:u})}else Si.set(o,[{fn:i,args:a,context:o,resolve:l,reject:u,name:t}]),r({fn:i,args:a,context:o,resolve:l,reject:u})})},n}}var G8=(bI=wI(),kI=yi({retries:1,timeout:0,onRetrying:function(e){this.log_.warn("connection timeout, retrying [".concat(e,"]"))},onError:function(e,t,n){e.message.includes("timeout")?t():n(e)}}),II=wI(),TI=function(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:1e4;return function(t,n,i){var r=i.value;return i.value=function(){for(var o=this,c=arguments.length,a=new Array(c),s=0;s<c;s++)a[s]=arguments[s];return new Promise(function(l,u){var h=setTimeout(function(){return u(new Error("".concat(n," timeout")))},e);r.apply(o,a).then(l,u).finally(function(){clearTimeout(h)})})},i}}(),Nt=function(e){ki(l,e);var t,n,i,r,o,c,a,s=Ti(l);function l(u){var h;return ce(this,l),(h=s.call(this,u)).remoteStreams_=new Map,h.autoSubscribe=u.autoSubscribe,h.trackState_={audio:u.trackState.audio,video:u.trackState.video,auxiliary:u.trackState.auxiliary,smallVideo:u.trackState.smallVideo},h.ssrc_={audio:0,video:0,auxiliary:0},h.subscribeState_={audio:u.autoSubscribe,video:u.autoSubscribe,auxiliary:u.autoSubscribe,smallVideo:!1},h.isSDPExchanging_=!1,h.installEvents(),h}return ue(l,[{key:"getMixUserList",value:function(){return this.mixUserList_?this.mixUserList_.map(function(u){var h=u.userId,g=u.flag;return{userId:h,hasAudio:!!(8&g),hasVideo:!!(1&g),hasAuxiliary:!!(4&g)}}):void 0}},{key:"setMixUserList",value:function(u){(!this.mixUserList_||Yr(this.mixUserList_)&&!function(h,g){if(g.length===h.length){var b,T=qt(g);try{var k=function(){var S=b.value,f=h.find(function(I){return I.userId===S.userId});if(!f||f.flag!==S.flag)return{v:!1}};for(T.s();!(b=T.n()).done;){var p=k();if(bi(p)==="object")return p.v}}catch(S){T.e(S)}finally{T.f()}return!0}return!1}(this.mixUserList_,u))&&(this.mixUserList_=u,this.emitter_.emit(de.STREAM_UPDATED,{stream:this.getMainStream()}))}},{key:"isMainStreamSubscribed",get:function(){return(this.subscribeState_.audio||this.subscribeState_.video||this.subscribeState_.smallVideo)&&(this.trackState_.audio||this.trackState_.video||this.trackState_.smallVideo)}},{key:"isAuxStreamSubscribed",get:function(){return this.subscribeState_.auxiliary&&this.trackState_.auxiliary}},{key:"isSmallStreamSubscribed",get:function(){return this.subscribeState_.smallVideo&&this.trackState_.smallVideo}},{key:"isBigStreamSubscribed",get:function(){return this.subscribeState_.video&&this.trackState_.video}},{key:"isStreamUnpublished",value:function(u){return u.getType()===le?!this.trackState_.audio&&!this.trackState_.video:!this.trackState_.auxiliary}},{key:"initialize",value:function(){Re(ve(l.prototype),"initialize",this).call(this),this.peerConnection_.ontrack=this.onTrack.bind(this)}},{key:"close",value:function(){var u,h,g,b=this;Re(ve(l.prototype),"close",this).call(this),this.trackState_.audio=!1,this.trackState_.video=!1,this.trackState_.smallVideo=!1,this.trackState_.auxiliary=!1,this.emitConnectionStateChangedEvent(Xe),u=this,h=function(T){T.fn;var k=T.args,p=T.resolve,S=T.reject,f=T.name;if(f==="subscribe"){if(!b.client_.getIsJoined())return S(new j({code:V.API_CALL_ABORTED,message:H({key:$l,data:{message:"leave room",stream:k[0]}})}));if(b.isStreamUnpublished(k[0]))return S(new j({code:V.API_CALL_ABORTED,message:H({key:$l,data:{message:"remote user ".concat(b.userId_," unpublished stream"),stream:k[0]}})}))}else if(f==="unsubscribe")return p();p()},(g=Si.get(u))===null||g===void 0||g.forEach(h),Si.delete(u),this.remoteStreams_.forEach(function(T){var k=T;k.setConnection(null),k.uninstallEvents(),k.getIsStreamAddedEventEmitted()&&b.emitter_.emit(de.STREAM_REMOVED,{stream:k})}),this.remoteStreams_.clear(),this.uninstallEvents()}},{key:"installEvents",value:function(){var u=this;U.on(mt,this.onRemoteStreamUpdate,this),this.emitter_.on(de.ERROR,function(h){h.getCode()===V.ICE_TRANSPORT_ERROR&&(u.isFirstConnection_&&(u.isFirstConnection_=!1,J.logFailedEvent({userId:u.client_.getUserId(),eventType:zg,error:h})),u.isReconnecting_||u.startReconnection())}),this.emitter_.on(de.CONNECTION_STATE_CHANGED,function(h){h.state===Ye&&u.isFirstConnection_&&(u.isFirstConnection_=!1,J.logSuccessEvent({userId:u.client_.getUserId(),eventType:zg}),u.addEventInternal(XU,"downlink-connection is connected"))})}},{key:"uninstallEvents",value:function(){U.removeListener(mt,this.onRemoteStreamUpdate,this)}},{key:"onRemoteStreamUpdate",value:function(u){if(this.hitTest(u.tinyId)&&u.client===this.client_){this.updateTrackState(u.action,u.kind);var h=u.kind===ke?aa:Gt,g=this.remoteStreams_.get(h);if(!g)return;u.action===$e.ADD?this.handleRemoteAddTrack(u.kind,g):this.handleRemoteRemoveTrack(u.kind,g)}}},{key:"handleRemoteAddTrack",value:function(u,h){this.log_.info("remote add ".concat(u," track")),u===K?h.updateAudioPlayingState(this.subscribeState_.audio):h.updateVideoPlayingState(u===ke?this.subscribeState_.auxiliary:this.subscribeState_.video||this.subscribeState_.smallVideo),h.getIsStreamAddedEventEmitted()?this.emitter_.emit(de.STREAM_UPDATED,{stream:h}):(this.emitter_.emit(de.STREAM_ADDED,{stream:h}),this.currentState_===Ye&&h.emitConnectionStateChanged({prevState:Xe,state:Ye}))}},{key:"handleRemoteRemoveTrack",value:function(u,h){h.getIsStreamAddedEventEmitted()&&(this.log_.info("remote remove ".concat(u," track")),u===ke||!this.trackState_.audio&&!this.trackState_.video?(this.log_.info("remote stream ".concat(h.getType()," removed")),this.currentState_===Ye&&h.emitConnectionStateChanged({prevState:Ye,state:Xe}),this.emitter_.emit(de.STREAM_REMOVED,{stream:h})):(u===K?h.updateAudioPlayingState(!1):(u!==Bo||this.isSmallStreamSubscribed)&&h.updateVideoPlayingState(!1),this.emitter_.emit(de.STREAM_UPDATED,{stream:h})))}},{key:"updateTrackState",value:function(u,h){var g=u===$e.ADD;switch(h){case K:this.trackState_.audio=g;break;case q:this.trackState_.video=g;break;case ke:this.trackState_.auxiliary=g;break;case Bo:this.trackState_.smallVideo=g}this.log_.info("trackState updated: ".concat(JSON.stringify(this.trackState_)))}},{key:"onTrack",value:function(u){var h=u.streams[0],g=u.track;if(this.log_.info("ontrack() kind: ".concat(g.kind," id: ").concat(g.id," streamId: ").concat(h.id)),this.sdpSemantics_===sa){var b=function(f){var I=At.parse(f),A={audio:[],video:[]};return I.media.forEach(function(x){if(x.ssrcs){var D=x.ssrcs[0].id>>16&255;if(x.type===K)A.audio.push(Gt);else if(x.type==q){var m=D===LM?Gt:aa;A.video.push(m)}}}),A}(this.peerConnection_.remoteDescription.sdp);if(g.kind===K){if(b.audio.length===0||h.id!==Gt)return void this.log_.debug("skip this invalid audio track")}else if(b.video.indexOf(h.id)===-1)return void this.log_.debug("skip this invalid video track: ".concat(g.id," msid: ").concat(h.id))}J.logEvent({eventType:"ontrack",kind:g.kind});var T=!1,k=this.remoteStreams_.get(h.id),p=h.id===Gt?Te:Ne;if(G(k)&&((k=new Mp({type:p,userId:this.userId_,client:this.client_})).setConnection(this),this.remoteStreams_.set(h.id,k),T=!0),k.setMediaStream(h),g.kind===K?k.updateAudioPlayingState(this.subscribeState_.audio):p===Te?k.updateVideoPlayingState(this.subscribeState_.video||this.subscribeState_.smallVideo):k.updateVideoPlayingState(this.subscribeState_.auxiliary),(p!==Ne||this.trackState_.auxiliary)&&(p!==Te||this.trackState_.audio||this.trackState_.video)){var S=this.client_.getSubscriptionManager();S&&S.hasAutoRecoveryFlag(this.userId_,p)||(T?this.emitter_.emit(de.STREAM_ADDED,{stream:k}):this.emitter_.emit(de.STREAM_UPDATED,{stream:k}))}}},{key:"addRRTRLine",value:function(u){var h=u.split(`\r
`),g=new Map;h.forEach(function(f,I){/^a=rtcp-fb:/.test(f)&&h[I+1]&&!/^a=rtcp-fb:/.test(h[I+1])&&f.match(/^a=rtcp-fb:\d+/)&&g.set(I+1,f.match(/^a=rtcp-fb:\d+/)[0]+" rrtr")});for(var b=Se(g),T=0;T<b.length;T++){var k=lt(b[T],2),p=k[0],S=k[1];h.splice(p+T,0,S)}return h.join(`\r
`)}},{key:"addSPSDescription",value:function(u){var h=sn(u);return h.media.forEach(function(g){g.type===q&&g.fmtp.forEach(function(b){b.config+=";sps-pps-idr-in-keyframe=1"})}),ii(h)}},{key:"removeSDESDescription",value:function(u){var h=["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"],g=sn(u);return g.media.forEach(function(b){b.ext=b.ext.filter(function(T){return!h.includes(T.uri)})}),ii(g)}},{key:"isSubscriptionStateNotChanged",value:function(u,h){return u.getType()===Te?(h==null?void 0:h.audio)===this.subscribeState_.audio&&(h==null?void 0:h.video)===this.subscribeState_.video&&this.isSubscribeSmall(h):u.getType()===Ne?!G(h.video)&&this.subscribeState_.auxiliary===h.video:void 0}},{key:"isSubscribeSmall",value:function(u){return G(u.smallVideo)&&!this.subscribeState_.smallVideo}},{key:"subscribe",value:(a=F(M().mark(function u(h,g){var b,T,k,p,S,f;return M().wrap(function(I){for(;;)switch(I.prev=I.next){case 0:if(I.prev=0,k=g.emitEvent,p=k===void 0||k,S=h.getType(),((b=this.peerConnection_)===null||b===void 0?void 0:b.connectionState)!==UM&&((T=this.peerConnection_)===null||T===void 0?void 0:T.connectionState)!==Jo){I.next=6;break}return I.next=6,this.waitForPeerConnectionConnected();case 6:if(!this.isSubscriptionStateNotChanged(h,g)){I.next=13;break}if(this.peerConnection_){I.next=11;break}return this.initialize(),I.next=11,this.connect();case 11:return p&&G(g.smallVideo)&&this.emitter_.emit(de.STREAM_SUBSCRIBED,{stream:h,result:!0}),I.abrupt("return",h);case 13:if(S===le?(G(g.audio)||(this.subscribeState_.audio=g.audio),G(g.video)||(this.subscribeState_.video=g.video),this.subscribeState_.smallVideo=(g==null?void 0:g.smallVideo)||!1,this.addEventInternal(this.subscribeState_.audio?NS:eh,this.subscribeState_.audio?"subscribe audio":"unsubscribe audio"),this.addEventInternal(this.subscribeState_.video?NS:eh,this.subscribeState_.video?"subscribe video":"unsubscribe video"),this.addEventInternal(this.subscribeState_.smallVideo?oV:sV,this.subscribeState_.smallVideo?"subscribe smallVideo":"unsubscribe smallVideo")):G(g.video)||(this.subscribeState_.auxiliary=g.video),this.log_.info("subscribe ".concat(S," stream with options ").concat(JSON.stringify(g)," current state: ").concat(JSON.stringify(this.subscribeState_))),!this.peerConnection_&&!this.isSDPExchanging_){I.next=23;break}return f=Vl,this.isMainStreamSubscribed||this.isAuxStreamSubscribed||(f=Ul),I.next=20,this.sendSubscription(f);case 20:S===le?(h.updateAudioPlayingState(this.subscribeState_.audio),h.updateVideoPlayingState(this.subscribeState_.video||this.subscribeState_.smallVideo)):h.updateVideoPlayingState(this.subscribeState_.auxiliary),I.next=26;break;case 23:return this.initialize(),I.next=26,this.connect();case 26:return p&&this.emitter_.emit(de.STREAM_SUBSCRIBED,{stream:h,result:!0}),I.abrupt("return",h);case 30:if(I.prev=30,I.t0=I.catch(0),!this.client_.getIsJoined()||!this.isStreamUnpublished(h)){I.next=35;break}throw this.log_.warn("".concat(I.t0.message," ").concat(JSON.stringify(this.trackState_))),new j({code:V.REMOTE_STREAM_NOT_EXIST,message:"remote user ".concat(this.userId_," unpublished stream")});case 35:throw I.t0;case 36:case"end":return I.stop()}},u,this,[[0,30]])})),function(u,h){return a.apply(this,arguments)})},{key:"checkTrackEnded",value:function(){try{var u=this.peerConnection_.getReceivers().map(function(h){return h.track}).find(function(h){return h.readyState==="ended"});u&&this.currentState_===Ye&&!this.isReconnecting_&&(this.log_.warn("".concat(u.kind," track ended, start reconnect")),this.startReconnection())}catch{}}},{key:"unsubscribe",value:(c=F(M().mark(function u(h){var g,b,T;return M().wrap(function(k){for(;;)switch(k.prev=k.next){case 0:if((g=h.getType())!==le){k.next=10;break}if(this.isMainStreamSubscribed){k.next=5;break}return this.log_.info("main stream already unsubscribed"),k.abrupt("return",h);case 5:this.subscribeState_.audio=!1,this.subscribeState_.video=!1,this.subscribeState_.smallVideo=!1,k.next=14;break;case 10:if(this.isAuxStreamSubscribed){k.next=13;break}return this.log_.info("auxiliary stream already unsubscribed"),k.abrupt("return",h);case 13:this.subscribeState_.auxiliary=!1;case 14:return b=Ul,(g===Te&&this.isAuxStreamSubscribed||g===Ne&&this.isMainStreamSubscribed)&&(b=Vl),this.log_.info("unsubscribe ".concat(g," stream with ").concat(JSON.stringify(this.subscribeState_))),k.next=19,this.sendSubscription(b);case 19:return h.updateVideoPlayingState(!1),h.updateAudioPlayingState(!1),b===Ul&&((T=h.getMediaStream())&&T.getTracks().forEach(function(p){return T.removeTrack(p)}),this.closePeerConnection(),this.emitConnectionStateChangedEvent(Xe)),this.addEventInternal(eh,"unsubscribe audio"),this.addEventInternal(LU,"unsubscribe video"),k.abrupt("return",h);case 25:case"end":return k.stop()}},u,this)})),function(u){return c.apply(this,arguments)})},{key:"sendSubscription",value:function(u){var h=this,g={srcTinyId:this.tinyId_,srcUserId:this.userId_},b=gU,T=pe.UNSUBSCRIBE_RESULT;return u===Vl&&(g={audio:this.subscribeState_.audio,bigVideo:this.subscribeState_.video,auxVideo:this.subscribeState_.auxiliary,smallVideo:this.subscribeState_.smallVideo,srcTinyId:this.tinyId_},b=yU,T=pe.SUBSCRIBE_CHANGE_RESULT),this.signalChannel_.sendWaitForResponse({command:b,data:g,responseCommand:T,timeout:1e4}).then(function(k){var p=k.data;if(p.code!==0){var S=new j({code:p.code,message:H({key:pN,data:{type:u,message:p.message}})});throw h.log_.error(S),S}})}},{key:"connect",value:(o=F(M().mark(function u(){return M().wrap(function(h){for(;;)switch(h.prev=h.next){case 0:return h.prev=0,h.next=3,this.exchangeSDP();case 3:return h.next=5,this.waitForPeerConnectionConnected();case 5:h.next=11;break;case 7:throw h.prev=7,h.t0=h.catch(0),this.closePeerConnection(!0),h.t0;case 11:case"end":return h.stop()}},u,this,[[0,7]])})),function(){return o.apply(this,arguments)})},{key:"exchangeSDP",value:(r=F(M().mark(function u(){var h,g,b,T,k,p;return M().wrap(function(S){for(;;)switch(S.prev=S.next){case 0:return S.prev=0,this.isSDPExchanging_=!0,S.next=4,this.createOffer();case 4:return this.log_.info("createOffer success, sending offer to remote server"),h=this.peerConnection_.localDescription,g=h.type,b=h.sdp,T={type:g,sdp:b,srcUserId:this.userId_,srcTinyId:this.tinyId_,audio:this.subscribeState_.audio,bigVideo:this.subscribeState_.video,auxVideo:this.subscribeState_.auxiliary,smallVideo:this.subscribeState_.smallVideo},U.emit(Gd,{client:this.client_,connection:this,userId:this.userId_,tinyId:this.tinyId_,role:Jr,subscribeState:this.subscribeState_,trackState:this.trackState_}),S.next=10,this.signalChannel_.sendWaitForResponse({command:vU,commandDesc:"exchange sdp",data:T,responseCommand:pe.SUBSCRIBE_RESULT,timeout:1e4});case 10:if(k=S.sent,this.peerConnection_){S.next=15;break}throw p=new j({code:V.INVALID_OPERATION,message:H({key:NL})}),this.log_.warn(p),p;case 15:return S.next=17,this.onSubscribeResult(k);case 17:this.isSDPExchanging_=!1,S.next=24;break;case 20:throw S.prev=20,S.t0=S.catch(0),this.isSDPExchanging_=!1,S.t0;case 24:case"end":return S.stop()}},u,this,[[0,20]])})),function(){return r.apply(this,arguments)})},{key:"createOffer",value:(i=F(M().mark(function u(){var h,g;return M().wrap(function(b){for(;;)switch(b.prev=b.next){case 0:return h={voiceActivityDetection:!1},_s()&&this.sdpSemantics_===sa?(this.peerConnection_.addTransceiver(K,{direction:"recvonly"}),this.peerConnection_.addTransceiver(q,{direction:"recvonly"}),this.peerConnection_.addTransceiver(q,{direction:"recvonly"})):(h.offerToReceiveAudio=!0,h.offerToReceiveVideo=!0),b.next=4,this.peerConnection_.createOffer(h);case 4:return g=b.sent,b.next=7,YS();case 7:return b.sent.isH264DecodeSupported||(this.log_.warn("remove h264 desc from sdp"),g.sdp=(T=g.sdp,k=void 0,(k=sn(T)).media.forEach(function(p){if(p.type===q){var S=new Set;p.rtp.forEach(function(I){var A=I.payload;return I.codec==="H264"&&S.add(A)}),p.fmtp.forEach(function(I){var A=I.payload,x=I.config.match(/apt=(\d+)/);x&&x[1]&&S.has(Number(x[1]))&&S.add(A)});var f=function(I){var A=I.payload;return!S.has(A)};p.rtp=p.rtp.filter(f),p.rtcpFb=p.rtcpFb.filter(f),p.fmtp=p.fmtp.filter(f),p.payloads=p.payloads.split(" ").filter(function(I){return!S.has(Number(I))}).join(" ")}}),ii(k))),g.sdp=this.addRRTRLine(g.sdp),g.sdp=this.addSPSDescription(g.sdp),g.sdp=DV(g.sdp),this.sdpSemantics_===sa&&(g.sdp=this.removeSDESDescription(g.sdp)),b.next=16,this.peerConnection_.setLocalDescription(g);case 16:case"end":return b.stop()}var T,k},u,this)})),function(){return i.apply(this,arguments)})},{key:"onSubscribeResult",value:(n=F(M().mark(function u(h){var g,b,T,k,p,S,f,I=this;return M().wrap(function(A){for(;;)switch(A.prev=A.next){case 0:if(g=h&&h.data||{},b=g.code,T=g.message,k=T===void 0?"":T,p=h&&h.data&&h.data.data||{},S=p.type,f=p.sdp,b!==77393){A.next=5;break}throw this.log_.error(En.NOT_SUPPORTED_H264DECODE),new j({code:V.NOT_SUPPORTED_H264,message:H({key:Dy})});case 5:if(A.prev=5,b===0){A.next=8;break}throw new j({code:b,message:H({key:_N,data:{errMsg:k}})});case 8:return this.log_.debug("accept remote answer: "+f),A.next=11,this.peerConnection_.setRemoteDescription({type:S,sdp:f});case 11:this.sei_&&(this.sei_.handleEncodedStreams(),this.sei_.onSEIMessage=function(x){I.emitter_.emit(de.SEI_MESSAGE,te(te({},x),{},{userId:I.userId_}))}),this.updateSSRC(f),A.next=19;break;case 15:throw A.prev=15,A.t0=A.catch(5),this.log_.error(A.t0),A.t0;case 19:case"end":return A.stop()}},u,this,[[5,15]])})),function(u){return n.apply(this,arguments)})},{key:"updateSSRC",value:function(u){var h=this;try{sn(u).media.forEach(function(g){if(g.type===K){var b=g.ssrcs.find(function(p){return p.value.includes(Gt)});b&&(h.ssrc_.audio=b.id)}else{var T=g.ssrcs.find(function(p){return p.value.includes(Gt)}),k=g.ssrcs.find(function(p){return p.value.includes(aa)});T&&(h.ssrc_.video=T.id),k&&(h.ssrc_.auxiliary=k.id)}})}catch{}}},{key:"setRemoteStream",value:function(u,h){this.remoteStreams_.set(u,h)}},{key:"getSubscribeState",value:function(){return this.subscribeState_}},{key:"getTrackState",value:function(){return this.trackState_}},{key:"getSSRC",value:function(){return this.ssrc_}},{key:"getMainStream",value:function(){return this.remoteStreams_.get(Gt)}},{key:"getAuxStream",value:function(){return this.remoteStreams_.get(aa)}},{key:"getMainStreamVideoTrackId",value:function(){var u=this.getMainStream();if(u){var h=u.getVideoTrack();if(h)return h.id}return""}},{key:"getAuxStreamVideoTrackId",value:function(){var u=this.getAuxStream();if(u){var h=u.getVideoTrack();if(h)return h.id}return""}},{key:"reconnect",value:(t=F(M().mark(function u(){var h,g,b=this;return M().wrap(function(T){for(;;)switch(T.prev=T.next){case 0:if(this.reconnectionTimer_===-1){T.next=3;break}return this.log_.warn("reconnect() downlink is reconnecting, ignore current reconnection"),T.abrupt("return");case 3:if(!(this.reconnectionCount_>=30)){T.next=12;break}return this.log_.warn("SDK has tried reconnect downlink [".concat(this.userId_,"] for ").concat(30," times, but all failed, please check your network")),this.stopReconnection(),h=new j({code:V.DOWNLINK_RECONNECTION_FAILED,message:H({key:mN})}),J.logFailedEvent({userId:this.client_.getUserId(),eventType:Jg,error:h}),this.addEventInternal(aV,"downlink-connection reconnect fail"),this.emitConnectionStateChangedEvent(Xe),this.emitter_.emit(de.ERROR,h),T.abrupt("return");case 12:if(this.signalChannel_.getCurrentState()===_a){T.next=16;break}return this.log_.warn("reconnect() signal channel is not connected, suspend reconnection until signal is connected"),this.signalChannel_.once(ma,this.reconnect,this),T.abrupt("return");case 16:if(this.reconnectionCount_++,this.log_.warn("reconnect() try to reconnect downlink [".concat(this.reconnectionCount_,"/").concat(30,"]")),g=gd(this.reconnectionCount_),this.reconnectionTimer_=setTimeout(function(){b.log_.warn("reconnect() downlink [".concat(b.userId_,"] reconnect timeout(").concat(g/1e3,"s), try again")),b.clearReconnectionTimer(),b.reconnect()},g),!(this.isSDPExchanging_||this.peerConnection_&&this.peerConnection_.connectionState===Jo)){T.next=22;break}return T.abrupt("return");case 22:return T.prev=22,this.closePeerConnection(),this.initialize(),T.next=27,this.connect();case 27:this.stopReconnection(),this.log_.warn("reconnect() downlink reconnect successfully"),J.logSuccessEvent({userId:this.client_.getUserId(),eventType:Jg}),this.addEventInternal(iV,"downlink-connection reconnect success"),this.recoverSubscription(),T.next=36;break;case 34:T.prev=34,T.t0=T.catch(22);case 36:case"end":return T.stop()}},u,this,[[22,34]])})),function(){return t.apply(this,arguments)})},{key:"recoverSubscription",value:function(){var u=this,h=this.client_.getSubscriptionManager();h&&Se(this.remoteStreams_.values()).forEach(function(g){h.hasAutoRecoveryFlag(u.userId_,g.getType())&&h.recover(g)})}},{key:"getIsReconnecting",value:function(){return this.isReconnecting_}},{key:"getSubscribedMainStream",value:function(){var u=null;return this.isMainStreamSubscribed&&(u=this.remoteStreams_.get(Gt)),u}},{key:"clearReconnectionTimer",value:function(){this.reconnectionTimer_!==-1&&(clearTimeout(this.reconnectionTimer_),this.reconnectionTimer_=-1)}},{key:"startReconnection",value:function(){var u=this.client_.getSubscriptionManager();if(u){var h,g=qt(this.remoteStreams_.values());try{for(g.s();!(h=g.n()).done;){var b=h.value,T=b.getType();(T===Te&&(this.trackState_.audio||this.trackState_.video)||T===Ne&&this.trackState_.auxiliary)&&u.setAutoRecoveryFlag(this.userId_,b.getType())}}catch(k){g.e(k)}finally{g.f()}}Re(ve(l.prototype),"startReconnection",this).call(this)}},{key:"getCurrentState",value:function(){return this.currentState_}},{key:"hasMainStream",value:function(){return this.trackState_.video||this.trackState_.audio||this.trackState_.smallVideo}},{key:"hasAuxStream",value:function(){return this.trackState_.auxiliary}}]),l}(Pp),ie(Nt.prototype,"subscribe",[bI,kI],Object.getOwnPropertyDescriptor(Nt.prototype,"subscribe"),Nt.prototype),ie(Nt.prototype,"unsubscribe",[II],Object.getOwnPropertyDescriptor(Nt.prototype,"unsubscribe"),Nt.prototype),ie(Nt.prototype,"exchangeSDP",[TI],Object.getOwnPropertyDescriptor(Nt.prototype,"exchangeSDP"),Nt.prototype),Nt),oc=function(){function e(){ce(this,e),this.startTime=0,this.endTime=0,this.start()}return ue(e,[{key:"start",value:function(){this.startTime===0&&(this.startTime=De())}},{key:"stop",value:function(){this.endTime===0&&(this.endTime=De())}},{key:"getDuration",value:function(){return this.endTime===0?De()-this.startTime:this.endTime-this.startTime}}]),e}(),z8=function(){function e(r){ce(this,e),this.client_=r.client,this.intervalId_=-1,this.statsCalculator_=r.stats,this.prevStats_=null,this.renderFreezeMap_=new Map,this.remoteStreamMap_=new Map,this.dataFreezeMap_=new Map,this.monitorFreezeData_=new Map}var t,n,i;return ue(e,[{key:"installEvents",value:function(){U.on(Fd,this.handlePlayVideoStart,this),U.on(ha,this.onVideoTrackMuted,this),U.on(Ud,this.onVideoTrackUnmuted,this),U.on(cr,this.handleStreamStopped,this),U.on(rn,this.handleStreamStopped,this),U.on(da,this.handleVideoPlaying,this)}},{key:"uninstallEvents",value:function(){U.off(Fd,this.handlePlayVideoStart,this),U.off(ha,this.onVideoTrackMuted,this),U.off(Ud,this.onVideoTrackUnmuted,this),U.off(cr,this.handleStreamStopped,this),U.off(rn,this.handleStreamStopped,this),U.off(da,this.handleVideoPlaying,this)}},{key:"start",value:function(){var r=this;this.intervalId_===-1&&(this.installEvents(),this.intervalId_=ye.run(F(M().mark(function o(){return M().wrap(function(c){for(;;)switch(c.prev=c.next){case 0:return c.prev=0,c.next=3,r.detectFPS();case 3:c.next=7;break;case 5:c.prev=5,c.t0=c.catch(0);case 7:case"end":return c.stop()}},o,null,[[0,5]])})),{delay:1e3}))}},{key:"stop",value:function(){this.intervalId_!==-1&&(this.uninstallEvents(),ye.clearTask(this.intervalId_),this.intervalId_=-1,this.renderFreezeMap_.clear(),this.dataFreezeMap_.clear(),this.remoteStreamMap_.clear())}},{key:"onVideoTrackMuted",value:function(r){var o=r.stream;if(o.getClient()===this.client_&&o.isRemote()){var c=o.userId_,a=o.type_,s="".concat(c,"_").concat(a),l=this.dataFreezeMap_.get(s),u=new oc;l?l.durationItemList.push(u):this.dataFreezeMap_.set(s,{userId:c,type:a,durationItemList:[u],isFreezing:function(){var h=this.durationItemList[this.durationItemList.length-1];return h&&h.endTime===0}})}}},{key:"onVideoTrackUnmuted",value:function(r){var o=r.stream;if(o.getClient()===this.client_&&o.isRemote()){var c=o.userId_,a=o.type_,s="".concat(c,"_").concat(a);this.stopDataFreeze({key:s,userId:c,type:a})}}},{key:"handleStreamStopped",value:function(r){var o=r.client,c=r.stream;if(o===this.client_){var a=c.getUserId(),s=c.getType(),l="".concat(a,"_").concat(s);this.stopDataFreeze({key:l,userId:a,type:s})}}},{key:"stopDataFreeze",value:function(r){var o=r.key,c=r.userId,a=r.type,s=this.dataFreezeMap_.get(o);if(s&&s.isFreezing()){var l=s.durationItemList[s.durationItemList.length-1];l.stop();var u=l.getDuration();u>500?(J.logEvent({eventType:"videoFrozenCount",delta:u}),this.monitorFreezeData_.set(o,{userId:c,type:a,duration:u})):s.durationItemList.pop()}}},{key:"getTotalDuration",value:function(r){return r.reduce(function(o,c){var a=c.getDuration();return o+Math.min(a,5e3)},0)}},{key:"getStats",value:(i=F(M().mark(function r(){var o,c,a,s,l,u,h,g,b,T,k;return M().wrap(function(p){for(;;)switch(p.prev=p.next){case 0:o=this.client_.getConnections(),c={},a=qt(o),p.prev=3,a.s();case 5:if((s=a.n()).done){p.next=20;break}if(l=lt(s.value,2),u=l[0],(h=l[1]).getPeerConnection()){p.next=9;break}return p.abrupt("continue",18);case 9:return g=h.getSubscribeState(),b=h.getTrackState(),p.next=13,this.statsCalculator_.getReceiverStats(h);case 13:T=p.sent,(k={userId:T.userId,tinyId:u,hasVideo:b.video&&g.video,hasAuxiliary:b.auxiliary&&g.auxiliary,video:{framesDecoded:0},auxiliary:{framesDecoded:0}}).hasVideo&&(k.video.framesDecoded=T.video.framesDecoded),k.hasAuxiliary&&(k.auxiliary.framesDecoded=T.auxiliary.framesDecoded),c[T.userId]=k;case 18:p.next=5;break;case 20:p.next=25;break;case 22:p.prev=22,p.t0=p.catch(3),a.e(p.t0);case 25:return p.prev=25,a.f(),p.finish(25);case 28:return p.abrupt("return",c);case 29:case"end":return p.stop()}},r,this,[[3,22,25,28]])})),function(){return i.apply(this,arguments)})},{key:"detectFPS",value:(n=F(M().mark(function r(){var o,c,a,s,l,u;return M().wrap(function(h){for(;;)switch(h.prev=h.next){case 0:return h.next=2,this.getStats();case 2:if(o=h.sent,this.prevStats_){h.next=6;break}return this.prevStats_=o,h.abrupt("return");case 6:h.t0=M().keys(o);case 7:if((h.t1=h.t0()).done){h.next=17;break}if(c=h.t1.value,this.prevStats_[c]){h.next=11;break}return h.abrupt("continue",7);case 11:a=o[c].tinyId,s=this.client_.getMutedStates(),o[c].hasVideo&&this.prevStats_[c].hasVideo&&s.has(a)&&!s.get(a).videoMuted&&(l=o[c].video.framesDecoded-this.prevStats_[c].video.framesDecoded,this.handleRenderFreeze({userId:c,type:Te,fps:l})),o[c].hasAuxiliary&&this.prevStats_[c].hasAuxiliary&&(u=o[c].auxiliary.framesDecoded-this.prevStats_[c].auxiliary.framesDecoded,this.handleRenderFreeze({userId:c,type:Ne,fps:u})),h.next=7;break;case 17:this.prevStats_=o;case 18:case"end":return h.stop()}},r,this)})),function(){return n.apply(this,arguments)})},{key:"handleRenderFreeze",value:(t=F(M().mark(function r(o){var c,a,s,l,u,h,g,b;return M().wrap(function(T){for(;;)switch(T.prev=T.next){case 0:c=o.userId,a=o.fps,s=o.type,l="".concat(c,"_").concat(s),u=this.renderFreezeMap_.get(l),a<=2?(h=De(),u&&!u.isFreeze&&(u.freezeTimeline.push({startTime:h,endTime:void 0}),u.isFreeze=!0),u||this.renderFreezeMap_.set(l,{userId:c,type:s,isFreeze:!0,freezeTimeline:[{startTime:h,endTime:void 0}],renderFreezeTotal:0})):u&&u.isFreeze&&(u.isFreeze=!1,(g=u.freezeTimeline.pop()).endTime=De(),b=g.endTime-g.startTime,u.freezeTimeline.push(g),u.renderFreezeTotal+=Math.min(5e3,b));case 4:case"end":return T.stop()}},r,this)})),function(r){return t.apply(this,arguments)})},{key:"handlePlayVideoStart",value:function(r){var o=r.stream;if(o.getClient()===this.client_&&o.isRemote()&&o.hasVideo()){var c="".concat(o.getUserId(),"_").concat(o.getType());this.remoteStreamMap_.has(c)||this.remoteStreamMap_.set(c,{isPlayingFired:!1})}}},{key:"handleVideoPlaying",value:function(r){var o=r.stream;if(o.isRemote()&&o.getClient()===this.client_){var c="".concat(o.getUserId(),"_").concat(o.getType());this.remoteStreamMap_.has(c)&&(this.remoteStreamMap_.get(c).isPlayingFired=!0)}}},{key:"getDataFreezeDuration",value:function(r){var o={dataFreeze:0,count:0},c=this.dataFreezeMap_.get(r);if(c){if(c.isFreezing()){var a=c.durationItemList[c.durationItemList.length-1];a.stop(),a.getDuration()<500&&c.durationItemList.pop()}o.dataFreeze=this.getTotalDuration(c.durationItemList),o.count=c.durationItemList.length}return o}},{key:"getRenderFreezeDuration",value:function(r){var o=this.renderFreezeMap_.get(r),c=0,a=0;if(o)if(o.isFreeze){var s=De()-o.freezeTimeline[o.freezeTimeline.length-1].startTime;c=o.renderFreezeTotal+Math.min(s,5e3),a=o.freezeTimeline.length}else c=o.renderFreezeTotal;return{renderFreeze:c,count:a}}},{key:"getMonitorFreeze",value:function(){return this.monitorFreezeData_}},{key:"isBlackStream",value:function(r){return!!this.remoteStreamMap_.has(r)&&!this.remoteStreamMap_.get(r).isPlayingFired}},{key:"resetMonitor",value:function(){this.monitorFreezeData_.clear()}}]),e}(),Hp=ue(function e(t){ce(this,e),this.userId=t.userId,this.tinyId=t.tinyId,this.role=t.role===Jr?Wt:er}),EI={exports:{}};(function(e){(function(t){function n(p,S){var f=(65535&p)+(65535&S);return(p>>16)+(S>>16)+(f>>16)<<16|65535&f}function i(p,S,f,I,A,x){return n((D=n(n(S,p),n(I,x)))<<(m=A)|D>>>32-m,f);var D,m}function r(p,S,f,I,A,x,D){return i(S&f|~S&I,p,S,A,x,D)}function o(p,S,f,I,A,x,D){return i(S&I|f&~I,p,S,A,x,D)}function c(p,S,f,I,A,x,D){return i(S^f^I,p,S,A,x,D)}function a(p,S,f,I,A,x,D){return i(f^(S|~I),p,S,A,x,D)}function s(p,S){var f,I,A,x,D;p[S>>5]|=128<<S%32,p[14+(S+64>>>9<<4)]=S;var m=1732584193,v=-271733879,w=-1732584194,R=271733878;for(f=0;f<p.length;f+=16)I=m,A=v,x=w,D=R,m=r(m,v,w,R,p[f],7,-680876936),R=r(R,m,v,w,p[f+1],12,-389564586),w=r(w,R,m,v,p[f+2],17,606105819),v=r(v,w,R,m,p[f+3],22,-1044525330),m=r(m,v,w,R,p[f+4],7,-176418897),R=r(R,m,v,w,p[f+5],12,1200080426),w=r(w,R,m,v,p[f+6],17,-1473231341),v=r(v,w,R,m,p[f+7],22,-45705983),m=r(m,v,w,R,p[f+8],7,1770035416),R=r(R,m,v,w,p[f+9],12,-1958414417),w=r(w,R,m,v,p[f+10],17,-42063),v=r(v,w,R,m,p[f+11],22,-1990404162),m=r(m,v,w,R,p[f+12],7,1804603682),R=r(R,m,v,w,p[f+13],12,-40341101),w=r(w,R,m,v,p[f+14],17,-1502002290),m=o(m,v=r(v,w,R,m,p[f+15],22,1236535329),w,R,p[f+1],5,-165796510),R=o(R,m,v,w,p[f+6],9,-1069501632),w=o(w,R,m,v,p[f+11],14,643717713),v=o(v,w,R,m,p[f],20,-373897302),m=o(m,v,w,R,p[f+5],5,-701558691),R=o(R,m,v,w,p[f+10],9,38016083),w=o(w,R,m,v,p[f+15],14,-660478335),v=o(v,w,R,m,p[f+4],20,-405537848),m=o(m,v,w,R,p[f+9],5,568446438),R=o(R,m,v,w,p[f+14],9,-1019803690),w=o(w,R,m,v,p[f+3],14,-187363961),v=o(v,w,R,m,p[f+8],20,1163531501),m=o(m,v,w,R,p[f+13],5,-1444681467),R=o(R,m,v,w,p[f+2],9,-51403784),w=o(w,R,m,v,p[f+7],14,1735328473),m=c(m,v=o(v,w,R,m,p[f+12],20,-1926607734),w,R,p[f+5],4,-378558),R=c(R,m,v,w,p[f+8],11,-2022574463),w=c(w,R,m,v,p[f+11],16,1839030562),v=c(v,w,R,m,p[f+14],23,-35309556),m=c(m,v,w,R,p[f+1],4,-1530992060),R=c(R,m,v,w,p[f+4],11,1272893353),w=c(w,R,m,v,p[f+7],16,-155497632),v=c(v,w,R,m,p[f+10],23,-1094730640),m=c(m,v,w,R,p[f+13],4,681279174),R=c(R,m,v,w,p[f],11,-358537222),w=c(w,R,m,v,p[f+3],16,-722521979),v=c(v,w,R,m,p[f+6],23,76029189),m=c(m,v,w,R,p[f+9],4,-640364487),R=c(R,m,v,w,p[f+12],11,-421815835),w=c(w,R,m,v,p[f+15],16,530742520),m=a(m,v=c(v,w,R,m,p[f+2],23,-995338651),w,R,p[f],6,-198630844),R=a(R,m,v,w,p[f+7],10,1126891415),w=a(w,R,m,v,p[f+14],15,-1416354905),v=a(v,w,R,m,p[f+5],21,-57434055),m=a(m,v,w,R,p[f+12],6,1700485571),R=a(R,m,v,w,p[f+3],10,-1894986606),w=a(w,R,m,v,p[f+10],15,-1051523),v=a(v,w,R,m,p[f+1],21,-2054922799),m=a(m,v,w,R,p[f+8],6,1873313359),R=a(R,m,v,w,p[f+15],10,-30611744),w=a(w,R,m,v,p[f+6],15,-1560198380),v=a(v,w,R,m,p[f+13],21,1309151649),m=a(m,v,w,R,p[f+4],6,-145523070),R=a(R,m,v,w,p[f+11],10,-1120210379),w=a(w,R,m,v,p[f+2],15,718787259),v=a(v,w,R,m,p[f+9],21,-343485551),m=n(m,I),v=n(v,A),w=n(w,x),R=n(R,D);return[m,v,w,R]}function l(p){var S,f="",I=32*p.length;for(S=0;S<I;S+=8)f+=String.fromCharCode(p[S>>5]>>>S%32&255);return f}function u(p){var S,f=[];for(f[(p.length>>2)-1]=void 0,S=0;S<f.length;S+=1)f[S]=0;var I=8*p.length;for(S=0;S<I;S+=8)f[S>>5]|=(255&p.charCodeAt(S/8))<<S%32;return f}function h(p){var S,f,I="0123456789abcdef",A="";for(f=0;f<p.length;f+=1)S=p.charCodeAt(f),A+=I.charAt(S>>>4&15)+I.charAt(15&S);return A}function g(p){return unescape(encodeURIComponent(p))}function b(p){return function(S){return l(s(u(S),8*S.length))}(g(p))}function T(p,S){return function(f,I){var A,x,D=u(f),m=[],v=[];for(m[15]=v[15]=void 0,D.length>16&&(D=s(D,8*f.length)),A=0;A<16;A+=1)m[A]=909522486^D[A],v[A]=1549556828^D[A];return x=s(m.concat(u(I)),512+8*I.length),l(s(v.concat(x),640))}(g(p),g(S))}function k(p,S,f){return S?f?T(S,p):h(T(S,p)):f?b(p):h(b(p))}e.exports?e.exports=k:t.md5=k})(gc)})(EI);var RI,CI,Fn,sc=EI.exports,J8=function(){function e(o){ce(this,e),this.client_=o.client,this.signalChannel_=o.signalChannel,this.log_=z.createLogger({id:"mix|"+this.client_.getUserId(),userId:o.client.getUserId(),sdkAppId:o.client.getSDKAppId()}),this.isMixing_=!1,this.config_=null,this.data_=null,this.remoteStreamMap_=new Map,this.installEvents()}var t,n,i,r;return ue(e,[{key:"isPresetLayoutMode",get:function(){return this.config_&&this.config_.mode===Fl.PRESET_LAYOUT}},{key:"installEvents",value:function(){U.on(nn,this.onStreamSubscribed,this),U.on(rn,this.onStreamUnsubscribed,this),this.client_.on("stream-removed",this.onStreamRemoved,this)}},{key:"uninstallEvents",value:function(){U.off(nn,this.onStreamSubscribed,this),U.off(rn,this.onStreamUnsubscribed,this),this.client_.off("stream-removed",this.onStreamRemoved,this)}},{key:"reset",value:function(){this.uninstallEvents(),this.isMixing_=!1,this.config_=null}},{key:"onStreamSubscribed",value:function(o){var c=o.client,a=o.stream;c===this.client_&&(this.remoteStreamMap_.set(a.getId(),{remoteStream:a,isUsed:!1}),this.isMixing_&&this.hasAvailablePlaceHolder()&&this.startMixTranscode(this.config_))}},{key:"onStreamUnsubscribed",value:function(o){var c=o.client,a=o.stream;c===this.client_&&this.onStreamRemoved({stream:a})}},{key:"onStreamRemoved",value:function(o){var c=o.stream;if(this.remoteStreamMap_.has(c.getId())){var a=this.remoteStreamMap_.get(c.getId()).isUsed;this.remoteStreamMap_.delete(c.getId()),this.isMixing_&&this.isPresetLayoutMode&&a&&this.startMixTranscode(this.config_)}}},{key:"startMixTranscode",value:(r=F(M().mark(function o(c){var a,s,l;return M().wrap(function(u){for(;;)switch(u.prev=u.next){case 0:if(u.prev=0,this.resetIsUsedFlag(),this.config_=c,a=this.getInputParam(c,this.remoteStreamMap_),s=this.getOutputParam(c),l=this.getOutputSessionId({config:c,roomId:this.client_.getRoomId(),userId:this.client_.getUserId()}),!this.isMixing_||!this.data_||l===this.data_.outputSessionId){u.next=10;break}return this.log_.info("startMixTranscode() streamId changed, stop mixing before start"),u.next=10,this.doStopMixTranscode();case 10:return u.next=12,this.doStartMixTranscode({outputSessionId:l,inputParam:a,outputParam:s});case 12:u.next=18;break;case 14:throw u.prev=14,u.t0=u.catch(0),this.resetIsUsedFlag(),u.t0;case 18:case"end":return u.stop()}},o,this,[[0,14]])})),function(o){return r.apply(this,arguments)})},{key:"doStartMixTranscode",value:(i=F(M().mark(function o(c){var a,s,l,u,h,g,b,T;return M().wrap(function(k){for(;;)switch(k.prev=k.next){case 0:return a=c.outputSessionId,s=c.inputParam,l=c.outputParam,u={roomId:String(this.client_.getRoomId()),mcuRequestTime:Date.now(),outputSessionId:a,inputParam:s,outputParam:l},this.data_=u,this.log_.info("startMixTranscode: ".concat(JSON.stringify(u))),this.isMixing_=!0,k.prev=5,k.next=8,this.signalChannel_.sendWaitForResponse({command:TU,data:u,timeout:5e3,responseCommand:pe.START_MIX_TRANSCODE_RES,commandDesc:"startMixTranscode"});case 8:if(h=k.sent,g=h.data,b=g.code,T=g.message,b===0){k.next=15;break}throw b===-102083&&(T="Please enable relayed-push in ".concat(hy," and try later, refer to ").concat(zl,"tutorial-26-advanced-publish-cdn-stream.html")),this.log_.error("startMixTranscode failed, errCode: ".concat(b," errMsg: ").concat(T)),this.isMixing_=!1,new j({code:V.START_MIX_TRANSCODE_FAILED,message:H({key:dL,data:{message:T},link:{className:"Client",fnName:"startMixTranscode"}})});case 15:k.next=21;break;case 17:throw k.prev=17,k.t0=k.catch(5),this.isMixing_=!1,k.t0;case 21:case"end":return k.stop()}},o,this,[[5,17]])})),function(o){return i.apply(this,arguments)})},{key:"reStartMixTranscode",value:function(){this.isMixing_&&this.startMixTranscode(this.config_)}},{key:"stopMixTranscode",value:(n=F(M().mark(function o(){return M().wrap(function(c){for(;;)switch(c.prev=c.next){case 0:if(this.isMixing_){c.next=2;break}throw new j({code:V.INVALID_OPERATION,message:H({key:pL})});case 2:return c.next=4,this.doStopMixTranscode();case 4:this.resetIsUsedFlag();case 5:case"end":return c.stop()}},o,this)})),function(){return n.apply(this,arguments)})},{key:"doStopMixTranscode",value:(t=F(M().mark(function o(){var c,a,s,l,u;return M().wrap(function(h){for(;;)switch(h.prev=h.next){case 0:return c={mcuRequestTime:Date.now(),outputSessionId:this.data_.outputSessionId,streamType:this.data_.outputParam.streamType},this.log_.info("stopMixTranscode: ".concat(JSON.stringify(c))),h.next=4,this.signalChannel_.sendWaitForResponse({command:wU,data:c,timeout:5e3,responseCommand:pe.STOP_MIX_TRANSCODE_RES,commandDesc:"stopMixTranscode"});case 4:if(a=h.sent,s=a.data,l=s.code,u=s.message,l!==0){h.next=10;break}this.isMixing_=!1,h.next=12;break;case 10:throw this.log_.error("stopMixTranscode failed, errCode: ".concat(l," errMsg: ").concat(u)),new j({code:V.STOP_MIX_TRANSCODE_FAILED,message:H({key:hL,data:{message:u},link:{className:"Client",fnName:"stopMixTranscode"}})});case 12:case"end":return h.stop()}},o,this)})),function(){return t.apply(this,arguments)})},{key:"getOutputSessionId",value:function(o){var c=o.config,a=o.userId,s=o.roomId;return je(c.streamId)&&c.streamId.length>0?c.streamId:sc("".concat(s,"_").concat(a,"_main"))}},{key:"getInputParam",value:function(o,c){var a=this,s=o.mixUsers.map(function(l){return{userId:l.userId,roomId:String(l.roomId||a.client_.getRoomId()),width:l.width||0,height:l.height||0,locationX:l.locationX||0,locationY:l.locationY||0,zOrder:l.zOrder,streamType:G(l.streamType)||l.streamType!==Ne?0:1,inputType:l.pureAudio?ry.IT_PURE_AUDIO:ry.IT_AUDIO_VIDEO,renderMode:l.renderMode||0}});return o.mode===Fl.PRESET_LAYOUT&&(s.forEach(function(l){if(l.userId===ny.REMOTE){var u=Se(c.values()).find(function(h){return!h.isUsed});u&&(l.userId=u.remoteStream.getUserId(),l.streamType=u.remoteStream.getType()===Ne?1:0,u.isUsed=!0)}}),s=s.filter(function(l){return l.userId!==ny.REMOTE})),s}},{key:"getOutputParam",value:function(o){var c=o.streamId||"";return{streamId:c,streamType:c.length>0?1:0,width:G(o.videoWidth)?640:o.videoWidth,height:G(o.videoHeight)?480:o.videoHeight,videoBps:o.videoBitrate||0,fps:o.videoFramerate||15,gop:o.videoGOP||2,audioSampleRate:o.audioSampleRate||48e3,audioBps:o.audioBitrate||64,audioChannels:o.audioChannels||1,backgroundColor:o.backgroundColor||0,backgroundImg:o.backgroundImage||"",extraInfo:"",videoCodec:2,audioCodec:0}}},{key:"hasAvailablePlaceHolder",value:function(){return!!this.isPresetLayoutMode&&this.data_.inputParam.length!==this.config_.mixUsers.length}},{key:"resetIsUsedFlag",value:function(){this.remoteStreamMap_.forEach(function(o){return o.isUsed=!1})}}]),e}(),q8=function(){function e(a){ce(this,e),this.client_=a.client,this.signalChannel_=a.signalChannel,this.publishTencentMainStreamObj_={params_:null,streamId_:void 0,isPublishing_:!1},this.publishTencentAuxStreamObj_={params_:null,streamId_:void 0,isPublishing_:!1},this.publishGivenCDNData_=null,this.isPublishingGivenCDN_=!1}var t,n,i,r,o,c;return ue(e,[{key:"setSignalChannel",value:function(a){this.signalChannel_=a.signalChannel}},{key:"getIsPublishingTencentCDN",value:function(){return this.publishTencentMainStreamObj_.isPublishing_||this.publishTencentAuxStreamObj_.isPublishing_}},{key:"getIsPublishingGivenCDN",value:function(){return this.isPublishingGivenCDN_}},{key:"generatePublishCDNStreamId",value:function(a,s){if(!a){var l="".concat(this.client_.getRoomId(),"_").concat(this.client_.getUserId(),"_").concat(s);return/^[A-Za-z\d_-]*$/.test(l)||(l=sc(l)),"".concat(this.client_.getSDKAppId(),"_").concat(l)}return a}},{key:"generatePublishCDNSessionId",value:function(a){return sc("".concat(this.client_.getRoomId(),"_").concat(this.client_.getUserId(),"_").concat(a))}},{key:"startPublishTencentCDN",value:(c=F(M().mark(function a(s){var l,u,h,g;return M().wrap(function(b){for(;;)switch(b.prev=b.next){case 0:if(s.streamType===ht?(this.publishTencentAuxStreamObj_.params_=s,this.publishTencentAuxStreamObj_.isPublishing_=!0):(this.publishTencentMainStreamObj_.params_=s,this.publishTencentMainStreamObj_.isPublishing_=!0),this.client_.isJoined_){b.next=3;break}return b.abrupt("return");case 3:return l=this.generatePublishCDNStreamId(s.streamId,s.streamType),u=this.generatePublishCDNSessionId(s.streamType),h=s.streamType===ht?1:0,g={requestTime:Date.now(),sessionId:u,streamId:l,streamType:h},b.next=9,this.doStartPublishTencentCDN(g,s.streamType);case 9:case"end":return b.stop()}},a,this)})),function(a){return c.apply(this,arguments)})},{key:"doStartPublishTencentCDN",value:(o=F(M().mark(function a(s,l){var u,h,g,b;return M().wrap(function(T){for(;;)switch(T.prev=T.next){case 0:return T.prev=0,z.info("startPublishTencentCDN: "+JSON.stringify(s)),T.next=4,this.signalChannel_.sendWaitForResponseWithRetry({command:SU,data:s,timeout:2e3,responseCommand:pe.START_PUBLISH_TENCENT_CDN_RES,commandDesc:"startPublishCDNStream",retries:2});case 4:if(u=T.sent,h=u.data,g=h.code,b=h.message,g!==0){T.next=10;break}l===ht?this.publishTencentAuxStreamObj_.streamId_=s.streamId:this.publishTencentMainStreamObj_.streamId_=s.streamId,T.next=14;break;case 10:throw l===ht?this.publishTencentAuxStreamObj_.isPublishing_=!1:this.publishTencentMainStreamObj_.isPublishing_=!1,g===-102083&&(b="Please enable relayed-push in ".concat(hy," and try later, refer to ").concat(zl,"tutorial-26-advanced-publish-cdn-stream.html")),z.error("startPublishTencentCDN failed, errCode: ".concat(g,", errMsg: ").concat(b)),new j({code:V.START_PUBLISH_CDN_FAILED,message:H({key:wy,data:{message:b},link:{className:"Client",fnName:"startPublishCDNStream"}})});case 14:T.next=20;break;case 16:throw T.prev=16,T.t0=T.catch(0),l===ht?this.publishTencentAuxStreamObj_.isPublishing_=!1:this.publishTencentMainStreamObj_.isPublishing_=!1,T.t0;case 20:case"end":return T.stop()}},a,this,[[0,16]])})),function(a,s){return o.apply(this,arguments)})},{key:"resetPublishTencentParam",value:function(a){a===le&&(this.publishTencentMainStreamObj_={params_:null,streamId_:void 0,isPublishing_:!1}),a===ht&&(this.publishTencentAuxStreamObj_={params_:null,streamId_:void 0,isPublishing_:!1})}},{key:"stopPublishTencentCDN",value:(r=F(M().mark(function a(){return M().wrap(function(s){for(;;)switch(s.prev=s.next){case 0:if(this.client_.isJoined_){s.next=4;break}return this.resetPublishTencentParam(le),this.resetPublishTencentParam(ht),s.abrupt("return");case 4:if(!this.publishTencentMainStreamObj_.isPublishing_){s.next=7;break}return s.next=7,this.doStopPublishTencentCDN(le);case 7:if(!this.publishTencentAuxStreamObj_.isPublishing_){s.next=10;break}return s.next=10,this.doStopPublishTencentCDN(ht);case 10:case"end":return s.stop()}},a,this)})),function(){return r.apply(this,arguments)})},{key:"doStopPublishTencentCDN",value:(i=F(M().mark(function a(s){var l,u,h,g,b;return M().wrap(function(T){for(;;)switch(T.prev=T.next){case 0:return l={requestTime:Date.now(),sessionId:sc("".concat(this.client_.getRoomId(),"_").concat(this.client_.getUserId(),"_").concat(s))},z.info("stopPublishTencentCDN: "+JSON.stringify(l)),T.next=4,this.signalChannel_.sendWaitForResponse({command:bU,data:l,timeout:5e3,responseCommand:pe.STOP_PUBLISH_TENCENT_CDN_RES,commandDesc:"stopPublishCDNStream"});case 4:if(u=T.sent,h=u.data,g=h.code,b=h.message,g!==0){T.next=10;break}this.resetPublishTencentParam(s),T.next=17;break;case 10:if(g!==-102069){T.next=15;break}z.warn("stopPublishTencentCDN failed, can not stopPublishTencentCDN in auto relayed-push mode"),this.resetPublishTencentParam(s),T.next=17;break;case 15:throw z.error("stopPublishTencentCDN failed, errCode: ".concat(g," errMsg: ").concat(b)),new j({code:V.STOP_PUBLISH_CDN_FAILED,message:H({key:Ey,data:{message:b},link:{className:"Client",fnName:"stopPublishCDNStream"}})});case 17:case"end":return T.stop()}},a,this)})),function(a){return i.apply(this,arguments)})},{key:"startPublishGivenCDN",value:(n=F(M().mark(function a(s){var l,u,h,g,b,T;return M().wrap(function(k){for(;;)switch(k.prev=k.next){case 0:if(l=s.streamType===le?this.publishTencentMainStreamObj_.streamId_:this.publishTencentAuxStreamObj_.streamId_,u={pushRequestTime:Date.now(),pushAppId:s.appId,pushBizId:s.bizId,pushCdnUrl:s.url,pushStreamType:s.streamType,pushStreamId:l},z.info("startPublishGivenCDN: "+JSON.stringify(u)),this.publishGivenCDNData_=u,this.isPublishingGivenCDN_=!0,this.client_.isJoined_){k.next=7;break}return k.abrupt("return");case 7:return k.prev=7,k.next=10,this.signalChannel_.sendWaitForResponse({command:kU,data:u,timeout:5e3,responseCommand:pe.START_PUBLISH_GIVEN_CDN_RES,commandDesc:"startPublishCDNStream"});case 10:if(h=k.sent,g=h.data,b=g.code,T=g.message,b===0){k.next=17;break}throw z.error("startPublishGivenCDN failed, errCode: ".concat(b,", errMsg: ").concat(T)),this.publishGivenCDNData_=null,this.isPublishingGivenCDN_=!1,new j({code:V.START_PUBLISH_CDN_FAILED,message:H({key:wy,data:{message:T},link:{className:"Client",fnName:"startPublishCDNStream"}})});case 17:k.next=24;break;case 19:throw k.prev=19,k.t0=k.catch(7),this.publishGivenCDNData_=null,this.isPublishingGivenCDN_=!1,k.t0;case 24:case"end":return k.stop()}},a,this,[[7,19]])})),function(a){return n.apply(this,arguments)})},{key:"stopPublishGivenCDN",value:(t=F(M().mark(function a(){var s,l,u,h,g,b,T,k,p,S;return M().wrap(function(f){for(;;)switch(f.prev=f.next){case 0:if(this.client_.isJoined_){f.next=4;break}return this.publishGivenCDNData_=null,this.isPublishingGivenCDN_=!1,f.abrupt("return");case 4:return s=this.publishGivenCDNData_,l=s.pushAppId,u=s.pushBizId,h=s.pushCdnUrl,g=s.pushStreamType,b={pushRequestTime:Date.now(),pushAppId:l,pushBizId:u,pushCdnUrl:h,pushStreamType:g},z.info("stopPublishGivenCDN: "+JSON.stringify(b)),f.next=9,this.signalChannel_.sendWaitForResponse({command:IU,data:b,timeout:5e3,responseCommand:pe.STOP_PUBLISH_GIVEN_CDN_RES,commandDesc:"stopPublishCDNStream"});case 9:if(T=f.sent,k=T.data,p=k.code,S=k.message,p!==0){f.next=16;break}this.publishGivenCDNData_=null,this.isPublishingGivenCDN_=!1,f.next=18;break;case 16:throw z.error("stopPublishGivenCDN failed, errCode: ".concat(p," errMsg: ").concat(S)),new j({code:V.STOP_PUBLISH_CDN_FAILED,message:H({key:Ey,data:{message:S},link:{className:"Client",fnName:"stopPublishCDNStream"}})});case 18:case"end":return f.stop()}},a,this)})),function(){return t.apply(this,arguments)})},{key:"handleCDNConfigForJoinData",value:function(a){var s,l=a;if(this.publishTencentMainStreamObj_.isPublishing_||this.publishTencentAuxStreamObj_.isPublishing_){var u={};je(l)&&(u=JSON.parse(l)),u.Str_uc_params||(u.Str_uc_params={}),this.publishTencentMainStreamObj_.isPublishing_&&(this.publishTencentMainStreamObj_.streamId_?u.Str_uc_params.userdefine_streamid_main=this.publishTencentMainStreamObj_.streamId_:this.publishTencentMainStreamObj_.params_&&(u.Str_uc_params.userdefine_streamid_main=this.generatePublishCDNStreamId(this.publishTencentMainStreamObj_.params_.streamId,le))),this.publishTencentAuxStreamObj_.isPublishing_&&(this.publishTencentAuxStreamObj_.streamId_?u.Str_uc_params.userdefine_streamid_aux=this.publishTencentAuxStreamObj_.streamId_:this.publishTencentAuxStreamObj_.params_&&(u.Str_uc_params.userdefine_streamid_aux=this.generatePublishCDNStreamId(this.publishTencentAuxStreamObj_.params_.streamId,ht))),l=JSON.stringify(u)}if(this.isPublishingGivenCDN_){var h=this.publishGivenCDNData_,g=h.pushAppId,b=h.pushBizId,T=h.pushCdnUrl,k=h.pushStreamType,p=h.pushStreamId;s={pushRequestTime:Date.now(),pushAppId:g,pushBizId:b,pushCdnUrl:T,pushStreamType:k,pushStreamId:p}}return{bussinessInfo:l,pushUserCdnInfo:s}}},{key:"reset",value:function(){this.resetPublishTencentParam(le),this.resetPublishTencentParam(ht),this.publishGivenCDNData_=null,this.isPublishingGivenCDN_=!1}}]),e}(),K8=function(){function e(t){ce(this,e),this.client_=t.client,this.durationMap_=new Map,this.installEvents()}return ue(e,[{key:"installEvents",value:function(){U.on(nn,this.handleSubscribed,this),U.on(mt,this.handleStreamTrackUpdated,this),U.on(rn,this.handleStreamStopped,this),U.on(cr,this.handleStreamStopped,this)}},{key:"uninstallEvents",value:function(){U.off(nn,this.handleSubscribed,this),U.off(mt,this.handleStreamTrackUpdated,this),U.off(rn,this.handleStreamStopped,this),U.off(cr,this.handleStreamStopped,this)}},{key:"handleSubscribed",value:function(t){var n=t.client,i=t.stream;if(n===this.client_){var r=i.getUserId(),o=i.getType(),c="".concat(r,"_").concat(o);if(i.hasAudio())if(i.isMainAudioSubscribed){var a=new oc,s=this.durationMap_.get(c);s?this.isRecording(s.audio)||s.audio.push(a):this.durationMap_.set(c,{userId:r,type:o,audio:[a],video:[]})}else this.stopDurationItem(c,K);if(i.hasVideo())if(o===Te&&i.isMainVideoSubscribed||o===Ne&&i.isAuxVideoSubscribed){var l=new oc,u=this.durationMap_.get(c);u?this.isRecording(u.video)||u.video.push(l):this.durationMap_.set(c,{userId:r,type:o,audio:[],video:[l]})}else this.stopDurationItem(c,q)}}},{key:"handleStreamStopped",value:function(t){var n=t.client,i=t.stream;if(this.clientHitTest(n)){var r=i.getUserId(),o=i.getType(),c="".concat(r,"_").concat(o);this.stopDurationItem(c,K),this.stopDurationItem(c,q)}}},{key:"handleStreamTrackUpdated",value:function(t){var n=t.client,i=t.userId,r=t.tinyId,o=t.kind,c=t.action;if(this.clientHitTest(n)&&this.client_.getConnections().has(r)){var a=o===ke?o:Te,s="".concat(i,"_").concat(a);if(c===$e.ADD){var l=this.client_.getConnections().get(r).getSubscribeState();if(o===K&&!l.audio||o===q&&!l.video||o===ke&&!l.auxiliary)return;var u=new oc,h=this.durationMap_.get(s);h?(o!==K||this.isRecording(h.audio)||h.audio.push(u),o===K||this.isRecording(h.video)||h.video.push(u)):this.durationMap_.set(s,{userId:i,type:a,audio:o===K?[u]:[],video:o===K?[]:[u]})}else this.stopDurationItem(s,o===K?K:q)}}},{key:"isRecording",value:function(t){return t.findIndex(function(n){return n.endTime===0})>=0}},{key:"stopDurationItem",value:function(t,n){if(this.durationMap_.has(t)){var i=this.durationMap_.get(t)[n].find(function(r){return r.endTime===0});i&&i.stop()}}},{key:"clientHitTest",value:function(t){return this.client_===t}},{key:"getDuration",value:function(t,n){return this.durationMap_.has(t)?this.durationMap_.get(t)[n].reduce(function(i,r){return i+r.getDuration()},0):0}},{key:"getDurationMap",value:function(){return this.durationMap_}},{key:"reset",value:function(){this.durationMap_.clear()}},{key:"destroy",value:function(){this.client_=null,this.uninstallEvents()}}]),e}();function Va(){return function(e,t,n){var i=n.value,r=new Set;return n.value=F(M().mark(function o(){var c,a,s,l,u=arguments;return M().wrap(function(h){for(;;)switch(h.prev=h.next){case 0:if(!r.has(this)){h.next=2;break}throw new j({code:V.INVALID_OPERATION,message:H({key:oN,data:{name:t}})});case 2:for(h.prev=2,r.add(this),c=u.length,a=new Array(c),s=0;s<c;s++)a[s]=u[s];return h.next=7,i.apply(this,a);case 7:return l=h.sent,r.delete(this),h.abrupt("return",l);case 12:throw h.prev=12,h.t0=h.catch(2),r.delete(this),h.t0;case 16:case"end":return h.stop()}},o,this,[[2,12]])})),n}}var AI,xI,PI,DI,OI,MI,NI,LI,UI,VI,jI,FI,BI,HI,WI,GI,zI,JI,qI,KI,QI,XI,YI,$I,ZI,eT,tT,nT,rT,iT,aT,Q,Q8=(RI=nt({name:"options",type:ct,required:!0,properties:{roomId:{type:me,required:!0},userId:{type:me,required:!1}}}),CI=nt({name:"options",type:ct,required:!0,properties:{updateList:{type:iy,required:!0,arrayItem:{require:!0,type:ct,properties:{roomId:{required:!0,type:me},userId:{required:!1,type:me},muteAudio:{type:Be},muteVideo:{type:Be},muteAuxiliary:{type:Be}}},validate:function(e){if(e.find(function(t){return t.userId})&&e.find(function(t){return!t.userId}))throw new j({code:V.INVALID_PARAMETER,message:"you can not update both userId and all"})}}}}),Fn=function(){function e(){ce(this,e),this.crossRoomSeq=0}var t,n,i;return ue(e,[{key:"call",value:function(r,o){return et(this[r])?this[r](o):Promise.reject(new j({code:V.INVALID_PARAMETER,message:H({key:ML,data:{name:r}})}))}},{key:"updatePrivateMapKey",value:function(r){var o=r.privateMapKey;return r.client.setProperty("privateMapKey",o),Promise.resolve()}},{key:"connectOtherRoom",value:(i=F(M().mark(function r(o){var c,a,s,l;return M().wrap(function(u){for(;;)switch(u.prev=u.next){case 0:if(c=o.client,a=o.roomId,s=o.userId,c.signalChannel_){u.next=3;break}return u.abrupt("return",Promise.reject(new j({code:V.INVALID_OPERATION,message:"you did not joined room"})));case 3:return u.next=5,c.signalChannel_.sendWaitForResponseWithRetry({command:AU,responseCommand:pe.CONNECT_OTHER_ROOM_RES,data:{roomId:a,userId:s,localRoomId:s?void 0:c.getRoomId()},retries:3});case 5:if((l=u.sent).data.code===0){u.next=8;break}throw new j({code:l.data.code,message:l.data.message});case 8:case"end":return u.stop()}},r)})),function(r){return i.apply(this,arguments)})},{key:"updateOtherRoomForwardMode",value:(n=F(M().mark(function r(o){var c,a,s,l,u;return M().wrap(function(h){for(;;)switch(h.prev=h.next){case 0:if(a=o.client,s=o.updateList,a.signalChannel_){h.next=3;break}return h.abrupt("return",Promise.reject(new j({code:V.INVALID_OPERATION,message:"you did not joined room"})));case 3:return l=s.find(function(g){return g.userId})?0:1,h.next=6,a.signalChannel_.sendWaitForResponseWithRetry({command:xU,responseCommand:pe.UPDATE_OTHER_ROOM_FORWARD_MODE_RES,data:{seq:++this.crossRoomSeq,operationType:l,updateList:s.map(function(g){return{roomId:g.roomId,userId:g.userId,muteAudio:g.muteAudio,muteVideo:g.muteVideo,muteSubStream:g.muteAuxiliary}})},retries:3});case 6:if(!(u=h.sent).data.data.expectSeq){h.next=10;break}return this.crossRoomSeq=u.data.data.expectSeq,h.abrupt("return",this.updateOtherRoomForwardMode({client:a,updateList:s}));case 10:if(u.data.code===0){h.next=14;break}throw new j({code:u.data.code,message:u.data.message});case 14:if(!(((c=u.data.errorList)===null||c===void 0?void 0:c.length)>0)){h.next=16;break}throw new j({code:V.UNKNOWN,message:u.data.errorList[0].message});case 16:case"end":return h.stop()}},r,this)})),function(r){return n.apply(this,arguments)})},{key:"disconnectOtherRoom",value:(t=F(M().mark(function r(o){var c,a,s;return M().wrap(function(l){for(;;)switch(l.prev=l.next){case 0:if(c=o.client,a=o.roomId,c.signalChannel_){l.next=3;break}return l.abrupt("return",Promise.resolve());case 3:return l.next=5,c.signalChannel_.sendWaitForResponseWithRetry({command:PU,responseCommand:pe.DISCONNECT_OTHER_ROOM_RES,data:{roomId:a,localRoomId:a?c.getRoomId():void 0},retries:3});case 5:if((s=l.sent).data.code===0){l.next=8;break}throw new j({code:s.data.code,message:s.data.message});case 8:case"end":return l.stop()}},r)})),function(r){return t.apply(this,arguments)})}]),e}(),ie(Fn.prototype,"connectOtherRoom",[RI],Object.getOwnPropertyDescriptor(Fn.prototype,"connectOtherRoom"),Fn.prototype),ie(Fn.prototype,"updateOtherRoomForwardMode",[CI],Object.getOwnPropertyDescriptor(Fn.prototype,"updateOtherRoomForwardMode"),Fn.prototype),Fn),X8=new Q8,cc,uc,lc,Wp,oT,sT,cT,uT,lT,dT,Ge,Y8=(AI=Va(),xI=nt(We.CLIENT.join),PI=yi({retries:1,timeout:0,onError:function(e,t,n){this.isUsingCachedSchedule_?(this.log_.warn("is using cached schedule, retry join"),Dn(!0),this.reset(),t()):(U.emit(sr,{client:this,error:e}),J.logFailedEvent({userId:this.userId_,eventType:Ug,error:e}),this.reset(),this.log_.error(e),n(e))}}),DI=Va(),OI=yi({retries:3}),MI=Va(),NI=nt.apply(void 0,Se(We.CLIENT.publish)),LI=Ee(Ze),UI=Va(),VI=nt(We.CLIENT.unpublish),jI=nt.apply(void 0,Se(We.CLIENT.subscribe)),FI=nt(We.CLIENT.unsubscribe),BI=Va(),HI=nt(We.CLIENT.switchRole),WI=Ee(Ze),GI=nt(We.CLIENT.startPublishCDNStream),zI=Ee(Ze),JI=Ee(Ze),qI=nt(We.CLIENT.startMixTranscode),KI=Ee(Ze),QI=Ee(Ze),XI=Ee(Ze),YI=Ee(Ze),$I=Ee(Ze),ZI=Ee(Ze),eT=Ee(Ze),tT=Qs.apply(void 0,Se(We.CLIENT.sendSEIMessage)),nT=Ee(Ze),cc={timesInSecond:30,maxSizeInSecond:8e3,getSize:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return t[0].byteLength}},uc=cc.timesInSecond,lc=cc.maxSizeInSecond,Wp=cc.getSize,rT=function(e,t,n){var i=n.value,r=new Map;return U.on(Pd,function(o){var c=o.client;return r.delete(c)}),n.value=function(){var o=r.get(this);o||(o={callCountInSecond:0,timestamp:0,totalSizeInSecond:0},r.set(this,o)),o.timestamp===0?o.timestamp=Date.now():Date.now()-o.timestamp>1e3&&(o.timestamp=Date.now(),o.callCountInSecond=0,o.totalSizeInSecond=0);for(var c=arguments.length,a=new Array(c),s=0;s<c;s++)a[s]=arguments[s];if(Wp&&(o.totalSizeInSecond+=Wp.apply(void 0,a)),o.timestamp!==0&&Date.now()-o.timestamp<1e3&&(o.callCountInSecond>=uc||o.totalSizeInSecond>lc))throw new j({code:V.INVALID_OPERATION,message:H({key:HL,data:{isTimes:o.callCountInSecond>=uc,isSize:o.totalSizeInSecond>lc,name:t,timesInSecond:uc,maxSizeInSecond:lc}})});return o.callCountInSecond++,i.apply(this,a)},n},iT=Ee(Ze),aT=Ee(Ze),Q=function(){function e(y){var d,_;ce(this,e),this.name_=Ze,this.mode_=y.mode,this.sdpSemantics_=jl,G(y.sdpSemantics)?function(){var E;if(G(window.RTCRtpTransceiver)||!("currentDirection"in RTCRtpTransceiver.prototype))return!1;var C=null,O=!1;try{(C=new RTCPeerConnection({sdpSemantics:sa})).addTransceiver(K),O=!0}catch{}return(E=C)===null||E===void 0||E.close(),O}()&&(this.sdpSemantics_=sa):this.sdpSemantics_=y.sdpSemantics,this.sdkAppId_=y.sdkAppId,this.userId_=y.userId,this.log_=z.createLogger({id:"c".concat(y.seq,"|").concat(this.userId_),userId:this.userId_,sdkAppId:this.sdkAppId_}),this.userSig_=y.userSig,this.roomId_=0,this.useStringRoomId_=y.useStringRoomId||!1,this.pureAudioPushMode_=null,this.version_=y.version,this.log_.info("using sdpSemantics: "+this.sdpSemantics_),this.signalChannel_=null,this.role_=Wt,this.privateMapKey_="",this.tinyId_=0,this.env_="",this.proxy_=null,this.unifiedProxy_=null,this.connections_=new Map,this.mutedStates_=new Map,this.userMap_=new Map,this.syncUserListInterval_=-1,this.localStream_=null,this.localAuxStream_=null,this.uplinkConnection_=null,this.emitter_=rS(new Pn,this.name_),this.isJoined_=!1,this.heartbeat_=-1,this.lastHeartBeatTime_=-1,this.stats_=new QV(this),this.joinTimeout_=-1,this.changeBigSmallRecords_=new Map,this.networkQuality_=null,this.badCaseDetector_=null,this.networkType_=vd(),this.autoSubscribe_=!!G(y.autoSubscribe)||y.autoSubscribe,this.joinedTimestamp_=0,this.joinOptions_={},this.basis_=(_={browser:ar().name+"/"+ar().version,os:yh(),displayResolution:FV(),isScreenShareSupported:ZS(),isWebRTCSupported:ph(),isGetUserMediaSupported:BV(),isWebAudioSupported:HV(),isWebSocketsSupported:"WebSocket"in window&&window.WebSocket.CLOSING===2,isWebCodecSupported:(d={AudioDecoder:!1,AudioEncoder:!1,VideoDecoder:!1,VideoEncoder:!1,ImageDecoder:!1},G(window.AudioDecoder)||(d.AudioDecoder=!0),G(window.AudioEncoder)||(d.AudioEncoder=!0),G(window.VideoDecoder)||(d.VideoDecoder=!0),G(window.VideoEncoder)||(d.VideoEncoder=!0),G(window.ImageDecoder)||(d.ImageDecoder=!0),d),isMediaSessionSupported:"mediaSession"in navigator&&!G(navigator.mediaSession.setActionHandler),isWebTransportSupported:!G(window.WebTransport)},navigator.userAgent.includes("miniProgram")&&(_.browser="mini/".concat(_.browser)),_),this.initBussinessInfo_(y),this.publishedCDN_=!1,this.publishCDNData_=null,this.mixedMCU_=!1,this.mixTranscodeData_=null,this.checkSystemResult_=null,this.enableAudioVolumeEvaluation_=!1,this.audioVolumeIntervalId_=null,this.mixTranscodeManager_=null,this.publishCDNManager_=new q8({client:this}),this.keyPointManager_=new l8({client:this,frameWorkType:y.frameWorkType,component:y.component}),this.isPublishing_=!1,this.isEnableSmallStream_=!1,this.smallStreamConfig_={bitrate:100,frameRate:15,height:120,width:160},this.turnServers_=[],this.iceTransportPolicy_=y.iceTransportPolicy,this.schedule_={domains:null,iceServers:null,iceTransportPolicy:null,trtcCapability:null},this.isUsingCachedSchedule_=!1,this.enableAutoPlayDialog_=!!G(y.enableAutoPlayDialog)||y.enableAutoPlayDialog,this.enableMultiAuxStream_=!G(y.enableMultiAuxStream)&&y.enableMultiAuxStream,this.signalInfo_={},this.enableSEI_=!G(y.enableSEI)&&y.enableSEI,this.isDestroyed_=!1}var t,n,i,r,o,c,a,s,l,u,h,g,b,T,k,p,S,f,I,A,x,D,m,v,w,R,P;return ue(e,[{key:"initBussinessInfo_",value:function(y){this.bussinessInfo_=y.bussinessInfo;var d={};if(je(y.bussinessInfo)&&(d=JSON.parse(y.bussinessInfo)),!G(y.pureAudioPushMode)){if(!Number.isInteger(Number(y.pureAudioPushMode)))throw new j({code:V.INVALID_PARAMETER,message:H({key:gN})});this.pureAudioPushMode_=y.pureAudioPushMode,d.Str_uc_params||(d.Str_uc_params={}),d.Str_uc_params.pure_audio_push_mod=this.pureAudioPushMode_}if(!G(y.streamId)){if(!(je(y.streamId)&&String(y.streamId)&&String(y.streamId).length<=64))throw new j({code:V.INVALID_PARAMETER,message:H({key:yN})});d.Str_uc_params||(d.Str_uc_params={}),d.Str_uc_params.userdefine_streamid_main=y.streamId}if(!G(y.userDefineRecordId)){if(y.userDefineRecordId.match(/^[A-Za-z0-9_-]{1,64}$/gi)===null)throw new j({code:V.INVALID_PARAMETER,message:H({key:SN})});d.Str_uc_params||(d.Str_uc_params={}),d.Str_uc_params.userdefine_record_id=y.userDefineRecordId}if(!G(y.userDefinePushArgs)){if(!(je(y.userDefinePushArgs)&&String(y.userDefinePushArgs)&&String(y.userDefinePushArgs).length<=256))throw new j({code:V.INVALID_PARAMETER,message:H({key:bN})});d.Str_uc_params||(d.Str_uc_params={}),d.Str_uc_params.userdefine_push_args=y.userDefinePushArgs}y.enableServerAudioMix&&(d.Str_uc_params||(d.Str_uc_params={}),d.Str_uc_params.enable_server_audio_mix=1,d.Str_uc_params.uc_biz_type=1e3),on(d)||(this.bussinessInfo_=JSON.stringify(d))}},{key:"schedule",value:(P=F(M().mark(function y(d){var _,E,C;return M().wrap(function(O){for(;;)switch(O.prev=O.next){case 0:return O.next=2,SV({userId:this.userId_,sdkAppId:this.sdkAppId_,roomId:d,useStringRoomId:this.useStringRoomId_,version:this.version_,userSig:this.userSig_});case 2:_=O.sent,E=_.result,C=_.isCached,this.isUsingCachedSchedule_=C,E&&(this.log_.info("schedule with cache:".concat(C," : ").concat(JSON.stringify(E))),E.trtcCapability=E==null?void 0:E.trtcAutoConf,this.schedule_=te(te({},this.schedule_),E),U.emit(sS,this.schedule_));case 7:case"end":return O.stop()}},y,this)})),function(y){return P.apply(this,arguments)})},{key:"getSignalChannelUrl",value:function(){var y={mainUrl:"",backupUrl:""},d=Qy();return d?y.mainUrl=y.backupUrl="wss://".concat(d,".rtc.qq.com"):this.proxy_?y.mainUrl=y.backupUrl=this.proxy_:this.unifiedProxy_?y.mainUrl=y.backupUrl="wss://".concat(this.unifiedProxy_):Array.isArray(this.schedule_.domains)&&this.schedule_.domains.length>0&&(y.mainUrl=y.backupUrl="wss://".concat(this.schedule_.domains[0]),this.schedule_.domains[1]&&(y.backupUrl="wss://".concat(this.schedule_.domains[1]))),y}},{key:"getUserId",value:function(){return this.userId_}},{key:"getUserSig",value:function(){return this.userSig_}},{key:"getRole",value:function(){return this.role_}},{key:"getSignalInfo",value:function(){return this.signalInfo_}},{key:"getRoomId",value:function(){return this.roomId_}},{key:"getSDKAppId",value:function(){return this.sdkAppId_}},{key:"getTinyId",value:function(){return this.tinyId_}},{key:"getIceTransportPolicy",value:function(){return this.iceTransportPolicy_||this.schedule_.iceTransportPolicy||"all"}},{key:"initialize",value:function(y){var d=this;this.log_.info("setup signal channel");var _=this.getSignalChannelUrl(),E=_.mainUrl,C=_.backupUrl;return this.signalChannel_=new IV({sdkAppId:this.sdkAppId_,userId:this.userId_,userSig:this.userSig_,roomId:y.roomId,url:E,backupUrl:C,signalDomainWhenUnifiedProxy:this.unifiedProxy_?this.schedule_.domains[0]:void 0,client:this}),this.networkQuality_||(this.networkQuality_=new XV({connections:this.connections_,signalChannel:this.signalChannel_,userId:this.userId_,client:this}),this.networkQuality_.on(fe.NETWORK_QUALITY,function(O){d.emitter_.emit(fe.NETWORK_QUALITY,O)})),this.deviceDetector_||(this.deviceDetector_=new YV({client:this})),this.subscriptionManager_||(this.subscriptionManager_=new d8({client:this})),this.badCaseDetector_||(this.badCaseDetector_=new z8({client:this,stats:this.stats_})),this.callDurationCalculator_||(this.callDurationCalculator_=new K8({client:this})),this.mixTranscodeManager_||(this.mixTranscodeManager_=new J8({client:this,signalChannel:this.signalChannel_})),this.publishCDNManager_&&this.publishCDNManager_.setSignalChannel({signalChannel:this.signalChannel_}),this.signalChannel_.on(Yd,function(O){d.log_.info("SignalChannel state changed from ".concat(O.prevState," to ").concat(O.state)),d.emitter_.emit(fe.CONNECTION_STATE_CHANGED,O)}),this.signalChannel_.on($d,function(O){d.reset(),d.emitter_.emit(fe.ERROR,O)}),this.signalChannel_.once(RS,function(O){d.tinyId_=O.signalInfo.tinyId,U.emit(ls,{client:d})}),this.signalChannel_.on(pe.PEER_JOIN,this.onPeerJoin,this),this.signalChannel_.on(pe.PEER_LEAVE,this.onPeerLeave,this),this.signalChannel_.on(pe.UPDATE_REMOTE_MUTE_STAT,function(O){Date.now()-d.lastHeartBeatTime_>=1e4&&d.doHeartbeat(),U.emit(Rd,{client:d,data:O.data}),d.onPublishedUserList(O.data),d.onUpdateRemoteMuteStat(O.data)}),this.signalChannel_.on(pe.CLIENT_BANNED,function(O){var L,N=O.data.data.reason;if(J.uploadEvent({log:"stat-banned:".concat(N),userId:d.userId_}),N===IM)L="you got banned by the admin";else if(N===TM)L="duplicated userId joining the room";else if(N===EM)L="the room has been disbanded by the admin",N=N.replace("_","-");else if(N===wM)return d.log_.warn("".concat(N," last heart beat time: ").concat(d.lastHeartBeatTime_," interval: ").concat(Date.now()-d.lastHeartBeatTime_,", visibility: ").concat(document.visibilityState)),void d.reJoin();d.log_[N==="kick"?"error":"info"]("user was banned because of [".concat(N,"]")),d.reset(),d.emitter_.emit(fe.CLIENT_BANNED,{reason:N,message:H({key:jN,data:{message:L,reason:N}})||N})}),U.emit(Ad,{client:this}),this.signalChannel_.connect()}},{key:"preJoin",value:(R=F(M().mark(function y(d){var _,E,C,O;return M().wrap(function(L){for(;;)switch(L.prev=L.next){case 0:return this.joinOptions_=d,L.next=3,mh();case 3:if(this.checkSystemResult_=L.sent,this.checkDestroy(),(_=Qy())||(_=Wo,this.proxy_&&(this.proxy_.startsWith(CM)?_=xM:this.proxy_.startsWith(AM)&&(_=PM))),this.env_=_,J.setConfig({env:_,sdkAppId:this.sdkAppId_,userId:this.userId_,roomId:d.roomId}),this.uploadTrtcStats(),E=this.checkSystemResult_.detail,C=E.isH264EncodeSupported,O=E.isVp8EncodeSupported,ph()&&(C||O)){L.next=13;break}throw new j({code:V.NOT_SUPPORTED,message:H({key:xy})});case 13:case"end":return L.stop()}},y,this)})),function(y){return R.apply(this,arguments)})},{key:"join",value:(w=F(M().mark(function y(d){var _,E=this;return M().wrap(function(C){for(;;)switch(C.prev=C.next){case 0:return this.roomId_=d.roomId,G(d.role)||(this.role_=d.role),G(d.privateMapKey)||(this.privateMapKey_=d.privateMapKey),_=De(),U.emit(us,{client:this}),rt(this.userId_,{eventId:zU,eventDesc:"joining room",timestamp:Qe(),userId:this.userId_,tinyId:this.tinyId_}),C.next=8,this.preJoin(d);case 8:return C.abrupt("return",new Promise(function(){var O=F(M().mark(function L(N,W){return M().wrap(function(B){for(;;)switch(B.prev=B.next){case 0:if(E.joinReject_=W,B.prev=1,E.proxy_||E.schedule_.domains){B.next=5;break}return B.next=5,E.schedule(d.roomId);case 5:return E.checkDestroy(),B.next=8,E.initialize(d);case 8:return B.next=10,E.doJoin(d);case 10:E.signalInfo_=E.signalChannel_.getSignalInfo(),U.emit(Zr,{client:E}),E.joinedTimestamp_=De(),J.logSuccessEvent({userId:E.userId_,eventType:FM,delta:E.joinedTimestamp_-_}),J.logSuccessEvent({userId:E.userId_,eventType:Ug}),J.uploadEvent({log:"stat-autoplay-dialog:".concat(E.enableAutoPlayDialog_),userId:E.userId_}),J.uploadEvent({log:"stat-conv-".concat(rr,"-").concat(location.hostname),userId:E.userId_}),N(),B.next=23;break;case 20:B.prev=20,B.t0=B.catch(1),W(B.t0);case 23:E.joinReject_=null;case 24:case"end":return B.stop()}},L,null,[[1,20]])}));return function(L,N){return O.apply(this,arguments)}}()));case 9:case"end":return C.stop()}},y,this)})),function(y){return w.apply(this,arguments)})},{key:"checkDestroy",value:function(){if(this.isDestroyed_)throw new j({code:V.INVALID_OPERATION,message:H({key:Ql,data:{funName:"join"}})})}},{key:"uploadTrtcStats",value:(v=F(M().mark(function y(){var d,_,E,C,O,L,N,W,B,se,ee,ne,_e;return M().wrap(function(ae){for(;;)switch(ae.prev=ae.next){case 0:return ae.prev=0,ae.next=3,Ce.getMicrophones();case 3:E=ae.sent,d=E&&E.length,ae.next=9;break;case 7:ae.prev=7,ae.t0=ae.catch(0);case 9:return ae.prev=9,ae.next=12,Ce.getCameras();case 12:C=ae.sent,_=C&&C.length,ae.next=18;break;case 16:ae.prev=16,ae.t1=ae.catch(9);case 18:O={microphone:d,camera:_},L=this.checkSystemResult_.detail,N=L.isH264EncodeSupported,W=L.isVp8EncodeSupported,B=L.isH264DecodeSupported,se=L.isVp8DecodeSupported,ee={webRTC:this.basis_.isWebRTCSupported,getUserMedia:this.basis_.isGetUserMediaSupported,webSocket:this.basis_.isWebSocketsSupported,screenShare:this.basis_.isScreenShareSupported,webAudio:this.basis_.isWebAudioSupported,h264Encode:N,h264Decode:B,vp8Encode:W,vp8Decode:se},ne={browser:this.basis_.browser,os:this.basis_.os,trtc:ee,devices:O},_e={isWebCodecSupported:this.basis_.isWebCodecSupported,isMediaSessionSupported:this.basis_.isMediaSessionSupported,isWebTransportSupported:this.basis_.isWebTransportSupported},J.uploadEvent({log:"trtcstats-"+JSON.stringify(ne),userId:this.userId_}),this.log_.info("TrtcStats-"+JSON.stringify(ne)),J.uploadEvent({log:"trtcadvancedstats-"+JSON.stringify(_e),userId:this.userId_});case 26:case"end":return ae.stop()}},y,this,[[0,7],[9,16]])})),function(){return v.apply(this,arguments)})},{key:"doJoin",value:function(y){var d=this;return new Promise(function(_,E){d.log_.info("Join() => joining room: ".concat(d.roomId_," useStringRoomId: ").concat(d.useStringRoomId_," mode: ").concat(d.mode_," role: ").concat(d.role_));var C={roomId:String(d.roomId_),useStringRoomId:d.useStringRoomId_,privateMapKey:d.privateMapKey_,trtcRole:d.role_===Wt?Jr:Dl,trtcScene:d.mode_===Go?NM:MM,sdpSemantics:d.sdpSemantics_,version:v3(d.version_),ua:navigator&&navigator.userAgent||"",autoSubscribe:d.autoSubscribe_,terminalType:Qr?4:ed?2:Zl?3:la?12:Gy?5:zy?13:1,netType:Bl[vd()],bussinessInfo:d.bussinessInfo_,receiveMix:!0};if(d.publishCDNManager_){var O=d.publishCDNManager_.handleCDNConfigForJoinData(d.bussinessInfo_),L=O.bussinessInfo,N=O.pushUserCdnInfo;Object.assign(C,{bussinessInfo:L,pushUserCdnInfo:N})}d.log_.debug("join room signal data: ".concat(JSON.stringify(C))),d.joinTimeout_=setTimeout(function(){E(new j({code:V.JOIN_ROOM_FAILED,message:H({key:EN})}))},5e3),U.emit(kd,{client:d}),d.signalChannel_.once(CS,function(W){d.clearJoinTimeout(),U.emit(ls,{client:d,error:W}),E(W)}),d.signalChannel_.send(hU,C),d.signalChannel_.once(pe.JOIN_ROOM_RESULT,function(W){d.clearJoinTimeout();var B=W.data,se=B.code,ee=B.message,ne=B.data;d.onPublishedUserList({data:{userList:ne.publishers}}),U.emit(Id,{client:d,code:se}),se===0?(d.isJoined_=!0,d.log_.info("Join room success, start heartbeat"),d.startHeartbeat(),d.badCaseDetector_&&d.badCaseDetector_.start(),d.syncUserList(),d.startSyncUserListInterval(),_()):(d.log_.error("Join room failed result: "+se+" error: "+ee),E(new j({code:V.JOIN_ROOM_FAILED,extraCode:se,message:H({key:Iy,data:{error:ee,code:se}})})))})})}},{key:"reJoin",value:(m=F(M().mark(function y(){return M().wrap(function(d){for(;;)switch(d.prev=d.next){case 0:if(this.isJoined_){d.next=3;break}return this.log_.warn("reJoin abort"),d.abrupt("return");case 3:return this.isJoined_=!1,d.prev=4,this.log_.warn("reJoin pending: ".concat(this.joinOptions_.roomId)),this.subscriptionManager_&&this.subscriptionManager_.markAllStream(),this.signalChannel_.close(),d.next=10,this.signalChannel_.connect();case 10:return d.next=12,this.doJoin(te(te({},this.joinOptions_),{},{role:this.role_,privateMapKey:this.privateMapKey_}));case 12:this.log_.warn("reJoin success"),J.logSuccessEvent({userId:this.userId_,eventType:Vg}),this.checkConnectionsToReconnect(),this.uplinkConnection_&&!this.uplinkConnection_.getIsReconnecting()&&this.uplinkConnection_.startReconnection(),this.mixTranscodeManager_&&this.mixTranscodeManager_.reStartMixTranscode(),d.next=25;break;case 19:d.prev=19,d.t0=d.catch(4),this.log_.warn("reJoin fail "+d.t0),this.reset(),J.logFailedEvent({userId:this.userId_,eventType:Vg,error:d.t0}),this.emitter_.emit(fe.ERROR,new j({code:V.JOIN_ROOM_FAILED,message:H({key:RN,data:{roomId:this.joinOptions_.roomId}})}));case 25:case"end":return d.stop()}},y,this,[[4,19]])})),function(){return m.apply(this,arguments)})},{key:"leave",value:(D=F(M().mark(function y(){var d;return M().wrap(function(_){for(;;)switch(_.prev=_.next){case 0:return U.emit(Td,{client:this}),rt(this.userId_,{eventId:JU,eventDesc:"leaving room",timestamp:Qe(),userId:this.userId_,tinyId:this.tinyId_}),_.prev=2,_.next=5,this.doHeartbeat();case 5:_.next=9;break;case 7:_.prev=7,_.t0=_.catch(2);case 9:this.doLeave(),U.emit(ei,{client:this}),J.logSuccessEvent({userId:this.userId_,eventType:BM}),d=Math.floor((De()-this.joinedTimestamp_)/1e3),J.logSuccessEvent({userId:this.userId_,eventType:HM,delta:d});case 14:case"end":return _.stop()}},y,this,[[2,7]])})),function(){return D.apply(this,arguments)})},{key:"doLeave",value:function(){this.isJoined_&&(U.emit(wd,{client:this}),this.log_.info("leave() => leaving room"),this.signalChannel_.send(pU),this.reset())}},{key:"clearNetworkQuality",value:function(){this.networkQuality_&&(this.networkQuality_.stop(),this.networkQuality_=null)}},{key:"closeConnections",value:function(){var y=this;this.connections_.forEach(function(d){y.closeDownLink(d.getTinyId())})}},{key:"clearJoinTimeout",value:function(){clearTimeout(this.joinTimeout_),this.joinTimeout_=-1}},{key:"destroy",value:function(){var y,d,_;if(this.isJoined_)throw this.log_.warn(En.INVALID_DESTROY),new j({code:V.INVALID_OPERATION,message:H({key:CN})});this.isDestroyed_||(this.log_.info("destroy client"),this.joinReject_&&(this.joinReject_(new j({code:V.INVALID_OPERATION,message:H({key:Ql,data:{funName:"join"}})})),this.clearJoinTimeout(),this.reset()),this.off("*"),(y=this.callDurationCalculator_)===null||y===void 0||y.destroy(),(d=this.keyPointManager_)===null||d===void 0||d.destroy(),(_=this.deviceDetector_)===null||_===void 0||_.destroy(),this.callDurationCalculator_=null,this.keyPointManager_=null,this.deviceDetector_=null,this.badCaseDetector_=null,this.publishCDNManager_=null,this.isDestroyed_=!0,U.emit(Pd,{client:this}))}},{key:"reset",value:function(){this.isJoined_=!1,this.schedule_={domains:null,iceServers:null,iceTransportPolicy:null,trtcCapability:null},this.keyPointManager_&&this.keyPointManager_.prepareReport(),this.mixTranscodeManager_&&(this.mixTranscodeManager_.reset(),this.mixTranscodeManager_=null),this.publishCDNManager_&&this.publishCDNManager_.reset(),this.userMap_.clear(),this.stopSyncUserListInterval(),this.stopHeartbeat(),this.closeConnections(),this.mutedStates_.clear(),this.clearNetworkQuality(),this.badCaseDetector_&&this.callDurationCalculator_&&this.uploadAllCallStats(),this.closeUplink(),this.signalChannel_&&(this.log_.info("destroying SignalChannel"),this.signalChannel_.close(),this.signalChannel_=null),this.stats_.reset()}},{key:"startSyncUserListInterval",value:function(){this.syncUserListInterval_===-1&&(this.syncUserListInterval_=ye.run(Kr,this.syncUserList.bind(this)))}},{key:"stopSyncUserListInterval",value:function(){ye.clearTask(this.syncUserListInterval_),this.syncUserListInterval_=-1}},{key:"syncUserList",value:(x=F(M().mark(function y(){var d,_=this;return M().wrap(function(E){for(;;)switch(E.prev=E.next){case 0:return E.prev=0,E.next=3,this.getUserList();case 3:d=E.sent,this.userMap_.size!==0&&this.userMap_.forEach(function(C){d.findIndex(function(O){return O.userId===C.userId})<0&&(_.log_.info("peer leave detected: ".concat(C.userId)),_.cleanUser({userId:C.userId,tinyId:C.tinyId}))}),d.forEach(function(C){var O=C.userId;_.userMap_.has(O)||O===_.userId_||(_.userMap_.set(O,C),_.emitter_.emit(fe.PEER_JOIN,{userId:O}))}),E.next=11;break;case 8:E.prev=8,E.t0=E.catch(0),this.log_.warn("sync user list failed: "+E.t0);case 11:case"end":return E.stop()}},y,this,[[0,8]])})),function(){return x.apply(this,arguments)})},{key:"getUserList",value:function(){return this.signalChannel_?this.signalChannel_.sendWaitForResponse({command:EU,responseCommand:pe.USER_LIST_RES,enableLog:!1,timeout:2e3}).then(function(y){var d=y.data,_=d.code,E=d.message;if(_===0)return(d.data&&d.data.userList||[]).map(function(C){var O=C.userId,L=C.srcTinyId,N=C.role;return new Hp({userId:O,tinyId:L,role:N})});throw H({key:Oy,data:{signalResponse:pe.USER_LIST_RES,code:_,message:E}})}):[]}},{key:"publish",value:(A=F(M().mark(function y(d){var _,E,C,O,L,N,W,B,se=this,ee=arguments;return M().wrap(function(ne){for(;;)switch(ne.prev=ne.next){case 0:return _=ee.length>1&&ee[1]!==void 0?ee[1]:{isAuxiliary:!1},d.setPublishState(ca),this.isPublishing_=!0,E=De(),U.emit(Cd,{client:this,stream:d}),C=_.isAuxiliary,O=C?ke:le,L=d.getScreen(),this.log_.info("publish() => publishing ".concat(L?Rl+" ":"").concat(O," stream ").concat(d.getId())),N=this.uplinkConnection_,ne.prev=10,N||((N=new b8({userId:this.userId_,tinyId:this.tinyId_,client:this,isUplink:!0,signalChannel:this.signalChannel_,enableSEI:this.enableSEI_})).initialize(),N.on(de.ERROR,function(_e){var ae=_e.getCode();ae!==V.ICE_TRANSPORT_ERROR&&(ae===V.UPLINK_RECONNECTION_FAILED&&se.closeUplink(),se.emitter_.emit(fe.ERROR,_e))})),d.setConnection(N),ne.next=15,N.publish(d,C);case 15:this.log_.info("local ".concat(L?Rl+" ":"").concat(O," stream is published")),this.isPublishing_=!1,C?this.localAuxStream_=d:(this.localStream_=d,this.deviceDetector_&&this.deviceDetector_.setLocalStream(this.localStream_),this.localStream_.getBeautyStatus()&&this.log_.info("beauty stream is published successfully")),d.setPublishState(GM),d.setClient(this,C),this.uplinkConnection_=N,W=De(),B=W-E,J.logSuccessEvent({userId:this.userId_,eventType:jg}),J.logSuccessEvent({userId:this.userId_,eventType:WM,delta:B}),d.hasAudio()&&rt(this.userId_,{eventId:DS,eventDesc:"publish audio track",timestamp:Qe(),userId:this.userId_,tinyId:this.tinyId_}),d.hasVideo()&&rt(this.userId_,{eventId:PS,eventDesc:"publish video track",timestamp:Qe(),userId:this.userId_,tinyId:this.tinyId_}),this.networkQuality_&&this.networkQuality_.setUplinkConnection(this.uplinkConnection_),U.emit(k3,{localStream:d,isAuxiliary:C,client:this}),this.notPublishWithoutH264Supported_=!1,d.isAIDenoiser&&jn.handleFunctionState({fnName:"AI_DENOISER"}),ne.next=42;break;case 33:throw ne.prev=33,ne.t0=ne.catch(10),ne.t0 instanceof j&&ne.t0.getCode()===V.NOT_SUPPORTED_H264&&(this.notPublishWithoutH264Supported_=!0),d.setPublishState(ay),N.close(),this.log_.error("failed to publish stream "+ne.t0),this.isPublishing_=!1,J.logFailedEvent({userId:this.userId_,eventType:jg,error:ne.t0}),ne.t0;case 42:case"end":return ne.stop()}},y,this,[[10,33]])})),function(y){return A.apply(this,arguments)})},{key:"unpublish",value:(I=F(M().mark(function y(d){var _,E;return M().wrap(function(C){for(;;)switch(C.prev=C.next){case 0:if(this.uplinkConnection_){C.next=2;break}return C.abrupt("return");case 2:return _=d===this.localAuxStream_,E=d.getScreen(),this.log_.info("unpublish() => unpublishing local ".concat(E?Rl+" ":"").concat(_?ke:le," stream")),C.prev=5,C.next=8,this.uplinkConnection_.unpublish(d);case 8:J.logSuccessEvent({userId:this.userId_,eventType:Fg}),C.next=15;break;case 11:C.prev=11,C.t0=C.catch(5),this.log_.warn("unpublish error ".concat(C.t0)),J.logFailedEvent({userId:this.userId_,eventType:Fg,error:C.t0});case 15:d.setClient(null),d.setConnection(null),_?this.localAuxStream_=null:(this.localStream_=null,d.hasAudio()&&rt(this.userId_,{eventId:MS,eventDesc:"unpublish audio track",timestamp:Qe(),userId:this.userId_,tinyId:this.tinyId_}),d.hasVideo()&&rt(this.userId_,{eventId:OS,eventDesc:"unpublish video track",timestamp:Qe(),userId:this.userId_,tinyId:this.tinyId_})),this.localStream_||this.localAuxStream_||this.closeUplink();case 19:case"end":return C.stop()}},y,this,[[5,11]])})),function(y){return I.apply(this,arguments)})},{key:"closeUplink",value:function(){this.uplinkConnection_&&(this.uplinkConnection_.close(),this.uplinkConnection_=null,this.networkQuality_&&this.networkQuality_.setUplinkConnection(null),this.localStream_&&(this.localStream_.setClient(null),this.localStream_.setConnection(null),this.localStream_=null),this.localAuxStream_&&(this.localAuxStream_.setClient(null),this.localAuxStream_.setConnection(null),this.localAuxStream_=null),this.deviceDetector_&&this.deviceDetector_.setLocalStream(null))}},{key:"closeDownLink",value:function(y){var d=this.connections_.get(y);d&&(d.getIsReconnecting()&&d.stopReconnection(),this.subscriptionManager_&&this.subscriptionManager_.delete(d.getUserId()),d.close(),this.connections_.delete(y),this.mutedStates_.delete(y))}},{key:"subscribe",value:(f=F(M().mark(function y(d,_){var E,C,O;return M().wrap(function(L){for(;;)switch(L.prev=L.next){case 0:return this.log_.info("subscribe() => subscribe to [".concat(d.getUserId(),"] ").concat(d.getType()," stream with options: ").concat(JSON.stringify(_))),G(_)&&(_={audio:!0,video:!0}),G(_.audio)&&(_.audio=!0),G(_.smallVideo)?G(_.video)&&(_.video=!0):_.smallVideo?G(_.video)?(_.video=!1,_.smallVideo=!0):_.video&&(_.video=!0,delete _.smallVideo,this.log_.warn("options.video and options.smallVideo can't be both true")):G(_.video)&&(_.video=!0,delete _.smallVideo),_.video&&this.changeBigSmallRecords_.delete(d.getUserId()),E=d.getConnection(),_.smallVideo&&(E.getTrackState().smallVideo||(this.setRemoteVideoStreamType(d,"small"),_.video=!0,delete _.smallVideo)),L.prev=7,U.emit(Od,{client:this,stream:d}),L.next=11,E.subscribe(d,_);case 11:this.subscriptionManager_&&this.subscriptionManager_.addSubscriptionRecord(d.getUserId(),d,_),this.notSubscribeWithoutH264Supported_=!1,J.logSuccessEvent({userId:this.userId_,eventType:Bg}),E.checkTrackEnded(),L.next=25;break;case 17:throw L.prev=17,L.t0=L.catch(7),(C=L.t0 instanceof j?L.t0.getCode():V.UNKNOWN)===V.NOT_SUPPORTED_H264&&(this.notSubscribeWithoutH264Supported_=!0),(O=new j(C===V.REMOTE_STREAM_NOT_EXIST?{code:V.API_CALL_ABORTED,message:H({key:$l,data:{message:L.t0.message,stream:d}})}:{code:C,message:H({key:MN,data:{message:L.t0.message,stream:d}})})).getCode()===V.API_CALL_ABORTED?this.log_.warn(O):this.log_.error(O),J.logFailedEvent({userId:this.userId_,eventType:Bg,error:O}),O;case 25:case"end":return L.stop()}},y,this,[[7,17]])})),function(y,d){return f.apply(this,arguments)})},{key:"unsubscribe",value:(S=F(M().mark(function y(d){var _;return M().wrap(function(E){for(;;)switch(E.prev=E.next){case 0:return this.log_.info("unsubscribe() => unsubscribe to [".concat(d.getUserId(),"] ").concat(d.getType()," stream")),E.prev=1,_=d.getConnection(),E.next=5,_.unsubscribe(d);case 5:this.subscriptionManager_&&this.subscriptionManager_.addUnsubscriptionRecord(d.getUserId(),d),U.emit(rn,{client:this,stream:d}),J.logSuccessEvent({userId:this.userId_,eventType:Hg}),E.next=14;break;case 10:throw E.prev=10,E.t0=E.catch(1),J.logFailedEvent({userId:this.userId_,eventType:Hg,error:E.t0}),E.t0;case 14:case"end":return E.stop()}},y,this,[[1,10]])})),function(y){return S.apply(this,arguments)})},{key:"switchRole",value:(p=F(M().mark(function y(d){return M().wrap(function(_){for(;;)switch(_.prev=_.next){case 0:if(this.role_!==d){_.next=2;break}return _.abrupt("return");case 2:return d===er&&this.uplinkConnection_&&this.closeUplink(),this.log_.info("switchRole() => switch role to: "+d),_.next=6,this.doSwitchRole(d);case 6:case"end":return _.stop()}},y,this)})),function(y){return p.apply(this,arguments)})},{key:"doSwitchRole",value:function(y){var d,_,E=this,C={command:RU,data:{role:y===Wt?Jr:Dl,privateMapKey:this.privateMapKey_},responseCommand:pe.SWITCH_ROLE_RES,retries:((d=this.schedule_.config)===null||d===void 0||(_=d.retries)===null||_===void 0?void 0:_.switchRole)||1};return this.log_.info("switchRole signal data: "+JSON.stringify(C.data)),this.signalChannel_.sendWaitForResponseWithRetry(C).then(function(O){var L=O.data,N=L.code,W=L.message;if(N!==0)throw new j({code:V.SWITCH_ROLE_FAILED,message:H({key:VN,data:{errMsg:W,errCode:N}})});E.role_=y}).catch(function(O){throw O instanceof j&&O.getCode()===V.API_CALL_TIMEOUT&&(O=new j({code:V.SWITCH_ROLE_FAILED,message:H({key:UN})})),E.log_.error(O),O})}},{key:"on",value:function(y,d,_){this.emitter_.on(y,d,_)}},{key:"off",value:function(y,d,_){y==="*"?this.emitter_.removeAllListeners():this.emitter_.off(y,d,_)}},{key:"getRemoteMutedState",value:function(){var y=this,d=[];return this.mutedStates_.forEach(function(_,E,C){var O=y.connections_.get(E);O&&d.push(te({userId:O.getUserId()},_))}),d}},{key:"getTransportStats",value:(k=F(M().mark(function y(){var d,_,E,C,O,L,N;return M().wrap(function(W){for(;;)switch(W.prev=W.next){case 0:if(d={rtt:0,downlinksRTT:{}},!this.uplinkConnection_){W.next=6;break}return W.next=4,this.stats_.getSenderStats(this.uplinkConnection_);case 4:_=W.sent,d.rtt=_.rtt;case 6:E=qt(this.connections_),W.prev=7,E.s();case 9:if((C=E.n()).done){W.next=17;break}return(O=lt(C.value,2))[0],L=O[1],W.next=13,this.stats_.getReceiverStats(L);case 13:N=W.sent,d.downlinksRTT[N.userId]=N.rtt;case 15:W.next=9;break;case 17:W.next=22;break;case 19:W.prev=19,W.t0=W.catch(7),E.e(W.t0);case 22:return W.prev=22,E.f(),W.finish(22);case 25:return W.abrupt("return",d);case 26:case"end":return W.stop()}},y,this,[[7,19,22,25]])})),function(){return k.apply(this,arguments)})},{key:"getLocalAudioStats",value:(T=F(M().mark(function y(){var d,_;return M().wrap(function(E){for(;;)switch(E.prev=E.next){case 0:if((d={})[this.userId_]={bytesSent:0,packetsSent:0},!this.uplinkConnection_){E.next=7;break}return E.next=5,this.stats_.getSenderStats(this.uplinkConnection_);case 5:_=E.sent,d[this.userId_]={bytesSent:_.audio.bytesSent,packetsSent:_.audio.packetsSent};case 7:return E.abrupt("return",d);case 8:case"end":return E.stop()}},y,this)})),function(){return T.apply(this,arguments)})},{key:"getLocalVideoStats",value:(b=F(M().mark(function y(){var d,_;return M().wrap(function(E){for(;;)switch(E.prev=E.next){case 0:if((d={})[this.userId_]={bytesSent:0,packetsSent:0,framesEncoded:0,framesSent:0,frameWidth:0,frameHeight:0},!this.uplinkConnection_){E.next=7;break}return E.next=5,this.stats_.getSenderStats(this.uplinkConnection_);case 5:_=E.sent,d[this.userId_]={bytesSent:_.video.bytesSent,packetsSent:_.video.packetsSent,framesEncoded:_.video.framesEncoded,framesSent:_.video.framesSent,frameWidth:_.video.frameWidth,frameHeight:_.video.frameHeight};case 7:return E.abrupt("return",d);case 8:case"end":return E.stop()}},y,this)})),function(){return b.apply(this,arguments)})},{key:"getRemoteAudioStats",value:(g=F(M().mark(function y(){var d,_,E,C,O,L,N,W;return M().wrap(function(B){for(;;)switch(B.prev=B.next){case 0:d={},_=qt(this.connections_),B.prev=2,_.s();case 4:if((E=_.n()).done){B.next=13;break}return(C=lt(E.value,2))[0],O=C[1],L=O.getDelay(),N=L.audioDelay,B.next=9,this.stats_.getReceiverStats(O);case 9:(W=B.sent).hasAudio&&(d[W.userId]={bytesReceived:W.audio.bytesReceived,packetsReceived:W.audio.packetsReceived,packetsLost:W.audio.packetsLost,end2EndDelay:N});case 11:B.next=4;break;case 13:B.next=18;break;case 15:B.prev=15,B.t0=B.catch(2),_.e(B.t0);case 18:return B.prev=18,_.f(),B.finish(18);case 21:return B.abrupt("return",d);case 22:case"end":return B.stop()}},y,this,[[2,15,18,21]])})),function(){return g.apply(this,arguments)})},{key:"getRemoteVideoStats",value:(h=F(M().mark(function y(){var d,_,E,C,O,L,N,W,B,se=arguments;return M().wrap(function(ee){for(;;)switch(ee.prev=ee.next){case 0:d=se.length>0&&se[0]!==void 0?se[0]:Te,_={},E=qt(this.connections_),ee.prev=3,E.s();case 5:if((C=E.n()).done){ee.next=15;break}return(O=lt(C.value,2))[0],L=O[1],ee.next=9,this.stats_.getReceiverStats(L);case 9:N=ee.sent,W=L.getDelay(),B=W.videoDelay,d===Te&&N.hasVideo&&(_[N.userId]={bytesReceived:N.video.bytesReceived,packetsReceived:N.video.packetsReceived,packetsLost:N.video.packetsLost,framesDecoded:N.video.framesDecoded,frameWidth:N.video.frameWidth,frameHeight:N.video.frameHeight,end2EndDelay:B}),d===Ne&&N.hasAuxiliary&&(_[N.userId]={bytesReceived:N.auxiliary.bytesReceived,packetsReceived:N.auxiliary.packetsReceived,packetsLost:N.auxiliary.packetsLost,framesDecoded:N.auxiliary.framesDecoded,frameWidth:N.auxiliary.frameWidth,frameHeight:N.auxiliary.frameHeight,end2EndDelay:B});case 13:ee.next=5;break;case 15:ee.next=20;break;case 17:ee.prev=17,ee.t0=ee.catch(3),E.e(ee.t0);case 20:return ee.prev=20,E.f(),ee.finish(20);case 23:return ee.abrupt("return",_);case 24:case"end":return ee.stop()}},y,this,[[3,17,20,23]])})),function(){return h.apply(this,arguments)})},{key:"getSdpSemantics",value:function(){return this.sdpSemantics_}},{key:"getIceServers",value:function(){return this.turnServers_.length===0&&this.schedule_.iceServers?this.schedule_.iceServers:this.turnServers_}},{key:"getConnections",value:function(){return this.connections_}},{key:"getMutedStates",value:function(){return this.mutedStates_}},{key:"startHeartbeat",value:function(){this.heartbeat_===-1&&(this.log_.info("startHeartbeat..."),this.heartbeat_=ye.run(Kr,this.doHeartbeat.bind(this),{delay:2e3}))}},{key:"stopHeartbeat",value:function(){this.heartbeat_!==-1&&(this.log_.info("stopHeartbeat"),ye.clearTask(this.heartbeat_),this.heartbeat_=-1,this.lastHeartBeatTime_=-1)}},{key:"doHeartbeat",value:(u=F(M().mark(function y(){var d,_,E,C,O,L;return M().wrap(function(N){for(;;)switch(N.prev=N.next){case 0:return _=this.badCaseDetector_.getMonitorFreeze(),N.next=3,this.stats_.getStatsReport({uplinkConnection:this.uplinkConnection_,downlinkConnections:this.connections_,freezeMap:_});case 3:if(E=N.sent,U.emit(Ed,{client:this,stats:E}),(d=this.badCaseDetector_)===null||d===void 0||d.resetMonitor(),this.signalChannel_){N.next=8;break}return N.abrupt("return");case 8:C=this.signalChannel_.isConnected()?cV(this.userId_):[],O=te(te({str_sdk_version:this.version_,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:Bl[this.networkType_]}},E),{},{msg_event_msg:C}),this.signalChannel_.send(fU,O),L=Date.now(),this.lastHeartBeatTime_>0&&L-this.lastHeartBeatTime_>1e4&&this.log_.warn("heartbeat took ".concat(L-this.lastHeartBeatTime_)),this.lastHeartBeatTime_=L,!this.isRelayChanged_&&this.isRelayMaybeFailed()&&(this.reJoin(),this.isRelayChanged_=!0);case 15:case"end":return N.stop()}},y,this)})),function(){return u.apply(this,arguments)})},{key:"onRemoteStreamAdded",value:function(y){var d=y.content,_=d.userId,E=d.tinyId,C=d.audio,O=d.bigVideo,L=d.auxVideo,N=d.smallVideo;if(_!==null){this.userMap_.has(_)||(this.userMap_.set(_,new Hp({userId:_,tinyId:E,role:Wt})),this.emitter_.emit(fe.PEER_JOIN,{userId:_}));var W=this.connections_.get(E);if(W){if(W.getIsReconnecting())return;this.log_.warn("duplicated stream-added observed, rebuild the connection"),W.close(),this.connections_.delete(E)}var B={audio:C,video:O,auxiliary:L,smallVideo:N};this.log_.info("remote peer [".concat(_,"] published stream. trackState: ").concat(JSON.stringify(B))),this.createDownlinkConnection({userId:_,tinyId:E,trackState:B})}else this.log_.warn("received null userId on stream added")}},{key:"createDownlinkConnection",value:function(y){var d=this,_=y.userId,E=y.tinyId,C=y.trackState,O=new G8({userId:_,tinyId:E,client:this,isUplink:!1,signalChannel:this.signalChannel_,autoSubscribe:this.autoSubscribe_,trackState:C,enableSEI:this.enableSEI_});this.connections_.set(E,O),this.installDownlinkEvents(O,_,E),this.autoSubscribe_?(O.initialize(),O.connect().catch(function(){!O.getMainStream()&&O.hasMainStream()&&d.initRemoteStream({type:Te,userId:_,downlinkConnection:O}),!O.getAuxStream()&&O.hasAuxStream()&&d.initRemoteStream({type:Ne,userId:_,downlinkConnection:O})})):(O.hasMainStream()&&this.initRemoteStream({type:Te,userId:_,downlinkConnection:O}),O.hasAuxStream()&&this.initRemoteStream({type:Ne,userId:_,downlinkConnection:O}))}},{key:"initRemoteStream",value:function(y){var d=y.type,_=y.userId,E=y.downlinkConnection,C=new Mp({type:d,userId:_,client:this});C.setConnection(E),E.setRemoteStream(d===Te?Gt:aa,C),C.setIsStreamAddedEventEmitted(!0),U.emit(ds,{client:this,stream:C}),this.emitter_.emit(fe.STREAM_ADDED,{stream:C})}},{key:"installDownlinkEvents",value:function(y,d,_){var E=this;y.on(de.SEI_MESSAGE,function(C){E.emitter_.emit(fe.SEI_MESSAGE,C)}),y.on(de.STREAM_ADDED,function(C){C.stream.setIsStreamAddedEventEmitted(!0),U.emit(ds,{client:E,stream:C.stream}),E.emitter_.emit(fe.STREAM_ADDED,{stream:C.stream})}),y.on(de.STREAM_REMOVED,function(C){E.changeBigSmallRecords_.delete(C.stream.getUserId()),C.stream.stop(),C.stream.setIsStreamAddedEventEmitted(!1),E.subscriptionManager_&&E.subscriptionManager_.deleteAutoRecoveryFlag(C.stream.getUserId(),C.stream.getType()),U.emit(cr,{client:E,stream:C.stream}),E.emitter_.emit(fe.STREAM_REMOVED,{stream:C.stream})}),y.on(de.STREAM_UPDATED,function(C){U.emit(b3,{client:E,stream:C.stream});var O=y.getMixUserList();O&&(C.mixUserList=O),E.emitter_.emit(fe.STREAM_UPDATED,C)}),y.on(de.STREAM_SUBSCRIBED,function(C){U.emit(nn,{client:E,stream:C.stream}),E.emitter_.emit(fe.STREAM_SUBSCRIBED,{stream:C.stream})}),y.on(de.ERROR,function(C){var O=C.getCode();O!==V.ICE_TRANSPORT_ERROR&&(O===V.DOWNLINK_RECONNECTION_FAILED&&E.closeDownLink(_),E.emitter_.emit(fe.ERROR,C))})}},{key:"onPeerJoin",value:function(y){var d=y.data.data,_=d.srcTinyId,E=d.userId,C=d.role;this.userMap_.has(E)||(this.userMap_.set(E,new Hp({userId:E,tinyId:_,role:C})),this.emitter_.emit(fe.PEER_JOIN,{userId:E}))}},{key:"onPeerLeave",value:function(y){var d=y.data.data,_=d.srcTinyId,E=d.userId,C=d.reason,O=C===void 0?0:C;this.log_.info("peer leave [".concat(E,"]: ").concat($M[O])),this.cleanUser({userId:E,tinyId:_})}},{key:"cleanUser",value:function(y){var d=y.userId,_=y.tinyId;this.userMap_.delete(d),this.closeDownLink(_),this.emitter_.emit(fe.PEER_LEAVE,{userId:d})}},{key:"onPublishedUserList",value:function(y){var d=this;try{var _=Se(y.data.userList);y.data.mixRobotList&&_.push.apply(_,Se(y.data.mixRobotList)),y.data.fakeMixUser&&_.push(y.data.fakeMixUser);var E=_.map(function(C){return C.userId});this.connections_.forEach(function(C){var O=C.getUserId(),L=C.getTinyId();E.findIndex(function(N){return N===O})<0&&(d.log_.info("peer unpublished detected [".concat(O,"]")),d.closeDownLink(L))}),_.forEach(function(C){var O=C.userId,L=C.srcTinyId,N=C.flag,W=C.mixUserList;if(O!==d.userId_){var B=!!(1&N),se=!!(8&N),ee=!!(4&N),ne=!!(2&N),_e=d.connections_.get(L);if((ne||B)&&d.checkSubscribeBigSmallVideo(_e,ne),_e){var ae=_e.getTrackState(),ja=ae.audio,dc=ae.video,Fa=ae.auxiliary,hT=ae.smallVideo;Yr(W)&&_e.setMixUserList(W),!dc&&B&&U.emit(mt,{client:d,tinyId:L,userId:O,action:$e.ADD,kind:q}),!ja&&se&&U.emit(mt,{client:d,tinyId:L,userId:O,action:$e.ADD,kind:K}),!Fa&&ee&&U.emit(mt,{client:d,tinyId:L,userId:O,action:$e.ADD,kind:ke}),!hT&&ne&&U.emit(mt,{client:d,tinyId:L,userId:O,action:$e.ADD,kind:Bo}),dc&&!B&&U.emit(mt,{client:d,tinyId:L,userId:O,action:$e.REMOVE,kind:q}),ja&&!se&&U.emit(mt,{client:d,tinyId:L,userId:O,action:$e.REMOVE,kind:K}),Fa&&!ee&&U.emit(mt,{client:d,tinyId:L,userId:O,action:$e.REMOVE,kind:ke}),hT&&!ne&&U.emit(mt,{client:d,tinyId:L,userId:O,action:$e.REMOVE,kind:Bo})}else d.log_.info("peer published detected [".concat(O,"]")),d.onRemoteStreamAdded({content:{audio:se,bigVideo:B,auxVideo:ee,smallVideo:ne,userId:O,tinyId:L}})}})}catch{}}},{key:"onUpdateRemoteMuteStat",value:function(y){var d=this,_=y.data;(_&&_.userList||[]).forEach(function(E){var C=E.srcTinyId,O=E.userId;if(C!==0&&C!==d.tinyId_){var L=d.connections_.get(C);if(L){var N=L.getMainStream();if(N&&N.getIsStreamAddedEventEmitted()){var W=!!(1&E.flag),B=!!(8&E.flag),se=!!(2&E.flag),ee=!!(64&E.flag),ne=!!(16&E.flag),_e=d.mutedStates_.get(C);if(_e===void 0)return d.mutedStates_.set(C,{hasAudio:B,hasVideo:W,hasSmall:se,audioMuted:ee,videoMuted:ne}),W?ne?d.emitter_.emit(fe.MUTE_VIDEO,{userId:O}):d.emitter_.emit(fe.UNMUTE_VIDEO,{userId:O}):d.emitter_.emit(fe.MUTE_VIDEO,{userId:O}),void(B?ee?d.emitter_.emit(fe.MUTE_AUDIO,{userId:O}):d.emitter_.emit(fe.UNMUTE_AUDIO,{userId:O}):d.emitter_.emit(fe.MUTE_AUDIO,{userId:O}));var ae=!_e.audioMuted&&_e.hasAudio,ja=!ee&&B,dc=!_e.videoMuted&&_e.hasVideo,Fa=!ne&&W;d.mutedStates_.set(C,{hasAudio:B,hasVideo:W,hasSmall:se,audioMuted:ee,videoMuted:ne}),ae!==ja&&(ja?d.emitter_.emit(fe.UNMUTE_AUDIO,{userId:O}):d.emitter_.emit(fe.MUTE_AUDIO,{userId:O})),dc!==Fa&&(Fa?d.emitter_.emit(fe.UNMUTE_VIDEO,{userId:O}):d.emitter_.emit(fe.MUTE_VIDEO,{userId:O}))}}else d.mutedStates_.delete(C)}})}},{key:"getEnv",value:function(){return this.env_}},{key:"getSubscriptionManager",value:function(){return this.subscriptionManager_}},{key:"startPublishCDNStream",value:(l=F(M().mark(function y(){var d,_=arguments;return M().wrap(function(E){for(;;)switch(E.prev=E.next){case 0:if(d=_.length>0&&_[0]!==void 0?_[0]:{},this.log_.info("startPublishCDNStream with params: ".concat(JSON.stringify(d),"; isJoined: ").concat(this.isJoined_,"; hasMainStream: ").concat(!!this.localStream_,"; hasAuxStream: ").concat(!!this.localAuxStream_,";")),d.streamType=d.streamType||le,d.streamType===ke&&(d.streamType=ht),d.streamId=d.streamId||"",!this.isJoined_){E.next=10;break}if(d.streamType!==le||this.localStream_){E.next=8;break}throw new j({code:V.INVALID_OPERATION,message:H({key:Ty})});case 8:if(d.streamType!==ht||this.localAuxStream_){E.next=10;break}throw new j({code:V.INVALID_OPERATION,message:H({key:Ty})});case 10:return E.next=12,this.publishCDNManager_.startPublishTencentCDN(d);case 12:if(!(d.appId&&d.bizId&&d.url)){E.next=15;break}return E.next=15,this.publishCDNManager_.startPublishGivenCDN(d);case 15:case"end":return E.stop()}},y,this)})),function(){return l.apply(this,arguments)})},{key:"stopPublishCDNStream",value:(s=F(M().mark(function y(){return M().wrap(function(d){for(;;)switch(d.prev=d.next){case 0:if(this.publishCDNManager_.getIsPublishingTencentCDN()){d.next=2;break}throw new j({code:V.INVALID_OPERATION,message:H({key:FN})});case 2:return this.log_.info("stopPublishCDNStream"),d.next=5,this.publishCDNManager_.stopPublishTencentCDN();case 5:if(!this.publishCDNManager_.getIsPublishingGivenCDN()){d.next=8;break}return d.next=8,this.publishCDNManager_.stopPublishGivenCDN();case 8:case"end":return d.stop()}},y,this)})),function(){return s.apply(this,arguments)})},{key:"startMixTranscode",value:(a=F(M().mark(function y(d){return M().wrap(function(_){for(;;)switch(_.prev=_.next){case 0:if(this.isJoined_&&this.mixTranscodeManager_){_.next=2;break}throw new j({code:V.INVALID_OPERATION,message:H({key:HN})});case 2:return G(d.mode)&&(d.mode=Fl.MANUAL),_.prev=3,this.log_.info("startMixTranscode with config ".concat(JSON.stringify(d))),J.uploadEvent({log:"mix-transcode-mode:".concat(d.mode),userId:this.userId_}),_.next=8,this.mixTranscodeManager_.startMixTranscode(d);case 8:J.logSuccessEvent({userId:this.userId_,eventType:$g}),_.next=15;break;case 11:throw _.prev=11,_.t0=_.catch(3),J.logFailedEvent({userId:this.userId_,eventType:$g,error:_.t0}),_.t0;case 15:case"end":return _.stop()}},y,this,[[3,11]])})),function(y){return a.apply(this,arguments)})},{key:"stopMixTranscode",value:(c=F(M().mark(function y(){return M().wrap(function(d){for(;;)switch(d.prev=d.next){case 0:if(this.isJoined_&&this.mixTranscodeManager_){d.next=2;break}throw new j({code:V.INVALID_OPERATION,message:H({key:WN})});case 2:return d.prev=2,d.next=5,this.mixTranscodeManager_.stopMixTranscode();case 5:J.logSuccessEvent({userId:this.userId_,eventType:Zg}),d.next=12;break;case 8:throw d.prev=8,d.t0=d.catch(2),J.logFailedEvent({userId:this.userId_,eventType:Zg,error:d.t0}),d.t0;case 12:case"end":return d.stop()}},y,this,[[2,8]])})),function(){return c.apply(this,arguments)})},{key:"getSystemResult",value:function(){return this.checkSystemResult_}},{key:"enableAudioVolumeEvaluation",value:function(){var y=this,d=arguments.length>0&&arguments[0]!==void 0?arguments[0]:2e3,_=arguments.length>1&&arguments[1]!==void 0&&arguments[1];if(!Rt(d))throw new j({code:V.INVALID_PARAMETER,message:H({key:GN})});if(this.log_.info("enableAudioVolumeEvaluation with interval: "+d),d<=0)return this.enableAudioVolumeEvaluation_=!1,ye.clearTask(this.audioVolumeIntervalId_),void(this.audioVolumeIntervalId_=null);d=Math.floor(Math.max(d,16)),U.emit(xd,{interval:d}),this.audioVolumeIntervalId_&&(ye.clearTask(this.audioVolumeIntervalId_),this.audioVolumeIntervalId_=null),this.enableAudioVolumeEvaluation_=!0,this.audioVolumeIntervalId_=ye.run(Xo,function(){var E=[];if(y.localStream_){var C=Math.floor(100*y.localStream_.getAudioLevel());E.push({userId:y.userId_,audioVolume:C,stream:y.localStream_})}y.connections_.forEach(function(O){var L=O.getSubscribedMainStream();if(L){var N=Math.floor(100*L.getAudioLevel());E.push({userId:O.getUserId(),audioVolume:N,stream:L})}}),y.emitter_.emit(fe.AUDIO_VOLUME,{result:E})},{fps:1e3/d,backgroundTask:_})}},{key:"callExperimentalAPI",value:function(y,d){return this.log_.info("callExperimentalAPI(".concat(y,", ").concat(JSON.stringify(d),")")),X8.call(y,te({client:this},d))}},{key:"setProperty",value:function(y,d){var _="".concat(y,"_");G(this[_])||(this[_]=d)}},{key:"uploadAllCallStats",value:function(){var y=this;this.callDurationCalculator_.getDurationMap().forEach(function(d,_){var E={userId:d.userId,type:d.type,duration:y.callDurationCalculator_.getDuration(_,q),dataFreeze:y.badCaseDetector_.getDataFreezeDuration(_).dataFreeze,renderFreeze:y.badCaseDetector_.getRenderFreezeDuration(_).renderFreeze};J.uploadEvent({log:"callStats-"+JSON.stringify(E),userId:y.userId_})}),this.badCaseDetector_.stop(),this.callDurationCalculator_.reset()}},{key:"enableSmallStream",value:(o=F(M().mark(function y(){return M().wrap(function(d){for(;;)switch(d.prev=d.next){case 0:if(!this.isPublished()&&!this.isPublishing_){d.next=2;break}throw new j({code:V.INVALID_OPERATION,message:H({key:zN})});case 2:if(!rb()){d.next=7;break}this.setIsEnableSmallStream(!0),this.log_.info("SmallStream successfully enabled"),d.next=8;break;case 7:throw new j({code:V.INVALID_OPERATION,message:H({key:qN})});case 8:case"end":return d.stop()}},y,this)})),function(){return o.apply(this,arguments)})},{key:"disableSmallStream",value:(r=F(M().mark(function y(){return M().wrap(function(d){for(;;)switch(d.prev=d.next){case 0:if(!this.isPublished()&&!this.isPublishing_){d.next=2;break}throw new j({code:V.INVALID_OPERATION,message:H({key:JN})});case 2:this.setIsEnableSmallStream(!1),this.log_.info("SmallStream successfully disabled");case 4:case"end":return d.stop()}},y,this)})),function(){return r.apply(this,arguments)})},{key:"setSmallStreamProfile",value:function(y){var d=this;y&&y.framerate&&(y.frameRate=y.framerate),y.width*y.height>307200&&(y.width=320,y.height=240,this.log_.info("Small stream resolution is beyond limitation, which is invalid. Reset to 320 * 240")),Object.keys(this.smallStreamConfig_).forEach(function(N){y[N]&&(d.smallStreamConfig_[N]=y[N])});var _=this.smallStreamConfig_,E=_.width,C=_.height,O=_.bitrate,L=_.frameRate;if(this.log_.info("setSmallStreamProfile: bitrate=".concat(O,", frameRate=").concat(L,", height=").concat(C,", width=").concat(E)),E<0||C<0||O<0||L<0)throw new j({code:V.INVALID_PARAMETER,message:H({key:KN})})}},{key:"setRemoteVideoStreamType",value:(i=F(M().mark(function y(d,_){return M().wrap(function(E){for(;;)switch(E.prev=E.next){case 0:if(d instanceof Mp){E.next=2;break}throw new j({code:V.INVALID_PARAMETER,message:H({key:QN})});case 2:if(d.getConnection()){E.next=4;break}throw new j({code:V.INVALID_OPERATION,message:H({key:Kl})});case 4:if(d.getType()!==Ne){E.next=6;break}return E.abrupt("return");case 6:E.t0=_,E.next=E.t0===oy||E.t0===sy?9:12;break;case 9:return E.next=11,this.changeVideoType(d,_);case 11:case 12:return E.abrupt("break",13);case 13:case"end":return E.stop()}},y,this)})),function(y,d){return i.apply(this,arguments)})},{key:"changeVideoType",value:(n=F(M().mark(function y(d,_){var E,C;return M().wrap(function(O){for(;;)switch(O.prev=O.next){case 0:E=d.getUserId(),C={stream:d,options:{video:_===oy,smallVideo:_===sy},isSubscribing:!1,reSubscribeCount:10},this.changeBigSmallRecords_.set(E,C),this.log_.info("set [".concat(E,"] ").concat(d.getType()," stream video prefer type: ").concat(_));case 5:case"end":return O.stop()}},y,this)})),function(y,d){return n.apply(this,arguments)})},{key:"checkSubscribeBigSmallVideo",value:(t=F(M().mark(function y(d,_){var E,C,O,L,N,W,B,se,ee,ne,_e;return M().wrap(function(ae){for(;;)switch(ae.prev=ae.next){case 0:if(d!=null&&d.isBigStreamSubscribed||d!=null&&d.isSmallStreamSubscribed){ae.next=2;break}return ae.abrupt("return");case 2:if(E=d.getUserId(),this.changeBigSmallRecords_.has(E)){ae.next=5;break}return ae.abrupt("return");case 5:if(C=this.changeBigSmallRecords_.get(E),O=d.getSubscribeState(),L=O.video,N=O.smallVideo,W=C.stream,B=C.options,se=C.isSubscribing,ee=C.reSubscribeCount,!(B.video&&L||B.smallVideo&&N&&_)){ae.next=10;break}return ae.abrupt("return");case 10:if(ne={video:B.video,smallVideo:B.smallVideo},!(_&&d.isBigStreamSubscribed||d.isSmallStreamSubscribed)){ae.next=31;break}if(ae.prev=12,!(B&&W&&!se&&ee>=1)){ae.next=24;break}return C.isSubscribing=!0,C.reSubscribeCount=ee-1,_e=W.getConnection(),!_&&_e.isSmallStreamSubscribed&&(ne={video:!0,smallVideo:!1}),ne.emitEvent=!1,ae.next=21,_e==null?void 0:_e.subscribe(W,ne);case 21:this.log_.info("change [".concat(E,"] to ").concat(ne.smallVideo?"small":"big"," video successfully. count ").concat(10-C.reSubscribeCount,".")),C.isSubscribing=!1,C.reSubscribeCount=10;case 24:ae.next=31;break;case 26:ae.prev=26,ae.t0=ae.catch(12),this.log_.info("change [".concat(E,"] to ").concat(ne.smallVideo?"small":"big"," video failed. count ").concat(10-C.reSubscribeCount,".")),C.isSubscribing=!1,ee===0&&this.changeBigSmallRecords_.delete(E);case 31:case"end":return ae.stop()}},y,this,[[12,26]])})),function(y,d){return t.apply(this,arguments)})},{key:"setIsEnableSmallStream",value:function(y){this.isEnableSmallStream_=y}},{key:"getIsEnableSmallStream",value:function(){return this.isEnableSmallStream_}},{key:"smallStreamConfig",get:function(){return this.smallStreamConfig_}},{key:"isPublished",value:function(){return!!this.localStream_}},{key:"getUplinkConnection",value:function(){return this.uplinkConnection_}},{key:"getLocalStream",value:function(){return this.localStream_}},{key:"getMode",value:function(){return this.mode_}},{key:"getBadCaseDetector",value:function(){return this.badCaseDetector_}},{key:"getCallDurationCalculator",value:function(){return this.callDurationCalculator_}},{key:"getIsJoined",value:function(){return this.isJoined_}},{key:"getAllConnections",value:function(){var y=Se(this.connections_.values());return this.uplinkConnection_&&y.push(this.uplinkConnection_),y}},{key:"isRelayMaybeFailed",value:function(){if(!this.signalChannel_.isOnline)return!1;var y=this.getAllConnections();if(y.length===0)return!1;for(var d=0;d<y.length;d++)if(y[d].getReconnectionCount()<6)return!1;return!0}},{key:"getUseStringRoomId",value:function(){return this.useStringRoomId_}},{key:"checkConnectionsToReconnect",value:function(){var y=this;this.getAllConnections().forEach(function(d){if(!d.getIsReconnecting()){var _=d.getPeerConnection();_&&_.connectionState===Ml&&(y.log_.warn("[".concat(d.getUserId(),"] pc is closed but not reconnect")),d.startReconnection())}})}},{key:"getEnableAutoPlayDialog",value:function(){return this.enableAutoPlayDialog_}},{key:"sendSEIMessage",value:function(y,d){this.uplinkConnection_.sendSEI(y,d)}},{key:"setProxyServer",value:function(y){if(this.log_.info("set proxy server: ".concat(JSON.stringify(y))),je(y)){if(!y.startsWith("wss://"))throw new j({code:V.INVALID_PARAMETER,message:H({key:kN})});this.proxy_=y}else if(An(y)){var d=y.websocketProxy,_=y.loggerProxy,E=y.scheduleProxy,C=y.unifiedProxy;d&&(this.proxy_=d),_&&Pl(_),E&&uy(E),C&&(this.unifiedProxy_=C,Pl("https://".concat(C)),uy(C))}}},{key:"setTurnServer",value:function(y){this.log_.info("set turn server: "+JSON.stringify(y));var d=[];Array.isArray(y)?y.forEach(function(_){return d.push(Zy(_))}):An(y)&&d.push(Zy(y)),this.turnServers_=d}},{key:"get2k4kFlag",value:function(){var y,d;return((y=this.schedule_)===null||y===void 0||(d=y.trtcCapability)===null||d===void 0?void 0:d["2k4k"])||2}},{key:"getWSProxy",value:function(){return this.proxy_}},{key:"getUnifiedProxy",value:function(){return this.unifiedProxy_}}]),e}(),ie(Q.prototype,"join",[AI,xI,PI],Object.getOwnPropertyDescriptor(Q.prototype,"join"),Q.prototype),ie(Q.prototype,"leave",[DI],Object.getOwnPropertyDescriptor(Q.prototype,"leave"),Q.prototype),ie(Q.prototype,"getUserList",[OI],Object.getOwnPropertyDescriptor(Q.prototype,"getUserList"),Q.prototype),ie(Q.prototype,"publish",[MI,NI,LI],Object.getOwnPropertyDescriptor(Q.prototype,"publish"),Q.prototype),ie(Q.prototype,"unpublish",[UI,VI],Object.getOwnPropertyDescriptor(Q.prototype,"unpublish"),Q.prototype),ie(Q.prototype,"subscribe",[jI],Object.getOwnPropertyDescriptor(Q.prototype,"subscribe"),Q.prototype),ie(Q.prototype,"unsubscribe",[FI],Object.getOwnPropertyDescriptor(Q.prototype,"unsubscribe"),Q.prototype),ie(Q.prototype,"switchRole",[BI,HI,WI],Object.getOwnPropertyDescriptor(Q.prototype,"switchRole"),Q.prototype),ie(Q.prototype,"startPublishCDNStream",[GI,zI],Object.getOwnPropertyDescriptor(Q.prototype,"startPublishCDNStream"),Q.prototype),ie(Q.prototype,"stopPublishCDNStream",[JI],Object.getOwnPropertyDescriptor(Q.prototype,"stopPublishCDNStream"),Q.prototype),ie(Q.prototype,"startMixTranscode",[qI,KI],Object.getOwnPropertyDescriptor(Q.prototype,"startMixTranscode"),Q.prototype),ie(Q.prototype,"stopMixTranscode",[QI],Object.getOwnPropertyDescriptor(Q.prototype,"stopMixTranscode"),Q.prototype),ie(Q.prototype,"enableAudioVolumeEvaluation",[XI],Object.getOwnPropertyDescriptor(Q.prototype,"enableAudioVolumeEvaluation"),Q.prototype),ie(Q.prototype,"enableSmallStream",[YI],Object.getOwnPropertyDescriptor(Q.prototype,"enableSmallStream"),Q.prototype),ie(Q.prototype,"disableSmallStream",[$I],Object.getOwnPropertyDescriptor(Q.prototype,"disableSmallStream"),Q.prototype),ie(Q.prototype,"setSmallStreamProfile",[ZI],Object.getOwnPropertyDescriptor(Q.prototype,"setSmallStreamProfile"),Q.prototype),ie(Q.prototype,"setRemoteVideoStreamType",[eT],Object.getOwnPropertyDescriptor(Q.prototype,"setRemoteVideoStreamType"),Q.prototype),ie(Q.prototype,"sendSEIMessage",[tT,nT,rT],Object.getOwnPropertyDescriptor(Q.prototype,"sendSEIMessage"),Q.prototype),ie(Q.prototype,"setProxyServer",[iT],Object.getOwnPropertyDescriptor(Q.prototype,"setProxyServer"),Q.prototype),ie(Q.prototype,"setTurnServer",[aT],Object.getOwnPropertyDescriptor(Q.prototype,"setTurnServer"),Q.prototype),Q),$8=0,Z8=0,eB=(oT=Ee(ua),sT=Ee(ua),cT=Ee(ua),uT=Qs(We.TRTC.createClient),lT=Ee(ua),dT=Qs(We.TRTC.createStream),Ge=function(){function e(){ce(this,e),this.name_=ua,this.VERSION=Wn,this.Logger={loggerManager:z,LogLevel:pt,setLogLevel:function(n){z.setLogLevel(n),n<=1&&m3()},enableUploadLog:function(){jn.handleFunctionState({fnName:"TRTC.enableUploadLog"}),z.enableUploadLog()},disableUploadLog:function(){z.warn("disableUploadLog"),jn.handleFunctionState({fnName:"TRTC.disableUploadLog"}),z.disableUploadLog()}}}var t;return ue(e,[{key:"checkSystemRequirements",value:(t=F(M().mark(function n(){return M().wrap(function(i){for(;;)switch(i.prev=i.next){case 0:return i.next=2,mh();case 2:return i.abrupt("return",i.sent);case 3:case"end":return i.stop()}},n)})),function(){return t.apply(this,arguments)})},{key:"isScreenShareSupported",value:function(){return ZS()}},{key:"isSmallStreamSupported",value:function(){return rb()}},{key:"getDevices",value:function(){return kh()}},{key:"getCameras",value:function(){return function(){return bh.apply(this,arguments)}()}},{key:"getMicrophones",value:function(){return cb()}},{key:"getSpeakers",value:function(){return ub()}},{key:"createClient",value:function(n){(function(){if(lS&&(lS=!1,z.getLogLevel()!=Ce.Logger.LogLevel.NONE&&(console.info("******************************************************************************"),console.info("* TRTC Web SDK"),console.info("* API Document: "+"".concat(zl,"index.html")),console.info("* Changelog: https://cloud.tencent.com/document/product/647/38958"),console.info("* Report issues: https://github.com/LiteAVSDK/TRTC_Web/issues"),console.info("******************************************************************************")),z.info("TRTC Web SDK Version: 4.15.22"),z.info("UserAgent: "+navigator.userAgent),z.info("URL of current page: "+location.href),navigator.userAgentData&&et(navigator.userAgentData.getHighEntropyValues)))try{navigator.userAgentData.getHighEntropyValues(["architecture","bitness","model","platformVersion","fullVersionList"]).then(function(o){var c="UAData: ".concat(o.platform,"/").concat(o.platformVersion);o.architecture&&o.bitness&&(c+=" ".concat(o.architecture,"/").concat(o.bitness)),o.mobile&&(c+=" mobile"),o.model&&(c+=" model: ".concat(o.model)),o.fullVersionList&&(c+=" ".concat(o.fullVersionList.filter(function(a){return a.brand!=="Not/A)Brand"}).map(function(a){return"".concat(a.brand,"/").concat(a.version)}).join(","))),z.info(c)}).catch(function(){})}catch{}})();var i={version:this.VERSION},r=new Y8(te(te(te({},i),n),{},{seq:++$8}));return U.emit(oS,{client:r}),r}},{key:"createStream",value:function(n){return new S8(te(te({},n),{},{seq:++Z8}))}}]),e}(),ie(Ge.prototype,"checkSystemRequirements",[oT],Object.getOwnPropertyDescriptor(Ge.prototype,"checkSystemRequirements"),Ge.prototype),ie(Ge.prototype,"isScreenShareSupported",[sT],Object.getOwnPropertyDescriptor(Ge.prototype,"isScreenShareSupported"),Ge.prototype),ie(Ge.prototype,"isSmallStreamSupported",[cT],Object.getOwnPropertyDescriptor(Ge.prototype,"isSmallStreamSupported"),Ge.prototype),ie(Ge.prototype,"createClient",[uT,lT],Object.getOwnPropertyDescriptor(Ge.prototype,"createClient"),Ge.prototype),ie(Ge.prototype,"createStream",[dT],Object.getOwnPropertyDescriptor(Ge.prototype,"createStream"),Ge.prototype),Ge),Ce=new eB;return Ce})}(hc)),hc.exports}export{iB as r};