@lingoace/lingo-trtc-rtc 0.0.12 → 0.0.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/trtc-lingo.js +63 -99
package/trtc-lingo.js CHANGED
@@ -1,111 +1,75 @@
1
- var $7=Object.create;var _d=Object.defineProperty,Z7=Object.defineProperties,Ww=Object.getOwnPropertyDescriptor,e9=Object.getOwnPropertyDescriptors,t9=Object.getOwnPropertyNames,zw=Object.getOwnPropertySymbols,n9=Object.getPrototypeOf,Jw=Object.prototype.hasOwnProperty,r9=Object.prototype.propertyIsEnumerable;var lg=(Z,H,p)=>H in Z?_d(Z,H,{enumerable:!0,configurable:!0,writable:!0,value:p}):Z[H]=p,qr=(Z,H)=>{for(var p in H||(H={}))Jw.call(H,p)&&lg(Z,p,H[p]);if(zw)for(var p of zw(H))r9.call(H,p)&&lg(Z,p,H[p]);return Z},yd=(Z,H)=>Z7(Z,e9(H));var dg=(Z,H)=>()=>(H||Z((H={exports:{}}).exports,H),H.exports);var i9=(Z,H,p,V)=>{if(H&&typeof H=="object"||typeof H=="function")for(let X of t9(H))!Jw.call(Z,X)&&X!==p&&_d(Z,X,{get:()=>H[X],enumerable:!(V=Ww(H,X))||V.enumerable});return Z};var sr=(Z,H,p)=>(p=Z!=null?$7(n9(Z)):{},i9(H||!Z||!Z.__esModule?_d(p,"default",{value:Z,enumerable:!0}):p,Z));var En=(Z,H,p,V)=>{for(var X=V>1?void 0:V?Ww(H,p):H,N=Z.length-1,J;N>=0;N--)(J=Z[N])&&(X=(V?J(H,p,X):J(X))||X);return V&&X&&_d(H,p,X),X};var Ue=(Z,H,p)=>(lg(Z,typeof H!="symbol"?H+"":H,p),p);var Rr=dg((hg,pg)=>{(function(Z,H){typeof hg=="object"&&typeof pg!="undefined"?pg.exports=H():typeof define=="function"&&define.amd?define(H):(Z=typeof globalThis!="undefined"?globalThis:Z||self).TRTC=H()})(hg,function(){function Z(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),n.push.apply(n,r)}return n}function H(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?Z(Object(n),!0).forEach(function(r){ut(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Z(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}function p(){p=function(){return e};var e={},t=Object.prototype,n=t.hasOwnProperty,r=typeof Symbol=="function"?Symbol:{},i=r.iterator||"@@iterator",o=r.asyncIterator||"@@asyncIterator",a=r.toStringTag||"@@toStringTag";function s(A,U,T){return Object.defineProperty(A,U,{value:T,enumerable:!0,configurable:!0,writable:!0}),A[U]}try{s({},"")}catch(A){s=function(U,T,v){return U[T]=v}}function c(A,U,T,v){var E=U&&U.prototype instanceof h?U:h,C=Object.create(E.prototype),O=new L(v||[]);return C._invoke=function(F,K,re){var ce="suspendedStart";return function(ge,Ye){if(ce==="executing")throw new Error("Generator is already running");if(ce==="completed"){if(ge==="throw")throw Ye;return P()}for(re.method=ge,re.arg=Ye;;){var Ve=re.delegate;if(Ve){var Ge=z(Ve,re);if(Ge){if(Ge===d)continue;return Ge}}if(re.method==="next")re.sent=re._sent=re.arg;else if(re.method==="throw"){if(ce==="suspendedStart")throw ce="completed",re.arg;re.dispatchException(re.arg)}else re.method==="return"&&re.abrupt("return",re.arg);ce="executing";var Ke=u(F,K,re);if(Ke.type==="normal"){if(ce=re.done?"completed":"suspendedYield",Ke.arg===d)continue;return{value:Ke.arg,done:re.done}}Ke.type==="throw"&&(ce="completed",re.method="throw",re.arg=Ke.arg)}}}(A,T,O),C}function u(A,U,T){try{return{type:"normal",arg:A.call(U,T)}}catch(v){return{type:"throw",arg:v}}}e.wrap=c;var d={};function h(){}function _(){}function y(){}var b={};s(b,i,function(){return this});var f=Object.getPrototypeOf,g=f&&f(f(k([])));g&&g!==t&&n.call(g,i)&&(b=g);var I=y.prototype=h.prototype=Object.create(b);function w(A){["next","throw","return"].forEach(function(U){s(A,U,function(T){return this._invoke(U,T)})})}function j(A,U){function T(E,C,O,F){var K=u(A[E],A,C);if(K.type!=="throw"){var re=K.arg,ce=re.value;return ce&&typeof ce=="object"&&n.call(ce,"__await")?U.resolve(ce.__await).then(function(ge){T("next",ge,O,F)},function(ge){T("throw",ge,O,F)}):U.resolve(ce).then(function(ge){re.value=ge,O(re)},function(ge){return T("throw",ge,O,F)})}F(K.arg)}var v;this._invoke=function(E,C){function O(){return new U(function(F,K){T(E,C,F,K)})}return v=v?v.then(O,O):O()}}function z(A,U){var T=A.iterator[U.method];if(T===void 0){if(U.delegate=null,U.method==="throw"){if(A.iterator.return&&(U.method="return",U.arg=void 0,z(A,U),U.method==="throw"))return d;U.method="throw",U.arg=new TypeError("The iterator does not provide a 'throw' method")}return d}var v=u(T,A.iterator,U.arg);if(v.type==="throw")return U.method="throw",U.arg=v.arg,U.delegate=null,d;var E=v.arg;return E?E.done?(U[A.resultName]=E.value,U.next=A.nextLoc,U.method!=="return"&&(U.method="next",U.arg=void 0),U.delegate=null,d):E:(U.method="throw",U.arg=new TypeError("iterator result is not an object"),U.delegate=null,d)}function $(A){var U={tryLoc:A[0]};1 in A&&(U.catchLoc=A[1]),2 in A&&(U.finallyLoc=A[2],U.afterLoc=A[3]),this.tryEntries.push(U)}function ue(A){var U=A.completion||{};U.type="normal",delete U.arg,A.completion=U}function L(A){this.tryEntries=[{tryLoc:"root"}],A.forEach($,this),this.reset(!0)}function k(A){if(A){var U=A[i];if(U)return U.call(A);if(typeof A.next=="function")return A;if(!isNaN(A.length)){var T=-1,v=function E(){for(;++T<A.length;)if(n.call(A,T))return E.value=A[T],E.done=!1,E;return E.value=void 0,E.done=!0,E};return v.next=v}}return{next:P}}function P(){return{value:void 0,done:!0}}return _.prototype=y,s(I,"constructor",y),s(y,"constructor",_),_.displayName=s(y,a,"GeneratorFunction"),e.isGeneratorFunction=function(A){var U=typeof A=="function"&&A.constructor;return!!U&&(U===_||(U.displayName||U.name)==="GeneratorFunction")},e.mark=function(A){return Object.setPrototypeOf?Object.setPrototypeOf(A,y):(A.__proto__=y,s(A,a,"GeneratorFunction")),A.prototype=Object.create(I),A},e.awrap=function(A){return{__await:A}},w(j.prototype),s(j.prototype,o,function(){return this}),e.AsyncIterator=j,e.async=function(A,U,T,v,E){E===void 0&&(E=Promise);var C=new j(c(A,U,T,v),E);return e.isGeneratorFunction(U)?C:C.next().then(function(O){return O.done?O.value:C.next()})},w(I),s(I,a,"Generator"),s(I,i,function(){return this}),s(I,"toString",function(){return"[object Generator]"}),e.keys=function(A){var U=[];for(var T in A)U.push(T);return U.reverse(),function v(){for(;U.length;){var E=U.pop();if(E in A)return v.value=E,v.done=!1,v}return v.done=!0,v}},e.values=k,L.prototype={constructor:L,reset:function(A){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(ue),!A)for(var U in this)U.charAt(0)==="t"&&n.call(this,U)&&!isNaN(+U.slice(1))&&(this[U]=void 0)},stop:function(){this.done=!0;var A=this.tryEntries[0].completion;if(A.type==="throw")throw A.arg;return this.rval},dispatchException:function(A){if(this.done)throw A;var U=this;function T(K,re){return C.type="throw",C.arg=A,U.next=K,re&&(U.method="next",U.arg=void 0),!!re}for(var v=this.tryEntries.length-1;v>=0;--v){var E=this.tryEntries[v],C=E.completion;if(E.tryLoc==="root")return T("end");if(E.tryLoc<=this.prev){var O=n.call(E,"catchLoc"),F=n.call(E,"finallyLoc");if(O&&F){if(this.prev<E.catchLoc)return T(E.catchLoc,!0);if(this.prev<E.finallyLoc)return T(E.finallyLoc)}else if(O){if(this.prev<E.catchLoc)return T(E.catchLoc,!0)}else{if(!F)throw new Error("try statement without catch or finally");if(this.prev<E.finallyLoc)return T(E.finallyLoc)}}}},abrupt:function(A,U){for(var T=this.tryEntries.length-1;T>=0;--T){var v=this.tryEntries[T];if(v.tryLoc<=this.prev&&n.call(v,"finallyLoc")&&this.prev<v.finallyLoc){var E=v;break}}E&&(A==="break"||A==="continue")&&E.tryLoc<=U&&U<=E.finallyLoc&&(E=null);var C=E?E.completion:{};return C.type=A,C.arg=U,E?(this.method="next",this.next=E.finallyLoc,d):this.complete(C)},complete:function(A,U){if(A.type==="throw")throw A.arg;return A.type==="break"||A.type==="continue"?this.next=A.arg:A.type==="return"?(this.rval=this.arg=A.arg,this.method="return",this.next="end"):A.type==="normal"&&U&&(this.next=U),d},finish:function(A){for(var U=this.tryEntries.length-1;U>=0;--U){var T=this.tryEntries[U];if(T.finallyLoc===A)return this.complete(T.completion,T.afterLoc),ue(T),d}},catch:function(A){for(var U=this.tryEntries.length-1;U>=0;--U){var T=this.tryEntries[U];if(T.tryLoc===A){var v=T.completion;if(v.type==="throw"){var E=v.arg;ue(T)}return E}}throw new Error("illegal catch attempt")},delegateYield:function(A,U,T){return this.delegate={iterator:k(A),resultName:U,nextLoc:T},this.method==="next"&&(this.arg=void 0),d}},e}function V(e){return V=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},V(e)}function X(e,t,n,r,i,o,a){try{var s=e[o](a),c=s.value}catch(u){return void n(u)}s.done?t(c):Promise.resolve(c).then(r,i)}function N(e){return function(){var t=this,n=arguments;return new Promise(function(r,i){var o=e.apply(t,n);function a(c){X(o,r,i,a,s,"next",c)}function s(c){X(o,r,i,a,s,"throw",c)}a(void 0)})}}function J(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function Pe(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function ye(e,t,n){return t&&Pe(e.prototype,t),n&&Pe(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}function ut(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Nt(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&&cr(e,t)}function $e(e){return $e=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},$e(e)}function cr(e,t){return cr=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(n,r){return n.__proto__=r,n},cr(e,t)}function Dc(){if(typeof Reflect=="undefined"||!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(e){return!1}}function Go(e,t,n){return Go=Dc()?Reflect.construct.bind():function(r,i,o){var a=[null];a.push.apply(a,i);var s=new(Function.bind.apply(r,a));return o&&cr(s,o.prototype),s},Go.apply(null,arguments)}function Ho(e){var t=typeof Map=="function"?new Map:void 0;return Ho=function(n){if(n===null||(r=n,Function.toString.call(r).indexOf("[native code]")===-1))return n;var r;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,i)}function i(){return Go(n,arguments,$e(this).constructor)}return i.prototype=Object.create(n.prototype,{constructor:{value:i,enumerable:!1,writable:!0,configurable:!0}}),cr(i,n)},Ho(e)}function zo(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 Ar(e){var t=Dc();return function(){var n,r=$e(e);if(t){var i=$e(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return zo(this,n)}}function Lc(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&(e=$e(e))!==null;);return e}function se(){return se=typeof Reflect!="undefined"&&Reflect.get?Reflect.get.bind():function(e,t,n){var r=Lc(e,t);if(r){var i=Object.getOwnPropertyDescriptor(r,t);return i.get?i.get.call(arguments.length<3?e:n):i.value}},se.apply(this,arguments)}function Te(e,t){return function(n){if(Array.isArray(n))return n}(e)||function(n,r){var i=n==null?null:typeof Symbol!="undefined"&&n[Symbol.iterator]||n["@@iterator"];if(i!=null){var o,a,s=[],c=!0,u=!1;try{for(i=i.call(n);!(c=(o=i.next()).done)&&(s.push(o.value),!r||s.length!==r);c=!0);}catch(d){u=!0,a=d}finally{try{c||i.return==null||i.return()}finally{if(u)throw a}}return s}}(e,t)||Be(e,t)||function(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
2
- In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}()}function be(e){return function(t){if(Array.isArray(t))return ze(t)}(e)||function(t){if(typeof Symbol!="undefined"&&t[Symbol.iterator]!=null||t["@@iterator"]!=null)return Array.from(t)}(e)||Be(e)||function(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
3
- In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}()}function Be(e,t){if(e){if(typeof e=="string")return ze(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)?ze(e,t):void 0}}function ze(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function ie(e,t){var n=typeof Symbol!="undefined"&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=Be(e))||t&&e&&typeof e.length=="number"){n&&(e=n);var r=0,i=function(){};return{s:i,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(c){throw c},f:i}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
4
- In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var o,a=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var c=n.next();return a=c.done,c},e:function(c){s=!0,o=c},f:function(){try{a||n.return==null||n.return()}finally{if(s)throw o}}}}function W(e,t,n,r,i){var o={};return Object.keys(r).forEach(function(a){o[a]=r[a]}),o.enumerable=!!o.enumerable,o.configurable=!!o.configurable,("value"in o||o.initializer)&&(o.writable=!0),o=n.slice().reverse().reduce(function(a,s){return s(e,t,a)||a},o),i&&o.initializer!==void 0&&(o.value=o.initializer?o.initializer.call(i):void 0,o.initializer=void 0),o.initializer===void 0&&(Object.defineProperty(e,t,o),o=null),o}var ae=typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:typeof global!="undefined"?global:typeof self!="undefined"?self:{},B=function(e){return e&&e.Math==Math&&e},te=B(typeof globalThis=="object"&&globalThis)||B(typeof window=="object"&&window)||B(typeof self=="object"&&self)||B(typeof ae=="object"&&ae)||function(){return this}()||Function("return this")(),Se={},oe=function(e){try{return!!e()}catch(t){return!0}},_e=!oe(function(){return Object.defineProperty({},1,{get:function(){return 7}})[1]!=7}),Oe=!oe(function(){var e=function(){}.bind();return typeof e!="function"||e.hasOwnProperty("prototype")}),Jt=Oe,Zt=Function.prototype.call,Qe=Jt?Zt.bind(Zt):function(){return Zt.apply(Zt,arguments)},Kt={},ht={}.propertyIsEnumerable,Jn=Object.getOwnPropertyDescriptor,ur=Jn&&!ht.call({1:2},1);Kt.f=ur?function(e){var t=Jn(this,e);return!!t&&t.enumerable}:ht;var Ht,An,et=function(e,t){return{enumerable:!(1&e),configurable:!(2&e),writable:!(4&e),value:t}},zt=Oe,Kn=Function.prototype,de=Kn.call,le=zt&&Kn.bind.bind(de,de),Ne=function(e){return zt?le(e):function(){return de.apply(e,arguments)}},Je=Ne,De=Je({}.toString),lt=Je("".slice),it=function(e){return lt(De(e),8,-1)},Vt=it,en=Ne,pe=function(e){if(Vt(e)==="Function")return en(e)},Lt=oe,qt=it,lr=Object,wi=pe("".split),yn=Lt(function(){return!lr("z").propertyIsEnumerable(0)})?function(e){return qt(e)=="String"?wi(e,""):lr(e)}:lr,Ct=function(e){return e==null},Dd=Ct,Ot=TypeError,pt=function(e){if(Dd(e))throw Ot("Can't call method on "+e);return e},Oc=yn,Mc=pt,Sn=function(e){return Oc(Mc(e))},va=typeof document=="object"&&document.all,Ei={all:va,IS_HTMLDDA:va===void 0&&va!==void 0},Nc=Ei.all,at=Ei.IS_HTMLDDA?function(e){return typeof e=="function"||e===Nc}:function(e){return typeof e=="function"},ga=at,Vc=Ei.all,ot=Ei.IS_HTMLDDA?function(e){return typeof e=="object"?e!==null:ga(e)||e===Vc}:function(e){return typeof e=="object"?e!==null:ga(e)},_a=te,Wo=at,Uc=function(e){return Wo(e)?e:void 0},Pn=function(e,t){return arguments.length<2?Uc(_a[e]):_a[e]&&_a[e][t]},bn=pe({}.isPrototypeOf),qn=Pn("navigator","userAgent")||"",Bc=te,ya=qn,Xr=Bc.process,Sa=Bc.Deno,Jo=Xr&&Xr.versions||Sa&&Sa.version,Ko=Jo&&Jo.v8;Ko&&(An=(Ht=Ko.split("."))[0]>0&&Ht[0]<4?1:+(Ht[0]+Ht[1])),!An&&ya&&(!(Ht=ya.match(/Edge\/(\d+)/))||Ht[1]>=74)&&(Ht=ya.match(/Chrome\/(\d+)/))&&(An=+Ht[1]);var dr=An,hr=dr,Ci=oe,qo=!!Object.getOwnPropertySymbols&&!Ci(function(){var e=Symbol();return!String(e)||!(Object(e)instanceof Symbol)||!Symbol.sham&&hr&&hr<41}),Xo=qo&&!Symbol.sham&&typeof Symbol.iterator=="symbol",Qo=Pn,jc=at,Pr=bn,Yo=Object,Ri=Xo?function(e){return typeof e=="symbol"}:function(e){var t=Qo("Symbol");return jc(t)&&Pr(t.prototype,Yo(e))},ba=String,Xn=function(e){try{return ba(e)}catch(t){return"Object"}},Ld=at,Qr=Xn,Qn=TypeError,Ut=function(e){if(Ld(e))return e;throw Qn(Qr(e)+" is not a function")},Fc=Ut,wt=Ct,Xt=function(e,t){var n=e[t];return wt(n)?void 0:Fc(n)},Ai=Qe,$o=at,Yr=ot,Zo=TypeError,Dr={exports:{}},$r=te,ka=Object.defineProperty,Ta=function(e,t){try{ka($r,e,{value:t,configurable:!0,writable:!0})}catch(n){$r[e]=t}return t},es=Ta,xa="__core-js_shared__",Ia=te[xa]||es(xa,{}),pn=Ia;(Dr.exports=function(e,t){return pn[e]||(pn[e]=t!==void 0?t:{})})("versions",[]).push({version:"3.25.5",mode:"global",copyright:"\xA9 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 Dn=pt,Pi=Object,Bt=function(e){return Pi(Dn(e))},ts=Bt,Gc=pe({}.hasOwnProperty),xt=Object.hasOwn||function(e,t){return Gc(ts(e),t)},Ln=pe,Hc=0,wa=Math.random(),On=Ln(1 .toString),Di=function(e){return"Symbol("+(e===void 0?"":e)+")_"+On(++Hc+wa,36)},ns=te,Od=Dr.exports,zc=xt,Wc=Di,rs=qo,is=Xo,Zr=Od("wks"),Rt=ns.Symbol,as=Rt&&Rt.for,Jc=is?Rt:Rt&&Rt.withoutSetter||Wc,nt=function(e){if(!zc(Zr,e)||!rs&&typeof Zr[e]!="string"){var t="Symbol."+e;rs&&zc(Rt,e)?Zr[e]=Rt[e]:Zr[e]=is&&as?as(t):Jc(t)}return Zr[e]},Kc=Qe,os=ot,qc=Ri,Xc=Xt,Qc=function(e,t){var n,r;if(t==="string"&&$o(n=e.toString)&&!Yr(r=Ai(n,e))||$o(n=e.valueOf)&&!Yr(r=Ai(n,e))||t!=="string"&&$o(n=e.toString)&&!Yr(r=Ai(n,e)))return r;throw Zo("Can't convert object to primitive value")},Ea=TypeError,Yc=nt("toPrimitive"),Ca=function(e,t){if(!os(e)||qc(e))return e;var n,r=Xc(e,Yc);if(r){if(t===void 0&&(t="default"),n=Kc(r,e,t),!os(n)||qc(n))return n;throw Ea("Can't convert object to primitive value")}return t===void 0&&(t="number"),Qc(e,t)},Li=Ca,Md=Ri,Ra=function(e){var t=Li(e,"string");return Md(t)?t:t+""},$c=ot,ss=te.document,cs=$c(ss)&&$c(ss.createElement),pr=function(e){return cs?ss.createElement(e):{}},Nd=pr,Zc=!_e&&!oe(function(){return Object.defineProperty(Nd("div"),"a",{get:function(){return 7}}).a!=7}),Vd=_e,Ud=Qe,us=Kt,eu=et,tu=Sn,Oi=Ra,kn=xt,Bd=Zc,nu=Object.getOwnPropertyDescriptor;Se.f=Vd?nu:function(e,t){if(e=tu(e),t=Oi(t),Bd)try{return nu(e,t)}catch(n){}if(kn(e,t))return eu(!Ud(us.f,e,t),e[t])};var At={},ls=_e&&oe(function(){return Object.defineProperty(function(){},"prototype",{value:42,writable:!1}).prototype!=42}),ds=ot,hs=String,ei=TypeError,It=function(e){if(ds(e))return e;throw ei(hs(e)+" is not an object")},ps=_e,jd=Zc,Fd=ls,fr=It,fs=Ra,ru=TypeError,ms=Object.defineProperty,Gd=Object.getOwnPropertyDescriptor,Aa="enumerable",iu="configurable",Hd="writable";At.f=ps?Fd?function(e,t,n){if(fr(e),t=fs(t),fr(n),typeof e=="function"&&t==="prototype"&&"value"in n&&Hd in n&&!n.writable){var r=Gd(e,t);r&&r.writable&&(e[t]=n.value,n={configurable:iu in n?n.configurable:r.configurable,enumerable:Aa in n?n.enumerable:r.enumerable,writable:!1})}return ms(e,t,n)}:ms:function(e,t,n){if(fr(e),t=fs(t),fr(n),jd)try{return ms(e,t,n)}catch(r){}if("get"in n||"set"in n)throw ru("Accessors not supported");return"value"in n&&(e[t]=n.value),e};var au=At,zd=et,Mn=_e?function(e,t,n){return au.f(e,t,zd(1,n))}:function(e,t,n){return e[t]=n,e},Mi={exports:{}},Pa=_e,Wd=xt,ou=Function.prototype,Jd=Pa&&Object.getOwnPropertyDescriptor,Da=Wd(ou,"name"),Yn={EXISTS:Da,PROPER:Da&&function(){}.name==="something",CONFIGURABLE:Da&&(!Pa||Pa&&Jd(ou,"name").configurable)},Kd=at,ti=Ia,qd=pe(Function.toString);Kd(ti.inspectSource)||(ti.inspectSource=function(e){return qd(e)});var La,ni,Ni,l=ti.inspectSource,m=at,S=te.WeakMap,x=m(S)&&/native code/.test(String(S)),D=Dr.exports,R=Di,M=D("keys"),G=function(e){return M[e]||(M[e]=R(e))},Q={},he=x,fe=te,we=ot,Re=Mn,me=xt,Le=Ia,je=G,st=Q,dt="Object already initialized",jt=fe.TypeError,fn=fe.WeakMap;if(he||Le.state){var St=Le.state||(Le.state=new fn);St.get=St.get,St.has=St.has,St.set=St.set,La=function(e,t){if(St.has(e))throw jt(dt);return t.facade=e,St.set(e,t),t},ni=function(e){return St.get(e)||{}},Ni=function(e){return St.has(e)}}else{var qe=je("state");st[qe]=!0,La=function(e,t){if(me(e,qe))throw jt(dt);return t.facade=e,Re(e,qe,t),t},ni=function(e){return me(e,qe)?e[qe]:{}},Ni=function(e){return me(e,qe)}}var Xe={set:La,get:ni,has:Ni,enforce:function(e){return Ni(e)?ni(e):La(e,{})},getterFor:function(e){return function(t){var n;if(!we(t)||(n=ni(t)).type!==e)throw jt("Incompatible receiver, "+e+" required");return n}}},mr=oe,Oa=at,Nn=xt,Ma=_e,ri=Yn.CONFIGURABLE,Na=l,vs=Xe.enforce,hE=Xe.get,su=Object.defineProperty,pE=Ma&&!mr(function(){return su(function(){},"length",{value:8}).length!==8}),fE=String(String).split("String"),mE=Mi.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),(!Nn(e,"name")||ri&&e.name!==t)&&(Ma?su(e,"name",{value:t,configurable:!0}):e.name=t),pE&&n&&Nn(n,"arity")&&e.length!==n.arity&&su(e,"length",{value:n.arity});try{n&&Nn(n,"constructor")&&n.constructor?Ma&&su(e,"prototype",{writable:!1}):e.prototype&&(e.prototype=void 0)}catch(i){}var r=vs(e);return Nn(r,"source")||(r.source=fE.join(typeof t=="string"?t:"")),e};Function.prototype.toString=mE(function(){return Oa(this)&&hE(this).source||Na(this)},"toString");var vE=at,gE=At,_E=Mi.exports,yE=Ta,Qt=function(e,t,n,r){r||(r={});var i=r.enumerable,o=r.name!==void 0?r.name:t;if(vE(n)&&_E(n,o,r),r.global)i?e[t]=n:yE(t,n);else{try{r.unsafe?e[t]&&(i=!0):delete e[t]}catch(a){}i?e[t]=n:gE.f(e,t,{value:n,enumerable:!1,configurable:!r.nonConfigurable,writable:!r.nonWritable})}return e},ii={},SE=Math.ceil,bE=Math.floor,kE=Math.trunc||function(e){var t=+e;return(t>0?bE:SE)(t)},$n=function(e){var t=+e;return t!=t||t===0?0:kE(t)},TE=$n,xE=Math.max,IE=Math.min,ai=function(e,t){var n=TE(e);return n<0?xE(n+t,0):IE(n,t)},wE=$n,EE=Math.min,vr=function(e){return e>0?EE(wE(e),9007199254740991):0},CE=vr,rn=function(e){return CE(e.length)},RE=Sn,AE=ai,PE=rn,Ig=function(e){return function(t,n,r){var i,o=RE(t),a=PE(o),s=AE(r,a);if(e&&n!=n){for(;a>s;)if((i=o[s++])!=i)return!0}else for(;a>s;s++)if((e||s in o)&&o[s]===n)return e||s||0;return!e&&-1}},gs={includes:Ig(!0),indexOf:Ig(!1)},Xd=xt,DE=Sn,LE=gs.indexOf,OE=Q,wg=pe([].push),Eg=function(e,t){var n,r=DE(e),i=0,o=[];for(n in r)!Xd(OE,n)&&Xd(r,n)&&wg(o,n);for(;t.length>i;)Xd(r,n=t[i++])&&(~LE(o,n)||wg(o,n));return o},Qd=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"],ME=Eg,NE=Qd.concat("length","prototype");ii.f=Object.getOwnPropertyNames||function(e){return ME(e,NE)};var Yd={};Yd.f=Object.getOwnPropertySymbols;var VE=Pn,UE=ii,BE=Yd,jE=It,FE=pe([].concat),GE=VE("Reflect","ownKeys")||function(e){var t=UE.f(jE(e)),n=BE.f;return n?FE(t,n(e)):t},Cg=xt,HE=GE,zE=Se,WE=At,JE=oe,KE=at,qE=/#|\.prototype\./,_s=function(e,t){var n=QE[XE(e)];return n==$E||n!=YE&&(KE(t)?JE(t):!!t)},XE=_s.normalize=function(e){return String(e).replace(qE,".").toLowerCase()},QE=_s.data={},YE=_s.NATIVE="N",$E=_s.POLYFILL="P",ys=_s,$d=te,ZE=Se.f,eC=Mn,tC=Qt,nC=Ta,rC=function(e,t,n){for(var r=HE(t),i=WE.f,o=zE.f,a=0;a<r.length;a++){var s=r[a];Cg(e,s)||n&&Cg(n,s)||i(e,s,o(t,s))}},iC=ys,Me=function(e,t){var n,r,i,o,a,s=e.target,c=e.global,u=e.stat;if(n=c?$d:u?$d[s]||nC(s,{}):($d[s]||{}).prototype)for(r in t){if(o=t[r],i=e.dontCallGetSet?(a=ZE(n,r))&&a.value:n[r],!iC(c?r:s+(u?".":"#")+r,e.forced)&&i!==void 0){if(typeof o==typeof i)continue;rC(o,i)}(e.sham||i&&i.sham)&&eC(o,"sham",!0),tC(n,r,o,e)}},aC=Me,oC=oe,sC=Sn,Rg=Se.f,Ag=_e,cC=oC(function(){Rg(1)});aC({target:"Object",stat:!0,forced:!Ag||cC,sham:!Ag},{getOwnPropertyDescriptor:function(e,t){return Rg(sC(e),t)}});let Pg=!0,Dg=!0;function Ss(e,t,n){let r=e.match(t);return r&&r.length>=n&&parseInt(r[n],10)}function Va(e,t,n){if(!e.RTCPeerConnection)return;let r=e.RTCPeerConnection.prototype,i=r.addEventListener;r.addEventListener=function(a,s){if(a!==t)return i.apply(this,arguments);let c=u=>{let d=n(u);d&&(s.handleEvent?s.handleEvent(d):s(d))};return this._eventMap=this._eventMap||{},this._eventMap[t]||(this._eventMap[t]=new Map),this._eventMap[t].set(s,c),i.apply(this,[a,c])};let o=r.removeEventListener;r.removeEventListener=function(a,s){if(a!==t||!this._eventMap||!this._eventMap[t])return o.apply(this,arguments);if(!this._eventMap[t].has(s))return o.apply(this,arguments);let c=this._eventMap[t].get(s);return this._eventMap[t].delete(s),this._eventMap[t].size===0&&delete this._eventMap[t],Object.keys(this._eventMap).length===0&&delete this._eventMap,o.apply(this,[a,c])},Object.defineProperty(r,"on"+t,{get(){return this["_on"+t]},set(a){this["_on"+t]&&(this.removeEventListener(t,this["_on"+t]),delete this["_on"+t]),a&&this.addEventListener(t,this["_on"+t]=a)},enumerable:!0,configurable:!0})}function uC(e){return typeof e!="boolean"?new Error("Argument type: "+typeof e+". Please use a boolean."):(Pg=e,e?"adapter.js logging disabled":"adapter.js logging enabled")}function lC(e){return typeof e!="boolean"?new Error("Argument type: "+typeof e+". Please use a boolean."):(Dg=!e,"adapter.js deprecation warnings "+(e?"disabled":"enabled"))}function Zd(){if(typeof window=="object"){if(Pg)return;typeof console!="undefined"&&typeof console.log=="function"&&console.log.apply(console,arguments)}}function cu(e,t){Dg&&console.warn(e+" is deprecated, please use "+t+" instead.")}function Lg(e){return Object.prototype.toString.call(e)==="[object Object]"}function Og(e){return Lg(e)?Object.keys(e).reduce(function(t,n){let r=Lg(e[n]),i=r?Og(e[n]):e[n],o=r&&!Object.keys(i).length;return i===void 0||o?t:Object.assign(t,{[n]:i})},{}):e}function eh(e,t,n){t&&!n.has(t.id)&&(n.set(t.id,t),Object.keys(t).forEach(r=>{r.endsWith("Id")?eh(e,e.get(t[r]),n):r.endsWith("Ids")&&t[r].forEach(i=>{eh(e,e.get(i),n)})}))}function Mg(e,t,n){let r=n?"outbound-rtp":"inbound-rtp",i=new Map;if(t===null)return i;let o=[];return e.forEach(a=>{a.type==="track"&&a.trackIdentifier===t.id&&o.push(a)}),o.forEach(a=>{e.forEach(s=>{s.type===r&&s.trackId===a.id&&eh(e,s,i)})}),i}let Ng=Zd;function Vg(e,t){let n=e&&e.navigator;if(!n.mediaDevices)return;let r=function(a){if(typeof a!="object"||a.mandatory||a.optional)return a;let s={};return Object.keys(a).forEach(c=>{if(c==="require"||c==="advanced"||c==="mediaSource")return;let u=typeof a[c]=="object"?a[c]:{ideal:a[c]};u.exact!==void 0&&typeof u.exact=="number"&&(u.min=u.max=u.exact);let d=function(h,_){return h?h+_.charAt(0).toUpperCase()+_.slice(1):_==="deviceId"?"sourceId":_};if(u.ideal!==void 0){s.optional=s.optional||[];let h={};typeof u.ideal=="number"?(h[d("min",c)]=u.ideal,s.optional.push(h),h={},h[d("max",c)]=u.ideal,s.optional.push(h)):(h[d("",c)]=u.ideal,s.optional.push(h))}u.exact!==void 0&&typeof u.exact!="number"?(s.mandatory=s.mandatory||{},s.mandatory[d("",c)]=u.exact):["min","max"].forEach(h=>{u[h]!==void 0&&(s.mandatory=s.mandatory||{},s.mandatory[d(h,c)]=u[h])})}),a.advanced&&(s.optional=(s.optional||[]).concat(a.advanced)),s},i=function(a,s){if(t.version>=61)return s(a);if((a=JSON.parse(JSON.stringify(a)))&&typeof a.audio=="object"){let c=function(u,d,h){d in u&&!(h in u)&&(u[h]=u[d],delete u[d])};c((a=JSON.parse(JSON.stringify(a))).audio,"autoGainControl","googAutoGainControl"),c(a.audio,"noiseSuppression","googNoiseSuppression"),a.audio=r(a.audio)}if(a&&typeof a.video=="object"){let c=a.video.facingMode;c=c&&(typeof c=="object"?c:{ideal:c});let u=t.version<66;if(c&&(c.exact==="user"||c.exact==="environment"||c.ideal==="user"||c.ideal==="environment")&&(!n.mediaDevices.getSupportedConstraints||!n.mediaDevices.getSupportedConstraints().facingMode||u)){let d;if(delete a.video.facingMode,c.exact==="environment"||c.ideal==="environment"?d=["back","rear"]:c.exact!=="user"&&c.ideal!=="user"||(d=["front"]),d)return n.mediaDevices.enumerateDevices().then(h=>{let _=(h=h.filter(y=>y.kind==="videoinput")).find(y=>d.some(b=>y.label.toLowerCase().includes(b)));return!_&&h.length&&d.includes("back")&&(_=h[h.length-1]),_&&(a.video.deviceId=c.exact?{exact:_.deviceId}:{ideal:_.deviceId}),a.video=r(a.video),Ng("chrome: "+JSON.stringify(a)),s(a)})}a.video=r(a.video)}return Ng("chrome: "+JSON.stringify(a)),s(a)},o=function(a){return t.version>=64?a:{name:{PermissionDeniedError:"NotAllowedError",PermissionDismissedError:"NotAllowedError",InvalidStateError:"NotAllowedError",DevicesNotFoundError:"NotFoundError",ConstraintNotSatisfiedError:"OverconstrainedError",TrackStartError:"NotReadableError",MediaDeviceFailedDueToShutdown:"NotAllowedError",MediaDeviceKillSwitchOn:"NotAllowedError",TabCaptureError:"AbortError",ScreenCaptureError:"AbortError",DeviceCaptureError:"AbortError"}[a.name]||a.name,message:a.message,constraint:a.constraint||a.constraintName,toString(){return this.name+(this.message&&": ")+this.message}}};if(n.getUserMedia=function(a,s,c){i(a,u=>{n.webkitGetUserMedia(u,s,d=>{c&&c(o(d))})})}.bind(n),n.mediaDevices.getUserMedia){let a=n.mediaDevices.getUserMedia.bind(n.mediaDevices);n.mediaDevices.getUserMedia=function(s){return i(s,c=>a(c).then(u=>{if(c.audio&&!u.getAudioTracks().length||c.video&&!u.getVideoTracks().length)throw u.getTracks().forEach(d=>{d.stop()}),new DOMException("","NotFoundError");return u},u=>Promise.reject(o(u))))}}}function Ug(e){e.MediaStream=e.MediaStream||e.webkitMediaStream}function Bg(e){if(typeof e=="object"&&e.RTCPeerConnection&&!("ontrack"in e.RTCPeerConnection.prototype)){Object.defineProperty(e.RTCPeerConnection.prototype,"ontrack",{get(){return this._ontrack},set(n){this._ontrack&&this.removeEventListener("track",this._ontrack),this.addEventListener("track",this._ontrack=n)},enumerable:!0,configurable:!0});let t=e.RTCPeerConnection.prototype.setRemoteDescription;e.RTCPeerConnection.prototype.setRemoteDescription=function(){return this._ontrackpoly||(this._ontrackpoly=n=>{n.stream.addEventListener("addtrack",r=>{let i;i=e.RTCPeerConnection.prototype.getReceivers?this.getReceivers().find(a=>a.track&&a.track.id===r.track.id):{track:r.track};let o=new Event("track");o.track=r.track,o.receiver=i,o.transceiver={receiver:i},o.streams=[n.stream],this.dispatchEvent(o)}),n.stream.getTracks().forEach(r=>{let i;i=e.RTCPeerConnection.prototype.getReceivers?this.getReceivers().find(a=>a.track&&a.track.id===r.id):{track:r};let o=new Event("track");o.track=r,o.receiver=i,o.transceiver={receiver:i},o.streams=[n.stream],this.dispatchEvent(o)})},this.addEventListener("addstream",this._ontrackpoly)),t.apply(this,arguments)}}else Va(e,"track",t=>(t.transceiver||Object.defineProperty(t,"transceiver",{value:{receiver:t.receiver}}),t))}function jg(e){if(typeof e=="object"&&e.RTCPeerConnection&&!("getSenders"in e.RTCPeerConnection.prototype)&&"createDTMFSender"in e.RTCPeerConnection.prototype){let t=function(i,o){return{track:o,get dtmf(){return this._dtmf===void 0&&(o.kind==="audio"?this._dtmf=i.createDTMFSender(o):this._dtmf=null),this._dtmf},_pc:i}};if(!e.RTCPeerConnection.prototype.getSenders){e.RTCPeerConnection.prototype.getSenders=function(){return this._senders=this._senders||[],this._senders.slice()};let i=e.RTCPeerConnection.prototype.addTrack;e.RTCPeerConnection.prototype.addTrack=function(a,s){let c=i.apply(this,arguments);return c||(c=t(this,a),this._senders.push(c)),c};let o=e.RTCPeerConnection.prototype.removeTrack;e.RTCPeerConnection.prototype.removeTrack=function(a){o.apply(this,arguments);let s=this._senders.indexOf(a);s!==-1&&this._senders.splice(s,1)}}let n=e.RTCPeerConnection.prototype.addStream;e.RTCPeerConnection.prototype.addStream=function(i){this._senders=this._senders||[],n.apply(this,[i]),i.getTracks().forEach(o=>{this._senders.push(t(this,o))})};let r=e.RTCPeerConnection.prototype.removeStream;e.RTCPeerConnection.prototype.removeStream=function(i){this._senders=this._senders||[],r.apply(this,[i]),i.getTracks().forEach(o=>{let a=this._senders.find(s=>s.track===o);a&&this._senders.splice(this._senders.indexOf(a),1)})}}else if(typeof e=="object"&&e.RTCPeerConnection&&"getSenders"in e.RTCPeerConnection.prototype&&"createDTMFSender"in e.RTCPeerConnection.prototype&&e.RTCRtpSender&&!("dtmf"in e.RTCRtpSender.prototype)){let t=e.RTCPeerConnection.prototype.getSenders;e.RTCPeerConnection.prototype.getSenders=function(){let n=t.apply(this,[]);return n.forEach(r=>r._pc=this),n},Object.defineProperty(e.RTCRtpSender.prototype,"dtmf",{get(){return this._dtmf===void 0&&(this.track.kind==="audio"?this._dtmf=this._pc.createDTMFSender(this.track):this._dtmf=null),this._dtmf}})}}function Fg(e){if(!e.RTCPeerConnection)return;let t=e.RTCPeerConnection.prototype.getStats;e.RTCPeerConnection.prototype.getStats=function(){let[n,r,i]=arguments;if(arguments.length>0&&typeof n=="function")return t.apply(this,arguments);if(t.length===0&&(arguments.length===0||typeof n!="function"))return t.apply(this,[]);let o=function(s){let c={};return s.result().forEach(u=>{let d={id:u.id,timestamp:u.timestamp,type:{localcandidate:"local-candidate",remotecandidate:"remote-candidate"}[u.type]||u.type};u.names().forEach(h=>{d[h]=u.stat(h)}),c[d.id]=d}),c},a=function(s){return new Map(Object.keys(s).map(c=>[c,s[c]]))};if(arguments.length>=2){let s=function(c){r(a(o(c)))};return t.apply(this,[s,n])}return new Promise((s,c)=>{t.apply(this,[function(u){s(a(o(u)))},c])}).then(r,i)}}function Gg(e){if(!(typeof e=="object"&&e.RTCPeerConnection&&e.RTCRtpSender&&e.RTCRtpReceiver))return;if(!("getStats"in e.RTCRtpSender.prototype)){let n=e.RTCPeerConnection.prototype.getSenders;n&&(e.RTCPeerConnection.prototype.getSenders=function(){let i=n.apply(this,[]);return i.forEach(o=>o._pc=this),i});let r=e.RTCPeerConnection.prototype.addTrack;r&&(e.RTCPeerConnection.prototype.addTrack=function(){let i=r.apply(this,arguments);return i._pc=this,i}),e.RTCRtpSender.prototype.getStats=function(){let i=this;return this._pc.getStats().then(o=>Mg(o,i.track,!0))}}if(!("getStats"in e.RTCRtpReceiver.prototype)){let n=e.RTCPeerConnection.prototype.getReceivers;n&&(e.RTCPeerConnection.prototype.getReceivers=function(){let r=n.apply(this,[]);return r.forEach(i=>i._pc=this),r}),Va(e,"track",r=>(r.receiver._pc=r.srcElement,r)),e.RTCRtpReceiver.prototype.getStats=function(){let r=this;return this._pc.getStats().then(i=>Mg(i,r.track,!1))}}if(!("getStats"in e.RTCRtpSender.prototype)||!("getStats"in e.RTCRtpReceiver.prototype))return;let t=e.RTCPeerConnection.prototype.getStats;e.RTCPeerConnection.prototype.getStats=function(){if(arguments.length>0&&arguments[0]instanceof e.MediaStreamTrack){let n=arguments[0],r,i,o;return this.getSenders().forEach(a=>{a.track===n&&(r?o=!0:r=a)}),this.getReceivers().forEach(a=>(a.track===n&&(i?o=!0:i=a),a.track===n)),o||r&&i?Promise.reject(new DOMException("There are more than one sender or receiver for the track.","InvalidAccessError")):r?r.getStats():i?i.getStats():Promise.reject(new DOMException("There is no sender or receiver for the track.","InvalidAccessError"))}return t.apply(this,arguments)}}function Hg(e){e.RTCPeerConnection.prototype.getLocalStreams=function(){return this._shimmedLocalStreams=this._shimmedLocalStreams||{},Object.keys(this._shimmedLocalStreams).map(o=>this._shimmedLocalStreams[o][0])};let t=e.RTCPeerConnection.prototype.addTrack;e.RTCPeerConnection.prototype.addTrack=function(o,a){if(!a)return t.apply(this,arguments);this._shimmedLocalStreams=this._shimmedLocalStreams||{};let s=t.apply(this,arguments);return this._shimmedLocalStreams[a.id]?this._shimmedLocalStreams[a.id].indexOf(s)===-1&&this._shimmedLocalStreams[a.id].push(s):this._shimmedLocalStreams[a.id]=[a,s],s};let n=e.RTCPeerConnection.prototype.addStream;e.RTCPeerConnection.prototype.addStream=function(o){this._shimmedLocalStreams=this._shimmedLocalStreams||{},o.getTracks().forEach(c=>{if(this.getSenders().find(u=>u.track===c))throw new DOMException("Track already exists.","InvalidAccessError")});let a=this.getSenders();n.apply(this,arguments);let s=this.getSenders().filter(c=>a.indexOf(c)===-1);this._shimmedLocalStreams[o.id]=[o].concat(s)};let r=e.RTCPeerConnection.prototype.removeStream;e.RTCPeerConnection.prototype.removeStream=function(o){return this._shimmedLocalStreams=this._shimmedLocalStreams||{},delete this._shimmedLocalStreams[o.id],r.apply(this,arguments)};let i=e.RTCPeerConnection.prototype.removeTrack;e.RTCPeerConnection.prototype.removeTrack=function(o){return this._shimmedLocalStreams=this._shimmedLocalStreams||{},o&&Object.keys(this._shimmedLocalStreams).forEach(a=>{let s=this._shimmedLocalStreams[a].indexOf(o);s!==-1&&this._shimmedLocalStreams[a].splice(s,1),this._shimmedLocalStreams[a].length===1&&delete this._shimmedLocalStreams[a]}),i.apply(this,arguments)}}function zg(e,t){if(!e.RTCPeerConnection)return;if(e.RTCPeerConnection.prototype.addTrack&&t.version>=65)return Hg(e);let n=e.RTCPeerConnection.prototype.getLocalStreams;e.RTCPeerConnection.prototype.getLocalStreams=function(){let u=n.apply(this);return this._reverseStreams=this._reverseStreams||{},u.map(d=>this._reverseStreams[d.id])};let r=e.RTCPeerConnection.prototype.addStream;e.RTCPeerConnection.prototype.addStream=function(u){if(this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{},u.getTracks().forEach(d=>{if(this.getSenders().find(h=>h.track===d))throw new DOMException("Track already exists.","InvalidAccessError")}),!this._reverseStreams[u.id]){let d=new e.MediaStream(u.getTracks());this._streams[u.id]=d,this._reverseStreams[d.id]=u,u=d}r.apply(this,[u])};let i=e.RTCPeerConnection.prototype.removeStream;function o(u,d){let h=d.sdp;return Object.keys(u._reverseStreams||[]).forEach(_=>{let y=u._reverseStreams[_],b=u._streams[y.id];h=h.replace(new RegExp(b.id,"g"),y.id)}),new RTCSessionDescription({type:d.type,sdp:h})}function a(u,d){let h=d.sdp;return Object.keys(u._reverseStreams||[]).forEach(_=>{let y=u._reverseStreams[_],b=u._streams[y.id];h=h.replace(new RegExp(y.id,"g"),b.id)}),new RTCSessionDescription({type:d.type,sdp:h})}e.RTCPeerConnection.prototype.removeStream=function(u){this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{},i.apply(this,[this._streams[u.id]||u]),delete this._reverseStreams[this._streams[u.id]?this._streams[u.id].id:u.id],delete this._streams[u.id]},e.RTCPeerConnection.prototype.addTrack=function(u,d){if(this.signalingState==="closed")throw new DOMException("The RTCPeerConnection's signalingState is 'closed'.","InvalidStateError");let h=[].slice.call(arguments,1);if(h.length!==1||!h[0].getTracks().find(b=>b===u))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(b=>b.track===u))throw new DOMException("Track already exists.","InvalidAccessError");this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{};let y=this._streams[d.id];if(y)y.addTrack(u),Promise.resolve().then(()=>{this.dispatchEvent(new Event("negotiationneeded"))});else{let b=new e.MediaStream([u]);this._streams[d.id]=b,this._reverseStreams[b.id]=d,this.addStream(b)}return this.getSenders().find(b=>b.track===u)},["createOffer","createAnswer"].forEach(function(u){let d=e.RTCPeerConnection.prototype[u],h={[u](){let _=arguments;return arguments.length&&typeof arguments[0]=="function"?d.apply(this,[y=>{let b=o(this,y);_[0].apply(null,[b])},y=>{_[1]&&_[1].apply(null,y)},arguments[2]]):d.apply(this,arguments).then(y=>o(this,y))}};e.RTCPeerConnection.prototype[u]=h[u]});let s=e.RTCPeerConnection.prototype.setLocalDescription;e.RTCPeerConnection.prototype.setLocalDescription=function(){return arguments.length&&arguments[0].type?(arguments[0]=a(this,arguments[0]),s.apply(this,arguments)):s.apply(this,arguments)};let c=Object.getOwnPropertyDescriptor(e.RTCPeerConnection.prototype,"localDescription");Object.defineProperty(e.RTCPeerConnection.prototype,"localDescription",{get(){let u=c.get.apply(this);return u.type===""?u:o(this,u)}}),e.RTCPeerConnection.prototype.removeTrack=function(u){if(this.signalingState==="closed")throw new DOMException("The RTCPeerConnection's signalingState is 'closed'.","InvalidStateError");if(!u._pc)throw new DOMException("Argument 1 of RTCPeerConnection.removeTrack does not implement interface RTCRtpSender.","TypeError");if(u._pc!==this)throw new DOMException("Sender was not created by this connection.","InvalidAccessError");let d;this._streams=this._streams||{},Object.keys(this._streams).forEach(h=>{this._streams[h].getTracks().find(_=>u.track===_)&&(d=this._streams[h])}),d&&(d.getTracks().length===1?this.removeStream(this._reverseStreams[d.id]):d.removeTrack(u.track),this.dispatchEvent(new Event("negotiationneeded")))}}function th(e,t){!e.RTCPeerConnection&&e.webkitRTCPeerConnection&&(e.RTCPeerConnection=e.webkitRTCPeerConnection),e.RTCPeerConnection&&t.version<53&&["setLocalDescription","setRemoteDescription","addIceCandidate"].forEach(function(n){let r=e.RTCPeerConnection.prototype[n],i={[n](){return arguments[0]=new(n==="addIceCandidate"?e.RTCIceCandidate:e.RTCSessionDescription)(arguments[0]),r.apply(this,arguments)}};e.RTCPeerConnection.prototype[n]=i[n]})}function Wg(e,t){Va(e,"negotiationneeded",n=>{let r=n.target;if(!(t.version<72||r.getConfiguration&&r.getConfiguration().sdpSemantics==="plan-b")||r.signalingState==="stable")return n})}var Jg=Object.freeze({__proto__:null,shimMediaStream:Ug,shimOnTrack:Bg,shimGetSendersWithDtmf:jg,shimGetStats:Fg,shimSenderReceiverGetStats:Gg,shimAddTrackRemoveTrackWithNative:Hg,shimAddTrackRemoveTrack:zg,shimPeerConnection:th,fixNegotiationNeeded:Wg,shimGetUserMedia:Vg,shimGetDisplayMedia:function(e,t){e.navigator.mediaDevices&&"getDisplayMedia"in e.navigator.mediaDevices||e.navigator.mediaDevices&&(typeof t=="function"?e.navigator.mediaDevices.getDisplayMedia=function(n){return t(n).then(r=>{let i=n.video&&n.video.width,o=n.video&&n.video.height,a=n.video&&n.video.frameRate;return n.video={mandatory:{chromeMediaSource:"desktop",chromeMediaSourceId:r,maxFrameRate:a||3}},i&&(n.video.mandatory.maxWidth=i),o&&(n.video.mandatory.maxHeight=o),e.navigator.mediaDevices.getUserMedia(n)})}:console.error("shimGetDisplayMedia: getSourceId argument is not a function"))}}),nh={exports:{}};(function(e){var t={generateIdentifier:function(){return Math.random().toString(36).substr(2,10)}};t.localCName=t.generateIdentifier(),t.splitLines=function(n){return n.trim().split(`
5
- `).map(function(r){return r.trim()})},t.splitSections=function(n){return n.split(`
6
- m=`).map(function(r,i){return(i>0?"m="+r:r).trim()+`\r
7
- `})},t.getDescription=function(n){var r=t.splitSections(n);return r&&r[0]},t.getMediaSections=function(n){var r=t.splitSections(n);return r.shift(),r},t.matchPrefix=function(n,r){return t.splitLines(n).filter(function(i){return i.indexOf(r)===0})},t.parseCandidate=function(n){for(var r,i={foundation:(r=n.indexOf("a=candidate:")===0?n.substring(12).split(" "):n.substring(10).split(" "))[0],component:parseInt(r[1],10),protocol:r[2].toLowerCase(),priority:parseInt(r[3],10),ip:r[4],address:r[4],port:parseInt(r[5],10),type:r[7]},o=8;o<r.length;o+=2)switch(r[o]){case"raddr":i.relatedAddress=r[o+1];break;case"rport":i.relatedPort=parseInt(r[o+1],10);break;case"tcptype":i.tcpType=r[o+1];break;case"ufrag":i.ufrag=r[o+1],i.usernameFragment=r[o+1];break;default:i[r[o]]=r[o+1]}return i},t.writeCandidate=function(n){var r=[];r.push(n.foundation),r.push(n.component),r.push(n.protocol.toUpperCase()),r.push(n.priority),r.push(n.address||n.ip),r.push(n.port);var i=n.type;return r.push("typ"),r.push(i),i!=="host"&&n.relatedAddress&&n.relatedPort&&(r.push("raddr"),r.push(n.relatedAddress),r.push("rport"),r.push(n.relatedPort)),n.tcpType&&n.protocol.toLowerCase()==="tcp"&&(r.push("tcptype"),r.push(n.tcpType)),(n.usernameFragment||n.ufrag)&&(r.push("ufrag"),r.push(n.usernameFragment||n.ufrag)),"candidate:"+r.join(" ")},t.parseIceOptions=function(n){return n.substr(14).split(" ")},t.parseRtpMap=function(n){var r=n.substr(9).split(" "),i={payloadType:parseInt(r.shift(),10)};return r=r[0].split("/"),i.name=r[0],i.clockRate=parseInt(r[1],10),i.channels=r.length===3?parseInt(r[2],10):1,i.numChannels=i.channels,i},t.writeRtpMap=function(n){var r=n.payloadType;n.preferredPayloadType!==void 0&&(r=n.preferredPayloadType);var i=n.channels||n.numChannels||1;return"a=rtpmap:"+r+" "+n.name+"/"+n.clockRate+(i!==1?"/"+i:"")+`\r
8
- `},t.parseExtmap=function(n){var r=n.substr(9).split(" ");return{id:parseInt(r[0],10),direction:r[0].indexOf("/")>0?r[0].split("/")[1]:"sendrecv",uri:r[1]}},t.writeExtmap=function(n){return"a=extmap:"+(n.id||n.preferredId)+(n.direction&&n.direction!=="sendrecv"?"/"+n.direction:"")+" "+n.uri+`\r
9
- `},t.parseFmtp=function(n){for(var r,i={},o=n.substr(n.indexOf(" ")+1).split(";"),a=0;a<o.length;a++)i[(r=o[a].trim().split("="))[0].trim()]=r[1];return i},t.writeFmtp=function(n){var r="",i=n.payloadType;if(n.preferredPayloadType!==void 0&&(i=n.preferredPayloadType),n.parameters&&Object.keys(n.parameters).length){var o=[];Object.keys(n.parameters).forEach(function(a){n.parameters[a]?o.push(a+"="+n.parameters[a]):o.push(a)}),r+="a=fmtp:"+i+" "+o.join(";")+`\r
10
- `}return r},t.parseRtcpFb=function(n){var r=n.substr(n.indexOf(" ")+1).split(" ");return{type:r.shift(),parameter:r.join(" ")}},t.writeRtcpFb=function(n){var r="",i=n.payloadType;return n.preferredPayloadType!==void 0&&(i=n.preferredPayloadType),n.rtcpFeedback&&n.rtcpFeedback.length&&n.rtcpFeedback.forEach(function(o){r+="a=rtcp-fb:"+i+" "+o.type+(o.parameter&&o.parameter.length?" "+o.parameter:"")+`\r
11
- `}),r},t.parseSsrcMedia=function(n){var r=n.indexOf(" "),i={ssrc:parseInt(n.substr(7,r-7),10)},o=n.indexOf(":",r);return o>-1?(i.attribute=n.substr(r+1,o-r-1),i.value=n.substr(o+1)):i.attribute=n.substr(r+1),i},t.parseSsrcGroup=function(n){var r=n.substr(13).split(" ");return{semantics:r.shift(),ssrcs:r.map(function(i){return parseInt(i,10)})}},t.getMid=function(n){var r=t.matchPrefix(n,"a=mid:")[0];if(r)return r.substr(6)},t.parseFingerprint=function(n){var r=n.substr(14).split(" ");return{algorithm:r[0].toLowerCase(),value:r[1]}},t.getDtlsParameters=function(n,r){return{role:"auto",fingerprints:t.matchPrefix(n+r,"a=fingerprint:").map(t.parseFingerprint)}},t.writeDtlsParameters=function(n,r){var i="a=setup:"+r+`\r
12
- `;return n.fingerprints.forEach(function(o){i+="a=fingerprint:"+o.algorithm+" "+o.value+`\r
13
- `}),i},t.parseCryptoLine=function(n){var r=n.substr(9).split(" ");return{tag:parseInt(r[0],10),cryptoSuite:r[1],keyParams:r[2],sessionParams:r.slice(3)}},t.writeCryptoLine=function(n){return"a=crypto:"+n.tag+" "+n.cryptoSuite+" "+(typeof n.keyParams=="object"?t.writeCryptoKeyParams(n.keyParams):n.keyParams)+(n.sessionParams?" "+n.sessionParams.join(" "):"")+`\r
14
- `},t.parseCryptoKeyParams=function(n){if(n.indexOf("inline:")!==0)return null;var r=n.substr(7).split("|");return{keyMethod:"inline",keySalt:r[0],lifeTime:r[1],mkiValue:r[2]?r[2].split(":")[0]:void 0,mkiLength:r[2]?r[2].split(":")[1]:void 0}},t.writeCryptoKeyParams=function(n){return n.keyMethod+":"+n.keySalt+(n.lifeTime?"|"+n.lifeTime:"")+(n.mkiValue&&n.mkiLength?"|"+n.mkiValue+":"+n.mkiLength:"")},t.getCryptoParameters=function(n,r){return t.matchPrefix(n+r,"a=crypto:").map(t.parseCryptoLine)},t.getIceParameters=function(n,r){var i=t.matchPrefix(n+r,"a=ice-ufrag:")[0],o=t.matchPrefix(n+r,"a=ice-pwd:")[0];return i&&o?{usernameFragment:i.substr(12),password:o.substr(10)}:null},t.writeIceParameters=function(n){return"a=ice-ufrag:"+n.usernameFragment+`\r
15
- a=ice-pwd:`+n.password+`\r
16
- `},t.parseRtpParameters=function(n){for(var r={codecs:[],headerExtensions:[],fecMechanisms:[],rtcp:[]},i=t.splitLines(n)[0].split(" "),o=3;o<i.length;o++){var a=i[o],s=t.matchPrefix(n,"a=rtpmap:"+a+" ")[0];if(s){var c=t.parseRtpMap(s),u=t.matchPrefix(n,"a=fmtp:"+a+" ");switch(c.parameters=u.length?t.parseFmtp(u[0]):{},c.rtcpFeedback=t.matchPrefix(n,"a=rtcp-fb:"+a+" ").map(t.parseRtcpFb),r.codecs.push(c),c.name.toUpperCase()){case"RED":case"ULPFEC":r.fecMechanisms.push(c.name.toUpperCase())}}}return t.matchPrefix(n,"a=extmap:").forEach(function(d){r.headerExtensions.push(t.parseExtmap(d))}),r},t.writeRtpDescription=function(n,r){var i="";i+="m="+n+" ",i+=r.codecs.length>0?"9":"0",i+=" UDP/TLS/RTP/SAVPF ",i+=r.codecs.map(function(a){return a.preferredPayloadType!==void 0?a.preferredPayloadType:a.payloadType}).join(" ")+`\r
17
- `,i+=`c=IN IP4 0.0.0.0\r
18
- `,i+=`a=rtcp:9 IN IP4 0.0.0.0\r
19
- `,r.codecs.forEach(function(a){i+=t.writeRtpMap(a),i+=t.writeFmtp(a),i+=t.writeRtcpFb(a)});var o=0;return r.codecs.forEach(function(a){a.maxptime>o&&(o=a.maxptime)}),o>0&&(i+="a=maxptime:"+o+`\r
20
- `),i+=`a=rtcp-mux\r
21
- `,r.headerExtensions&&r.headerExtensions.forEach(function(a){i+=t.writeExtmap(a)}),i},t.parseRtpEncodingParameters=function(n){var r,i=[],o=t.parseRtpParameters(n),a=o.fecMechanisms.indexOf("RED")!==-1,s=o.fecMechanisms.indexOf("ULPFEC")!==-1,c=t.matchPrefix(n,"a=ssrc:").map(function(_){return t.parseSsrcMedia(_)}).filter(function(_){return _.attribute==="cname"}),u=c.length>0&&c[0].ssrc,d=t.matchPrefix(n,"a=ssrc-group:FID").map(function(_){return _.substr(17).split(" ").map(function(y){return parseInt(y,10)})});d.length>0&&d[0].length>1&&d[0][0]===u&&(r=d[0][1]),o.codecs.forEach(function(_){if(_.name.toUpperCase()==="RTX"&&_.parameters.apt){var y={ssrc:u,codecPayloadType:parseInt(_.parameters.apt,10)};u&&r&&(y.rtx={ssrc:r}),i.push(y),a&&((y=JSON.parse(JSON.stringify(y))).fec={ssrc:u,mechanism:s?"red+ulpfec":"red"},i.push(y))}}),i.length===0&&u&&i.push({ssrc:u});var h=t.matchPrefix(n,"b=");return h.length&&(h=h[0].indexOf("b=TIAS:")===0?parseInt(h[0].substr(7),10):h[0].indexOf("b=AS:")===0?1e3*parseInt(h[0].substr(5),10)*.95-16e3:void 0,i.forEach(function(_){_.maxBitrate=h})),i},t.parseRtcpParameters=function(n){var r={},i=t.matchPrefix(n,"a=ssrc:").map(function(s){return t.parseSsrcMedia(s)}).filter(function(s){return s.attribute==="cname"})[0];i&&(r.cname=i.value,r.ssrc=i.ssrc);var o=t.matchPrefix(n,"a=rtcp-rsize");r.reducedSize=o.length>0,r.compound=o.length===0;var a=t.matchPrefix(n,"a=rtcp-mux");return r.mux=a.length>0,r},t.parseMsid=function(n){var r,i=t.matchPrefix(n,"a=msid:");if(i.length===1)return{stream:(r=i[0].substr(7).split(" "))[0],track:r[1]};var o=t.matchPrefix(n,"a=ssrc:").map(function(a){return t.parseSsrcMedia(a)}).filter(function(a){return a.attribute==="msid"});return o.length>0?{stream:(r=o[0].value.split(" "))[0],track:r[1]}:void 0},t.parseSctpDescription=function(n){var r,i=t.parseMLine(n),o=t.matchPrefix(n,"a=max-message-size:");o.length>0&&(r=parseInt(o[0].substr(19),10)),isNaN(r)&&(r=65536);var a=t.matchPrefix(n,"a=sctp-port:");if(a.length>0)return{port:parseInt(a[0].substr(12),10),protocol:i.fmt,maxMessageSize:r};if(t.matchPrefix(n,"a=sctpmap:").length>0){var s=t.matchPrefix(n,"a=sctpmap:")[0].substr(10).split(" ");return{port:parseInt(s[0],10),protocol:s[1],maxMessageSize:r}}},t.writeSctpDescription=function(n,r){var i=[];return i=n.protocol!=="DTLS/SCTP"?["m="+n.kind+" 9 "+n.protocol+" "+r.protocol+`\r
1
+ var n7=Object.create;var ld=Object.defineProperty,r7=Object.defineProperties,qI=Object.getOwnPropertyDescriptor,i7=Object.getOwnPropertyDescriptors,a7=Object.getOwnPropertyNames,WI=Object.getOwnPropertySymbols,o7=Object.getPrototypeOf,JI=Object.prototype.hasOwnProperty,s7=Object.prototype.propertyIsEnumerable;var Yv=(te,q,f)=>q in te?ld(te,q,{enumerable:!0,configurable:!0,writable:!0,value:f}):te[q]=f,Jr=(te,q)=>{for(var f in q||(q={}))JI.call(q,f)&&Yv(te,f,q[f]);if(WI)for(var f of WI(q))s7.call(q,f)&&Yv(te,f,q[f]);return te},dd=(te,q)=>r7(te,i7(q));var $v=(te,q)=>()=>(q||te((q={exports:{}}).exports,q),q.exports);var c7=(te,q,f,G)=>{if(q&&typeof q=="object"||typeof q=="function")for(let $ of a7(q))!JI.call(te,$)&&$!==f&&ld(te,$,{get:()=>q[$],enumerable:!(G=qI(q,$))||G.enumerable});return te};var sr=(te,q,f)=>(f=te!=null?n7(o7(te)):{},c7(q||!te||!te.__esModule?ld(f,"default",{value:te,enumerable:!0}):f,te));var In=(te,q,f,G)=>{for(var $=G>1?void 0:G?qI(q,f):q,H=te.length-1,Q;H>=0;H--)(Q=te[H])&&($=(G?Q(q,f,$):Q($))||$);return G&&$&&ld(q,f,$),$};var Ve=(te,q,f)=>(Yv(te,typeof q!="symbol"?q+"":q,f),f);var Cr=$v((Zv,eg)=>{(function(te,q){typeof Zv=="object"&&typeof eg!="undefined"?eg.exports=q():typeof define=="function"&&define.amd?define(q):(te=typeof globalThis!="undefined"?globalThis:te||self).TRTC=q()})(Zv,function(){function te(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 q(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?te(Object(n),!0).forEach(function(i){$e(e,i,n[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):te(Object(n)).forEach(function(i){Object.defineProperty(e,i,Object.getOwnPropertyDescriptor(n,i))})}return e}function f(){f=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(P,V,S){return Object.defineProperty(P,V,{value:S,enumerable:!0,configurable:!0,writable:!0}),P[V]}try{a({},"")}catch(P){a=function(V,S,h){return V[S]=h}}function s(P,V,S,h){var y=V&&V.prototype instanceof p?V:p,A=Object.create(y.prototype),D=new _(h||[]);return A._invoke=function(U,K,J){var ce="suspendedStart";return function(ae,qe){if(ce==="executing")throw new Error("Generator is already running");if(ce==="completed"){if(ae==="throw")throw qe;return R()}for(J.method=ae,J.arg=qe;;){var Ue=J.delegate;if(Ue){var Fe=O(Ue,J);if(Fe){if(Fe===u)continue;return Fe}}if(J.method==="next")J.sent=J._sent=J.arg;else if(J.method==="throw"){if(ce==="suspendedStart")throw ce="completed",J.arg;J.dispatchException(J.arg)}else J.method==="return"&&J.abrupt("return",J.arg);ce="executing";var lt=l(U,K,J);if(lt.type==="normal"){if(ce=J.done?"completed":"suspendedYield",lt.arg===u)continue;return{value:lt.arg,done:J.done}}lt.type==="throw"&&(ce="completed",J.method="throw",J.arg=lt.arg)}}}(P,S,D),A}function l(P,V,S){try{return{type:"normal",arg:P.call(V,S)}}catch(h){return{type:"throw",arg:h}}}e.wrap=s;var u={};function p(){}function k(){}function x(){}var E={};a(E,r,function(){return this});var I=Object.getPrototypeOf,m=I&&I(I(b([])));m&&m!==t&&n.call(m,r)&&(E=m);var T=x.prototype=p.prototype=Object.create(E);function v(P){["next","throw","return"].forEach(function(V){a(P,V,function(S){return this._invoke(V,S)})})}function C(P,V){function S(y,A,D,U){var K=l(P[y],P,A);if(K.type!=="throw"){var J=K.arg,ce=J.value;return ce&&typeof ce=="object"&&n.call(ce,"__await")?V.resolve(ce.__await).then(function(ae){S("next",ae,D,U)},function(ae){S("throw",ae,D,U)}):V.resolve(ce).then(function(ae){J.value=ae,D(J)},function(ae){return S("throw",ae,D,U)})}U(K.arg)}var h;this._invoke=function(y,A){function D(){return new V(function(U,K){S(y,A,U,K)})}return h=h?h.then(D,D):D()}}function O(P,V){var S=P.iterator[V.method];if(S===void 0){if(V.delegate=null,V.method==="throw"){if(P.iterator.return&&(V.method="return",V.arg=void 0,O(P,V),V.method==="throw"))return u;V.method="throw",V.arg=new TypeError("The iterator does not provide a 'throw' method")}return u}var h=l(S,P.iterator,V.arg);if(h.type==="throw")return V.method="throw",V.arg=h.arg,V.delegate=null,u;var y=h.arg;return y?y.done?(V[P.resultName]=y.value,V.next=P.nextLoc,V.method!=="return"&&(V.method="next",V.arg=void 0),V.delegate=null,u):y:(V.method="throw",V.arg=new TypeError("iterator result is not an object"),V.delegate=null,u)}function N(P){var V={tryLoc:P[0]};1 in P&&(V.catchLoc=P[1]),2 in P&&(V.finallyLoc=P[2],V.afterLoc=P[3]),this.tryEntries.push(V)}function j(P){var V=P.completion||{};V.type="normal",delete V.arg,P.completion=V}function _(P){this.tryEntries=[{tryLoc:"root"}],P.forEach(N,this),this.reset(!0)}function b(P){if(P){var V=P[r];if(V)return V.call(P);if(typeof P.next=="function")return P;if(!isNaN(P.length)){var S=-1,h=function y(){for(;++S<P.length;)if(n.call(P,S))return y.value=P[S],y.done=!1,y;return y.value=void 0,y.done=!0,y};return h.next=h}}return{next:R}}function R(){return{value:void 0,done:!0}}return k.prototype=x,a(T,"constructor",x),a(x,"constructor",k),k.displayName=a(x,c,"GeneratorFunction"),e.isGeneratorFunction=function(P){var V=typeof P=="function"&&P.constructor;return!!V&&(V===k||(V.displayName||V.name)==="GeneratorFunction")},e.mark=function(P){return Object.setPrototypeOf?Object.setPrototypeOf(P,x):(P.__proto__=x,a(P,c,"GeneratorFunction")),P.prototype=Object.create(T),P},e.awrap=function(P){return{__await:P}},v(C.prototype),a(C.prototype,o,function(){return this}),e.AsyncIterator=C,e.async=function(P,V,S,h,y){y===void 0&&(y=Promise);var A=new C(s(P,V,S,h),y);return e.isGeneratorFunction(V)?A:A.next().then(function(D){return D.done?D.value:A.next()})},v(T),a(T,c,"Generator"),a(T,r,function(){return this}),a(T,"toString",function(){return"[object Generator]"}),e.keys=function(P){var V=[];for(var S in P)V.push(S);return V.reverse(),function h(){for(;V.length;){var y=V.pop();if(y in P)return h.value=y,h.done=!1,h}return h.done=!0,h}},e.values=b,_.prototype={constructor:_,reset:function(P){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(j),!P)for(var V in this)V.charAt(0)==="t"&&n.call(this,V)&&!isNaN(+V.slice(1))&&(this[V]=void 0)},stop:function(){this.done=!0;var P=this.tryEntries[0].completion;if(P.type==="throw")throw P.arg;return this.rval},dispatchException:function(P){if(this.done)throw P;var V=this;function S(K,J){return A.type="throw",A.arg=P,V.next=K,J&&(V.method="next",V.arg=void 0),!!J}for(var h=this.tryEntries.length-1;h>=0;--h){var y=this.tryEntries[h],A=y.completion;if(y.tryLoc==="root")return S("end");if(y.tryLoc<=this.prev){var D=n.call(y,"catchLoc"),U=n.call(y,"finallyLoc");if(D&&U){if(this.prev<y.catchLoc)return S(y.catchLoc,!0);if(this.prev<y.finallyLoc)return S(y.finallyLoc)}else if(D){if(this.prev<y.catchLoc)return S(y.catchLoc,!0)}else{if(!U)throw new Error("try statement without catch or finally");if(this.prev<y.finallyLoc)return S(y.finallyLoc)}}}},abrupt:function(P,V){for(var S=this.tryEntries.length-1;S>=0;--S){var h=this.tryEntries[S];if(h.tryLoc<=this.prev&&n.call(h,"finallyLoc")&&this.prev<h.finallyLoc){var y=h;break}}y&&(P==="break"||P==="continue")&&y.tryLoc<=V&&V<=y.finallyLoc&&(y=null);var A=y?y.completion:{};return A.type=P,A.arg=V,y?(this.method="next",this.next=y.finallyLoc,u):this.complete(A)},complete:function(P,V){if(P.type==="throw")throw P.arg;return P.type==="break"||P.type==="continue"?this.next=P.arg:P.type==="return"?(this.rval=this.arg=P.arg,this.method="return",this.next="end"):P.type==="normal"&&V&&(this.next=V),u},finish:function(P){for(var V=this.tryEntries.length-1;V>=0;--V){var S=this.tryEntries[V];if(S.finallyLoc===P)return this.complete(S.completion,S.afterLoc),j(S),u}},catch:function(P){for(var V=this.tryEntries.length-1;V>=0;--V){var S=this.tryEntries[V];if(S.tryLoc===P){var h=S.completion;if(h.type==="throw"){var y=h.arg;j(S)}return y}}throw new Error("illegal catch attempt")},delegateYield:function(P,V,S){return this.delegate={iterator:b(P),resultName:V,nextLoc:S},this.method==="next"&&(this.arg=void 0),u}},e}function G(e){return G=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},G(e)}function $(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 H(e){return function(){var t=this,n=arguments;return new Promise(function(i,r){var o=e.apply(t,n);function c(s){$(o,i,r,c,a,"next",s)}function a(s){$(o,i,r,c,a,"throw",s)}c(void 0)})}}function Q(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function Re(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 Ie(e,t,n){return t&&Re(e.prototype,t),n&&Re(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}function $e(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Ct(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&&cr(e,t)}function Qe(e){return Qe=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},Qe(e)}function cr(e,t){return cr=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(n,i){return n.__proto__=i,n},cr(e,t)}function Rc(){if(typeof Reflect=="undefined"||!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(e){return!1}}function Go(e,t,n){return Go=Rc()?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&&cr(a,o.prototype),a},Go.apply(null,arguments)}function zo(e){var t=typeof Map=="function"?new Map:void 0;return zo=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 Go(n,arguments,Qe(this).constructor)}return r.prototype=Object.create(n.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),cr(r,n)},zo(e)}function Wo(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 Er(e){var t=Rc();return function(){var n,i=Qe(e);if(t){var r=Qe(this).constructor;n=Reflect.construct(i,arguments,r)}else n=i.apply(this,arguments);return Wo(this,n)}}function Ac(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&(e=Qe(e))!==null;);return e}function le(){return le=typeof Reflect!="undefined"&&Reflect.get?Reflect.get.bind():function(e,t,n){var i=Ac(e,t);if(i){var r=Object.getOwnPropertyDescriptor(i,t);return r.get?r.get.call(arguments.length<3?e:n):r.value}},le.apply(this,arguments)}function ke(e,t){return function(n){if(Array.isArray(n))return n}(e)||function(n,i){var r=n==null?null:typeof Symbol!="undefined"&&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)||je(e,t)||function(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
2
+ 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 He(t)}(e)||function(t){if(typeof Symbol!="undefined"&&t[Symbol.iterator]!=null||t["@@iterator"]!=null)return Array.from(t)}(e)||je(e)||function(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
3
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}()}function je(e,t){if(e){if(typeof e=="string")return He(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)?He(e,t):void 0}}function He(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 oe(e,t){var n=typeof Symbol!="undefined"&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=je(e))||t&&e&&typeof e.length=="number"){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.
4
+ 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 X(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 se=typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:typeof global!="undefined"?global:typeof self!="undefined"?self:{},z=function(e){return e&&e.Math==Math&&e},re=z(typeof globalThis=="object"&&globalThis)||z(typeof window=="object"&&window)||z(typeof self=="object"&&self)||z(typeof se=="object"&&se)||function(){return this}()||Function("return this")(),be={},ue=function(e){try{return!!e()}catch(t){return!0}},_e=!ue(function(){return Object.defineProperty({},1,{get:function(){return 7}})[1]!=7}),Oe=!ue(function(){var e=function(){}.bind();return typeof e!="function"||e.hasOwnProperty("prototype")}),Wt=Oe,$t=Function.prototype.call,Xe=Wt?$t.bind($t):function(){return $t.apply($t,arguments)},qt={},dt={}.propertyIsEnumerable,zn=Object.getOwnPropertyDescriptor,ur=zn&&!dt.call({1:2},1);qt.f=ur?function(e){var t=zn(this,e);return!!t&&t.enumerable}:dt;var Ht,En,Ze=function(e,t){return{enumerable:!(1&e),configurable:!(2&e),writable:!(4&e),value:t}},Gt=Oe,Wn=Function.prototype,he=Wn.call,de=Gt&&Wn.bind.bind(he,he),Ne=function(e){return Gt?de(e):function(){return he.apply(e,arguments)}},We=Ne,De=We({}.toString),ct=We("".slice),rt=function(e){return ct(De(e),8,-1)},Nt=rt,Zt=Ne,pe=function(e){if(Nt(e)==="Function")return Zt(e)},Lt=ue,Jt=rt,lr=Object,Ri=pe("".split),_n=Lt(function(){return!lr("z").propertyIsEnumerable(0)})?function(e){return Jt(e)=="String"?Ri(e,""):lr(e)}:lr,Et=function(e){return e==null},xd=Et,Ot=TypeError,ht=function(e){if(xd(e))throw Ot("Can't call method on "+e);return e},Pc=_n,Dc=ht,yn=function(e){return Pc(Dc(e))},ga=typeof document=="object"&&document.all,Ai={all:ga,IS_HTMLDDA:ga===void 0&&ga!==void 0},Lc=Ai.all,it=Ai.IS_HTMLDDA?function(e){return typeof e=="function"||e===Lc}:function(e){return typeof e=="function"},_a=it,Oc=Ai.all,at=Ai.IS_HTMLDDA?function(e){return typeof e=="object"?e!==null:_a(e)||e===Oc}:function(e){return typeof e=="object"?e!==null:_a(e)},ya=re,qo=it,Mc=function(e){return qo(e)?e:void 0},Rn=function(e,t){return arguments.length<2?Mc(ya[e]):ya[e]&&ya[e][t]},bn=pe({}.isPrototypeOf),qn=Rn("navigator","userAgent")||"",Nc=re,ba=qn,Kr=Nc.process,Sa=Nc.Deno,Jo=Kr&&Kr.versions||Sa&&Sa.version,Ko=Jo&&Jo.v8;Ko&&(En=(Ht=Ko.split("."))[0]>0&&Ht[0]<4?1:+(Ht[0]+Ht[1])),!En&&ba&&(!(Ht=ba.match(/Edge\/(\d+)/))||Ht[1]>=74)&&(Ht=ba.match(/Chrome\/(\d+)/))&&(En=+Ht[1]);var dr=En,hr=dr,Pi=ue,Xo=!!Object.getOwnPropertySymbols&&!Pi(function(){var e=Symbol();return!String(e)||!(Object(e)instanceof Symbol)||!Symbol.sham&&hr&&hr<41}),Qo=Xo&&!Symbol.sham&&typeof Symbol.iterator=="symbol",Yo=Rn,Uc=it,Rr=bn,$o=Object,Di=Qo?function(e){return typeof e=="symbol"}:function(e){var t=Yo("Symbol");return Uc(t)&&Rr(t.prototype,$o(e))},ka=String,Jn=function(e){try{return ka(e)}catch(t){return"Object"}},Id=it,Xr=Jn,Kn=TypeError,Ut=function(e){if(Id(e))return e;throw Kn(Xr(e)+" is not a function")},Vc=Ut,It=Et,Kt=function(e,t){var n=e[t];return It(n)?void 0:Vc(n)},Li=Xe,Zo=it,Qr=at,es=TypeError,Ar={exports:{}},Yr=re,Ta=Object.defineProperty,xa=function(e,t){try{Ta(Yr,e,{value:t,configurable:!0,writable:!0})}catch(n){Yr[e]=t}return t},ts=xa,Ia="__core-js_shared__",wa=re[Ia]||ts(Ia,{}),dn=wa;(Ar.exports=function(e,t){return dn[e]||(dn[e]=t!==void 0?t:{})})("versions",[]).push({version:"3.25.5",mode:"global",copyright:"\xA9 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 An=ht,Oi=Object,Vt=function(e){return Oi(An(e))},ns=Vt,jc=pe({}.hasOwnProperty),kt=Object.hasOwn||function(e,t){return jc(ns(e),t)},Pn=pe,Bc=0,Ca=Math.random(),Dn=Pn(1 .toString),Mi=function(e){return"Symbol("+(e===void 0?"":e)+")_"+Dn(++Bc+Ca,36)},rs=re,wd=Ar.exports,Fc=kt,Hc=Mi,is=Xo,as=Qo,$r=wd("wks"),Rt=rs.Symbol,os=Rt&&Rt.for,Gc=as?Rt:Rt&&Rt.withoutSetter||Hc,tt=function(e){if(!Fc($r,e)||!is&&typeof $r[e]!="string"){var t="Symbol."+e;is&&Fc(Rt,e)?$r[e]=Rt[e]:$r[e]=as&&os?os(t):Gc(t)}return $r[e]},zc=Xe,ss=at,Wc=Di,qc=Kt,Jc=function(e,t){var n,i;if(t==="string"&&Zo(n=e.toString)&&!Qr(i=Li(n,e))||Zo(n=e.valueOf)&&!Qr(i=Li(n,e))||t!=="string"&&Zo(n=e.toString)&&!Qr(i=Li(n,e)))return i;throw es("Can't convert object to primitive value")},Ea=TypeError,Kc=tt("toPrimitive"),Ra=function(e,t){if(!ss(e)||Wc(e))return e;var n,i=qc(e,Kc);if(i){if(t===void 0&&(t="default"),n=zc(i,e,t),!ss(n)||Wc(n))return n;throw Ea("Can't convert object to primitive value")}return t===void 0&&(t="number"),Jc(e,t)},Ni=Ra,Cd=Di,Aa=function(e){var t=Ni(e,"string");return Cd(t)?t:t+""},Xc=at,cs=re.document,us=Xc(cs)&&Xc(cs.createElement),fr=function(e){return us?cs.createElement(e):{}},Ed=fr,Qc=!_e&&!ue(function(){return Object.defineProperty(Ed("div"),"a",{get:function(){return 7}}).a!=7}),Rd=_e,Ad=Xe,ls=qt,Yc=Ze,$c=yn,Ui=Aa,Sn=kt,Pd=Qc,Zc=Object.getOwnPropertyDescriptor;be.f=Rd?Zc:function(e,t){if(e=$c(e),t=Ui(t),Pd)try{return Zc(e,t)}catch(n){}if(Sn(e,t))return Yc(!Ad(ls.f,e,t),e[t])};var At={},ds=_e&&ue(function(){return Object.defineProperty(function(){},"prototype",{value:42,writable:!1}).prototype!=42}),hs=at,fs=String,Zr=TypeError,Tt=function(e){if(hs(e))return e;throw Zr(fs(e)+" is not an object")},ps=_e,Dd=Qc,Ld=ds,pr=Tt,ms=Aa,eu=TypeError,vs=Object.defineProperty,Od=Object.getOwnPropertyDescriptor,Pa="enumerable",tu="configurable",Md="writable";At.f=ps?Ld?function(e,t,n){if(pr(e),t=ms(t),pr(n),typeof e=="function"&&t==="prototype"&&"value"in n&&Md in n&&!n.writable){var i=Od(e,t);i&&i.writable&&(e[t]=n.value,n={configurable:tu in n?n.configurable:i.configurable,enumerable:Pa in n?n.enumerable:i.enumerable,writable:!1})}return vs(e,t,n)}:vs:function(e,t,n){if(pr(e),t=ms(t),pr(n),Dd)try{return vs(e,t,n)}catch(i){}if("get"in n||"set"in n)throw eu("Accessors not supported");return"value"in n&&(e[t]=n.value),e};var nu=At,Nd=Ze,Ln=_e?function(e,t,n){return nu.f(e,t,Nd(1,n))}:function(e,t,n){return e[t]=n,e},Vi={exports:{}},Da=_e,Ud=kt,ru=Function.prototype,Vd=Da&&Object.getOwnPropertyDescriptor,La=Ud(ru,"name"),Xn={EXISTS:La,PROPER:La&&function(){}.name==="something",CONFIGURABLE:La&&(!Da||Da&&Vd(ru,"name").configurable)},jd=it,ei=wa,Bd=pe(Function.toString);jd(ei.inspectSource)||(ei.inspectSource=function(e){return Bd(e)});var Oa,ti,ji,d=ei.inspectSource,g=it,w=re.WeakMap,L=g(w)&&/native code/.test(String(w)),B=Ar.exports,M=Mi,F=B("keys"),W=function(e){return F[e]||(F[e]=M(e))},Z={},fe=L,me=re,we=at,Ae=Ln,ve=kt,Le=wa,Be=W,ot=Z,ut="Object already initialized",jt=me.TypeError,hn=me.WeakMap;if(fe||Le.state){var yt=Le.state||(Le.state=new hn);yt.get=yt.get,yt.has=yt.has,yt.set=yt.set,Oa=function(e,t){if(yt.has(e))throw jt(ut);return t.facade=e,yt.set(e,t),t},ti=function(e){return yt.get(e)||{}},ji=function(e){return yt.has(e)}}else{var Je=Be("state");ot[Je]=!0,Oa=function(e,t){if(ve(e,Je))throw jt(ut);return t.facade=e,Ae(e,Je,t),t},ti=function(e){return ve(e,Je)?e[Je]:{}},ji=function(e){return ve(e,Je)}}var Ke={set:Oa,get:ti,has:ji,enforce:function(e){return ji(e)?ti(e):Oa(e,{})},getterFor:function(e){return function(t){var n;if(!we(t)||(n=ti(t)).type!==e)throw jt("Incompatible receiver, "+e+" required");return n}}},mr=ue,Ma=it,On=kt,Na=_e,ni=Xn.CONFIGURABLE,Ua=d,gs=Ke.enforce,fw=Ke.get,iu=Object.defineProperty,pw=Na&&!mr(function(){return iu(function(){},"length",{value:8}).length!==8}),mw=String(String).split("String"),vw=Vi.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),(!On(e,"name")||ni&&e.name!==t)&&(Na?iu(e,"name",{value:t,configurable:!0}):e.name=t),pw&&n&&On(n,"arity")&&e.length!==n.arity&&iu(e,"length",{value:n.arity});try{n&&On(n,"constructor")&&n.constructor?Na&&iu(e,"prototype",{writable:!1}):e.prototype&&(e.prototype=void 0)}catch(r){}var i=gs(e);return On(i,"source")||(i.source=mw.join(typeof t=="string"?t:"")),e};Function.prototype.toString=vw(function(){return Ma(this)&&fw(this).source||Ua(this)},"toString");var gw=it,_w=At,yw=Vi.exports,bw=xa,Xt=function(e,t,n,i){i||(i={});var r=i.enumerable,o=i.name!==void 0?i.name:t;if(gw(n)&&yw(n,o,i),i.global)r?e[t]=n:bw(t,n);else{try{i.unsafe?e[t]&&(r=!0):delete e[t]}catch(c){}r?e[t]=n:_w.f(e,t,{value:n,enumerable:!1,configurable:!i.nonConfigurable,writable:!i.nonWritable})}return e},ri={},Sw=Math.ceil,kw=Math.floor,Tw=Math.trunc||function(e){var t=+e;return(t>0?kw:Sw)(t)},Qn=function(e){var t=+e;return t!=t||t===0?0:Tw(t)},xw=Qn,Iw=Math.max,ww=Math.min,ii=function(e,t){var n=xw(e);return n<0?Iw(n+t,0):ww(n,t)},Cw=Qn,Ew=Math.min,vr=function(e){return e>0?Ew(Cw(e),9007199254740991):0},Rw=vr,tn=function(e){return Rw(e.length)},Aw=yn,Pw=ii,Dw=tn,hg=function(e){return function(t,n,i){var r,o=Aw(t),c=Dw(o),a=Pw(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}},_s={includes:hg(!0),indexOf:hg(!1)},Fd=kt,Lw=yn,Ow=_s.indexOf,Mw=Z,fg=pe([].push),pg=function(e,t){var n,i=Lw(e),r=0,o=[];for(n in i)!Fd(Mw,n)&&Fd(i,n)&&fg(o,n);for(;t.length>r;)Fd(i,n=t[r++])&&(~Ow(o,n)||fg(o,n));return o},Hd=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"],Nw=pg,Uw=Hd.concat("length","prototype");ri.f=Object.getOwnPropertyNames||function(e){return Nw(e,Uw)};var Gd={};Gd.f=Object.getOwnPropertySymbols;var Vw=Rn,jw=ri,Bw=Gd,Fw=Tt,Hw=pe([].concat),Gw=Vw("Reflect","ownKeys")||function(e){var t=jw.f(Fw(e)),n=Bw.f;return n?Hw(t,n(e)):t},mg=kt,zw=Gw,Ww=be,qw=At,Jw=ue,Kw=it,Xw=/#|\.prototype\./,ys=function(e,t){var n=Yw[Qw(e)];return n==Zw||n!=$w&&(Kw(t)?Jw(t):!!t)},Qw=ys.normalize=function(e){return String(e).replace(Xw,".").toLowerCase()},Yw=ys.data={},$w=ys.NATIVE="N",Zw=ys.POLYFILL="P",bs=ys,zd=re,eC=be.f,tC=Ln,nC=Xt,rC=xa,iC=function(e,t,n){for(var i=zw(t),r=qw.f,o=Ww.f,c=0;c<i.length;c++){var a=i[c];mg(e,a)||n&&mg(n,a)||r(e,a,o(t,a))}},aC=bs,Me=function(e,t){var n,i,r,o,c,a=e.target,s=e.global,l=e.stat;if(n=s?zd:l?zd[a]||rC(a,{}):(zd[a]||{}).prototype)for(i in t){if(o=t[i],r=e.dontCallGetSet?(c=eC(n,i))&&c.value:n[i],!aC(s?i:a+(l?".":"#")+i,e.forced)&&r!==void 0){if(typeof o==typeof r)continue;iC(o,r)}(e.sham||r&&r.sham)&&tC(o,"sham",!0),nC(n,i,o,e)}},oC=Me,sC=ue,cC=yn,vg=be.f,gg=_e,uC=sC(function(){vg(1)});function Wd(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.')}oC({target:"Object",stat:!0,forced:!gg||uC,sham:!gg},{getOwnPropertyDescriptor:function(e,t){return vg(cC(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&&Wd)return Wd(l);if(a)return a(l,!0);var p=new Error("Cannot find module '"+l+"'");throw p.code="MODULE_NOT_FOUND",p}var k=r[l]={exports:{}};i[l][0].call(k.exports,function(x){return c(i[l][1][x]||x)},k,k.exports,n,i,r,o)}return r[l].exports}for(var a=Wd,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=="undefined"?void 0:window});i.exports=o},{"./adapter_factory.js":2}],2:[function(n,i,r){function o(I){return o=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},o(I)}Object.defineProperty(r,"__esModule",{value:!0}),r.adapterFactory=E;var c=x(n("./utils")),a=x(n("./chrome/chrome_shim")),s=x(n("./firefox/firefox_shim")),l=x(n("./safari/safari_shim")),u=x(n("./common_shim")),p=x(n("sdp"));function k(I){if(typeof WeakMap!="function")return null;var m=new WeakMap,T=new WeakMap;return(k=function(v){return v?T:m})(I)}function x(I,m){if(!m&&I&&I.__esModule)return I;if(I===null||o(I)!=="object"&&typeof I!="function")return{default:I};var T=k(m);if(T&&T.has(I))return T.get(I);var v={},C=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var O in I)if(O!=="default"&&Object.prototype.hasOwnProperty.call(I,O)){var N=C?Object.getOwnPropertyDescriptor(I,O):null;N&&(N.get||N.set)?Object.defineProperty(v,O,N):v[O]=I[O]}return v.default=I,T&&T.set(I,v),v}function E(){var I=(arguments.length>0&&arguments[0]!==void 0?arguments[0]:{}).window,m=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{shimChrome:!0,shimFirefox:!0,shimSafari:!0},T=c.log,v=c.detectBrowser(I),C={browserDetails:v,commonShim:u,extractVersion:c.extractVersion,disableLog:c.disableLog,disableWarnings:c.disableWarnings,sdp:p};switch(v.browser){case"chrome":if(!a||!a.shimPeerConnection||!m.shimChrome)return T("Chrome shim is not included in this adapter release."),C;if(v.version===null)return T("Chrome shim can not determine version, not shimming."),C;T("adapter.js shimming chrome."),C.browserShim=a,u.shimAddIceCandidateNullOrEmpty(I,v),u.shimParameterlessSetLocalDescription(I,v),a.shimGetUserMedia(I,v),a.shimMediaStream(I,v),a.shimPeerConnection(I,v),a.shimOnTrack(I,v),a.shimAddTrackRemoveTrack(I,v),a.shimGetSendersWithDtmf(I,v),a.shimGetStats(I,v),a.shimSenderReceiverGetStats(I,v),a.fixNegotiationNeeded(I,v),u.shimRTCIceCandidate(I,v),u.shimRTCIceCandidateRelayProtocol(I,v),u.shimConnectionState(I,v),u.shimMaxMessageSize(I,v),u.shimSendThrowTypeError(I,v),u.removeExtmapAllowMixed(I,v);break;case"firefox":if(!s||!s.shimPeerConnection||!m.shimFirefox)return T("Firefox shim is not included in this adapter release."),C;T("adapter.js shimming firefox."),C.browserShim=s,u.shimAddIceCandidateNullOrEmpty(I,v),u.shimParameterlessSetLocalDescription(I,v),s.shimGetUserMedia(I,v),s.shimPeerConnection(I,v),s.shimOnTrack(I,v),s.shimRemoveStream(I,v),s.shimSenderGetStats(I,v),s.shimReceiverGetStats(I,v),s.shimRTCDataChannel(I,v),s.shimAddTransceiver(I,v),s.shimGetParameters(I,v),s.shimCreateOffer(I,v),s.shimCreateAnswer(I,v),u.shimRTCIceCandidate(I,v),u.shimConnectionState(I,v),u.shimMaxMessageSize(I,v),u.shimSendThrowTypeError(I,v);break;case"safari":if(!l||!m.shimSafari)return T("Safari shim is not included in this adapter release."),C;T("adapter.js shimming safari."),C.browserShim=l,u.shimAddIceCandidateNullOrEmpty(I,v),u.shimParameterlessSetLocalDescription(I,v),l.shimRTCIceServerUrls(I,v),l.shimCreateOfferLegacy(I,v),l.shimCallbacksAPI(I,v),l.shimLocalStreamsAPI(I,v),l.shimRemoteStreamsAPI(I,v),l.shimTrackEventTransceiver(I,v),l.shimGetUserMedia(I,v),l.shimAudioContext(I,v),u.shimRTCIceCandidate(I,v),u.shimRTCIceCandidateRelayProtocol(I,v),u.shimMaxMessageSize(I,v),u.shimSendThrowTypeError(I,v),u.removeExtmapAllowMixed(I,v);break;default:T("Unsupported browser!")}return C}},{"./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=j,r.shimAddTrackRemoveTrack=O,r.shimAddTrackRemoveTrackWithNative=C,Object.defineProperty(r,"shimGetDisplayMedia",{enumerable:!0,get:function(){return a.shimGetDisplayMedia}}),r.shimGetSendersWithDtmf=m,r.shimGetStats=T,Object.defineProperty(r,"shimGetUserMedia",{enumerable:!0,get:function(){return c.shimGetUserMedia}}),r.shimMediaStream=E,r.shimOnTrack=I,r.shimPeerConnection=N,r.shimSenderReceiverGetStats=v;var o=l(n("../utils.js")),c=n("./getusermedia"),a=n("./getdisplaymedia");function s(_){if(typeof WeakMap!="function")return null;var b=new WeakMap,R=new WeakMap;return(s=function(P){return P?R:b})(_)}function l(_,b){if(!b&&_&&_.__esModule)return _;if(_===null||x(_)!=="object"&&typeof _!="function")return{default:_};var R=s(b);if(R&&R.has(_))return R.get(_);var P={},V=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var S in _)if(S!=="default"&&Object.prototype.hasOwnProperty.call(_,S)){var h=V?Object.getOwnPropertyDescriptor(_,S):null;h&&(h.get||h.set)?Object.defineProperty(P,S,h):P[S]=_[S]}return P.default=_,R&&R.set(_,P),P}function u(_,b,R){return(b=p(b))in _?Object.defineProperty(_,b,{value:R,enumerable:!0,configurable:!0,writable:!0}):_[b]=R,_}function p(_){var b=k(_,"string");return x(b)==="symbol"?b:String(b)}function k(_,b){if(x(_)!=="object"||_===null)return _;var R=_[Symbol.toPrimitive];if(R!==void 0){var P=R.call(_,b||"default");if(x(P)!=="object")return P;throw new TypeError("@@toPrimitive must return a primitive value.")}return(b==="string"?String:Number)(_)}function x(_){return x=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(b){return typeof b}:function(b){return b&&typeof Symbol=="function"&&b.constructor===Symbol&&b!==Symbol.prototype?"symbol":typeof b},x(_)}function E(_){_.MediaStream=_.MediaStream||_.webkitMediaStream}function I(_){if(x(_)==="object"&&_.RTCPeerConnection&&!("ontrack"in _.RTCPeerConnection.prototype)){Object.defineProperty(_.RTCPeerConnection.prototype,"ontrack",{get:function(){return this._ontrack},set:function(R){this._ontrack&&this.removeEventListener("track",this._ontrack),this.addEventListener("track",this._ontrack=R)},enumerable:!0,configurable:!0});var b=_.RTCPeerConnection.prototype.setRemoteDescription;_.RTCPeerConnection.prototype.setRemoteDescription=function(){var R=this;return this._ontrackpoly||(this._ontrackpoly=function(P){P.stream.addEventListener("addtrack",function(V){var S;S=_.RTCPeerConnection.prototype.getReceivers?R.getReceivers().find(function(y){return y.track&&y.track.id===V.track.id}):{track:V.track};var h=new Event("track");h.track=V.track,h.receiver=S,h.transceiver={receiver:S},h.streams=[P.stream],R.dispatchEvent(h)}),P.stream.getTracks().forEach(function(V){var S;S=_.RTCPeerConnection.prototype.getReceivers?R.getReceivers().find(function(y){return y.track&&y.track.id===V.id}):{track:V};var h=new Event("track");h.track=V,h.receiver=S,h.transceiver={receiver:S},h.streams=[P.stream],R.dispatchEvent(h)})},this.addEventListener("addstream",this._ontrackpoly)),b.apply(this,arguments)}}else o.wrapPeerConnectionEvent(_,"track",function(R){return R.transceiver||Object.defineProperty(R,"transceiver",{value:{receiver:R.receiver}}),R})}function m(_){if(x(_)==="object"&&_.RTCPeerConnection&&!("getSenders"in _.RTCPeerConnection.prototype)&&"createDTMFSender"in _.RTCPeerConnection.prototype){var b=function(y,A){return{track:A,get dtmf(){return this._dtmf===void 0&&(A.kind==="audio"?this._dtmf=y.createDTMFSender(A):this._dtmf=null),this._dtmf},_pc:y}};if(!_.RTCPeerConnection.prototype.getSenders){_.RTCPeerConnection.prototype.getSenders=function(){return this._senders=this._senders||[],this._senders.slice()};var R=_.RTCPeerConnection.prototype.addTrack;_.RTCPeerConnection.prototype.addTrack=function(y,A){var D=R.apply(this,arguments);return D||(D=b(this,y),this._senders.push(D)),D};var P=_.RTCPeerConnection.prototype.removeTrack;_.RTCPeerConnection.prototype.removeTrack=function(y){P.apply(this,arguments);var A=this._senders.indexOf(y);A!==-1&&this._senders.splice(A,1)}}var V=_.RTCPeerConnection.prototype.addStream;_.RTCPeerConnection.prototype.addStream=function(y){var A=this;this._senders=this._senders||[],V.apply(this,[y]),y.getTracks().forEach(function(D){A._senders.push(b(A,D))})};var S=_.RTCPeerConnection.prototype.removeStream;_.RTCPeerConnection.prototype.removeStream=function(y){var A=this;this._senders=this._senders||[],S.apply(this,[y]),y.getTracks().forEach(function(D){var U=A._senders.find(function(K){return K.track===D});U&&A._senders.splice(A._senders.indexOf(U),1)})}}else if(x(_)==="object"&&_.RTCPeerConnection&&"getSenders"in _.RTCPeerConnection.prototype&&"createDTMFSender"in _.RTCPeerConnection.prototype&&_.RTCRtpSender&&!("dtmf"in _.RTCRtpSender.prototype)){var h=_.RTCPeerConnection.prototype.getSenders;_.RTCPeerConnection.prototype.getSenders=function(){var y=this,A=h.apply(this,[]);return A.forEach(function(D){return D._pc=y}),A},Object.defineProperty(_.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 T(_){if(_.RTCPeerConnection){var b=_.RTCPeerConnection.prototype.getStats;_.RTCPeerConnection.prototype.getStats=function(){var R=this,P=Array.prototype.slice.call(arguments),V=P[0],S=P[1],h=P[2];if(arguments.length>0&&typeof V=="function")return b.apply(this,arguments);if(b.length===0&&(arguments.length===0||typeof V!="function"))return b.apply(this,[]);var y=function(U){var K={};return U.result().forEach(function(J){var ce={id:J.id,timestamp:J.timestamp,type:{localcandidate:"local-candidate",remotecandidate:"remote-candidate"}[J.type]||J.type};J.names().forEach(function(ae){ce[ae]=J.stat(ae)}),K[ce.id]=ce}),K},A=function(U){return new Map(Object.keys(U).map(function(K){return[K,U[K]]}))};if(arguments.length>=2){var D=function(U){S(A(y(U)))};return b.apply(this,[D,V])}return new Promise(function(U,K){b.apply(R,[function(J){U(A(y(J)))},K])}).then(S,h)}}}function v(_){if(x(_)==="object"&&_.RTCPeerConnection&&_.RTCRtpSender&&_.RTCRtpReceiver){if(!("getStats"in _.RTCRtpSender.prototype)){var b=_.RTCPeerConnection.prototype.getSenders;b&&(_.RTCPeerConnection.prototype.getSenders=function(){var S=this,h=b.apply(this,[]);return h.forEach(function(y){return y._pc=S}),h});var R=_.RTCPeerConnection.prototype.addTrack;R&&(_.RTCPeerConnection.prototype.addTrack=function(){var S=R.apply(this,arguments);return S._pc=this,S}),_.RTCRtpSender.prototype.getStats=function(){var S=this;return this._pc.getStats().then(function(h){return o.filterStats(h,S.track,!0)})}}if(!("getStats"in _.RTCRtpReceiver.prototype)){var P=_.RTCPeerConnection.prototype.getReceivers;P&&(_.RTCPeerConnection.prototype.getReceivers=function(){var S=this,h=P.apply(this,[]);return h.forEach(function(y){return y._pc=S}),h}),o.wrapPeerConnectionEvent(_,"track",function(S){return S.receiver._pc=S.srcElement,S}),_.RTCRtpReceiver.prototype.getStats=function(){var S=this;return this._pc.getStats().then(function(h){return o.filterStats(h,S.track,!1)})}}if("getStats"in _.RTCRtpSender.prototype&&"getStats"in _.RTCRtpReceiver.prototype){var V=_.RTCPeerConnection.prototype.getStats;_.RTCPeerConnection.prototype.getStats=function(){if(arguments.length>0&&arguments[0]instanceof _.MediaStreamTrack){var S,h,y,A=arguments[0];return this.getSenders().forEach(function(D){D.track===A&&(S?y=!0:S=D)}),this.getReceivers().forEach(function(D){return D.track===A&&(h?y=!0:h=D),D.track===A}),y||S&&h?Promise.reject(new DOMException("There are more than one sender or receiver for the track.","InvalidAccessError")):S?S.getStats():h?h.getStats():Promise.reject(new DOMException("There is no sender or receiver for the track.","InvalidAccessError"))}return V.apply(this,arguments)}}}}function C(_){_.RTCPeerConnection.prototype.getLocalStreams=function(){var S=this;return this._shimmedLocalStreams=this._shimmedLocalStreams||{},Object.keys(this._shimmedLocalStreams).map(function(h){return S._shimmedLocalStreams[h][0]})};var b=_.RTCPeerConnection.prototype.addTrack;_.RTCPeerConnection.prototype.addTrack=function(S,h){if(!h)return b.apply(this,arguments);this._shimmedLocalStreams=this._shimmedLocalStreams||{};var y=b.apply(this,arguments);return this._shimmedLocalStreams[h.id]?this._shimmedLocalStreams[h.id].indexOf(y)===-1&&this._shimmedLocalStreams[h.id].push(y):this._shimmedLocalStreams[h.id]=[h,y],y};var R=_.RTCPeerConnection.prototype.addStream;_.RTCPeerConnection.prototype.addStream=function(S){var h=this;this._shimmedLocalStreams=this._shimmedLocalStreams||{},S.getTracks().forEach(function(D){if(h.getSenders().find(function(U){return U.track===D}))throw new DOMException("Track already exists.","InvalidAccessError")});var y=this.getSenders();R.apply(this,arguments);var A=this.getSenders().filter(function(D){return y.indexOf(D)===-1});this._shimmedLocalStreams[S.id]=[S].concat(A)};var P=_.RTCPeerConnection.prototype.removeStream;_.RTCPeerConnection.prototype.removeStream=function(S){return this._shimmedLocalStreams=this._shimmedLocalStreams||{},delete this._shimmedLocalStreams[S.id],P.apply(this,arguments)};var V=_.RTCPeerConnection.prototype.removeTrack;_.RTCPeerConnection.prototype.removeTrack=function(S){var h=this;return this._shimmedLocalStreams=this._shimmedLocalStreams||{},S&&Object.keys(this._shimmedLocalStreams).forEach(function(y){var A=h._shimmedLocalStreams[y].indexOf(S);A!==-1&&h._shimmedLocalStreams[y].splice(A,1),h._shimmedLocalStreams[y].length===1&&delete h._shimmedLocalStreams[y]}),V.apply(this,arguments)}}function O(_,b){if(_.RTCPeerConnection){if(_.RTCPeerConnection.prototype.addTrack&&b.version>=65)return C(_);var R=_.RTCPeerConnection.prototype.getLocalStreams;_.RTCPeerConnection.prototype.getLocalStreams=function(){var D=this,U=R.apply(this);return this._reverseStreams=this._reverseStreams||{},U.map(function(K){return D._reverseStreams[K.id]})};var P=_.RTCPeerConnection.prototype.addStream;_.RTCPeerConnection.prototype.addStream=function(D){var U=this;if(this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{},D.getTracks().forEach(function(J){if(U.getSenders().find(function(ce){return ce.track===J}))throw new DOMException("Track already exists.","InvalidAccessError")}),!this._reverseStreams[D.id]){var K=new _.MediaStream(D.getTracks());this._streams[D.id]=K,this._reverseStreams[K.id]=D,D=K}P.apply(this,[D])};var V=_.RTCPeerConnection.prototype.removeStream;_.RTCPeerConnection.prototype.removeStream=function(D){this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{},V.apply(this,[this._streams[D.id]||D]),delete this._reverseStreams[this._streams[D.id]?this._streams[D.id].id:D.id],delete this._streams[D.id]},_.RTCPeerConnection.prototype.addTrack=function(D,U){var K=this;if(this.signalingState==="closed")throw new DOMException("The RTCPeerConnection's signalingState is 'closed'.","InvalidStateError");var J=[].slice.call(arguments,1);if(J.length!==1||!J[0].getTracks().find(function(qe){return qe===D}))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(qe){return qe.track===D}))throw new DOMException("Track already exists.","InvalidAccessError");this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{};var ce=this._streams[U.id];if(ce)ce.addTrack(D),Promise.resolve().then(function(){K.dispatchEvent(new Event("negotiationneeded"))});else{var ae=new _.MediaStream([D]);this._streams[U.id]=ae,this._reverseStreams[ae.id]=U,this.addStream(ae)}return this.getSenders().find(function(qe){return qe.track===D})},["createOffer","createAnswer"].forEach(function(D){var U=_.RTCPeerConnection.prototype[D],K=u({},D,function(){var J=this,ce=arguments;return arguments.length&&typeof arguments[0]=="function"?U.apply(this,[function(ae){var qe=y(J,ae);ce[0].apply(null,[qe])},function(ae){ce[1]&&ce[1].apply(null,ae)},arguments[2]]):U.apply(this,arguments).then(function(ae){return y(J,ae)})});_.RTCPeerConnection.prototype[D]=K[D]});var S=_.RTCPeerConnection.prototype.setLocalDescription;_.RTCPeerConnection.prototype.setLocalDescription=function(){return arguments.length&&arguments[0].type?(arguments[0]=A(this,arguments[0]),S.apply(this,arguments)):S.apply(this,arguments)};var h=Object.getOwnPropertyDescriptor(_.RTCPeerConnection.prototype,"localDescription");Object.defineProperty(_.RTCPeerConnection.prototype,"localDescription",{get:function(){var D=h.get.apply(this);return D.type===""?D:y(this,D)}}),_.RTCPeerConnection.prototype.removeTrack=function(D){var U,K=this;if(this.signalingState==="closed")throw new DOMException("The RTCPeerConnection's signalingState is 'closed'.","InvalidStateError");if(!D._pc)throw new DOMException("Argument 1 of RTCPeerConnection.removeTrack does not implement interface RTCRtpSender.","TypeError");if(D._pc!==this)throw new DOMException("Sender was not created by this connection.","InvalidAccessError");this._streams=this._streams||{},Object.keys(this._streams).forEach(function(J){K._streams[J].getTracks().find(function(ce){return D.track===ce})&&(U=K._streams[J])}),U&&(U.getTracks().length===1?this.removeStream(this._reverseStreams[U.id]):U.removeTrack(D.track),this.dispatchEvent(new Event("negotiationneeded")))}}function y(D,U){var K=U.sdp;return Object.keys(D._reverseStreams||[]).forEach(function(J){var ce=D._reverseStreams[J],ae=D._streams[ce.id];K=K.replace(new RegExp(ae.id,"g"),ce.id)}),new RTCSessionDescription({type:U.type,sdp:K})}function A(D,U){var K=U.sdp;return Object.keys(D._reverseStreams||[]).forEach(function(J){var ce=D._reverseStreams[J],ae=D._streams[ce.id];K=K.replace(new RegExp(ce.id,"g"),ae.id)}),new RTCSessionDescription({type:U.type,sdp:K})}}function N(_,b){!_.RTCPeerConnection&&_.webkitRTCPeerConnection&&(_.RTCPeerConnection=_.webkitRTCPeerConnection),_.RTCPeerConnection&&b.version<53&&["setLocalDescription","setRemoteDescription","addIceCandidate"].forEach(function(R){var P=_.RTCPeerConnection.prototype[R],V=u({},R,function(){return arguments[0]=new(R==="addIceCandidate"?_.RTCIceCandidate:_.RTCSessionDescription)(arguments[0]),P.apply(this,arguments)});_.RTCPeerConnection.prototype[R]=V[R]})}function j(_,b){o.wrapPeerConnectionEvent(_,"negotiationneeded",function(R){var P=R.target;if(!(b.version<72||P.getConfiguration&&P.getConfiguration().sdpSemantics==="plan-b")||P.signalingState==="stable")return R})}},{"../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,p=s.video&&s.video.height,k=s.video&&s.video.frameRate;return s.video={mandatory:{chromeMediaSource:"desktop",chromeMediaSourceId:l,maxFrameRate:k||3}},u&&(s.video.mandatory.maxWidth=u),p&&(s.video.mandatory.maxHeight=p),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 p=new WeakMap,k=new WeakMap;return(o=function(x){return x?k:p})(u)}function c(u,p){if(!p&&u&&u.__esModule)return u;if(u===null||a(u)!=="object"&&typeof u!="function")return{default:u};var k=o(p);if(k&&k.has(u))return k.get(u);var x={},E=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var I in u)if(I!=="default"&&Object.prototype.hasOwnProperty.call(u,I)){var m=E?Object.getOwnPropertyDescriptor(u,I):null;m&&(m.get||m.set)?Object.defineProperty(x,I,m):x[I]=u[I]}return x.default=u,k&&k.set(u,x),x}function a(u){return a=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},a(u)}Object.defineProperty(r,"__esModule",{value:!0}),r.shimGetUserMedia=l;var s=c(n("../utils.js")).log;function l(u,p){var k=u&&u.navigator;if(k.mediaDevices){var x=function(v){if(a(v)!=="object"||v.mandatory||v.optional)return v;var C={};return Object.keys(v).forEach(function(O){if(O!=="require"&&O!=="advanced"&&O!=="mediaSource"){var N=a(v[O])==="object"?v[O]:{ideal:v[O]};N.exact!==void 0&&typeof N.exact=="number"&&(N.min=N.max=N.exact);var j=function(b,R){return b?b+R.charAt(0).toUpperCase()+R.slice(1):R==="deviceId"?"sourceId":R};if(N.ideal!==void 0){C.optional=C.optional||[];var _={};typeof N.ideal=="number"?(_[j("min",O)]=N.ideal,C.optional.push(_),(_={})[j("max",O)]=N.ideal,C.optional.push(_)):(_[j("",O)]=N.ideal,C.optional.push(_))}N.exact!==void 0&&typeof N.exact!="number"?(C.mandatory=C.mandatory||{},C.mandatory[j("",O)]=N.exact):["min","max"].forEach(function(b){N[b]!==void 0&&(C.mandatory=C.mandatory||{},C.mandatory[j(b,O)]=N[b])})}}),v.advanced&&(C.optional=(C.optional||[]).concat(v.advanced)),C},E=function(v,C){if(p.version>=61)return C(v);if((v=JSON.parse(JSON.stringify(v)))&&a(v.audio)==="object"){var O=function(b,R,P){R in b&&!(P in b)&&(b[P]=b[R],delete b[R])};O((v=JSON.parse(JSON.stringify(v))).audio,"autoGainControl","googAutoGainControl"),O(v.audio,"noiseSuppression","googNoiseSuppression"),v.audio=x(v.audio)}if(v&&a(v.video)==="object"){var N=v.video.facingMode;N=N&&(a(N)==="object"?N:{ideal:N});var j,_=p.version<66;if(N&&(N.exact==="user"||N.exact==="environment"||N.ideal==="user"||N.ideal==="environment")&&(!k.mediaDevices.getSupportedConstraints||!k.mediaDevices.getSupportedConstraints().facingMode||_)&&(delete v.video.facingMode,N.exact==="environment"||N.ideal==="environment"?j=["back","rear"]:N.exact!=="user"&&N.ideal!=="user"||(j=["front"]),j))return k.mediaDevices.enumerateDevices().then(function(b){var R=(b=b.filter(function(P){return P.kind==="videoinput"})).find(function(P){return j.some(function(V){return P.label.toLowerCase().includes(V)})});return!R&&b.length&&j.includes("back")&&(R=b[b.length-1]),R&&(v.video.deviceId=N.exact?{exact:R.deviceId}:{ideal:R.deviceId}),v.video=x(v.video),s("chrome: "+JSON.stringify(v)),C(v)});v.video=x(v.video)}return s("chrome: "+JSON.stringify(v)),C(v)},I=function(v){return p.version>=64?v:{name:{PermissionDeniedError:"NotAllowedError",PermissionDismissedError:"NotAllowedError",InvalidStateError:"NotAllowedError",DevicesNotFoundError:"NotFoundError",ConstraintNotSatisfiedError:"OverconstrainedError",TrackStartError:"NotReadableError",MediaDeviceFailedDueToShutdown:"NotAllowedError",MediaDeviceKillSwitchOn:"NotAllowedError",TabCaptureError:"AbortError",ScreenCaptureError:"AbortError",DeviceCaptureError:"AbortError"}[v.name]||v.name,message:v.message,constraint:v.constraint||v.constraintName,toString:function(){return this.name+(this.message&&": ")+this.message}}},m=function(v,C,O){E(v,function(N){k.webkitGetUserMedia(N,C,function(j){O&&O(I(j))})})};if(k.getUserMedia=m.bind(k),k.mediaDevices.getUserMedia){var T=k.mediaDevices.getUserMedia.bind(k.mediaDevices);k.mediaDevices.getUserMedia=function(v){return E(v,function(C){return T(C).then(function(O){if(C.audio&&!O.getAudioTracks().length||C.video&&!O.getVideoTracks().length)throw O.getTracks().forEach(function(N){N.stop()}),new DOMException("","NotFoundError");return O},function(O){return Promise.reject(I(O))})})}}}}},{"../utils.js":11}],6:[function(n,i,r){Object.defineProperty(r,"__esModule",{value:!0}),r.removeExtmapAllowMixed=m,r.shimAddIceCandidateNullOrEmpty=T,r.shimConnectionState=I,r.shimMaxMessageSize=x,r.shimParameterlessSetLocalDescription=v,r.shimRTCIceCandidate=p,r.shimRTCIceCandidateRelayProtocol=k,r.shimSendThrowTypeError=E;var o=l(n("sdp")),c=s(n("./utils"));function a(C){if(typeof WeakMap!="function")return null;var O=new WeakMap,N=new WeakMap;return(a=function(j){return j?N:O})(C)}function s(C,O){if(!O&&C&&C.__esModule)return C;if(C===null||u(C)!=="object"&&typeof C!="function")return{default:C};var N=a(O);if(N&&N.has(C))return N.get(C);var j={},_=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var b in C)if(b!=="default"&&Object.prototype.hasOwnProperty.call(C,b)){var R=_?Object.getOwnPropertyDescriptor(C,b):null;R&&(R.get||R.set)?Object.defineProperty(j,b,R):j[b]=C[b]}return j.default=C,N&&N.set(C,j),j}function l(C){return C&&C.__esModule?C:{default:C}}function u(C){return u=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(O){return typeof O}:function(O){return O&&typeof Symbol=="function"&&O.constructor===Symbol&&O!==Symbol.prototype?"symbol":typeof O},u(C)}function p(C){if(!(!C.RTCIceCandidate||C.RTCIceCandidate&&"foundation"in C.RTCIceCandidate.prototype)){var O=C.RTCIceCandidate;C.RTCIceCandidate=function(N){if(u(N)==="object"&&N.candidate&&N.candidate.indexOf("a=")===0&&((N=JSON.parse(JSON.stringify(N))).candidate=N.candidate.substring(2)),N.candidate&&N.candidate.length){var j=new O(N),_=o.default.parseCandidate(N.candidate);for(var b in _)b in j||Object.defineProperty(j,b,{value:_[b]});return j.toJSON=function(){return{candidate:j.candidate,sdpMid:j.sdpMid,sdpMLineIndex:j.sdpMLineIndex,usernameFragment:j.usernameFragment}},j}return new O(N)},C.RTCIceCandidate.prototype=O.prototype,c.wrapPeerConnectionEvent(C,"icecandidate",function(N){return N.candidate&&Object.defineProperty(N,"candidate",{value:new C.RTCIceCandidate(N.candidate),writable:"false"}),N})}}function k(C){!C.RTCIceCandidate||C.RTCIceCandidate&&"relayProtocol"in C.RTCIceCandidate.prototype||c.wrapPeerConnectionEvent(C,"icecandidate",function(O){if(O.candidate){var N=o.default.parseCandidate(O.candidate.candidate);N.type==="relay"&&(O.candidate.relayProtocol={0:"tls",1:"tcp",2:"udp"}[N.priority>>24])}return O})}function x(C,O){if(C.RTCPeerConnection){"sctp"in C.RTCPeerConnection.prototype||Object.defineProperty(C.RTCPeerConnection.prototype,"sctp",{get:function(){return this._sctp===void 0?null:this._sctp}});var N=function(P){if(!P||!P.sdp)return!1;var V=o.default.splitSections(P.sdp);return V.shift(),V.some(function(S){var h=o.default.parseMLine(S);return h&&h.kind==="application"&&h.protocol.indexOf("SCTP")!==-1})},j=function(P){var V=P.sdp.match(/mozilla...THIS_IS_SDPARTA-(\d+)/);if(V===null||V.length<2)return-1;var S=parseInt(V[1],10);return S!=S?-1:S},_=function(P){var V=65536;return O.browser==="firefox"&&(V=O.version<57?P===-1?16384:2147483637:O.version<60?O.version===57?65535:65536:2147483637),V},b=function(P,V){var S=65536;O.browser==="firefox"&&O.version===57&&(S=65535);var h=o.default.matchPrefix(P.sdp,"a=max-message-size:");return h.length>0?S=parseInt(h[0].substring(19),10):O.browser==="firefox"&&V!==-1&&(S=2147483637),S},R=C.RTCPeerConnection.prototype.setRemoteDescription;C.RTCPeerConnection.prototype.setRemoteDescription=function(){if(this._sctp=null,O.browser==="chrome"&&O.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}),N(arguments[0])){var P,V=j(arguments[0]),S=_(V),h=b(arguments[0],V);P=S===0&&h===0?Number.POSITIVE_INFINITY:S===0||h===0?Math.max(S,h):Math.min(S,h);var y={};Object.defineProperty(y,"maxMessageSize",{get:function(){return P}}),this._sctp=y}return R.apply(this,arguments)}}}function E(C){if(C.RTCPeerConnection&&"createDataChannel"in C.RTCPeerConnection.prototype){var O=C.RTCPeerConnection.prototype.createDataChannel;C.RTCPeerConnection.prototype.createDataChannel=function(){var j=O.apply(this,arguments);return N(j,this),j},c.wrapPeerConnectionEvent(C,"datachannel",function(j){return N(j.channel,j.target),j})}function N(j,_){var b=j.send;j.send=function(){var R=arguments[0],P=R.length||R.size||R.byteLength;if(j.readyState==="open"&&_.sctp&&P>_.sctp.maxMessageSize)throw new TypeError("Message too large (can send a maximum of "+_.sctp.maxMessageSize+" bytes)");return b.apply(j,arguments)}}}function I(C){if(C.RTCPeerConnection&&!("connectionState"in C.RTCPeerConnection.prototype)){var O=C.RTCPeerConnection.prototype;Object.defineProperty(O,"connectionState",{get:function(){return{completed:"connected",checking:"connecting"}[this.iceConnectionState]||this.iceConnectionState},enumerable:!0,configurable:!0}),Object.defineProperty(O,"onconnectionstatechange",{get:function(){return this._onconnectionstatechange||null},set:function(N){this._onconnectionstatechange&&(this.removeEventListener("connectionstatechange",this._onconnectionstatechange),delete this._onconnectionstatechange),N&&this.addEventListener("connectionstatechange",this._onconnectionstatechange=N)},enumerable:!0,configurable:!0}),["setLocalDescription","setRemoteDescription"].forEach(function(N){var j=O[N];O[N]=function(){return this._connectionstatechangepoly||(this._connectionstatechangepoly=function(_){var b=_.target;if(b._lastConnectionState!==b.connectionState){b._lastConnectionState=b.connectionState;var R=new Event("connectionstatechange",_);b.dispatchEvent(R)}return _},this.addEventListener("iceconnectionstatechange",this._connectionstatechangepoly)),j.apply(this,arguments)}})}}function m(C,O){if(C.RTCPeerConnection&&!(O.browser==="chrome"&&O.version>=71||O.browser==="safari"&&O.version>=605)){var N=C.RTCPeerConnection.prototype.setRemoteDescription;C.RTCPeerConnection.prototype.setRemoteDescription=function(j){if(j&&j.sdp&&j.sdp.indexOf(`
5
+ a=extmap-allow-mixed`)!==-1){var _=j.sdp.split(`
6
+ `).filter(function(b){return b.trim()!=="a=extmap-allow-mixed"}).join(`
7
+ `);C.RTCSessionDescription&&j instanceof C.RTCSessionDescription?arguments[0]=new C.RTCSessionDescription({type:j.type,sdp:_}):j.sdp=_}return N.apply(this,arguments)}}}function T(C,O){if(C.RTCPeerConnection&&C.RTCPeerConnection.prototype){var N=C.RTCPeerConnection.prototype.addIceCandidate;N&&N.length!==0&&(C.RTCPeerConnection.prototype.addIceCandidate=function(){return arguments[0]?(O.browser==="chrome"&&O.version<78||O.browser==="firefox"&&O.version<68||O.browser==="safari")&&arguments[0]&&arguments[0].candidate===""?Promise.resolve():N.apply(this,arguments):(arguments[1]&&arguments[1].apply(null),Promise.resolve())})}}function v(C,O){if(C.RTCPeerConnection&&C.RTCPeerConnection.prototype){var N=C.RTCPeerConnection.prototype.setLocalDescription;N&&N.length!==0&&(C.RTCPeerConnection.prototype.setLocalDescription=function(){var j=this,_=arguments[0]||{};if(u(_)!=="object"||_.type&&_.sdp)return N.apply(this,arguments);if(!(_={type:_.type,sdp:_.sdp}).type)switch(this.signalingState){case"stable":case"have-local-offer":case"have-remote-pranswer":_.type="offer";break;default:_.type="answer"}return _.sdp||_.type!=="offer"&&_.type!=="answer"?N.apply(this,[_]):(_.type==="offer"?this.createOffer:this.createAnswer).apply(this).then(function(b){return N.apply(j,[b])})})}}},{"./utils":11,sdp:12}],7:[function(n,i,r){Object.defineProperty(r,"__esModule",{value:!0}),r.shimAddTransceiver=P,r.shimCreateAnswer=h,r.shimCreateOffer=S,Object.defineProperty(r,"shimGetDisplayMedia",{enumerable:!0,get:function(){return a.shimGetDisplayMedia}}),r.shimGetParameters=V,Object.defineProperty(r,"shimGetUserMedia",{enumerable:!0,get:function(){return c.shimGetUserMedia}}),r.shimOnTrack=O,r.shimPeerConnection=N,r.shimRTCDataChannel=R,r.shimReceiverGetStats=_,r.shimRemoveStream=b,r.shimSenderGetStats=j;var o=l(n("../utils")),c=n("./getusermedia"),a=n("./getdisplaymedia");function s(y){if(typeof WeakMap!="function")return null;var A=new WeakMap,D=new WeakMap;return(s=function(U){return U?D:A})(y)}function l(y,A){if(!A&&y&&y.__esModule)return y;if(y===null||C(y)!=="object"&&typeof y!="function")return{default:y};var D=s(A);if(D&&D.has(y))return D.get(y);var U={},K=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var J in y)if(J!=="default"&&Object.prototype.hasOwnProperty.call(y,J)){var ce=K?Object.getOwnPropertyDescriptor(y,J):null;ce&&(ce.get||ce.set)?Object.defineProperty(U,J,ce):U[J]=y[J]}return U.default=y,D&&D.set(y,U),U}function u(y){return E(y)||x(y)||k(y)||p()}function p(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
8
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function k(y,A){if(y){if(typeof y=="string")return I(y,A);var D=Object.prototype.toString.call(y).slice(8,-1);return D==="Object"&&y.constructor&&(D=y.constructor.name),D==="Map"||D==="Set"?Array.from(y):D==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(D)?I(y,A):void 0}}function x(y){if(typeof Symbol!="undefined"&&y[Symbol.iterator]!=null||y["@@iterator"]!=null)return Array.from(y)}function E(y){if(Array.isArray(y))return I(y)}function I(y,A){(A==null||A>y.length)&&(A=y.length);for(var D=0,U=new Array(A);D<A;D++)U[D]=y[D];return U}function m(y,A,D){return(A=T(A))in y?Object.defineProperty(y,A,{value:D,enumerable:!0,configurable:!0,writable:!0}):y[A]=D,y}function T(y){var A=v(y,"string");return C(A)==="symbol"?A:String(A)}function v(y,A){if(C(y)!=="object"||y===null)return y;var D=y[Symbol.toPrimitive];if(D!==void 0){var U=D.call(y,A||"default");if(C(U)!=="object")return U;throw new TypeError("@@toPrimitive must return a primitive value.")}return(A==="string"?String:Number)(y)}function C(y){return C=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(y)}function O(y){C(y)==="object"&&y.RTCTrackEvent&&"receiver"in y.RTCTrackEvent.prototype&&!("transceiver"in y.RTCTrackEvent.prototype)&&Object.defineProperty(y.RTCTrackEvent.prototype,"transceiver",{get:function(){return{receiver:this.receiver}}})}function N(y,A){if(C(y)==="object"&&(y.RTCPeerConnection||y.mozRTCPeerConnection)){!y.RTCPeerConnection&&y.mozRTCPeerConnection&&(y.RTCPeerConnection=y.mozRTCPeerConnection),A.version<53&&["setLocalDescription","setRemoteDescription","addIceCandidate"].forEach(function(K){var J=y.RTCPeerConnection.prototype[K],ce=m({},K,function(){return arguments[0]=new(K==="addIceCandidate"?y.RTCIceCandidate:y.RTCSessionDescription)(arguments[0]),J.apply(this,arguments)});y.RTCPeerConnection.prototype[K]=ce[K]});var D={inboundrtp:"inbound-rtp",outboundrtp:"outbound-rtp",candidatepair:"candidate-pair",localcandidate:"local-candidate",remotecandidate:"remote-candidate"},U=y.RTCPeerConnection.prototype.getStats;y.RTCPeerConnection.prototype.getStats=function(){var K=Array.prototype.slice.call(arguments),J=K[0],ce=K[1],ae=K[2];return U.apply(this,[J||null]).then(function(qe){if(A.version<53&&!ce)try{qe.forEach(function(Ue){Ue.type=D[Ue.type]||Ue.type})}catch(Ue){if(Ue.name!=="TypeError")throw Ue;qe.forEach(function(Fe,lt){qe.set(lt,Object.assign({},Fe,{type:D[Fe.type]||Fe.type}))})}return qe}).then(ce,ae)}}}function j(y){if(C(y)==="object"&&y.RTCPeerConnection&&y.RTCRtpSender&&(!y.RTCRtpSender||!("getStats"in y.RTCRtpSender.prototype))){var A=y.RTCPeerConnection.prototype.getSenders;A&&(y.RTCPeerConnection.prototype.getSenders=function(){var U=this,K=A.apply(this,[]);return K.forEach(function(J){return J._pc=U}),K});var D=y.RTCPeerConnection.prototype.addTrack;D&&(y.RTCPeerConnection.prototype.addTrack=function(){var U=D.apply(this,arguments);return U._pc=this,U}),y.RTCRtpSender.prototype.getStats=function(){return this.track?this._pc.getStats(this.track):Promise.resolve(new Map)}}}function _(y){if(C(y)==="object"&&y.RTCPeerConnection&&y.RTCRtpSender&&(!y.RTCRtpSender||!("getStats"in y.RTCRtpReceiver.prototype))){var A=y.RTCPeerConnection.prototype.getReceivers;A&&(y.RTCPeerConnection.prototype.getReceivers=function(){var D=this,U=A.apply(this,[]);return U.forEach(function(K){return K._pc=D}),U}),o.wrapPeerConnectionEvent(y,"track",function(D){return D.receiver._pc=D.srcElement,D}),y.RTCRtpReceiver.prototype.getStats=function(){return this._pc.getStats(this.track)}}}function b(y){y.RTCPeerConnection&&!("removeStream"in y.RTCPeerConnection.prototype)&&(y.RTCPeerConnection.prototype.removeStream=function(A){var D=this;o.deprecated("removeStream","removeTrack"),this.getSenders().forEach(function(U){U.track&&A.getTracks().includes(U.track)&&D.removeTrack(U)})})}function R(y){y.DataChannel&&!y.RTCDataChannel&&(y.RTCDataChannel=y.DataChannel)}function P(y){if(C(y)==="object"&&y.RTCPeerConnection){var A=y.RTCPeerConnection.prototype.addTransceiver;A&&(y.RTCPeerConnection.prototype.addTransceiver=function(){this.setParametersPromises=[];var D=arguments[1]&&arguments[1].sendEncodings;D===void 0&&(D=[]);var U=(D=u(D)).length>0;U&&D.forEach(function(ae){if("rid"in ae&&!/^[a-z0-9]{0,16}$/i.test(ae.rid))throw new TypeError("Invalid RID value provided.");if("scaleResolutionDownBy"in ae&&!(parseFloat(ae.scaleResolutionDownBy)>=1))throw new RangeError("scale_resolution_down_by must be >= 1.0");if("maxFramerate"in ae&&!(parseFloat(ae.maxFramerate)>=0))throw new RangeError("max_framerate must be >= 0.0")});var K=A.apply(this,arguments);if(U){var J=K.sender,ce=J.getParameters();(!("encodings"in ce)||ce.encodings.length===1&&Object.keys(ce.encodings[0]).length===0)&&(ce.encodings=D,J.sendEncodings=D,this.setParametersPromises.push(J.setParameters(ce).then(function(){delete J.sendEncodings}).catch(function(){delete J.sendEncodings})))}return K})}}function V(y){if(C(y)==="object"&&y.RTCRtpSender){var A=y.RTCRtpSender.prototype.getParameters;A&&(y.RTCRtpSender.prototype.getParameters=function(){var D=A.apply(this,arguments);return"encodings"in D||(D.encodings=[].concat(this.sendEncodings||[{}])),D})}}function S(y){if(C(y)==="object"&&y.RTCPeerConnection){var A=y.RTCPeerConnection.prototype.createOffer;y.RTCPeerConnection.prototype.createOffer=function(){var D=arguments,U=this;return this.setParametersPromises&&this.setParametersPromises.length?Promise.all(this.setParametersPromises).then(function(){return A.apply(U,D)}).finally(function(){U.setParametersPromises=[]}):A.apply(this,arguments)}}}function h(y){if(C(y)==="object"&&y.RTCPeerConnection){var A=y.RTCPeerConnection.prototype.createAnswer;y.RTCPeerConnection.prototype.createAnswer=function(){var D=arguments,U=this;return this.setParametersPromises&&this.setParametersPromises.length?Promise.all(this.setParametersPromises).then(function(){return A.apply(U,D)}).finally(function(){U.setParametersPromises=[]}):A.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 p=new WeakMap,k=new WeakMap;return(c=function(x){return x?k:p})(u)}function a(u,p){if(!p&&u&&u.__esModule)return u;if(u===null||s(u)!=="object"&&typeof u!="function")return{default:u};var k=c(p);if(k&&k.has(u))return k.get(u);var x={},E=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var I in u)if(I!=="default"&&Object.prototype.hasOwnProperty.call(u,I)){var m=E?Object.getOwnPropertyDescriptor(u,I):null;m&&(m.get||m.set)?Object.defineProperty(x,I,m):x[I]=u[I]}return x.default=u,k&&k.set(u,x),x}function s(u){return s=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},s(u)}function l(u,p){var k=u&&u.navigator,x=u&&u.MediaStreamTrack;if(k.getUserMedia=function(v,C,O){o.deprecated("navigator.getUserMedia","navigator.mediaDevices.getUserMedia"),k.mediaDevices.getUserMedia(v).then(C,O)},!(p.version>55&&"autoGainControl"in k.mediaDevices.getSupportedConstraints())){var E=function(v,C,O){C in v&&!(O in v)&&(v[O]=v[C],delete v[C])},I=k.mediaDevices.getUserMedia.bind(k.mediaDevices);if(k.mediaDevices.getUserMedia=function(v){return s(v)==="object"&&s(v.audio)==="object"&&(v=JSON.parse(JSON.stringify(v)),E(v.audio,"autoGainControl","mozAutoGainControl"),E(v.audio,"noiseSuppression","mozNoiseSuppression")),I(v)},x&&x.prototype.getSettings){var m=x.prototype.getSettings;x.prototype.getSettings=function(){var v=m.apply(this,arguments);return E(v,"mozAutoGainControl","autoGainControl"),E(v,"mozNoiseSuppression","noiseSuppression"),v}}if(x&&x.prototype.applyConstraints){var T=x.prototype.applyConstraints;x.prototype.applyConstraints=function(v){return this.kind==="audio"&&s(v)==="object"&&(v=JSON.parse(JSON.stringify(v)),E(v,"autoGainControl","mozAutoGainControl"),E(v,"noiseSuppression","mozNoiseSuppression")),T.apply(this,[v])}}}}},{"../utils":11}],10:[function(n,i,r){Object.defineProperty(r,"__esModule",{value:!0}),r.shimAudioContext=T,r.shimCallbacksAPI=p,r.shimConstraints=x,r.shimCreateOfferLegacy=m,r.shimGetUserMedia=k,r.shimLocalStreamsAPI=l,r.shimRTCIceServerUrls=E,r.shimRemoteStreamsAPI=u,r.shimTrackEventTransceiver=I;var o=a(n("../utils"));function c(v){if(typeof WeakMap!="function")return null;var C=new WeakMap,O=new WeakMap;return(c=function(N){return N?O:C})(v)}function a(v,C){if(!C&&v&&v.__esModule)return v;if(v===null||s(v)!=="object"&&typeof v!="function")return{default:v};var O=c(C);if(O&&O.has(v))return O.get(v);var N={},j=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var _ in v)if(_!=="default"&&Object.prototype.hasOwnProperty.call(v,_)){var b=j?Object.getOwnPropertyDescriptor(v,_):null;b&&(b.get||b.set)?Object.defineProperty(N,_,b):N[_]=v[_]}return N.default=v,O&&O.set(v,N),N}function s(v){return s=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(C){return typeof C}:function(C){return C&&typeof Symbol=="function"&&C.constructor===Symbol&&C!==Symbol.prototype?"symbol":typeof C},s(v)}function l(v){if(s(v)==="object"&&v.RTCPeerConnection){if("getLocalStreams"in v.RTCPeerConnection.prototype||(v.RTCPeerConnection.prototype.getLocalStreams=function(){return this._localStreams||(this._localStreams=[]),this._localStreams}),!("addStream"in v.RTCPeerConnection.prototype)){var C=v.RTCPeerConnection.prototype.addTrack;v.RTCPeerConnection.prototype.addStream=function(O){var N=this;this._localStreams||(this._localStreams=[]),this._localStreams.includes(O)||this._localStreams.push(O),O.getAudioTracks().forEach(function(j){return C.call(N,j,O)}),O.getVideoTracks().forEach(function(j){return C.call(N,j,O)})},v.RTCPeerConnection.prototype.addTrack=function(O){for(var N=this,j=arguments.length,_=new Array(j>1?j-1:0),b=1;b<j;b++)_[b-1]=arguments[b];return _&&_.forEach(function(R){N._localStreams?N._localStreams.includes(R)||N._localStreams.push(R):N._localStreams=[R]}),C.apply(this,arguments)}}"removeStream"in v.RTCPeerConnection.prototype||(v.RTCPeerConnection.prototype.removeStream=function(O){var N=this;this._localStreams||(this._localStreams=[]);var j=this._localStreams.indexOf(O);if(j!==-1){this._localStreams.splice(j,1);var _=O.getTracks();this.getSenders().forEach(function(b){_.includes(b.track)&&N.removeTrack(b)})}})}}function u(v){if(s(v)==="object"&&v.RTCPeerConnection&&("getRemoteStreams"in v.RTCPeerConnection.prototype||(v.RTCPeerConnection.prototype.getRemoteStreams=function(){return this._remoteStreams?this._remoteStreams:[]}),!("onaddstream"in v.RTCPeerConnection.prototype))){Object.defineProperty(v.RTCPeerConnection.prototype,"onaddstream",{get:function(){return this._onaddstream},set:function(O){var N=this;this._onaddstream&&(this.removeEventListener("addstream",this._onaddstream),this.removeEventListener("track",this._onaddstreampoly)),this.addEventListener("addstream",this._onaddstream=O),this.addEventListener("track",this._onaddstreampoly=function(j){j.streams.forEach(function(_){if(N._remoteStreams||(N._remoteStreams=[]),!N._remoteStreams.includes(_)){N._remoteStreams.push(_);var b=new Event("addstream");b.stream=_,N.dispatchEvent(b)}})})}});var C=v.RTCPeerConnection.prototype.setRemoteDescription;v.RTCPeerConnection.prototype.setRemoteDescription=function(){var O=this;return this._onaddstreampoly||this.addEventListener("track",this._onaddstreampoly=function(N){N.streams.forEach(function(j){if(O._remoteStreams||(O._remoteStreams=[]),!(O._remoteStreams.indexOf(j)>=0)){O._remoteStreams.push(j);var _=new Event("addstream");_.stream=j,O.dispatchEvent(_)}})}),C.apply(O,arguments)}}}function p(v){if(s(v)==="object"&&v.RTCPeerConnection){var C=v.RTCPeerConnection.prototype,O=C.createOffer,N=C.createAnswer,j=C.setLocalDescription,_=C.setRemoteDescription,b=C.addIceCandidate;C.createOffer=function(P,V){var S=arguments.length>=2?arguments[2]:arguments[0],h=O.apply(this,[S]);return V?(h.then(P,V),Promise.resolve()):h},C.createAnswer=function(P,V){var S=arguments.length>=2?arguments[2]:arguments[0],h=N.apply(this,[S]);return V?(h.then(P,V),Promise.resolve()):h};var R=function(P,V,S){var h=j.apply(this,[P]);return S?(h.then(V,S),Promise.resolve()):h};C.setLocalDescription=R,R=function(P,V,S){var h=_.apply(this,[P]);return S?(h.then(V,S),Promise.resolve()):h},C.setRemoteDescription=R,R=function(P,V,S){var h=b.apply(this,[P]);return S?(h.then(V,S),Promise.resolve()):h},C.addIceCandidate=R}}function k(v){var C=v&&v.navigator;if(C.mediaDevices&&C.mediaDevices.getUserMedia){var O=C.mediaDevices,N=O.getUserMedia.bind(O);C.mediaDevices.getUserMedia=function(j){return N(x(j))}}!C.getUserMedia&&C.mediaDevices&&C.mediaDevices.getUserMedia&&(C.getUserMedia=function(j,_,b){C.mediaDevices.getUserMedia(j).then(_,b)}.bind(C))}function x(v){return v&&v.video!==void 0?Object.assign({},v,{video:o.compactObject(v.video)}):v}function E(v){if(v.RTCPeerConnection){var C=v.RTCPeerConnection;v.RTCPeerConnection=function(O,N){if(O&&O.iceServers){for(var j=[],_=0;_<O.iceServers.length;_++){var b=O.iceServers[_];b.urls===void 0&&b.url?(o.deprecated("RTCIceServer.url","RTCIceServer.urls"),(b=JSON.parse(JSON.stringify(b))).urls=b.url,delete b.url,j.push(b)):j.push(O.iceServers[_])}O.iceServers=j}return new C(O,N)},v.RTCPeerConnection.prototype=C.prototype,"generateCertificate"in C&&Object.defineProperty(v.RTCPeerConnection,"generateCertificate",{get:function(){return C.generateCertificate}})}}function I(v){s(v)==="object"&&v.RTCTrackEvent&&"receiver"in v.RTCTrackEvent.prototype&&!("transceiver"in v.RTCTrackEvent.prototype)&&Object.defineProperty(v.RTCTrackEvent.prototype,"transceiver",{get:function(){return{receiver:this.receiver}}})}function m(v){var C=v.RTCPeerConnection.prototype.createOffer;v.RTCPeerConnection.prototype.createOffer=function(O){if(O){O.offerToReceiveAudio!==void 0&&(O.offerToReceiveAudio=!!O.offerToReceiveAudio);var N=this.getTransceivers().find(function(_){return _.receiver.track.kind==="audio"});O.offerToReceiveAudio===!1&&N?N.direction==="sendrecv"?N.setDirection?N.setDirection("sendonly"):N.direction="sendonly":N.direction==="recvonly"&&(N.setDirection?N.setDirection("inactive"):N.direction="inactive"):O.offerToReceiveAudio!==!0||N||this.addTransceiver("audio",{direction:"recvonly"}),O.offerToReceiveVideo!==void 0&&(O.offerToReceiveVideo=!!O.offerToReceiveVideo);var j=this.getTransceivers().find(function(_){return _.receiver.track.kind==="video"});O.offerToReceiveVideo===!1&&j?j.direction==="sendrecv"?j.setDirection?j.setDirection("sendonly"):j.direction="sendonly":j.direction==="recvonly"&&(j.setDirection?j.setDirection("inactive"):j.direction="inactive"):O.offerToReceiveVideo!==!0||j||this.addTransceiver("video",{direction:"recvonly"})}return C.apply(this,arguments)}}function T(v){s(v)!=="object"||v.AudioContext||(v.AudioContext=v.webkitAudioContext)}},{"../utils":11}],11:[function(n,i,r){function o(j,_,b){return(_=c(_))in j?Object.defineProperty(j,_,{value:b,enumerable:!0,configurable:!0,writable:!0}):j[_]=b,j}function c(j){var _=a(j,"string");return s(_)==="symbol"?_:String(_)}function a(j,_){if(s(j)!=="object"||j===null)return j;var b=j[Symbol.toPrimitive];if(b!==void 0){var R=b.call(j,_||"default");if(s(R)!=="object")return R;throw new TypeError("@@toPrimitive must return a primitive value.")}return(_==="string"?String:Number)(j)}function s(j){return s=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(_){return typeof _}:function(_){return _&&typeof Symbol=="function"&&_.constructor===Symbol&&_!==Symbol.prototype?"symbol":typeof _},s(j)}Object.defineProperty(r,"__esModule",{value:!0}),r.compactObject=C,r.deprecated=m,r.detectBrowser=T,r.disableLog=x,r.disableWarnings=E,r.extractVersion=p,r.filterStats=N,r.log=I,r.walkStats=O,r.wrapPeerConnectionEvent=k;var l=!0,u=!0;function p(j,_,b){var R=j.match(_);return R&&R.length>=b&&parseInt(R[b],10)}function k(j,_,b){if(j.RTCPeerConnection){var R=j.RTCPeerConnection.prototype,P=R.addEventListener;R.addEventListener=function(S,h){if(S!==_)return P.apply(this,arguments);var y=function(A){var D=b(A);D&&(h.handleEvent?h.handleEvent(D):h(D))};return this._eventMap=this._eventMap||{},this._eventMap[_]||(this._eventMap[_]=new Map),this._eventMap[_].set(h,y),P.apply(this,[S,y])};var V=R.removeEventListener;R.removeEventListener=function(S,h){if(S!==_||!this._eventMap||!this._eventMap[_])return V.apply(this,arguments);if(!this._eventMap[_].has(h))return V.apply(this,arguments);var y=this._eventMap[_].get(h);return this._eventMap[_].delete(h),this._eventMap[_].size===0&&delete this._eventMap[_],Object.keys(this._eventMap).length===0&&delete this._eventMap,V.apply(this,[S,y])},Object.defineProperty(R,"on"+_,{get:function(){return this["_on"+_]},set:function(S){this["_on"+_]&&(this.removeEventListener(_,this["_on"+_]),delete this["_on"+_]),S&&this.addEventListener(_,this["_on"+_]=S)},enumerable:!0,configurable:!0})}}function x(j){return typeof j!="boolean"?new Error("Argument type: "+s(j)+". Please use a boolean."):(l=j,j?"adapter.js logging disabled":"adapter.js logging enabled")}function E(j){return typeof j!="boolean"?new Error("Argument type: "+s(j)+". Please use a boolean."):(u=!j,"adapter.js deprecation warnings "+(j?"disabled":"enabled"))}function I(){if((typeof window=="undefined"?"undefined":s(window))==="object"){if(l)return;typeof console!="undefined"&&typeof console.log=="function"&&console.log.apply(console,arguments)}}function m(j,_){u&&console.warn(j+" is deprecated, please use "+_+" instead.")}function T(j){var _={browser:null,version:null};if(j===void 0||!j.navigator||!j.navigator.userAgent)return _.browser="Not a browser.",_;var b=j.navigator;if(b.mozGetUserMedia)_.browser="firefox",_.version=p(b.userAgent,/Firefox\/(\d+)\./,1);else if(b.webkitGetUserMedia||j.isSecureContext===!1&&j.webkitRTCPeerConnection)_.browser="chrome",_.version=p(b.userAgent,/Chrom(e|ium)\/(\d+)\./,2);else{if(!j.RTCPeerConnection||!b.userAgent.match(/AppleWebKit\/(\d+)\./))return _.browser="Not a supported browser.",_;_.browser="safari",_.version=p(b.userAgent,/AppleWebKit\/(\d+)\./,1),_.supportsUnifiedPlan=j.RTCRtpTransceiver&&"currentDirection"in j.RTCRtpTransceiver.prototype}return _}function v(j){return Object.prototype.toString.call(j)==="[object Object]"}function C(j){return v(j)?Object.keys(j).reduce(function(_,b){var R=v(j[b]),P=R?C(j[b]):j[b],V=R&&!Object.keys(P).length;return P===void 0||V?_:Object.assign(_,o({},b,P))},{}):j}function O(j,_,b){_&&!b.has(_.id)&&(b.set(_.id,_),Object.keys(_).forEach(function(R){R.endsWith("Id")?O(j,j.get(_[R]),b):R.endsWith("Ids")&&_[R].forEach(function(P){O(j,j.get(P),b)})}))}function N(j,_,b){var R=b?"outbound-rtp":"inbound-rtp",P=new Map;if(_===null)return P;var V=[];return j.forEach(function(S){S.type==="track"&&S.trackIdentifier===_.id&&V.push(S)}),V.forEach(function(S){j.forEach(function(h){h.type===R&&h.trackId===S.id&&O(j,h,P)})}),P}},{}],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(`
9
+ `).map(function(s){return s.trim()})},c.splitSections=function(a){return a.split(`
10
+ m=`).map(function(s,l){return(l>0?"m="+s:s).trim()+`\r
11
+ `})},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
12
+ `},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
13
+ `},c.parseFmtp=function(a){for(var s={},l=void 0,u=a.substring(a.indexOf(" ")+1).split(";"),p=0;p<u.length;p++)s[(l=u[p].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(p){a.parameters[p]!==void 0?u.push(p+"="+a.parameters[p]):u.push(p)}),s+="a=fmtp:"+l+" "+u.join(";")+`\r
14
+ `}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
15
+ `}),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
16
+ `;return a.fingerprints.forEach(function(u){l+="a=fingerprint:"+u.algorithm+" "+u.value+`\r
17
+ `}),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
18
+ `},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
19
+ a=ice-pwd:`+a.password+`\r
20
+ `;return a.iceLite&&(s+=`a=ice-lite\r
21
+ `),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 p=l[u],k=c.matchPrefix(a,"a=rtpmap:"+p+" ")[0];if(k){var x=c.parseRtpMap(k),E=c.matchPrefix(a,"a=fmtp:"+p+" ");switch(x.parameters=E.length?c.parseFmtp(E[0]):{},x.rtcpFeedback=c.matchPrefix(a,"a=rtcp-fb:"+p+" ").map(c.parseRtcpFb),s.codecs.push(x),x.name.toUpperCase()){case"RED":case"ULPFEC":s.fecMechanisms.push(x.name.toUpperCase())}}}c.matchPrefix(a,"a=extmap:").forEach(function(m){s.headerExtensions.push(c.parseExtmap(m))});var I=c.matchPrefix(a,"a=rtcp-fb:* ").map(c.parseRtcpFb);return s.codecs.forEach(function(m){I.forEach(function(T){m.rtcpFeedback.find(function(v){return v.type===T.type&&v.parameter===T.parameter})||m.rtcpFeedback.push(T)})}),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(p){return p.preferredPayloadType!==void 0?p.preferredPayloadType:p.payloadType}).join(" ")+`\r
22
+ `,l+=`c=IN IP4 0.0.0.0\r
23
+ `,l+=`a=rtcp:9 IN IP4 0.0.0.0\r
24
+ `,s.codecs.forEach(function(p){l+=c.writeRtpMap(p),l+=c.writeFmtp(p),l+=c.writeRtcpFb(p)});var u=0;return s.codecs.forEach(function(p){p.maxptime>u&&(u=p.maxptime)}),u>0&&(l+="a=maxptime:"+u+`\r
25
+ `),s.headerExtensions&&s.headerExtensions.forEach(function(p){l+=c.writeExtmap(p)}),l},c.parseRtpEncodingParameters=function(a){var s=[],l=c.parseRtpParameters(a),u=l.fecMechanisms.indexOf("RED")!==-1,p=l.fecMechanisms.indexOf("ULPFEC")!==-1,k=c.matchPrefix(a,"a=ssrc:").map(function(T){return c.parseSsrcMedia(T)}).filter(function(T){return T.attribute==="cname"}),x=k.length>0&&k[0].ssrc,E=void 0,I=c.matchPrefix(a,"a=ssrc-group:FID").map(function(T){return T.substring(17).split(" ").map(function(v){return parseInt(v,10)})});I.length>0&&I[0].length>1&&I[0][0]===x&&(E=I[0][1]),l.codecs.forEach(function(T){if(T.name.toUpperCase()==="RTX"&&T.parameters.apt){var v={ssrc:x,codecPayloadType:parseInt(T.parameters.apt,10)};x&&E&&(v.rtx={ssrc:E}),s.push(v),u&&((v=JSON.parse(JSON.stringify(v))).fec={ssrc:x,mechanism:p?"red+ulpfec":"red"},s.push(v))}}),s.length===0&&x&&s.push({ssrc:x});var m=c.matchPrefix(a,"b=");return m.length&&(m=m[0].indexOf("b=TIAS:")===0?parseInt(m[0].substring(7),10):m[0].indexOf("b=AS:")===0?1e3*parseInt(m[0].substring(5),10)*.95-16e3:void 0,s.forEach(function(T){T.maxBitrate=m})),s},c.parseRtcpParameters=function(a){var s={},l=c.matchPrefix(a,"a=ssrc:").map(function(k){return c.parseSsrcMedia(k)}).filter(function(k){return k.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 p=c.matchPrefix(a,"a=rtcp-mux");return s.mux=p.length>0,s},c.writeRtcpParameters=function(a){var s="";return a.reducedSize&&(s+=`a=rtcp-rsize\r
26
+ `),a.mux&&(s+=`a=rtcp-mux\r
27
+ `),a.ssrc!==void 0&&a.cname&&(s+="a=ssrc:"+a.ssrc+" cname:"+a.cname+`\r
28
+ `),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(p){return c.parseSsrcMedia(p)}).filter(function(p){return p.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 p=c.matchPrefix(a,"a=sctp-port:");if(p.length>0)return{port:parseInt(p[0].substring(12),10),protocol:s.fmt,maxMessageSize:u};var k=c.matchPrefix(a,"a=sctpmap:");if(k.length>0){var x=k[0].substring(10).split(" ");return{port:parseInt(x[0],10),protocol:x[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
22
29
  `,`c=IN IP4 0.0.0.0\r
23
- `,"a=sctp-port:"+r.port+`\r
24
- `]:["m="+n.kind+" 9 "+n.protocol+" "+r.port+`\r
30
+ `,"a=sctp-port:"+s.port+`\r
31
+ `]:["m="+a.kind+" 9 "+a.protocol+" "+s.port+`\r
25
32
  `,`c=IN IP4 0.0.0.0\r
26
- `,"a=sctpmap:"+r.port+" "+r.protocol+` 65535\r
27
- `],r.maxMessageSize!==void 0&&i.push("a=max-message-size:"+r.maxMessageSize+`\r
28
- `),i.join("")},t.generateSessionId=function(){return Math.random().toString().substr(2,21)},t.writeSessionBoilerplate=function(n,r,i){var o=r!==void 0?r:2;return`v=0\r
29
- o=`+(i||"thisisadapterortc")+" "+(n||t.generateSessionId())+" "+o+` IN IP4 127.0.0.1\r
33
+ `,"a=sctpmap:"+s.port+" "+s.protocol+` 65535\r
34
+ `],s.maxMessageSize!==void 0&&l.push("a=max-message-size:"+s.maxMessageSize+`\r
35
+ `),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
36
+ o=`+(l||"thisisadapterortc")+" "+(a||c.generateSessionId())+" "+u+` IN IP4 127.0.0.1\r
30
37
  s=-\r
31
38
  t=0 0\r
32
- `},t.writeMediaSection=function(n,r,i,o){var a=t.writeRtpDescription(n.kind,r);if(a+=t.writeIceParameters(n.iceGatherer.getLocalParameters()),a+=t.writeDtlsParameters(n.dtlsTransport.getLocalParameters(),i==="offer"?"actpass":"active"),a+="a=mid:"+n.mid+`\r
33
- `,n.direction?a+="a="+n.direction+`\r
34
- `:n.rtpSender&&n.rtpReceiver?a+=`a=sendrecv\r
35
- `:n.rtpSender?a+=`a=sendonly\r
36
- `:n.rtpReceiver?a+=`a=recvonly\r
37
- `:a+=`a=inactive\r
38
- `,n.rtpSender){var s="msid:"+o.id+" "+n.rtpSender.track.id+`\r
39
- `;a+="a="+s,a+="a=ssrc:"+n.sendEncodingParameters[0].ssrc+" "+s,n.sendEncodingParameters[0].rtx&&(a+="a=ssrc:"+n.sendEncodingParameters[0].rtx.ssrc+" "+s,a+="a=ssrc-group:FID "+n.sendEncodingParameters[0].ssrc+" "+n.sendEncodingParameters[0].rtx.ssrc+`\r
40
- `)}return a+="a=ssrc:"+n.sendEncodingParameters[0].ssrc+" cname:"+t.localCName+`\r
41
- `,n.rtpSender&&n.sendEncodingParameters[0].rtx&&(a+="a=ssrc:"+n.sendEncodingParameters[0].rtx.ssrc+" cname:"+t.localCName+`\r
42
- `),a},t.getDirection=function(n,r){for(var i=t.splitLines(n),o=0;o<i.length;o++)switch(i[o]){case"a=sendrecv":case"a=sendonly":case"a=recvonly":case"a=inactive":return i[o].substr(2)}return r?t.getDirection(r):"sendrecv"},t.getKind=function(n){return t.splitLines(n)[0].split(" ")[0].substr(2)},t.isRejected=function(n){return n.split(" ",2)[1]==="0"},t.parseMLine=function(n){var r=t.splitLines(n)[0].substr(2).split(" ");return{kind:r[0],port:parseInt(r[1],10),protocol:r[2],fmt:r.slice(3).join(" ")}},t.parseOLine=function(n){var r=t.matchPrefix(n,"o=")[0].substr(2).split(" ");return{username:r[0],sessionId:r[1],sessionVersion:parseInt(r[2],10),netType:r[3],addressType:r[4],address:r[5]}},t.isValidSDP=function(n){if(typeof n!="string"||n.length===0)return!1;for(var r=t.splitLines(n),i=0;i<r.length;i++)if(r[i].length<2||r[i].charAt(1)!=="=")return!1;return!0},e.exports=t})(nh);var uu=nh.exports,Fe=nh.exports;function Kg(e,t,n,r,i){var o=Fe.writeRtpDescription(e.kind,t);if(o+=Fe.writeIceParameters(e.iceGatherer.getLocalParameters()),o+=Fe.writeDtlsParameters(e.dtlsTransport.getLocalParameters(),n==="offer"?"actpass":i||"active"),o+="a=mid:"+e.mid+`\r
43
- `,e.rtpSender&&e.rtpReceiver?o+=`a=sendrecv\r
44
- `:e.rtpSender?o+=`a=sendonly\r
45
- `:e.rtpReceiver?o+=`a=recvonly\r
46
- `:o+=`a=inactive\r
47
- `,e.rtpSender){var a=e.rtpSender._initialTrackId||e.rtpSender.track.id;e.rtpSender._initialTrackId=a;var s="msid:"+(r?r.id:"-")+" "+a+`\r
48
- `;o+="a="+s,o+="a=ssrc:"+e.sendEncodingParameters[0].ssrc+" "+s,e.sendEncodingParameters[0].rtx&&(o+="a=ssrc:"+e.sendEncodingParameters[0].rtx.ssrc+" "+s,o+="a=ssrc-group:FID "+e.sendEncodingParameters[0].ssrc+" "+e.sendEncodingParameters[0].rtx.ssrc+`\r
49
- `)}return o+="a=ssrc:"+e.sendEncodingParameters[0].ssrc+" cname:"+Fe.localCName+`\r
50
- `,e.rtpSender&&e.sendEncodingParameters[0].rtx&&(o+="a=ssrc:"+e.sendEncodingParameters[0].rtx.ssrc+" cname:"+Fe.localCName+`\r
51
- `),o}function lu(e,t){var n={codecs:[],headerExtensions:[],fecMechanisms:[]},r=function(o,a){o=parseInt(o,10);for(var s=0;s<a.length;s++)if(a[s].payloadType===o||a[s].preferredPayloadType===o)return a[s]},i=function(o,a,s,c){var u=r(o.parameters.apt,s),d=r(a.parameters.apt,c);return u&&d&&u.name.toLowerCase()===d.name.toLowerCase()};return e.codecs.forEach(function(o){for(var a=0;a<t.codecs.length;a++){var s=t.codecs[a];if(o.name.toLowerCase()===s.name.toLowerCase()&&o.clockRate===s.clockRate){if(o.name.toLowerCase()==="rtx"&&o.parameters&&s.parameters.apt&&!i(o,s,e.codecs,t.codecs))continue;(s=JSON.parse(JSON.stringify(s))).numChannels=Math.min(o.numChannels,s.numChannels),n.codecs.push(s),s.rtcpFeedback=s.rtcpFeedback.filter(function(c){for(var u=0;u<o.rtcpFeedback.length;u++)if(o.rtcpFeedback[u].type===c.type&&o.rtcpFeedback[u].parameter===c.parameter)return!0;return!1});break}}}),e.headerExtensions.forEach(function(o){for(var a=0;a<t.headerExtensions.length;a++){var s=t.headerExtensions[a];if(o.uri===s.uri){n.headerExtensions.push(s);break}}}),n}function qg(e,t,n){return{offer:{setLocalDescription:["stable","have-local-offer"],setRemoteDescription:["stable","have-remote-offer"]},answer:{setLocalDescription:["have-remote-offer","have-local-pranswer"],setRemoteDescription:["have-local-offer","have-remote-pranswer"]}}[t][e].indexOf(n)!==-1}function rh(e,t){var n=e.getRemoteCandidates().find(function(r){return t.foundation===r.foundation&&t.ip===r.ip&&t.port===r.port&&t.priority===r.priority&&t.protocol===r.protocol&&t.type===r.type});return n||e.addRemoteCandidate(t),!n}function tn(e,t){var n=new Error(t);return n.name=e,n.code={NotSupportedError:9,InvalidStateError:11,InvalidAccessError:15,TypeError:void 0,OperationError:void 0}[e],n}var dC=function(e,t){function n(a,s){s.addTrack(a),s.dispatchEvent(new e.MediaStreamTrackEvent("addtrack",{track:a}))}function r(a,s,c,u){var d=new Event("track");d.track=s,d.receiver=c,d.transceiver={receiver:c},d.streams=u,e.setTimeout(function(){a._dispatchEvent("track",d)})}var i=function(a){var s=this,c=document.createDocumentFragment();if(["addEventListener","removeEventListener","dispatchEvent"].forEach(function(d){s[d]=c[d].bind(c)}),this.canTrickleIceCandidates=null,this.needNegotiation=!1,this.localStreams=[],this.remoteStreams=[],this._localDescription=null,this._remoteDescription=null,this.signalingState="stable",this.iceConnectionState="new",this.connectionState="new",this.iceGatheringState="new",a=JSON.parse(JSON.stringify(a||{})),this.usingBundle=a.bundlePolicy==="max-bundle",a.rtcpMuxPolicy==="negotiate")throw tn("NotSupportedError","rtcpMuxPolicy 'negotiate' is not supported");switch(a.rtcpMuxPolicy||(a.rtcpMuxPolicy="require"),a.iceTransportPolicy){case"all":case"relay":break;default:a.iceTransportPolicy="all"}switch(a.bundlePolicy){case"balanced":case"max-compat":case"max-bundle":break;default:a.bundlePolicy="balanced"}if(a.iceServers=function(d,h){var _=!1;return(d=JSON.parse(JSON.stringify(d))).filter(function(y){if(y&&(y.urls||y.url)){var b=y.urls||y.url;y.url&&!y.urls&&console.warn("RTCIceServer.url is deprecated! Use urls instead.");var f=typeof b=="string";return f&&(b=[b]),b=b.filter(function(g){return g.indexOf("turn:")!==0||g.indexOf("transport=udp")===-1||g.indexOf("turn:[")!==-1||_?g.indexOf("stun:")===0&&h>=14393&&g.indexOf("?transport=udp")===-1:(_=!0,!0)}),delete y.url,y.urls=f?b[0]:b,!!b.length}})}(a.iceServers||[],t),this._iceGatherers=[],a.iceCandidatePoolSize)for(var u=a.iceCandidatePoolSize;u>0;u--)this._iceGatherers.push(new e.RTCIceGatherer({iceServers:a.iceServers,gatherPolicy:a.iceTransportPolicy}));else a.iceCandidatePoolSize=0;this._config=a,this.transceivers=[],this._sdpSessionId=Fe.generateSessionId(),this._sdpSessionVersion=0,this._dtlsRole=void 0,this._isClosed=!1};Object.defineProperty(i.prototype,"localDescription",{configurable:!0,get:function(){return this._localDescription}}),Object.defineProperty(i.prototype,"remoteDescription",{configurable:!0,get:function(){return this._remoteDescription}}),i.prototype.onicecandidate=null,i.prototype.onaddstream=null,i.prototype.ontrack=null,i.prototype.onremovestream=null,i.prototype.onsignalingstatechange=null,i.prototype.oniceconnectionstatechange=null,i.prototype.onconnectionstatechange=null,i.prototype.onicegatheringstatechange=null,i.prototype.onnegotiationneeded=null,i.prototype.ondatachannel=null,i.prototype._dispatchEvent=function(a,s){this._isClosed||(this.dispatchEvent(s),typeof this["on"+a]=="function"&&this["on"+a](s))},i.prototype._emitGatheringStateChange=function(){var a=new Event("icegatheringstatechange");this._dispatchEvent("icegatheringstatechange",a)},i.prototype.getConfiguration=function(){return this._config},i.prototype.getLocalStreams=function(){return this.localStreams},i.prototype.getRemoteStreams=function(){return this.remoteStreams},i.prototype._createTransceiver=function(a,s){var c=this.transceivers.length>0,u={track:null,iceGatherer:null,iceTransport:null,dtlsTransport:null,localCapabilities:null,remoteCapabilities:null,rtpSender:null,rtpReceiver:null,kind:a,mid:null,sendEncodingParameters:null,recvEncodingParameters:null,stream:null,associatedRemoteMediaStreams:[],wantReceive:!0};if(this.usingBundle&&c)u.iceTransport=this.transceivers[0].iceTransport,u.dtlsTransport=this.transceivers[0].dtlsTransport;else{var d=this._createIceAndDtlsTransports();u.iceTransport=d.iceTransport,u.dtlsTransport=d.dtlsTransport}return s||this.transceivers.push(u),u},i.prototype.addTrack=function(a,s){if(this._isClosed)throw tn("InvalidStateError","Attempted to call addTrack on a closed peerconnection.");var c;if(this.transceivers.find(function(d){return d.track===a}))throw tn("InvalidAccessError","Track already exists.");for(var u=0;u<this.transceivers.length;u++)this.transceivers[u].track||this.transceivers[u].kind!==a.kind||(c=this.transceivers[u]);return c||(c=this._createTransceiver(a.kind)),this._maybeFireNegotiationNeeded(),this.localStreams.indexOf(s)===-1&&this.localStreams.push(s),c.track=a,c.stream=s,c.rtpSender=new e.RTCRtpSender(a,c.dtlsTransport),c.rtpSender},i.prototype.addStream=function(a){var s=this;if(t>=15025)a.getTracks().forEach(function(u){s.addTrack(u,a)});else{var c=a.clone();a.getTracks().forEach(function(u,d){var h=c.getTracks()[d];u.addEventListener("enabled",function(_){h.enabled=_.enabled})}),c.getTracks().forEach(function(u){s.addTrack(u,c)})}},i.prototype.removeTrack=function(a){if(this._isClosed)throw tn("InvalidStateError","Attempted to call removeTrack on a closed peerconnection.");if(!(a instanceof e.RTCRtpSender))throw new TypeError("Argument 1 of RTCPeerConnection.removeTrack does not implement interface RTCRtpSender.");var s=this.transceivers.find(function(u){return u.rtpSender===a});if(!s)throw tn("InvalidAccessError","Sender was not created by this connection.");var c=s.stream;s.rtpSender.stop(),s.rtpSender=null,s.track=null,s.stream=null,this.transceivers.map(function(u){return u.stream}).indexOf(c)===-1&&this.localStreams.indexOf(c)>-1&&this.localStreams.splice(this.localStreams.indexOf(c),1),this._maybeFireNegotiationNeeded()},i.prototype.removeStream=function(a){var s=this;a.getTracks().forEach(function(c){var u=s.getSenders().find(function(d){return d.track===c});u&&s.removeTrack(u)})},i.prototype.getSenders=function(){return this.transceivers.filter(function(a){return!!a.rtpSender}).map(function(a){return a.rtpSender})},i.prototype.getReceivers=function(){return this.transceivers.filter(function(a){return!!a.rtpReceiver}).map(function(a){return a.rtpReceiver})},i.prototype._createIceGatherer=function(a,s){var c=this;if(s&&a>0)return this.transceivers[0].iceGatherer;if(this._iceGatherers.length)return this._iceGatherers.shift();var u=new e.RTCIceGatherer({iceServers:this._config.iceServers,gatherPolicy:this._config.iceTransportPolicy});return Object.defineProperty(u,"state",{value:"new",writable:!0}),this.transceivers[a].bufferedCandidateEvents=[],this.transceivers[a].bufferCandidates=function(d){var h=!d.candidate||Object.keys(d.candidate).length===0;u.state=h?"completed":"gathering",c.transceivers[a].bufferedCandidateEvents!==null&&c.transceivers[a].bufferedCandidateEvents.push(d)},u.addEventListener("localcandidate",this.transceivers[a].bufferCandidates),u},i.prototype._gather=function(a,s){var c=this,u=this.transceivers[s].iceGatherer;if(!u.onlocalcandidate){var d=this.transceivers[s].bufferedCandidateEvents;this.transceivers[s].bufferedCandidateEvents=null,u.removeEventListener("localcandidate",this.transceivers[s].bufferCandidates),u.onlocalcandidate=function(h){if(!(c.usingBundle&&s>0)){var _=new Event("icecandidate");_.candidate={sdpMid:a,sdpMLineIndex:s};var y=h.candidate,b=!y||Object.keys(y).length===0;if(b)u.state!=="new"&&u.state!=="gathering"||(u.state="completed");else{u.state==="new"&&(u.state="gathering"),y.component=1,y.ufrag=u.getLocalParameters().usernameFragment;var f=Fe.writeCandidate(y);_.candidate=Object.assign(_.candidate,Fe.parseCandidate(f)),_.candidate.candidate=f,_.candidate.toJSON=function(){return{candidate:_.candidate.candidate,sdpMid:_.candidate.sdpMid,sdpMLineIndex:_.candidate.sdpMLineIndex,usernameFragment:_.candidate.usernameFragment}}}var g=Fe.getMediaSections(c._localDescription.sdp);g[_.candidate.sdpMLineIndex]+=b?`a=end-of-candidates\r
52
- `:"a="+_.candidate.candidate+`\r
53
- `,c._localDescription.sdp=Fe.getDescription(c._localDescription.sdp)+g.join("");var I=c.transceivers.every(function(w){return w.iceGatherer&&w.iceGatherer.state==="completed"});c.iceGatheringState!=="gathering"&&(c.iceGatheringState="gathering",c._emitGatheringStateChange()),b||c._dispatchEvent("icecandidate",_),I&&(c._dispatchEvent("icecandidate",new Event("icecandidate")),c.iceGatheringState="complete",c._emitGatheringStateChange())}},e.setTimeout(function(){d.forEach(function(h){u.onlocalcandidate(h)})},0)}},i.prototype._createIceAndDtlsTransports=function(){var a=this,s=new e.RTCIceTransport(null);s.onicestatechange=function(){a._updateIceConnectionState(),a._updateConnectionState()};var c=new e.RTCDtlsTransport(s);return c.ondtlsstatechange=function(){a._updateConnectionState()},c.onerror=function(){Object.defineProperty(c,"state",{value:"failed",writable:!0}),a._updateConnectionState()},{iceTransport:s,dtlsTransport:c}},i.prototype._disposeIceAndDtlsTransports=function(a){var s=this.transceivers[a].iceGatherer;s&&(delete s.onlocalcandidate,delete this.transceivers[a].iceGatherer);var c=this.transceivers[a].iceTransport;c&&(delete c.onicestatechange,delete this.transceivers[a].iceTransport);var u=this.transceivers[a].dtlsTransport;u&&(delete u.ondtlsstatechange,delete u.onerror,delete this.transceivers[a].dtlsTransport)},i.prototype._transceive=function(a,s,c){var u=lu(a.localCapabilities,a.remoteCapabilities);s&&a.rtpSender&&(u.encodings=a.sendEncodingParameters,u.rtcp={cname:Fe.localCName,compound:a.rtcpParameters.compound},a.recvEncodingParameters.length&&(u.rtcp.ssrc=a.recvEncodingParameters[0].ssrc),a.rtpSender.send(u)),c&&a.rtpReceiver&&u.codecs.length>0&&(a.kind==="video"&&a.recvEncodingParameters&&t<15019&&a.recvEncodingParameters.forEach(function(d){delete d.rtx}),a.recvEncodingParameters.length?u.encodings=a.recvEncodingParameters:u.encodings=[{}],u.rtcp={compound:a.rtcpParameters.compound},a.rtcpParameters.cname&&(u.rtcp.cname=a.rtcpParameters.cname),a.sendEncodingParameters.length&&(u.rtcp.ssrc=a.sendEncodingParameters[0].ssrc),a.rtpReceiver.receive(u))},i.prototype.setLocalDescription=function(a){var s,c,u=this;if(["offer","answer"].indexOf(a.type)===-1)return Promise.reject(tn("TypeError",'Unsupported type "'+a.type+'"'));if(!qg("setLocalDescription",a.type,u.signalingState)||u._isClosed)return Promise.reject(tn("InvalidStateError","Can not set local "+a.type+" in state "+u.signalingState));if(a.type==="offer")s=Fe.splitSections(a.sdp),c=s.shift(),s.forEach(function(h,_){var y=Fe.parseRtpParameters(h);u.transceivers[_].localCapabilities=y}),u.transceivers.forEach(function(h,_){u._gather(h.mid,_)});else if(a.type==="answer"){s=Fe.splitSections(u._remoteDescription.sdp),c=s.shift();var d=Fe.matchPrefix(c,"a=ice-lite").length>0;s.forEach(function(h,_){var y=u.transceivers[_],b=y.iceGatherer,f=y.iceTransport,g=y.dtlsTransport,I=y.localCapabilities,w=y.remoteCapabilities;if(!(Fe.isRejected(h)&&Fe.matchPrefix(h,"a=bundle-only").length===0)&&!y.rejected){var j=Fe.getIceParameters(h,c),z=Fe.getDtlsParameters(h,c);d&&(z.role="server"),u.usingBundle&&_!==0||(u._gather(y.mid,_),f.state==="new"&&f.start(b,j,d?"controlling":"controlled"),g.state==="new"&&g.start(z));var $=lu(I,w);u._transceive(y,$.codecs.length>0,!1)}})}return u._localDescription={type:a.type,sdp:a.sdp},a.type==="offer"?u._updateSignalingState("have-local-offer"):u._updateSignalingState("stable"),Promise.resolve()},i.prototype.setRemoteDescription=function(a){var s=this;if(["offer","answer"].indexOf(a.type)===-1)return Promise.reject(tn("TypeError",'Unsupported type "'+a.type+'"'));if(!qg("setRemoteDescription",a.type,s.signalingState)||s._isClosed)return Promise.reject(tn("InvalidStateError","Can not set remote "+a.type+" in state "+s.signalingState));var c={};s.remoteStreams.forEach(function(f){c[f.id]=f});var u=[],d=Fe.splitSections(a.sdp),h=d.shift(),_=Fe.matchPrefix(h,"a=ice-lite").length>0,y=Fe.matchPrefix(h,"a=group:BUNDLE ").length>0;s.usingBundle=y;var b=Fe.matchPrefix(h,"a=ice-options:")[0];return s.canTrickleIceCandidates=!!b&&b.substr(14).split(" ").indexOf("trickle")>=0,d.forEach(function(f,g){var I=Fe.splitLines(f),w=Fe.getKind(f),j=Fe.isRejected(f)&&Fe.matchPrefix(f,"a=bundle-only").length===0,z=I[0].substr(2).split(" ")[2],$=Fe.getDirection(f,h),ue=Fe.parseMsid(f),L=Fe.getMid(f)||Fe.generateIdentifier();if(j||w==="application"&&(z==="DTLS/SCTP"||z==="UDP/DTLS/SCTP"))s.transceivers[g]={mid:L,kind:w,protocol:z,rejected:!0};else{var k,P,A,U,T,v,E,C,O;!j&&s.transceivers[g]&&s.transceivers[g].rejected&&(s.transceivers[g]=s._createTransceiver(w,!0));var F,K,re=Fe.parseRtpParameters(f);j||(F=Fe.getIceParameters(f,h),(K=Fe.getDtlsParameters(f,h)).role="client"),E=Fe.parseRtpEncodingParameters(f);var ce=Fe.parseRtcpParameters(f),ge=Fe.matchPrefix(f,"a=end-of-candidates",h).length>0,Ye=Fe.matchPrefix(f,"a=candidate:").map(function(Ke){return Fe.parseCandidate(Ke)}).filter(function(Ke){return Ke.component===1});if((a.type==="offer"||a.type==="answer")&&!j&&y&&g>0&&s.transceivers[g]&&(s._disposeIceAndDtlsTransports(g),s.transceivers[g].iceGatherer=s.transceivers[0].iceGatherer,s.transceivers[g].iceTransport=s.transceivers[0].iceTransport,s.transceivers[g].dtlsTransport=s.transceivers[0].dtlsTransport,s.transceivers[g].rtpSender&&s.transceivers[g].rtpSender.setTransport(s.transceivers[0].dtlsTransport),s.transceivers[g].rtpReceiver&&s.transceivers[g].rtpReceiver.setTransport(s.transceivers[0].dtlsTransport)),a.type!=="offer"||j)a.type==="answer"&&!j&&(P=(k=s.transceivers[g]).iceGatherer,A=k.iceTransport,U=k.dtlsTransport,T=k.rtpReceiver,v=k.sendEncodingParameters,C=k.localCapabilities,s.transceivers[g].recvEncodingParameters=E,s.transceivers[g].remoteCapabilities=re,s.transceivers[g].rtcpParameters=ce,Ye.length&&A.state==="new"&&(!_&&!ge||y&&g!==0?Ye.forEach(function(Ke){rh(k.iceTransport,Ke)}):A.setRemoteCandidates(Ye)),y&&g!==0||(A.state==="new"&&A.start(P,F,"controlling"),U.state==="new"&&U.start(K)),!lu(k.localCapabilities,k.remoteCapabilities).codecs.filter(function(Ke){return Ke.name.toLowerCase()==="rtx"}).length&&k.sendEncodingParameters[0].rtx&&delete k.sendEncodingParameters[0].rtx,s._transceive(k,$==="sendrecv"||$==="recvonly",$==="sendrecv"||$==="sendonly"),!T||$!=="sendrecv"&&$!=="sendonly"?delete k.rtpReceiver:(O=T.track,ue?(c[ue.stream]||(c[ue.stream]=new e.MediaStream),n(O,c[ue.stream]),u.push([O,T,c[ue.stream]])):(c.default||(c.default=new e.MediaStream),n(O,c.default),u.push([O,T,c.default]))));else{(k=s.transceivers[g]||s._createTransceiver(w)).mid=L,k.iceGatherer||(k.iceGatherer=s._createIceGatherer(g,y)),Ye.length&&k.iceTransport.state==="new"&&(!ge||y&&g!==0?Ye.forEach(function(Ke){rh(k.iceTransport,Ke)}):k.iceTransport.setRemoteCandidates(Ye)),C=e.RTCRtpReceiver.getCapabilities(w),t<15019&&(C.codecs=C.codecs.filter(function(Ke){return Ke.name!=="rtx"})),v=k.sendEncodingParameters||[{ssrc:1001*(2*g+2)}];var Ve,Ge=!1;$==="sendrecv"||$==="sendonly"?(Ge=!k.rtpReceiver,T=k.rtpReceiver||new e.RTCRtpReceiver(k.dtlsTransport,w),Ge&&(O=T.track,ue&&ue.stream==="-"||(ue?(c[ue.stream]||(c[ue.stream]=new e.MediaStream,Object.defineProperty(c[ue.stream],"id",{get:function(){return ue.stream}})),Object.defineProperty(O,"id",{get:function(){return ue.track}}),Ve=c[ue.stream]):(c.default||(c.default=new e.MediaStream),Ve=c.default)),Ve&&(n(O,Ve),k.associatedRemoteMediaStreams.push(Ve)),u.push([O,T,Ve]))):k.rtpReceiver&&k.rtpReceiver.track&&(k.associatedRemoteMediaStreams.forEach(function(Ke){var He=Ke.getTracks().find(function(Cr){return Cr.id===k.rtpReceiver.track.id});He&&function(Cr,ma){ma.removeTrack(Cr),ma.dispatchEvent(new e.MediaStreamTrackEvent("removetrack",{track:Cr}))}(He,Ke)}),k.associatedRemoteMediaStreams=[]),k.localCapabilities=C,k.remoteCapabilities=re,k.rtpReceiver=T,k.rtcpParameters=ce,k.sendEncodingParameters=v,k.recvEncodingParameters=E,s._transceive(s.transceivers[g],!1,Ge)}}}),s._dtlsRole===void 0&&(s._dtlsRole=a.type==="offer"?"active":"passive"),s._remoteDescription={type:a.type,sdp:a.sdp},a.type==="offer"?s._updateSignalingState("have-remote-offer"):s._updateSignalingState("stable"),Object.keys(c).forEach(function(f){var g=c[f];if(g.getTracks().length){if(s.remoteStreams.indexOf(g)===-1){s.remoteStreams.push(g);var I=new Event("addstream");I.stream=g,e.setTimeout(function(){s._dispatchEvent("addstream",I)})}u.forEach(function(w){var j=w[0],z=w[1];g.id===w[2].id&&r(s,j,z,[g])})}}),u.forEach(function(f){f[2]||r(s,f[0],f[1],[])}),e.setTimeout(function(){s&&s.transceivers&&s.transceivers.forEach(function(f){f.iceTransport&&f.iceTransport.state==="new"&&f.iceTransport.getRemoteCandidates().length>0&&(console.warn("Timeout for addRemoteCandidate. Consider sending an end-of-candidates notification"),f.iceTransport.addRemoteCandidate({}))})},4e3),Promise.resolve()},i.prototype.close=function(){this.transceivers.forEach(function(a){a.iceTransport&&a.iceTransport.stop(),a.dtlsTransport&&a.dtlsTransport.stop(),a.rtpSender&&a.rtpSender.stop(),a.rtpReceiver&&a.rtpReceiver.stop()}),this._isClosed=!0,this._updateSignalingState("closed")},i.prototype._updateSignalingState=function(a){this.signalingState=a;var s=new Event("signalingstatechange");this._dispatchEvent("signalingstatechange",s)},i.prototype._maybeFireNegotiationNeeded=function(){var a=this;this.signalingState==="stable"&&this.needNegotiation!==!0&&(this.needNegotiation=!0,e.setTimeout(function(){if(a.needNegotiation){a.needNegotiation=!1;var s=new Event("negotiationneeded");a._dispatchEvent("negotiationneeded",s)}},0))},i.prototype._updateIceConnectionState=function(){var a,s={new:0,closed:0,checking:0,connected:0,completed:0,disconnected:0,failed:0};if(this.transceivers.forEach(function(u){u.iceTransport&&!u.rejected&&s[u.iceTransport.state]++}),a="new",s.failed>0?a="failed":s.checking>0?a="checking":s.disconnected>0?a="disconnected":s.new>0?a="new":s.connected>0?a="connected":s.completed>0&&(a="completed"),a!==this.iceConnectionState){this.iceConnectionState=a;var c=new Event("iceconnectionstatechange");this._dispatchEvent("iceconnectionstatechange",c)}},i.prototype._updateConnectionState=function(){var a,s={new:0,closed:0,connecting:0,connected:0,completed:0,disconnected:0,failed:0};if(this.transceivers.forEach(function(u){u.iceTransport&&u.dtlsTransport&&!u.rejected&&(s[u.iceTransport.state]++,s[u.dtlsTransport.state]++)}),s.connected+=s.completed,a="new",s.failed>0?a="failed":s.connecting>0?a="connecting":s.disconnected>0?a="disconnected":s.new>0?a="new":s.connected>0&&(a="connected"),a!==this.connectionState){this.connectionState=a;var c=new Event("connectionstatechange");this._dispatchEvent("connectionstatechange",c)}},i.prototype.createOffer=function(){var a=this;if(a._isClosed)return Promise.reject(tn("InvalidStateError","Can not call createOffer after close"));var s=a.transceivers.filter(function(_){return _.kind==="audio"}).length,c=a.transceivers.filter(function(_){return _.kind==="video"}).length,u=arguments[0];if(u){if(u.mandatory||u.optional)throw new TypeError("Legacy mandatory/optional constraints not supported.");u.offerToReceiveAudio!==void 0&&(s=u.offerToReceiveAudio===!0?1:u.offerToReceiveAudio===!1?0:u.offerToReceiveAudio),u.offerToReceiveVideo!==void 0&&(c=u.offerToReceiveVideo===!0?1:u.offerToReceiveVideo===!1?0:u.offerToReceiveVideo)}for(a.transceivers.forEach(function(_){_.kind==="audio"?--s<0&&(_.wantReceive=!1):_.kind==="video"&&--c<0&&(_.wantReceive=!1)});s>0||c>0;)s>0&&(a._createTransceiver("audio"),s--),c>0&&(a._createTransceiver("video"),c--);var d=Fe.writeSessionBoilerplate(a._sdpSessionId,a._sdpSessionVersion++);a.transceivers.forEach(function(_,y){var b=_.track,f=_.kind,g=_.mid||Fe.generateIdentifier();_.mid=g,_.iceGatherer||(_.iceGatherer=a._createIceGatherer(y,a.usingBundle));var I=e.RTCRtpSender.getCapabilities(f);t<15019&&(I.codecs=I.codecs.filter(function(j){return j.name!=="rtx"})),I.codecs.forEach(function(j){j.name==="H264"&&j.parameters["level-asymmetry-allowed"]===void 0&&(j.parameters["level-asymmetry-allowed"]="1"),_.remoteCapabilities&&_.remoteCapabilities.codecs&&_.remoteCapabilities.codecs.forEach(function(z){j.name.toLowerCase()===z.name.toLowerCase()&&j.clockRate===z.clockRate&&(j.preferredPayloadType=z.payloadType)})}),I.headerExtensions.forEach(function(j){(_.remoteCapabilities&&_.remoteCapabilities.headerExtensions||[]).forEach(function(z){j.uri===z.uri&&(j.id=z.id)})});var w=_.sendEncodingParameters||[{ssrc:1001*(2*y+1)}];b&&t>=15019&&f==="video"&&!w[0].rtx&&(w[0].rtx={ssrc:w[0].ssrc+1}),_.wantReceive&&(_.rtpReceiver=new e.RTCRtpReceiver(_.dtlsTransport,f)),_.localCapabilities=I,_.sendEncodingParameters=w}),a._config.bundlePolicy!=="max-compat"&&(d+="a=group:BUNDLE "+a.transceivers.map(function(_){return _.mid}).join(" ")+`\r
54
- `),d+=`a=ice-options:trickle\r
55
- `,a.transceivers.forEach(function(_,y){d+=Kg(_,_.localCapabilities,"offer",_.stream,a._dtlsRole),d+=`a=rtcp-rsize\r
56
- `,!_.iceGatherer||a.iceGatheringState==="new"||y!==0&&a.usingBundle||(_.iceGatherer.getLocalCandidates().forEach(function(b){b.component=1,d+="a="+Fe.writeCandidate(b)+`\r
57
- `}),_.iceGatherer.state==="completed"&&(d+=`a=end-of-candidates\r
58
- `))});var h=new e.RTCSessionDescription({type:"offer",sdp:d});return Promise.resolve(h)},i.prototype.createAnswer=function(){var a=this;if(a._isClosed)return Promise.reject(tn("InvalidStateError","Can not call createAnswer after close"));if(a.signalingState!=="have-remote-offer"&&a.signalingState!=="have-local-pranswer")return Promise.reject(tn("InvalidStateError","Can not call createAnswer in signalingState "+a.signalingState));var s=Fe.writeSessionBoilerplate(a._sdpSessionId,a._sdpSessionVersion++);a.usingBundle&&(s+="a=group:BUNDLE "+a.transceivers.map(function(d){return d.mid}).join(" ")+`\r
59
- `),s+=`a=ice-options:trickle\r
60
- `;var c=Fe.getMediaSections(a._remoteDescription.sdp).length;a.transceivers.forEach(function(d,h){if(!(h+1>c)){if(d.rejected)return d.kind==="application"?d.protocol==="DTLS/SCTP"?s+=`m=application 0 DTLS/SCTP 5000\r
61
- `:s+="m=application 0 "+d.protocol+` webrtc-datachannel\r
62
- `:d.kind==="audio"?s+=`m=audio 0 UDP/TLS/RTP/SAVPF 0\r
63
- a=rtpmap:0 PCMU/8000\r
64
- `:d.kind==="video"&&(s+=`m=video 0 UDP/TLS/RTP/SAVPF 120\r
65
- a=rtpmap:120 VP8/90000\r
66
- `),void(s+=`c=IN IP4 0.0.0.0\r
67
- a=inactive\r
68
- a=mid:`+d.mid+`\r
69
- `);var _;d.stream&&(d.kind==="audio"?_=d.stream.getAudioTracks()[0]:d.kind==="video"&&(_=d.stream.getVideoTracks()[0]),_&&t>=15019&&d.kind==="video"&&!d.sendEncodingParameters[0].rtx&&(d.sendEncodingParameters[0].rtx={ssrc:d.sendEncodingParameters[0].ssrc+1}));var y=lu(d.localCapabilities,d.remoteCapabilities);!y.codecs.filter(function(b){return b.name.toLowerCase()==="rtx"}).length&&d.sendEncodingParameters[0].rtx&&delete d.sendEncodingParameters[0].rtx,s+=Kg(d,y,"answer",d.stream,a._dtlsRole),d.rtcpParameters&&d.rtcpParameters.reducedSize&&(s+=`a=rtcp-rsize\r
70
- `)}});var u=new e.RTCSessionDescription({type:"answer",sdp:s});return Promise.resolve(u)},i.prototype.addIceCandidate=function(a){var s,c=this;return a&&a.sdpMLineIndex===void 0&&!a.sdpMid?Promise.reject(new TypeError("sdpMLineIndex or sdpMid required")):new Promise(function(u,d){if(!c._remoteDescription)return d(tn("InvalidStateError","Can not add ICE candidate without a remote description"));if(a&&a.candidate!==""){var h=a.sdpMLineIndex;if(a.sdpMid){for(var _=0;_<c.transceivers.length;_++)if(c.transceivers[_].mid===a.sdpMid){h=_;break}}var y=c.transceivers[h];if(!y)return d(tn("OperationError","Can not add ICE candidate"));if(y.rejected)return u();var b=Object.keys(a.candidate).length>0?Fe.parseCandidate(a.candidate):{};if(b.protocol==="tcp"&&(b.port===0||b.port===9)||b.component&&b.component!==1)return u();if((h===0||h>0&&y.iceTransport!==c.transceivers[0].iceTransport)&&!rh(y.iceTransport,b))return d(tn("OperationError","Can not add ICE candidate"));var f=a.candidate.trim();f.indexOf("a=")===0&&(f=f.substr(2)),(s=Fe.getMediaSections(c._remoteDescription.sdp))[h]+="a="+(b.type?f:"end-of-candidates")+`\r
71
- `,c._remoteDescription.sdp=Fe.getDescription(c._remoteDescription.sdp)+s.join("")}else for(var g=0;g<c.transceivers.length&&(c.transceivers[g].rejected||(c.transceivers[g].iceTransport.addRemoteCandidate({}),(s=Fe.getMediaSections(c._remoteDescription.sdp))[g]+=`a=end-of-candidates\r
72
- `,c._remoteDescription.sdp=Fe.getDescription(c._remoteDescription.sdp)+s.join(""),!c.usingBundle));g++);u()})},i.prototype.getStats=function(a){if(a&&a instanceof e.MediaStreamTrack){var s=null;if(this.transceivers.forEach(function(u){u.rtpSender&&u.rtpSender.track===a?s=u.rtpSender:u.rtpReceiver&&u.rtpReceiver.track===a&&(s=u.rtpReceiver)}),!s)throw tn("InvalidAccessError","Invalid selector.");return s.getStats()}var c=[];return this.transceivers.forEach(function(u){["rtpSender","rtpReceiver","iceGatherer","iceTransport","dtlsTransport"].forEach(function(d){u[d]&&c.push(u[d].getStats())})}),Promise.all(c).then(function(u){var d=new Map;return u.forEach(function(h){h.forEach(function(_){d.set(_.id,_)})}),d})},["RTCRtpSender","RTCRtpReceiver","RTCIceGatherer","RTCIceTransport","RTCDtlsTransport"].forEach(function(a){var s=e[a];if(s&&s.prototype&&s.prototype.getStats){var c=s.prototype.getStats;s.prototype.getStats=function(){return c.apply(this).then(function(u){var d=new Map;return Object.keys(u).forEach(function(h){var _;u[h].type={inboundrtp:"inbound-rtp",outboundrtp:"outbound-rtp",candidatepair:"candidate-pair",localcandidate:"local-candidate",remotecandidate:"remote-candidate"}[(_=u[h]).type]||_.type,d.set(h,u[h])}),d})}}});var o=["createOffer","createAnswer"];return o.forEach(function(a){var s=i.prototype[a];i.prototype[a]=function(){var c=arguments;return typeof c[0]=="function"||typeof c[1]=="function"?s.apply(this,[arguments[2]]).then(function(u){typeof c[0]=="function"&&c[0].apply(null,[u])},function(u){typeof c[1]=="function"&&c[1].apply(null,[u])}):s.apply(this,arguments)}}),(o=["setLocalDescription","setRemoteDescription","addIceCandidate"]).forEach(function(a){var s=i.prototype[a];i.prototype[a]=function(){var c=arguments;return typeof c[1]=="function"||typeof c[2]=="function"?s.apply(this,arguments).then(function(){typeof c[1]=="function"&&c[1].apply(null)},function(u){typeof c[2]=="function"&&c[2].apply(null,[u])}):s.apply(this,arguments)}}),["getStats"].forEach(function(a){var s=i.prototype[a];i.prototype[a]=function(){var c=arguments;return typeof c[1]=="function"?s.apply(this,arguments).then(function(){typeof c[1]=="function"&&c[1].apply(null)}):s.apply(this,arguments)}}),i};function Xg(e){let t=e&&e.navigator,n=t.mediaDevices.getUserMedia.bind(t.mediaDevices);t.mediaDevices.getUserMedia=function(r){return n(r).catch(i=>Promise.reject(function(o){return{name:{PermissionDeniedError:"NotAllowedError"}[o.name]||o.name,message:o.message,constraint:o.constraint,toString(){return this.name}}}(i)))}}function Qg(e){"getDisplayMedia"in e.navigator&&e.navigator.mediaDevices&&(e.navigator.mediaDevices&&"getDisplayMedia"in e.navigator.mediaDevices||(e.navigator.mediaDevices.getDisplayMedia=e.navigator.getDisplayMedia.bind(e.navigator)))}function ih(e,t){if(e.RTCIceGatherer&&(e.RTCIceCandidate||(e.RTCIceCandidate=function(r){return r}),e.RTCSessionDescription||(e.RTCSessionDescription=function(r){return r}),t.version<15025)){let r=Object.getOwnPropertyDescriptor(e.MediaStreamTrack.prototype,"enabled");Object.defineProperty(e.MediaStreamTrack.prototype,"enabled",{set(i){r.set.call(this,i);let o=new Event("enabled");o.enabled=i,this.dispatchEvent(o)}})}e.RTCRtpSender&&!("dtmf"in e.RTCRtpSender.prototype)&&Object.defineProperty(e.RTCRtpSender.prototype,"dtmf",{get(){return this._dtmf===void 0&&(this.track.kind==="audio"?this._dtmf=new e.RTCDtmfSender(this):this.track.kind==="video"&&(this._dtmf=null)),this._dtmf}}),e.RTCDtmfSender&&!e.RTCDTMFSender&&(e.RTCDTMFSender=e.RTCDtmfSender);let n=dC(e,t.version);e.RTCPeerConnection=function(r){return r&&r.iceServers&&(r.iceServers=function(i,o){let a=!1;return(i=JSON.parse(JSON.stringify(i))).filter(s=>{if(s&&(s.urls||s.url)){let c=s.urls||s.url;s.url&&!s.urls&&cu("RTCIceServer.url","RTCIceServer.urls");let u=typeof c=="string";return u&&(c=[c]),c=c.filter(d=>{if(d.indexOf("stun:")===0)return!1;let h=d.startsWith("turn")&&!d.startsWith("turn:[")&&d.includes("transport=udp");return h&&!a?(a=!0,!0):h&&!a}),delete s.url,s.urls=u?c[0]:c,!!c.length}})}(r.iceServers,t.version),Zd("ICE servers after filtering:",r.iceServers)),new n(r)},e.RTCPeerConnection.prototype=n.prototype}function Yg(e){e.RTCRtpSender&&!("replaceTrack"in e.RTCRtpSender.prototype)&&(e.RTCRtpSender.prototype.replaceTrack=e.RTCRtpSender.prototype.setTrack)}var $g=Object.freeze({__proto__:null,shimPeerConnection:ih,shimReplaceTrack:Yg,shimGetUserMedia:Xg,shimGetDisplayMedia:Qg});function Zg(e,t){let n=e&&e.navigator,r=e&&e.MediaStreamTrack;if(n.getUserMedia=function(i,o,a){cu("navigator.getUserMedia","navigator.mediaDevices.getUserMedia"),n.mediaDevices.getUserMedia(i).then(o,a)},!(t.version>55&&"autoGainControl"in n.mediaDevices.getSupportedConstraints())){let i=function(a,s,c){s in a&&!(c in a)&&(a[c]=a[s],delete a[s])},o=n.mediaDevices.getUserMedia.bind(n.mediaDevices);if(n.mediaDevices.getUserMedia=function(a){return typeof a=="object"&&typeof a.audio=="object"&&(a=JSON.parse(JSON.stringify(a)),i(a.audio,"autoGainControl","mozAutoGainControl"),i(a.audio,"noiseSuppression","mozNoiseSuppression")),o(a)},r&&r.prototype.getSettings){let a=r.prototype.getSettings;r.prototype.getSettings=function(){let s=a.apply(this,arguments);return i(s,"mozAutoGainControl","autoGainControl"),i(s,"mozNoiseSuppression","noiseSuppression"),s}}if(r&&r.prototype.applyConstraints){let a=r.prototype.applyConstraints;r.prototype.applyConstraints=function(s){return this.kind==="audio"&&typeof s=="object"&&(s=JSON.parse(JSON.stringify(s)),i(s,"autoGainControl","mozAutoGainControl"),i(s,"noiseSuppression","mozNoiseSuppression")),a.apply(this,[s])}}}}function e_(e){typeof e=="object"&&e.RTCTrackEvent&&"receiver"in e.RTCTrackEvent.prototype&&!("transceiver"in e.RTCTrackEvent.prototype)&&Object.defineProperty(e.RTCTrackEvent.prototype,"transceiver",{get(){return{receiver:this.receiver}}})}function ah(e,t){if(typeof e!="object"||!e.RTCPeerConnection&&!e.mozRTCPeerConnection)return;!e.RTCPeerConnection&&e.mozRTCPeerConnection&&(e.RTCPeerConnection=e.mozRTCPeerConnection),t.version<53&&["setLocalDescription","setRemoteDescription","addIceCandidate"].forEach(function(i){let o=e.RTCPeerConnection.prototype[i],a={[i](){return arguments[0]=new(i==="addIceCandidate"?e.RTCIceCandidate:e.RTCSessionDescription)(arguments[0]),o.apply(this,arguments)}};e.RTCPeerConnection.prototype[i]=a[i]});let n={inboundrtp:"inbound-rtp",outboundrtp:"outbound-rtp",candidatepair:"candidate-pair",localcandidate:"local-candidate",remotecandidate:"remote-candidate"},r=e.RTCPeerConnection.prototype.getStats;e.RTCPeerConnection.prototype.getStats=function(){let[i,o,a]=arguments;return r.apply(this,[i||null]).then(s=>{if(t.version<53&&!o)try{s.forEach(c=>{c.type=n[c.type]||c.type})}catch(c){if(c.name!=="TypeError")throw c;s.forEach((u,d)=>{s.set(d,Object.assign({},u,{type:n[u.type]||u.type}))})}return s}).then(o,a)}}function t_(e){if(typeof e!="object"||!e.RTCPeerConnection||!e.RTCRtpSender||e.RTCRtpSender&&"getStats"in e.RTCRtpSender.prototype)return;let t=e.RTCPeerConnection.prototype.getSenders;t&&(e.RTCPeerConnection.prototype.getSenders=function(){let r=t.apply(this,[]);return r.forEach(i=>i._pc=this),r});let n=e.RTCPeerConnection.prototype.addTrack;n&&(e.RTCPeerConnection.prototype.addTrack=function(){let r=n.apply(this,arguments);return r._pc=this,r}),e.RTCRtpSender.prototype.getStats=function(){return this.track?this._pc.getStats(this.track):Promise.resolve(new Map)}}function n_(e){if(typeof e!="object"||!e.RTCPeerConnection||!e.RTCRtpSender||e.RTCRtpSender&&"getStats"in e.RTCRtpReceiver.prototype)return;let t=e.RTCPeerConnection.prototype.getReceivers;t&&(e.RTCPeerConnection.prototype.getReceivers=function(){let n=t.apply(this,[]);return n.forEach(r=>r._pc=this),n}),Va(e,"track",n=>(n.receiver._pc=n.srcElement,n)),e.RTCRtpReceiver.prototype.getStats=function(){return this._pc.getStats(this.track)}}function r_(e){e.RTCPeerConnection&&!("removeStream"in e.RTCPeerConnection.prototype)&&(e.RTCPeerConnection.prototype.removeStream=function(t){cu("removeStream","removeTrack"),this.getSenders().forEach(n=>{n.track&&t.getTracks().includes(n.track)&&this.removeTrack(n)})})}function i_(e){e.DataChannel&&!e.RTCDataChannel&&(e.RTCDataChannel=e.DataChannel)}function a_(e){if(typeof e!="object"||!e.RTCPeerConnection)return;let t=e.RTCPeerConnection.prototype.addTransceiver;t&&(e.RTCPeerConnection.prototype.addTransceiver=function(){this.setParametersPromises=[];let n=arguments[1],r=n&&"sendEncodings"in n;r&&n.sendEncodings.forEach(o=>{if("rid"in o&&!/^[a-z0-9]{0,16}$/i.test(o.rid))throw new TypeError("Invalid RID value provided.");if("scaleResolutionDownBy"in o&&!(parseFloat(o.scaleResolutionDownBy)>=1))throw new RangeError("scale_resolution_down_by must be >= 1.0");if("maxFramerate"in o&&!(parseFloat(o.maxFramerate)>=0))throw new RangeError("max_framerate must be >= 0.0")});let i=t.apply(this,arguments);if(r){let{sender:o}=i,a=o.getParameters();(!("encodings"in a)||a.encodings.length===1&&Object.keys(a.encodings[0]).length===0)&&(a.encodings=n.sendEncodings,o.sendEncodings=n.sendEncodings,this.setParametersPromises.push(o.setParameters(a).then(()=>{delete o.sendEncodings}).catch(()=>{delete o.sendEncodings})))}return i})}function o_(e){if(typeof e!="object"||!e.RTCRtpSender)return;let t=e.RTCRtpSender.prototype.getParameters;t&&(e.RTCRtpSender.prototype.getParameters=function(){let n=t.apply(this,arguments);return"encodings"in n||(n.encodings=[].concat(this.sendEncodings||[{}])),n})}function s_(e){if(typeof e!="object"||!e.RTCPeerConnection)return;let t=e.RTCPeerConnection.prototype.createOffer;e.RTCPeerConnection.prototype.createOffer=function(){return this.setParametersPromises&&this.setParametersPromises.length?Promise.all(this.setParametersPromises).then(()=>t.apply(this,arguments)).finally(()=>{this.setParametersPromises=[]}):t.apply(this,arguments)}}function c_(e){if(typeof e!="object"||!e.RTCPeerConnection)return;let t=e.RTCPeerConnection.prototype.createAnswer;e.RTCPeerConnection.prototype.createAnswer=function(){return this.setParametersPromises&&this.setParametersPromises.length?Promise.all(this.setParametersPromises).then(()=>t.apply(this,arguments)).finally(()=>{this.setParametersPromises=[]}):t.apply(this,arguments)}}var u_=Object.freeze({__proto__:null,shimOnTrack:e_,shimPeerConnection:ah,shimSenderGetStats:t_,shimReceiverGetStats:n_,shimRemoveStream:r_,shimRTCDataChannel:i_,shimAddTransceiver:a_,shimGetParameters:o_,shimCreateOffer:s_,shimCreateAnswer:c_,shimGetUserMedia:Zg,shimGetDisplayMedia:function(e,t){e.navigator.mediaDevices&&"getDisplayMedia"in e.navigator.mediaDevices||e.navigator.mediaDevices&&(e.navigator.mediaDevices.getDisplayMedia=function(n){if(!n||!n.video){let r=new DOMException("getDisplayMedia without video constraints is undefined");return r.name="NotFoundError",r.code=8,Promise.reject(r)}return n.video===!0?n.video={mediaSource:t}:n.video.mediaSource=t,e.navigator.mediaDevices.getUserMedia(n)})}});function l_(e){if(typeof e=="object"&&e.RTCPeerConnection){if("getLocalStreams"in e.RTCPeerConnection.prototype||(e.RTCPeerConnection.prototype.getLocalStreams=function(){return this._localStreams||(this._localStreams=[]),this._localStreams}),!("addStream"in e.RTCPeerConnection.prototype)){let t=e.RTCPeerConnection.prototype.addTrack;e.RTCPeerConnection.prototype.addStream=function(n){this._localStreams||(this._localStreams=[]),this._localStreams.includes(n)||this._localStreams.push(n),n.getAudioTracks().forEach(r=>t.call(this,r,n)),n.getVideoTracks().forEach(r=>t.call(this,r,n))},e.RTCPeerConnection.prototype.addTrack=function(n,...r){return r&&r.forEach(i=>{this._localStreams?this._localStreams.includes(i)||this._localStreams.push(i):this._localStreams=[i]}),t.apply(this,arguments)}}"removeStream"in e.RTCPeerConnection.prototype||(e.RTCPeerConnection.prototype.removeStream=function(t){this._localStreams||(this._localStreams=[]);let n=this._localStreams.indexOf(t);if(n===-1)return;this._localStreams.splice(n,1);let r=t.getTracks();this.getSenders().forEach(i=>{r.includes(i.track)&&this.removeTrack(i)})})}}function d_(e){if(typeof e=="object"&&e.RTCPeerConnection&&("getRemoteStreams"in e.RTCPeerConnection.prototype||(e.RTCPeerConnection.prototype.getRemoteStreams=function(){return this._remoteStreams?this._remoteStreams:[]}),!("onaddstream"in e.RTCPeerConnection.prototype))){Object.defineProperty(e.RTCPeerConnection.prototype,"onaddstream",{get(){return this._onaddstream},set(n){this._onaddstream&&(this.removeEventListener("addstream",this._onaddstream),this.removeEventListener("track",this._onaddstreampoly)),this.addEventListener("addstream",this._onaddstream=n),this.addEventListener("track",this._onaddstreampoly=r=>{r.streams.forEach(i=>{if(this._remoteStreams||(this._remoteStreams=[]),this._remoteStreams.includes(i))return;this._remoteStreams.push(i);let o=new Event("addstream");o.stream=i,this.dispatchEvent(o)})})}});let t=e.RTCPeerConnection.prototype.setRemoteDescription;e.RTCPeerConnection.prototype.setRemoteDescription=function(){let n=this;return this._onaddstreampoly||this.addEventListener("track",this._onaddstreampoly=function(r){r.streams.forEach(i=>{if(n._remoteStreams||(n._remoteStreams=[]),n._remoteStreams.indexOf(i)>=0)return;n._remoteStreams.push(i);let o=new Event("addstream");o.stream=i,n.dispatchEvent(o)})}),t.apply(n,arguments)}}}function h_(e){if(typeof e!="object"||!e.RTCPeerConnection)return;let t=e.RTCPeerConnection.prototype,n=t.createOffer,r=t.createAnswer,i=t.setLocalDescription,o=t.setRemoteDescription,a=t.addIceCandidate;t.createOffer=function(c,u){let d=arguments.length>=2?arguments[2]:arguments[0],h=n.apply(this,[d]);return u?(h.then(c,u),Promise.resolve()):h},t.createAnswer=function(c,u){let d=arguments.length>=2?arguments[2]:arguments[0],h=r.apply(this,[d]);return u?(h.then(c,u),Promise.resolve()):h};let s=function(c,u,d){let h=i.apply(this,[c]);return d?(h.then(u,d),Promise.resolve()):h};t.setLocalDescription=s,s=function(c,u,d){let h=o.apply(this,[c]);return d?(h.then(u,d),Promise.resolve()):h},t.setRemoteDescription=s,s=function(c,u,d){let h=a.apply(this,[c]);return d?(h.then(u,d),Promise.resolve()):h},t.addIceCandidate=s}function p_(e){let t=e&&e.navigator;if(t.mediaDevices&&t.mediaDevices.getUserMedia){let n=t.mediaDevices,r=n.getUserMedia.bind(n);t.mediaDevices.getUserMedia=i=>r(f_(i))}!t.getUserMedia&&t.mediaDevices&&t.mediaDevices.getUserMedia&&(t.getUserMedia=function(n,r,i){t.mediaDevices.getUserMedia(n).then(r,i)}.bind(t))}function f_(e){return e&&e.video!==void 0?Object.assign({},e,{video:Og(e.video)}):e}function m_(e){if(!e.RTCPeerConnection)return;let t=e.RTCPeerConnection;e.RTCPeerConnection=function(n,r){if(n&&n.iceServers){let i=[];for(let o=0;o<n.iceServers.length;o++){let a=n.iceServers[o];!a.hasOwnProperty("urls")&&a.hasOwnProperty("url")?(cu("RTCIceServer.url","RTCIceServer.urls"),a=JSON.parse(JSON.stringify(a)),a.urls=a.url,delete a.url,i.push(a)):i.push(n.iceServers[o])}n.iceServers=i}return new t(n,r)},e.RTCPeerConnection.prototype=t.prototype,"generateCertificate"in t&&Object.defineProperty(e.RTCPeerConnection,"generateCertificate",{get:()=>t.generateCertificate})}function v_(e){typeof e=="object"&&e.RTCTrackEvent&&"receiver"in e.RTCTrackEvent.prototype&&!("transceiver"in e.RTCTrackEvent.prototype)&&Object.defineProperty(e.RTCTrackEvent.prototype,"transceiver",{get(){return{receiver:this.receiver}}})}function g_(e){let t=e.RTCPeerConnection.prototype.createOffer;e.RTCPeerConnection.prototype.createOffer=function(n){if(n){n.offerToReceiveAudio!==void 0&&(n.offerToReceiveAudio=!!n.offerToReceiveAudio);let r=this.getTransceivers().find(o=>o.receiver.track.kind==="audio");n.offerToReceiveAudio===!1&&r?r.direction==="sendrecv"?r.setDirection?r.setDirection("sendonly"):r.direction="sendonly":r.direction==="recvonly"&&(r.setDirection?r.setDirection("inactive"):r.direction="inactive"):n.offerToReceiveAudio!==!0||r||this.addTransceiver("audio"),n.offerToReceiveVideo!==void 0&&(n.offerToReceiveVideo=!!n.offerToReceiveVideo);let i=this.getTransceivers().find(o=>o.receiver.track.kind==="video");n.offerToReceiveVideo===!1&&i?i.direction==="sendrecv"?i.setDirection?i.setDirection("sendonly"):i.direction="sendonly":i.direction==="recvonly"&&(i.setDirection?i.setDirection("inactive"):i.direction="inactive"):n.offerToReceiveVideo!==!0||i||this.addTransceiver("video")}return t.apply(this,arguments)}}function __(e){typeof e!="object"||e.AudioContext||(e.AudioContext=e.webkitAudioContext)}var y_=Object.freeze({__proto__:null,shimLocalStreamsAPI:l_,shimRemoteStreamsAPI:d_,shimCallbacksAPI:h_,shimGetUserMedia:p_,shimConstraints:f_,shimRTCIceServerUrls:m_,shimTrackEventTransceiver:v_,shimCreateOfferLegacy:g_,shimAudioContext:__});function du(e){if(!e.RTCIceCandidate||e.RTCIceCandidate&&"foundation"in e.RTCIceCandidate.prototype)return;let t=e.RTCIceCandidate;e.RTCIceCandidate=function(n){if(typeof n=="object"&&n.candidate&&n.candidate.indexOf("a=")===0&&((n=JSON.parse(JSON.stringify(n))).candidate=n.candidate.substr(2)),n.candidate&&n.candidate.length){let r=new t(n),i=uu.parseCandidate(n.candidate),o=Object.assign(r,i);return o.toJSON=function(){return{candidate:o.candidate,sdpMid:o.sdpMid,sdpMLineIndex:o.sdpMLineIndex,usernameFragment:o.usernameFragment}},o}return new t(n)},e.RTCIceCandidate.prototype=t.prototype,Va(e,"icecandidate",n=>(n.candidate&&Object.defineProperty(n,"candidate",{value:new e.RTCIceCandidate(n.candidate),writable:"false"}),n))}function bs(e,t){if(!e.RTCPeerConnection)return;"sctp"in e.RTCPeerConnection.prototype||Object.defineProperty(e.RTCPeerConnection.prototype,"sctp",{get(){return this._sctp===void 0?null:this._sctp}});let n=function(s){if(!s||!s.sdp)return!1;let c=uu.splitSections(s.sdp);return c.shift(),c.some(u=>{let d=uu.parseMLine(u);return d&&d.kind==="application"&&d.protocol.indexOf("SCTP")!==-1})},r=function(s){let c=s.sdp.match(/mozilla...THIS_IS_SDPARTA-(\d+)/);if(c===null||c.length<2)return-1;let u=parseInt(c[1],10);return u!=u?-1:u},i=function(s){let c=65536;return t.browser==="firefox"&&(c=t.version<57?s===-1?16384:2147483637:t.version<60?t.version===57?65535:65536:2147483637),c},o=function(s,c){let u=65536;t.browser==="firefox"&&t.version===57&&(u=65535);let d=uu.matchPrefix(s.sdp,"a=max-message-size:");return d.length>0?u=parseInt(d[0].substr(19),10):t.browser==="firefox"&&c!==-1&&(u=2147483637),u},a=e.RTCPeerConnection.prototype.setRemoteDescription;e.RTCPeerConnection.prototype.setRemoteDescription=function(){if(this._sctp=null,t.browser==="chrome"&&t.version>=76){let{sdpSemantics:s}=this.getConfiguration();s==="plan-b"&&Object.defineProperty(this,"sctp",{get(){return this._sctp===void 0?null:this._sctp},enumerable:!0,configurable:!0})}if(n(arguments[0])){let s=r(arguments[0]),c=i(s),u=o(arguments[0],s),d;d=c===0&&u===0?Number.POSITIVE_INFINITY:c===0||u===0?Math.max(c,u):Math.min(c,u);let h={};Object.defineProperty(h,"maxMessageSize",{get:()=>d}),this._sctp=h}return a.apply(this,arguments)}}function ks(e){if(!e.RTCPeerConnection||!("createDataChannel"in e.RTCPeerConnection.prototype))return;function t(r,i){let o=r.send;r.send=function(){let a=arguments[0],s=a.length||a.size||a.byteLength;if(r.readyState==="open"&&i.sctp&&s>i.sctp.maxMessageSize)throw new TypeError("Message too large (can send a maximum of "+i.sctp.maxMessageSize+" bytes)");return o.apply(r,arguments)}}let n=e.RTCPeerConnection.prototype.createDataChannel;e.RTCPeerConnection.prototype.createDataChannel=function(){let r=n.apply(this,arguments);return t(r,this),r},Va(e,"datachannel",r=>(t(r.channel,r.target),r))}function oh(e){if(!e.RTCPeerConnection||"connectionState"in e.RTCPeerConnection.prototype)return;let t=e.RTCPeerConnection.prototype;Object.defineProperty(t,"connectionState",{get(){return{completed:"connected",checking:"connecting"}[this.iceConnectionState]||this.iceConnectionState},enumerable:!0,configurable:!0}),Object.defineProperty(t,"onconnectionstatechange",{get(){return this._onconnectionstatechange||null},set(n){this._onconnectionstatechange&&(this.removeEventListener("connectionstatechange",this._onconnectionstatechange),delete this._onconnectionstatechange),n&&this.addEventListener("connectionstatechange",this._onconnectionstatechange=n)},enumerable:!0,configurable:!0}),["setLocalDescription","setRemoteDescription"].forEach(n=>{let r=t[n];t[n]=function(){return this._connectionstatechangepoly||(this._connectionstatechangepoly=i=>{let o=i.target;if(o._lastConnectionState!==o.connectionState){o._lastConnectionState=o.connectionState;let a=new Event("connectionstatechange",i);o.dispatchEvent(a)}return i},this.addEventListener("iceconnectionstatechange",this._connectionstatechangepoly)),r.apply(this,arguments)}})}function sh(e,t){if(!e.RTCPeerConnection||t.browser==="chrome"&&t.version>=71||t.browser==="safari"&&t.version>=605)return;let n=e.RTCPeerConnection.prototype.setRemoteDescription;e.RTCPeerConnection.prototype.setRemoteDescription=function(r){if(r&&r.sdp&&r.sdp.indexOf(`
73
- a=extmap-allow-mixed`)!==-1){let i=r.sdp.split(`
74
- `).filter(o=>o.trim()!=="a=extmap-allow-mixed").join(`
75
- `);e.RTCSessionDescription&&r instanceof e.RTCSessionDescription?arguments[0]=new e.RTCSessionDescription({type:r.type,sdp:i}):r.sdp=i}return n.apply(this,arguments)}}function hu(e,t){if(!e.RTCPeerConnection||!e.RTCPeerConnection.prototype)return;let n=e.RTCPeerConnection.prototype.addIceCandidate;n&&n.length!==0&&(e.RTCPeerConnection.prototype.addIceCandidate=function(){return arguments[0]?(t.browser==="chrome"&&t.version<78||t.browser==="firefox"&&t.version<68||t.browser==="safari")&&arguments[0]&&arguments[0].candidate===""?Promise.resolve():n.apply(this,arguments):(arguments[1]&&arguments[1].apply(null),Promise.resolve())})}var hC=Object.freeze({__proto__:null,shimRTCIceCandidate:du,shimMaxMessageSize:bs,shimSendThrowTypeError:ks,shimConnectionState:oh,removeExtmapAllowMixed:sh,shimAddIceCandidateNullOrEmpty:hu});(function({window:e}={},t={shimChrome:!0,shimFirefox:!0,shimEdge:!0,shimSafari:!0}){let n=Zd,r=function(o){let a={browser:null,version:null};if(o===void 0||!o.navigator)return a.browser="Not a browser.",a;let{navigator:s}=o;if(s.mozGetUserMedia)a.browser="firefox",a.version=Ss(s.userAgent,/Firefox\/(\d+)\./,1);else if(s.webkitGetUserMedia||o.isSecureContext===!1&&o.webkitRTCPeerConnection&&!o.RTCIceGatherer)a.browser="chrome",a.version=Ss(s.userAgent,/Chrom(e|ium)\/(\d+)\./,2);else if(s.mediaDevices&&s.userAgent.match(/Edge\/(\d+).(\d+)$/))a.browser="edge",a.version=Ss(s.userAgent,/Edge\/(\d+).(\d+)$/,2);else{if(!o.RTCPeerConnection||!s.userAgent.match(/AppleWebKit\/(\d+)\./))return a.browser="Not a supported browser.",a;a.browser="safari",a.version=Ss(s.userAgent,/AppleWebKit\/(\d+)\./,1),a.supportsUnifiedPlan=o.RTCRtpTransceiver&&"currentDirection"in o.RTCRtpTransceiver.prototype}return a}(e),i={browserDetails:r,commonShim:hC,extractVersion:Ss,disableLog:uC,disableWarnings:lC};switch(r.browser){case"chrome":if(!Jg||!th||!t.shimChrome)return n("Chrome shim is not included in this adapter release."),i;if(r.version===null)return n("Chrome shim can not determine version, not shimming."),i;n("adapter.js shimming chrome."),i.browserShim=Jg,hu(e,r),Vg(e,r),Ug(e),th(e,r),Bg(e),zg(e,r),jg(e),Fg(e),Gg(e),Wg(e,r),du(e),oh(e),bs(e,r),ks(e),sh(e,r);break;case"firefox":if(!u_||!ah||!t.shimFirefox)return n("Firefox shim is not included in this adapter release."),i;n("adapter.js shimming firefox."),i.browserShim=u_,hu(e,r),Zg(e,r),ah(e,r),e_(e),r_(e),t_(e),n_(e),i_(e),a_(e),o_(e),s_(e),c_(e),du(e),oh(e),bs(e,r),ks(e);break;case"edge":if(!$g||!ih||!t.shimEdge)return n("MS edge shim is not included in this adapter release."),i;n("adapter.js shimming edge."),i.browserShim=$g,Xg(e),Qg(e),ih(e,r),Yg(e),bs(e,r),ks(e);break;case"safari":if(!y_||!t.shimSafari)return n("Safari shim is not included in this adapter release."),i;n("adapter.js shimming safari."),i.browserShim=y_,hu(e,r),m_(e),g_(e),h_(e),l_(e),d_(e),v_(e),p_(e),__(e),du(e),bs(e,r),ks(e),sh(e,r);break;default:n("Unsupported browser!")}})({window:typeof window=="undefined"?void 0:window});var Vi="4.15.10",S_={},pC=Eg,fC=Qd,pu=Object.keys||function(e){return pC(e,fC)},mC=_e,vC=ls,gC=At,_C=It,yC=Sn,SC=pu;S_.f=mC&&!vC?Object.defineProperties:function(e,t){_C(e);for(var n,r=yC(t),i=SC(t),o=i.length,a=0;o>a;)gC.f(e,n=i[a++],r[n]);return e};var fu,b_=Pn("document","documentElement"),bC=It,kC=S_,k_=Qd,TC=Q,xC=b_,IC=pr,T_=G("IE_PROTO"),ch=function(){},x_=function(e){return"<script>"+e+"<\/script>"},I_=function(e){e.write(x_("")),e.close();var t=e.parentWindow.Object;return e=null,t},mu=function(){try{fu=new ActiveXObject("htmlfile")}catch(r){}var e,t;mu=typeof document!="undefined"?document.domain&&fu?I_(fu):((t=IC("iframe")).style.display="none",xC.appendChild(t),t.src=String("javascript:"),(e=t.contentWindow.document).open(),e.write(x_("document.F=Object")),e.close(),e.F):I_(fu);for(var n=k_.length;n--;)delete mu.prototype[k_[n]];return mu()};TC[T_]=!0;var Ua=Object.create||function(e,t){var n;return e!==null?(ch.prototype=bC(e),n=new ch,ch.prototype=null,n[T_]=e):n=mu(),t===void 0?n:kC.f(n,t)},wC=nt,EC=Ua,CC=At.f,uh=wC("unscopables"),lh=Array.prototype;lh[uh]==null&&CC(lh,uh,{configurable:!0,value:EC(null)});var Ui,w_,E_,vu=function(e){lh[uh][e]=!0},Ts={},C_=!oe(function(){function e(){}return e.prototype.constructor=null,Object.getPrototypeOf(new e)!==e.prototype}),RC=xt,AC=at,PC=Bt,DC=C_,R_=G("IE_PROTO"),dh=Object,LC=dh.prototype,xs=DC?dh.getPrototypeOf:function(e){var t=PC(e);if(RC(t,R_))return t[R_];var n=t.constructor;return AC(n)&&t instanceof n?n.prototype:t instanceof dh?LC:null},OC=oe,MC=at,NC=ot,A_=xs,VC=Qt,hh=nt("iterator"),P_=!1;[].keys&&("next"in(E_=[].keys())?(w_=A_(A_(E_)))!==Object.prototype&&(Ui=w_):P_=!0);var UC=!NC(Ui)||OC(function(){var e={};return Ui[hh].call(e)!==e});UC&&(Ui={}),MC(Ui[hh])||VC(Ui,hh,function(){return this});var ph={IteratorPrototype:Ui,BUGGY_SAFARI_ITERATORS:P_},BC=At.f,jC=xt,D_=nt("toStringTag"),Bi=function(e,t,n){e&&!n&&(e=e.prototype),e&&!jC(e,D_)&&BC(e,D_,{configurable:!0,value:t})},FC=ph.IteratorPrototype,GC=Ua,HC=et,zC=Bi,WC=Ts,JC=function(){return this},L_=function(e,t,n,r){var i=t+" Iterator";return e.prototype=GC(FC,{next:HC(+!r,n)}),zC(e,i,!1),WC[i]=JC,e},KC=at,qC=String,XC=TypeError,QC=pe,YC=It,$C=function(e){if(typeof e=="object"||KC(e))return e;throw XC("Can't set "+qC(e)+" as a prototype")},Ba=Object.setPrototypeOf||("__proto__"in{}?function(){var e,t=!1,n={};try{(e=QC(Object.getOwnPropertyDescriptor(Object.prototype,"__proto__").set))(n,[]),t=n instanceof Array}catch(r){}return function(r,i){return YC(r),$C(i),t?e(r,i):r.__proto__=i,r}}():void 0),ZC=Me,eR=Qe,tR=at,nR=L_,O_=xs,M_=Ba,rR=Bi,iR=Mn,fh=Qt,aR=Ts,oR=Yn.PROPER,sR=Yn.CONFIGURABLE,N_=ph.IteratorPrototype,gu=ph.BUGGY_SAFARI_ITERATORS,Is=nt("iterator"),V_="keys",ws="values",U_="entries",cR=function(){return this},mh=function(e,t,n,r,i,o,a){nR(n,t,r);var s,c,u,d=function(I){if(I===i&&f)return f;if(!gu&&I in y)return y[I];switch(I){case V_:case ws:case U_:return function(){return new n(this,I)}}return function(){return new n(this)}},h=t+" Iterator",_=!1,y=e.prototype,b=y[Is]||y["@@iterator"]||i&&y[i],f=!gu&&b||d(i),g=t=="Array"&&y.entries||b;if(g&&(s=O_(g.call(new e)))!==Object.prototype&&s.next&&(O_(s)!==N_&&(M_?M_(s,N_):tR(s[Is])||fh(s,Is,cR)),rR(s,h,!0)),oR&&i==ws&&b&&b.name!==ws&&(sR?iR(y,"name",ws):(_=!0,f=function(){return eR(b,this)})),i)if(c={values:d(ws),keys:o?f:d(V_),entries:d(U_)},a)for(u in c)(gu||_||!(u in y))&&fh(y,u,c[u]);else ZC({target:t,proto:!0,forced:gu||_},c);return y[Is]!==f&&fh(y,Is,f,{name:i}),aR[t]=f,c},vh=function(e,t){return{value:e,done:t}},uR=Sn,gh=vu,B_=Ts,j_=Xe,lR=At.f,dR=mh,F_=vh,hR=_e,G_="Array Iterator",pR=j_.set,fR=j_.getterFor(G_),H_=dR(Array,"Array",function(e,t){pR(this,{type:G_,target:uR(e),index:0,kind:t})},function(){var e=fR(this),t=e.target,n=e.kind,r=e.index++;return!t||r>=t.length?(e.target=void 0,F_(void 0,!0)):F_(n=="keys"?r:n=="values"?t[r]:[r,t[r]],!1)},"values"),z_=B_.Arguments=B_.Array;if(gh("keys"),gh("values"),gh("entries"),hR&&z_.name!=="values")try{lR(z_,"name",{value:"values"})}catch(e){}var W_={};W_[nt("toStringTag")]="z";var _h=String(W_)==="[object z]",mR=_h,vR=at,_u=it,gR=nt("toStringTag"),_R=Object,yR=_u(function(){return arguments}())=="Arguments",Lr=mR?_u:function(e){var t,n,r;return e===void 0?"Undefined":e===null?"Null":typeof(n=function(i,o){try{return i[o]}catch(a){}}(t=_R(e),gR))=="string"?n:yR?_u(t):(r=_u(t))=="Object"&&vR(t.callee)?"Arguments":r},SR=Lr,bR=_h?{}.toString:function(){return"[object "+SR(this)+"]"};_h||Qt(Object.prototype,"toString",bR,{unsafe:!0});var Es={exports:{}},yh={},kR=Ra,TR=At,xR=et,Cs=function(e,t,n){var r=kR(t);r in e?TR.f(e,r,xR(0,n)):e[r]=n},J_=ai,IR=rn,wR=Cs,ER=Array,CR=Math.max,yu=function(e,t,n){for(var r=IR(e),i=J_(t,r),o=J_(n===void 0?r:n,r),a=ER(CR(o-i,0)),s=0;i<o;i++,s++)wR(a,s,e[i]);return a.length=s,a},RR=it,AR=Sn,K_=ii.f,PR=yu,q_=typeof window=="object"&&window&&Object.getOwnPropertyNames?Object.getOwnPropertyNames(window):[];yh.f=function(e){return q_&&RR(e)=="Window"?function(t){try{return K_(t)}catch(n){return PR(q_)}}(e):K_(AR(e))};var DR=oe(function(){if(typeof ArrayBuffer=="function"){var e=new ArrayBuffer(8);Object.isExtensible(e)&&Object.defineProperty(e,"a",{value:8})}}),LR=oe,OR=ot,MR=it,X_=DR,Su=Object.isExtensible,Q_=LR(function(){Su(1)})||X_?function(e){return!!OR(e)&&(!X_||MR(e)!="ArrayBuffer")&&(!Su||Su(e))}:Su,NR=!oe(function(){return Object.isExtensible(Object.preventExtensions({}))}),VR=Me,UR=pe,BR=Q,jR=ot,Sh=xt,FR=At.f,Y_=ii,GR=yh,bh=Q_,HR=NR,$_=!1,Or=Di("meta"),zR=0,kh=function(e){FR(e,Or,{value:{objectID:"O"+zR++,weakData:{}}})},WR=Es.exports={enable:function(){WR.enable=function(){},$_=!0;var e=Y_.f,t=UR([].splice),n={};n[Or]=1,e(n).length&&(Y_.f=function(r){for(var i=e(r),o=0,a=i.length;o<a;o++)if(i[o]===Or){t(i,o,1);break}return i},VR({target:"Object",stat:!0,forced:!0},{getOwnPropertyNames:GR.f}))},fastKey:function(e,t){if(!jR(e))return typeof e=="symbol"?e:(typeof e=="string"?"S":"P")+e;if(!Sh(e,Or)){if(!bh(e))return"F";if(!t)return"E";kh(e)}return e[Or].objectID},getWeakData:function(e,t){if(!Sh(e,Or)){if(!bh(e))return!0;if(!t)return!1;kh(e)}return e[Or].weakData},onFreeze:function(e){return HR&&$_&&bh(e)&&!Sh(e,Or)&&kh(e),e}};BR[Or]=!0;var JR=Ut,KR=Oe,qR=pe(pe.bind),Mr=function(e,t){return JR(e),t===void 0?e:KR?qR(e,t):function(){return e.apply(t,arguments)}},XR=Ts,QR=nt("iterator"),YR=Array.prototype,Th=function(e){return e!==void 0&&(XR.Array===e||YR[QR]===e)},$R=Lr,Z_=Xt,ZR=Ct,eA=Ts,tA=nt("iterator"),Rs=function(e){if(!ZR(e))return Z_(e,tA)||Z_(e,"@@iterator")||eA[$R(e)]},nA=Qe,rA=Ut,iA=It,aA=Xn,oA=Rs,sA=TypeError,bu=function(e,t){var n=arguments.length<2?oA(e):t;if(rA(n))return iA(nA(n,e));throw sA(aA(e)+" is not iterable")},cA=Qe,ey=It,uA=Xt,ty=function(e,t,n){var r,i;ey(e);try{if(!(r=uA(e,"return"))){if(t==="throw")throw n;return n}r=cA(r,e)}catch(o){i=!0,r=o}if(t==="throw")throw n;if(i)throw r;return ey(r),n},lA=Mr,dA=Qe,hA=It,pA=Xn,fA=Th,mA=rn,ny=bn,vA=bu,gA=Rs,ry=ty,_A=TypeError,ku=function(e,t){this.stopped=e,this.result=t},iy=ku.prototype,As=function(e,t,n){var r,i,o,a,s,c,u,d=n&&n.that,h=!(!n||!n.AS_ENTRIES),_=!(!n||!n.IS_RECORD),y=!(!n||!n.IS_ITERATOR),b=!(!n||!n.INTERRUPTED),f=lA(t,d),g=function(w){return r&&ry(r,"normal",w),new ku(!0,w)},I=function(w){return h?(hA(w),b?f(w[0],w[1],g):f(w[0],w[1])):b?f(w,g):f(w)};if(_)r=e.iterator;else if(y)r=e;else{if(!(i=gA(e)))throw _A(pA(e)+" is not iterable");if(fA(i)){for(o=0,a=mA(e);a>o;o++)if((s=I(e[o]))&&ny(iy,s))return s;return new ku(!1)}r=vA(e,i)}for(c=_?e.next:r.next;!(u=dA(c,r)).done;){try{s=I(u.value)}catch(w){ry(r,"throw",w)}if(typeof s=="object"&&s&&ny(iy,s))return s}return new ku(!1)},yA=bn,SA=TypeError,oi=function(e,t){if(yA(t,e))return e;throw SA("Incorrect invocation")},ay=nt("iterator"),oy=!1;try{var bA=0,sy={next:function(){return{done:!!bA++}},return:function(){oy=!0}};sy[ay]=function(){return this},Array.from(sy,function(){throw 2})}catch(e){}var Tu=function(e,t){if(!t&&!oy)return!1;var n=!1;try{var r={};r[ay]=function(){return{next:function(){return{done:n=!0}}}},e(r)}catch(i){}return n},kA=at,TA=ot,cy=Ba,xu=function(e,t,n){var r,i;return cy&&kA(r=t.constructor)&&r!==n&&TA(i=r.prototype)&&i!==n.prototype&&cy(e,i),e},xA=Me,IA=te,wA=pe,uy=ys,EA=Qt,CA=Es.exports,RA=As,AA=oi,PA=at,DA=Ct,xh=ot,Ih=oe,LA=Tu,OA=Bi,MA=xu,wh=function(e,t,n){var r=e.indexOf("Map")!==-1,i=e.indexOf("Weak")!==-1,o=r?"set":"add",a=IA[e],s=a&&a.prototype,c=a,u={},d=function(g){var I=wA(s[g]);EA(s,g,g=="add"?function(w){return I(this,w===0?0:w),this}:g=="delete"?function(w){return!(i&&!xh(w))&&I(this,w===0?0:w)}:g=="get"?function(w){return i&&!xh(w)?void 0:I(this,w===0?0:w)}:g=="has"?function(w){return!(i&&!xh(w))&&I(this,w===0?0:w)}:function(w,j){return I(this,w===0?0:w,j),this})};if(uy(e,!PA(a)||!(i||s.forEach&&!Ih(function(){new a().entries().next()}))))c=n.getConstructor(t,e,r,o),CA.enable();else if(uy(e,!0)){var h=new c,_=h[o](i?{}:-0,1)!=h,y=Ih(function(){h.has(1)}),b=LA(function(g){new a(g)}),f=!i&&Ih(function(){for(var g=new a,I=5;I--;)g[o](I,I);return!g.has(-0)});b||((c=t(function(g,I){AA(g,s);var w=MA(new a,g,c);return DA(I)||RA(I,w[o],{that:w,AS_ENTRIES:r}),w})).prototype=s,s.constructor=c),(y||f)&&(d("delete"),d("has"),r&&d("get")),(f||_)&&d(o),i&&s.clear&&delete s.clear}return u[e]=c,xA({global:!0,constructor:!0,forced:c!=a},u),OA(c,e),i||n.setStrong(c,e,r),c},NA=Qt,Ps=function(e,t,n){for(var r in t)NA(e,r,t[r],n);return e},VA=Pn,UA=At,BA=_e,ly=nt("species"),Ds=function(e){var t=VA(e),n=UA.f;BA&&t&&!t[ly]&&n(t,ly,{configurable:!0,get:function(){return this}})},jA=At.f,FA=Ua,dy=Ps,GA=Mr,HA=oi,zA=Ct,WA=As,JA=mh,hy=vh,KA=Ds,Ls=_e,py=Es.exports.fastKey,fy=Xe.set,Eh=Xe.getterFor,my={getConstructor:function(e,t,n,r){var i=e(function(u,d){HA(u,o),fy(u,{type:t,index:FA(null),first:void 0,last:void 0,size:0}),Ls||(u.size=0),zA(d)||WA(d,u[r],{that:u,AS_ENTRIES:n})}),o=i.prototype,a=Eh(t),s=function(u,d,h){var _,y,b=a(u),f=c(u,d);return f?f.value=h:(b.last=f={index:y=py(d,!0),key:d,value:h,previous:_=b.last,next:void 0,removed:!1},b.first||(b.first=f),_&&(_.next=f),Ls?b.size++:u.size++,y!=="F"&&(b.index[y]=f)),u},c=function(u,d){var h,_=a(u),y=py(d);if(y!=="F")return _.index[y];for(h=_.first;h;h=h.next)if(h.key==d)return h};return dy(o,{clear:function(){for(var u=a(this),d=u.index,h=u.first;h;)h.removed=!0,h.previous&&(h.previous=h.previous.next=void 0),delete d[h.index],h=h.next;u.first=u.last=void 0,Ls?u.size=0:this.size=0},delete:function(u){var d=this,h=a(d),_=c(d,u);if(_){var y=_.next,b=_.previous;delete h.index[_.index],_.removed=!0,b&&(b.next=y),y&&(y.previous=b),h.first==_&&(h.first=y),h.last==_&&(h.last=b),Ls?h.size--:d.size--}return!!_},forEach:function(u){for(var d,h=a(this),_=GA(u,arguments.length>1?arguments[1]:void 0);d=d?d.next:h.first;)for(_(d.value,d.key,this);d&&d.removed;)d=d.previous},has:function(u){return!!c(this,u)}}),dy(o,n?{get:function(u){var d=c(this,u);return d&&d.value},set:function(u,d){return s(this,u===0?0:u,d)}}:{add:function(u){return s(this,u=u===0?0:u,u)}}),Ls&&jA(o,"size",{get:function(){return a(this).size}}),i},setStrong:function(e,t,n){var r=t+" Iterator",i=Eh(t),o=Eh(r);JA(e,t,function(a,s){fy(this,{type:r,target:a,state:i(a),kind:s,last:void 0})},function(){for(var a=o(this),s=a.kind,c=a.last;c&&c.removed;)c=c.previous;return a.target&&(a.last=c=c?c.next:a.state.first)?hy(s=="keys"?c.key:s=="values"?c.value:[c.key,c.value],!1):(a.target=void 0,hy(void 0,!0))},n?"entries":"values",!n,!0),KA(t)}};wh("Set",function(e){return function(){return e(this,arguments.length?arguments[0]:void 0)}},my);var qA=Lr,XA=String,Wt=function(e){if(qA(e)==="Symbol")throw TypeError("Cannot convert a Symbol value to a string");return XA(e)},Ch=pe,QA=$n,YA=Wt,$A=pt,ZA=Ch("".charAt),vy=Ch("".charCodeAt),e2=Ch("".slice),gy=function(e){return function(t,n){var r,i,o=YA($A(t)),a=QA(n),s=o.length;return a<0||a>=s?e?"":void 0:(r=vy(o,a))<55296||r>56319||a+1===s||(i=vy(o,a+1))<56320||i>57343?e?ZA(o,a):r:e?e2(o,a,a+2):i-56320+(r-55296<<10)+65536}},Rh={codeAt:gy(!1),charAt:gy(!0)},t2=Rh.charAt,n2=Wt,_y=Xe,r2=mh,yy=vh,Sy="String Iterator",i2=_y.set,a2=_y.getterFor(Sy);r2(String,"String",function(e){i2(this,{type:Sy,string:n2(e),index:0})},function(){var e,t=a2(this),n=t.string,r=t.index;return r>=n.length?yy(void 0,!0):(e=t2(n,r),t.index+=e.length,yy(e,!1))});var by={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},Ah=pr("span").classList,ky=Ah&&Ah.constructor&&Ah.constructor.prototype,Ty=ky===Object.prototype?void 0:ky,xy=te,Iy=by,o2=Ty,Os=H_,Ph=Mn,wy=nt,Dh=wy("iterator"),Ey=wy("toStringTag"),Lh=Os.values,Cy=function(e,t){if(e){if(e[Dh]!==Lh)try{Ph(e,Dh,Lh)}catch(r){e[Dh]=Lh}if(e[Ey]||Ph(e,Ey,t),Iy[t]){for(var n in Os)if(e[n]!==Os[n])try{Ph(e,n,Os[n])}catch(r){e[n]=Os[n]}}}};for(var Oh in Iy)Cy(xy[Oh]&&xy[Oh].prototype,Oh);Cy(o2,"DOMTokenList");var s2=Oe,Ry=Function.prototype,Ay=Ry.apply,Py=Ry.call,ji=typeof Reflect=="object"&&Reflect.apply||(s2?Py.bind(Ay):function(){return Py.apply(Ay,arguments)}),ja=pe([].slice),c2=TypeError,Iu=function(e,t){if(e<t)throw c2("Not enough arguments");return e},Mh=te,u2=ji,l2=at,d2=ja,h2=Iu,p2=/MSIE .\./.test(qn),f2=Mh.Function,Dy=function(e){return p2?function(t,n){var r=h2(arguments.length,1)>2,i=l2(t)?t:f2(t),o=r?d2(arguments,2):void 0;return e(r?function(){u2(i,this,o)}:i,n)}:e},Ly={setTimeout:Dy(Mh.setTimeout),setInterval:Dy(Mh.setInterval)},Oy=Ly.setInterval;Me({global:!0,bind:!0,forced:te.setInterval!==Oy},{setInterval:Oy});var My=Ly.setTimeout;Me({global:!0,bind:!0,forced:te.setTimeout!==My},{setTimeout:My}),wh("Map",function(e){return function(){return e(this,arguments.length?arguments[0]:void 0)}},my);var m2=it,Fa=Array.isArray||function(e){return m2(e)=="Array"},v2=pe,g2=oe,Ny=at,_2=Lr,y2=l,Vy=function(){},S2=[],Uy=Pn("Reflect","construct"),Nh=/^\s*(?:class|function)\b/,b2=v2(Nh.exec),k2=!Nh.exec(Vy),Ms=function(e){if(!Ny(e))return!1;try{return Uy(Vy,S2,e),!0}catch(t){return!1}},By=function(e){if(!Ny(e))return!1;switch(_2(e)){case"AsyncFunction":case"GeneratorFunction":case"AsyncGeneratorFunction":return!1}try{return k2||!!b2(Nh,y2(e))}catch(t){return!0}};By.sham=!0;var wu=!Uy||g2(function(){var e;return Ms(Ms.call)||!Ms(Object)||!Ms(function(){e=!0})||e})?By:Ms,jy=Fa,T2=wu,x2=ot,I2=nt("species"),Fy=Array,w2=function(e){var t;return jy(e)&&(t=e.constructor,(T2(t)&&(t===Fy||jy(t.prototype))||x2(t)&&(t=t[I2])===null)&&(t=void 0)),t===void 0?Fy:t},Vh=function(e,t){return new(w2(e))(t===0?0:t)},E2=Mr,C2=yn,R2=Bt,A2=rn,P2=Vh,Gy=pe([].push),si=function(e){var t=e==1,n=e==2,r=e==3,i=e==4,o=e==6,a=e==7,s=e==5||o;return function(c,u,d,h){for(var _,y,b=R2(c),f=C2(b),g=E2(u,d),I=A2(f),w=0,j=h||P2,z=t?j(c,I):n||a?j(c,0):void 0;I>w;w++)if((s||w in f)&&(y=g(_=f[w],w,b),e))if(t)z[w]=y;else if(y)switch(e){case 3:return!0;case 5:return _;case 6:return w;case 2:Gy(z,_)}else switch(e){case 4:return!1;case 7:Gy(z,_)}return o?-1:r||i?i:z}},an={forEach:si(0),map:si(1),filter:si(2),some:si(3),every:si(4),find:si(5),findIndex:si(6),filterReject:si(7)},D2=oe,L2=dr,O2=nt("species"),Ns=function(e){return L2>=51||!D2(function(){var t=[];return(t.constructor={})[O2]=function(){return{foo:1}},t[e](Boolean).foo!==1})},M2=an.map;Me({target:"Array",proto:!0,forced:!Ns("map")},{map:function(e){return M2(this,e,arguments.length>1?arguments[1]:void 0)}});var N2=_e,V2=Fa,U2=TypeError,B2=Object.getOwnPropertyDescriptor,j2=N2&&!function(){if(this!==void 0)return!0;try{Object.defineProperty([],"length",{writable:!1}).length=1}catch(e){return e instanceof TypeError}}(),F2=TypeError,Hy=function(e){if(e>9007199254740991)throw F2("Maximum allowed index exceeded");return e},zy=Xn,G2=TypeError,Wy=function(e,t){if(!delete e[t])throw G2("Cannot delete property "+zy(t)+" of "+zy(e))},H2=Me,z2=Bt,W2=ai,J2=$n,K2=rn,q2=j2?function(e,t){if(V2(e)&&!B2(e,"length").writable)throw U2("Cannot set read only .length");return e.length=t}:function(e,t){return e.length=t},X2=Hy,Q2=Vh,Y2=Cs,Uh=Wy,$2=Ns("splice"),Z2=Math.max,eP=Math.min;H2({target:"Array",proto:!0,forced:!$2},{splice:function(e,t){var n,r,i,o,a,s,c=z2(this),u=K2(c),d=W2(e,u),h=arguments.length;for(h===0?n=r=0:h===1?(n=0,r=u-d):(n=h-2,r=eP(Z2(J2(t),0),u-d)),X2(u+n-r),i=Q2(c,r),o=0;o<r;o++)(a=d+o)in c&&Y2(i,o,c[a]);if(i.length=r,n<r){for(o=d;o<u-r;o++)s=o+n,(a=o+r)in c?c[s]=c[a]:Uh(c,s);for(o=u;o>u-r+n;o--)Uh(c,o-1)}else if(n>r)for(o=u-r;o>d;o--)s=o+n-1,(a=o+r-1)in c?c[s]=c[a]:Uh(c,s);for(o=0;o<n;o++)c[o+d]=arguments[o+2];return q2(c,u-r+n),i}});var tP=oe,Vs=function(e,t){var n=[][e];return!!n&&tP(function(){n.call(null,t||function(){return 1},1)})},nP=an.forEach,Bh=Vs("forEach")?[].forEach:function(e){return nP(this,e,arguments.length>1?arguments[1]:void 0)};Me({target:"Array",proto:!0,forced:[].forEach!=Bh},{forEach:Bh});var Jy=te,Ky=by,rP=Ty,jh=Bh,iP=Mn,qy=function(e){if(e&&e.forEach!==jh)try{iP(e,"forEach",jh)}catch(t){e.forEach=jh}};for(var Fh in Ky)Ky[Fh]&&qy(Jy[Fh]&&Jy[Fh].prototype);qy(rP);var aP=Me,oP=yn,sP=Sn,cP=Vs,uP=pe([].join),lP=oP!=Object,dP=cP("join",",");aP({target:"Array",proto:!0,forced:lP||!dP},{join:function(e){return uP(sP(this),e===void 0?",":e)}});var hP=an.filter;Me({target:"Array",proto:!0,forced:!Ns("filter")},{filter:function(e){return hP(this,e,arguments.length>1?arguments[1]:void 0)}});var pP=Me,fP=oe,mP=Fa,vP=ot,gP=Bt,_P=rn,Xy=Hy,Qy=Cs,yP=Vh,SP=Ns,bP=dr,Yy=nt("isConcatSpreadable"),kP=bP>=51||!fP(function(){var e=[];return e[Yy]=!1,e.concat()[0]!==e}),TP=SP("concat"),xP=function(e){if(!vP(e))return!1;var t=e[Yy];return t!==void 0?!!t:mP(e)};pP({target:"Array",proto:!0,arity:1,forced:!kP||!TP},{concat:function(e){var t,n,r,i,o,a=gP(this),s=yP(a,0),c=0;for(t=-1,r=arguments.length;t<r;t++)if(xP(o=t===-1?a:arguments[t]))for(i=_P(o),Xy(c+i),n=0;n<i;n++,c++)n in o&&Qy(s,c,o[n]);else Xy(c+1),Qy(s,c++,o);return s.length=c,s}});var $y=pe,IP=Qt,Gh=Date.prototype,Zy="Invalid Date",wP="toString",EP=$y(Gh.toString),CP=$y(Gh.getTime);String(new Date(NaN))!=Zy&&IP(Gh,wP,function(){var e=CP(this);return e==e?EP(this):Zy});var RP=$n,AP=Wt,PP=pt,DP=RangeError,e0=function(e){var t=AP(PP(this)),n="",r=RP(e);if(r<0||r==1/0)throw DP("Wrong number of repetitions");for(;r>0;(r>>>=1)&&(t+=t))1&r&&(n+=t);return n},t0=pe,LP=vr,n0=Wt,OP=pt,MP=t0(e0),NP=t0("".slice),VP=Math.ceil,r0=function(e){return function(t,n,r){var i,o,a=n0(OP(t)),s=LP(n),c=a.length,u=r===void 0?" ":n0(r);return s<=c||u==""?a:((o=MP(u,VP((i=s-c)/u.length))).length>i&&(o=NP(o,0,i)),e?a+o:o+a)}},UP={start:r0(!1),end:r0(!0)},BP=/Version\/10(?:\.\d+){1,2}(?: [\w./]+)?(?: Mobile\/\w+)? Safari\//.test(qn),jP=UP.start;Me({target:"String",proto:!0,forced:BP},{padStart:function(e){return jP(this,e,arguments.length>1?arguments[1]:void 0)}});var FP=It,i0=function(){var e=FP(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},Hh=oe,zh=te.RegExp,Wh=Hh(function(){var e=zh("a","y");return e.lastIndex=2,e.exec("abcd")!=null}),GP=Wh||Hh(function(){return!zh("a","y").sticky}),a0={BROKEN_CARET:Wh||Hh(function(){var e=zh("^r","gy");return e.lastIndex=2,e.exec("str")!=null}),MISSED_STICKY:GP,UNSUPPORTED_Y:Wh},HP=oe,zP=te.RegExp,o0=HP(function(){var e=zP(".","s");return!(e.dotAll&&e.exec(`
76
- `)&&e.flags==="s")}),WP=oe,JP=te.RegExp,s0=WP(function(){var e=JP("(?<a>b)","g");return e.exec("b").groups.a!=="b"||"b".replace(e,"$<a>c")!=="bc"}),Ga=Qe,Eu=pe,KP=Wt,qP=i0,XP=a0,QP=Dr.exports,YP=Ua,$P=Xe.get,ZP=o0,eD=s0,tD=QP("native-string-replace",String.prototype.replace),Cu=RegExp.prototype.exec,Jh=Cu,nD=Eu("".charAt),rD=Eu("".indexOf),iD=Eu("".replace),Kh=Eu("".slice),qh=function(){var e=/a/,t=/b*/g;return Ga(Cu,e,"a"),Ga(Cu,t,"a"),e.lastIndex!==0||t.lastIndex!==0}(),c0=XP.BROKEN_CARET,Xh=/()??/.exec("")[1]!==void 0;(qh||Xh||c0||ZP||eD)&&(Jh=function(e){var t,n,r,i,o,a,s,c=this,u=$P(c),d=KP(e),h=u.raw;if(h)return h.lastIndex=c.lastIndex,t=Ga(Jh,h,d),c.lastIndex=h.lastIndex,t;var _=u.groups,y=c0&&c.sticky,b=Ga(qP,c),f=c.source,g=0,I=d;if(y&&(b=iD(b,"y",""),rD(b,"g")===-1&&(b+="g"),I=Kh(d,c.lastIndex),c.lastIndex>0&&(!c.multiline||c.multiline&&nD(d,c.lastIndex-1)!==`
77
- `)&&(f="(?: "+f+")",I=" "+I,g++),n=new RegExp("^(?:"+f+")",b)),Xh&&(n=new RegExp("^"+f+"$(?!\\s)",b)),qh&&(r=c.lastIndex),i=Ga(Cu,y?n:c,I),y?i?(i.input=Kh(i.input,g),i[0]=Kh(i[0],g),i.index=c.lastIndex,c.lastIndex+=i[0].length):c.lastIndex=0:qh&&i&&(c.lastIndex=c.global?i.index+i[0].length:r),Xh&&i&&i.length>1&&Ga(tD,i[0],n,function(){for(o=1;o<arguments.length-2;o++)arguments[o]===void 0&&(i[o]=void 0)}),i&&_)for(i.groups=a=YP(null),o=0;o<_.length;o++)a[(s=_[o])[0]]=i[s[1]];return i});var Ru=Jh;Me({target:"RegExp",proto:!0,forced:/./.exec!==Ru},{exec:Ru});var u0=pe,l0=Qt,aD=Ru,d0=oe,h0=nt,oD=Mn,sD=h0("species"),Qh=RegExp.prototype,Yh=function(e,t,n,r){var i=h0(e),o=!d0(function(){var u={};return u[i]=function(){return 7},""[e](u)!=7}),a=o&&!d0(function(){var u=!1,d=/a/;return e==="split"&&((d={}).constructor={},d.constructor[sD]=function(){return d},d.flags="",d[i]=/./[i]),d.exec=function(){return u=!0,null},d[i](""),!u});if(!o||!a||n){var s=u0(/./[i]),c=t(i,""[e],function(u,d,h,_,y){var b=u0(u),f=d.exec;return f===aD||f===Qh.exec?o&&!y?{done:!0,value:s(d,h,_)}:{done:!0,value:b(h,d,_)}:{done:!1}});l0(String.prototype,e,c[0]),l0(Qh,i,c[1])}r&&oD(Qh[i],"sham",!0)},cD=Rh.charAt,p0=function(e,t,n){return t+(n?cD(e,t).length:1)},$h=pe,uD=Bt,lD=Math.floor,Zh=$h("".charAt),dD=$h("".replace),ep=$h("".slice),hD=/\$([$&'`]|\d{1,2}|<[^>]*>)/g,pD=/\$([$&'`]|\d{1,2})/g,f0=Qe,fD=It,mD=at,vD=it,gD=Ru,_D=TypeError,tp=function(e,t){var n=e.exec;if(mD(n)){var r=f0(n,e,t);return r!==null&&fD(r),r}if(vD(e)==="RegExp")return f0(gD,e,t);throw _D("RegExp#exec called on incompatible receiver")},yD=ji,m0=Qe,Au=pe,SD=Yh,bD=oe,kD=It,TD=at,xD=Ct,ID=$n,wD=vr,Ha=Wt,ED=pt,CD=p0,RD=Xt,AD=function(e,t,n,r,i,o){var a=n+e.length,s=r.length,c=pD;return i!==void 0&&(i=uD(i),c=hD),dD(o,c,function(u,d){var h;switch(Zh(d,0)){case"$":return"$";case"&":return e;case"`":return ep(t,0,n);case"'":return ep(t,a);case"<":h=i[ep(d,1,-1)];break;default:var _=+d;if(_===0)return u;if(_>s){var y=lD(_/10);return y===0?u:y<=s?r[y-1]===void 0?Zh(d,1):r[y-1]+Zh(d,1):u}h=r[_-1]}return h===void 0?"":h})},PD=tp,np=nt("replace"),DD=Math.max,LD=Math.min,OD=Au([].concat),rp=Au([].push),v0=Au("".indexOf),g0=Au("".slice),MD="a".replace(/./,"$0")==="$0",_0=!!/./[np]&&/./[np]("a","$0")==="",ND=!bD(function(){var e=/./;return e.exec=function(){var t=[];return t.groups={a:"7"},t},"".replace(e,"$<a>")!=="7"});SD("replace",function(e,t,n){var r=_0?"$":"$0";return[function(i,o){var a=ED(this),s=xD(i)?void 0:RD(i,np);return s?m0(s,i,a,o):m0(t,Ha(a),i,o)},function(i,o){var a=kD(this),s=Ha(i);if(typeof o=="string"&&v0(o,r)===-1&&v0(o,"$<")===-1){var c=n(t,a,s,o);if(c.done)return c.value}var u=TD(o);u||(o=Ha(o));var d=a.global;if(d){var h=a.unicode;a.lastIndex=0}for(var _=[];;){var y=PD(a,s);if(y===null||(rp(_,y),!d))break;Ha(y[0])===""&&(a.lastIndex=CD(s,wD(a.lastIndex),h))}for(var b,f="",g=0,I=0;I<_.length;I++){for(var w=Ha((y=_[I])[0]),j=DD(LD(ID(y.index),s.length),0),z=[],$=1;$<y.length;$++)rp(z,(b=y[$])===void 0?b:String(b));var ue=y.groups;if(u){var L=OD([w],z,j,s);ue!==void 0&&rp(L,ue);var k=Ha(yD(o,void 0,L))}else k=AD(w,s,j,z,ue,o);j>=g&&(f+=g0(s,g,j)+k,g=j+w.length)}return f+g0(s,g)}]},!ND||!MD||_0);var VD=Qe,UD=xt,BD=bn,jD=i0,y0=RegExp.prototype,S0=function(e){var t=e.flags;return t!==void 0||"flags"in y0||UD(e,"flags")||!BD(y0,e)?t:VD(jD,e)},FD=Yn.PROPER,GD=Qt,HD=It,b0=Wt,zD=oe,WD=S0,k0="toString",T0=RegExp.prototype.toString,JD=zD(function(){return T0.call({source:"a",flags:"b"})!="/a/b"}),KD=FD&&T0.name!=k0;(JD||KD)&&GD(RegExp.prototype,k0,function(){var e=HD(this);return"/"+b0(e.source)+"/"+b0(WD(e))},{unsafe:!0});var qD=oe,XD=nt("iterator"),x0=!qD(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(r,i){t.delete("b"),n+=i+r}),!t.sort||e.href!=="http://a/c%20d?a=1&c=3"||t.get("c")!=="3"||String(new URLSearchParams("?a=1"))!=="a=1"||!t[XD]||new URL("https://a@b").username!=="a"||new URLSearchParams(new URLSearchParams("a=b")).get("a")!=="b"||new URL("http://\u0442\u0435\u0441\u0442").host!=="xn--e1aybc"||new URL("http://a#\u0431").hash!=="#%D0%B1"||n!=="a1c3"||new URL("http://x",void 0).host!=="x"}),I0=yu,QD=Math.floor,ip=function(e,t){var n=e.length,r=QD(n/2);return n<8?YD(e,t):$D(e,ip(I0(e,0,r),t),ip(I0(e,r),t),t)},YD=function(e,t){for(var n,r,i=e.length,o=1;o<i;){for(r=o,n=e[o];r&&t(e[r-1],n)>0;)e[r]=e[--r];r!==o++&&(e[r]=n)}return e},$D=function(e,t,n,r){for(var i=t.length,o=n.length,a=0,s=0;a<i||s<o;)e[a+s]=a<i&&s<o?r(t[a],n[s])<=0?t[a++]:n[s++]:a<i?t[a++]:n[s++];return e},w0=ip,ap=Me,za=te,Pu=Qe,gr=pe,ZD=_e,E0=x0,C0=Qt,eL=Ps,tL=Bi,nL=L_,op=Xe,R0=oi,sp=at,rL=xt,iL=Mr,aL=Lr,oL=It,A0=ot,Tn=Wt,sL=Ua,P0=et,cp=bu,cL=Rs,Wa=Iu,uL=w0,lL=nt("iterator"),Du="URLSearchParams",D0="URLSearchParamsIterator",L0=op.set,Zn=op.getterFor(Du),dL=op.getterFor(D0),hL=Object.getOwnPropertyDescriptor,up=function(e){if(!ZD)return za[e];var t=hL(za,e);return t&&t.value},O0=up("fetch"),Lu=up("Request"),Us=up("Headers"),lp=Lu&&Lu.prototype,M0=Us&&Us.prototype,pL=za.RegExp,fL=za.TypeError,N0=za.decodeURIComponent,mL=za.encodeURIComponent,vL=gr("".charAt),V0=gr([].join),Fi=gr([].push),dp=gr("".replace),gL=gr([].shift),U0=gr([].splice),B0=gr("".split),_L=gr("".slice),yL=/\+/g,j0=Array(4),SL=function(e){return j0[e-1]||(j0[e-1]=pL("((?:%[\\da-f]{2}){"+e+"})","gi"))},bL=function(e){try{return N0(e)}catch(t){return e}},F0=function(e){var t=dp(e,yL," "),n=4;try{return N0(t)}catch(r){for(;n;)t=dp(t,SL(n--),bL);return t}},kL=/[!'()~]|%20/g,TL={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+"},xL=function(e){return TL[e]},G0=function(e){return dp(mL(e),kL,xL)},hp=nL(function(e,t){L0(this,{type:D0,iterator:cp(Zn(e).entries),kind:t})},"Iterator",function(){var e=dL(this),t=e.kind,n=e.iterator.next(),r=n.value;return n.done||(n.value=t==="keys"?r.key:t==="values"?r.value:[r.key,r.value]),n},!0),H0=function(e){this.entries=[],this.url=null,e!==void 0&&(A0(e)?this.parseObject(e):this.parseQuery(typeof e=="string"?vL(e,0)==="?"?_L(e,1):e:Tn(e)))};H0.prototype={type:Du,bindURL:function(e){this.url=e,this.update()},parseObject:function(e){var t,n,r,i,o,a,s,c=cL(e);if(c)for(n=(t=cp(e,c)).next;!(r=Pu(n,t)).done;){if(o=(i=cp(oL(r.value))).next,(a=Pu(o,i)).done||(s=Pu(o,i)).done||!Pu(o,i).done)throw fL("Expected sequence with length 2");Fi(this.entries,{key:Tn(a.value),value:Tn(s.value)})}else for(var u in e)rL(e,u)&&Fi(this.entries,{key:u,value:Tn(e[u])})},parseQuery:function(e){if(e)for(var t,n,r=B0(e,"&"),i=0;i<r.length;)(t=r[i++]).length&&(n=B0(t,"="),Fi(this.entries,{key:F0(gL(n)),value:F0(V0(n,"="))}))},serialize:function(){for(var e,t=this.entries,n=[],r=0;r<t.length;)e=t[r++],Fi(n,G0(e.key)+"="+G0(e.value));return V0(n,"&")},update:function(){this.entries.length=0,this.parseQuery(this.url.query)},updateURL:function(){this.url&&this.url.update()}};var Ou=function(){R0(this,Bs);var e=arguments.length>0?arguments[0]:void 0;L0(this,new H0(e))},Bs=Ou.prototype;if(eL(Bs,{append:function(e,t){Wa(arguments.length,2);var n=Zn(this);Fi(n.entries,{key:Tn(e),value:Tn(t)}),n.updateURL()},delete:function(e){Wa(arguments.length,1);for(var t=Zn(this),n=t.entries,r=Tn(e),i=0;i<n.length;)n[i].key===r?U0(n,i,1):i++;t.updateURL()},get:function(e){Wa(arguments.length,1);for(var t=Zn(this).entries,n=Tn(e),r=0;r<t.length;r++)if(t[r].key===n)return t[r].value;return null},getAll:function(e){Wa(arguments.length,1);for(var t=Zn(this).entries,n=Tn(e),r=[],i=0;i<t.length;i++)t[i].key===n&&Fi(r,t[i].value);return r},has:function(e){Wa(arguments.length,1);for(var t=Zn(this).entries,n=Tn(e),r=0;r<t.length;)if(t[r++].key===n)return!0;return!1},set:function(e,t){Wa(arguments.length,1);for(var n,r=Zn(this),i=r.entries,o=!1,a=Tn(e),s=Tn(t),c=0;c<i.length;c++)(n=i[c]).key===a&&(o?U0(i,c--,1):(o=!0,n.value=s));o||Fi(i,{key:a,value:s}),r.updateURL()},sort:function(){var e=Zn(this);uL(e.entries,function(t,n){return t.key>n.key?1:-1}),e.updateURL()},forEach:function(e){for(var t,n=Zn(this).entries,r=iL(e,arguments.length>1?arguments[1]:void 0),i=0;i<n.length;)r((t=n[i++]).value,t.key,this)},keys:function(){return new hp(this,"keys")},values:function(){return new hp(this,"values")},entries:function(){return new hp(this,"entries")}},{enumerable:!0}),C0(Bs,lL,Bs.entries,{name:"entries"}),C0(Bs,"toString",function(){return Zn(this).serialize()},{enumerable:!0}),tL(Ou,Du),ap({global:!0,constructor:!0,forced:!E0},{URLSearchParams:Ou}),!E0&&sp(Us)){var IL=gr(M0.has),wL=gr(M0.set),z0=function(e){if(A0(e)){var t,n=e.body;if(aL(n)===Du)return t=e.headers?new Us(e.headers):new Us,IL(t,"content-type")||wL(t,"content-type","application/x-www-form-urlencoded;charset=UTF-8"),sL(e,{body:P0(0,Tn(n)),headers:P0(0,t)})}return e};if(sp(O0)&&ap({global:!0,enumerable:!0,dontCallGetSet:!0,forced:!0},{fetch:function(e){return O0(e,arguments.length>1?z0(arguments[1]):{})}}),sp(Lu)){var pp=function(e){return R0(this,lp),new Lu(e,arguments.length>1?z0(arguments[1]):{})};lp.constructor=pp,pp.prototype=lp,ap({global:!0,constructor:!0,dontCallGetSet:!0,forced:!0},{Request:pp})}}var EL={URLSearchParams:Ou,getState:Zn},CL=Object.is||function(e,t){return e===t?e!==0||1/e==1/t:e!=e&&t!=t},RL=Qe,AL=It,PL=Ct,DL=pt,W0=CL,J0=Wt,LL=Xt,OL=tp;Yh("search",function(e,t,n){return[function(r){var i=DL(this),o=PL(r)?void 0:LL(r,e);return o?RL(o,r,i):new RegExp(r)[e](J0(i))},function(r){var i=AL(this),o=J0(r),a=n(t,i,o);if(a.done)return a.value;var s=i.lastIndex;W0(s,0)||(i.lastIndex=0);var c=OL(i,o);return W0(i.lastIndex,s)||(i.lastIndex=s),c===null?-1:c.index}]}),new Date().getTime();var fp=0,on=function(){return new Date().getTime()+fp},K0=function(){var e=new Date;return e.setTime(on()),e.toLocaleString()},ML=Qe,NL=It,VL=Ct,UL=vr,mp=Wt,BL=pt,jL=Xt,FL=p0,q0=tp;Yh("match",function(e,t,n){return[function(r){var i=BL(this),o=VL(r)?void 0:jL(r,e);return o?ML(o,r,i):new RegExp(r)[e](mp(i))},function(r){var i=NL(this),o=mp(r),a=n(t,i,o);if(a.done)return a.value;if(!i.global)return q0(i,o);var s=i.unicode;i.lastIndex=0;for(var c,u=[],d=0;(c=q0(i,o))!==null;){var h=mp(c[0]);u[d]=h,h===""&&(i.lastIndex=FL(o,UL(i.lastIndex),s)),d++}return d===0?null:u}]});var GL=ot,HL=it,zL=nt("match"),X0=function(e){var t;return GL(e)&&((t=e[zL])!==void 0?!!t:HL(e)=="RegExp")},WL=At.f,JL=_e,vp=te,js=pe,KL=ys,qL=xu,XL=Mn,QL=ii.f,Q0=bn,YL=X0,Y0=Wt,$L=S0,$0=a0,ZL=function(e,t,n){n in e||WL(e,n,{configurable:!0,get:function(){return t[n]},set:function(r){t[n]=r}})},eO=Qt,tO=oe,nO=xt,rO=Xe.enforce,iO=Ds,Z0=o0,eS=s0,aO=nt("match"),ci=vp.RegExp,Ja=ci.prototype,oO=vp.SyntaxError,sO=js(Ja.exec),Mu=js("".charAt),tS=js("".replace),nS=js("".indexOf),cO=js("".slice),uO=/^\?<[^\s\d!#%&*+<=>@^][^\s!#%&*+<=>@^]*>/,Gi=/a/g,gp=/a/g,lO=new ci(Gi)!==Gi,rS=$0.MISSED_STICKY,dO=$0.UNSUPPORTED_Y,hO=JL&&(!lO||rS||Z0||eS||tO(function(){return gp[aO]=!1,ci(Gi)!=Gi||ci(gp)==gp||ci(Gi,"i")!="/a/i"}));if(KL("RegExp",hO)){for(var Hi=function(e,t){var n,r,i,o,a,s,c=Q0(Ja,this),u=YL(e),d=t===void 0,h=[],_=e;if(!c&&u&&d&&e.constructor===Hi)return e;if((u||Q0(Ja,e))&&(e=e.source,d&&(t=$L(_))),e=e===void 0?"":Y0(e),t=t===void 0?"":Y0(t),_=e,Z0&&"dotAll"in Gi&&(r=!!t&&nS(t,"s")>-1)&&(t=tS(t,/s/g,"")),n=t,rS&&"sticky"in Gi&&(i=!!t&&nS(t,"y")>-1)&&dO&&(t=tS(t,/y/g,"")),eS&&(o=function(y){for(var b,f=y.length,g=0,I="",w=[],j={},z=!1,$=!1,ue=0,L="";g<=f;g++){if((b=Mu(y,g))==="\\")b+=Mu(y,++g);else if(b==="]")z=!1;else if(!z)switch(!0){case b==="[":z=!0;break;case b==="(":sO(uO,cO(y,g+1))&&(g+=2,$=!0),I+=b,ue++;continue;case(b===">"&&$):if(L===""||nO(j,L))throw new oO("Invalid capture group name");j[L]=!0,w[w.length]=[L,ue],$=!1,L="";continue}$?L+=b:I+=b}return[I,w]}(e),e=o[0],h=o[1]),a=qL(ci(e,t),c?this:Ja,Hi),(r||i||h.length)&&(s=rO(a),r&&(s.dotAll=!0,s.raw=Hi(function(y){for(var b,f=y.length,g=0,I="",w=!1;g<=f;g++)(b=Mu(y,g))!=="\\"?w||b!=="."?(b==="["?w=!0:b==="]"&&(w=!1),I+=b):I+="[\\s\\S]":I+=b+Mu(y,++g);return I}(e),n)),i&&(s.sticky=!0),h.length&&(s.groups=h)),e!==_)try{XL(a,"source",_===""?"(?:)":_)}catch(y){}return a},iS=QL(ci),aS=0;iS.length>aS;)ZL(Hi,ci,iS[aS++]);Ja.constructor=Hi,Hi.prototype=Ja,eO(vp,"RegExp",Hi,{constructor:!0})}iO("RegExp");var oS=pe(1 .valueOf),sS=`
78
- \v\f\r \xA0\u1680\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028\u2029\uFEFF`,pO=pt,fO=Wt,cS=pe("".replace),Nu=`[
79
- \v\f\r \xA0\u1680\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028\u2029\uFEFF]`,mO=RegExp("^"+Nu+Nu+"*"),vO=RegExp(Nu+Nu+"*$"),_p=function(e){return function(t){var n=fO(pO(t));return 1&e&&(n=cS(n,mO,"")),2&e&&(n=cS(n,vO,"")),n}},Vu={start:_p(1),end:_p(2),trim:_p(3)},gO=_e,yp=te,uS=pe,_O=ys,yO=Qt,lS=xt,SO=xu,bO=bn,kO=Ri,dS=Ca,TO=oe,xO=ii.f,IO=Se.f,wO=At.f,EO=oS,CO=Vu.trim,hS="Number",ui=yp.Number,Sp=ui.prototype,RO=yp.TypeError,AO=uS("".slice),Uu=uS("".charCodeAt),PO=function(e){var t=dS(e,"number");return typeof t=="bigint"?t:DO(t)},DO=function(e){var t,n,r,i,o,a,s,c,u=dS(e,"number");if(kO(u))throw RO("Cannot convert a Symbol value to a number");if(typeof u=="string"&&u.length>2){if(u=CO(u),(t=Uu(u,0))===43||t===45){if((n=Uu(u,2))===88||n===120)return NaN}else if(t===48){switch(Uu(u,1)){case 66:case 98:r=2,i=49;break;case 79:case 111:r=8,i=55;break;default:return+u}for(a=(o=AO(u,2)).length,s=0;s<a;s++)if((c=Uu(o,s))<48||c>i)return NaN;return parseInt(o,r)}}return+u};if(_O(hS,!ui(" 0o1")||!ui("0b1")||ui("+0x1"))){for(var Bu,Ka=function(e){var t=arguments.length<1?0:ui(PO(e)),n=this;return bO(Sp,n)&&TO(function(){EO(n)})?SO(Object(t),n,Ka):t},pS=gO?xO(ui):"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(","),bp=0;pS.length>bp;bp++)lS(ui,Bu=pS[bp])&&!lS(Ka,Bu)&&wO(Ka,Bu,IO(ui,Bu));Ka.prototype=Sp,Sp.constructor=Ka,yO(yp,hS,Ka,{constructor:!0})}var LO=gs.includes,OO=vu;Me({target:"Array",proto:!0,forced:oe(function(){return!Array(1).includes()})},{includes:function(e){return LO(this,e,arguments.length>1?arguments[1]:void 0)}}),OO("includes");var MO=X0,NO=TypeError,fS=function(e){if(MO(e))throw NO("The method doesn't accept regular expressions");return e},VO=nt("match"),mS=function(e){var t=/./;try{"/./"[e](t)}catch(n){try{return t[VO]=!1,"/./"[e](t)}catch(r){}}return!1},UO=Me,BO=fS,jO=pt,vS=Wt,FO=mS,GO=pe("".indexOf);UO({target:"String",proto:!0,forced:!FO("includes")},{includes:function(e){return!!~GO(vS(jO(this)),vS(BO(e)),arguments.length>1?arguments[1]:void 0)}});var HO=Me,zO=gs.indexOf,WO=Vs,kp=pe([].indexOf),gS=!!kp&&1/kp([1],1,-0)<0,JO=WO("indexOf");HO({target:"Array",proto:!0,forced:gS||!JO},{indexOf:function(e){var t=arguments.length>1?arguments[1]:void 0;return gS?kp(this,e,t)||0:zO(this,e,t)}});var KO=Bt,_S=xs,qO=C_;Me({target:"Object",stat:!0,forced:oe(function(){_S(1)}),sham:!qO},{getPrototypeOf:function(e){return _S(KO(e))}});var XO=ji,QO=Ut,YO=It;Me({target:"Reflect",stat:!0,forced:!oe(function(){Reflect.apply(function(){})})},{apply:function(e,t,n){return XO(QO(e),t,YO(n))}});var $O=_e,ZO=Yn.EXISTS,yS=pe,eM=At.f,SS=Function.prototype,tM=yS(SS.toString),bS=/function\b(?:\s|\/\*[\S\s]*?\*\/|\/\/[^\n\r]*[\n\r]+)*([^\s(/]*)/,nM=yS(bS.exec);$O&&!ZO&&eM(SS,"name",{configurable:!0,get:function(){try{return nM(bS,tM(this))[1]}catch(e){return""}}});var rM=Me,kS=Date,iM=pe(kS.prototype.getTime);rM({target:"Date",stat:!0},{now:function(){return iM(new kS)}});var Fs,qa,TS,Tp,Gs=it(te.process)=="process",aM=wu,oM=Xn,sM=TypeError,xS=function(e){if(aM(e))return e;throw sM(oM(e)+" is not a constructor")},IS=It,cM=xS,uM=Ct,lM=nt("species"),ju=function(e,t){var n,r=IS(e).constructor;return r===void 0||uM(n=IS(r)[lM])?t:cM(n)},wS=/(?:ipad|iphone|ipod).*applewebkit/i.test(qn),xn=te,dM=ji,hM=Mr,ES=at,pM=xt,fM=oe,CS=b_,mM=ja,RS=pr,vM=Iu,gM=wS,_M=Gs,xp=xn.setImmediate,Ip=xn.clearImmediate,yM=xn.process,wp=xn.Dispatch,SM=xn.Function,AS=xn.MessageChannel,bM=xn.String,Ep=0,Hs={},kM="onreadystatechange";try{Fs=xn.location}catch(e){}var Cp=function(e){if(pM(Hs,e)){var t=Hs[e];delete Hs[e],t()}},Rp=function(e){return function(){Cp(e)}},PS=function(e){Cp(e.data)},DS=function(e){xn.postMessage(bM(e),Fs.protocol+"//"+Fs.host)};xp&&Ip||(xp=function(e){vM(arguments.length,1);var t=ES(e)?e:SM(e),n=mM(arguments,1);return Hs[++Ep]=function(){dM(t,void 0,n)},qa(Ep),Ep},Ip=function(e){delete Hs[e]},_M?qa=function(e){yM.nextTick(Rp(e))}:wp&&wp.now?qa=function(e){wp.now(Rp(e))}:AS&&!gM?(Tp=(TS=new AS).port2,TS.port1.onmessage=PS,qa=hM(Tp.postMessage,Tp)):xn.addEventListener&&ES(xn.postMessage)&&!xn.importScripts&&Fs&&Fs.protocol!=="file:"&&!fM(DS)?(qa=DS,xn.addEventListener("message",PS,!1)):qa=kM in RS("script")?function(e){CS.appendChild(RS("script")).onreadystatechange=function(){CS.removeChild(this),Cp(e)}}:function(e){setTimeout(Rp(e),0)});var zs,zi,Ws,Xa,Ap,Pp,Dp,LS,OS={set:xp,clear:Ip},TM=te,xM=/ipad|iphone|ipod/i.test(qn)&&TM.Pebble!==void 0,IM=/web0s(?!.*chrome)/i.test(qn),Wi=te,MS=Mr,wM=Se.f,Lp=OS.set,EM=wS,CM=xM,RM=IM,Op=Gs,NS=Wi.MutationObserver||Wi.WebKitMutationObserver,VS=Wi.document,US=Wi.process,Fu=Wi.Promise,BS=wM(Wi,"queueMicrotask"),jS=BS&&BS.value;jS||(zs=function(){var e,t;for(Op&&(e=US.domain)&&e.exit();zi;){t=zi.fn,zi=zi.next;try{t()}catch(n){throw zi?Xa():Ws=void 0,n}}Ws=void 0,e&&e.enter()},EM||Op||RM||!NS||!VS?!CM&&Fu&&Fu.resolve?((Dp=Fu.resolve(void 0)).constructor=Fu,LS=MS(Dp.then,Dp),Xa=function(){LS(zs)}):Op?Xa=function(){US.nextTick(zs)}:(Lp=MS(Lp,Wi),Xa=function(){Lp(zs)}):(Ap=!0,Pp=VS.createTextNode(""),new NS(zs).observe(Pp,{characterData:!0}),Xa=function(){Pp.data=Ap=!Ap}));var AM=jS||function(e){var t={fn:e,next:void 0};Ws&&(Ws.next=t),zi||(zi=t,Xa()),Ws=t},PM=te,Mp=function(e){try{return{error:!1,value:e()}}catch(t){return{error:!0,value:t}}},FS=function(){this.head=null,this.tail=null};FS.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 DM=FS,Js=te.Promise,GS=typeof Deno=="object"&&Deno&&typeof Deno.version=="object",LM=!GS&&!Gs&&typeof window=="object"&&typeof document=="object",OM=te,Ks=Js,MM=at,NM=ys,VM=l,UM=nt,BM=LM,jM=GS,Np=dr;Ks&&Ks.prototype;var FM=UM("species"),HS=!1,zS=MM(OM.PromiseRejectionEvent),GM=NM("Promise",function(){var e=VM(Ks),t=e!==String(Ks);if(!t&&Np===66)return!0;if(!Np||Np<51||!/native code/.test(e)){var n=new Ks(function(i){i(1)}),r=function(i){i(function(){},function(){})};if((n.constructor={})[FM]=r,!(HS=n.then(function(){})instanceof r))return!0}return!t&&(BM||jM)&&!zS}),Ji={CONSTRUCTOR:GM,REJECTION_EVENT:zS,SUBCLASSING:HS},Qa={},WS=Ut,HM=TypeError,zM=function(e){var t,n;this.promise=new e(function(r,i){if(t!==void 0||n!==void 0)throw HM("Bad Promise constructor");t=r,n=i}),this.resolve=WS(t),this.reject=WS(n)};Qa.f=function(e){return new zM(e)};var Vp,JS,KS,WM=Me,Gu=Gs,li=te,Ya=Qe,qS=Qt,XS=Ba,JM=Bi,KM=Ds,qM=Ut,Hu=at,XM=ot,QM=oi,YM=ju,QS=OS.set,Up=AM,$M=function(e,t){var n=PM.console;n&&n.error&&(arguments.length==1?n.error(e):n.error(e,t))},ZM=Mp,eN=DM,YS=Xe,zu=Js,$S=Qa,Wu="Promise",ZS=Ji.CONSTRUCTOR,tN=Ji.REJECTION_EVENT,nN=Ji.SUBCLASSING,Bp=YS.getterFor(Wu),rN=YS.set,$a=zu&&zu.prototype,Za=zu,Ju=$a,eb=li.TypeError,jp=li.document,Fp=li.process,Gp=$S.f,iN=Gp,aN=!!(jp&&jp.createEvent&&li.dispatchEvent),tb="unhandledrejection",nb=function(e){var t;return!(!XM(e)||!Hu(t=e.then))&&t},rb=function(e,t){var n,r,i,o=t.value,a=t.state==1,s=a?e.ok:e.fail,c=e.resolve,u=e.reject,d=e.domain;try{s?(a||(t.rejection===2&&sN(t),t.rejection=1),s===!0?n=o:(d&&d.enter(),n=s(o),d&&(d.exit(),i=!0)),n===e.promise?u(eb("Promise-chain cycle")):(r=nb(n))?Ya(r,n,c,u):c(n)):u(o)}catch(h){d&&!i&&d.exit(),u(h)}},ib=function(e,t){e.notified||(e.notified=!0,Up(function(){for(var n,r=e.reactions;n=r.get();)rb(n,e);e.notified=!1,t&&!e.rejection&&oN(e)}))},ab=function(e,t,n){var r,i;aN?((r=jp.createEvent("Event")).promise=t,r.reason=n,r.initEvent(e,!1,!0),li.dispatchEvent(r)):r={promise:t,reason:n},!tN&&(i=li["on"+e])?i(r):e===tb&&$M("Unhandled promise rejection",n)},oN=function(e){Ya(QS,li,function(){var t,n=e.facade,r=e.value;if(ob(e)&&(t=ZM(function(){Gu?Fp.emit("unhandledRejection",r,n):ab(tb,n,r)}),e.rejection=Gu||ob(e)?2:1,t.error))throw t.value})},ob=function(e){return e.rejection!==1&&!e.parent},sN=function(e){Ya(QS,li,function(){var t=e.facade;Gu?Fp.emit("rejectionHandled",t):ab("rejectionhandled",t,e.value)})},eo=function(e,t,n){return function(r){e(t,r,n)}},to=function(e,t,n){e.done||(e.done=!0,n&&(e=n),e.value=t,e.state=2,ib(e,!0))},Hp=function(e,t,n){if(!e.done){e.done=!0,n&&(e=n);try{if(e.facade===t)throw eb("Promise can't be resolved itself");var r=nb(t);r?Up(function(){var i={done:!1};try{Ya(r,t,eo(Hp,i,e),eo(to,i,e))}catch(o){to(i,o,e)}}):(e.value=t,e.state=1,ib(e,!1))}catch(i){to({done:!1},i,e)}}};if(ZS&&(Ju=(Za=function(e){QM(this,Ju),qM(e),Ya(Vp,this);var t=Bp(this);try{e(eo(Hp,t),eo(to,t))}catch(n){to(t,n)}}).prototype,(Vp=function(e){rN(this,{type:Wu,done:!1,notified:!1,parent:!1,reactions:new eN,rejection:!1,state:0,value:void 0})}).prototype=qS(Ju,"then",function(e,t){var n=Bp(this),r=Gp(YM(this,Za));return n.parent=!0,r.ok=!Hu(e)||e,r.fail=Hu(t)&&t,r.domain=Gu?Fp.domain:void 0,n.state==0?n.reactions.add(r):Up(function(){rb(r,n)}),r.promise}),JS=function(){var e=new Vp,t=Bp(e);this.promise=e,this.resolve=eo(Hp,t),this.reject=eo(to,t)},$S.f=Gp=function(e){return e===Za||e===void 0?new JS(e):iN(e)},Hu(zu)&&$a!==Object.prototype)){KS=$a.then,nN||qS($a,"then",function(e,t){var n=this;return new Za(function(r,i){Ya(KS,n,r,i)}).then(e,t)},{unsafe:!0});try{delete $a.constructor}catch(e){}XS&&XS($a,Ju)}WM({global:!0,constructor:!0,wrap:!0,forced:ZS},{Promise:Za}),JM(Za,Wu,!1),KM(Wu);var cN=Js,sb=Ji.CONSTRUCTOR||!Tu(function(e){cN.all(e).then(void 0,function(){})}),uN=Qe,lN=Ut,dN=Qa,hN=Mp,pN=As;Me({target:"Promise",stat:!0,forced:sb},{all:function(e){var t=this,n=dN.f(t),r=n.resolve,i=n.reject,o=hN(function(){var a=lN(t.resolve),s=[],c=0,u=1;pN(e,function(d){var h=c++,_=!1;u++,uN(a,t,d).then(function(y){_||(_=!0,s[h]=y,--u||r(s))},i)}),--u||r(s)});return o.error&&i(o.value),n.promise}});var fN=Me,mN=Ji.CONSTRUCTOR,zp=Js,vN=Pn,gN=at,_N=Qt,cb=zp&&zp.prototype;if(fN({target:"Promise",proto:!0,forced:mN,real:!0},{catch:function(e){return this.then(void 0,e)}}),gN(zp)){var ub=vN("Promise").prototype.catch;cb.catch!==ub&&_N(cb,"catch",ub,{unsafe:!0})}var yN=Qe,SN=Ut,bN=Qa,kN=Mp,TN=As;Me({target:"Promise",stat:!0,forced:sb},{race:function(e){var t=this,n=bN.f(t),r=n.reject,i=kN(function(){var o=SN(t.resolve);TN(e,function(a){yN(o,t,a).then(n.resolve,r)})});return i.error&&r(i.value),n.promise}});var xN=Qe,IN=Qa;Me({target:"Promise",stat:!0,forced:Ji.CONSTRUCTOR},{reject:function(e){var t=IN.f(this);return xN(t.reject,void 0,e),t.promise}});var wN=It,EN=ot,CN=Qa,lb=function(e,t){if(wN(e),EN(t)&&t.constructor===e)return t;var n=CN.f(e);return(0,n.resolve)(t),n.promise},RN=Me,AN=Ji.CONSTRUCTOR,PN=lb;Pn("Promise"),RN({target:"Promise",stat:!0,forced:AN},{resolve:function(e){return PN(this,e)}});var DN=Bt,db=pu;Me({target:"Object",stat:!0,forced:oe(function(){db(1)})},{keys:function(e){return db(DN(e))}});var hb="canvas",Ce="audio",xe="video",Wp="screen",Nr="small",Ku="big",mt="auxiliary",Vn="aux",qu="smallVideo",pb="user",fb="environment",nn="mute",_r="unmute",Mt="ended",di="playing",hi="pause",no="error",Jp="loadeddata",qs="audioinput",Xu="videoinput",mb="detail",LN="text",Ze="main",Ki="backup",ON="banned",MN="kick",NN="user_time_out",VN="room_disband",vb="sei-message",ro="PLAYING",yr="PAUSED",pi="STOPPED",io="inactive",fi="sendonly",Kp="recvonly",gb="add",_b="remove",UN="replace",qp="track",BN="wss://trtc.rtc.qq.com",jN="wss://webrtc.qq.com",Qu="qcloud",FN="trtc",GN="webrtc",Xs="",yb="jssdk_log",HN="jssdk_event",zN="jssdk_new_endreport",Xp=function(e){return Xs=e},WN=1,JN=2,Yu="live",ao=20,Qp=21,Sr="anchor",qi="audience",br="5Y2wZK8nANNAoVw6dSAHVjNxrD1ObBM2kBPV",Qs="224d130c-7b5c-415b-aaa2-79c2eb5a6df2",KN=2,_t=Ze,Dt=mt,$u="unknown",sn="DISCONNECTED",Sb="CONNECTING",bb="RECONNECTING",mn="CONNECTED",qN="new",Zu="connecting",kb="failed",Yp="closed",XN="disconnected",Tb="connected",QN="completed",$p=30,xb="join",YN="delta-join",Ib="rejoin",$N="leave",ZN="delta-leave",wb="publish",e3="delta-publish",Eb="unpublish",Cb="subscribe",Rb="unsubscribe",Ab="uplink-connection",Pb="uplink-reconnection",Db="downlink-connection",Lb="downlink-reconnection",el="setLocalDescription",Ob="setRemoteDescription",Mb="iceConnectionState",Ys="stream-initialize",Zp="websocketConnectionState",Nb="websocketReconnectionState",Vb="update-stream",Ub="recover-subscription",Bb="start-mix-transcode",jb="stop-mix-transcode",Fb="player-error",Gb="schedule",ef="unsubscribe",tf="subscribe_change",$s="unified-plan",nf="plan-b",rf={MANUAL:"manual",PRESET_LAYOUT:"preset-layout"},Hb={REMOTE:"$PLACE_HOLDER_REMOTE$"},zb={IT_AUDIO_VIDEO:0,IT_PICTURE:2,IT_CANVAS:3,IT_PURE_AUDIO:4,IT_PURE_VIDEO:5},bt="string",Et="number",cn="boolean",t3="array",kr="object",un={ADD:gb,REMOVE:_b},af={unknown:0,wifi:1,"4g":2,"3g":3,"2g":4,wired:5},Wb=-1,Zs=0,n3=1,Jb=Ku,Kb=Nr,qb=6048e5,r3="schedule.rtc.qq.com",i3="schedule.rtc.qcloud.com",a3="schedule.rtc.tencentcloud.com",o3="schedule-ecdn.rtc.tencentcloud.com",of="",Xb=function(e){return of=e},ec="TRTC",ln="Client",mi="LocalStream",sf="RemoteStream",s3="Stream",cf="web.sdk.qcloud.com",Qb="web.sdk.tencent.cn",Yb="web.sdk.cloud.tencent.cn",$b="https://console.cloud.tencent.com/trtc",oo="https://".concat(cf,"/trtc/webrtc/doc"),uf="".concat(oo,"/zh-cn/"),lf="trtc_error_assistance",tl="default",Zb="communications",Un={TRACE:0,DEBUG:1,INFO:2,WARN:3,ERROR:4,NONE:5},Xi=Object.keys(Un),c3=["normal leave","timeout leave","kick","role change"],nl=2e3,so="ric",rl="raf",u3="interval",ek="timeout",tk="Resolution reset to 1080p, need to upgrade ability here https://cloud.tencent.com/document/product/647/85386",l3={"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},d3=pt,nk=Wt,h3=/"/g,p3=pe("".replace),rk=function(e,t,n,r){var i=nk(d3(e)),o="<"+t;return n!==""&&(o+=" "+n+'="'+p3(nk(r),h3,"&quot;")+'"'),o+">"+i+"</"+t+">"},f3=oe,ik=function(e){return f3(function(){var t=""[e]('"');return t!==t.toLowerCase()||t.split('"').length>3})},m3=rk;Me({target:"String",proto:!0,forced:ik("link")},{link:function(e){return m3(this,"a","href",e)}}),Me({target:"Array",stat:!0},{isArray:Fa});var v3="AVOID_REPEATED_CALL",g3="INVALID_PARAMETER_REQUIRED",ak="INVALID_PARAMETER_TYPE",_3="INVALID_PARAMETER_EMPTY",ok="INVALID_PARAMETER_INSTANCE",y3="INVALID_PARAMETER_RANGE",S3="API_CALL_TIMEOUT",b3="SIGNAL_CHANNEL_RECONNECTION_FAILED",k3="SIGNAL_CHANNEL_SETUP_FAILED",T3="ERROR_MESSAGE",x3="EXCHANGE_SDP_TIMEOUT",I3="DOWNLINK_RECONNECTION_FAILED",w3="EXCHANGE_SDP_FAILED",E3="UPLINK_RECONNECTION_FAILED",C3="INVALID_PURE_AUDIO",R3="INVALID_STREAMID",A3="INVALID_USER_DEFINE_RECORDID",P3="INVALID_USER_DEFINE_PUSH_ARGS",D3="INVALID_PROXY",L3="INVALID_JOIN",O3="INVALID_ROOMID_STRING",M3="INVALID_ROOMID_INTEGER",N3="JOIN_ROOM_TIMEOUT",sk="JOIN_ROOM_FAILED",V3="REJOIN_ROOM_FAILED",U3="INVALID_DESTROY",B3="INVALID_PUBLISH",j3="INVALID_UNPUBLISH",F3="INVALID_AUDIENCE",G3="INVALID_INITIALIZE",H3="INVALID_DUPLICATE_PUBLISHING",df="INVALID_REMOTE_STREAM",z3="SUBSCRIBE_FAILED",W3="INVALID_ROLE",J3="INVALID_OPERATION_SWITCH_ROLE",K3="SWITCH_ROLE_TIMEOUT",q3="SWITCH_ROLE_FAILED",X3="CLIENT_BANNED",ck="INVALID_OPERATION_START_PUBLISH_CDN",Q3="INVALID_OPERATION_STOP_PUBLISH_CDN",Y3="INVALID_STREAM_ID",uk="START_PUBLISH_CDN_FAILED",lk="STOP_PUBLISH_CDN_FAILED",$3="START_MIX_TRANSCODE",Z3="STOP_MIX_TRANSCODE",e4="INVALID_AUDIO_VOLUME",t4="ENABLE_SMALL_STREAM_PUBLISHED",n4="DISABLE_SMALL_STREAM_PUBLISHED",r4="NOT_SUPPORTED_SMALL_STREAM",i4="INVALID_SMALL_STREAM_PROFILE",a4="INVALID_PARAMETER_REMOTE_STREAM",o4="INVALID_SWITCH_DEVICE",s4="INVALID_SWITCH_DEVICE_PUBLISHING",dk="INVALID_REPLACE_TRACK",c4="INVALID_INITIALIZE_LOCAL_STREAM",u4="INVALID_ADD_TRACK_REPETITIVE",l4="INVALID_ADD_TRACK_REMOVING",d4="INVALID_ADD_TRACK_PUBLISHING",hk="INVALID_STREAM_INITIALIZED",h4="INVALID_ADD_TRACK_NUMBER",p4="INVALID_REMOVE_AUDIO_TRACK",f4="INVALID_REMOVE_AUDIO_ADDING",m4="INVALID_REMOVE_AUDIO_ON",v4="INVALID_REMOVE_TRACK_PUBLISHING",g4="INVALID_REMOVE_TRACK_NOT_PUBLISHING",_4="INVALID_REMOVE_TRACK_NUMBER",y4="INVALID_REPLACE_TRACK_NO_TRACK",S4="REPEAT_JOIN",hf="CLIENT_DESTROYED",b4="START_MIX_TRANSCODE_FAILED",k4="STOP_MIX_TRANSCODE_FAILED",T4="MIX_TRANSCODE_NOT_STARTED",x4="CANNOT_LESS_THAN_ZERO",I4="MIX_PARAMS_VIDEO_FRAMERATE",w4="MIX_PARAMS_VIDEO_GOP",E4="MIX_PARAMS_AUDIO_BITRATE",C4="MIX_PARAMS_USER_Z_ORDER",R4="MIX_PARAMS_NOT_SELF",A4="MIX_PARAMS_USER_STREAM",P4="INVALID_ELEMENT_ID",D4="INVALID_ELEMENT_ID_TYPE",pf="PLAY_FAILED",L4="INVALID_CREATE_STREAM_SOURCE",O4="INVALID_CREATE_STREAM_SCREEN",M4="INVALID_CREATE_STREAM_AUDIO",N4="INVALID_CREATE_STREAM_SCREEN_AUDIO",pk="NOT_SUPPORTED_HTTP",fk="NOT_SUPPORTED_WEBRTC",V4="NOT_SUPPORTED_PROFILE",mk="NOT_SUPPORTED_H264ENCODE",vk="NOT_SUPPORTED_H264DECODE",ff="NOT_SUPPORTED_TRACK",U4="NOT_SUPPORTED_SWITCH_DEVICE",B4="NOT_SUPPORTED_CAPTURE",j4="NOT_SUPPORTED_AUX",F4="MICROPHONE_NOT_FOUND",G4="CAMERA_NOT_FOUND",gk="SIGNAL_RESPONSE_FAILED",H4="CATCH_HANDLER_ERROR",z4="API_NOT_EXIST",W4="CONNECTION_CLOSED",J4="SUBSCRIBE_ALL_FALSE",_k="SEI_NOT_SUPPORT",K4="SEI_DISABLED",q4="SEI_EMPTY",X4="SEI_OVERSIZE",Q4="SEI_BEFORE_PUBLISH",Y4="SEI_NOT_VIDEO",$4="CALL_FREQUENCY_LIMIT",Z4="CONNECTION_ABORTED",mf="API_CALL_ABORTED",eV="DUPLICATE_AUX",vi={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,r=e.fnName,i=e.value;return"'".concat(t||n.name,"' is a required param when calling ").concat(r,"(), received: ").concat(i,".")},INVALID_PARAMETER_TYPE:function(e){var t=e.key,n=e.rule,r=e.fnName,i=e.value,o="".concat(t||n.name),a="";return a=Array.isArray(n.type)?n.type.join("|"):n.type,"'".concat(o,"' must be type of ").concat(a," when calling ").concat(r,"(), received type: ").concat(gi(i),".")},INVALID_PARAMETER_EMPTY:function(e){var t=e.key,n=e.rule,r=e.fnName,i=e.value;return"'".concat(t||n.name,"' cannot be '").concat(i,"' when calling ").concat(r,"().")},INVALID_PARAMETER_INSTANCE:function(e){var t=e.key,n=e.rule,r=e.fnName,i=e.value,o="".concat(t||n.name),a="".concat(n.instanceOf.name||n.instanceOf);return"'".concat(o,"' must be instanceof ").concat(a," when calling ").concat(r,"(), received type: ").concat(gi(i),".")},INVALID_PARAMETER_RANGE:function(e){var t=e.key,n=e.rule,r=e.fnName,i=e.value;return"'".concat(t||n.name,"' must be one of ").concat(n.values.join("|")," when calling ").concat(r,"(), received: ").concat(i,".")},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(qi,', please call switchRole("').concat(Sr,'") 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(Sr," or ").concat(qi,"."),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,r=e.fnName;return e.value,"'".concat(t||n.name,"' cannot be less than 0 when calling ").concat(r,"().")},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,r=e.type;return"the element corresponding to '".concat(t,"' must be instanceof HTMLDivElement when calling ").concat(n,"(), received: ").concat(r,".")},PLAY_FAILED:function(e){return"".concat(e.media," play failed\uFF0Cbrowser 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,r=e.timesInSecond,i=e.maxSizeInSecond;return"api ".concat(n," call ").concat(t?"size":"times"," is over ").concat(t?i+" bytes":r," 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."},yk=te,tV=oe,nV=Wt,rV=Vu.trim,iV=pe("".charAt),il=yk.parseFloat,Sk=yk.Symbol,bk=Sk&&Sk.iterator,kk=1/il(`
80
- \v\f\r \xA0\u1680\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028\u2029\uFEFF-0`)!=-1/0||bk&&!tV(function(){il(Object(bk))})?function(e){var t=rV(nV(e)),n=il(t);return n===0&&iV(t,0)=="-"?-0:n}:il;Me({global:!0,forced:parseFloat!=kk},{parseFloat:kk});var Ee=window.navigator&&window.navigator.userAgent||"",Tk=/AppleWebKit\/([\d.]+)/i.exec(Ee);Tk&&parseFloat(Tk.pop());var vf=/iPad/i.test(Ee),xk=navigator.maxTouchPoints&&navigator.maxTouchPoints>2&&/Macintosh/.test(Ee),gf=/iPhone/i.test(Ee)&&!vf,aV=/iPod/i.test(Ee),Qi=gf||vf||aV||xk,co=/Android/i.test(Ee);co&&function(){var e=Ee.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])}(),co&&/webkit/i.test(Ee);var Tr=/Firefox/i.test(Ee),Ik=Tr&&function(){var e=Ee.match(/Firefox\/(\d+)/);return e&&e[1]?parseFloat(e[1]):null}(),al=/Edge\//i.test(Ee),oV=al&&function(){var e=Ee.match(/Edge\/(\d+)/i);if(e&&e[1])return e[1]}(),ol=/Edg\//i.test(Ee),wk=ol&&function(){var e=Ee.match(/Edg\/(\d+)/);return e&&e[1]?parseFloat(e[1]):null}(),_f=/SogouMobileBrowser\//i.test(Ee),sV=_f&&function(){var e=Ee.match(/SogouMobileBrowser\/(\d+)/);return e&&e[1]?parseFloat(e[1]):null}(),yf=/MetaSr\s/i.test(Ee),cV=yf&&function(){var e=Ee.match(/MetaSr(\s\d+(\.\d+)+)/);return e&&e[1]?parseFloat(e[1]):null}(),Vr=/TBS\/\d+/i.test(Ee),uV=Vr&&function(){var e=Ee.match(/TBS\/(\d+)/i);if(e&&e[1])return e[1]}(),Sf=/XWEB\/\d+/i.test(Ee),lV=Sf&&function(){var e=Ee.match(/XWEB\/(\d+)/i);if(e&&e[1])return e[1]}();/MSIE\s8\.0/.test(Ee),/MSIE\/\d+/i.test(Ee)&&function(){var e=/MSIE\s(\d+)\.\d/.exec(Ee),t=e&&parseFloat(e[1]);!t&&/Trident\/7.0/i.test(Ee)&&/rv:11.0/.test(Ee)&&(t=11)}();var bf=/(micromessenger|webbrowser)/i.test(Ee),dV=bf&&function(){var e=Ee.match(/MicroMessenger\/(\d+)/i);if(e&&e[1])return e[1]}(),kf=!Vr&&/MQQBrowser\/\d+/i.test(Ee)&&/COVC\/\d+/i.test(Ee),Tf=!Vr&&/MQQBrowser\/\d+/i.test(Ee)&&!/COVC\/\d+/i.test(Ee),Ek=(Tf||kf)&&function(){var e=Ee.match(/ MQQBrowser\/([\d.]+)/);return e&&e[1]?e[1]:null}(),xf=!Vr&&/ QQBrowser\/\d+/i.test(Ee),hV=xf&&function(){var e=Ee.match(/ QQBrowser\/([\d.]+)/);return e&&e[1]?e[1]:null}(),If=!Vr&&/QQBrowserLite\/\d+/i.test(Ee),pV=If&&function(){var e=Ee.match(/QQBrowserLite\/([\d.]+)/);return e&&e[1]?e[1]:null}(),wf=!Vr&&/MQBHD\/\d+/i.test(Ee),fV=wf&&function(){var e=Ee.match(/MQBHD\/([\d.]+)/);return e&&e[1]?e[1]:null}(),Ck=/Windows/i.test(Ee),tc=!Qi&&/MAC OS X/i.test(Ee),Rk=!co&&/Linux/i.test(Ee);/MicroMessenger/i.test(Ee);var mV=/UCBrowser/i.test(Ee);/Electron/i.test(Ee);var Ak,sl,Ef=/MiuiBrowser/i.test(Ee),vV=Ef&&function(){var e=Ee.match(/MiuiBrowser\/([\d.]+)/);return e&&e[1]?e[1]:null}(),Cf=/HuaweiBrowser/i.test(Ee),Rf=/Huawei/i.test(Ee),gV=Cf&&function(){var e=Ee.match(/HuaweiBrowser\/([\d.]+)/);return e&&e[1]?e[1]:null}(),Af=/SamsungBrowser/i.test(Ee),_V=Af&&function(){var e=Ee.match(/SamsungBrowser\/([\d.]+)/);return e&&e[1]?e[1]:null}(),cl=/HeyTapBrowser/i.test(Ee),yV=cl&&function(){var e=Ee.match(/HeyTapBrowser\/([\d.]+)/);return e&&e[1]?e[1]:null}(),ul=/VivoBrowser/i.test(Ee),SV=ul&&function(){var e=Ee.match(/VivoBrowser\/([\d.]+)/);return e&&e[1]?e[1]:null}(),nc=function(){var e=Ee.match(/Chrome\/(\d+)/);return e&&e[1]?Number(e[1]):null},bV=/Chrome/i.test(Ee),ll=!al&&!yf&&!_f&&!Vr&&!Sf&&!ol&&!xf&&!Ef&&!Cf&&!Af&&!cl&&!ul&&/Chrome/i.test(Ee),Pf=ll&&nc(),kV=ll&&function(){var e=Ee.match(/Chrome\/([\d.]+)/);return e&&e[1]?e[1]:null}(),Yi=!bV&&!Tf&&!kf&&!If&&!wf&&/Safari/i.test(Ee),Df=function(){if(Yi){var e=Ee.match(/Version\/([\d.]+)/);if(e&&e[1])return e[1]}return""}(),TV=/Android.*(wv|.0.0.0)/.test(Ee),$i=function(){if(xk)return Df;if(Qi){var e=Ee.match(/OS (\d+)_(\d+)/i);if(e&&e[1]){var t=e[1];return e[2]&&(t+=".".concat(e[2])),t}}return""}(),dl=Df==="15.1",hl=$i==="15.1",xV=(Ak=Number($i.split(".")[0]))===14||Ak===13,Zi=location.protocol==="file:"||location.hostname==="localhost"||location.hostname==="127.0.0.1",ea=function(){if(ve(sl))try{sl=window.localStorage}catch(e){ke.warn(e),sl=!1}return sl},Lf=new Map([[Tr,["Firefox",Ik]],[ol,["Edg",wk]],[ll,["Chrome",kV]],[Yi,["Safari",Df]],[Vr,["TBS",uV]],[Sf,["XWEB",lV]],[bf&&gf,["WeChat",dV]],[xf,["QQ(Win)",hV]],[Tf,["QQ(Mobile)",Ek]],[kf,["QQ(Mobile X5)",Ek]],[If,["QQ(Mac)",pV]],[wf,["QQ(iPad)",fV]],[Ef,["MI",vV]],[Cf,["HW",gV]],[Af,["Samsung",_V]],[cl,["OPPO",yV]],[ul,["VIVO",SV]],[al,["EDGE",oV]],[_f,["SogouMobile",sV]],[yf,["Sogou",cV]]]);function ta(){var e="unknown",t="unknown";return Lf.get(!0)&&(e=Lf.get(!0)[0],t=Lf.get(!0)[1]),{name:e,version:t}}var Pk=function(e,t){return t?oo+"/"+e+"/"+t:oo+"/"+e+"/index.html"},IV=function(){if(!ea())return!1;var e=localStorage.getItem(lf);e&&!function(t){var n=t.saveTime&&new Date().getTime()-t.saveTime>=qb,r=!t.saveVersion||t.saveVersion!==Vi;return n||r}(JSON.parse(e))||(ke.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(lf,JSON.stringify({message:t.responseText,saveTime:new Date().getTime(),saveVersion:Vi})),document.body.removeChild(n)}}())};function ne(e){var t=e.key,n=e.data,r=e.link,i=e.addDocLink,o=i===void 0||i,a="",s="",c="";In(vi[t])?a=vi[t](n):Ft(vi[t])&&(a=vi[t]);var u=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 y=localStorage.getItem(lf);if(y){y=JSON.parse(y);var b=document.createElement("script");b.type="text/javascript",b.text=y.message,document.body.appendChild(b);var f=window.TRTC_ERROR_INFO,g=window.TRTC_ERROR_LINK;return document.body.removeChild(b),{TRTC_ERROR_INFO:f,TRTC_ERROR_LINK:g}}return{}}(),d=u.TRTC_ERROR_INFO,h=u.TRTC_ERROR_LINK;r?c="".concat(r.className,".html#").concat(r.fnName):h&&h[t]&&(In(h[t])?c=h[t](n):Ft(h[t])&&(c=h[t]));var _=a;return ra()&&(d&&d[t]&&(In(d[t])?s=d[t](n):Ft(d[t])&&(s=d[t])),s&&(_=o?s+`
81
- \u8BF7\u67E5\u770B\u6587\u6863: `+Pk("zh-cn",c)+`
39
+ `},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 Bi="4.15.14",_g={},lC=pg,dC=Hd,au=Object.keys||function(e){return lC(e,dC)},hC=_e,fC=ds,pC=At,mC=Tt,vC=yn,gC=au;_g.f=hC&&!fC?Object.defineProperties:function(e,t){mC(e);for(var n,i=vC(t),r=gC(t),o=r.length,c=0;o>c;)pC.f(e,n=r[c++],i[n]);return e};var ou,yg=Rn("document","documentElement"),_C=Tt,yC=_g,bg=Hd,bC=Z,SC=yg,kC=fr,Sg=W("IE_PROTO"),qd=function(){},kg=function(e){return"<script>"+e+"<\/script>"},Tg=function(e){e.write(kg("")),e.close();var t=e.parentWindow.Object;return e=null,t},su=function(){try{ou=new ActiveXObject("htmlfile")}catch(i){}var e,t;su=typeof document!="undefined"?document.domain&&ou?Tg(ou):((t=kC("iframe")).style.display="none",SC.appendChild(t),t.src=String("javascript:"),(e=t.contentWindow.document).open(),e.write(kg("document.F=Object")),e.close(),e.F):Tg(ou);for(var n=bg.length;n--;)delete su.prototype[bg[n]];return su()};bC[Sg]=!0;var Va=Object.create||function(e,t){var n;return e!==null?(qd.prototype=_C(e),n=new qd,qd.prototype=null,n[Sg]=e):n=su(),t===void 0?n:yC.f(n,t)},TC=tt,xC=Va,IC=At.f,Jd=TC("unscopables"),Kd=Array.prototype;Kd[Jd]==null&&IC(Kd,Jd,{configurable:!0,value:xC(null)});var Fi,xg,Ig,cu=function(e){Kd[Jd][e]=!0},Ss={},wg=!ue(function(){function e(){}return e.prototype.constructor=null,Object.getPrototypeOf(new e)!==e.prototype}),wC=kt,CC=it,EC=Vt,RC=wg,Cg=W("IE_PROTO"),Xd=Object,AC=Xd.prototype,ks=RC?Xd.getPrototypeOf:function(e){var t=EC(e);if(wC(t,Cg))return t[Cg];var n=t.constructor;return CC(n)&&t instanceof n?n.prototype:t instanceof Xd?AC:null},PC=ue,DC=it,LC=at,Eg=ks,OC=Xt,Qd=tt("iterator"),Rg=!1;[].keys&&("next"in(Ig=[].keys())?(xg=Eg(Eg(Ig)))!==Object.prototype&&(Fi=xg):Rg=!0);var MC=!LC(Fi)||PC(function(){var e={};return Fi[Qd].call(e)!==e});MC&&(Fi={}),DC(Fi[Qd])||OC(Fi,Qd,function(){return this});var Yd={IteratorPrototype:Fi,BUGGY_SAFARI_ITERATORS:Rg},NC=At.f,UC=kt,Ag=tt("toStringTag"),Hi=function(e,t,n){e&&!n&&(e=e.prototype),e&&!UC(e,Ag)&&NC(e,Ag,{configurable:!0,value:t})},VC=Yd.IteratorPrototype,jC=Va,BC=Ze,FC=Hi,HC=Ss,GC=function(){return this},Pg=function(e,t,n,i){var r=t+" Iterator";return e.prototype=jC(VC,{next:BC(+!i,n)}),FC(e,r,!1),HC[r]=GC,e},zC=it,WC=String,qC=TypeError,JC=pe,KC=Tt,XC=function(e){if(typeof e=="object"||zC(e))return e;throw qC("Can't set "+WC(e)+" as a prototype")},ja=Object.setPrototypeOf||("__proto__"in{}?function(){var e,t=!1,n={};try{(e=JC(Object.getOwnPropertyDescriptor(Object.prototype,"__proto__").set))(n,[]),t=n instanceof Array}catch(i){}return function(i,r){return KC(i),XC(r),t?e(i,r):i.__proto__=r,i}}():void 0),QC=Me,YC=Xe,$C=it,ZC=Pg,Dg=ks,Lg=ja,eE=Hi,tE=Ln,$d=Xt,nE=Ss,rE=Xn.PROPER,iE=Xn.CONFIGURABLE,Og=Yd.IteratorPrototype,uu=Yd.BUGGY_SAFARI_ITERATORS,Ts=tt("iterator"),Mg="keys",xs="values",Ng="entries",aE=function(){return this},Zd=function(e,t,n,i,r,o,c){ZC(n,t,i);var a,s,l,u=function(T){if(T===r&&I)return I;if(!uu&&T in x)return x[T];switch(T){case Mg:case xs:case Ng:return function(){return new n(this,T)}}return function(){return new n(this)}},p=t+" Iterator",k=!1,x=e.prototype,E=x[Ts]||x["@@iterator"]||r&&x[r],I=!uu&&E||u(r),m=t=="Array"&&x.entries||E;if(m&&(a=Dg(m.call(new e)))!==Object.prototype&&a.next&&(Dg(a)!==Og&&(Lg?Lg(a,Og):$C(a[Ts])||$d(a,Ts,aE)),eE(a,p,!0)),rE&&r==xs&&E&&E.name!==xs&&(iE?tE(x,"name",xs):(k=!0,I=function(){return YC(E,this)})),r)if(s={values:u(xs),keys:o?I:u(Mg),entries:u(Ng)},c)for(l in s)(uu||k||!(l in x))&&$d(x,l,s[l]);else QC({target:t,proto:!0,forced:uu||k},s);return x[Ts]!==I&&$d(x,Ts,I,{name:r}),nE[t]=I,s},eh=function(e,t){return{value:e,done:t}},oE=yn,th=cu,Ug=Ss,Vg=Ke,sE=At.f,cE=Zd,jg=eh,uE=_e,Bg="Array Iterator",lE=Vg.set,dE=Vg.getterFor(Bg),Fg=cE(Array,"Array",function(e,t){lE(this,{type:Bg,target:oE(e),index:0,kind:t})},function(){var e=dE(this),t=e.target,n=e.kind,i=e.index++;return!t||i>=t.length?(e.target=void 0,jg(void 0,!0)):jg(n=="keys"?i:n=="values"?t[i]:[i,t[i]],!1)},"values"),Hg=Ug.Arguments=Ug.Array;if(th("keys"),th("values"),th("entries"),uE&&Hg.name!=="values")try{sE(Hg,"name",{value:"values"})}catch(e){}var Gg={};Gg[tt("toStringTag")]="z";var nh=String(Gg)==="[object z]",hE=nh,fE=it,lu=rt,pE=tt("toStringTag"),mE=Object,vE=lu(function(){return arguments}())=="Arguments",Pr=hE?lu:function(e){var t,n,i;return e===void 0?"Undefined":e===null?"Null":typeof(n=function(r,o){try{return r[o]}catch(c){}}(t=mE(e),pE))=="string"?n:vE?lu(t):(i=lu(t))=="Object"&&fE(t.callee)?"Arguments":i},gE=Pr,_E=nh?{}.toString:function(){return"[object "+gE(this)+"]"};nh||Xt(Object.prototype,"toString",_E,{unsafe:!0});var Is={exports:{}},rh={},yE=Aa,bE=At,SE=Ze,ws=function(e,t,n){var i=yE(t);i in e?bE.f(e,i,SE(0,n)):e[i]=n},zg=ii,kE=tn,TE=ws,xE=Array,IE=Math.max,du=function(e,t,n){for(var i=kE(e),r=zg(t,i),o=zg(n===void 0?i:n,i),c=xE(IE(o-r,0)),a=0;r<o;r++,a++)TE(c,a,e[r]);return c.length=a,c},wE=rt,CE=yn,Wg=ri.f,EE=du,qg=typeof window=="object"&&window&&Object.getOwnPropertyNames?Object.getOwnPropertyNames(window):[];rh.f=function(e){return qg&&wE(e)=="Window"?function(t){try{return Wg(t)}catch(n){return EE(qg)}}(e):Wg(CE(e))};var RE=ue(function(){if(typeof ArrayBuffer=="function"){var e=new ArrayBuffer(8);Object.isExtensible(e)&&Object.defineProperty(e,"a",{value:8})}}),AE=ue,PE=at,DE=rt,Jg=RE,hu=Object.isExtensible,Kg=AE(function(){hu(1)})||Jg?function(e){return!!PE(e)&&(!Jg||DE(e)!="ArrayBuffer")&&(!hu||hu(e))}:hu,LE=!ue(function(){return Object.isExtensible(Object.preventExtensions({}))}),OE=Me,ME=pe,NE=Z,UE=at,ih=kt,VE=At.f,Xg=ri,jE=rh,ah=Kg,BE=LE,Qg=!1,Dr=Mi("meta"),FE=0,oh=function(e){VE(e,Dr,{value:{objectID:"O"+FE++,weakData:{}}})},HE=Is.exports={enable:function(){HE.enable=function(){},Qg=!0;var e=Xg.f,t=ME([].splice),n={};n[Dr]=1,e(n).length&&(Xg.f=function(i){for(var r=e(i),o=0,c=r.length;o<c;o++)if(r[o]===Dr){t(r,o,1);break}return r},OE({target:"Object",stat:!0,forced:!0},{getOwnPropertyNames:jE.f}))},fastKey:function(e,t){if(!UE(e))return typeof e=="symbol"?e:(typeof e=="string"?"S":"P")+e;if(!ih(e,Dr)){if(!ah(e))return"F";if(!t)return"E";oh(e)}return e[Dr].objectID},getWeakData:function(e,t){if(!ih(e,Dr)){if(!ah(e))return!0;if(!t)return!1;oh(e)}return e[Dr].weakData},onFreeze:function(e){return BE&&Qg&&ah(e)&&!ih(e,Dr)&&oh(e),e}};NE[Dr]=!0;var GE=Ut,zE=Oe,WE=pe(pe.bind),Lr=function(e,t){return GE(e),t===void 0?e:zE?WE(e,t):function(){return e.apply(t,arguments)}},qE=Ss,JE=tt("iterator"),KE=Array.prototype,sh=function(e){return e!==void 0&&(qE.Array===e||KE[JE]===e)},XE=Pr,Yg=Kt,QE=Et,YE=Ss,$E=tt("iterator"),Cs=function(e){if(!QE(e))return Yg(e,$E)||Yg(e,"@@iterator")||YE[XE(e)]},ZE=Xe,eR=Ut,tR=Tt,nR=Jn,rR=Cs,iR=TypeError,fu=function(e,t){var n=arguments.length<2?rR(e):t;if(eR(n))return tR(ZE(n,e));throw iR(nR(e)+" is not iterable")},aR=Xe,$g=Tt,oR=Kt,Zg=function(e,t,n){var i,r;$g(e);try{if(!(i=oR(e,"return"))){if(t==="throw")throw n;return n}i=aR(i,e)}catch(o){r=!0,i=o}if(t==="throw")throw n;if(r)throw i;return $g(i),n},sR=Lr,cR=Xe,uR=Tt,lR=Jn,dR=sh,hR=tn,e_=bn,fR=fu,pR=Cs,t_=Zg,mR=TypeError,pu=function(e,t){this.stopped=e,this.result=t},n_=pu.prototype,Es=function(e,t,n){var i,r,o,c,a,s,l,u=n&&n.that,p=!(!n||!n.AS_ENTRIES),k=!(!n||!n.IS_RECORD),x=!(!n||!n.IS_ITERATOR),E=!(!n||!n.INTERRUPTED),I=sR(t,u),m=function(v){return i&&t_(i,"normal",v),new pu(!0,v)},T=function(v){return p?(uR(v),E?I(v[0],v[1],m):I(v[0],v[1])):E?I(v,m):I(v)};if(k)i=e.iterator;else if(x)i=e;else{if(!(r=pR(e)))throw mR(lR(e)+" is not iterable");if(dR(r)){for(o=0,c=hR(e);c>o;o++)if((a=T(e[o]))&&e_(n_,a))return a;return new pu(!1)}i=fR(e,r)}for(s=k?e.next:i.next;!(l=cR(s,i)).done;){try{a=T(l.value)}catch(v){t_(i,"throw",v)}if(typeof a=="object"&&a&&e_(n_,a))return a}return new pu(!1)},vR=bn,gR=TypeError,ai=function(e,t){if(vR(t,e))return e;throw gR("Incorrect invocation")},r_=tt("iterator"),i_=!1;try{var _R=0,a_={next:function(){return{done:!!_R++}},return:function(){i_=!0}};a_[r_]=function(){return this},Array.from(a_,function(){throw 2})}catch(e){}var mu=function(e,t){if(!t&&!i_)return!1;var n=!1;try{var i={};i[r_]=function(){return{next:function(){return{done:n=!0}}}},e(i)}catch(r){}return n},yR=it,bR=at,o_=ja,vu=function(e,t,n){var i,r;return o_&&yR(i=t.constructor)&&i!==n&&bR(r=i.prototype)&&r!==n.prototype&&o_(e,r),e},SR=Me,kR=re,TR=pe,s_=bs,xR=Xt,IR=Is.exports,wR=Es,CR=ai,ER=it,RR=Et,ch=at,uh=ue,AR=mu,PR=Hi,DR=vu,lh=function(e,t,n){var i=e.indexOf("Map")!==-1,r=e.indexOf("Weak")!==-1,o=i?"set":"add",c=kR[e],a=c&&c.prototype,s=c,l={},u=function(m){var T=TR(a[m]);xR(a,m,m=="add"?function(v){return T(this,v===0?0:v),this}:m=="delete"?function(v){return!(r&&!ch(v))&&T(this,v===0?0:v)}:m=="get"?function(v){return r&&!ch(v)?void 0:T(this,v===0?0:v)}:m=="has"?function(v){return!(r&&!ch(v))&&T(this,v===0?0:v)}:function(v,C){return T(this,v===0?0:v,C),this})};if(s_(e,!ER(c)||!(r||a.forEach&&!uh(function(){new c().entries().next()}))))s=n.getConstructor(t,e,i,o),IR.enable();else if(s_(e,!0)){var p=new s,k=p[o](r?{}:-0,1)!=p,x=uh(function(){p.has(1)}),E=AR(function(m){new c(m)}),I=!r&&uh(function(){for(var m=new c,T=5;T--;)m[o](T,T);return!m.has(-0)});E||((s=t(function(m,T){CR(m,a);var v=DR(new c,m,s);return RR(T)||wR(T,v[o],{that:v,AS_ENTRIES:i}),v})).prototype=a,a.constructor=s),(x||I)&&(u("delete"),u("has"),i&&u("get")),(I||k)&&u(o),r&&a.clear&&delete a.clear}return l[e]=s,SR({global:!0,constructor:!0,forced:s!=c},l),PR(s,e),r||n.setStrong(s,e,i),s},LR=Xt,Rs=function(e,t,n){for(var i in t)LR(e,i,t[i],n);return e},OR=Rn,MR=At,NR=_e,c_=tt("species"),As=function(e){var t=OR(e),n=MR.f;NR&&t&&!t[c_]&&n(t,c_,{configurable:!0,get:function(){return this}})},UR=At.f,VR=Va,u_=Rs,jR=Lr,BR=ai,FR=Et,HR=Es,GR=Zd,l_=eh,zR=As,Ps=_e,d_=Is.exports.fastKey,h_=Ke.set,dh=Ke.getterFor,f_={getConstructor:function(e,t,n,i){var r=e(function(l,u){BR(l,o),h_(l,{type:t,index:VR(null),first:void 0,last:void 0,size:0}),Ps||(l.size=0),FR(u)||HR(u,l[i],{that:l,AS_ENTRIES:n})}),o=r.prototype,c=dh(t),a=function(l,u,p){var k,x,E=c(l),I=s(l,u);return I?I.value=p:(E.last=I={index:x=d_(u,!0),key:u,value:p,previous:k=E.last,next:void 0,removed:!1},E.first||(E.first=I),k&&(k.next=I),Ps?E.size++:l.size++,x!=="F"&&(E.index[x]=I)),l},s=function(l,u){var p,k=c(l),x=d_(u);if(x!=="F")return k.index[x];for(p=k.first;p;p=p.next)if(p.key==u)return p};return u_(o,{clear:function(){for(var l=c(this),u=l.index,p=l.first;p;)p.removed=!0,p.previous&&(p.previous=p.previous.next=void 0),delete u[p.index],p=p.next;l.first=l.last=void 0,Ps?l.size=0:this.size=0},delete:function(l){var u=this,p=c(u),k=s(u,l);if(k){var x=k.next,E=k.previous;delete p.index[k.index],k.removed=!0,E&&(E.next=x),x&&(x.previous=E),p.first==k&&(p.first=x),p.last==k&&(p.last=E),Ps?p.size--:u.size--}return!!k},forEach:function(l){for(var u,p=c(this),k=jR(l,arguments.length>1?arguments[1]:void 0);u=u?u.next:p.first;)for(k(u.value,u.key,this);u&&u.removed;)u=u.previous},has:function(l){return!!s(this,l)}}),u_(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)}}),Ps&&UR(o,"size",{get:function(){return c(this).size}}),r},setStrong:function(e,t,n){var i=t+" Iterator",r=dh(t),o=dh(i);GR(e,t,function(c,a){h_(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)?l_(a=="keys"?s.key:a=="values"?s.value:[s.key,s.value],!1):(c.target=void 0,l_(void 0,!0))},n?"entries":"values",!n,!0),zR(t)}};lh("Set",function(e){return function(){return e(this,arguments.length?arguments[0]:void 0)}},f_);var WR=Pr,qR=String,zt=function(e){if(WR(e)==="Symbol")throw TypeError("Cannot convert a Symbol value to a string");return qR(e)},hh=pe,JR=Qn,KR=zt,XR=ht,QR=hh("".charAt),p_=hh("".charCodeAt),YR=hh("".slice),m_=function(e){return function(t,n){var i,r,o=KR(XR(t)),c=JR(n),a=o.length;return c<0||c>=a?e?"":void 0:(i=p_(o,c))<55296||i>56319||c+1===a||(r=p_(o,c+1))<56320||r>57343?e?QR(o,c):i:e?YR(o,c,c+2):r-56320+(i-55296<<10)+65536}},fh={codeAt:m_(!1),charAt:m_(!0)},$R=fh.charAt,ZR=zt,v_=Ke,eA=Zd,g_=eh,__="String Iterator",tA=v_.set,nA=v_.getterFor(__);eA(String,"String",function(e){tA(this,{type:__,string:ZR(e),index:0})},function(){var e,t=nA(this),n=t.string,i=t.index;return i>=n.length?g_(void 0,!0):(e=$R(n,i),t.index+=e.length,g_(e,!1))});var y_={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},ph=fr("span").classList,b_=ph&&ph.constructor&&ph.constructor.prototype,S_=b_===Object.prototype?void 0:b_,k_=re,T_=y_,rA=S_,Ds=Fg,mh=Ln,x_=tt,vh=x_("iterator"),I_=x_("toStringTag"),gh=Ds.values,w_=function(e,t){if(e){if(e[vh]!==gh)try{mh(e,vh,gh)}catch(i){e[vh]=gh}if(e[I_]||mh(e,I_,t),T_[t]){for(var n in Ds)if(e[n]!==Ds[n])try{mh(e,n,Ds[n])}catch(i){e[n]=Ds[n]}}}};for(var _h in T_)w_(k_[_h]&&k_[_h].prototype,_h);w_(rA,"DOMTokenList");var iA=Oe,C_=Function.prototype,E_=C_.apply,R_=C_.call,Gi=typeof Reflect=="object"&&Reflect.apply||(iA?R_.bind(E_):function(){return R_.apply(E_,arguments)}),Ba=pe([].slice),aA=TypeError,gu=function(e,t){if(e<t)throw aA("Not enough arguments");return e},yh=re,oA=Gi,sA=it,cA=Ba,uA=gu,lA=/MSIE .\./.test(qn),dA=yh.Function,A_=function(e){return lA?function(t,n){var i=uA(arguments.length,1)>2,r=sA(t)?t:dA(t),o=i?cA(arguments,2):void 0;return e(i?function(){oA(r,this,o)}:r,n)}:e},P_={setTimeout:A_(yh.setTimeout),setInterval:A_(yh.setInterval)},D_=P_.setInterval;Me({global:!0,bind:!0,forced:re.setInterval!==D_},{setInterval:D_});var L_=P_.setTimeout;Me({global:!0,bind:!0,forced:re.setTimeout!==L_},{setTimeout:L_}),lh("Map",function(e){return function(){return e(this,arguments.length?arguments[0]:void 0)}},f_);var hA=rt,Fa=Array.isArray||function(e){return hA(e)=="Array"},fA=pe,pA=ue,O_=it,mA=Pr,vA=d,M_=function(){},gA=[],N_=Rn("Reflect","construct"),bh=/^\s*(?:class|function)\b/,_A=fA(bh.exec),yA=!bh.exec(M_),Ls=function(e){if(!O_(e))return!1;try{return N_(M_,gA,e),!0}catch(t){return!1}},U_=function(e){if(!O_(e))return!1;switch(mA(e)){case"AsyncFunction":case"GeneratorFunction":case"AsyncGeneratorFunction":return!1}try{return yA||!!_A(bh,vA(e))}catch(t){return!0}};U_.sham=!0;var _u=!N_||pA(function(){var e;return Ls(Ls.call)||!Ls(Object)||!Ls(function(){e=!0})||e})?U_:Ls,V_=Fa,bA=_u,SA=at,kA=tt("species"),j_=Array,TA=function(e){var t;return V_(e)&&(t=e.constructor,(bA(t)&&(t===j_||V_(t.prototype))||SA(t)&&(t=t[kA])===null)&&(t=void 0)),t===void 0?j_:t},Sh=function(e,t){return new(TA(e))(t===0?0:t)},xA=Lr,IA=_n,wA=Vt,CA=tn,EA=Sh,B_=pe([].push),oi=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,p){for(var k,x,E=wA(s),I=IA(E),m=xA(l,u),T=CA(I),v=0,C=p||EA,O=t?C(s,T):n||c?C(s,0):void 0;T>v;v++)if((a||v in I)&&(x=m(k=I[v],v,E),e))if(t)O[v]=x;else if(x)switch(e){case 3:return!0;case 5:return k;case 6:return v;case 2:B_(O,k)}else switch(e){case 4:return!1;case 7:B_(O,k)}return o?-1:i||r?r:O}},nn={forEach:oi(0),map:oi(1),filter:oi(2),some:oi(3),every:oi(4),find:oi(5),findIndex:oi(6),filterReject:oi(7)},RA=ue,AA=dr,PA=tt("species"),Os=function(e){return AA>=51||!RA(function(){var t=[];return(t.constructor={})[PA]=function(){return{foo:1}},t[e](Boolean).foo!==1})},DA=nn.map;Me({target:"Array",proto:!0,forced:!Os("map")},{map:function(e){return DA(this,e,arguments.length>1?arguments[1]:void 0)}});var LA=_e,OA=Fa,MA=TypeError,NA=Object.getOwnPropertyDescriptor,UA=LA&&!function(){if(this!==void 0)return!0;try{Object.defineProperty([],"length",{writable:!1}).length=1}catch(e){return e instanceof TypeError}}(),VA=TypeError,F_=function(e){if(e>9007199254740991)throw VA("Maximum allowed index exceeded");return e},H_=Jn,jA=TypeError,G_=function(e,t){if(!delete e[t])throw jA("Cannot delete property "+H_(t)+" of "+H_(e))},BA=Me,FA=Vt,HA=ii,GA=Qn,zA=tn,WA=UA?function(e,t){if(OA(e)&&!NA(e,"length").writable)throw MA("Cannot set read only .length");return e.length=t}:function(e,t){return e.length=t},qA=F_,JA=Sh,KA=ws,kh=G_,XA=Os("splice"),QA=Math.max,YA=Math.min;BA({target:"Array",proto:!0,forced:!XA},{splice:function(e,t){var n,i,r,o,c,a,s=FA(this),l=zA(s),u=HA(e,l),p=arguments.length;for(p===0?n=i=0:p===1?(n=0,i=l-u):(n=p-2,i=YA(QA(GA(t),0),l-u)),qA(l+n-i),r=JA(s,i),o=0;o<i;o++)(c=u+o)in s&&KA(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]:kh(s,a);for(o=l;o>l-i+n;o--)kh(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]:kh(s,a);for(o=0;o<n;o++)s[o+u]=arguments[o+2];return WA(s,l-i+n),r}});var $A=ue,Ms=function(e,t){var n=[][e];return!!n&&$A(function(){n.call(null,t||function(){return 1},1)})},ZA=nn.forEach,Th=Ms("forEach")?[].forEach:function(e){return ZA(this,e,arguments.length>1?arguments[1]:void 0)};Me({target:"Array",proto:!0,forced:[].forEach!=Th},{forEach:Th});var z_=re,W_=y_,e2=S_,xh=Th,t2=Ln,q_=function(e){if(e&&e.forEach!==xh)try{t2(e,"forEach",xh)}catch(t){e.forEach=xh}};for(var Ih in W_)W_[Ih]&&q_(z_[Ih]&&z_[Ih].prototype);q_(e2);var n2=Me,r2=_n,i2=yn,a2=Ms,o2=pe([].join),s2=r2!=Object,c2=a2("join",",");n2({target:"Array",proto:!0,forced:s2||!c2},{join:function(e){return o2(i2(this),e===void 0?",":e)}});var u2=nn.filter;Me({target:"Array",proto:!0,forced:!Os("filter")},{filter:function(e){return u2(this,e,arguments.length>1?arguments[1]:void 0)}});var l2=Me,d2=ue,h2=Fa,f2=at,p2=Vt,m2=tn,J_=F_,K_=ws,v2=Sh,g2=Os,_2=dr,X_=tt("isConcatSpreadable"),y2=_2>=51||!d2(function(){var e=[];return e[X_]=!1,e.concat()[0]!==e}),b2=g2("concat"),S2=function(e){if(!f2(e))return!1;var t=e[X_];return t!==void 0?!!t:h2(e)};l2({target:"Array",proto:!0,arity:1,forced:!y2||!b2},{concat:function(e){var t,n,i,r,o,c=p2(this),a=v2(c,0),s=0;for(t=-1,i=arguments.length;t<i;t++)if(S2(o=t===-1?c:arguments[t]))for(r=m2(o),J_(s+r),n=0;n<r;n++,s++)n in o&&K_(a,s,o[n]);else J_(s+1),K_(a,s++,o);return a.length=s,a}});var Q_=pe,k2=Xt,wh=Date.prototype,Y_="Invalid Date",T2="toString",x2=Q_(wh.toString),I2=Q_(wh.getTime);String(new Date(NaN))!=Y_&&k2(wh,T2,function(){var e=I2(this);return e==e?x2(this):Y_});var w2=Qn,C2=zt,E2=ht,R2=RangeError,$_=function(e){var t=C2(E2(this)),n="",i=w2(e);if(i<0||i==1/0)throw R2("Wrong number of repetitions");for(;i>0;(i>>>=1)&&(t+=t))1&i&&(n+=t);return n},Z_=pe,A2=vr,ey=zt,P2=ht,D2=Z_($_),L2=Z_("".slice),O2=Math.ceil,ty=function(e){return function(t,n,i){var r,o,c=ey(P2(t)),a=A2(n),s=c.length,l=i===void 0?" ":ey(i);return a<=s||l==""?c:((o=D2(l,O2((r=a-s)/l.length))).length>r&&(o=L2(o,0,r)),e?c+o:o+c)}},M2={start:ty(!1),end:ty(!0)},N2=/Version\/10(?:\.\d+){1,2}(?: [\w./]+)?(?: Mobile\/\w+)? Safari\//.test(qn),U2=M2.start;Me({target:"String",proto:!0,forced:N2},{padStart:function(e){return U2(this,e,arguments.length>1?arguments[1]:void 0)}});var V2=Tt,ny=function(){var e=V2(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},Ch=ue,Eh=re.RegExp,Rh=Ch(function(){var e=Eh("a","y");return e.lastIndex=2,e.exec("abcd")!=null}),j2=Rh||Ch(function(){return!Eh("a","y").sticky}),ry={BROKEN_CARET:Rh||Ch(function(){var e=Eh("^r","gy");return e.lastIndex=2,e.exec("str")!=null}),MISSED_STICKY:j2,UNSUPPORTED_Y:Rh},B2=ue,F2=re.RegExp,iy=B2(function(){var e=F2(".","s");return!(e.dotAll&&e.exec(`
40
+ `)&&e.flags==="s")}),H2=ue,G2=re.RegExp,ay=H2(function(){var e=G2("(?<a>b)","g");return e.exec("b").groups.a!=="b"||"b".replace(e,"$<a>c")!=="bc"}),Ha=Xe,yu=pe,z2=zt,W2=ny,q2=ry,J2=Ar.exports,K2=Va,X2=Ke.get,Q2=iy,Y2=ay,$2=J2("native-string-replace",String.prototype.replace),bu=RegExp.prototype.exec,Ah=bu,Z2=yu("".charAt),eP=yu("".indexOf),tP=yu("".replace),Ph=yu("".slice),Dh=function(){var e=/a/,t=/b*/g;return Ha(bu,e,"a"),Ha(bu,t,"a"),e.lastIndex!==0||t.lastIndex!==0}(),oy=q2.BROKEN_CARET,Lh=/()??/.exec("")[1]!==void 0;(Dh||Lh||oy||Q2||Y2)&&(Ah=function(e){var t,n,i,r,o,c,a,s=this,l=X2(s),u=z2(e),p=l.raw;if(p)return p.lastIndex=s.lastIndex,t=Ha(Ah,p,u),s.lastIndex=p.lastIndex,t;var k=l.groups,x=oy&&s.sticky,E=Ha(W2,s),I=s.source,m=0,T=u;if(x&&(E=tP(E,"y",""),eP(E,"g")===-1&&(E+="g"),T=Ph(u,s.lastIndex),s.lastIndex>0&&(!s.multiline||s.multiline&&Z2(u,s.lastIndex-1)!==`
41
+ `)&&(I="(?: "+I+")",T=" "+T,m++),n=new RegExp("^(?:"+I+")",E)),Lh&&(n=new RegExp("^"+I+"$(?!\\s)",E)),Dh&&(i=s.lastIndex),r=Ha(bu,x?n:s,T),x?r?(r.input=Ph(r.input,m),r[0]=Ph(r[0],m),r.index=s.lastIndex,s.lastIndex+=r[0].length):s.lastIndex=0:Dh&&r&&(s.lastIndex=s.global?r.index+r[0].length:i),Lh&&r&&r.length>1&&Ha($2,r[0],n,function(){for(o=1;o<arguments.length-2;o++)arguments[o]===void 0&&(r[o]=void 0)}),r&&k)for(r.groups=c=K2(null),o=0;o<k.length;o++)c[(a=k[o])[0]]=r[a[1]];return r});var Su=Ah;Me({target:"RegExp",proto:!0,forced:/./.exec!==Su},{exec:Su});var sy=pe,cy=Xt,nP=Su,uy=ue,ly=tt,rP=Ln,iP=ly("species"),Oh=RegExp.prototype,Mh=function(e,t,n,i){var r=ly(e),o=!uy(function(){var l={};return l[r]=function(){return 7},""[e](l)!=7}),c=o&&!uy(function(){var l=!1,u=/a/;return e==="split"&&((u={}).constructor={},u.constructor[iP]=function(){return u},u.flags="",u[r]=/./[r]),u.exec=function(){return l=!0,null},u[r](""),!l});if(!o||!c||n){var a=sy(/./[r]),s=t(r,""[e],function(l,u,p,k,x){var E=sy(l),I=u.exec;return I===nP||I===Oh.exec?o&&!x?{done:!0,value:a(u,p,k)}:{done:!0,value:E(p,u,k)}:{done:!1}});cy(String.prototype,e,s[0]),cy(Oh,r,s[1])}i&&rP(Oh[r],"sham",!0)},aP=fh.charAt,dy=function(e,t,n){return t+(n?aP(e,t).length:1)},Nh=pe,oP=Vt,sP=Math.floor,Uh=Nh("".charAt),cP=Nh("".replace),Vh=Nh("".slice),uP=/\$([$&'`]|\d{1,2}|<[^>]*>)/g,lP=/\$([$&'`]|\d{1,2})/g,hy=Xe,dP=Tt,hP=it,fP=rt,pP=Su,mP=TypeError,jh=function(e,t){var n=e.exec;if(hP(n)){var i=hy(n,e,t);return i!==null&&dP(i),i}if(fP(e)==="RegExp")return hy(pP,e,t);throw mP("RegExp#exec called on incompatible receiver")},vP=Gi,fy=Xe,ku=pe,gP=Mh,_P=ue,yP=Tt,bP=it,SP=Et,kP=Qn,TP=vr,Ga=zt,xP=ht,IP=dy,wP=Kt,CP=function(e,t,n,i,r,o){var c=n+e.length,a=i.length,s=lP;return r!==void 0&&(r=oP(r),s=uP),cP(o,s,function(l,u){var p;switch(Uh(u,0)){case"$":return"$";case"&":return e;case"`":return Vh(t,0,n);case"'":return Vh(t,c);case"<":p=r[Vh(u,1,-1)];break;default:var k=+u;if(k===0)return l;if(k>a){var x=sP(k/10);return x===0?l:x<=a?i[x-1]===void 0?Uh(u,1):i[x-1]+Uh(u,1):l}p=i[k-1]}return p===void 0?"":p})},EP=jh,Bh=tt("replace"),RP=Math.max,AP=Math.min,PP=ku([].concat),Fh=ku([].push),py=ku("".indexOf),my=ku("".slice),DP="a".replace(/./,"$0")==="$0",vy=!!/./[Bh]&&/./[Bh]("a","$0")==="",LP=!_P(function(){var e=/./;return e.exec=function(){var t=[];return t.groups={a:"7"},t},"".replace(e,"$<a>")!=="7"});gP("replace",function(e,t,n){var i=vy?"$":"$0";return[function(r,o){var c=xP(this),a=SP(r)?void 0:wP(r,Bh);return a?fy(a,r,c,o):fy(t,Ga(c),r,o)},function(r,o){var c=yP(this),a=Ga(r);if(typeof o=="string"&&py(o,i)===-1&&py(o,"$<")===-1){var s=n(t,c,a,o);if(s.done)return s.value}var l=bP(o);l||(o=Ga(o));var u=c.global;if(u){var p=c.unicode;c.lastIndex=0}for(var k=[];;){var x=EP(c,a);if(x===null||(Fh(k,x),!u))break;Ga(x[0])===""&&(c.lastIndex=IP(a,TP(c.lastIndex),p))}for(var E,I="",m=0,T=0;T<k.length;T++){for(var v=Ga((x=k[T])[0]),C=RP(AP(kP(x.index),a.length),0),O=[],N=1;N<x.length;N++)Fh(O,(E=x[N])===void 0?E:String(E));var j=x.groups;if(l){var _=PP([v],O,C,a);j!==void 0&&Fh(_,j);var b=Ga(vP(o,void 0,_))}else b=CP(v,a,C,O,j,o);C>=m&&(I+=my(a,m,C)+b,m=C+v.length)}return I+my(a,m)}]},!LP||!DP||vy);var OP=Xe,MP=kt,NP=bn,UP=ny,gy=RegExp.prototype,_y=function(e){var t=e.flags;return t!==void 0||"flags"in gy||MP(e,"flags")||!NP(gy,e)?t:OP(UP,e)},VP=Xn.PROPER,jP=Xt,BP=Tt,yy=zt,FP=ue,HP=_y,by="toString",Sy=RegExp.prototype.toString,GP=FP(function(){return Sy.call({source:"a",flags:"b"})!="/a/b"}),zP=VP&&Sy.name!=by;(GP||zP)&&jP(RegExp.prototype,by,function(){var e=BP(this);return"/"+yy(e.source)+"/"+yy(HP(e))},{unsafe:!0});var WP=ue,qP=tt("iterator"),ky=!WP(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[qP]||new URL("https://a@b").username!=="a"||new URLSearchParams(new URLSearchParams("a=b")).get("a")!=="b"||new URL("http://\u0442\u0435\u0441\u0442").host!=="xn--e1aybc"||new URL("http://a#\u0431").hash!=="#%D0%B1"||n!=="a1c3"||new URL("http://x",void 0).host!=="x"}),Ty=du,JP=Math.floor,Hh=function(e,t){var n=e.length,i=JP(n/2);return n<8?KP(e,t):XP(e,Hh(Ty(e,0,i),t),Hh(Ty(e,i),t),t)},KP=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},XP=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},xy=Hh,Gh=Me,za=re,Tu=Xe,gr=pe,QP=_e,Iy=ky,wy=Xt,YP=Rs,$P=Hi,ZP=Pg,zh=Ke,Cy=ai,Wh=it,eD=kt,tD=Lr,nD=Pr,rD=Tt,Ey=at,kn=zt,iD=Va,Ry=Ze,qh=fu,aD=Cs,Wa=gu,oD=xy,sD=tt("iterator"),xu="URLSearchParams",Ay="URLSearchParamsIterator",Py=zh.set,Yn=zh.getterFor(xu),cD=zh.getterFor(Ay),uD=Object.getOwnPropertyDescriptor,Jh=function(e){if(!QP)return za[e];var t=uD(za,e);return t&&t.value},Dy=Jh("fetch"),Iu=Jh("Request"),Ns=Jh("Headers"),Kh=Iu&&Iu.prototype,Ly=Ns&&Ns.prototype,lD=za.RegExp,dD=za.TypeError,Oy=za.decodeURIComponent,hD=za.encodeURIComponent,fD=gr("".charAt),My=gr([].join),zi=gr([].push),Xh=gr("".replace),pD=gr([].shift),Ny=gr([].splice),Uy=gr("".split),mD=gr("".slice),vD=/\+/g,Vy=Array(4),gD=function(e){return Vy[e-1]||(Vy[e-1]=lD("((?:%[\\da-f]{2}){"+e+"})","gi"))},_D=function(e){try{return Oy(e)}catch(t){return e}},jy=function(e){var t=Xh(e,vD," "),n=4;try{return Oy(t)}catch(i){for(;n;)t=Xh(t,gD(n--),_D);return t}},yD=/[!'()~]|%20/g,bD={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+"},SD=function(e){return bD[e]},By=function(e){return Xh(hD(e),yD,SD)},Qh=ZP(function(e,t){Py(this,{type:Ay,iterator:qh(Yn(e).entries),kind:t})},"Iterator",function(){var e=cD(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),Fy=function(e){this.entries=[],this.url=null,e!==void 0&&(Ey(e)?this.parseObject(e):this.parseQuery(typeof e=="string"?fD(e,0)==="?"?mD(e,1):e:kn(e)))};Fy.prototype={type:xu,bindURL:function(e){this.url=e,this.update()},parseObject:function(e){var t,n,i,r,o,c,a,s=aD(e);if(s)for(n=(t=qh(e,s)).next;!(i=Tu(n,t)).done;){if(o=(r=qh(rD(i.value))).next,(c=Tu(o,r)).done||(a=Tu(o,r)).done||!Tu(o,r).done)throw dD("Expected sequence with length 2");zi(this.entries,{key:kn(c.value),value:kn(a.value)})}else for(var l in e)eD(e,l)&&zi(this.entries,{key:l,value:kn(e[l])})},parseQuery:function(e){if(e)for(var t,n,i=Uy(e,"&"),r=0;r<i.length;)(t=i[r++]).length&&(n=Uy(t,"="),zi(this.entries,{key:jy(pD(n)),value:jy(My(n,"="))}))},serialize:function(){for(var e,t=this.entries,n=[],i=0;i<t.length;)e=t[i++],zi(n,By(e.key)+"="+By(e.value));return My(n,"&")},update:function(){this.entries.length=0,this.parseQuery(this.url.query)},updateURL:function(){this.url&&this.url.update()}};var wu=function(){Cy(this,Us);var e=arguments.length>0?arguments[0]:void 0;Py(this,new Fy(e))},Us=wu.prototype;if(YP(Us,{append:function(e,t){Wa(arguments.length,2);var n=Yn(this);zi(n.entries,{key:kn(e),value:kn(t)}),n.updateURL()},delete:function(e){Wa(arguments.length,1);for(var t=Yn(this),n=t.entries,i=kn(e),r=0;r<n.length;)n[r].key===i?Ny(n,r,1):r++;t.updateURL()},get:function(e){Wa(arguments.length,1);for(var t=Yn(this).entries,n=kn(e),i=0;i<t.length;i++)if(t[i].key===n)return t[i].value;return null},getAll:function(e){Wa(arguments.length,1);for(var t=Yn(this).entries,n=kn(e),i=[],r=0;r<t.length;r++)t[r].key===n&&zi(i,t[r].value);return i},has:function(e){Wa(arguments.length,1);for(var t=Yn(this).entries,n=kn(e),i=0;i<t.length;)if(t[i++].key===n)return!0;return!1},set:function(e,t){Wa(arguments.length,1);for(var n,i=Yn(this),r=i.entries,o=!1,c=kn(e),a=kn(t),s=0;s<r.length;s++)(n=r[s]).key===c&&(o?Ny(r,s--,1):(o=!0,n.value=a));o||zi(r,{key:c,value:a}),i.updateURL()},sort:function(){var e=Yn(this);oD(e.entries,function(t,n){return t.key>n.key?1:-1}),e.updateURL()},forEach:function(e){for(var t,n=Yn(this).entries,i=tD(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 Qh(this,"keys")},values:function(){return new Qh(this,"values")},entries:function(){return new Qh(this,"entries")}},{enumerable:!0}),wy(Us,sD,Us.entries,{name:"entries"}),wy(Us,"toString",function(){return Yn(this).serialize()},{enumerable:!0}),$P(wu,xu),Gh({global:!0,constructor:!0,forced:!Iy},{URLSearchParams:wu}),!Iy&&Wh(Ns)){var kD=gr(Ly.has),TD=gr(Ly.set),Hy=function(e){if(Ey(e)){var t,n=e.body;if(nD(n)===xu)return t=e.headers?new Ns(e.headers):new Ns,kD(t,"content-type")||TD(t,"content-type","application/x-www-form-urlencoded;charset=UTF-8"),iD(e,{body:Ry(0,kn(n)),headers:Ry(0,t)})}return e};if(Wh(Dy)&&Gh({global:!0,enumerable:!0,dontCallGetSet:!0,forced:!0},{fetch:function(e){return Dy(e,arguments.length>1?Hy(arguments[1]):{})}}),Wh(Iu)){var Yh=function(e){return Cy(this,Kh),new Iu(e,arguments.length>1?Hy(arguments[1]):{})};Kh.constructor=Yh,Yh.prototype=Kh,Gh({global:!0,constructor:!0,dontCallGetSet:!0,forced:!0},{Request:Yh})}}var xD={URLSearchParams:wu,getState:Yn},ID=Object.is||function(e,t){return e===t?e!==0||1/e==1/t:e!=e&&t!=t},wD=Xe,CD=Tt,ED=Et,RD=ht,Gy=ID,zy=zt,AD=Kt,PD=jh;Mh("search",function(e,t,n){return[function(i){var r=RD(this),o=ED(i)?void 0:AD(i,e);return o?wD(o,i,r):new RegExp(i)[e](zy(r))},function(i){var r=CD(this),o=zy(i),c=n(t,r,o);if(c.done)return c.value;var a=r.lastIndex;Gy(a,0)||(r.lastIndex=0);var s=PD(r,o);return Gy(r.lastIndex,a)||(r.lastIndex=a),s===null?-1:s.index}]}),new Date().getTime();var $h=0,rn=function(){return new Date().getTime()+$h},Wy=function(){var e=new Date;return e.setTime(rn()),e.toLocaleString()},DD=Xe,LD=Tt,OD=Et,MD=vr,Zh=zt,ND=ht,UD=Kt,VD=dy,qy=jh;Mh("match",function(e,t,n){return[function(i){var r=ND(this),o=OD(i)?void 0:UD(i,e);return o?DD(o,i,r):new RegExp(i)[e](Zh(r))},function(i){var r=LD(this),o=Zh(i),c=n(t,r,o);if(c.done)return c.value;if(!r.global)return qy(r,o);var a=r.unicode;r.lastIndex=0;for(var s,l=[],u=0;(s=qy(r,o))!==null;){var p=Zh(s[0]);l[u]=p,p===""&&(r.lastIndex=VD(o,MD(r.lastIndex),a)),u++}return u===0?null:l}]});var jD=at,BD=rt,FD=tt("match"),Jy=function(e){var t;return jD(e)&&((t=e[FD])!==void 0?!!t:BD(e)=="RegExp")},HD=At.f,GD=_e,ef=re,Vs=pe,zD=bs,WD=vu,qD=Ln,JD=ri.f,Ky=bn,KD=Jy,Xy=zt,XD=_y,Qy=ry,QD=function(e,t,n){n in e||HD(e,n,{configurable:!0,get:function(){return t[n]},set:function(i){t[n]=i}})},YD=Xt,$D=ue,ZD=kt,eL=Ke.enforce,tL=As,Yy=iy,$y=ay,nL=tt("match"),si=ef.RegExp,qa=si.prototype,rL=ef.SyntaxError,iL=Vs(qa.exec),Cu=Vs("".charAt),Zy=Vs("".replace),e0=Vs("".indexOf),aL=Vs("".slice),oL=/^\?<[^\s\d!#%&*+<=>@^][^\s!#%&*+<=>@^]*>/,Wi=/a/g,tf=/a/g,sL=new si(Wi)!==Wi,t0=Qy.MISSED_STICKY,cL=Qy.UNSUPPORTED_Y,uL=GD&&(!sL||t0||Yy||$y||$D(function(){return tf[nL]=!1,si(Wi)!=Wi||si(tf)==tf||si(Wi,"i")!="/a/i"}));if(zD("RegExp",uL)){for(var qi=function(e,t){var n,i,r,o,c,a,s=Ky(qa,this),l=KD(e),u=t===void 0,p=[],k=e;if(!s&&l&&u&&e.constructor===qi)return e;if((l||Ky(qa,e))&&(e=e.source,u&&(t=XD(k))),e=e===void 0?"":Xy(e),t=t===void 0?"":Xy(t),k=e,Yy&&"dotAll"in Wi&&(i=!!t&&e0(t,"s")>-1)&&(t=Zy(t,/s/g,"")),n=t,t0&&"sticky"in Wi&&(r=!!t&&e0(t,"y")>-1)&&cL&&(t=Zy(t,/y/g,"")),$y&&(o=function(x){for(var E,I=x.length,m=0,T="",v=[],C={},O=!1,N=!1,j=0,_="";m<=I;m++){if((E=Cu(x,m))==="\\")E+=Cu(x,++m);else if(E==="]")O=!1;else if(!O)switch(!0){case E==="[":O=!0;break;case E==="(":iL(oL,aL(x,m+1))&&(m+=2,N=!0),T+=E,j++;continue;case(E===">"&&N):if(_===""||ZD(C,_))throw new rL("Invalid capture group name");C[_]=!0,v[v.length]=[_,j],N=!1,_="";continue}N?_+=E:T+=E}return[T,v]}(e),e=o[0],p=o[1]),c=WD(si(e,t),s?this:qa,qi),(i||r||p.length)&&(a=eL(c),i&&(a.dotAll=!0,a.raw=qi(function(x){for(var E,I=x.length,m=0,T="",v=!1;m<=I;m++)(E=Cu(x,m))!=="\\"?v||E!=="."?(E==="["?v=!0:E==="]"&&(v=!1),T+=E):T+="[\\s\\S]":T+=E+Cu(x,++m);return T}(e),n)),r&&(a.sticky=!0),p.length&&(a.groups=p)),e!==k)try{qD(c,"source",k===""?"(?:)":k)}catch(x){}return c},n0=JD(si),r0=0;n0.length>r0;)QD(qi,si,n0[r0++]);qa.constructor=qi,qi.prototype=qa,YD(ef,"RegExp",qi,{constructor:!0})}tL("RegExp");var i0=pe(1 .valueOf),a0=`
42
+ \v\f\r \xA0\u1680\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028\u2029\uFEFF`,lL=ht,dL=zt,o0=pe("".replace),Eu=`[
43
+ \v\f\r \xA0\u1680\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028\u2029\uFEFF]`,hL=RegExp("^"+Eu+Eu+"*"),fL=RegExp(Eu+Eu+"*$"),nf=function(e){return function(t){var n=dL(lL(t));return 1&e&&(n=o0(n,hL,"")),2&e&&(n=o0(n,fL,"")),n}},Ru={start:nf(1),end:nf(2),trim:nf(3)},pL=_e,rf=re,s0=pe,mL=bs,vL=Xt,c0=kt,gL=vu,_L=bn,yL=Di,u0=Ra,bL=ue,SL=ri.f,kL=be.f,TL=At.f,xL=i0,IL=Ru.trim,l0="Number",ci=rf.Number,af=ci.prototype,wL=rf.TypeError,CL=s0("".slice),Au=s0("".charCodeAt),EL=function(e){var t=u0(e,"number");return typeof t=="bigint"?t:RL(t)},RL=function(e){var t,n,i,r,o,c,a,s,l=u0(e,"number");if(yL(l))throw wL("Cannot convert a Symbol value to a number");if(typeof l=="string"&&l.length>2){if(l=IL(l),(t=Au(l,0))===43||t===45){if((n=Au(l,2))===88||n===120)return NaN}else if(t===48){switch(Au(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=CL(l,2)).length,a=0;a<c;a++)if((s=Au(o,a))<48||s>r)return NaN;return parseInt(o,i)}}return+l};if(mL(l0,!ci(" 0o1")||!ci("0b1")||ci("+0x1"))){for(var Pu,Ja=function(e){var t=arguments.length<1?0:ci(EL(e)),n=this;return _L(af,n)&&bL(function(){xL(n)})?gL(Object(t),n,Ja):t},d0=pL?SL(ci):"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(","),of=0;d0.length>of;of++)c0(ci,Pu=d0[of])&&!c0(Ja,Pu)&&TL(Ja,Pu,kL(ci,Pu));Ja.prototype=af,af.constructor=Ja,vL(rf,l0,Ja,{constructor:!0})}var AL=_s.includes,PL=cu;Me({target:"Array",proto:!0,forced:ue(function(){return!Array(1).includes()})},{includes:function(e){return AL(this,e,arguments.length>1?arguments[1]:void 0)}}),PL("includes");var DL=Jy,LL=TypeError,h0=function(e){if(DL(e))throw LL("The method doesn't accept regular expressions");return e},OL=tt("match"),f0=function(e){var t=/./;try{"/./"[e](t)}catch(n){try{return t[OL]=!1,"/./"[e](t)}catch(i){}}return!1},ML=Me,NL=h0,UL=ht,p0=zt,VL=f0,jL=pe("".indexOf);ML({target:"String",proto:!0,forced:!VL("includes")},{includes:function(e){return!!~jL(p0(UL(this)),p0(NL(e)),arguments.length>1?arguments[1]:void 0)}});var BL=Me,FL=_s.indexOf,HL=Ms,sf=pe([].indexOf),m0=!!sf&&1/sf([1],1,-0)<0,GL=HL("indexOf");BL({target:"Array",proto:!0,forced:m0||!GL},{indexOf:function(e){var t=arguments.length>1?arguments[1]:void 0;return m0?sf(this,e,t)||0:FL(this,e,t)}});var zL=Vt,v0=ks,WL=wg;Me({target:"Object",stat:!0,forced:ue(function(){v0(1)}),sham:!WL},{getPrototypeOf:function(e){return v0(zL(e))}});var qL=Gi,JL=Ut,KL=Tt;Me({target:"Reflect",stat:!0,forced:!ue(function(){Reflect.apply(function(){})})},{apply:function(e,t,n){return qL(JL(e),t,KL(n))}});var XL=_e,QL=Xn.EXISTS,g0=pe,YL=At.f,_0=Function.prototype,$L=g0(_0.toString),y0=/function\b(?:\s|\/\*[\S\s]*?\*\/|\/\/[^\n\r]*[\n\r]+)*([^\s(/]*)/,ZL=g0(y0.exec);XL&&!QL&&YL(_0,"name",{configurable:!0,get:function(){try{return ZL(y0,$L(this))[1]}catch(e){return""}}});var eO=Me,b0=Date,tO=pe(b0.prototype.getTime);eO({target:"Date",stat:!0},{now:function(){return tO(new b0)}});var js,Ka,S0,cf,Bs=rt(re.process)=="process",nO=_u,rO=Jn,iO=TypeError,k0=function(e){if(nO(e))return e;throw iO(rO(e)+" is not a constructor")},T0=Tt,aO=k0,oO=Et,sO=tt("species"),Du=function(e,t){var n,i=T0(e).constructor;return i===void 0||oO(n=T0(i)[sO])?t:aO(n)},x0=/(?:ipad|iphone|ipod).*applewebkit/i.test(qn),Tn=re,cO=Gi,uO=Lr,I0=it,lO=kt,dO=ue,w0=yg,hO=Ba,C0=fr,fO=gu,pO=x0,mO=Bs,uf=Tn.setImmediate,lf=Tn.clearImmediate,vO=Tn.process,df=Tn.Dispatch,gO=Tn.Function,E0=Tn.MessageChannel,_O=Tn.String,hf=0,Fs={},yO="onreadystatechange";try{js=Tn.location}catch(e){}var ff=function(e){if(lO(Fs,e)){var t=Fs[e];delete Fs[e],t()}},pf=function(e){return function(){ff(e)}},R0=function(e){ff(e.data)},A0=function(e){Tn.postMessage(_O(e),js.protocol+"//"+js.host)};uf&&lf||(uf=function(e){fO(arguments.length,1);var t=I0(e)?e:gO(e),n=hO(arguments,1);return Fs[++hf]=function(){cO(t,void 0,n)},Ka(hf),hf},lf=function(e){delete Fs[e]},mO?Ka=function(e){vO.nextTick(pf(e))}:df&&df.now?Ka=function(e){df.now(pf(e))}:E0&&!pO?(cf=(S0=new E0).port2,S0.port1.onmessage=R0,Ka=uO(cf.postMessage,cf)):Tn.addEventListener&&I0(Tn.postMessage)&&!Tn.importScripts&&js&&js.protocol!=="file:"&&!dO(A0)?(Ka=A0,Tn.addEventListener("message",R0,!1)):Ka=yO in C0("script")?function(e){w0.appendChild(C0("script")).onreadystatechange=function(){w0.removeChild(this),ff(e)}}:function(e){setTimeout(pf(e),0)});var Hs,Ji,Gs,Xa,mf,vf,gf,P0,D0={set:uf,clear:lf},bO=re,SO=/ipad|iphone|ipod/i.test(qn)&&bO.Pebble!==void 0,kO=/web0s(?!.*chrome)/i.test(qn),Ki=re,L0=Lr,TO=be.f,_f=D0.set,xO=x0,IO=SO,wO=kO,yf=Bs,O0=Ki.MutationObserver||Ki.WebKitMutationObserver,M0=Ki.document,N0=Ki.process,Lu=Ki.Promise,U0=TO(Ki,"queueMicrotask"),V0=U0&&U0.value;V0||(Hs=function(){var e,t;for(yf&&(e=N0.domain)&&e.exit();Ji;){t=Ji.fn,Ji=Ji.next;try{t()}catch(n){throw Ji?Xa():Gs=void 0,n}}Gs=void 0,e&&e.enter()},xO||yf||wO||!O0||!M0?!IO&&Lu&&Lu.resolve?((gf=Lu.resolve(void 0)).constructor=Lu,P0=L0(gf.then,gf),Xa=function(){P0(Hs)}):yf?Xa=function(){N0.nextTick(Hs)}:(_f=L0(_f,Ki),Xa=function(){_f(Hs)}):(mf=!0,vf=M0.createTextNode(""),new O0(Hs).observe(vf,{characterData:!0}),Xa=function(){vf.data=mf=!mf}));var CO=V0||function(e){var t={fn:e,next:void 0};Gs&&(Gs.next=t),Ji||(Ji=t,Xa()),Gs=t},EO=re,bf=function(e){try{return{error:!1,value:e()}}catch(t){return{error:!0,value:t}}},j0=function(){this.head=null,this.tail=null};j0.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 RO=j0,zs=re.Promise,B0=typeof Deno=="object"&&Deno&&typeof Deno.version=="object",AO=!B0&&!Bs&&typeof window=="object"&&typeof document=="object",PO=re,Ws=zs,DO=it,LO=bs,OO=d,MO=tt,NO=AO,UO=B0,Sf=dr;Ws&&Ws.prototype;var VO=MO("species"),F0=!1,H0=DO(PO.PromiseRejectionEvent),jO=LO("Promise",function(){var e=OO(Ws),t=e!==String(Ws);if(!t&&Sf===66)return!0;if(!Sf||Sf<51||!/native code/.test(e)){var n=new Ws(function(r){r(1)}),i=function(r){r(function(){},function(){})};if((n.constructor={})[VO]=i,!(F0=n.then(function(){})instanceof i))return!0}return!t&&(NO||UO)&&!H0}),Xi={CONSTRUCTOR:jO,REJECTION_EVENT:H0,SUBCLASSING:F0},Qa={},G0=Ut,BO=TypeError,FO=function(e){var t,n;this.promise=new e(function(i,r){if(t!==void 0||n!==void 0)throw BO("Bad Promise constructor");t=i,n=r}),this.resolve=G0(t),this.reject=G0(n)};Qa.f=function(e){return new FO(e)};var kf,z0,W0,HO=Me,Ou=Bs,ui=re,Ya=Xe,q0=Xt,J0=ja,GO=Hi,zO=As,WO=Ut,Mu=it,qO=at,JO=ai,KO=Du,K0=D0.set,Tf=CO,XO=function(e,t){var n=EO.console;n&&n.error&&(arguments.length==1?n.error(e):n.error(e,t))},QO=bf,YO=RO,X0=Ke,Nu=zs,Q0=Qa,Uu="Promise",Y0=Xi.CONSTRUCTOR,$O=Xi.REJECTION_EVENT,ZO=Xi.SUBCLASSING,xf=X0.getterFor(Uu),eM=X0.set,$a=Nu&&Nu.prototype,Za=Nu,Vu=$a,$0=ui.TypeError,If=ui.document,wf=ui.process,Cf=Q0.f,tM=Cf,nM=!!(If&&If.createEvent&&ui.dispatchEvent),Z0="unhandledrejection",eb=function(e){var t;return!(!qO(e)||!Mu(t=e.then))&&t},tb=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&&iM(t),t.rejection=1),a===!0?n=o:(u&&u.enter(),n=a(o),u&&(u.exit(),r=!0)),n===e.promise?l($0("Promise-chain cycle")):(i=eb(n))?Ya(i,n,s,l):s(n)):l(o)}catch(p){u&&!r&&u.exit(),l(p)}},nb=function(e,t){e.notified||(e.notified=!0,Tf(function(){for(var n,i=e.reactions;n=i.get();)tb(n,e);e.notified=!1,t&&!e.rejection&&rM(e)}))},rb=function(e,t,n){var i,r;nM?((i=If.createEvent("Event")).promise=t,i.reason=n,i.initEvent(e,!1,!0),ui.dispatchEvent(i)):i={promise:t,reason:n},!$O&&(r=ui["on"+e])?r(i):e===Z0&&XO("Unhandled promise rejection",n)},rM=function(e){Ya(K0,ui,function(){var t,n=e.facade,i=e.value;if(ib(e)&&(t=QO(function(){Ou?wf.emit("unhandledRejection",i,n):rb(Z0,n,i)}),e.rejection=Ou||ib(e)?2:1,t.error))throw t.value})},ib=function(e){return e.rejection!==1&&!e.parent},iM=function(e){Ya(K0,ui,function(){var t=e.facade;Ou?wf.emit("rejectionHandled",t):rb("rejectionhandled",t,e.value)})},eo=function(e,t,n){return function(i){e(t,i,n)}},to=function(e,t,n){e.done||(e.done=!0,n&&(e=n),e.value=t,e.state=2,nb(e,!0))},Ef=function(e,t,n){if(!e.done){e.done=!0,n&&(e=n);try{if(e.facade===t)throw $0("Promise can't be resolved itself");var i=eb(t);i?Tf(function(){var r={done:!1};try{Ya(i,t,eo(Ef,r,e),eo(to,r,e))}catch(o){to(r,o,e)}}):(e.value=t,e.state=1,nb(e,!1))}catch(r){to({done:!1},r,e)}}};if(Y0&&(Vu=(Za=function(e){JO(this,Vu),WO(e),Ya(kf,this);var t=xf(this);try{e(eo(Ef,t),eo(to,t))}catch(n){to(t,n)}}).prototype,(kf=function(e){eM(this,{type:Uu,done:!1,notified:!1,parent:!1,reactions:new YO,rejection:!1,state:0,value:void 0})}).prototype=q0(Vu,"then",function(e,t){var n=xf(this),i=Cf(KO(this,Za));return n.parent=!0,i.ok=!Mu(e)||e,i.fail=Mu(t)&&t,i.domain=Ou?wf.domain:void 0,n.state==0?n.reactions.add(i):Tf(function(){tb(i,n)}),i.promise}),z0=function(){var e=new kf,t=xf(e);this.promise=e,this.resolve=eo(Ef,t),this.reject=eo(to,t)},Q0.f=Cf=function(e){return e===Za||e===void 0?new z0(e):tM(e)},Mu(Nu)&&$a!==Object.prototype)){W0=$a.then,ZO||q0($a,"then",function(e,t){var n=this;return new Za(function(i,r){Ya(W0,n,i,r)}).then(e,t)},{unsafe:!0});try{delete $a.constructor}catch(e){}J0&&J0($a,Vu)}HO({global:!0,constructor:!0,wrap:!0,forced:Y0},{Promise:Za}),GO(Za,Uu,!1),zO(Uu);var aM=zs,ab=Xi.CONSTRUCTOR||!mu(function(e){aM.all(e).then(void 0,function(){})}),oM=Xe,sM=Ut,cM=Qa,uM=bf,lM=Es;Me({target:"Promise",stat:!0,forced:ab},{all:function(e){var t=this,n=cM.f(t),i=n.resolve,r=n.reject,o=uM(function(){var c=sM(t.resolve),a=[],s=0,l=1;lM(e,function(u){var p=s++,k=!1;l++,oM(c,t,u).then(function(x){k||(k=!0,a[p]=x,--l||i(a))},r)}),--l||i(a)});return o.error&&r(o.value),n.promise}});var dM=Me,hM=Xi.CONSTRUCTOR,Rf=zs,fM=Rn,pM=it,mM=Xt,ob=Rf&&Rf.prototype;if(dM({target:"Promise",proto:!0,forced:hM,real:!0},{catch:function(e){return this.then(void 0,e)}}),pM(Rf)){var sb=fM("Promise").prototype.catch;ob.catch!==sb&&mM(ob,"catch",sb,{unsafe:!0})}var vM=Xe,gM=Ut,_M=Qa,yM=bf,bM=Es;Me({target:"Promise",stat:!0,forced:ab},{race:function(e){var t=this,n=_M.f(t),i=n.reject,r=yM(function(){var o=gM(t.resolve);bM(e,function(c){vM(o,t,c).then(n.resolve,i)})});return r.error&&i(r.value),n.promise}});var SM=Xe,kM=Qa;Me({target:"Promise",stat:!0,forced:Xi.CONSTRUCTOR},{reject:function(e){var t=kM.f(this);return SM(t.reject,void 0,e),t.promise}});var TM=Tt,xM=at,IM=Qa,cb=function(e,t){if(TM(e),xM(t)&&t.constructor===e)return t;var n=IM.f(e);return(0,n.resolve)(t),n.promise},wM=Me,CM=Xi.CONSTRUCTOR,EM=cb;Rn("Promise"),wM({target:"Promise",stat:!0,forced:CM},{resolve:function(e){return EM(this,e)}});var RM=Vt,ub=au;Me({target:"Object",stat:!0,forced:ue(function(){ub(1)})},{keys:function(e){return ub(RM(e))}});var lb="canvas",Ee="audio",Te="video",Af="screen",Or="small",ju="big",pt="auxiliary",Mn="aux",Bu="smallVideo",db="user",hb="environment",en="mute",_r="unmute",Mt="ended",li="playing",di="pause",no="error",Pf="loadeddata",qs="audioinput",Fu="videoinput",fb="detail",AM="text",Ye="main",Mr="backup",PM="banned",DM="kick",LM="user_time_out",OM="room_disband",pb="sei-message",ro="PLAYING",yr="PAUSED",hi="STOPPED",io="inactive",fi="sendonly",Df="recvonly",mb="add",vb="remove",MM="replace",Lf="track",NM="wss://trtc.rtc.qq.com",UM="wss://webrtc.qq.com",Hu="qcloud",VM="trtc",jM="webrtc",Js="",gb="jssdk_log",BM="jssdk_event",FM="jssdk_new_endreport",Of=function(e){return Js=e},HM=1,GM=2,Gu="live",ao=20,Mf=21,br="anchor",Qi="audience",Sr="5Y2wZK8nANNAoVw6dSAHVjNxrD1ObBM2kBPV",Ks="224d130c-7b5c-415b-aaa2-79c2eb5a6df2",zM=2,gt=Ye,Dt=pt,zu="unknown",an="DISCONNECTED",_b="CONNECTING",Nf="RECONNECTING",fn="CONNECTED",WM="new",Wu="connecting",yb="failed",Uf="closed",qM="disconnected",bb="connected",JM="completed",Vf=30,Sb="join",KM="delta-join",kb="rejoin",XM="leave",QM="delta-leave",Tb="publish",YM="delta-publish",xb="unpublish",Ib="subscribe",wb="unsubscribe",Cb="uplink-connection",Eb="uplink-reconnection",Rb="downlink-connection",Ab="downlink-reconnection",qu="setLocalDescription",Pb="setRemoteDescription",Db="iceConnectionState",Xs="stream-initialize",jf="websocketConnectionState",Lb="websocketReconnectionState",Ob="update-stream",Mb="recover-subscription",Nb="start-mix-transcode",Ub="stop-mix-transcode",Vb="player-error",jb="schedule",Bf="unsubscribe",Ff="subscribe_change",Qs="unified-plan",Hf="plan-b",Gf={MANUAL:"manual",PRESET_LAYOUT:"preset-layout"},Bb={REMOTE:"$PLACE_HOLDER_REMOTE$"},Fb={IT_AUDIO_VIDEO:0,IT_PICTURE:2,IT_CANVAS:3,IT_PURE_AUDIO:4,IT_PURE_VIDEO:5},bt="string",wt="number",on="boolean",$M="array",kr="object",sn={ADD:mb,REMOVE:vb},zf={unknown:0,wifi:1,"4g":2,"3g":3,"2g":4,wired:5},Hb=-1,Ys=0,ZM=1,Gb=ju,zb=Or,Wb=6048e5,eN="schedule.rtc.qq.com",tN="schedule.rtc.qcloud.com",nN="schedule.rtc.tencentcloud.com",rN="schedule-ecdn.rtc.tencentcloud.com",Wf="",qb=function(e){return Wf=e},$s="TRTC",cn="Client",pi="LocalStream",qf="RemoteStream",iN="Stream",Jf="web.sdk.qcloud.com",Jb="web.sdk.tencent.cn",Kb="web.sdk.cloud.tencent.cn",Xb="https://console.cloud.tencent.com/trtc",oo="https://".concat(Jf,"/trtc/webrtc/doc"),Kf="".concat(oo,"/zh-cn/"),Xf="trtc_error_assistance",Ju="default",Qb="communications",Nn={TRACE:0,DEBUG:1,INFO:2,WARN:3,ERROR:4,NONE:5},aN=1,Yb=2,oN=1,$b=2,Yi=Object.keys(Nn),sN=["normal leave","timeout leave","kick","role change"],Ku=2e3,so="ric",Xu="raf",cN="interval",Zb="timeout",eS="Resolution reset to 1080p, need to upgrade ability here https://cloud.tencent.com/document/product/647/85386",uN={"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},Qf=["width","height","frameRate","facingMode","sampleRate","sampleSize","channelCount","deviceId"],lN=ht,tS=zt,dN=/"/g,hN=pe("".replace),nS=function(e,t,n,i){var r=tS(lN(e)),o="<"+t;return n!==""&&(o+=" "+n+'="'+hN(tS(i),dN,"&quot;")+'"'),o+">"+r+"</"+t+">"},fN=ue,rS=function(e){return fN(function(){var t=""[e]('"');return t!==t.toLowerCase()||t.split('"').length>3})},pN=nS;Me({target:"String",proto:!0,forced:rS("link")},{link:function(e){return pN(this,"a","href",e)}}),Me({target:"Array",stat:!0},{isArray:Fa});var mN="AVOID_REPEATED_CALL",vN="INVALID_PARAMETER_REQUIRED",iS="INVALID_PARAMETER_TYPE",gN="INVALID_PARAMETER_EMPTY",aS="INVALID_PARAMETER_INSTANCE",_N="INVALID_PARAMETER_RANGE",yN="API_CALL_TIMEOUT",bN="SIGNAL_CHANNEL_RECONNECTION_FAILED",SN="SIGNAL_CHANNEL_SETUP_FAILED",kN="ERROR_MESSAGE",TN="EXCHANGE_SDP_TIMEOUT",xN="DOWNLINK_RECONNECTION_FAILED",IN="EXCHANGE_SDP_FAILED",wN="UPLINK_RECONNECTION_FAILED",CN="INVALID_PURE_AUDIO",EN="INVALID_STREAMID",RN="INVALID_USER_DEFINE_RECORDID",AN="INVALID_USER_DEFINE_PUSH_ARGS",PN="INVALID_PROXY",DN="INVALID_JOIN",LN="INVALID_ROOMID_STRING",ON="INVALID_ROOMID_INTEGER",MN="JOIN_ROOM_TIMEOUT",oS="JOIN_ROOM_FAILED",NN="REJOIN_ROOM_FAILED",UN="INVALID_DESTROY",VN="INVALID_PUBLISH",jN="INVALID_UNPUBLISH",BN="INVALID_AUDIENCE",FN="INVALID_INITIALIZE",HN="INVALID_DUPLICATE_PUBLISHING",Yf="INVALID_REMOTE_STREAM",GN="SUBSCRIBE_FAILED",zN="INVALID_ROLE",WN="INVALID_OPERATION_SWITCH_ROLE",qN="SWITCH_ROLE_TIMEOUT",JN="SWITCH_ROLE_FAILED",KN="CLIENT_BANNED",sS="INVALID_OPERATION_START_PUBLISH_CDN",XN="INVALID_OPERATION_STOP_PUBLISH_CDN",QN="INVALID_STREAM_ID",cS="START_PUBLISH_CDN_FAILED",uS="STOP_PUBLISH_CDN_FAILED",YN="START_MIX_TRANSCODE",$N="STOP_MIX_TRANSCODE",ZN="INVALID_AUDIO_VOLUME",e3="ENABLE_SMALL_STREAM_PUBLISHED",t3="DISABLE_SMALL_STREAM_PUBLISHED",n3="NOT_SUPPORTED_SMALL_STREAM",r3="INVALID_SMALL_STREAM_PROFILE",i3="INVALID_PARAMETER_REMOTE_STREAM",a3="INVALID_SWITCH_DEVICE",o3="INVALID_SWITCH_DEVICE_PUBLISHING",lS="INVALID_REPLACE_TRACK",s3="INVALID_INITIALIZE_LOCAL_STREAM",c3="INVALID_ADD_TRACK_REPETITIVE",u3="INVALID_ADD_TRACK_REMOVING",l3="INVALID_ADD_TRACK_PUBLISHING",dS="INVALID_STREAM_INITIALIZED",d3="INVALID_ADD_TRACK_NUMBER",h3="INVALID_REMOVE_AUDIO_TRACK",f3="INVALID_REMOVE_AUDIO_ADDING",p3="INVALID_REMOVE_AUDIO_ON",m3="INVALID_REMOVE_TRACK_PUBLISHING",v3="INVALID_REMOVE_TRACK_NOT_PUBLISHING",g3="INVALID_REMOVE_TRACK_NUMBER",_3="INVALID_REPLACE_TRACK_NO_TRACK",y3="REPEAT_JOIN",$f="CLIENT_DESTROYED",b3="START_MIX_TRANSCODE_FAILED",S3="STOP_MIX_TRANSCODE_FAILED",k3="MIX_TRANSCODE_NOT_STARTED",T3="CANNOT_LESS_THAN_ZERO",x3="MIX_PARAMS_VIDEO_FRAMERATE",I3="MIX_PARAMS_VIDEO_GOP",w3="MIX_PARAMS_AUDIO_BITRATE",C3="MIX_PARAMS_USER_Z_ORDER",E3="MIX_PARAMS_NOT_SELF",R3="MIX_PARAMS_USER_STREAM",A3="INVALID_ELEMENT_ID",P3="INVALID_ELEMENT_ID_TYPE",Zf="PLAY_FAILED",D3="INVALID_CREATE_STREAM_SOURCE",L3="INVALID_CREATE_STREAM_SCREEN",O3="INVALID_CREATE_STREAM_AUDIO",M3="INVALID_CREATE_STREAM_SCREEN_AUDIO",hS="NOT_SUPPORTED_HTTP",fS="NOT_SUPPORTED_WEBRTC",N3="NOT_SUPPORTED_PROFILE",pS="NOT_SUPPORTED_H264ENCODE",mS="NOT_SUPPORTED_H264DECODE",ep="NOT_SUPPORTED_TRACK",U3="NOT_SUPPORTED_SWITCH_DEVICE",V3="NOT_SUPPORTED_CAPTURE",j3="NOT_SUPPORTED_AUX",B3="MICROPHONE_NOT_FOUND",F3="CAMERA_NOT_FOUND",vS="SIGNAL_RESPONSE_FAILED",H3="CATCH_HANDLER_ERROR",G3="API_NOT_EXIST",z3="CONNECTION_CLOSED",W3="SUBSCRIBE_ALL_FALSE",gS="SEI_NOT_SUPPORT",q3="SEI_DISABLED",J3="SEI_EMPTY",K3="SEI_OVERSIZE",X3="SEI_BEFORE_PUBLISH",Q3="SEI_NOT_VIDEO",Y3="CALL_FREQUENCY_LIMIT",$3="CONNECTION_ABORTED",tp="API_CALL_ABORTED",Z3="DUPLICATE_AUX",mi={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(yi(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(yi(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(Qi,', please call switchRole("').concat(br,'") 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(br," or ").concat(Qi,"."),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 failed\uFF0Cbrowser 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."},_S=re,e4=ue,t4=zt,n4=Ru.trim,r4=pe("".charAt),Qu=_S.parseFloat,yS=_S.Symbol,bS=yS&&yS.iterator,SS=1/Qu(`
44
+ \v\f\r \xA0\u1680\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028\u2029\uFEFF-0`)!=-1/0||bS&&!e4(function(){Qu(Object(bS))})?function(e){var t=n4(t4(e)),n=Qu(t);return n===0&&r4(t,0)=="-"?-0:n}:Qu;Me({global:!0,forced:parseFloat!=SS},{parseFloat:SS});var Ce=window.navigator&&window.navigator.userAgent||"",kS=/AppleWebKit\/([\d.]+)/i.exec(Ce);kS&&parseFloat(kS.pop());var np=/iPad/i.test(Ce),TS=navigator.maxTouchPoints&&navigator.maxTouchPoints>2&&/Macintosh/.test(Ce),rp=/iPhone/i.test(Ce)&&!np,i4=/iPod/i.test(Ce),vi=rp||np||i4||TS,$i=/Android/i.test(Ce);$i&&function(){var e=Ce.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])}(),$i&&/webkit/i.test(Ce);var Tr=/Firefox/i.test(Ce),xS=Tr&&function(){var e=Ce.match(/Firefox\/(\d+)/);return e&&e[1]?parseFloat(e[1]):null}(),Yu=/Edge\//i.test(Ce),a4=Yu&&function(){var e=Ce.match(/Edge\/(\d+)/i);if(e&&e[1])return e[1]}(),$u=/Edg\//i.test(Ce),IS=$u&&function(){var e=Ce.match(/Edg\/(\d+)/);return e&&e[1]?parseFloat(e[1]):null}(),ip=/SogouMobileBrowser\//i.test(Ce),o4=ip&&function(){var e=Ce.match(/SogouMobileBrowser\/(\d+)/);return e&&e[1]?parseFloat(e[1]):null}(),ap=/MetaSr\s/i.test(Ce),s4=ap&&function(){var e=Ce.match(/MetaSr(\s\d+(\.\d+)+)/);return e&&e[1]?parseFloat(e[1]):null}(),Nr=/TBS\/\d+/i.test(Ce),c4=Nr&&function(){var e=Ce.match(/TBS\/(\d+)/i);if(e&&e[1])return e[1]}(),op=/XWEB\/\d+/i.test(Ce),u4=op&&function(){var e=Ce.match(/XWEB\/(\d+)/i);if(e&&e[1])return e[1]}();/MSIE\s8\.0/.test(Ce),/MSIE\/\d+/i.test(Ce)&&function(){var e=/MSIE\s(\d+)\.\d/.exec(Ce),t=e&&parseFloat(e[1]);!t&&/Trident\/7.0/i.test(Ce)&&/rv:11.0/.test(Ce)&&(t=11)}();var sp=/(micromessenger|webbrowser)/i.test(Ce),l4=sp&&function(){var e=Ce.match(/MicroMessenger\/(\d+)/i);if(e&&e[1])return e[1]}(),cp=!Nr&&/MQQBrowser\/\d+/i.test(Ce)&&/COVC\/\d+/i.test(Ce),up=!Nr&&/MQQBrowser\/\d+/i.test(Ce)&&!/COVC\/\d+/i.test(Ce),wS=(up||cp)&&function(){var e=Ce.match(/ MQQBrowser\/([\d.]+)/);return e&&e[1]?e[1]:null}(),lp=!Nr&&/ QQBrowser\/\d+/i.test(Ce),d4=lp&&function(){var e=Ce.match(/ QQBrowser\/([\d.]+)/);return e&&e[1]?e[1]:null}(),dp=!Nr&&/QQBrowserLite\/\d+/i.test(Ce),h4=dp&&function(){var e=Ce.match(/QQBrowserLite\/([\d.]+)/);return e&&e[1]?e[1]:null}(),hp=!Nr&&/MQBHD\/\d+/i.test(Ce),f4=hp&&function(){var e=Ce.match(/MQBHD\/([\d.]+)/);return e&&e[1]?e[1]:null}(),CS=/Windows/i.test(Ce),Zs=!vi&&/MAC OS X/i.test(Ce),ES=!$i&&/Linux/i.test(Ce);/MicroMessenger/i.test(Ce);var p4=/UCBrowser/i.test(Ce);/Electron/i.test(Ce);var RS,Zu,fp=/MiuiBrowser/i.test(Ce),m4=fp&&function(){var e=Ce.match(/MiuiBrowser\/([\d.]+)/);return e&&e[1]?e[1]:null}(),pp=/HuaweiBrowser/i.test(Ce),mp=/Huawei/i.test(Ce),v4=pp&&function(){var e=Ce.match(/HuaweiBrowser\/([\d.]+)/);return e&&e[1]?e[1]:null}(),vp=/SamsungBrowser/i.test(Ce),g4=vp&&function(){var e=Ce.match(/SamsungBrowser\/([\d.]+)/);return e&&e[1]?e[1]:null}(),el=/HeyTapBrowser/i.test(Ce),_4=el&&function(){var e=Ce.match(/HeyTapBrowser\/([\d.]+)/);return e&&e[1]?e[1]:null}(),tl=/VivoBrowser/i.test(Ce),y4=tl&&function(){var e=Ce.match(/VivoBrowser\/([\d.]+)/);return e&&e[1]?e[1]:null}(),co=function(){var e=Ce.match(/Chrome\/(\d+)/);return e&&e[1]?Number(e[1]):null},b4=/Chrome/i.test(Ce),nl=!Yu&&!ap&&!ip&&!Nr&&!op&&!$u&&!lp&&!fp&&!pp&&!vp&&!el&&!tl&&/Chrome/i.test(Ce),gp=nl&&co(),S4=nl&&function(){var e=Ce.match(/Chrome\/([\d.]+)/);return e&&e[1]?e[1]:null}(),Zi=!b4&&!up&&!cp&&!dp&&!hp&&/Safari/i.test(Ce),_p=function(){if(Zi){var e=Ce.match(/Version\/([\d.]+)/);if(e&&e[1])return e[1]}return""}(),k4=/Android.*(wv|.0.0.0)/.test(Ce),gi=function(){if(TS)return _p;if(vi){var e=Ce.match(/OS (\d+)_(\d+)/i);if(e&&e[1]){var t=e[1];return e[2]&&(t+=".".concat(e[2])),t}}return""}(),T4=Number(gi.split(".")[0]),rl=_p==="15.1",il=gi==="15.1",x4=(RS=Number(gi.split(".")[0]))===14||RS===13,ea=location.protocol==="file:"||location.hostname==="localhost"||location.hostname==="127.0.0.1",ta=function(){if(ge(Zu))try{Zu=window.localStorage}catch(e){ye.warn(e),Zu=!1}return Zu},yp=new Map([[Tr,["Firefox",xS]],[$u,["Edg",IS]],[nl,["Chrome",S4]],[Zi,["Safari",_p]],[Nr,["TBS",c4]],[op,["XWEB",u4]],[sp&&rp,["WeChat",l4]],[lp,["QQ(Win)",d4]],[up,["QQ(Mobile)",wS]],[cp,["QQ(Mobile X5)",wS]],[dp,["QQ(Mac)",h4]],[hp,["QQ(iPad)",f4]],[fp,["MI",m4]],[pp,["HW",v4]],[vp,["Samsung",g4]],[el,["OPPO",_4]],[tl,["VIVO",y4]],[Yu,["EDGE",a4]],[ip,["SogouMobile",o4]],[ap,["Sogou",s4]]]);function na(){var e="unknown",t="unknown";return yp.get(!0)&&(e=yp.get(!0)[0],t=yp.get(!0)[1]),{name:e,version:t}}var AS=function(e,t){return t?oo+"/"+e+"/"+t:oo+"/"+e+"/index.html"},I4=function(){if(!ta())return!1;var e=localStorage.getItem(Xf);e&&!function(t){var n=t.saveTime&&new Date().getTime()-t.saveTime>=Wb,i=!t.saveVersion||t.saveVersion!==Bi;return n||i}(JSON.parse(e))||(ye.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(Xf,JSON.stringify({message:t.responseText,saveTime:new Date().getTime(),saveVersion:Bi})),document.body.removeChild(n)}}())};function ie(e){var t=e.key,n=e.data,i=e.link,r=e.addDocLink,o=r===void 0||r,c="",a="",s="";pn(mi[t])?c=mi[t](n):Bt(mi[t])&&(c=mi[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 x=localStorage.getItem(Xf);if(x){x=JSON.parse(x);var E=document.createElement("script");E.type="text/javascript",E.text=x.message,document.body.appendChild(E);var I=window.TRTC_ERROR_INFO,m=window.TRTC_ERROR_LINK;return document.body.removeChild(E),{TRTC_ERROR_INFO:I,TRTC_ERROR_LINK:m}}return{}}(),u=l.TRTC_ERROR_INFO,p=l.TRTC_ERROR_LINK;i?s="".concat(i.className,".html#").concat(i.fnName):p&&p[t]&&(pn(p[t])?s=p[t](n):Bt(p[t])&&(s=p[t]));var k=c;return ra()&&(u&&u[t]&&(pn(u[t])?a=u[t](n):Bt(u[t])&&(a=u[t])),a&&(k=o?a+`
45
+ \u8BF7\u67E5\u770B\u6587\u6863: `+AS("zh-cn",s)+`
82
46
 
83
- `:s+`
47
+ `:a+`
84
48
 
85
- `,_+=a)),o&&(_+=`
86
- Refer to: `+Pk("en",c)+`
87
- `),_}var Dk=function(){return function(e){var t=window.location.search.match(new RegExp("(\\?|&)"+e+"=([^&]*)(&|$)"));return t?decodeURIComponent(t[2]):""}("trtc_env")},Lk=function(e){return(e=Number(e))>0&&e<14e8},pl=function(e,t){var n;n=Xs?Xs.includes("http")?Xs:"https://"+Xs:Lk(e)?"https://apisgp.my-imcloud.com":"https://yun.tim.qq.com";var r=Math.floor(Math.random()*Math.pow(2,31));return"".concat(n,"/v5/AVQualityReportSvc/C2S?random=").concat(r,"&sdkappid=").concat(e,"&cmdtype=").concat(t)};function Of(){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 r=t&&t.type&&t.type.toLowerCase(),i=t&&t.effectiveType&&t.effectiveType.toLowerCase();i==="slow-2"&&(i="2g");var o=n||"unknown";if(r)switch(r){case"cellular":case"wimax":o=i||"unknown";break;case"wifi":o="wifi";break;case"ethernet":o="wired";break;case"none":case"other":case"unknown":o="unknown"}return o}var na=function(e){if(!e||V(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 fl(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:fl(e-1,n,t+n)}function Mf(e){var t=Math.round(e/2)+1;return t>6?13e3:1e3*fl(t)}var In=function(e){return typeof e=="function"},ve=function(e){return e===void 0},Ft=function(e){return typeof e=="string"},xr=function(e){return typeof e=="number"},uo=function(e){return typeof e=="boolean"},Ok=function(e){return gi(e)==="object"},ml=function(e){return gi(e)==="array"},Mk=function(e){return gi(e)==="MediaStreamTrack".toLowerCase()};function gi(e){return Reflect.apply(Object.prototype.toString,e,[]).replace(/^\[object\s(\w+)\]$/,"$1").toLowerCase()}function Nk(e){var t={};return t.urls="turn:".concat(e.url),ve(e.username)||ve(e.credential)||(t.username=e.username,t.credential=e.credential,t.credentialType="password",ve(e.credentialType)||(t.credentialType=e.credentialType)),t}function Pt(){return performance&&performance.now?Math.floor(performance.now()):Date.now()}function Nf(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"big";if(!Ft(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 Vf,Uf,ra=function(){var e=navigator.language||navigator.userLanguage;return(e=e.substr(0,2))==="zh"},Vk=(Vf=!1,Uf=document.visibilityState,function(){document.visibilityState!==Uf&&ke.info("visibility change: ".concat(document.visibilityState)),Vf||(document.addEventListener("visibilitychange",function(){ke.info("visibility change: "+document.visibilityState),Uf=document.visibilityState}),Vf=!0)});window.AudioContext=window.AudioContext||window.webkitAudioContext||window.mozAudioContext;var Uk=function(){return new window.AudioContext},Bk=function(){var e;return function(){return e||(e=new window.AudioContext,e.onstatechange=function(){ke.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)}}(),wV=!!window.AudioWorkletNode,jk=function(e,t){var n=e.emit;return e.emit=function(){for(var r=arguments.length,i=new Array(r),o=0;o<r;o++)i[o]=arguments[o];try{n.apply(e,i)}catch(s){var a=ne({key:H4,data:{name:t,event:i[0]},addDocLink:!1});ke.warn(a+`
49
+ `,k+=c)),o&&(k+=`
50
+ Refer to: `+AS("en",s)+`
51
+ `),k}var PS=function(){return function(e){var t=window.location.search.match(new RegExp("(\\?|&)"+e+"=([^&]*)(&|$)"));return t?decodeURIComponent(t[2]):""}("trtc_env")},DS=function(e){return(e=Number(e))>0&&e<14e8},al=function(e,t){var n;n=Js?Js.includes("http")?Js:"https://"+Js:DS(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 bp(){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 _i=function(e){if(!e||G(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 ol(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:ol(e-1,n,t+n)}function Sp(e){var t=Math.round(e/2)+1;return t>6?13e3:1e3*ol(t)}var pn=function(e){return typeof e=="function"},ge=function(e){return e===void 0},Bt=function(e){return typeof e=="string"},$n=function(e){return typeof e=="number"},Zn=function(e){return typeof e=="boolean"},LS=function(e){return yi(e)==="object"},uo=function(e){return yi(e)==="array"},OS=function(e){return yi(e)==="MediaStreamTrack".toLowerCase()};function yi(e){return Reflect.apply(Object.prototype.toString,e,[]).replace(/^\[object\s(\w+)\]$/,"$1").toLowerCase()}function MS(e){var t={};return t.urls="turn:".concat(e.url),ge(e.username)||ge(e.credential)||(t.username=e.username,t.credential=e.credential,t.credentialType="password",ge(e.credentialType)||(t.credentialType=e.credentialType)),t}function Pt(){return performance&&performance.now?Math.floor(performance.now()):Date.now()}function kp(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"big";if(!Bt(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 Tp,xp,ra=function(){var e=navigator.language||navigator.userLanguage;return(e=e.substr(0,2))==="zh"},NS=(Tp=!1,xp=document.visibilityState,function(){document.visibilityState!==xp&&ye.info("visibility change: ".concat(document.visibilityState)),Tp||(document.addEventListener("visibilitychange",function(){ye.info("visibility change: "+document.visibilityState),xp=document.visibilityState}),Tp=!0)});window.AudioContext=window.AudioContext||window.webkitAudioContext||window.mozAudioContext;var US=function(){return new window.AudioContext},VS=function(){var e;return function(){return e||(e=new window.AudioContext,e.onstatechange=function(){ye.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)}}(),w4=!!window.AudioWorkletNode,jS=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=ie({key:H3,data:{name:t,event:r[0]},addDocLink:!1});ye.warn(c+`
88
52
 
89
- `+s.stack)}},e},Fk=function(e){return+e<10?"0".concat(e):e},EV=function(e){var t=e.match(/^\d+\.\d+\.\d+/)[0];if(!t)return e;var n=t.split("."),r=Fk(n[1])+Fk(n[2]);return n[1]-15>0&&(n[1]="15"),n[2]-15>0&&(n[2]="15"),n.join(".")+"."+r};function vl(e){var t=e.url,n=e.body,r=e.method,i=e.timeout,o=new XMLHttpRequest;return new Promise(function(a,s){o.onload=function(u){if(o.status>=200&&o.status<300&&o.responseText.length>0)try{var d=JSON.parse(o.response);a({data:d})}catch(h){a({data:o.response})}else o.status>0&&s({code:o.status,message:"request failed, readyState:".concat(o.readyState," status:").concat(o.status," loaded size:").concat(u.loaded)})};var c=function(u){s({code:o.readyState,message:"request ".concat(u.type,", readyState:").concat(o.readyState," status:").concat(o.status," loaded size:").concat(u.loaded)})};o.onerror=c,o.onabort=c,o.ontimeout=c,o.timeout=i||5e3,o.open(r||"POST",t,!0),o.send(n)})}var Gk={exports:{}};(function(e){var t=Object.prototype.hasOwnProperty,n="~";function r(){}function i(c,u,d){this.fn=c,this.context=u,this.once=d||!1}function o(c,u,d,h,_){if(typeof d!="function")throw new TypeError("The listener must be a function");var y=new i(d,h||c,_),b=n?n+u:u;return c._events[b]?c._events[b].fn?c._events[b]=[c._events[b],y]:c._events[b].push(y):(c._events[b]=y,c._eventsCount++),c}function a(c,u){--c._eventsCount==0?c._events=new r:delete c._events[u]}function s(){this._events=new r,this._eventsCount=0}Object.create&&(r.prototype=Object.create(null),new r().__proto__||(n=!1)),s.prototype.eventNames=function(){var c,u,d=[];if(this._eventsCount===0)return d;for(u in c=this._events)t.call(c,u)&&d.push(n?u.slice(1):u);return Object.getOwnPropertySymbols?d.concat(Object.getOwnPropertySymbols(c)):d},s.prototype.listeners=function(c){var u=n?n+c:c,d=this._events[u];if(!d)return[];if(d.fn)return[d.fn];for(var h=0,_=d.length,y=new Array(_);h<_;h++)y[h]=d[h].fn;return y},s.prototype.listenerCount=function(c){var u=n?n+c:c,d=this._events[u];return d?d.fn?1:d.length:0},s.prototype.emit=function(c,u,d,h,_,y){var b=n?n+c:c;if(!this._events[b])return!1;var f,g,I=this._events[b],w=arguments.length;if(I.fn){switch(I.once&&this.removeListener(c,I.fn,void 0,!0),w){case 1:return I.fn.call(I.context),!0;case 2:return I.fn.call(I.context,u),!0;case 3:return I.fn.call(I.context,u,d),!0;case 4:return I.fn.call(I.context,u,d,h),!0;case 5:return I.fn.call(I.context,u,d,h,_),!0;case 6:return I.fn.call(I.context,u,d,h,_,y),!0}for(g=1,f=new Array(w-1);g<w;g++)f[g-1]=arguments[g];I.fn.apply(I.context,f)}else{var j,z=I.length;for(g=0;g<z;g++)switch(I[g].once&&this.removeListener(c,I[g].fn,void 0,!0),w){case 1:I[g].fn.call(I[g].context);break;case 2:I[g].fn.call(I[g].context,u);break;case 3:I[g].fn.call(I[g].context,u,d);break;case 4:I[g].fn.call(I[g].context,u,d,h);break;default:if(!f)for(j=1,f=new Array(w-1);j<w;j++)f[j-1]=arguments[j];I[g].fn.apply(I[g].context,f)}}return!0},s.prototype.on=function(c,u,d){return o(this,c,u,d,!1)},s.prototype.once=function(c,u,d){return o(this,c,u,d,!0)},s.prototype.removeListener=function(c,u,d,h){var _=n?n+c:c;if(!this._events[_])return this;if(!u)return a(this,_),this;var y=this._events[_];if(y.fn)y.fn!==u||h&&!y.once||d&&y.context!==d||a(this,_);else{for(var b=0,f=[],g=y.length;b<g;b++)(y[b].fn!==u||h&&!y[b].once||d&&y[b].context!==d)&&f.push(y[b]);f.length?this._events[_]=f.length===1?f[0]:f:a(this,_)}return this},s.prototype.removeAllListeners=function(c){var u;return c?(u=n?n+c:c,this._events[u]&&a(this,u)):(this._events=new r,this._eventsCount=0),this},s.prototype.off=s.prototype.removeListener,s.prototype.addListener=s.prototype.on,s.prefixed=n,s.EventEmitter=s,e.exports=s})(Gk);var _i=Gk.exports,q=new _i,gl=1,Bf=2,jf=3,lo=4,ho=5,Ff=20,Gf=21,po=22,Hf=23,zf=24,Wf=27,Jf=28,_l=29,Hk=30,Kf=33,zk=31,qf=32,CV=100,Wk=101,rc=102,Xf=103,Bn=110,yl=111,Qf=112,Ur=113,Br=114,RV=115,ia=116,AV=120,Yf=121,$f=122,Zf=123,ic=130,em=131,tm=132,nm=133,rm=134,im=135,am=136,om=137,sm=200,cm=201,um=300,ac=301,lm=302,dm=303;function oc(e){var t=e.retryFunction,n=e.settings,r=e.onError,i=e.onRetrying,o=e.onRetryFailed,a=e.context;return function(){for(var s=this,c=arguments.length,u=new Array(c),d=0;d<c;d++)u[d]=arguments[d];var h=n.retries||5,_=0,y=-1,b=0,f=function(){var g=N(p().mark(function I(w,j){var z,$,ue,L;return p().wrap(function(k){for(;;)switch(k.prev=k.next){case 0:return z=a||s,k.prev=1,k.next=4,t.apply(z,u);case 4:$=k.sent,_=0,w($),k.next=14;break;case 9:k.prev=9,k.t0=k.catch(1),ue=function(){clearTimeout(y),_=0,b=2,j(k.t0)},L=function(){b!==2&&_<h?(_++,b=1,In(i)&&i.call(z,_,ue),y=setTimeout(function(){y=-1,f(w,j)},ve(n.timeout)?1e3:n.timeout)):(ue(),In(o)&&o.call(z,k.t0))},In(r)?r.call(z,k.t0,L,j,u):L();case 14:case"end":return k.stop()}},I,null,[[1,9]])}));return function(I,w){return g.apply(this,arguments)}}();return new Promise(f)}}var PV=ye(function e(t){J(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}),DV=function(){function e(t){J(this,e),this.id_=t.id,this.userId_=t.userId,this.sdkAppId_=t.sdkAppId,this.type_=t.type,this.isLocal_=!uo(t.isLocal)||t.isLocal}return ye(e,[{key:"setUserId",value:function(t){this.userId_=t}},{key:"setSdkAppId",value:function(t){this.sdkAppId_=t}},{key:"log",value:function(t,n){ke.log({log:"[".concat(this.isLocal_?"\u2191":"\u2193").concat(this.id_,"] ").concat(this.type_?this.type_+" ":"").concat(n),level:t,forAllJoinedClients:ve(this.userId_),userId:this.userId_,sdkAppId:this.sdkAppId_})}},{key:"info",value:function(t){this.log(Un.INFO,t)}},{key:"debug",value:function(t){this.log(Un.DEBUG,t)}},{key:"warn",value:function(t){this.log(Un.WARN,t)}},{key:"error",value:function(t){this.log(Un.ERROR,t)}}]),e}(),LV=!(Qi||co),OV=function(){function e(){var r=this;J(this,e),this.clients_=new Set,this.queue_=[],this.timeoutId_=-1,this.logLevel_=Un.DEBUG,this.logLevelToUpload_=Un.INFO,this.enableUploadLog_=!0,this.isAbleToUpload_=!1,this.checkURLParam(),q.on(Hk,function(i){var o=i.client;r.timeoutId_===-1&&r.startUpload(),r.clients_.add(o)}),q.on(Kf,function(i){var o=i.client;return r.clients_.delete(o)}),q.on(zk,function(i){i&&na(i.config)&&Xi[i.config.logLevelToUpload]&&(r.logLevelToUpload_=i.config.logLevelToUpload)}),q.on(lo,this.setIsAbleToUpload,this),q.on(ho,this.setIsAbleToUpload,this)}var t,n;return ye(e,[{key:"getIsAbleToUpload",value:function(){return this.isAbleToUpload_}},{key:"setIsAbleToUpload",value:function(){this.isAbleToUpload_=!0,q.off(lo,this.setIsAbleToUpload,this),q.off(ho,this.setIsAbleToUpload,this)}},{key:"startUpload",value:(n=N(p().mark(function r(){var i=this;return p().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 i.startUpload()},2e3);case 8:case"end":return o.stop()}},r,this,[[0,5]])})),function(){return n.apply(this,arguments)})},{key:"getLogsToUpload",value:function(){var r=this,i={map:new Map,splicedQueue:[]};if(this.queue_[0].forAllJoinedClients&&this.clients_.size===0)return i;for(var o=0,a=function(){if(o===50)return"break";var s=r.queue_[o];s.forAllJoinedClients?r.clients_.forEach(function(c){if(c.getIsJoined()){var u=c.getUserId(),d=c.getSDKAppId();i.map.has(u)?i.map.get(u).logs.push(s):i.map.set(u,{userId:u,sdkAppId:d,logs:[s]})}}):i.map.has(s.userId)?i.map.get(s.userId).logs.push(s):i.map.set(s.userId,{userId:s.userId,sdkAppId:s.sdkAppId,logs:[s]})};o<this.queue_.length&&a()!=="break";o++);return i.map.size>0&&(i.splicedQueue=this.queue_.splice(0,o)),i}},{key:"upload",value:(t=N(p().mark(function r(){var i,o,a,s,c,u,d,h,_,y;return p().wrap(function(b){for(;;)switch(b.prev=b.next){case 0:if(this.queue_.length!==0&&this.isAbleToUpload_){b.next=2;break}return b.abrupt("return");case 2:if(i=this.getLogsToUpload(),o=i.map,a=i.splicedQueue,o.size!==0){b.next=5;break}return b.abrupt("return");case 5:b.prev=5,s=be(o.values()),c=0;case 8:if(!(c<s.length)){b.next=16;break}return u=s[c],d=u.userId,h=u.sdkAppId,_=u.logs,b.next=12,this.uploadLogWithRetry(JSON.stringify({timestamp:K0(),sdkAppId:String(h),userId:d,version:Vi,log:_.map(function(f){return f.log}).join(`
90
- `)}),h);case 12:_.forEach(function(f){return f.uploaded=!0});case 13:c++,b.next=8;break;case 16:b.next=20;break;case 18:b.prev=18,b.t0=b.catch(5);case 20:y=a.filter(function(f){return!f.uploaded}),y.length>0&&(this.queue_=y.concat(this.queue_));case 22:case"end":return b.stop()}},r,this,[[5,18]])})),function(){return t.apply(this,arguments)})},{key:"uploadLogWithRetry",value:function(r,i){return oc({retryFunction:function(){return vl({url:pl(i,yb),body:r,timeout:5e3})},settings:{retries:3,timeout:1e3},onError:function(o,a){a()}})()}},{key:"getPrefix",value:function(r){var i=new Date;return i.setTime(on()),String.prototype.padStart?"[".concat(i.toTimeString().replace(/.*(\d{2}:\d{2}:\d{2}).*/,"$1"),":").concat(i.getMilliseconds().toString().padStart(3,"0"),"] <").concat(Xi[r],">"):"[".concat(i.toTimeString().replace(/.*(\d{2}:\d{2}:\d{2}).*/,"$1"),":").concat(i.getMilliseconds(),"] <").concat(Xi[r],">")}},{key:"getLogLevel",value:function(){return this.logLevel_}},{key:"setLogLevel",value:function(r){ve(Xi[r])||(this.logLevel_!==r&&this.info("setLogLevel ".concat(r)),this.logLevel_=r)}},{key:"enableUploadLog",value:function(){this.enableUploadLog_=!0}},{key:"disableUploadLog",value:function(){this.enableUploadLog_=!1}},{key:"log",value:function(r){var i=r.log,o=r.level,a=r.forAllJoinedClients,s=a===void 0||a,c=r.userId,u=r.sdkAppId;if(i="".concat(this.getPrefix(o)," ").concat(i),this.enableUploadLog_&&o>=this.logLevelToUpload_&&this.queue_.push(new PV({log:i,level:o,userId:c,sdkAppId:u,forAllJoinedClients:s})),!(o<this.logLevel_)){var d=Xi[o]?Xi[o].toLowerCase():"info";LV?console[d]("%cTRTC%c%s","padding: 1px 4px;border-radius: 3px;color: #fff;background: #1E88E5;","display: inline",i):console[d](i)}}},{key:"debug",value:function(r){this.log({log:r,level:Un.DEBUG})}},{key:"info",value:function(r){this.log({log:r,level:Un.INFO})}},{key:"warn",value:function(r){this.log({log:r,level:Un.WARN})}},{key:"error",value:function(r){this.log({log:r,level:Un.ERROR})}},{key:"createLogger",value:function(r){return new DV(r)}},{key:"checkURLParam",value:function(){var r=new URLSearchParams(location.search).get("logLevelToUpload");Xi[r]&&(this.logLevelToUpload_=r)}}]),e}(),ke=new OV,Jk=!0,MV=ot,NV=Math.floor,Kk=Number.isInteger||function(e){return!MV(e)&&isFinite(e)&&NV(e)===e};Me({target:"Number",stat:!0},{isInteger:Kk});var hm,VV=Me,qk=pe,UV=Se.f,BV=vr,Xk=Wt,jV=fS,FV=pt,GV=mS,Qk=qk("".startsWith),HV=qk("".slice),zV=Math.min,Yk=GV("startsWith");VV({target:"String",proto:!0,forced:!!(Yk||(hm=UV(String.prototype,"startsWith"),!hm||hm.writable))&&!Yk},{startsWith:function(e){var t=Xk(FV(this));jV(e);var n=BV(zV(arguments.length>1?arguments[1]:void 0,t.length)),r=Xk(e);return Qk?Qk(t,r,n):HV(t,n,n+r.length)===r}});var $k=_e,WV=pe,JV=Qe,KV=oe,pm=pu,qV=Yd,XV=Kt,QV=Bt,YV=yn,fo=Object.assign,Zk=Object.defineProperty,$V=WV([].concat),eT=!fo||KV(function(){if($k&&fo({b:1},fo(Zk({},"a",{enumerable:!0,get:function(){Zk(this,"b",{value:3,enumerable:!1})}}),{b:2})).b!==1)return!0;var e={},t={},n=Symbol(),r="abcdefghijklmnopqrst";return e[n]=7,r.split("").forEach(function(i){t[i]=i}),fo({},e)[n]!=7||pm(fo({},t)).join("")!=r})?function(e,t){for(var n=QV(e),r=arguments.length,i=1,o=qV.f,a=XV.f;r>i;)for(var s,c=YV(arguments[i++]),u=o?$V(pm(c),o(c)):pm(c),d=u.length,h=0;d>h;)s=u[h++],$k&&!JV(a,c,s)||(n[s]=c[s]);return n}:fo,tT=eT;Me({target:"Object",stat:!0,arity:2,forced:Object.assign!==tT},{assign:tT});var nT=pe,ZV=Ut,eU=ot,tU=xt,rT=ja,nU=Oe,iT=Function,rU=nT([].concat),iU=nT([].join),fm={},aU=function(e,t,n){if(!tU(fm,t)){for(var r=[],i=0;i<t;i++)r[i]="a["+i+"]";fm[t]=iT("C,a","return new C("+iU(r,",")+")")}return fm[t](e,n)},oU=nU?iT.bind:function(e){var t=ZV(this),n=t.prototype,r=rT(arguments,1),i=function(){var o=rU(r,rT(arguments));return this instanceof i?aU(t,o.length,o):t.apply(e,o)};return eU(n)&&(i.prototype=n),i},aT=oU;Me({target:"Function",proto:!0,forced:Function.bind!==aT},{bind:aT});var sU=Me,cU=an.findIndex,uU=vu,oT="findIndex",sT=!0;oT in[]&&Array(1).findIndex(function(){sT=!1}),sU({target:"Array",proto:!0,forced:sT},{findIndex:function(e){return cU(this,e,arguments.length>1?arguments[1]:void 0)}}),uU(oT);var lU=_e,cT=pe,dU=pu,hU=Sn,pU=cT(Kt.f),fU=cT([].push),uT=function(e){return function(t){for(var n,r=hU(t),i=dU(r),o=i.length,a=0,s=[];o>a;)n=i[a++],lU&&!pU(r,n)||fU(s,e?[n,r[n]]:r[n]);return s}},mU={entries:uT(!0),values:uT(!1)}.values;Me({target:"Object",stat:!0},{values:function(e){return mU(e)}});var lT=1,dT=5,mm=2,sc=3,vm=4,Sl="DISCONNECTED",hT="CONNECTING",gm="RECONNECTING",cc="CONNECTED",jr={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},vU=[jr.UPDATE_REMOTE_MUTE_STAT,jr.UPLINK_NETWORK_STATS,jr.USER_LIST_RES,jr.MUTE_RESULT],vt={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"},gU="publish_change",_U="publish_state_change",yU="join",SU="leave",bU="quality_report",kU="mute_uplink",TU="publish",pT="unpublish",xU="subscribe",IU="unsubscribe",wU="subscribe_change",EU="start_publishing",CU="stop_publishing",RU="start_push_user_cdn",AU="stop_push_user_cdn",PU="start_mcu_mix",DU="stop_mcu_mix",LU="get_user_list",OU="change_role",MU="update_constraint_config",Y={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},ee=function(e){Nt(n,e);var t=Ar(n);function n(r){var i,o=r.name,a=o===void 0?"RtcError":o,s=r.message,c=r.code,u=c===void 0?Y.UNKNOWN:c,d=r.extraCode,h=d===void 0?0:d,_=r.constraint;J(this,n);var y="<".concat(function(b){for(var f in Y)if(Y[f]===b)return f;return"UNKNOWN"}(u)," 0x").concat(u.toString(16),">");return(i=t.call(this,s+"".concat(_?" constraint: ".concat(_):"")+"".concat(s!=null&&s.includes(y)?"":" "+y))).code_=u,i.extraCode_=h,i.name=a,i.message_=s,_&&(i.constraint=_),i}return ye(n,[{key:"getCode",value:function(){return this.code_}},{key:"getExtraCode",value:function(){return this.extraCode_}}]),n}(Ho(Error)),fT=32768,mT=32769,vT=32770,gT=32771,NU=32772,VU=32773,UU=32774,BU=32775,_T=32777,jU=32778,_m=32779,FU=32780,GU=32781,HU=32782,zU=32783,WU=32784,JU=32785,KU=32786,qU=32787,XU=32788,QU=32789,YU=32790,$U=32791,ZU=32792,e6=32793,t6=32794,n6=32795,r6=32796,i6=32797,a6=32798,o6=32799,s6=32800,c6=32801,u6=32802,l6=32803,d6=32804,uc=new Map,vn=function(e,t){var n=uc.get(e);n||(uc.set(e,[]),n=uc.get(e)),n.push(t)},h6=function(e){var t=uc.get(e),n=[];return t?(uc.delete(e),n=t.map(function(r){return{uint32_event_id:r.eventId,uint64_date:r.timestamp,str_userid:r.remoteUserId,str_event_json:r.eventDesc}})):n=[],n},p6=Object.prototype.hasOwnProperty;function aa(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(na(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(p6.call(e,t))return!1;return!0}return!1}var f6=function(){function e(){J(this,e);var t=ta(),n=t.name,r=t.version;this.roomIdMap_=new Map,this.configs_={sdkAppId:"",userId:"",version:Vi,env:Qu,browserVersion:n+r,ua:navigator.userAgent}}return ye(e,[{key:"setConfig",value:function(t){var n=t.sdkAppId,r=t.env,i=t.userId,o=t.roomId;n!==this.configs_.sdkAppId&&(this.configs_.sdkAppId=String(n)),this.configs_.env=r,this.configs_.userId=i,this.roomIdMap_.set(i,String(o))}},{key:"logEvent",value:function(t){if(!Zi){var n=H(H(H({},t),this.configs_),{},{userId:t.userId||this.configs_.userId});ve(n.code)&&(n.code=n.result==="failed"?Y.UNKNOWN:0),this.sendRequest(pl(this.configs_.sdkAppId,HN),n)}}},{key:"logSuccessEvent",value:function(t){Zi||(this.logEvent(H(H({},t),{},{result:"success",roomId:this.roomIdMap_.get(t.userId)})),this.configs_.env===Qu&&this.uploadEventToKibana(H(H({},t),{},{result:"success"})))}},{key:"logFailedEvent",value:function(t){if(!Zi){var n=t.eventType,r=t.code,i=t.error,o=t.userId,a={roomId:this.roomIdMap_.get(o),userId:o,eventType:n,result:"failed",code:r||(i instanceof ee?i.getExtraCode()||i.getCode():Y.UNKNOWN)};this.logEvent(a),this.configs_.env===Qu&&this.uploadEventToKibana(H(H({},a),{},{error:i}))}}},{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,r=t.userId,i=t.error,o={timestamp:K0(),sdkAppId:this.configs_.sdkAppId,userId:r||this.configs_.userId,version:this.configs_.version,log:n};i&&(o.errorInfo=i.message),this.sendRequest(pl(this.configs_.sdkAppId,yb),o)}},{key:"sendRequest",value:function(t,n){var r=this;ke.getIsAbleToUpload()?vl({url:t,body:JSON.stringify(n)}).catch(function(){}):setTimeout(function(){r.sendRequest(t,n)},1e3)}}]),e}(),Ie=new f6,m6=function(){function e(t){J(this,e),this.client_=t.client,this.sdkAppId_=t.sdkAppId,this.userId_=t.userId,this.userSig_=t.userSig,this.url_=t.url,this.backupUrl_=t.backupUrl;var n="?sdkAppId=".concat(encodeURIComponent(this.sdkAppId_),"&userId=").concat(encodeURIComponent(this.userId_),"&userSig=").concat(encodeURIComponent(this.userSig_),"&roomId=").concat(encodeURIComponent(t.roomId)),r=this.client_.getSystemResult();if(r&&r.detail){var i=r.detail,o=i.isH264EncodeSupported,a=i.isVp8EncodeSupported,s=i.isH264DecodeSupported,c=i.isVp8DecodeSupported;n+="&enc264=".concat(Number(o),"&dec264=").concat(Number(s),"&encVp8=").concat(Number(a),"&decVp8=").concat(Number(c))}t.signalDomainWhenUnifiedProxy&&(n+="&signalDomain=".concat(encodeURIComponent(t.signalDomainWhenUnifiedProxy))),this.urlWithParam_="".concat(this.url_).concat(n),this.backupUrlWithParam_="".concat(this.backupUrl_).concat(n),this.isConnected_=!1,this.isConnecting_=!1,this.socketInUse_=null,this.socket_=null,this.backupSocket_=null,this.backupTimer_=-1,this.signalInfo_={},this.currentState_=Sl,this.reconnectionCount_=0,this.reconnectionTimer_=-1,this.lastMessageTime_=-1,this.seq_=0,this.log_=ke.createLogger({id:"ws|"+this.userId_,userId:this.userId_,sdkAppId:this.sdkAppId_}),this.emitter_=new _i}return ye(e,[{key:"isOnline",get:function(){return this.currentState_===cc&&Date.now()-this.lastMessageTime_<12e3}},{key:"connect",value:function(){var t=this;return new Promise(function(n,r){t.log_.info("connect to url: ".concat(t.urlWithParam_)),t.emitConnectionStateChanged(hT),t.socket_=new WebSocket(t.urlWithParam_),t.bindSocket(t.socket_),t.backupTimer_=setTimeout(function(){t.isConnected_||(t.log_.info("trying to connect to backupUrl"),t.tryConnectBackup())},5e3),t.once(sc,n),t.once(vm,r)})}},{key:"tryConnectBackup",value:function(){this.backupSocket_||(this.unbindAndCloseSocket(Ze),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(t){t.onopen=this.onopen.bind(this),t.onclose=this.onclose.bind(this),t.onerror=this.onerror.bind(this),t.onmessage=this.onmessage.bind(this)}},{key:"unbindSocket",value:function(t){t.onopen=function(){},t.onclose=function(){},t.onerror=function(){},t.onmessage=function(){}}},{key:"unbindAndCloseSocket",value:function(t){if(t===Ze){if(this.socket_){this.unbindSocket(this.socket_);try{this.socket_.close(1e3)}catch(n){}this.socket_=null}}else if(this.backupSocket_){this.unbindSocket(this.backupSocket_);try{this.backupSocket_.close(1e3)}catch(n){}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(t){if(!this.isConnected_){this.isConnected_=!0,this.isConnecting_=!1,this.isReconnecting_&&aa(this.signalInfo_)&&this.stopReconnection(),this.clearBackupTimer(),t.target===this.socket_?(this.unbindAndCloseSocket(Ki),this.socketInUse_=this.socket_):(this.unbindAndCloseSocket(Ze),this.socketInUse_=this.backupSocket_);var n=t.target.url;this.log_.info("websocket[".concat(n,"] is connected")),this.currentState_===hT?this.addSignalEvent($U,"signal channel is connected"):this.currentState_===gm&&this.addSignalEvent(n6,"signal channel reconnect success"),this.emitConnectionStateChanged(cc),this.emitter_.emit(sc)}}},{key:"onclose",value:function(t){var n=t.target.url,r=t.target===this.socketInUse_;this.log_.info("websocket[".concat(n," InUse: ").concat(r,"] is closed with code: ").concat(t.code)),t.target===this.socketInUse_&&(this.isConnected_=!1,this.emitConnectionStateChanged(Sl),this.addSignalEvent(YU,"signal channel is disconnected"),t.wasClean&&t.code===1e3||(this.log_.warn("onclose code:".concat(t.code," reason:").concat(t.reason)),this.log_.warn("close current websocket and schedule a reconnect timeout"),this.socketInUse_.onclose=function(){},this.socketInUse_.close(4011),this.socket_=this.backupSocket_=this.socketInUse_=null,this.reconnect(Ze)))}},{key:"onerror",value:function(t){var n=t.target.url;this.log_.error("websocket[".concat(n,"] error observed")),this.isConnected_?t.target===this.socketInUse_&&(this.isConnected_=!1,this.unbindAndCloseSocket(Ze),this.unbindAndCloseSocket(Ki),this.socketInUse_=null,this.reconnect(Ze)):(this.isReconnecting_||Ie.logFailedEvent({userId:this.client_.getUserId(),eventType:Zp,code:Y.UNKNOWN}),t.target==this.socket_?(this.unbindAndCloseSocket(Ze),this.reconnect(Ki)):(this.unbindAndCloseSocket(Ki),this.reconnect(Ze))),this.isConnecting_=!1,this.isConnected_=!1}},{key:"onmessage",value:function(t){if(this.isConnected_){this.lastMessageTime_=Date.now();var n=JSON.parse(t.data),r=n.cmd,i=n.data,o=Object.values(jr),a=Object.keys(jr)[o.indexOf(r)],s=vt[a];switch(vU.includes(r)||(this.log_.debug("received msg: ".concat(t.data)),this.log_.info("Received event: [ ".concat(s||"unknown cmd: "+r," ]"))),r){case jr.CHANNEL_SETUP_RESULT:if(n.code===0)this.signalInfo_.clientIp=i.clientIp,this.signalInfo_.signalIp=i.signalInnerIp,this.signalInfo_.tinyId=n.tinyId,i.svrTime&&function(u){fp=u-new Date().getTime();var d=new Date;d.setTime(u),ke.info("baseTime from server: "+d+" offset: "+fp)}(i.svrTime),this.log_.info("ChannelSetup Success"),Ie.logSuccessEvent({userId:this.userId_,eventType:Zp}),this.emitter_.emit(lT,{signalInfo:this.signalInfo_});else{var c=new ee({code:Y.SIGNAL_CHANNEL_SETUP_FAILED,extraCode:n.code,message:ne({key:k3,data:{errorCode:n.code,errorMsg:n.message}})});this.log_.error("".concat(n.code,", ").concat(n.message)),this.close(),Ie.logFailedEvent({userId:this.userId_,eventType:Zp,error:c}),this.emitter_.emit(dT,c)}break;case jr.JOIN_ROOM_RESULT:n.code===0&&(this.signalInfo_.relayIp=i.relayOuterIp,this.signalInfo_.relayInnerIp=i.relayInnerIp,this.signalInfo_.relayPort=i.relayPort,this.log_.info("signalIp:".concat(this.signalInfo_.signalIp," clientIp:").concat(this.signalInfo_.clientIp," relayIp: ").concat(this.signalInfo_.relayIp))),this.emitter_.emit(s,{data:n});break;case jr.CHANNEL_RECONNECT_RESULT:n.code===0?(this.log_.warn("reconnect success"),this.stopReconnection(),Ie.logSuccessEvent({userId:this.userId_,eventType:Nb}),this.client_.syncUserList(),this.client_.checkConnectionsToReconnect()):(this.log_.warn("reconnect failed, ".concat(n.code," ").concat(n.message)),this.client_.reJoin());break;default:this.emitter_.emit(s,{data:n})}}}},{key:"addSignalEvent",value:function(t,n){vn(this.userId_,{eventId:t,eventDesc:n,timestamp:on(),userId:this.userId_,tinyId:this.signalInfo_.tinyId})}},{key:"reconnect",value:function(){var t=this,n=arguments.length>0&&arguments[0]!==void 0?arguments[0]:Ze;if(this.isConnecting_||this.reconnectionTimer_!==-1)this.log_.info("signal channel is reconnecting, ignoring current reconnection");else{if(this.reconnectionCount_>=$p){this.log_.warn("SDK has tried reconnect signal channel for ".concat($p," times, but all failed. please check your network"));var r=new ee({code:Y.SIGNAL_CHANNEL_RECONNECTION_FAILED,message:ne({key:b3})});return Ie.logFailedEvent({userId:this.client_.getUserId(),eventType:Nb,error:r}),this.addSignalEvent(r6,"signal channel reconnect fail"),void this.emitter_.emit(vm,r)}this.isConnecting_=!0,this.reconnectionCount_++,this.currentState_!==gm&&(this.emitConnectionStateChanged(gm),this.addSignalEvent(t6,"signal channel is reconnecting")),this.log_.warn("reconnecting to ".concat(n," signal channel [").concat(this.reconnectionCount_,"/").concat($p,"]"));var i=this.getReconnectionUrl(n);n===Ze?(this.socket_=new WebSocket(i),this.bindSocket(this.socket_)):(this.backupSocket_=new WebSocket(i),this.bindSocket(this.backupSocket_));var o=Mf(this.reconnectionCount_);this.reconnectionTimer_=setTimeout(function(){t.log_.warn("reconnect ".concat(n," signal channel timeout(").concat(o/1e3,"s), close and try again")),t.isConnecting_=!1,t.clearReconnectionTimer(),t.unbindAndCloseSocket(n),t.reconnect(n===Ze?Ki:Ze)},o)}}},{key:"isConnected",value:function(){return this.isConnected_}},{key:"isReconnecting_",get:function(){return this.reconnectionTimer_!==-1}},{key:"getReconnectionUrl",value:function(t){var n=t===Ze?this.urlWithParam_:this.backupUrlWithParam_;if(!aa(this.signalInfo_)&&n.indexOf("&rc=1")===-1){var r=this.client_.getRoomId(),i=this.client_.getUseStringRoomId();n+="&rc=1&relayInnerIp=".concat(this.signalInfo_.relayInnerIp,"&relayOuterIp=").concat(this.signalInfo_.relayIp,"&relayPort=").concat(this.signalInfo_.relayPort,"&roomId=").concat(r,"&useStringRoomId=").concat(i)}return n}},{key:"send",value:function(t){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(this.isConnected_){var r={cmd:t,data:n,userId:this.userId_,tinyId:this.signalInfo_.tinyId,seq:++this.seq_};return this.socketInUse_.send(JSON.stringify(r)),r.seq}}},{key:"sendWaitForResponse",value:function(t){var n=this,r=t.command,i=t.data,o=t.timeout,a=o===void 0?5e3:o,s=t.responseCommand,c=t.commandDesc,u=t.enableLog,d=u===void 0||u;return new Promise(function(h,_){var y=setTimeout(function(){n.off(s,b);var g=new ee({code:Y.API_CALL_TIMEOUT,message:ne({key:S3,data:{commandDesc:c,command:r}})});d&&n.log_.warn(g),_(g)},a),b=function g(I){I.data.seq===f&&(clearTimeout(y),n.off(s,g),h(I))};n.on(s,b);var f=n.send(r,i)})}},{key:"sendWaitForResponseWithRetry",value:function(){var t=this,n=arguments.length<=0?void 0:arguments[0],r=n.commandDesc,i=n.command,o=n.retries,a=o===void 0?0:o,s=n.retryTimeout,c=s===void 0?0:s;return oc({retryFunction:this.sendWaitForResponse,onRetrying:function(u){t.log_.warn("".concat(r||i," timeout observed, retrying [").concat(u,"/").concat(a,"]"))},settings:{retries:a,timeout:c},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(Ze),this.unbindAndCloseSocket(Ki),this.emitConnectionStateChanged(Sl)}},{key:"on",value:function(t,n,r){this.emitter_.on(t,n,r)}},{key:"removeListener",value:function(t,n,r){this.emitter_.removeListener(t,n,r)}},{key:"once",value:function(t,n,r){this.emitter_.once(t,n,r)}},{key:"off",value:function(t,n,r){this.emitter_.off(t,n,r)}},{key:"emitConnectionStateChanged",value:function(t){t!==this.currentState_&&(this.emitter_.emit(mm,{prevState:this.currentState_,state:t}),this.currentState_=t)}}]),e}(),v6=Me,g6=an.find,_6=vu,yT="find",ST=!0;yT in[]&&Array(1).find(function(){ST=!1}),v6({target:"Array",proto:!0,forced:ST},{find:function(e){return g6(this,e,arguments.length>1?arguments[1]:void 0)}}),_6(yT);var er={},bT={},ym={exports:{}},kT=ym.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(kT).forEach(function(e){kT[e].forEach(function(t){t.reg||(t.reg=/(.*)/),t.format||(t.format="%s")})}),function(e){var t=function(a){return String(Number(a))===a?Number(a):a},n=function(a,s,c){var u=a.name&&a.names;a.push&&!s[a.push]?s[a.push]=[]:u&&!s[a.name]&&(s[a.name]={});var d=a.push?{}:u?s[a.name]:s;(function(h,_,y,b){if(b&&!y)_[b]=t(h[1]);else for(var f=0;f<y.length;f+=1)h[f+1]!=null&&(_[y[f]]=t(h[f+1]))})(c.match(a.reg),d,a.names,a.name),a.push&&s[a.push].push(d)},r=ym.exports,i=RegExp.prototype.test.bind(/^([a-z])=(.*)/);e.parse=function(a){var s={},c=[],u=s;return a.split(/(\r\n|\r|\n)/).filter(i).forEach(function(d){var h=d[0],_=d.slice(2);h==="m"&&(c.push({rtp:[],fmtp:[]}),u=c[c.length-1]);for(var y=0;y<(r[h]||[]).length;y+=1){var b=r[h][y];if(b.reg.test(_))return n(b,u,_)}}),s.media=c,s};var o=function(a,s){var c=s.split(/=(.+)/,2);return c.length===2?a[c[0]]=t(c[1]):c.length===1&&s.length>1&&(a[c[0]]=void 0),a};e.parseParams=function(a){return a.split(/;\s?/).reduce(o,{})},e.parseFmtpConfig=e.parseParams,e.parsePayloads=function(a){return a.toString().split(" ").map(Number)},e.parseRemoteCandidates=function(a){for(var s=[],c=a.split(" ").map(t),u=0;u<c.length;u+=3)s.push({component:c[u],ip:c[u+1],port:c[u+2]});return s},e.parseImageAttributes=function(a){return a.split(" ").map(function(s){return s.substring(1,s.length-1).split(",").reduce(o,{})})},e.parseSimulcastStreamList=function(a){return a.split(";").map(function(s){return s.split(",").map(function(c){var u,d=!1;return c[0]!=="~"?u=t(c):(u=t(c.substring(1,c.length)),d=!0),{scid:u,paused:d}})})}}(bT);var Sm=ym.exports,y6=/%[sdv%]/g,S6=function(e){var t=1,n=arguments,r=n.length;return e.replace(y6,function(i){if(t>=r)return i;var o=n[t];switch(t+=1,i){case"%%":return"%";case"%s":return String(o);case"%d":return Number(o);case"%v":return""}})},lc=function(e,t,n){var r=[e+"="+(t.format instanceof Function?t.format(t.push?n:n[t.name]):t.format)];if(t.names)for(var i=0;i<t.names.length;i+=1){var o=t.names[i];t.name?r.push(n[t.name][o]):r.push(n[t.names[i]])}else r.push(n[t.name]);return S6.apply(null,r)},b6=["v","o","s","i","u","e","p","c","b","t","r","z","a"],k6=["i","c","b","a"],oa=bT,T6=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||b6,r=t.innerOrder||k6,i=[];return n.forEach(function(o){Sm[o].forEach(function(a){a.name in e&&e[a.name]!=null?i.push(lc(o,a,e)):a.push in e&&e[a.push]!=null&&e[a.push].forEach(function(s){i.push(lc(o,a,s))})})}),e.media.forEach(function(o){i.push(lc("m",Sm.m[0],o)),r.forEach(function(a){Sm[a].forEach(function(s){s.name in o&&o[s.name]!=null?i.push(lc(a,s,o)):s.push in o&&o[s.push]!=null&&o[s.push].forEach(function(c){i.push(lc(a,s,c))})})})}),i.join(`\r
53
+ `+a.stack)}},e},BS=function(e){return+e<10?"0".concat(e):e},C4=function(e){var t=e.match(/^\d+\.\d+\.\d+/)[0];if(!t)return e;var n=t.split("."),i=BS(n[1])+BS(n[2]);return n[1]-15>0&&(n[1]="15"),n[2]-15>0&&(n[2]="15"),n.join(".")+"."+i};function lo(e,t){try{if(uo(e))return"[".concat(e.map(function(r){return lo(r,t)}).join(","),"]");if(!_i(e)||!uo(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(r){return"{}"}}function sl(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(p){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 FS={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,p,k){if(typeof u!="function")throw new TypeError("The listener must be a function");var x=new r(u,p||s,k),E=n?n+l:l;return s._events[E]?s._events[E].fn?s._events[E]=[s._events[E],x]:s._events[E].push(x):(s._events[E]=x,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 p=0,k=u.length,x=new Array(k);p<k;p++)x[p]=u[p].fn;return x},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,p,k,x){var E=n?n+s:s;if(!this._events[E])return!1;var I,m,T=this._events[E],v=arguments.length;if(T.fn){switch(T.once&&this.removeListener(s,T.fn,void 0,!0),v){case 1:return T.fn.call(T.context),!0;case 2:return T.fn.call(T.context,l),!0;case 3:return T.fn.call(T.context,l,u),!0;case 4:return T.fn.call(T.context,l,u,p),!0;case 5:return T.fn.call(T.context,l,u,p,k),!0;case 6:return T.fn.call(T.context,l,u,p,k,x),!0}for(m=1,I=new Array(v-1);m<v;m++)I[m-1]=arguments[m];T.fn.apply(T.context,I)}else{var C,O=T.length;for(m=0;m<O;m++)switch(T[m].once&&this.removeListener(s,T[m].fn,void 0,!0),v){case 1:T[m].fn.call(T[m].context);break;case 2:T[m].fn.call(T[m].context,l);break;case 3:T[m].fn.call(T[m].context,l,u);break;case 4:T[m].fn.call(T[m].context,l,u,p);break;default:if(!I)for(C=1,I=new Array(v-1);C<v;C++)I[C-1]=arguments[C];T[m].fn.apply(T[m].context,I)}}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,p){var k=n?n+s:s;if(!this._events[k])return this;if(!l)return c(this,k),this;var x=this._events[k];if(x.fn)x.fn!==l||p&&!x.once||u&&x.context!==u||c(this,k);else{for(var E=0,I=[],m=x.length;E<m;E++)(x[E].fn!==l||p&&!x[E].once||u&&x[E].context!==u)&&I.push(x[E]);I.length?this._events[k]=I.length===1?I[0]:I:c(this,k)}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})(FS);var bi=FS.exports,Y=new bi,cl=1,Ip=2,wp=3,ho=4,ia=5,Cp=20,Ep=21,fo=22,Rp=23,Ap=24,Pp=27,Dp=28,ul=29,HS=30,GS=31,Lp=32,Op=33,zS=40,E4=41,R4=52,A4=100,WS=101,ec=102,Mp=103,Un=110,ll=111,Np=112,Ur=113,Vr=114,P4=115,aa=116,D4=120,Up=121,Vp=122,jp=123,tc=130,Bp=131,Fp=132,Hp=133,Gp=134,zp=135,Wp=136,qp=137,dl=200,Jp=201,Kp=300,nc=301,Xp=302,Qp=303;function rc(e){var t=e.retryFunction,n=e.settings,i=e.onError,r=e.onRetrying,o=e.onRetryFailed,c=e.context;return function(){for(var a=this,s=arguments.length,l=new Array(s),u=0;u<s;u++)l[u]=arguments[u];var p=n.retries||5,k=0,x=-1,E=0,I=function(){var m=H(f().mark(function T(v,C){var O,N,j,_;return f().wrap(function(b){for(;;)switch(b.prev=b.next){case 0:return O=c||a,b.prev=1,b.next=4,t.apply(O,l);case 4:N=b.sent,k=0,v(N),b.next=14;break;case 9:b.prev=9,b.t0=b.catch(1),j=function(){clearTimeout(x),k=0,E=2,C(b.t0)},_=function(){E!==2&&k<p?(k++,E=1,pn(r)&&r.call(O,k,j),x=setTimeout(function(){x=-1,I(v,C)},ge(n.timeout)?1e3:n.timeout)):(j(),pn(o)&&o.call(O,b.t0))},pn(i)?i.call(O,b.t0,_,C,l):_();case 14:case"end":return b.stop()}},T,null,[[1,9]])}));return function(T,v){return m.apply(this,arguments)}}();return new Promise(I)}}var L4=Ie(function e(t){Q(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}),O4=function(){function e(t){Q(this,e),this.id_=t.id,this.userId_=t.userId,this.sdkAppId_=t.sdkAppId,this.type_=t.type,this.isLocal_=!Zn(t.isLocal)||t.isLocal}return Ie(e,[{key:"setUserId",value:function(t){this.userId_=t}},{key:"setSdkAppId",value:function(t){this.sdkAppId_=t}},{key:"log",value:function(t,n){ye.log({log:"[".concat(this.isLocal_?"\u2191":"\u2193").concat(this.id_,"] ").concat(this.type_?this.type_+" ":"").concat(n),level:t,forAllJoinedClients:ge(this.userId_),userId:this.userId_,sdkAppId:this.sdkAppId_})}},{key:"info",value:function(t){this.log(Nn.INFO,t)}},{key:"debug",value:function(t){this.log(Nn.DEBUG,t)}},{key:"warn",value:function(t){this.log(Nn.WARN,t)}},{key:"error",value:function(t){this.log(Nn.ERROR,t)}}]),e}(),M4=!(vi||$i),N4=function(){function e(){var i=this;Q(this,e),this.clients_=new Set,this.queue_=[],this.timeoutId_=-1,this.logLevel_=Nn.DEBUG,this.logLevelToUpload_=Nn.INFO,this.enableUploadLog_=!0,this.isAbleToUpload_=!1,this.checkURLParam(),Y.on(HS,function(r){var o=r.client;i.timeoutId_===-1&&i.startUpload(),i.clients_.add(o)}),Y.on(Op,function(r){var o=r.client;return i.clients_.delete(o)}),Y.on(GS,function(r){r&&_i(r.config)&&Yi[r.config.logLevelToUpload]&&(i.logLevelToUpload_=r.config.logLevelToUpload)}),Y.on(ho,this.setIsAbleToUpload,this),Y.on(ia,this.setIsAbleToUpload,this)}var t,n;return Ie(e,[{key:"getIsAbleToUpload",value:function(){return this.isAbleToUpload_}},{key:"setIsAbleToUpload",value:function(){this.isAbleToUpload_=!0,Y.off(ho,this.setIsAbleToUpload,this),Y.off(ia,this.setIsAbleToUpload,this)}},{key:"startUpload",value:(n=H(f().mark(function i(){var r=this;return f().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];a.forAllJoinedClients?i.clients_.forEach(function(s){if(s.getIsJoined()){var l=s.getUserId(),u=s.getSDKAppId();r.map.has(l)?r.map.get(l).logs.push(a):r.map.set(l,{userId:l,sdkAppId:u,logs:[a]})}}):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=H(f().mark(function i(){var r,o,c,a,s,l,u,p,k,x;return f().wrap(function(E){for(;;)switch(E.prev=E.next){case 0:if(this.queue_.length!==0&&this.isAbleToUpload_){E.next=2;break}return E.abrupt("return");case 2:if(r=this.getLogsToUpload(),o=r.map,c=r.splicedQueue,o.size!==0){E.next=5;break}return E.abrupt("return");case 5:E.prev=5,a=Se(o.values()),s=0;case 8:if(!(s<a.length)){E.next=16;break}return l=a[s],u=l.userId,p=l.sdkAppId,k=l.logs,E.next=12,this.uploadLogWithRetry(JSON.stringify({timestamp:Wy(),sdkAppId:String(p),userId:u,version:Bi,log:k.map(function(I){return I.log}).join(`
54
+ `)}),p);case 12:k.forEach(function(I){return I.uploaded=!0});case 13:s++,E.next=8;break;case 16:E.next=20;break;case 18:E.prev=18,E.t0=E.catch(5);case 20:x=c.filter(function(I){return!I.uploaded}),x.length>0&&(this.queue_=x.concat(this.queue_));case 22:case"end":return E.stop()}},i,this,[[5,18]])})),function(){return t.apply(this,arguments)})},{key:"uploadLogWithRetry",value:function(i,r){return rc({retryFunction:function(){return sl({url:al(r,gb),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(rn()),String.prototype.padStart?"[".concat(r.toTimeString().replace(/.*(\d{2}:\d{2}:\d{2}).*/,"$1"),":").concat(r.getMilliseconds().toString().padStart(3,"0"),"] <").concat(Yi[i],">"):"[".concat(r.toTimeString().replace(/.*(\d{2}:\d{2}:\d{2}).*/,"$1"),":").concat(r.getMilliseconds(),"] <").concat(Yi[i],">")}},{key:"getLogLevel",value:function(){return this.logLevel_}},{key:"setLogLevel",value:function(i){ge(Yi[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 L4({log:r,level:o,userId:s,sdkAppId:l,forAllJoinedClients:a})),!(o<this.logLevel_)){var u=Yi[o]?Yi[o].toLowerCase():"info";M4?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:Nn.DEBUG})}},{key:"info",value:function(i){this.log({log:i,level:Nn.INFO})}},{key:"warn",value:function(i){this.log({log:i,level:Nn.WARN})}},{key:"error",value:function(i){this.log({log:i,level:Nn.ERROR})}},{key:"createLogger",value:function(i){return new O4(i)}},{key:"checkURLParam",value:function(){var i=new URLSearchParams(location.search).get("logLevelToUpload");Yi[i]&&(this.logLevelToUpload_=i)}}]),e}(),ye=new N4,qS=!0,U4=at,V4=Math.floor,JS=Number.isInteger||function(e){return!U4(e)&&isFinite(e)&&V4(e)===e};Me({target:"Number",stat:!0},{isInteger:JS});var Yp,j4=Me,KS=pe,B4=be.f,F4=vr,XS=zt,H4=h0,G4=ht,z4=f0,QS=KS("".startsWith),W4=KS("".slice),q4=Math.min,YS=z4("startsWith");j4({target:"String",proto:!0,forced:!!(YS||(Yp=B4(String.prototype,"startsWith"),!Yp||Yp.writable))&&!YS},{startsWith:function(e){var t=XS(G4(this));H4(e);var n=F4(q4(arguments.length>1?arguments[1]:void 0,t.length)),i=XS(e);return QS?QS(t,i,n):W4(t,n,n+i.length)===i}});var $S=_e,J4=pe,K4=Xe,X4=ue,$p=au,Q4=Gd,Y4=qt,$4=Vt,Z4=_n,po=Object.assign,ZS=Object.defineProperty,eU=J4([].concat),ek=!po||X4(function(){if($S&&po({b:1},po(ZS({},"a",{enumerable:!0,get:function(){ZS(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}),po({},e)[n]!=7||$p(po({},t)).join("")!=i})?function(e,t){for(var n=$4(e),i=arguments.length,r=1,o=Q4.f,c=Y4.f;i>r;)for(var a,s=Z4(arguments[r++]),l=o?eU($p(s),o(s)):$p(s),u=l.length,p=0;u>p;)a=l[p++],$S&&!K4(c,s,a)||(n[a]=s[a]);return n}:po,tk=ek;Me({target:"Object",stat:!0,arity:2,forced:Object.assign!==tk},{assign:tk});var nk=pe,tU=Ut,nU=at,rU=kt,rk=Ba,iU=Oe,ik=Function,aU=nk([].concat),oU=nk([].join),Zp={},sU=function(e,t,n){if(!rU(Zp,t)){for(var i=[],r=0;r<t;r++)i[r]="a["+r+"]";Zp[t]=ik("C,a","return new C("+oU(i,",")+")")}return Zp[t](e,n)},cU=iU?ik.bind:function(e){var t=tU(this),n=t.prototype,i=rk(arguments,1),r=function(){var o=aU(i,rk(arguments));return this instanceof r?sU(t,o.length,o):t.apply(e,o)};return nU(n)&&(r.prototype=n),r},ak=cU;Me({target:"Function",proto:!0,forced:Function.bind!==ak},{bind:ak});var uU=Me,lU=nn.findIndex,dU=cu,ok="findIndex",sk=!0;ok in[]&&Array(1).findIndex(function(){sk=!1}),uU({target:"Array",proto:!0,forced:sk},{findIndex:function(e){return lU(this,e,arguments.length>1?arguments[1]:void 0)}}),dU(ok);var hU=_e,ck=pe,fU=au,pU=yn,mU=ck(qt.f),vU=ck([].push),uk=function(e){return function(t){for(var n,i=pU(t),r=fU(i),o=r.length,c=0,a=[];o>c;)n=r[c++],hU&&!mU(i,n)||vU(a,e?[n,i[n]]:i[n]);return a}},gU={entries:uk(!0),values:uk(!1)}.values;Me({target:"Object",stat:!0},{values:function(e){return gU(e)}});var lk=1,dk=5,em=2,ic=3,tm=4,hl="DISCONNECTED",hk="CONNECTING",nm="RECONNECTING",ac="CONNECTED",jr={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},_U=[jr.UPDATE_REMOTE_MUTE_STAT,jr.UPLINK_NETWORK_STATS,jr.USER_LIST_RES,jr.MUTE_RESULT],mt={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"},yU="publish_change",bU="publish_state_change",SU="join",kU="leave",TU="quality_report",xU="mute_uplink",IU="publish",fk="unpublish",wU="subscribe",CU="unsubscribe",EU="subscribe_change",RU="start_publishing",AU="stop_publishing",PU="start_push_user_cdn",DU="stop_push_user_cdn",LU="start_mcu_mix",OU="stop_mcu_mix",MU="get_user_list",NU="change_role",UU="update_constraint_config",ee={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},ne=function(e){Ct(n,e);var t=Er(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?ee.UNKNOWN:s,u=i.extraCode,p=u===void 0?0:u,k=i.constraint;Q(this,n);var x="<".concat(function(E){for(var I in ee)if(ee[I]===E)return I;return"UNKNOWN"}(l)," 0x").concat(l.toString(16),">");return(r=t.call(this,a+"".concat(k?" constraint: ".concat(k):"")+"".concat(a!=null&&a.includes(x)?"":" "+x))).code_=l,r.extraCode_=p,r.name=c,r.message_=a,k&&(r.constraint=k),r}return Ie(n,[{key:"getCode",value:function(){return this.code_}},{key:"getExtraCode",value:function(){return this.extraCode_}}]),n}(zo(Error)),pk=32768,mk=32769,vk=32770,gk=32771,VU=32772,jU=32773,BU=32774,FU=32775,_k=32777,HU=32778,rm=32779,GU=32780,zU=32781,WU=32782,qU=32783,JU=32784,KU=32785,XU=32786,QU=32787,YU=32788,$U=32789,ZU=32790,eV=32791,tV=32792,nV=32793,rV=32794,iV=32795,aV=32796,oV=32797,sV=32798,cV=32799,uV=32800,lV=32801,dV=32802,hV=32803,fV=32804,oc=new Map,mn=function(e,t){var n=oc.get(e);n||(oc.set(e,[]),n=oc.get(e)),n.push(t)},pV=function(e){var t=oc.get(e),n=[];return t?(oc.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},mV=Object.prototype.hasOwnProperty;function Si(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(_i(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(mV.call(e,t))return!1;return!0}return!1}var vV=function(){function e(){Q(this,e);var t=na(),n=t.name,i=t.version;this.roomIdMap_=new Map,this.configs_={sdkAppId:"",userId:"",version:Bi,env:Hu,browserVersion:n+i,ua:navigator.userAgent}}return Ie(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(!ea){var n=q(q(q({},t),this.configs_),{},{userId:t.userId||this.configs_.userId});ge(n.code)&&(n.code=n.result==="failed"?ee.UNKNOWN:0),this.sendRequest(al(this.configs_.sdkAppId,BM),n)}}},{key:"logSuccessEvent",value:function(t){ea||(this.logEvent(q(q({},t),{},{result:"success",roomId:this.roomIdMap_.get(t.userId)})),this.configs_.env===Hu&&this.uploadEventToKibana(q(q({},t),{},{result:"success"})))}},{key:"logFailedEvent",value:function(t){if(!ea){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 ne?r.getExtraCode()||r.getCode():ee.UNKNOWN)};this.logEvent(c),this.configs_.env===Hu&&this.uploadEventToKibana(q(q({},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:Wy(),sdkAppId:this.configs_.sdkAppId,userId:i||this.configs_.userId,version:this.configs_.version,log:n};r&&(o.errorInfo=r.message),this.sendRequest(al(this.configs_.sdkAppId,gb),o)}},{key:"sendRequest",value:function(t,n){var i=this;ye.getIsAbleToUpload()?sl({url:t,body:JSON.stringify(n)}).catch(function(){}):setTimeout(function(){i.sendRequest(t,n)},1e3)}}]),e}(),xe=new vV,gV=function(){function e(t){Q(this,e),this.client_=t.client,this.sdkAppId_=t.sdkAppId,this.userId_=t.userId,this.userSig_=t.userSig,this.url_=t.url,this.backupUrl_=t.backupUrl;var n="?sdkAppId=".concat(encodeURIComponent(this.sdkAppId_),"&userId=").concat(encodeURIComponent(this.userId_),"&userSig=").concat(encodeURIComponent(this.userSig_),"&roomId=").concat(encodeURIComponent(t.roomId)),i=this.client_.getSystemResult();if(i&&i.detail){var r=i.detail,o=r.isH264EncodeSupported,c=r.isVp8EncodeSupported,a=r.isH264DecodeSupported,s=r.isVp8DecodeSupported;n+="&enc264=".concat(Number(o),"&dec264=").concat(Number(a),"&encVp8=").concat(Number(c),"&decVp8=").concat(Number(s))}t.signalDomainWhenUnifiedProxy&&(n+="&signalDomain=".concat(encodeURIComponent(t.signalDomainWhenUnifiedProxy))),this.urlWithParam_="".concat(this.url_).concat(n),this.backupUrlWithParam_="".concat(this.backupUrl_).concat(n),this.isConnected_=!1,this.isConnecting_=!1,this.socketInUse_=null,this.socket_=null,this.backupSocket_=null,this.backupTimer_=-1,this.signalInfo_={},this.currentState_=hl,this.reconnectionCount_=0,this.reconnectionTimer_=-1,this.lastMessageTime_=-1,this.seq_=0,this.log_=ye.createLogger({id:"ws|"+this.userId_,userId:this.userId_,sdkAppId:this.sdkAppId_}),this.emitter_=new bi}return Ie(e,[{key:"isOnline",get:function(){return this.currentState_===ac&&Date.now()-this.lastMessageTime_<12e3}},{key:"connect",value:function(){var t=this;return new Promise(function(n,i){t.log_.info("connect to url: ".concat(t.urlWithParam_)),t.emitConnectionStateChanged(hk),t.socket_=new WebSocket(t.urlWithParam_),t.bindSocket(t.socket_),t.backupTimer_=setTimeout(function(){t.isConnected_||(t.log_.info("trying to connect to backupUrl"),t.tryConnectBackup())},5e3);var r=setTimeout(function(){t.close(),i(new ne({code:ee.JOIN_ROOM_FAILED,message:"join room timeout"}))},1e4);t.once(ic,function(){clearTimeout(r),n()}),t.once(tm,function(o){clearTimeout(r),i(o)})})}},{key:"tryConnectBackup",value:function(){this.backupSocket_||(this.unbindAndCloseSocket(Ye),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(t){t.onopen=this.onopen.bind(this),t.onclose=this.onclose.bind(this),t.onerror=this.onerror.bind(this),t.onmessage=this.onmessage.bind(this)}},{key:"unbindSocket",value:function(t){t.onopen=function(){},t.onclose=function(){},t.onerror=function(){},t.onmessage=function(){}}},{key:"unbindAndCloseSocket",value:function(t){if(t===Ye){if(this.socket_){this.unbindSocket(this.socket_);try{this.socket_.close(1e3)}catch(n){}this.socket_=null}}else if(this.backupSocket_){this.unbindSocket(this.backupSocket_);try{this.backupSocket_.close(1e3)}catch(n){}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(t){if(!this.isConnected_){this.isConnected_=!0,this.isConnecting_=!1,this.isReconnecting_&&Si(this.signalInfo_)&&this.stopReconnection(),this.clearBackupTimer(),t.target===this.socket_?(this.unbindAndCloseSocket(Mr),this.socketInUse_=this.socket_):(this.unbindAndCloseSocket(Ye),this.socketInUse_=this.backupSocket_);var n=t.target.url;this.log_.info("websocket[".concat(n,"] is connected")),this.currentState_===hk?this.addSignalEvent(eV,"signal channel is connected"):this.currentState_===nm&&this.addSignalEvent(iV,"signal channel reconnect success"),this.emitConnectionStateChanged(ac),this.emitter_.emit(ic)}}},{key:"onclose",value:function(t){var n=t.target.url,i=t.target===this.socketInUse_;if(this.log_.info("websocket[".concat(n," InUse: ").concat(i,"] is closed with code: ").concat(t.code)),i&&(this.isConnected_=!1,this.emitConnectionStateChanged(hl),this.addSignalEvent(ZU,"signal channel is disconnected"),!t.wasClean||t.code!==1e3)){this.log_.warn("onclose code:".concat(t.code," reason:").concat(t.reason)),this.log_.warn("close current websocket and schedule a reconnect timeout"),this.socketInUse_.onclose=function(){},this.socketInUse_.close(4011);var r=this.socketInUse_===this.socket_;this.socket_=this.backupSocket_=this.socketInUse_=null,this.reconnect(r?Mr:Ye)}}},{key:"onerror",value:function(t){var n=t.target.url;if(this.log_.error("websocket[".concat(n,"] error observed")),this.isConnected_){if(t.target===this.socketInUse_){this.isConnected_=!1,this.unbindAndCloseSocket(Ye),this.unbindAndCloseSocket(Mr);var i=this.socketInUse_===this.socket_;this.socketInUse_=null,this.reconnect(i?Mr:Ye)}}else this.isReconnecting_||xe.logFailedEvent({userId:this.client_.getUserId(),eventType:jf,code:ee.UNKNOWN}),t.target==this.socket_?(this.unbindAndCloseSocket(Ye),this.reconnect(Mr)):(this.unbindAndCloseSocket(Mr),this.reconnect(Ye));this.isConnecting_=!1,this.isConnected_=!1}},{key:"onmessage",value:function(t){if(this.isConnected_){this.lastMessageTime_=Date.now();var n=JSON.parse(t.data),i=n.cmd,r=n.data,o=Object.values(jr),c=Object.keys(jr)[o.indexOf(i)],a=mt[c];switch(_U.includes(i)||(this.log_.debug("received msg: ".concat(t.data)),this.log_.info("Received event: [ ".concat(a||"unknown cmd: "+i," ]"))),i){case jr.CHANNEL_SETUP_RESULT:if(n.code===0)this.signalInfo_.clientIp=r.clientIp,this.signalInfo_.signalIp=r.signalInnerIp,this.signalInfo_.tinyId=n.tinyId,r.svrTime&&function(l){$h=l-new Date().getTime();var u=new Date;u.setTime(l),ye.info("baseTime from server: "+u+" offset: "+$h)}(r.svrTime),this.log_.info("ChannelSetup Success"),xe.logSuccessEvent({userId:this.userId_,eventType:jf}),this.emitter_.emit(lk,{signalInfo:this.signalInfo_});else{var s=new ne({code:ee.SIGNAL_CHANNEL_SETUP_FAILED,extraCode:n.code,message:ie({key:SN,data:{errorCode:n.code,errorMsg:n.message}})});this.log_.error("".concat(n.code,", ").concat(n.message)),this.close(),xe.logFailedEvent({userId:this.userId_,eventType:jf,error:s}),this.emitter_.emit(dk,s)}break;case jr.JOIN_ROOM_RESULT:n.code===0&&(this.signalInfo_.relayIp=r.relayOuterIp,this.signalInfo_.relayInnerIp=r.relayInnerIp,this.signalInfo_.relayPort=r.relayPort,this.log_.info("signalIp:".concat(this.signalInfo_.signalIp," clientIp:").concat(this.signalInfo_.clientIp," relayIp: ").concat(this.signalInfo_.relayIp))),this.emitter_.emit(a,{data:n});break;case jr.CHANNEL_RECONNECT_RESULT:n.code===0?(this.log_.warn("reconnect success"),this.stopReconnection(),xe.logSuccessEvent({userId:this.userId_,eventType:Lb}),this.client_.syncUserList(),this.client_.checkConnectionsToReconnect()):(this.log_.warn("reconnect failed, ".concat(n.code," ").concat(n.message)),this.client_.reJoin());break;default:this.emitter_.emit(a,{data:n})}}}},{key:"addSignalEvent",value:function(t,n){mn(this.userId_,{eventId:t,eventDesc:n,timestamp:rn(),userId:this.userId_,tinyId:this.signalInfo_.tinyId})}},{key:"reconnect",value:function(){var t=this,n=arguments.length>0&&arguments[0]!==void 0?arguments[0]:Ye;if(this.isConnecting_||this.reconnectionTimer_!==-1)this.log_.info("signal channel is reconnecting, ignoring current reconnection");else{if(Y.emit(zS,this.client_),this.reconnectionCount_>=Vf){this.log_.warn("SDK has tried reconnect signal channel for ".concat(Vf," times, but all failed. please check your network"));var i=new ne({code:ee.SIGNAL_CHANNEL_RECONNECTION_FAILED,message:ie({key:bN})});return xe.logFailedEvent({userId:this.client_.getUserId(),eventType:Lb,error:i}),this.addSignalEvent(aV,"signal channel reconnect fail"),void this.emitter_.emit(tm,i)}this.isConnecting_=!0,this.reconnectionCount_++,this.currentState_!==nm&&(this.emitConnectionStateChanged(nm),this.addSignalEvent(rV,"signal channel is reconnecting")),this.log_.warn("reconnecting to ".concat(n," signal channel [").concat(this.reconnectionCount_,"/").concat(Vf,"]"));var r=this.getReconnectionUrl(n);n===Ye?(this.socket_=new WebSocket(r),this.bindSocket(this.socket_)):(this.backupSocket_=new WebSocket(r),this.bindSocket(this.backupSocket_));var o=Sp(this.reconnectionCount_);this.reconnectionTimer_=setTimeout(function(){t.log_.warn("reconnect ".concat(n," signal channel timeout(").concat(o/1e3,"s), close and try again")),t.isConnecting_=!1,t.clearReconnectionTimer(),t.unbindAndCloseSocket(n),t.reconnect(n===Ye?Mr:Ye)},o)}}},{key:"isConnected",value:function(){return this.isConnected_}},{key:"isReconnecting_",get:function(){return this.reconnectionTimer_!==-1}},{key:"getReconnectionUrl",value:function(t){var n=t===Ye?this.urlWithParam_:this.backupUrlWithParam_;if(!Si(this.signalInfo_)&&n.indexOf("&rc=1")===-1){var i=this.client_.getRoomId(),r=this.client_.getUseStringRoomId();n+="&rc=1&relayInnerIp=".concat(this.signalInfo_.relayInnerIp,"&relayOuterIp=").concat(this.signalInfo_.relayIp,"&relayPort=").concat(this.signalInfo_.relayPort,"&roomId=").concat(i,"&useStringRoomId=").concat(r)}return n}},{key:"send",value:function(t){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(this.isConnected_){var i={cmd:t,data:n,userId:this.userId_,tinyId:this.signalInfo_.tinyId,seq:++this.seq_};return this.socketInUse_.send(JSON.stringify(i)),i.seq}}},{key:"sendWaitForResponse",value:function(t){var n=this,i=t.command,r=t.data,o=t.timeout,c=o===void 0?5e3:o,a=t.responseCommand,s=t.commandDesc,l=t.enableLog,u=l===void 0||l;return new Promise(function(p,k){var x=setTimeout(function(){n.off(a,E);var m=new ne({code:ee.API_CALL_TIMEOUT,message:ie({key:yN,data:{commandDesc:s,command:i}})});u&&n.log_.warn(m),k(m)},c),E=function m(T){T.data.seq===I&&(clearTimeout(x),n.off(a,m),p(T))};n.on(a,E);var I=n.send(i,r)})}},{key:"sendWaitForResponseWithRetry",value:function(){var t=this,n=arguments.length<=0?void 0:arguments[0],i=n.commandDesc,r=n.command,o=n.retries,c=o===void 0?0:o,a=n.retryTimeout,s=a===void 0?0:a;return rc({retryFunction:this.sendWaitForResponse,onRetrying:function(l){t.log_.warn("".concat(i||r," timeout observed, retrying [").concat(l,"/").concat(c,"]"))},settings:{retries:c,timeout:s},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(Ye),this.unbindAndCloseSocket(Mr),this.emitConnectionStateChanged(hl)}},{key:"on",value:function(t,n,i){this.emitter_.on(t,n,i)}},{key:"removeListener",value:function(t,n,i){this.emitter_.removeListener(t,n,i)}},{key:"once",value:function(t,n,i){this.emitter_.once(t,n,i)}},{key:"off",value:function(t,n,i){this.emitter_.off(t,n,i)}},{key:"emitConnectionStateChanged",value:function(t){t!==this.currentState_&&(this.emitter_.emit(em,{prevState:this.currentState_,state:t}),this.currentState_=t)}}]),e}(),_V=Me,yV=nn.find,bV=cu,yk="find",bk=!0;yk in[]&&Array(1).find(function(){bk=!1}),_V({target:"Array",proto:!0,forced:bk},{find:function(e){return yV(this,e,arguments.length>1?arguments[1]:void 0)}}),bV(yk);var er={},Sk={},im={exports:{}},kk=im.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(kk).forEach(function(e){kk[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(p,k,x,E){if(E&&!x)k[E]=t(p[1]);else for(var I=0;I<x.length;I+=1)p[I+1]!=null&&(k[x[I]]=t(p[I+1]))})(s.match(c.reg),u,c.names,c.name),c.push&&a[c.push].push(u)},i=im.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 p=u[0],k=u.slice(2);p==="m"&&(s.push({rtp:[],fmtp:[]}),l=s[s.length-1]);for(var x=0;x<(i[p]||[]).length;x+=1){var E=i[p][x];if(E.reg.test(k))return n(E,l,k)}}),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}})})}}(Sk);var am=im.exports,SV=/%[sdv%]/g,kV=function(e){var t=1,n=arguments,i=n.length;return e.replace(SV,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""}})},sc=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 kV.apply(null,i)},TV=["v","o","s","i","u","e","p","c","b","t","r","z","a"],xV=["i","c","b","a"],oa=Sk,IV=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||TV,i=t.innerOrder||xV,r=[];return n.forEach(function(o){am[o].forEach(function(c){c.name in e&&e[c.name]!=null?r.push(sc(o,c,e)):c.push in e&&e[c.push]!=null&&e[c.push].forEach(function(a){r.push(sc(o,c,a))})})}),e.media.forEach(function(o){r.push(sc("m",am.m[0],o)),i.forEach(function(c){am[c].forEach(function(a){a.name in o&&o[a.name]!=null?r.push(sc(c,a,o)):a.push in o&&o[a.push]!=null&&o[a.push].forEach(function(s){r.push(sc(c,a,s))})})})}),r.join(`\r
91
55
  `)+`\r
92
- `};er.write=T6,er.parse=oa.parse,er.parseParams=oa.parseParams,er.parseFmtpConfig=oa.parseFmtpConfig,er.parsePayloads=oa.parsePayloads,er.parseRemoteCandidates=oa.parseRemoteCandidates,er.parseImageAttributes=oa.parseImageAttributes,er.parseSimulcastStreamList=oa.parseSimulcastStreamList;var Fr=function(e){return er.parse(e)},mo=function(e){return er.write(e)},x6=function(e){var t=Fr(e);return t.media.forEach(function(n){n.type===Ce&&n.fmtp.forEach(function(r){r.config+=";sprop-stereo=1;stereo=1"})}),mo(t)};function I6(e){var t=Fr(e);return t.media.forEach(function(n){if(n.type===xe){var r=new Set;n.rtp.forEach(function(o){var a=o.payload;return o.codec==="H264"&&r.add(a)}),n.fmtp.forEach(function(o){var a=o.payload,s=o.config.match(/apt=(\d+)/);s&&s[1]&&r.has(Number(s[1]))&&r.add(a)});var i=function(o){var a=o.payload;return!r.has(a)};n.rtp=n.rtp.filter(i),n.rtcpFb=n.rtcpFb.filter(i),n.fmtp=n.fmtp.filter(i),n.payloads=n.payloads.split(" ").filter(function(o){return!r.has(Number(o))}).join(" ")}}),mo(t)}var bm,km,Tm,xm,w6=Me,Im=pe,E6=$n,C6=oS,R6=e0,TT=oe,A6=RangeError,xT=String,IT=Math.floor,wm=Im(R6),wT=Im("".slice),dc=Im(1 .toFixed),vo=function(e,t,n){return t===0?n:t%2==1?vo(e,t-1,n*e):vo(e*e,t/2,n)},go=function(e,t,n){for(var r=-1,i=n;++r<6;)i+=t*e[r],e[r]=i%1e7,i=IT(i/1e7)},Em=function(e,t){for(var n=6,r=0;--n>=0;)r+=e[n],e[n]=IT(r/t),r=r%t*1e7},ET=function(e){for(var t=6,n="";--t>=0;)if(n!==""||t===0||e[t]!==0){var r=xT(e[t]);n=n===""?r:n+wm("0",7-r.length)+r}return n};w6({target:"Number",proto:!0,forced:TT(function(){return dc(8e-5,3)!=="0.000"||dc(.9,0)!=="1"||dc(1.255,2)!=="1.25"||dc(0xde0b6b3a7640080,0)!=="1000000000000000128"})||!TT(function(){dc({})})},{toFixed:function(e){var t,n,r,i,o=C6(this),a=E6(e),s=[0,0,0,0,0,0],c="",u="0";if(a<0||a>20)throw A6("Incorrect fraction digits");if(o!=o)return"NaN";if(o<=-1e21||o>=1e21)return xT(o);if(o<0&&(c="-",o=-o),o>1e-21)if(n=(t=function(d){for(var h=0,_=d;_>=4096;)h+=12,_/=4096;for(;_>=2;)h+=1,_/=2;return h}(o*vo(2,69,1))-69)<0?o*vo(2,-t,1):o/vo(2,t,1),n*=4503599627370496,(t=52-t)>0){for(go(s,0,n),r=a;r>=7;)go(s,1e7,0),r-=7;for(go(s,vo(10,r,1),0),r=t-1;r>=23;)Em(s,1<<23),r-=23;Em(s,1<<r),go(s,1,1),Em(s,2),u=ET(s)}else go(s,0,n),go(s,1<<-t,0),u=ET(s)+wm("0",a);return u=a>0?c+((i=u.length)<=a?"0."+wm("0",a-i)+u:wT(u,0,i-a)+"."+wT(u,i-a)):c+u}});var CT=((bm=window)===null||bm===void 0?void 0:bm.requestIdleCallback)||function(e){var t=Date.now();return setTimeout(function(){e({didTimeout:!1,timeRemaining:function(){return Math.max(0,50-(Date.now()-t))}})},1e3)},P6=((km=window)===null||km===void 0?void 0:km.cancelIdleCallback)||function(e){clearTimeout(e)},D6=((Tm=window)===null||Tm===void 0?void 0:Tm.cancelAnimationFrame)||((xm=window)===null||xm===void 0?void 0:xm.mozCancelAnimationFrame),yt=function(){function e(){J(this,e)}return ye(e,null,[{key:"generateTaskID",value:function(){return this.currentTaskID++}},{key:"run",value:function(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:ek,n=arguments.length>1?arguments[1]:void 0,r=arguments.length>2?arguments[2]:void 0;r=H(H({},t===u3?{delay:2e3,count:0,backgroundTask:!0}:t===so?{delay:1e4,count:0}:t===rl?{fps:60,delay:16.6,count:0,backgroundTask:!0}:{delay:2e3,count:0,backgroundTask:!0}),r),Ok(n)&&(r=H(H({},r),n)),In(t)&&(n=t,t=ek);var i=H({taskID:this.generateTaskID(),loopCount:0,intervalID:null,timeoutID:null,rafID:null,ricID:null,taskName:t,callback:n},r);return this.taskMap.set(i.taskID,i),this[t](i),i.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 r(){if(t.callback(),t.loopCount+=1,!n.isBreakLoop(t))return t.timeoutID=setTimeout(r,t.delay)},t.delay)}},{key:"ric",value:function(t){var n,r=this,i=Pt();return t.ricID=CT(function o(){if((n=Pt()-i)>=t.delay&&(i=Pt()-Math.floor(n%t.delay),t.callback(),t.loopCount+=1),!r.isBreakLoop(t))return t.ricID=CT(o,{timeout:t.delay})},{timeout:t.delay})}},{key:"raf",value:function(t){var n=this;t.delay=(1e3/t.fps).toFixed(2);var r,i=Pt(),o=function s(){if(document.hidden&&t.backgroundTask)return r=Pt()-i,i=Pt(),t.callback(),t.loopCount+=1,n.isBreakLoop(t)?void 0:t.timeoutID=setTimeout(s,t.delay-Math.floor(r%t.delay));if((r=Pt()-i)>=t.delay&&(i=Pt()-Math.floor(r%t.delay),t.callback(),t.loopCount+=1),!n.isBreakLoop(t))return t.rafID=requestAnimationFrame(s)};if(t.rafID=requestAnimationFrame(o),t.backgroundTask){var a=function(){if(document.hidden){var s=Pt()-i;s>=t.delay?o():t.timeoutID=setTimeout(o,t.delay-s)}};document.addEventListener("visibilitychange",a),t.onVisibilitychange=a,document.hidden&&a()}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),r=n.intervalID,i=n.timeoutID,o=n.rafID,a=n.ricID,s=n.onVisibilitychange;return r&&clearInterval(r),i&&clearTimeout(i),o&&D6(o),a&&P6(a),s&&document.removeEventListener("visibilitychange",s),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}();ut(yt,"taskMap",new Map),ut(yt,"currentTaskID",1);var L6=function(){function e(){J(this,e),this.prefix_="TRTC",this.queue_=new Map,this.checkStorage()}return ye(e,[{key:"getRealKey",value:function(t){return"".concat(this.prefix_,"_").concat(t)}},{key:"checkStorage",value:function(){var t=this;if(ea()){var n=Object.keys(localStorage).filter(function(r){if(r.startsWith(t.prefix_)){var i=JSON.parse(localStorage.getItem(r));if(i&&i.expiresIn<Date.now())return!0}return!1});n.forEach(function(r){return localStorage.removeItem(r)})}}},{key:"doFlush",value:function(){if(ea())try{var t,n=ie(this.queue_);try{for(n.s();!(t=n.n()).done;){var r=Te(t.value,2),i=r[0],o=r[1];localStorage.setItem(i,JSON.stringify(o))}}catch(a){n.e(a)}finally{n.f()}}catch(a){ke.warn(a)}}},{key:"getItem",value:function(t){if(!ea())return null;try{var n=JSON.parse(localStorage.getItem(this.getRealKey(t)));return n&&n.expiresIn>=Date.now()?n.value:null}catch(r){ke.warn(r)}}},{key:"setItem",value:function(t,n){var r=arguments.length>2&&arguments[2]!==void 0&&arguments[2];if(ea())try{var i={expiresIn:Date.now()+qb,value:n};r?localStorage.setItem(this.getRealKey(t),JSON.stringify(i)):(this.queue_.set(this.getRealKey(t),i),yt.hasTask(this.intervalId_)||(this.intervalId_=yt.run(so,this.doFlush.bind(this),{count:1})))}catch(o){ke.warn(o)}}},{key:"deleteItem",value:function(t){if(!ea())return!1;try{return t=this.getRealKey(t),this.queue_.delete(t),localStorage.removeItem(t),!0}catch(n){return ke.warn(n),!1}}},{key:"clear",value:function(){if(ea())try{localStorage.clear()}catch(t){ke.warn(t)}}}]),e}(),_o=new L6,gt={result:!1,detail:{isBrowserSupported:!1,isWebRTCSupported:!1,isMediaDevicesSupported:!1,isH264EncodeSupported:!1,isVp8EncodeSupported:!1,isH264DecodeSupported:!1,isVp8DecodeSupported:!1}},RT="checkResult",AT=function(){return!mV&&!al&&!(ol&&wk<80)&&!(Tr&&Ik<56)},Cm=function(){return["RTCPeerConnection","webkitRTCPeerConnection","RTCIceGatherer"].filter(function(e){return e in window}).length>0},O6=function(){if(!navigator.mediaDevices)return!1;var e=["getUserMedia","enumerateDevices"];return e.filter(function(t){return t in navigator.mediaDevices}).length===e.length},PT=function(){var e=N(p().mark(function t(){var n,r,i,o,a,s;return p().wrap(function(c){for(;;)switch(c.prev=c.next){case 0:if(!gt.detail.isH264EncodeSupported||!gt.detail.isVp8EncodeSupported){c.next=2;break}return c.abrupt("return",{isH264EncodeSupported:gt.detail.isH264EncodeSupported,isVp8EncodeSupported:gt.detail.isVp8EncodeSupported});case 2:return n="",r=!1,i=!1,c.prev=5,o=new RTCPeerConnection,(a=document.createElement(hb)).getContext("2d"),s=a.captureStream(0),o.addTrack(s.getVideoTracks()[0],s),c.next=13,o.createOffer();case 13:return(n=c.sent).sdp.toLowerCase().indexOf("h264")!==-1&&(r=!0),n.sdp.toLowerCase().indexOf("vp8")!==-1&&(i=!0),o.close(),gt.detail.isH264EncodeSupported=r,gt.detail.isVp8EncodeSupported=i,c.abrupt("return",{isH264EncodeSupported:gt.detail.isH264EncodeSupported,isVp8EncodeSupported:gt.detail.isVp8EncodeSupported});case 22:return c.prev=22,c.t0=c.catch(5),c.abrupt("return",{isH264EncodeSupported:!1,isVp8EncodeSupported:!1});case 25:case"end":return c.stop()}},t,null,[[5,22]])}));return function(){return e.apply(this,arguments)}}();function M6(){return Rm.apply(this,arguments)}function Rm(){return Rm=N(p().mark(function e(){return p().wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",new Promise(function(){var n=N(p().mark(function r(i){var o,a,s,c,u,d,h,_,y,b,f,g,I,w;return p().wrap(function(j){for(;;)switch(j.prev=j.next){case 0:return o={encode:!1,decode:!1},a=null,j.prev=2,s=document.createElement("canvas"),c=s.getContext("2d"),s.width=640,s.height=480,u=setInterval(function(){c.fillText("test",Math.floor(640*Math.random()),Math.floor(480*Math.random()))},33),d=-1,h=-1,a=function(){clearInterval(d),clearInterval(u),clearTimeout(h),y.close(),b.close(),_.getTracks().forEach(function(z){return z.stop()})},h=setTimeout(function(){a(),i(o)},3e3),_=s.captureStream(),y=new RTCPeerConnection({}),b=new RTCPeerConnection({offerToReceiveAudio:!0,offerToReceiveVideo:!0}),y.addEventListener("icecandidate",function(z){return b.addIceCandidate(z.candidate)}),b.addEventListener("icecandidate",function(z){return y.addIceCandidate(z.candidate)}),y.addTrack(_.getVideoTracks()[0],_),j.next=20,y.createOffer();case 20:return f=j.sent,j.next=23,y.setLocalDescription(f);case 23:return j.next=25,b.setRemoteDescription(f);case 25:return j.next=27,b.createAnswer();case 27:return g=j.sent,I=Fr(g.sdp),w=I.media[0].rtp.findIndex(function(z){return z.codec==="H264"}),I.media[0].rtp=[I.media[0].rtp[w]],I.media[0].fmtp=I.media[0].fmtp.filter(function(z){return z.payload===I.media[0].rtp[0].payload}),I.media[0].rtcpFb=I.media[0].rtcpFb.filter(function(z){return z.payload===I.media[0].rtp[0].payload}),g.sdp=mo(I),j.next=36,b.setLocalDescription(g);case 36:return j.next=38,y.setRemoteDescription(g);case 38:d=setInterval(N(p().mark(function z(){var $,ue;return p().wrap(function(L){for(;;)switch(L.prev=L.next){case 0:return o.encode&&o.decode&&(a(),i(o)),L.next=3,y.getStats();case 3:return $=L.sent,L.next=6,b.getStats();case 6:ue=L.sent,o.encode||$.forEach(function(k){k.type==="outbound-rtp"&&k.mediaType===xe&&k.framesEncoded>0&&(o.encode=!0)}),o.decode||ue.forEach(function(k){k.type==="inbound-rtp"&&k.mediaType===xe&&k.framesDecoded>0&&(o.decode=!0)});case 9:case"end":return L.stop()}},z)})),500),j.next=46;break;case 41:j.prev=41,j.t0=j.catch(2),a(),ke.warn(j.t0),i(o);case 46:case"end":return j.stop()}},r,null,[[2,41]])}));return function(r){return n.apply(this,arguments)}}()));case 1:case"end":return t.stop()}},e)})),Rm.apply(this,arguments)}var DT=function(){var e=N(p().mark(function t(){var n,r,i,o;return p().wrap(function(a){for(;;)switch(a.prev=a.next){case 0:if(!gt.detail.isH264DecodeSupported||!gt.detail.isVp8DecodeSupported){a.next=2;break}return a.abrupt("return",{isH264DecodeSupported:gt.detail.isH264DecodeSupported,isVp8DecodeSupported:gt.detail.isVp8DecodeSupported});case 2:return n="",r=!1,i=!1,a.prev=5,o=new RTCPeerConnection,a.next=9,o.createOffer({offerToReceiveAudio:1,offerToReceiveVideo:1});case 9:return(n=a.sent).sdp.toLowerCase().indexOf("h264")!==-1&&(r=!0),n.sdp.toLowerCase().indexOf("vp8")!==-1&&(i=!0),o.close(),a.abrupt("return",{isH264DecodeSupported:r,isVp8DecodeSupported:i});case 16:return a.prev=16,a.t0=a.catch(5),a.abrupt("return",{isH264DecodeSupported:!1,isVp8DecodeSupported:!1});case 19:case"end":return a.stop()}},t,null,[[5,16]])}));return function(){return e.apply(this,arguments)}}(),N6=function(){var e=N(p().mark(function t(){var n,r,i,o,a,s,c,u,d,h,_,y,b;return p().wrap(function(f){for(;;)switch(f.prev=f.next){case 0:if(LT()){f.next=2;break}return f.abrupt("return",gt);case 2:return n=AT(),r=Cm(),i=O6(),f.next=7,PT();case 7:return o=f.sent,a=o.isH264EncodeSupported,s=o.isVp8EncodeSupported,f.next=12,DT();case 12:if(c=f.sent,u=c.isH264DecodeSupported,d=c.isVp8DecodeSupported,a&&s){f.next=21;break}return f.next=18,PT();case 18:h=f.sent,a=h.isH264EncodeSupported,s=h.isVp8EncodeSupported;case 21:if(!(a&&u&&(cl||ul||TV)&&!Vr&&nc()<79)){f.next=29;break}return f.next=24,M6();case 24:_=f.sent,y=_.encode,b=_.decode,a=y,u=b;case 29:return gt.result=n&&r&&i&&(a||s)&&(u||d),gt.detail.isBrowserSupported=n,gt.detail.isWebRTCSupported=r,gt.detail.isMediaDevicesSupported=i,gt.detail.isH264EncodeSupported=a,gt.detail.isVp8EncodeSupported=s,gt.detail.isH264DecodeSupported=u,gt.detail.isVp8DecodeSupported=d,V6(),_o.setItem(RT,{ua:navigator.userAgent,checkResult:gt},!0),f.abrupt("return",gt);case 40:case"end":return f.stop()}},t)}));return function(){return e.apply(this,arguments)}}(),Am=function(e,t){var n=null;return function(){if(n)return n;for(var r=arguments.length,i=new Array(r),o=0;o<r;o++)i[o]=arguments[o];return(n=e.apply(t||this,i)).then(function(a){return n=null,a}).catch(function(a){throw n=null,a}),n}}(N6);function LT(){return Object.keys(gt.detail).findIndex(function(e){return!gt.detail[e]})>=0}function V6(){LT()&&(ke.warn(ne({key:fk})),ke.info("".concat(navigator.userAgent," ").concat(JSON.stringify(gt.detail))))}function OT(){return!(!navigator.mediaDevices||!navigator.mediaDevices.getDisplayMedia)}function MT(){return"RTCPeerConnection"in window&&"getReceivers"in window.RTCPeerConnection.prototype}function bl(){return"RTCPeerConnection"in window&&"getSenders"in window.RTCPeerConnection.prototype}function yi(){return"RTCPeerConnection"in window&&"getTransceivers"in window.RTCPeerConnection.prototype}function Pm(){return"RTCPeerConnection"in window&&"addTransceiver"in window.RTCPeerConnection.prototype}function Dm(){return"RTCRtpSender"in window&&"replaceTrack"in window.RTCRtpSender.prototype}function NT(){return"RTCRtpSender"in window&&"setParameters"in window.RTCRtpSender.prototype&&bl()}function kl(){return!!ve(navigator.mediaDevices)&&(ke.error(vi.NOT_SUPPORTED_MEDIA),!0)}function Tl(){return location.protocol==="http:"&&!Zi&&(ke.warn(ne({key:pk})),!0)}var Lm="RTCRtpSender"in window&&"createEncodedStreams"in window.RTCRtpSender.prototype&&nc()>=86;function Om(e){return!(e.type!=="candidate-pair"||!e.nominated||e.state!=="in-progress"&&e.state!=="succeeded")&&!(uo(e.selected)&&!e.selected)}var VT=new Map([[co,"Android"],[Qi,"iOS"],[Ck,"Windows"],[tc,"MacOS"],[Rk,"Linux"]]);function Mm(){var e="unknown";return VT.get(!0)&&(e=VT.get(!0)),e}function U6(){var e="";return screen.width&&(e+=(screen.width?screen.width*window.devicePixelRatio:"")+" * "+(screen.height?screen.height*window.devicePixelRatio:"")),e}function B6(){var e=!1;return(navigator.getUserMedia||navigator.mediaDevices&&navigator.mediaDevices.getUserMedia)&&(e=!0),e}function j6(){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 UT(){return!(bf&&nc()<86)&&!(Qi&&xr($i)&&$i<15)&&!(Pf&&Pf<63)&&!(!AT()||!("captureStream"in HTMLCanvasElement.prototype))}var yo=window.MediaStreamTrack&&"getSettings"in MediaStreamTrack.prototype,F6=window.MediaStreamTrack&&"getCapabilities"in MediaStreamTrack.prototype,G6=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(){Tl();var e=_o.getItem(RT);e&&e.ua===navigator.userAgent&&(gt=e.checkResult),Am()})();var tt={STREAM_ADDED:"stream-added",STREAM_REMOVED:"stream-removed",STREAM_UPDATED:"stream-updated",STREAM_PUBLISHED:"stream-published",STREAM_SUBSCRIBED:"stream-subscribed",STREAM_UNSUBSCRIBED:"stream-unsubscribed",STATE_CHANGED:"state-changed",ERROR:"error",CONNECTION_STATE_CHANGED:"connection-state-changed",SEI_MESSAGE:vb},ct={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:vb,ERROR:"error"},BT="player-state-changed",H6="screen-sharing-stopped",z6="connection-state-changed",W6="device-auto-recovered",Nm="error",gn="player-state-changed",J6=rk;Me({target:"String",proto:!0,forced:ik("small")},{small:function(){return J6(this,"small","","")}});var K6=function(){function e(o){J(this,e);var a=o.getUserId();this.log_=ke.createLogger({id:a,userId:a,sdkAppId:o.getSDKAppId()}),this.prevReportTime_=0,this.prevReport_={},this.prevEncoderImplementation_="",this.prevQualityLimitationReason_="",this.prevDecoderImplementationMap_=new Map}var t,n,r,i;return ye(e,[{key:"statInterval",get:function(){return this.prevReportTime_===0?2:(Date.now()-this.prevReportTime_)/1e3}},{key:"getSenderStats",value:(i=N(p().mark(function o(a){var s,c,u,d,h=this;return p().wrap(function(_){for(;;)switch(_.prev=_.next){case 0:if(s={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},c=a.getPeerConnection(),u=a.getSSRC(),!c){_.next=15;break}return _.prev=4,_.next=7,c.getStats();case 7:_.sent.forEach(function(y){if(y.type==="outbound-rtp")if(y.mediaType===xe){if(!Tr&&y.bytesSent===0)return;y.ssrc!==u.video||ve(y.encoderImplementation)||h.prevEncoderImplementation_===y.encoderImplementation||(h.log_.info("encoderImplementation change to ".concat(y.encoderImplementation)),h.prevEncoderImplementation_=y.encoderImplementation),y.ssrc!==u.video||ve(y.qualityLimitationReason)||h.prevQualityLimitationReason_===y.qualityLimitationReason||(h.log_.info("qualityLimitationReason change to ".concat(y.qualityLimitationReason)),h.prevQualityLimitationReason_=y.qualityLimitationReason);var b=xe;y.ssrc===u.small?b=Nr:y.ssrc===u.auxiliary&&(b=mt),s[b].bytesSent=y.bytesSent,s[b].packetsSent=y.packetsSent,s[b].framesEncoded=y.framesEncoded}else y.mediaType===Ce&&(s.audio.bytesSent=y.bytesSent,s.audio.packetsSent=y.packetsSent);else y.type==="candidate-pair"?Om(y)&&xr(y.currentRoundTripTime)&&(s.rtt=Math.floor(1e3*y.currentRoundTripTime)):y.type==="media-source"&&(y.kind===Ce?(s.audio.audioLevel=y.audioLevel||0,s.audio.totalAudioEnergy=y.totalAudioEnergy||0):y.kind===xe&&(y.trackIdentifier===a.getVideoTrackId(xe)?s.video.fpsCapture=y.framesPerSecond:y.trackIdentifier===a.getVideoTrackId(mt)?s.auxiliary.fpsCapture=y.framesPerSecond:s.small.fpsCapture=y.framesPerSecond));var f;ve(y.audioLevel)||(s.audio.audioLevel=y.audioLevel||0,s.audio.totalAudioEnergy=y.totalAudioEnergy||0),ve(y.frameWidth)||(y.trackIdentifier===a.getVideoTrackId(xe)||y.ssrc===u.video?f=xe:y.trackIdentifier===a.getVideoTrackId(mt)||y.ssrc===u.auxiliary?f=mt:y.trackIdentifier!==a.getVideoTrackId(Nr)&&y.ssrc!==u.small||(f=Nr),f&&(s[f].frameWidth=y.frameWidth,s[f].frameHeight=y.frameHeight,s[f].framesSent=y.framesSent))}),s.audio.audioLevel===0&&(s.audio.audioLevel=((d=a.getLocalStream())===null||d===void 0?void 0:d.getInternalAudioLevel())||0),_.next=15;break;case 12:_.prev=12,_.t0=_.catch(4),this.log_.warn("failed to getStats on sender connection "+_.t0);case 15:return _.abrupt("return",s);case 16:case"end":return _.stop()}},o,this,[[4,12]])})),function(o){return i.apply(this,arguments)})},{key:"getReceiverStats",value:(r=N(p().mark(function o(a){var s,c,u,d,h,_=this;return p().wrap(function(y){for(;;)switch(y.prev=y.next){case 0:if(s={tinyId:a.getTinyId(),userId:a.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}},!(c=a.getPeerConnection())){y.next=16;break}return y.prev=3,u=a.getSSRC(),d=a.getTrackState(),y.next=8,c.getStats();case 8:y.sent.forEach(function(b){if(b.type==="inbound-rtp"){if(b.mediaType===Ce&&b.ssrc===u.audio&&d.audio)s.audio.packetsReceived=b.packetsReceived,s.audio.bytesReceived=b.bytesReceived,s.audio.packetsLost=b.packetsLost,s.audio.jitter=b.jitter,s.hasAudio=!0;else if(b.mediaType===xe){if(Tr&&b.bytesReceived===0)return;b.ssrc===u.video&&d.video&&(s.video.packetsReceived=b.packetsReceived,s.video.bytesReceived=b.bytesReceived,s.video.packetsLost=b.packetsLost,s.video.framesReceived=b.framesReceived,s.video.framesDecoded=b.framesDecoded,s.video.fpsDecoded=b.framesPerSecond,s.hasVideo=!0,!b.decoderImplementation||_.prevDecoderImplementationMap_.has(s.userId)&&_.prevDecoderImplementationMap_.get(s.userId)===b.decoderImplementation||(_.log_.info("".concat(s.userId," decoderImplementation change to ").concat(b.decoderImplementation)),_.prevDecoderImplementationMap_.set(s.userId,b.decoderImplementation))),b.ssrc===u.auxiliary&&d.auxiliary&&(s.auxiliary.packetsReceived=b.packetsReceived,s.auxiliary.bytesReceived=b.bytesReceived,s.auxiliary.packetsLost=b.packetsLost,s.auxiliary.framesReceived=b.framesReceived,s.auxiliary.framesDecoded=b.framesDecoded,s.auxiliary.fpsDecoded=b.framesPerSecond,s.hasAuxiliary=!0)}}else b.type==="candidate-pair"&&Om(b)&&xr(b.currentRoundTripTime)&&(s.rtt=Math.floor(1e3*b.currentRoundTripTime));ve(b.frameWidth)||(b.trackIdentifier!==a.getMainStreamVideoTrackId()&&b.ssrc!==u.video||(s.video.frameWidth=b.frameWidth,s.video.frameHeight=b.frameHeight),b.trackIdentifier!==a.getAuxStreamVideoTrackId()&&b.ssrc!==u.auxiliary||(s.auxiliary.frameWidth=b.frameWidth,s.auxiliary.frameHeight=b.frameHeight)),ve(b.audioLevel)||(s.audio.audioLevel=b.audioLevel||0,s.audio.totalAudioEnergy=b.totalAudioEnergy||0)}),s.audio.audioLevel===0&&(s.audio.audioLevel=((h=a.getMainStream())===null||h===void 0?void 0:h.getInternalAudioLevel())||0),y.next=16;break;case 13:y.prev=13,y.t0=y.catch(3),this.log_.warn("failed to getStats on receiver connection "+y.t0);case 16:return y.abrupt("return",s);case 17:case"end":return y.stop()}},o,this,[[3,13]])})),function(o){return r.apply(this,arguments)})},{key:"getStats",value:(n=N(p().mark(function o(a,s){var c,u,d,h,_,y,b;return p().wrap(function(f){for(;;)switch(f.prev=f.next){case 0:if(c={},!a){f.next=5;break}return f.next=4,this.getSenderStats(a);case 4:c=f.sent;case 5:u=[],d=ie(s),f.prev=7,d.s();case 9:if((h=d.n()).done){f.next=17;break}return(_=Te(h.value,2))[0],y=_[1],f.next=13,this.getReceiverStats(y);case 13:b=f.sent,u.push(b);case 15:f.next=9;break;case 17:f.next=22;break;case 19:f.prev=19,f.t0=f.catch(7),d.e(f.t0);case 22:return f.prev=22,d.f(),f.finish(22);case 25:return f.abrupt("return",{senderStats:c,receiverStats:u});case 26:case"end":return f.stop()}},o,this,[[7,19,22,25]])})),function(o,a){return n.apply(this,arguments)})},{key:"getDifferenceValue",value:function(o,a){if(aa(o))return a;var s=a-o;return s<0?0:s}},{key:"prepareReport",value:function(o){var a=this,s=o.stats,c=o.report,u=o.freezeMap;if(!aa(s.senderStats)){var d;d={uint32_audio_level:1e8*s.senderStats.audio.audioLevel,uint32_audio_energy:1e6*s.senderStats.audio.totalAudioEnergy,uint32_audio_codec_bitrate:s.senderStats.audio.bytesSent,audioLevel:s.senderStats.audio.audioLevel};var h=[],_={uint32_video_stream_type:2,uint32_video_codec_fps:s.senderStats.video.framesSent,uint32_video_capture_fps:s.senderStats.video.fpsCapture,uint32_video_width:s.senderStats.video.frameWidth,uint32_video_height:s.senderStats.video.frameHeight,uint32_video_codec_bitrate:s.senderStats.video.bytesSent,uint32_video_enc_fps:s.senderStats.video.framesEncoded};if(h.push(_),s.senderStats.small.bytesSent){var y={uint32_video_stream_type:3,uint32_video_codec_fps:s.senderStats.small.framesSent||0,uint32_video_capture_fps:s.senderStats.small.fpsCapture||0,uint32_video_width:s.senderStats.small.frameWidth||0,uint32_video_height:s.senderStats.small.frameHeight||0,uint32_video_codec_bitrate:s.senderStats.small.bytesSent,uint32_video_enc_fps:s.senderStats.small.framesEncoded||0};h.push(y)}if(s.senderStats.auxiliary.bytesSent){var b={uint32_video_stream_type:7,uint32_video_codec_fps:s.senderStats.auxiliary.framesSent||0,uint32_video_capture_fps:s.senderStats.auxiliary.fpsCapture||0,uint32_video_width:s.senderStats.auxiliary.frameWidth||0,uint32_video_height:s.senderStats.auxiliary.frameHeight||0,uint32_video_codec_bitrate:s.senderStats.auxiliary.bytesSent,uint32_video_enc_fps:s.senderStats.auxiliary.framesEncoded||0};h.push(b)}var f={uint32_bitrate:0,uint32_rtt:s.senderStats.rtt};c.msg_up_stream_info={msg_audio_status:d,msg_video_status:h,msg_network_status:f}}var g=this.statInterval;c.msg_down_stream_info=[],s.receiverStats.forEach(function(k){var P={};if(P.msg_user_info={str_identifier:k.userId,uint64_tinyid:k.tinyId},P.msg_network_status={uint32_rtt:k.rtt},P.msg_video_status={},k.hasAudio){var A={uint32_audio_codec_bitrate:k.audio.bytesReceived,uint32_audio_total_bitrate:k.audio.bytesReceived,uint32_audio_level:1e8*k.audio.audioLevel,uint32_audio_energy:1e6*k.audio.totalAudioEnergy,uint32_audio_receive:k.audio.packetsReceived,uint32_audio_origin_lost:k.audio.packetsLost,audioLevel:k.audio.audioLevel};P.msg_audio_status=A}if(P.msg_video_status=[],k.hasVideo){var U=u.get(k.userId+"_"+_t),T=U?U.duration:0,v={uint32_video_stream_type:2,uint32_video_receive_fps:k.video.framesReceived,uint32_video_width:k.video.frameWidth,uint32_video_height:k.video.frameHeight,uint32_video_codec_bitrate:k.video.bytesReceived,uint32_video_receive:k.video.packetsReceived,uint32_video_origin_lost:k.video.packetsLost,uint32_video_block_time:T,uint32_video_dec_fps:k.video.framesDecoded};P.msg_video_status.push(v)}if(k.hasAuxiliary){var E=u.get(k.userId+"_"+Dt),C=E?E.duration:0,O={uint32_video_stream_type:7,uint32_video_receive_fps:k.auxiliary.framesReceived,uint32_video_width:k.auxiliary.frameWidth,uint32_video_height:k.auxiliary.frameHeight,uint32_video_codec_bitrate:k.auxiliary.bytesReceived,uint32_video_receive:k.auxiliary.packetsReceived+k.auxiliary.packetsLost,uint32_video_origin_lost:k.auxiliary.packetsLost,uint32_video_block_time:C,uint32_video_dec_fps:k.auxiliary.framesDecoded};P.msg_video_status.push(O)}c.msg_down_stream_info.push(P)});var I=this.prevReport_;if(this.prevReport_=JSON.parse(JSON.stringify(c)),c.msg_up_stream_info.msg_audio_status&&I.msg_up_stream_info.msg_audio_status){var w=I.msg_up_stream_info.msg_audio_status,j=c.msg_up_stream_info.msg_audio_status,z=this.getDifferenceValue(w.uint32_audio_codec_bitrate,j.uint32_audio_codec_bitrate);j.uint32_audio_codec_bitrate=Math.round(8*z/g),c.msg_up_stream_info.msg_network_status.uint32_bitrate+=j.uint32_audio_codec_bitrate}var $=I.msg_up_stream_info.msg_video_status;c.msg_up_stream_info.msg_video_status.forEach(function(k){var P=$.find(function(E){return E.uint32_video_stream_type===k.uint32_video_stream_type});if(!P||P.uint32_video_codec_bitrate===0)return k.uint32_video_codec_bitrate=0,k.uint32_video_enc_fps=0,void(k.uint32_video_codec_fps=0);var A=P.uint32_video_codec_bitrate,U=P.uint32_video_enc_fps,T=P.uint32_video_codec_fps,v=a.getDifferenceValue(A,k.uint32_video_codec_bitrate);k.uint32_video_codec_bitrate=Math.round(8*v/g),c.msg_up_stream_info.msg_network_status.uint32_bitrate+=k.uint32_video_codec_bitrate,k.uint32_video_enc_fps=Math.round(a.getDifferenceValue(U,k.uint32_video_enc_fps)/g),k.uint32_video_codec_fps=Math.round(a.getDifferenceValue(T,k.uint32_video_codec_fps)/g)});var ue=c.msg_down_stream_info,L=I.msg_down_stream_info;return ue.forEach(function(k){var P=L.find(function(C){return C.msg_user_info.uint64_tinyid===k.msg_user_info.uint64_tinyid});if(P){if(k.msg_audio_status&&P.msg_audio_status){var A=k.msg_audio_status,U=P.msg_audio_status;A.uint32_audio_origin_lost=a.getDifferenceValue(U.uint32_audio_origin_lost,A.uint32_audio_origin_lost),A.uint32_audio_receive=a.getDifferenceValue(U.uint32_audio_receive,A.uint32_audio_receive),A.uint32_audio_receive+=A.uint32_audio_origin_lost;var T=a.getDifferenceValue(U.uint32_audio_codec_bitrate,A.uint32_audio_codec_bitrate);A.uint32_audio_codec_bitrate=Math.round(8*T/g),A.uint32_audio_total_bitrate=Math.round(8*T/g)}if(k.msg_video_status&&P.msg_video_status){var v=k.msg_video_status,E=P.msg_video_status;v.forEach(function(C){var O=E.find(function(Ge){return Ge.uint32_video_stream_type===C.uint32_video_stream_type});if(!O)return C.uint32_video_receive=0,C.uint32_video_origin_lost=0,C.uint32_video_codec_bitrate=0,C.uint32_video_receive_fps=0,void(C.uint32_video_dec_fps=0);var F=O.uint32_video_receive,K=O.uint32_video_origin_lost,re=O.uint32_video_codec_bitrate,ce=O.uint32_video_receive_fps,ge=O.uint32_video_dec_fps;C.uint32_video_origin_lost=a.getDifferenceValue(K,C.uint32_video_origin_lost),C.uint32_video_receive=a.getDifferenceValue(F,C.uint32_video_receive)+C.uint32_video_origin_lost;var Ye=a.getDifferenceValue(re,C.uint32_video_codec_bitrate);C.uint32_video_codec_bitrate=Math.round(8*Ye/g);var Ve=a.getDifferenceValue(ce,C.uint32_video_receive_fps);C.uint32_video_receive_fps=Math.round(Ve/g),C.uint32_video_dec_fps=Math.round(a.getDifferenceValue(ge,C.uint32_video_dec_fps)/g)})}}}),c}},{key:"getStatsReport",value:(t=N(p().mark(function o(a){var s,c,u,d,h;return p().wrap(function(_){for(;;)switch(_.prev=_.next){case 0:return s=a.uplinkConnection,c=a.downlinkConnections,u=a.freezeMap,d={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}}]},_.next=4,this.getStats(s,c);case 4:return h=_.sent,JSON.stringify(this.prevReport_)==="{}"&&(this.prevReport_=JSON.parse(JSON.stringify(d))),this.prepareReport({stats:h,report:d,freezeMap:u,uplinkConnection:s,downlinkConnections:c}),this.prevReportTime_=Date.now(),_.abrupt("return",d);case 9:case"end":return _.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}(),q6=function(){function e(r){var i=r.signalChannel,o=r.connections,a=r.client;J(this,e),this.client_=a,this.signalChannel_=i,this.connections_=o,this.client_=a,this.log_=ke.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 _i,this.initialize()}var t,n;return ye(e,[{key:"uplinkNetworkQuality",get:function(){return this.uplinkNetworkQuality_},set:function(r){r!==this.uplinkNetworkQuality_&&this.log_.info("uplink network quality change ".concat(this.uplinkNetworkQuality," -> ").concat(r,", rtt: ").concat(this.uplinkRTT_,", loss: ").concat(this.uplinkLoss_)),this.uplinkNetworkQuality_=r}},{key:"downlinkNetworkQuality",get:function(){return this.downlinkNetworkQuality_},set:function(r){if(r!==this.downlinkNetworkQuality_){var i=this.getAverageLossAndRTT(be(this.downlinkLossAndRTTMap_.values())),o=i.rtt,a=i.loss;this.log_.info("downlink network quality change ".concat(this.downlinkNetworkQuality," -> ").concat(r,", rtt: ").concat(o,", loss: ").concat(a))}this.downlinkNetworkQuality_=r}},{key:"initialize",value:function(){var r=this;this.signalChannel_.on(vt.UPLINK_NETWORK_STATS,function(i){r.handleUplinkNetworkQuality(i)}),this.signalChannel_.on(mm,this.handleSignalConnectionStateChange.bind(this)),this.start()}},{key:"handleUplinkNetworkQuality",value:function(r){if(!this.uplinkConnection_)return this.uplinkNetworkQuality=0,this.uplinkLoss_=0,void(this.uplinkRTT_=0);var i=this.uplinkConnection_.getPeerConnection();if(i&&this.isPeerConnectionDisconnected(i))return this.uplinkNetworkQuality=6,this.uplinkLoss_=0,void(this.uplinkRTT_=0);if(r.data.code===0){var o=r.data.data,a=o.expectAudPkg+o.expectVidPkg,s=o.recvAudPkg+o.recvVidPkg,c=a-s,u=o.delay;if(u&&this.updateDelay(u),a===0&&s===0)return;this.uplinkLoss_=c<=0?0:Math.round(c/a*100),this.uplinkRTT_=o.rtt,this.uplinkNetworkQuality=this.getNetworkQuality(this.uplinkLoss_,this.uplinkRTT_)}}},{key:"handleDownlinkNetworkQuality",value:(n=N(p().mark(function r(){var i,o,a,s,c,u,d,h,_,y,b,f,g,I,w,j=this;return p().wrap(function(z){for(;;)switch(z.prev=z.next){case 0:if(this.connections_&&this.connections_.size!==0){z.next=3;break}return this.downlinkNetworkQuality=0,z.abrupt("return");case 3:if(i=be(this.connections_.values()),o=i.filter(function($){return $.getPeerConnection()&&$.getPeerConnection().connectionState===Tb}),i.filter(function($){return $.getPeerConnection()&&j.isPeerConnectionDisconnected($.getPeerConnection())}).length!==i.length){z.next=9;break}return this.downlinkNetworkQuality=6,z.abrupt("return");case 9:a=0;case 10:if(!(a<o.length)){z.next=31;break}return s=o[a].getPeerConnection(),z.next=14,this.getStat(s);case 14:if(c=z.sent,u=c.rtt,d=c.totalPacketsLost,h=c.totalPacketsReceived,this.downlinkPrevStatMap_.has(s)){z.next=21;break}return this.downlinkPrevStatMap_.set(s,{totalPacketsLost:d,totalPacketsReceived:h}),z.abrupt("continue",28);case 21:_=0,y=this.downlinkPrevStatMap_.get(s),b=d-y.totalPacketsLost,f=h-y.totalPacketsReceived,_=b<=0||f<0?0:Math.round(b/(b+f)*100),this.downlinkPrevStatMap_.set(s,{totalPacketsLost:d,totalPacketsReceived:h}),this.downlinkLossAndRTTMap_.set(s,{rtt:u,loss:_,userId:o[a].getUserId()});case 28:a++,z.next=10;break;case 31:if(be(this.downlinkPrevStatMap_.keys()).forEach(function($){j.isPeerConnectionDisconnected($)&&(j.downlinkPrevStatMap_.delete($),j.downlinkLossAndRTTMap_.delete($))}),this.downlinkLossAndRTTMap_.size!==0){z.next=34;break}return z.abrupt("return");case 34:g=this.getAverageLossAndRTT(be(this.downlinkLossAndRTTMap_.values())),I=g.rtt,w=g.loss,this.downlinkRTT_=I,this.downlinkLoss_=w,this.downlinkNetworkQuality=this.getNetworkQuality(w,I);case 38:case"end":return z.stop()}},r,this)})),function(){return n.apply(this,arguments)})},{key:"getStat",value:(t=N(p().mark(function r(i){var o,a,s,c;return p().wrap(function(u){for(;;)switch(u.prev=u.next){case 0:if(o={rtt:0,totalPacketsLost:0,totalPacketsReceived:0},i&&MT()){u.next=3;break}return u.abrupt("return",o);case 3:a=i.getReceivers(),u.prev=4,s=0;case 6:if(!(s<a.length)){u.next=15;break}return c=a[s],u.next=10,c.getStats();case 10:u.sent.forEach(function(d){d.type==="candidate-pair"&&xr(d.currentRoundTripTime)&&(o.rtt=Math.round(1e3*d.currentRoundTripTime)),d.type!=="inbound-rtp"||d.mediaType!==Ce&&d.mediaType!==xe||(o.totalPacketsLost+=d.packetsLost,o.totalPacketsReceived+=d.packetsReceived)});case 12:s++,u.next=6;break;case 15:return u.abrupt("return",o);case 18:return u.prev=18,u.t0=u.catch(4),u.abrupt("return",o);case 21:case"end":return u.stop()}},r,null,[[4,18]])})),function(r){return t.apply(this,arguments)})},{key:"getAverageLossAndRTT",value:function(r){var i={rtt:0,loss:0};return Array.isArray(r)&&r.length>0&&(r.forEach(function(o){i.rtt+=o.rtt,i.loss+=o.loss}),Object.keys(i).forEach(function(o){i[o]=Math.round(i[o]/r.length)})),i}},{key:"getNetworkQuality",value:function(r,i){return r>50||i>500?5:r>30||i>350?4:r>20||i>200?3:r>10||i>100?2:r>=0||i>=0?1:0}},{key:"handleSignalConnectionStateChange",value:function(r){r.state===Sl?(this.uplinkRTT_=0,this.uplinkLoss_=0,this.uplinkNetworkQuality=6):r.state===cc&&this.uplinkNetworkQuality===6&&(this.uplinkNetworkQuality=5)}},{key:"handleUplinkConnectionStateChange",value:function(r){var i=r.state;i===sn?(this.uplinkLoss_=0,this.uplinkRTT_=0,this.uplinkNetworkQuality=6):i===mn&&this.uplinkNetworkQuality===6&&(this.uplinkNetworkQuality=5)}},{key:"isPeerConnectionDisconnected",value:function(r){return!(!r||r.connectionState!==XN&&r.connectionState!==kb&&r.connectionState!==Yp)}},{key:"setUplinkConnection",value:function(r){this.uplinkConnection_=r,this.uplinkConnection_?this.uplinkConnection_.on(tt.CONNECTION_STATE_CHANGED,this.handleUplinkConnectionStateChange.bind(this)):(this.uplinkNetworkQuality=0,this.uplinkRTT_=0,this.uplinkLoss_=0)}},{key:"start",value:function(){var r=this;this.interval_===-1?(this.log_.info("start network quality calculating"),this.interval_=yt.run(so,function(){r.handleDownlinkNetworkQuality(),q.emit(um,{client:r.client_,uplinkNetworkQuality:r.uplinkNetworkQuality,downlinkNetworkQuality:r.downlinkNetworkQuality,uplinkRTT:r.uplinkRTT_,uplinkLoss:r.uplinkLoss_,downlinkRTT:r.downlinkRTT_,downlinkLoss:r.downlinkLoss_,downlinkLossAndRTTMap:r.downlinkLossAndRTTMap_}),r.emitter_.emit(ct.NETWORK_QUALITY,{uplinkNetworkQuality:r.uplinkNetworkQuality,downlinkNetworkQuality:r.downlinkNetworkQuality,uplinkRTT:r.uplinkRTT_,uplinkLoss:r.uplinkLoss_,downlinkRTT:r.downlinkRTT_,downlinkLoss:r.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&&(yt.clearTask(this.interval_),this.interval_=-1),this.downlinkLossAndRTTMap_.clear(),this.downlinkPrevStatMap_.clear()}},{key:"on",value:function(r,i){this.emitter_.on(r,i)}},{key:"updateDelay",value:function(r){var i=this;r.forEach(function(o){var a=o.srcTinyId,s=o.videoDelay,c=o.audioDelay,u=i.connections_.get(a);u&&u.setDelay({videoDelay:s,audioDelay:c})})}}]),e}(),X6=function(){function e(r){J(this,e),this.log_=ke.createLogger({id:r.client.getUserId(),userId:r.client.getUserId(),sdkAppId:r.client.getSDKAppId()}),this.localStream_=null,this.prevDevices_=[],this.initialize()}var t,n;return ye(e,[{key:"initialize",value:function(){navigator.mediaDevices&&(this.onDeviceChange=this.onDeviceChange.bind(this),navigator.mediaDevices.addEventListener("devicechange",this.onDeviceChange))}},{key:"destroy",value:function(){navigator.mediaDevices&&navigator.mediaDevices.removeEventListener("devicechange",this.onDeviceChange)}},{key:"onDeviceChange",value:(n=N(p().mark(function r(){var i,o,a,s=this;return p().wrap(function(c){for(;;)switch(c.prev=c.next){case 0:if(this.localStream_&&this.localStream_.getMediaStream()&&!this.localStream_.getScreen()){c.next=2;break}return c.abrupt("return");case 2:return c.next=4,Um();case 4:i=c.sent,o=i.filter(function(u){return s.prevDevices_.findIndex(function(d){var h=d.deviceId;return u.deviceId===h})<0}),a=this.prevDevices_.filter(function(u){return i.findIndex(function(d){var h=d.deviceId;return u.deviceId===h})<0}),o.length>0&&this.handleDeviceAdded(this.prevDevices_,o),a.length>0&&this.handleDeviceRemoved(i,a),this.prevDevices_=i;case 10:case"end":return c.stop()}},r,this)})),function(){return n.apply(this,arguments)})},{key:"setLocalStream",value:(t=N(p().mark(function r(i){return p().wrap(function(o){for(;;)switch(o.prev=o.next){case 0:if(!i){o.next=4;break}return o.next=3,Um();case 3:this.prevDevices_=o.sent;case 4:this.localStream_=i;case 5:case"end":return o.stop()}},r,this)})),function(r){return t.apply(this,arguments)})},{key:"handleDeviceAdded",value:function(r,i){var o,a;if(this.localStream_){this.log_.warn("devicesAdded: ".concat(JSON.stringify(i))),this.localStream_.updateDeviceIdInUse();var s=i.filter(function(y){return y.kind===Xu}),c=i.filter(function(y){return y.kind===qs}),u=r.filter(function(y){return y.kind===Xu}),d=r.filter(function(y){return y.kind===qs}),h=s.length>0&&u.length===0&&((o=this.localStream_.getVideoTrack())===null||o===void 0?void 0:o.readyState)!=="live",_=c.length>0&&d.length===0&&((a=this.localStream_.getAudioTrack())===null||a===void 0?void 0:a.readyState)!=="live";if(_&&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:s[0].deviceId,microphoneId:c[0].deviceId});h&&(this.log_.info("new camera detected, but there was no camera before."),this.localStream_.recoverCapture({audio:!1,video:!0,cameraId:s[0].deviceId})),_&&(this.log_.info("new microphone detected, but there was no microphone before."),this.localStream_.recoverCapture({audio:!0,video:!1,microphoneId:c[0].deviceId}))}}},{key:"handleDeviceRemoved",value:function(r,i){if(this.localStream_){this.log_.warn("devicesRemoved: ".concat(JSON.stringify(i))),this.localStream_.updateDeviceIdInUse();var o=!1,a=!1,s=this.localStream_.getCameraId(),c=this.localStream_.getMicrophoneId();if(c===tl){var u=this.localStream_.getMicrophoneGroupId(),d=r.filter(function(h){return h.deviceId===tl&&h.kind===qs})[0];d&&d.groupId!==u&&(a=!0)}if(i.forEach(function(h){var _=h.deviceId;s.length>0&&_===s?o=!0:c.length>0&&_===c&&(a=!0)}),o&&a)return this.log_.warn("current camera and microphone in use is lost, cameraId: ".concat(s,", microphoneId: ").concat(c)),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(s)),this.localStream_.getVideo()&&this.localStream_.recoverCapture({video:!0,audio:!1})),a&&(this.log_.warn("current microphone in use is lost, deviceId: ".concat(c)),this.localStream_.getAudio()&&this.localStream_.recoverCapture({video:!1,audio:!0}))}}}]),e}();function Vm(){return Vm=N(p().mark(function e(){var t;return p().wrap(function(n){for(;;)switch(n.prev=n.next){case 0:if(!Tl()&&!kl()){n.next=2;break}return n.abrupt("return",[]);case 2:return n.next=4,xl();case 4:return t=n.sent,n.abrupt("return",t.filter(function(r){return r.kind===Xu}).map(function(r,i){var o=r.label;r.label||(o="camera_"+i);var a={label:o,deviceId:r.deviceId,kind:r.kind};return r.groupId&&(a.groupId=r.groupId),r.getCapabilities&&(a.getCapabilities=function(){return r.getCapabilities()}),a}));case 6:case"end":return n.stop()}},e)})),Vm.apply(this,arguments)}var jT=new Set;function xl(){return FT.apply(this,arguments)}function FT(){return(FT=N(p().mark(function e(){var t;return p().wrap(function(n){for(;;)switch(n.prev=n.next){case 0:if(!Tl()&&!kl()){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(r){jT.add("".concat(r.deviceId,"_").concat(r.kind))}),n.abrupt("return",t);case 7:case"end":return n.stop()}},e)}))).apply(this,arguments)}function Um(){return Bm.apply(this,arguments)}function Bm(){return Bm=N(p().mark(function e(){var t;return p().wrap(function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,xl();case 2:return t=n.sent,n.abrupt("return",t.filter(function(r){return r.kind!==qs||r.deviceId!=Zb}).map(function(r,i){var o=r.label;r.label||(o=r.kind+"_"+i);var a={label:o,deviceId:r.deviceId,kind:r.kind};return r.groupId&&(a.groupId=r.groupId),r.getCapabilities&&(a.getCapabilities=function(){return r.getCapabilities()}),a}));case 4:case"end":return n.stop()}},e)})),Bm.apply(this,arguments)}function GT(){return jm.apply(this,arguments)}function jm(){return jm=N(p().mark(function e(){var t;return p().wrap(function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,xl();case 2:return t=n.sent,n.abrupt("return",t.filter(function(r){return r.kind===qs&&r.deviceId!==Zb}).map(function(r,i){var o=r.label;r.label||(o="microphone_"+i);var a={label:o,deviceId:r.deviceId,kind:r.kind};return r.groupId&&(a.groupId=r.groupId),r.getCapabilities&&(a.getCapabilities=function(){return r.getCapabilities()}),a}));case 4:case"end":return n.stop()}},e)})),jm.apply(this,arguments)}function Fm(){return Fm=N(p().mark(function e(){var t;return p().wrap(function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,xl();case 2:return t=n.sent,n.abrupt("return",t.filter(function(r){return r.kind==="audiooutput"}).map(function(r,i){var o=r.label;r.label||(o="speaker_"+i);var a={label:o,deviceId:r.deviceId,kind:r.kind};return r.groupId&&(a.groupId=r.groupId),a}));case 4:case"end":return n.stop()}},e)})),Fm.apply(this,arguments)}function Q6(e){var t;if(e instanceof CanvasCaptureMediaStreamTrack||!(e instanceof MediaStreamTrack))return!1;var n=e.label.toLocaleLowerCase();if(n.includes("camera")||n.includes("webcam"))return!0;var r="".concat((t=e.getSettings())===null||t===void 0?void 0:t.deviceId,"_").concat(Xu);return!!jT.has(r)}function Y6(e,t){return HT.apply(this,arguments)}function HT(){return(HT=N(p().mark(function e(t,n){var r,i;return p().wrap(function(o){for(;;)switch(o.prev=o.next){case 0:return o.next=2,GT();case 2:if(r=o.sent,((i=r.find(function(a){return a.deviceId===tl}))==null?void 0:i.groupId)!==t||i.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 jn,zT=Mi.exports,$6=At,Z6=It,e5=ty,t5=Mr,n5=Qe,r5=Bt,i5=function(e,t,n,r){try{return r?t(Z6(n)[0],n[1]):t(n)}catch(i){e5(e,"throw",i)}},a5=Th,o5=wu,s5=rn,WT=Cs,c5=bu,u5=Rs,JT=Array,KT=function(e){var t=r5(e),n=o5(this),r=arguments.length,i=r>1?arguments[1]:void 0,o=i!==void 0;o&&(i=t5(i,r>2?arguments[2]:void 0));var a,s,c,u,d,h,_=u5(t),y=0;if(!_||this===JT&&a5(_))for(a=s5(t),s=n?new this(a):JT(a);a>y;y++)h=o?i(t[y],y):t[y],WT(s,y,h);else for(d=(u=c5(t,_)).next,s=n?new this:[];!(c=n5(d,u)).done;y++)h=o?i5(u,i,[c.value,y],!0):c.value,WT(s,y,h);return s.length=y,s},sa=pe,Gm=2147483647,l5=/[^\0-\u007E]/,qT=/[.\u3002\uFF0E\uFF61]/g,XT="Overflow: input needs wider integers to process",QT=RangeError,d5=sa(qT.exec),So=Math.floor,Hm=String.fromCharCode,YT=sa("".charCodeAt),$T=sa([].join),Si=sa([].push),h5=sa("".replace),p5=sa("".split),f5=sa("".toLowerCase),ZT=function(e){return e+22+75*(e<26)},m5=function(e,t,n){var r=0;for(e=n?So(e/700):e>>1,e+=So(e/t);e>455;)e=So(e/35),r+=36;return So(r+36*e/(e+38))},v5=function(e){var t=[];e=function(I){for(var w=[],j=0,z=I.length;j<z;){var $=YT(I,j++);if($>=55296&&$<=56319&&j<z){var ue=YT(I,j++);(64512&ue)==56320?Si(w,((1023&$)<<10)+(1023&ue)+65536):(Si(w,$),j--)}else Si(w,$)}return w}(e);var n,r,i=e.length,o=128,a=0,s=72;for(n=0;n<e.length;n++)(r=e[n])<128&&Si(t,Hm(r));var c=t.length,u=c;for(c&&Si(t,"-");u<i;){var d=Gm;for(n=0;n<e.length;n++)(r=e[n])>=o&&r<d&&(d=r);var h=u+1;if(d-o>So((Gm-a)/h))throw QT(XT);for(a+=(d-o)*h,o=d,n=0;n<e.length;n++){if((r=e[n])<o&&++a>Gm)throw QT(XT);if(r==o){for(var _=a,y=36;;){var b=y<=s?1:y>=s+26?26:y-s;if(_<b)break;var f=_-b,g=36-b;Si(t,Hm(ZT(b+f%g))),_=So(f/g),y+=36}Si(t,Hm(ZT(_))),s=m5(a,h,u==c),a=0,u++}}a++,o++}return $T(t,"")},g5=Me,zm=_e,_5=x0,Wm=te,e1=Mr,Fn=pe,Il=Qt,Gn=function(e,t,n){return n.get&&zT(n.get,t,{getter:!0}),n.set&&zT(n.set,t,{setter:!0}),$6.f(e,t,n)},y5=oi,Jm=xt,Km=eT,bo=KT,tr=yu,S5=Rh.codeAt,b5=function(e){var t,n,r=[],i=p5(h5(f5(e),qT,"."),".");for(t=0;t<i.length;t++)n=i[t],Si(r,d5(l5,n)?"xn--"+v5(n):n);return $T(r,".")},Gr=Wt,k5=Bi,T5=Iu,t1=EL,n1=Xe,x5=n1.set,wl=n1.getterFor("URL"),I5=t1.URLSearchParams,w5=t1.getState,hc=Wm.URL,qm=Wm.TypeError,El=Wm.parseInt,E5=Math.floor,r1=Math.pow,Hn=Fn("".charAt),nr=Fn(/./.exec),pc=Fn([].join),C5=Fn(1 .toString),R5=Fn([].pop),ko=Fn([].push),i1=Fn("".replace),A5=Fn([].shift),P5=Fn("".split),fc=Fn("".slice),Cl=Fn("".toLowerCase),D5=Fn([].unshift),Xm="Invalid scheme",ca="Invalid host",a1="Invalid port",o1=/[a-z]/i,L5=/[\d+-.a-z]/i,Qm=/\d/,O5=/^0x/i,M5=/^[0-7]+$/,N5=/^\d+$/,s1=/^[\da-f]+$/i,V5=/[\0\t\n\r #%/:<>?@[\\\]^|]/,U5=/[\0\t\n\r #/:<>?@[\\\]^|]/,B5=/^[\u0000-\u0020]+|[\u0000-\u0020]+$/g,j5=/[\t\n\r]/g,mc=function(e){var t,n,r,i;if(typeof e=="number"){for(t=[],n=0;n<4;n++)D5(t,e%256),e=E5(e/256);return pc(t,".")}if(typeof e=="object"){for(t="",r=function(o){for(var a=null,s=1,c=null,u=0,d=0;d<8;d++)o[d]!==0?(u>s&&(a=c,s=u),c=null,u=0):(c===null&&(c=d),++u);return u>s&&(a=c,s=u),a}(e),n=0;n<8;n++)i&&e[n]===0||(i&&(i=!1),r===n?(t+=n?":":"::",i=!0):(t+=C5(e[n],16),n<7&&(t+=":")));return"["+t+"]"}return e},Rl={},c1=Km({},Rl,{" ":1,'"':1,"<":1,">":1,"`":1}),u1=Km({},c1,{"#":1,"?":1,"{":1,"}":1}),Ym=Km({},u1,{"/":1,":":1,";":1,"=":1,"@":1,"[":1,"\\":1,"]":1,"^":1,"|":1}),bi=function(e,t){var n=S5(e,0);return n>32&&n<127&&!Jm(t,e)?e:encodeURIComponent(e)},Al={ftp:21,file:null,http:80,https:443,ws:80,wss:443},vc=function(e,t){var n;return e.length==2&&nr(o1,Hn(e,0))&&((n=Hn(e,1))==":"||!t&&n=="|")},l1=function(e){var t;return e.length>1&&vc(fc(e,0,2))&&(e.length==2||(t=Hn(e,2))==="/"||t==="\\"||t==="?"||t==="#")},F5=function(e){return e==="."||Cl(e)==="%2e"},$m={},d1={},Zm={},h1={},p1={},ev={},f1={},m1={},Pl={},Dl={},tv={},nv={},rv={},iv={},v1={},av={},To={},Ir={},g1={},ua={},Hr={},ov=function(e,t,n){var r,i,o,a=Gr(e);if(t){if(i=this.parse(a))throw qm(i);this.searchParams=null}else{if(n!==void 0&&(r=new ov(n,!0)),i=this.parse(a,null,r))throw qm(i);(o=w5(new I5)).bindURL(this),this.searchParams=o}};ov.prototype={type:"URL",parse:function(e,t,n){var r,i,o,a,s,c=this,u=t||$m,d=0,h="",_=!1,y=!1,b=!1;for(e=Gr(e),t||(c.scheme="",c.username="",c.password="",c.host=null,c.port=null,c.path=[],c.query=null,c.fragment=null,c.cannotBeABaseURL=!1,e=i1(e,B5,"")),e=i1(e,j5,""),r=bo(e);d<=r.length;){switch(i=r[d],u){case $m:if(!i||!nr(o1,i)){if(t)return Xm;u=Zm;continue}h+=Cl(i),u=d1;break;case d1:if(i&&(nr(L5,i)||i=="+"||i=="-"||i=="."))h+=Cl(i);else{if(i!=":"){if(t)return Xm;h="",u=Zm,d=0;continue}if(t&&(c.isSpecial()!=Jm(Al,h)||h=="file"&&(c.includesCredentials()||c.port!==null)||c.scheme=="file"&&!c.host))return;if(c.scheme=h,t)return void(c.isSpecial()&&Al[c.scheme]==c.port&&(c.port=null));h="",c.scheme=="file"?u=iv:c.isSpecial()&&n&&n.scheme==c.scheme?u=h1:c.isSpecial()?u=m1:r[d+1]=="/"?(u=p1,d++):(c.cannotBeABaseURL=!0,ko(c.path,""),u=g1)}break;case Zm:if(!n||n.cannotBeABaseURL&&i!="#")return Xm;if(n.cannotBeABaseURL&&i=="#"){c.scheme=n.scheme,c.path=tr(n.path),c.query=n.query,c.fragment="",c.cannotBeABaseURL=!0,u=Hr;break}u=n.scheme=="file"?iv:ev;continue;case h1:if(i!="/"||r[d+1]!="/"){u=ev;continue}u=Pl,d++;break;case p1:if(i=="/"){u=Dl;break}u=Ir;continue;case ev:if(c.scheme=n.scheme,i==jn)c.username=n.username,c.password=n.password,c.host=n.host,c.port=n.port,c.path=tr(n.path),c.query=n.query;else if(i=="/"||i=="\\"&&c.isSpecial())u=f1;else if(i=="?")c.username=n.username,c.password=n.password,c.host=n.host,c.port=n.port,c.path=tr(n.path),c.query="",u=ua;else{if(i!="#"){c.username=n.username,c.password=n.password,c.host=n.host,c.port=n.port,c.path=tr(n.path),c.path.length--,u=Ir;continue}c.username=n.username,c.password=n.password,c.host=n.host,c.port=n.port,c.path=tr(n.path),c.query=n.query,c.fragment="",u=Hr}break;case f1:if(!c.isSpecial()||i!="/"&&i!="\\"){if(i!="/"){c.username=n.username,c.password=n.password,c.host=n.host,c.port=n.port,u=Ir;continue}u=Dl}else u=Pl;break;case m1:if(u=Pl,i!="/"||Hn(h,d+1)!="/")continue;d++;break;case Pl:if(i!="/"&&i!="\\"){u=Dl;continue}break;case Dl:if(i=="@"){_&&(h="%40"+h),_=!0,o=bo(h);for(var f=0;f<o.length;f++){var g=o[f];if(g!=":"||b){var I=bi(g,Ym);b?c.password+=I:c.username+=I}else b=!0}h=""}else if(i==jn||i=="/"||i=="?"||i=="#"||i=="\\"&&c.isSpecial()){if(_&&h=="")return"Invalid authority";d-=bo(h).length+1,h="",u=tv}else h+=i;break;case tv:case nv:if(t&&c.scheme=="file"){u=av;continue}if(i!=":"||y){if(i==jn||i=="/"||i=="?"||i=="#"||i=="\\"&&c.isSpecial()){if(c.isSpecial()&&h=="")return ca;if(t&&h==""&&(c.includesCredentials()||c.port!==null))return;if(a=c.parseHost(h))return a;if(h="",u=To,t)return;continue}i=="["?y=!0:i=="]"&&(y=!1),h+=i}else{if(h=="")return ca;if(a=c.parseHost(h))return a;if(h="",u=rv,t==nv)return}break;case rv:if(!nr(Qm,i)){if(i==jn||i=="/"||i=="?"||i=="#"||i=="\\"&&c.isSpecial()||t){if(h!=""){var w=El(h,10);if(w>65535)return a1;c.port=c.isSpecial()&&w===Al[c.scheme]?null:w,h=""}if(t)return;u=To;continue}return a1}h+=i;break;case iv:if(c.scheme="file",i=="/"||i=="\\")u=v1;else{if(!n||n.scheme!="file"){u=Ir;continue}if(i==jn)c.host=n.host,c.path=tr(n.path),c.query=n.query;else if(i=="?")c.host=n.host,c.path=tr(n.path),c.query="",u=ua;else{if(i!="#"){l1(pc(tr(r,d),""))||(c.host=n.host,c.path=tr(n.path),c.shortenPath()),u=Ir;continue}c.host=n.host,c.path=tr(n.path),c.query=n.query,c.fragment="",u=Hr}}break;case v1:if(i=="/"||i=="\\"){u=av;break}n&&n.scheme=="file"&&!l1(pc(tr(r,d),""))&&(vc(n.path[0],!0)?ko(c.path,n.path[0]):c.host=n.host),u=Ir;continue;case av:if(i==jn||i=="/"||i=="\\"||i=="?"||i=="#"){if(!t&&vc(h))u=Ir;else if(h==""){if(c.host="",t)return;u=To}else{if(a=c.parseHost(h))return a;if(c.host=="localhost"&&(c.host=""),t)return;h="",u=To}continue}h+=i;break;case To:if(c.isSpecial()){if(u=Ir,i!="/"&&i!="\\")continue}else if(t||i!="?")if(t||i!="#"){if(i!=jn&&(u=Ir,i!="/"))continue}else c.fragment="",u=Hr;else c.query="",u=ua;break;case Ir:if(i==jn||i=="/"||i=="\\"&&c.isSpecial()||!t&&(i=="?"||i=="#")){if((s=Cl(s=h))===".."||s==="%2e."||s===".%2e"||s==="%2e%2e"?(c.shortenPath(),i=="/"||i=="\\"&&c.isSpecial()||ko(c.path,"")):F5(h)?i=="/"||i=="\\"&&c.isSpecial()||ko(c.path,""):(c.scheme=="file"&&!c.path.length&&vc(h)&&(c.host&&(c.host=""),h=Hn(h,0)+":"),ko(c.path,h)),h="",c.scheme=="file"&&(i==jn||i=="?"||i=="#"))for(;c.path.length>1&&c.path[0]==="";)A5(c.path);i=="?"?(c.query="",u=ua):i=="#"&&(c.fragment="",u=Hr)}else h+=bi(i,u1);break;case g1:i=="?"?(c.query="",u=ua):i=="#"?(c.fragment="",u=Hr):i!=jn&&(c.path[0]+=bi(i,Rl));break;case ua:t||i!="#"?i!=jn&&(i=="'"&&c.isSpecial()?c.query+="%27":c.query+=i=="#"?"%23":bi(i,Rl)):(c.fragment="",u=Hr);break;case Hr:i!=jn&&(c.fragment+=bi(i,c1))}d++}},parseHost:function(e){var t,n,r;if(Hn(e,0)=="["){if(Hn(e,e.length-1)!="]"||(t=function(i){var o,a,s,c,u,d,h,_=[0,0,0,0,0,0,0,0],y=0,b=null,f=0,g=function(){return Hn(i,f)};if(g()==":"){if(Hn(i,1)!=":")return;f+=2,b=++y}for(;g();){if(y==8)return;if(g()!=":"){for(o=a=0;a<4&&nr(s1,g());)o=16*o+El(g(),16),f++,a++;if(g()=="."){if(a==0||(f-=a,y>6))return;for(s=0;g();){if(c=null,s>0){if(!(g()=="."&&s<4))return;f++}if(!nr(Qm,g()))return;for(;nr(Qm,g());){if(u=El(g(),10),c===null)c=u;else{if(c==0)return;c=10*c+u}if(c>255)return;f++}_[y]=256*_[y]+c,++s!=2&&s!=4||y++}if(s!=4)return;break}if(g()==":"){if(f++,!g())return}else if(g())return;_[y++]=o}else{if(b!==null)return;f++,b=++y}}if(b!==null)for(d=y-b,y=7;y!=0&&d>0;)h=_[y],_[y--]=_[b+d-1],_[b+--d]=h;else if(y!=8)return;return _}(fc(e,1,-1)),!t))return ca;this.host=t}else if(this.isSpecial()){if(e=b5(e),nr(V5,e)||(t=function(i){var o,a,s,c,u,d,h,_=P5(i,".");if(_.length&&_[_.length-1]==""&&_.length--,(o=_.length)>4)return i;for(a=[],s=0;s<o;s++){if((c=_[s])=="")return i;if(u=10,c.length>1&&Hn(c,0)=="0"&&(u=nr(O5,c)?16:8,c=fc(c,u==8?1:2)),c==="")d=0;else{if(!nr(u==10?N5:u==8?M5:s1,c))return i;d=El(c,u)}ko(a,d)}for(s=0;s<o;s++)if(d=a[s],s==o-1){if(d>=r1(256,5-o))return null}else if(d>255)return null;for(h=R5(a),s=0;s<a.length;s++)h+=a[s]*r1(256,3-s);return h}(e),t===null))return ca;this.host=t}else{if(nr(U5,e))return ca;for(t="",n=bo(e),r=0;r<n.length;r++)t+=bi(n[r],Rl);this.host=t}},cannotHaveUsernamePasswordPort:function(){return!this.host||this.cannotBeABaseURL||this.scheme=="file"},includesCredentials:function(){return this.username!=""||this.password!=""},isSpecial:function(){return Jm(Al,this.scheme)},shortenPath:function(){var e=this.path,t=e.length;!t||this.scheme=="file"&&t==1&&vc(e[0],!0)||e.length--},serialize:function(){var e=this,t=e.scheme,n=e.username,r=e.password,i=e.host,o=e.port,a=e.path,s=e.query,c=e.fragment,u=t+":";return i!==null?(u+="//",e.includesCredentials()&&(u+=n+(r?":"+r:"")+"@"),u+=mc(i),o!==null&&(u+=":"+o)):t=="file"&&(u+="//"),u+=e.cannotBeABaseURL?a[0]:a.length?"/"+pc(a,"/"):"",s!==null&&(u+="?"+s),c!==null&&(u+="#"+c),u},setHref:function(e){var t=this.parse(e);if(t)throw qm(t);this.searchParams.update()},getOrigin:function(){var e=this.scheme,t=this.port;if(e=="blob")try{return new xo(e.path[0]).origin}catch(n){return"null"}return e!="file"&&this.isSpecial()?e+"://"+mc(this.host)+(t!==null?":"+t:""):"null"},getProtocol:function(){return this.scheme+":"},setProtocol:function(e){this.parse(Gr(e)+":",$m)},getUsername:function(){return this.username},setUsername:function(e){var t=bo(Gr(e));if(!this.cannotHaveUsernamePasswordPort()){this.username="";for(var n=0;n<t.length;n++)this.username+=bi(t[n],Ym)}},getPassword:function(){return this.password},setPassword:function(e){var t=bo(Gr(e));if(!this.cannotHaveUsernamePasswordPort()){this.password="";for(var n=0;n<t.length;n++)this.password+=bi(t[n],Ym)}},getHost:function(){var e=this.host,t=this.port;return e===null?"":t===null?mc(e):mc(e)+":"+t},setHost:function(e){this.cannotBeABaseURL||this.parse(e,tv)},getHostname:function(){var e=this.host;return e===null?"":mc(e)},setHostname:function(e){this.cannotBeABaseURL||this.parse(e,nv)},getPort:function(){var e=this.port;return e===null?"":Gr(e)},setPort:function(e){this.cannotHaveUsernamePasswordPort()||((e=Gr(e))==""?this.port=null:this.parse(e,rv))},getPathname:function(){var e=this.path;return this.cannotBeABaseURL?e[0]:e.length?"/"+pc(e,"/"):""},setPathname:function(e){this.cannotBeABaseURL||(this.path=[],this.parse(e,To))},getSearch:function(){var e=this.query;return e?"?"+e:""},setSearch:function(e){(e=Gr(e))==""?this.query=null:(Hn(e,0)=="?"&&(e=fc(e,1)),this.query="",this.parse(e,ua)),this.searchParams.update()},getSearchParams:function(){return this.searchParams.facade},getHash:function(){var e=this.fragment;return e?"#"+e:""},setHash:function(e){(e=Gr(e))!=""?(Hn(e,0)=="#"&&(e=fc(e,1)),this.fragment="",this.parse(e,Hr)):this.fragment=null},update:function(){this.query=this.searchParams.serialize()||null}};var xo=function(e){var t=y5(this,dn),n=T5(arguments.length,1)>1?arguments[1]:void 0,r=x5(t,new ov(e,!1,n));zm||(t.href=r.serialize(),t.origin=r.getOrigin(),t.protocol=r.getProtocol(),t.username=r.getUsername(),t.password=r.getPassword(),t.host=r.getHost(),t.hostname=r.getHostname(),t.port=r.getPort(),t.pathname=r.getPathname(),t.search=r.getSearch(),t.searchParams=r.getSearchParams(),t.hash=r.getHash())},dn=xo.prototype,zn=function(e,t){return{get:function(){return wl(this)[e]()},set:t&&function(n){return wl(this)[t](n)},configurable:!0,enumerable:!0}};if(zm&&(Gn(dn,"href",zn("serialize","setHref")),Gn(dn,"origin",zn("getOrigin")),Gn(dn,"protocol",zn("getProtocol","setProtocol")),Gn(dn,"username",zn("getUsername","setUsername")),Gn(dn,"password",zn("getPassword","setPassword")),Gn(dn,"host",zn("getHost","setHost")),Gn(dn,"hostname",zn("getHostname","setHostname")),Gn(dn,"port",zn("getPort","setPort")),Gn(dn,"pathname",zn("getPathname","setPathname")),Gn(dn,"search",zn("getSearch","setSearch")),Gn(dn,"searchParams",zn("getSearchParams")),Gn(dn,"hash",zn("getHash","setHash"))),Il(dn,"toJSON",function(){return wl(this).serialize()},{enumerable:!0}),Il(dn,"toString",function(){return wl(this).serialize()},{enumerable:!0}),hc){var _1=hc.createObjectURL,y1=hc.revokeObjectURL;_1&&Il(xo,"createObjectURL",e1(_1,hc)),y1&&Il(xo,"revokeObjectURL",e1(y1,hc))}k5(xo,"URL"),g5({global:!0,constructor:!0,forced:!_5,sham:!zm},{URL:xo});var la,Ll,G5=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"}),S1=!1,H5=function(){function e(n){J(this,e),this.context_=n.context,this.addModuleToContext()}var t;return ye(e,[{key:"addModuleToContext",value:(t=N(p().mark(function n(){return p().wrap(function(r){for(;;)switch(r.prev=r.next){case 0:return r.prev=0,r.next=3,this.context_.audioWorklet.addModule(URL.createObjectURL(G5));case 3:ke.info("worklet addModule success"),q.emit(lm),S1=!0,r.next=12;break;case 8:r.prev=8,r.t0=r.catch(0),ke.info("worklet addModule catch error. ".concat(r.t0.message)),q.emit(dm);case 12:case"end":return r.stop()}},n,this,[[0,8]])})),function(){return t.apply(this,arguments)})},{key:"initWorkletSuccess",get:function(){return S1}}]),e}(),Ol=0,z5=function(){function e(t){J(this,e);var n=t.track,r=t.log,i=t.stream;this.volume_=0,this.log_=r,this.track_=n,this.stream_=i,la||(la=Uk()),this.audioCtx_=la,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,q.on(ac,this.resume,this),q.on(qf,this.handleAudioLevelInterval,this),wV?(q.on(lm,this.initAudioWorklet,this),q.on(dm,this.initScriptProcessor,this),this.preload()):this.initScriptProcessor(),Ol+=1}return ye(e,[{key:"preload",value:function(){Ll?Ll.initWorkletSuccess&&this.initAudioWorklet():Ll=new H5({context:la})}},{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."),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 r=n.inputBuffer.getChannelData(0),i=0,o=0;o<r.length;++o)i+=r[o]*r[o];t.volume_=Math.sqrt(i/r.length)||0},this.streamSource_.connect(this.scriptProcessorNode_),this.scriptProcessorNode_.connect(this.destination_)}catch(n){this.log_.error("volumeMeter init script processor error: "+n)}}},{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,q.off(ac,this.resume,this),q.off(qf,this.handleAudioLevelInterval,this),q.off(lm,this.initAudioWorklet,this),q.off(dm,this.initScriptProcessor,this),Ol>0&&(Ol-=1),Ol===0&&((t=la)===null||t===void 0||t.close(),la=null,Ll=null)}},{key:"resume",value:function(){var t;(t=la)===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,r=t.interval;this.interval_=r,(n=this.audioWorkletNode_)===null||n===void 0||n.port.postMessage({name:"setIntervalTime",intervalTime:r})}}]),e}(),W5=function(){function e(o){J(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 _i,this.initializeElement(),this.state_="NONE",this.volumeMeter_=new z5({stream:this.stream_,track:this.gainedTrack_||this.track_,log:this.log_})}var t,n,r,i;return ye(e,[{key:"isPlaying",get:function(){return this.state_===ro}},{key:"initializeElement",value:function(){if(this.isAudioElementInit()){var o=new MediaStream;o.addTrack(this.gainedTrack_||this.track_);var a=document.createElement(Ce);a.srcObject=o,a.muted=this.muted_,a.setAttribute("id","audio_".concat(this.stream_.getId())),a.setAttribute("autoplay","autoplay"),a.setAttribute("playsinline","playsinline"),this.div_.appendChild(a),this.element_=a}this.handleEvents()}},{key:"setMuted",value:function(o){this.element_&&(this.element_.muted=o,this.muted_=o)}},{key:"play",value:(i=N(p().mark(function o(){var a;return p().wrap(function(s){for(;;)switch(s.prev=s.next){case 0:if(!this.outputDeviceId_||!this.element_){s.next=3;break}return s.next=3,this.element_.setSinkId(this.outputDeviceId_);case 3:if(this.setVolume(this.volume_),s.prev=4,!this.element_){s.next=8;break}return s.next=8,this.element_.play();case 8:s.next=16;break;case 10:if(s.prev=10,s.t0=s.catch(4),a=ne({key:pf,data:{media:"Audio",error:s.t0}}),this.log_.warn(a),!a.includes("NotAllowedError")){s.next=16;break}throw new ee({code:Y.PLAY_NOT_ALLOWED,message:a});case 16:case"end":return s.stop()}},o,this,[[4,10]])})),function(){return i.apply(this,arguments)})},{key:"handleEvents",value:function(){this.handleElementEvent=this.handleElementEvent.bind(this),this.handleTrackEvent=this.handleTrackEvent.bind(this),this.element_&&(this.element_.addEventListener(di,this.handleElementEvent),this.element_.addEventListener(Mt,this.handleElementEvent),this.element_.addEventListener(hi,this.handleElementEvent),this.element_.addEventListener(no,this.handleElementEvent)),this.track_.addEventListener(Mt,this.handleTrackEvent),this.track_.addEventListener(nn,this.handleTrackEvent),this.track_.addEventListener(_r,this.handleTrackEvent),this.track_.readyState===Mt&&this.handleTrackEvent({type:Mt}),this.track_.muted&&this.handleTrackEvent({type:nn})}},{key:"handleElementEvent",value:(r=N(p().mark(function o(a){var s,c,u,d,h,_,y,b=this;return p().wrap(function(f){for(;;)switch(f.prev=f.next){case 0:s=a.type,f.t0=s,f.next=f.t0===di?4:f.t0===Mt?9:f.t0===hi?12:f.t0===no?21:32;break;case 4:return this.log_.info("audio player is playing"),this.state_=ro,q.emit(Xf,{stream:this.stream_}),this.emitter_.emit(gn,{state:this.state_,reason:di}),f.abrupt("break",32);case 9:return this.log_.info("audio player is ended"),this.state_!==pi&&(this.state_=pi,this.emitter_.emit(gn,{state:this.state_,reason:Mt})),f.abrupt("break",32);case 12:return this.log_.info("audio player is paused"),this.state_=yr,this.emitter_.emit(gn,{state:this.state_,reason:hi}),(c=this.div_&&document.getElementById(this.div_.id))||this.log_.warn("audio player has been remove, element ID: ".concat(this.div_.id)),u=nc(),this.pausedRetryCount_>0&&(xr(u)&&u<=70||!c)&&(this.resume(),this.pausedRetryCount_--),Qi&&(this.interval_=yt.run(function(){b.element_&&b.state_===yr&&b.resume()},{delay:3e3})),f.abrupt("break",32);case 21:if(!this.element_||!this.element_.error){f.next=31;break}return d="".concat(Mm(),"/").concat(ta().name,"/").concat(ta().version),f.next=25,Tt.getSpeakers();case 25:h=f.sent,_=h[0].label,(y=h.find(function(g){return g.deviceId===b.outputDeviceId_}))&&(_=y.label),this.log_.error("audio player error observed. code: ".concat(this.element_.error.code," message: ").concat(this.element_.error.message," deviceInfo: ").concat(d," speaker: ").concat(_)),Ie.uploadEvent("stat-".concat(this.stream_.getType(),"-audio-").concat(Fb,"-").concat(this.element_.error.code,"-").concat(d,"-").concat(_),this.element_.error);case 31:return f.abrupt("break",32);case 32:case"end":return f.stop()}},o,this)})),function(o){return r.apply(this,arguments)})},{key:"handleTrackEvent",value:function(o){var a=o.type;switch(a){case Mt:this.log_.info("audio track is ended"),this.state_!==pi&&(this.state_=pi,this.emitter_.emit(gn,{state:this.state_,reason:Mt})),q.emit(om,{stream:this.stream_,type:a});break;case nn:this.log_.info("audio track is unable to provide media output"),this.stream_.isRemote()||Vk(),this.state_!==yr&&(this.state_=yr,this.emitter_.emit(gn,{state:this.state_,reason:nn})),q.emit(am,{stream:this.stream_,type:a});break;case _r:this.log_.info("audio track is able to provide media output"),this.state_===yr&&(this.state_=ro,this.emitter_.emit(gn,{state:this.state_,reason:_r}))}}},{key:"unbindEvents",value:function(){this.element_&&(this.element_.removeEventListener(di,this.handleElementEvent),this.element_.removeEventListener(Mt,this.handleElementEvent),this.element_.removeEventListener(hi,this.handleElementEvent),this.element_.removeEventListener(no,this.handleElementEvent)),this.track_&&(this.track_.removeEventListener(Mt,this.handleTrackEvent),this.track_.removeEventListener(nn,this.handleTrackEvent),this.track_.removeEventListener(_r,this.handleTrackEvent))}},{key:"setSinkId",value:(n=N(p().mark(function o(a){return p().wrap(function(s){for(;;)switch(s.prev=s.next){case 0:if(this.outputDeviceId_===a){s.next=5;break}if(!this.element_){s.next=4;break}return s.next=4,this.element_.setSinkId(a);case 4:this.outputDeviceId_=a;case 5:case"end":return s.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&&yt.clearTask(this.interval_)}},{key:"resume",value:(t=N(p().mark(function o(){var a;return p().wrap(function(s){for(;;)switch(s.prev=s.next){case 0:if(s.prev=0,this.volumeMeter_&&this.volumeMeter_.resume(),!this.element_){s.next=5;break}return s.next=5,this.element_.play();case 5:s.next=13;break;case 7:if(s.prev=7,s.t0=s.catch(0),a=ne({key:pf,data:{media:"Audio",error:s.t0}}),this.log_.warn(a),!a.includes("NotAllowedError")){s.next=13;break}throw new ee({code:Y.PLAY_NOT_ALLOWED,message:a});case 13:case"end":return s.stop()}},o,this,[[0,7]])})),function(){return t.apply(this,arguments)})},{key:"on",value:function(o,a){this.emitter_.on(o,a)}},{key:"isAudioElementInit",value:function(){return!($i==="15.2"||$i==="15.3"||$i==="15.4")||this.stream_.getType()!=="local"||!this.muted_||(this.log_.info("audioElement is muted."),!1)}}]),e}(),J5=Yn.PROPER,K5=oe,b1=sS,q5=Vu.trim;Me({target:"String",proto:!0,forced:function(e){return K5(function(){return!!b1[e]()||"\u200B\x85\u180E"[e]()!=="\u200B\x85\u180E"||J5&&b1[e].name!==e})}("trim")},{trim:function(){return q5(this)}});var zr="trtc_autoplay",sv="".concat(zr,"_mask"),Io="".concat(zr,"_wrapper"),k1="".concat(zr,"_header"),cv="".concat(zr,"_content"),Ml="".concat(zr,"_action_wrapper"),uv="".concat(zr,"_question"),lv="".concat(zr,"_collapse"),Nl="".concat(zr,"_action_confirm"),T1="".concat(zr,"_detail"),x1="#2473E8",dv="dialog",X5="".concat(dv,"-show"),Q5="".concat(dv,"-1"),Y5="".concat(dv,"-2"),I1=!1,w1=function(){return!!document.querySelector(".".concat(Io))},E1="".concat(oo,"/").concat(ra()?"zh-cn":"en","/tutorial-21-advanced-auto-play-policy.html"),C1="<br><a href='".concat(E1,"' target='_blank'>").concat(ra()?"\u5176\u4ED6\u65B9\u6848\uFF1F":"Any other solution?","</a>"),$5="".concat(ra()?"\u6D4F\u89C8\u5668\u81EA\u52A8\u64AD\u653E\u7B56\u7565\uFF1A\u5728\u7528\u6237\u4E0E\u9875\u9762\u4EA7\u751F\u4EA4\u4E92\uFF08\u70B9\u51FB\u3001\u89E6\u6478\uFF09\u4E4B\u524D\uFF0C\u6D4F\u89C8\u5668\u7981\u6B62\u64AD\u653E\u6709\u58F0\u5A92\u4F53\u3002\u8BE5\u5F39\u7A97\u7528\u4E8E\u5E2E\u52A9\u7528\u6237\u6062\u590D\u97F3\u89C6\u9891\u64AD\u653E\u3002".concat(C1):"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(C1)),R1=function(){function e(){if(J(this,e),this.dialogNode_=null,this.bodyPosition_="",this.content="\u97F3\u89C6\u9891\u64AD\u653E\u88AB\u6D4F\u89C8\u5668\u62E6\u622A\uFF0C\u8BF7\u70B9\u51FB\u201C\u6062\u590D\u64AD\u653E\u201D\u3002",ra()||(this.content='Media playback failed. Click the "Resume" to resume playback.'),!I1){var t=document.createElement("style");t.innerHTML=".".concat(sv,"{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(sv," div:not(.").concat(Ml,"){display:block !important;}.").concat(Io,"{padding:14px;background:#fff;border-radius:3px;box-shadow:0px 3px 15px #434343;border:1px solid #d1cfcf;max-width:500px;}.").concat(Io," a{color:").concat(x1,";}.").concat(k1,"{overflow:hidden;text-overflow:ellipsis;font-size:16px;font-weight:600;}.").concat(cv,"{margin:8px 0;}.").concat(Ml,"{width:100%;display:flex !important;align-items:center;justify-content:right;float:right;}.").concat(lv,"{margin-right:auto;cursor:pointer}.").concat(uv,"{height:100%;line-height:16px;cursor:pointer;}.").concat(Nl,"{margin-left:8px;color:#fff;background:").concat(x1,";padding:4px 12px;outline:none;border:1px solid;border-radius:3px;font-weight:bold;}.").concat(Nl,":hover{opacity:0.9;}.").concat(lv,",.").concat(Nl,",.").concat(cv,",.").concat(uv,"{font-size:14px;}@media screen and (max-width:750px){.").concat(Io,"{width:80vw;}}"),document.head.appendChild(t),I1=!0}this.showDetail_=!1,this.isCollapseClicked_=!1,this.isQuestionClicked_=!1,this.addDiaLog()}return ye(e,[{key:"createDiaLog",value:function(){var t=document.createElement("template");t.innerHTML='<div class="'.concat(sv,`"><div class='`).concat(Io,"'><div class='").concat(k1,"'>").concat(location.host,"</div><div class='").concat(cv,"'>").concat(this.content,"</div><div class='").concat(T1,`' style="visibility:hidden;width:100%;height:0;font-size:12px;color:gray;">`).concat($5,"</div><div class='").concat(Ml,"'></div></div></div>").trim();var n=document.createElement("button");n.className=Nl,n.innerText=ra()?"\u6062\u590D\u64AD\u653E":"Resume",n.onclick=this.onConfirm.bind(this);var r=document.createElement("div");r.className=uv,r.innerHTML=`<?xml version="1.0" encoding="UTF-8"?>
56
+ `};er.write=IV,er.parse=oa.parse,er.parseParams=oa.parseParams,er.parseFmtpConfig=oa.parseFmtpConfig,er.parsePayloads=oa.parsePayloads,er.parseRemoteCandidates=oa.parseRemoteCandidates,er.parseImageAttributes=oa.parseImageAttributes,er.parseSimulcastStreamList=oa.parseSimulcastStreamList;var Br=function(e){return er.parse(e)},mo=function(e){return er.write(e)},wV=function(e){var t=Br(e);return t.media.forEach(function(n){n.type===Ee&&n.fmtp.forEach(function(i){i.config+=";sprop-stereo=1;stereo=1"})}),mo(t)},om,sm,cm,um,CV=Me,lm=pe,EV=Qn,RV=i0,AV=$_,Tk=ue,PV=RangeError,xk=String,Ik=Math.floor,dm=lm(AV),wk=lm("".slice),cc=lm(1 .toFixed),vo=function(e,t,n){return t===0?n:t%2==1?vo(e,t-1,n*e):vo(e*e,t/2,n)},go=function(e,t,n){for(var i=-1,r=n;++i<6;)r+=t*e[i],e[i]=r%1e7,r=Ik(r/1e7)},hm=function(e,t){for(var n=6,i=0;--n>=0;)i+=e[n],e[n]=Ik(i/t),i=i%t*1e7},Ck=function(e){for(var t=6,n="";--t>=0;)if(n!==""||t===0||e[t]!==0){var i=xk(e[t]);n=n===""?i:n+dm("0",7-i.length)+i}return n};CV({target:"Number",proto:!0,forced:Tk(function(){return cc(8e-5,3)!=="0.000"||cc(.9,0)!=="1"||cc(1.255,2)!=="1.25"||cc(0xde0b6b3a7640080,0)!=="1000000000000000128"})||!Tk(function(){cc({})})},{toFixed:function(e){var t,n,i,r,o=RV(this),c=EV(e),a=[0,0,0,0,0,0],s="",l="0";if(c<0||c>20)throw PV("Incorrect fraction digits");if(o!=o)return"NaN";if(o<=-1e21||o>=1e21)return xk(o);if(o<0&&(s="-",o=-o),o>1e-21)if(n=(t=function(u){for(var p=0,k=u;k>=4096;)p+=12,k/=4096;for(;k>=2;)p+=1,k/=2;return p}(o*vo(2,69,1))-69)<0?o*vo(2,-t,1):o/vo(2,t,1),n*=4503599627370496,(t=52-t)>0){for(go(a,0,n),i=c;i>=7;)go(a,1e7,0),i-=7;for(go(a,vo(10,i,1),0),i=t-1;i>=23;)hm(a,1<<23),i-=23;hm(a,1<<i),go(a,1,1),hm(a,2),l=Ck(a)}else go(a,0,n),go(a,1<<-t,0),l=Ck(a)+dm("0",c);return l=c>0?s+((r=l.length)<=c?"0."+dm("0",c-r)+l:wk(l,0,r-c)+"."+wk(l,r-c)):s+l}});var Ek=((om=window)===null||om===void 0?void 0:om.requestIdleCallback)||function(e){var t=Date.now();return setTimeout(function(){e({didTimeout:!1,timeRemaining:function(){return Math.max(0,50-(Date.now()-t))}})},1e3)},DV=((sm=window)===null||sm===void 0?void 0:sm.cancelIdleCallback)||function(e){clearTimeout(e)},LV=((cm=window)===null||cm===void 0?void 0:cm.cancelAnimationFrame)||((um=window)===null||um===void 0?void 0:um.mozCancelAnimationFrame),_t=function(){function e(){Q(this,e)}return Ie(e,null,[{key:"generateTaskID",value:function(){return this.currentTaskID++}},{key:"run",value:function(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:Zb,n=arguments.length>1?arguments[1]:void 0,i=arguments.length>2?arguments[2]:void 0;i=q(q({},t===cN?{delay:2e3,count:0,backgroundTask:!0}:t===so?{delay:1e4,count:0}:t===Xu?{fps:60,delay:16.6,count:0,backgroundTask:!0}:{delay:2e3,count:0,backgroundTask:!0}),i),LS(n)&&(i=q(q({},i),n)),pn(t)&&(n=t,t=Zb);var r=q({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=Pt();return t.ricID=Ek(function o(){if((n=Pt()-r)>=t.delay&&(r=Pt()-Math.floor(n%t.delay),t.callback(),t.loopCount+=1),!i.isBreakLoop(t))return t.ricID=Ek(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=Pt(),o=function a(){if(document.hidden&&t.backgroundTask)return i=Pt()-r,r=Pt(),t.callback(),t.loopCount+=1,n.isBreakLoop(t)?void 0:t.timeoutID=setTimeout(a,t.delay-Math.floor(i%t.delay));if((i=Pt()-r)>=t.delay&&(r=Pt()-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=Pt()-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&&LV(o),c&&DV(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}();$e(_t,"taskMap",new Map),$e(_t,"currentTaskID",1);var OV=function(){function e(){Q(this,e),this.prefix_="TRTC",this.queue_=new Map,this.checkStorage()}return Ie(e,[{key:"getRealKey",value:function(t){return"".concat(this.prefix_,"_").concat(t)}},{key:"checkStorage",value:function(){var t=this;if(ta()){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(ta())try{var t,n=oe(this.queue_);try{for(n.s();!(t=n.n()).done;){var i=ke(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){ye.warn(c)}}},{key:"getItem",value:function(t){if(!ta())return null;try{var n=JSON.parse(localStorage.getItem(this.getRealKey(t)));return n&&n.expiresIn>=Date.now()?n.value:null}catch(i){ye.warn(i)}}},{key:"setItem",value:function(t,n){var i=arguments.length>2&&arguments[2]!==void 0&&arguments[2];if(ta())try{var r={expiresIn:Date.now()+Wb,value:n};i?localStorage.setItem(this.getRealKey(t),JSON.stringify(r)):(this.queue_.set(this.getRealKey(t),r),_t.hasTask(this.intervalId_)||(this.intervalId_=_t.run(so,this.doFlush.bind(this),{count:1})))}catch(o){ye.warn(o)}}},{key:"deleteItem",value:function(t){if(!ta())return!1;try{return t=this.getRealKey(t),this.queue_.delete(t),localStorage.removeItem(t),!0}catch(n){return ye.warn(n),!1}}},{key:"clear",value:function(){if(ta())try{localStorage.clear()}catch(t){ye.warn(t)}}}]),e}(),_o=new OV,vt={result:!1,detail:{isBrowserSupported:!1,isWebRTCSupported:!1,isMediaDevicesSupported:!1,isH264EncodeSupported:!1,isVp8EncodeSupported:!1,isH264DecodeSupported:!1,isVp8DecodeSupported:!1}},Rk="checkResult",Ak=function(){return!p4&&!Yu&&!($u&&IS<80)&&!(Tr&&xS<56)},fm=function(){return["RTCPeerConnection","webkitRTCPeerConnection","RTCIceGatherer"].filter(function(e){return e in window}).length>0},MV=function(){if(!navigator.mediaDevices)return!1;var e=["getUserMedia","enumerateDevices"];return e.filter(function(t){return t in navigator.mediaDevices}).length===e.length},Pk=function(){var e=H(f().mark(function t(){var n,i,r,o,c,a;return f().wrap(function(s){for(;;)switch(s.prev=s.next){case 0:if(!vt.detail.isH264EncodeSupported||!vt.detail.isVp8EncodeSupported){s.next=2;break}return s.abrupt("return",{isH264EncodeSupported:vt.detail.isH264EncodeSupported,isVp8EncodeSupported:vt.detail.isVp8EncodeSupported});case 2:return n="",i=!1,r=!1,s.prev=5,o=new RTCPeerConnection,(c=document.createElement(lb)).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(),vt.detail.isH264EncodeSupported=i,vt.detail.isVp8EncodeSupported=r,s.abrupt("return",{isH264EncodeSupported:vt.detail.isH264EncodeSupported,isVp8EncodeSupported:vt.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 NV(){return pm.apply(this,arguments)}function pm(){return pm=H(f().mark(function e(){return f().wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",new Promise(function(){var n=H(f().mark(function i(r){var o,c,a,s,l,u,p,k,x,E,I,m,T,v;return f().wrap(function(C){for(;;)switch(C.prev=C.next){case 0:return o={encode:!1,decode:!1},c=null,C.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,p=-1,c=function(){clearInterval(u),clearInterval(l),clearTimeout(p),x.close(),E.close(),k.getTracks().forEach(function(O){return O.stop()})},p=setTimeout(function(){c(),r(o)},3e3),k=a.captureStream(),x=new RTCPeerConnection({}),E=new RTCPeerConnection({offerToReceiveAudio:!0,offerToReceiveVideo:!0}),x.addEventListener("icecandidate",function(O){return E.addIceCandidate(O.candidate)}),E.addEventListener("icecandidate",function(O){return x.addIceCandidate(O.candidate)}),x.addTrack(k.getVideoTracks()[0],k),C.next=20,x.createOffer();case 20:return I=C.sent,C.next=23,x.setLocalDescription(I);case 23:return C.next=25,E.setRemoteDescription(I);case 25:return C.next=27,E.createAnswer();case 27:return m=C.sent,T=Br(m.sdp),v=T.media[0].rtp.findIndex(function(O){return O.codec==="H264"}),T.media[0].rtp=[T.media[0].rtp[v]],T.media[0].fmtp=T.media[0].fmtp.filter(function(O){return O.payload===T.media[0].rtp[0].payload}),T.media[0].rtcpFb=T.media[0].rtcpFb.filter(function(O){return O.payload===T.media[0].rtp[0].payload}),m.sdp=mo(T),C.next=36,E.setLocalDescription(m);case 36:return C.next=38,x.setRemoteDescription(m);case 38:u=setInterval(H(f().mark(function O(){var N,j;return f().wrap(function(_){for(;;)switch(_.prev=_.next){case 0:return o.encode&&o.decode&&(c(),r(o)),_.next=3,x.getStats();case 3:return N=_.sent,_.next=6,E.getStats();case 6:j=_.sent,o.encode||N.forEach(function(b){b.type==="outbound-rtp"&&b.mediaType===Te&&b.framesEncoded>0&&(o.encode=!0)}),o.decode||j.forEach(function(b){b.type==="inbound-rtp"&&b.mediaType===Te&&b.framesDecoded>0&&(o.decode=!0)});case 9:case"end":return _.stop()}},O)})),500),C.next=46;break;case 41:C.prev=41,C.t0=C.catch(2),c(),ye.warn(C.t0),r(o);case 46:case"end":return C.stop()}},i,null,[[2,41]])}));return function(i){return n.apply(this,arguments)}}()));case 1:case"end":return t.stop()}},e)})),pm.apply(this,arguments)}var Dk=function(){var e=H(f().mark(function t(){var n,i,r,o;return f().wrap(function(c){for(;;)switch(c.prev=c.next){case 0:if(!vt.detail.isH264DecodeSupported||!vt.detail.isVp8DecodeSupported){c.next=2;break}return c.abrupt("return",{isH264DecodeSupported:vt.detail.isH264DecodeSupported,isVp8DecodeSupported:vt.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)}}(),UV=function(){var e=H(f().mark(function t(){var n,i,r,o,c,a,s,l,u,p,k,x,E;return f().wrap(function(I){for(;;)switch(I.prev=I.next){case 0:if(Lk()){I.next=2;break}return I.abrupt("return",vt);case 2:return n=Ak(),i=fm(),r=MV(),I.next=7,Pk();case 7:return o=I.sent,c=o.isH264EncodeSupported,a=o.isVp8EncodeSupported,I.next=12,Dk();case 12:if(s=I.sent,l=s.isH264DecodeSupported,u=s.isVp8DecodeSupported,c&&a){I.next=21;break}return I.next=18,Pk();case 18:p=I.sent,c=p.isH264EncodeSupported,a=p.isVp8EncodeSupported;case 21:if(!(c&&l&&(el||tl||k4)&&!Nr&&co()<79)){I.next=29;break}return I.next=24,NV();case 24:k=I.sent,x=k.encode,E=k.decode,c=x,l=E;case 29:return vt.result=n&&i&&r&&(c||a)&&(l||u),vt.detail.isBrowserSupported=n,vt.detail.isWebRTCSupported=i,vt.detail.isMediaDevicesSupported=r,vt.detail.isH264EncodeSupported=c,vt.detail.isVp8EncodeSupported=a,vt.detail.isH264DecodeSupported=l,vt.detail.isVp8DecodeSupported=u,VV(),_o.setItem(Rk,{ua:navigator.userAgent,checkResult:vt},!0),I.abrupt("return",vt);case 40:case"end":return I.stop()}},t)}));return function(){return e.apply(this,arguments)}}(),mm=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(t||this,r)).then(function(c){return n=null,c}).catch(function(c){throw n=null,c}),n}}(UV);function Lk(){return Object.keys(vt.detail).findIndex(function(e){return!vt.detail[e]})>=0}function VV(){Lk()&&(ye.warn(ie({key:fS})),ye.info("".concat(navigator.userAgent," ").concat(JSON.stringify(vt.detail))))}function Ok(){return!(!navigator.mediaDevices||!navigator.mediaDevices.getDisplayMedia)}function Mk(){return"RTCPeerConnection"in window&&"getReceivers"in window.RTCPeerConnection.prototype}function fl(){return"RTCPeerConnection"in window&&"getSenders"in window.RTCPeerConnection.prototype}function ki(){return"RTCPeerConnection"in window&&"getTransceivers"in window.RTCPeerConnection.prototype}function vm(){return"RTCPeerConnection"in window&&"addTransceiver"in window.RTCPeerConnection.prototype}function gm(){return"RTCRtpSender"in window&&"replaceTrack"in window.RTCRtpSender.prototype}function Nk(){return"RTCRtpSender"in window&&"setParameters"in window.RTCRtpSender.prototype&&fl()}function pl(){return!!ge(navigator.mediaDevices)&&(ye.error(mi.NOT_SUPPORTED_MEDIA),!0)}function ml(){return location.protocol==="http:"&&!ea&&(ye.warn(ie({key:hS})),!0)}var _m="RTCRtpSender"in window&&"createEncodedStreams"in window.RTCRtpSender.prototype&&co()>=86;function ym(e){return!(e.type!=="candidate-pair"||!e.nominated||e.state!=="in-progress"&&e.state!=="succeeded")&&!(Zn(e.selected)&&!e.selected)}var Uk=new Map([[$i,"Android"],[vi,"iOS"],[CS,"Windows"],[Zs,"MacOS"],[ES,"Linux"]]);function bm(){var e="unknown";return Uk.get(!0)&&(e=Uk.get(!0)),e}function jV(){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 FV(){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 Vk(){return!(sp&&co()<86)&&!(vi&&$n(gi)&&gi<15)&&!(gp&&gp<63)&&!(!Ak()||!("captureStream"in HTMLCanvasElement.prototype))}var yo=window.MediaStreamTrack&&"getSettings"in MediaStreamTrack.prototype,HV=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(){ml();var e=_o.getItem(Rk);e&&e.ua===navigator.userAgent&&(vt=e.checkResult),mm()})();var et={STREAM_ADDED:"stream-added",STREAM_REMOVED:"stream-removed",STREAM_UPDATED:"stream-updated",STREAM_PUBLISHED:"stream-published",STREAM_SUBSCRIBED:"stream-subscribed",STREAM_UNSUBSCRIBED:"stream-unsubscribed",STATE_CHANGED:"state-changed",ERROR:"error",CONNECTION_STATE_CHANGED:"connection-state-changed",SEI_MESSAGE:pb},st={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:pb,ERROR:"error"},jk="player-state-changed",zV="screen-sharing-stopped",WV="connection-state-changed",qV="device-auto-recovered",Sm="error",vn="player-state-changed",JV=nS;Me({target:"String",proto:!0,forced:rS("small")},{small:function(){return JV(this,"small","","")}});var KV=function(){function e(o){Q(this,e);var c=o.getUserId();this.log_=ye.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 Ie(e,[{key:"statInterval",get:function(){return this.prevReportTime_===0?2:(Date.now()-this.prevReportTime_)/1e3}},{key:"getSenderStats",value:(r=H(f().mark(function o(c){var a,s,l,u,p=this;return f().wrap(function(k){for(;;)switch(k.prev=k.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){k.next=15;break}return k.prev=4,k.next=7,s.getStats();case 7:k.sent.forEach(function(x){if(x.type==="outbound-rtp")if(x.mediaType===Te){if(!Tr&&x.bytesSent===0)return;x.ssrc!==l.video||ge(x.encoderImplementation)||p.prevEncoderImplementation_===x.encoderImplementation||(p.log_.info("encoderImplementation change to ".concat(x.encoderImplementation)),p.prevEncoderImplementation_=x.encoderImplementation),x.ssrc!==l.video||ge(x.qualityLimitationReason)||p.prevQualityLimitationReason_===x.qualityLimitationReason||(p.log_.info("qualityLimitationReason change to ".concat(x.qualityLimitationReason)),p.prevQualityLimitationReason_=x.qualityLimitationReason);var E=Te;x.ssrc===l.small?E=Or:x.ssrc===l.auxiliary&&(E=pt),a[E].bytesSent=x.bytesSent,a[E].packetsSent=x.packetsSent,a[E].framesEncoded=x.framesEncoded}else x.mediaType===Ee&&(a.audio.bytesSent=x.bytesSent,a.audio.packetsSent=x.packetsSent);else x.type==="candidate-pair"?ym(x)&&$n(x.currentRoundTripTime)&&(a.rtt=Math.floor(1e3*x.currentRoundTripTime)):x.type==="media-source"&&(x.kind===Ee?(a.audio.audioLevel=x.audioLevel||0,a.audio.totalAudioEnergy=x.totalAudioEnergy||0):x.kind===Te&&(x.trackIdentifier===c.getVideoTrackId(Te)?a.video.fpsCapture=x.framesPerSecond:x.trackIdentifier===c.getVideoTrackId(pt)?a.auxiliary.fpsCapture=x.framesPerSecond:a.small.fpsCapture=x.framesPerSecond));var I;ge(x.audioLevel)||(a.audio.audioLevel=x.audioLevel||0,a.audio.totalAudioEnergy=x.totalAudioEnergy||0),ge(x.frameWidth)||(x.trackIdentifier===c.getVideoTrackId(Te)||x.ssrc===l.video?I=Te:x.trackIdentifier===c.getVideoTrackId(pt)||x.ssrc===l.auxiliary?I=pt:x.trackIdentifier!==c.getVideoTrackId(Or)&&x.ssrc!==l.small||(I=Or),I&&(a[I].frameWidth=x.frameWidth,a[I].frameHeight=x.frameHeight,a[I].framesSent=x.framesSent))}),a.audio.audioLevel===0&&(a.audio.audioLevel=((u=c.getLocalStream())===null||u===void 0?void 0:u.getInternalAudioLevel())||0),k.next=15;break;case 12:k.prev=12,k.t0=k.catch(4),this.log_.warn("failed to getStats on sender connection "+k.t0);case 15:return k.abrupt("return",a);case 16:case"end":return k.stop()}},o,this,[[4,12]])})),function(o){return r.apply(this,arguments)})},{key:"getReceiverStats",value:(i=H(f().mark(function o(c){var a,s,l,u,p,k=this;return f().wrap(function(x){for(;;)switch(x.prev=x.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())){x.next=16;break}return x.prev=3,l=c.getSSRC(),u=c.getTrackState(),x.next=8,s.getStats();case 8:x.sent.forEach(function(E){if(E.type==="inbound-rtp"){if(E.mediaType===Ee&&E.ssrc===l.audio&&u.audio)a.audio.packetsReceived=E.packetsReceived,a.audio.bytesReceived=E.bytesReceived,a.audio.packetsLost=E.packetsLost,a.audio.jitter=E.jitter,a.hasAudio=!0;else if(E.mediaType===Te){if(Tr&&E.bytesReceived===0)return;E.ssrc===l.video&&u.video&&(a.video.packetsReceived=E.packetsReceived,a.video.bytesReceived=E.bytesReceived,a.video.packetsLost=E.packetsLost,a.video.framesReceived=E.framesReceived,a.video.framesDecoded=E.framesDecoded,a.video.fpsDecoded=E.framesPerSecond,a.hasVideo=!0,!E.decoderImplementation||k.prevDecoderImplementationMap_.has(a.userId)&&k.prevDecoderImplementationMap_.get(a.userId)===E.decoderImplementation||(k.log_.info("".concat(a.userId," decoderImplementation change to ").concat(E.decoderImplementation)),k.prevDecoderImplementationMap_.set(a.userId,E.decoderImplementation))),E.ssrc===l.auxiliary&&u.auxiliary&&(a.auxiliary.packetsReceived=E.packetsReceived,a.auxiliary.bytesReceived=E.bytesReceived,a.auxiliary.packetsLost=E.packetsLost,a.auxiliary.framesReceived=E.framesReceived,a.auxiliary.framesDecoded=E.framesDecoded,a.auxiliary.fpsDecoded=E.framesPerSecond,a.hasAuxiliary=!0)}}else E.type==="candidate-pair"&&ym(E)&&$n(E.currentRoundTripTime)&&(a.rtt=Math.floor(1e3*E.currentRoundTripTime));ge(E.frameWidth)||(E.trackIdentifier!==c.getMainStreamVideoTrackId()&&E.ssrc!==l.video||(a.video.frameWidth=E.frameWidth,a.video.frameHeight=E.frameHeight),E.trackIdentifier!==c.getAuxStreamVideoTrackId()&&E.ssrc!==l.auxiliary||(a.auxiliary.frameWidth=E.frameWidth,a.auxiliary.frameHeight=E.frameHeight)),ge(E.audioLevel)||(a.audio.audioLevel=E.audioLevel||0,a.audio.totalAudioEnergy=E.totalAudioEnergy||0)}),a.audio.audioLevel===0&&(a.audio.audioLevel=((p=c.getMainStream())===null||p===void 0?void 0:p.getInternalAudioLevel())||0),x.next=16;break;case 13:x.prev=13,x.t0=x.catch(3),this.log_.warn("failed to getStats on receiver connection "+x.t0);case 16:return x.abrupt("return",a);case 17:case"end":return x.stop()}},o,this,[[3,13]])})),function(o){return i.apply(this,arguments)})},{key:"getStats",value:(n=H(f().mark(function o(c,a){var s,l,u,p,k,x,E;return f().wrap(function(I){for(;;)switch(I.prev=I.next){case 0:if(s={},!c){I.next=5;break}return I.next=4,this.getSenderStats(c);case 4:s=I.sent;case 5:l=[],u=oe(a),I.prev=7,u.s();case 9:if((p=u.n()).done){I.next=17;break}return(k=ke(p.value,2))[0],x=k[1],I.next=13,this.getReceiverStats(x);case 13:E=I.sent,l.push(E);case 15:I.next=9;break;case 17:I.next=22;break;case 19:I.prev=19,I.t0=I.catch(7),u.e(I.t0);case 22:return I.prev=22,u.f(),I.finish(22);case 25:return I.abrupt("return",{senderStats:s,receiverStats:l});case 26:case"end":return I.stop()}},o,this,[[7,19,22,25]])})),function(o,c){return n.apply(this,arguments)})},{key:"getDifferenceValue",value:function(o,c){if(Si(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(!Si(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 p=[],k={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(p.push(k),a.senderStats.small.bytesSent){var x={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};p.push(x)}if(a.senderStats.auxiliary.bytesSent){var E={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};p.push(E)}var I={uint32_bitrate:0,uint32_rtt:a.senderStats.rtt};s.msg_up_stream_info={msg_audio_status:u,msg_video_status:p,msg_network_status:I}}var m=this.statInterval;s.msg_down_stream_info=[],a.receiverStats.forEach(function(b){var R={};if(R.msg_user_info={str_identifier:b.userId,uint64_tinyid:b.tinyId},R.msg_network_status={uint32_rtt:b.rtt},R.msg_video_status={},b.hasAudio){var P={uint32_audio_codec_bitrate:b.audio.bytesReceived,uint32_audio_total_bitrate:b.audio.bytesReceived,uint32_audio_level:1e8*b.audio.audioLevel,uint32_audio_energy:1e6*b.audio.totalAudioEnergy,uint32_audio_receive:b.audio.packetsReceived,uint32_audio_origin_lost:b.audio.packetsLost,audioLevel:b.audio.audioLevel};R.msg_audio_status=P}if(R.msg_video_status=[],b.hasVideo){var V=l.get(b.userId+"_"+gt),S=V?V.duration:0,h={uint32_video_stream_type:2,uint32_video_receive_fps:b.video.framesReceived,uint32_video_width:b.video.frameWidth,uint32_video_height:b.video.frameHeight,uint32_video_codec_bitrate:b.video.bytesReceived,uint32_video_receive:b.video.packetsReceived,uint32_video_origin_lost:b.video.packetsLost,uint32_video_block_time:S,uint32_video_dec_fps:b.video.framesDecoded};R.msg_video_status.push(h)}if(b.hasAuxiliary){var y=l.get(b.userId+"_"+Dt),A=y?y.duration:0,D={uint32_video_stream_type:7,uint32_video_receive_fps:b.auxiliary.framesReceived,uint32_video_width:b.auxiliary.frameWidth,uint32_video_height:b.auxiliary.frameHeight,uint32_video_codec_bitrate:b.auxiliary.bytesReceived,uint32_video_receive:b.auxiliary.packetsReceived+b.auxiliary.packetsLost,uint32_video_origin_lost:b.auxiliary.packetsLost,uint32_video_block_time:A,uint32_video_dec_fps:b.auxiliary.framesDecoded};R.msg_video_status.push(D)}s.msg_down_stream_info.push(R)});var T=this.prevReport_;if(this.prevReport_=JSON.parse(JSON.stringify(s)),s.msg_up_stream_info.msg_audio_status&&T.msg_up_stream_info.msg_audio_status){var v=T.msg_up_stream_info.msg_audio_status,C=s.msg_up_stream_info.msg_audio_status,O=this.getDifferenceValue(v.uint32_audio_codec_bitrate,C.uint32_audio_codec_bitrate);C.uint32_audio_codec_bitrate=Math.round(8*O/m),s.msg_up_stream_info.msg_network_status.uint32_bitrate+=C.uint32_audio_codec_bitrate}var N=T.msg_up_stream_info.msg_video_status;s.msg_up_stream_info.msg_video_status.forEach(function(b){var R=N.find(function(y){return y.uint32_video_stream_type===b.uint32_video_stream_type});if(!R||R.uint32_video_codec_bitrate===0)return b.uint32_video_codec_bitrate=0,b.uint32_video_enc_fps=0,void(b.uint32_video_codec_fps=0);var P=R.uint32_video_codec_bitrate,V=R.uint32_video_enc_fps,S=R.uint32_video_codec_fps,h=c.getDifferenceValue(P,b.uint32_video_codec_bitrate);b.uint32_video_codec_bitrate=Math.round(8*h/m),s.msg_up_stream_info.msg_network_status.uint32_bitrate+=b.uint32_video_codec_bitrate,b.uint32_video_enc_fps=Math.round(c.getDifferenceValue(V,b.uint32_video_enc_fps)/m),b.uint32_video_codec_fps=Math.round(c.getDifferenceValue(S,b.uint32_video_codec_fps)/m)});var j=s.msg_down_stream_info,_=T.msg_down_stream_info;return j.forEach(function(b){var R=_.find(function(A){return A.msg_user_info.uint64_tinyid===b.msg_user_info.uint64_tinyid});if(R){if(b.msg_audio_status&&R.msg_audio_status){var P=b.msg_audio_status,V=R.msg_audio_status;P.uint32_audio_origin_lost=c.getDifferenceValue(V.uint32_audio_origin_lost,P.uint32_audio_origin_lost),P.uint32_audio_receive=c.getDifferenceValue(V.uint32_audio_receive,P.uint32_audio_receive),P.uint32_audio_receive+=P.uint32_audio_origin_lost;var S=c.getDifferenceValue(V.uint32_audio_codec_bitrate,P.uint32_audio_codec_bitrate);P.uint32_audio_codec_bitrate=Math.round(8*S/m),P.uint32_audio_total_bitrate=Math.round(8*S/m)}if(b.msg_video_status&&R.msg_video_status){var h=b.msg_video_status,y=R.msg_video_status;h.forEach(function(A){var D=y.find(function(Fe){return Fe.uint32_video_stream_type===A.uint32_video_stream_type});if(!D)return A.uint32_video_receive=0,A.uint32_video_origin_lost=0,A.uint32_video_codec_bitrate=0,A.uint32_video_receive_fps=0,void(A.uint32_video_dec_fps=0);var U=D.uint32_video_receive,K=D.uint32_video_origin_lost,J=D.uint32_video_codec_bitrate,ce=D.uint32_video_receive_fps,ae=D.uint32_video_dec_fps;A.uint32_video_origin_lost=c.getDifferenceValue(K,A.uint32_video_origin_lost),A.uint32_video_receive=c.getDifferenceValue(U,A.uint32_video_receive)+A.uint32_video_origin_lost;var qe=c.getDifferenceValue(J,A.uint32_video_codec_bitrate);A.uint32_video_codec_bitrate=Math.round(8*qe/m);var Ue=c.getDifferenceValue(ce,A.uint32_video_receive_fps);A.uint32_video_receive_fps=Math.round(Ue/m),A.uint32_video_dec_fps=Math.round(c.getDifferenceValue(ae,A.uint32_video_dec_fps)/m)})}}}),s}},{key:"getStatsReport",value:(t=H(f().mark(function o(c){var a,s,l,u,p;return f().wrap(function(k){for(;;)switch(k.prev=k.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}}]},k.next=4,this.getStats(a,s);case 4:return p=k.sent,JSON.stringify(this.prevReport_)==="{}"&&(this.prevReport_=JSON.parse(JSON.stringify(u))),this.prepareReport({stats:p,report:u,freezeMap:l,uplinkConnection:a,downlinkConnections:s}),this.prevReportTime_=Date.now(),k.abrupt("return",u);case 9:case"end":return k.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;Q(this,e),this.client_=c,this.signalChannel_=r,this.connections_=o,this.client_=c,this.log_=ye.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 bi,this.initialize()}var t,n;return Ie(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(mt.UPLINK_NETWORK_STATS,function(r){i.handleUplinkNetworkQuality(r)}),this.signalChannel_.on(em,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=H(f().mark(function i(){var r,o,c,a,s,l,u,p,k,x,E,I,m,T,v,C=this;return f().wrap(function(O){for(;;)switch(O.prev=O.next){case 0:if(this.connections_&&this.connections_.size!==0){O.next=3;break}return this.downlinkNetworkQuality=0,O.abrupt("return");case 3:if(r=Se(this.connections_.values()),o=r.filter(function(N){return N.getPeerConnection()&&N.getPeerConnection().connectionState===bb}),r.filter(function(N){return N.getPeerConnection()&&C.isPeerConnectionDisconnected(N.getPeerConnection())}).length!==r.length){O.next=9;break}return this.downlinkNetworkQuality=6,O.abrupt("return");case 9:c=0;case 10:if(!(c<o.length)){O.next=31;break}return a=o[c].getPeerConnection(),O.next=14,this.getStat(a);case 14:if(s=O.sent,l=s.rtt,u=s.totalPacketsLost,p=s.totalPacketsReceived,this.downlinkPrevStatMap_.has(a)){O.next=21;break}return this.downlinkPrevStatMap_.set(a,{totalPacketsLost:u,totalPacketsReceived:p}),O.abrupt("continue",28);case 21:k=0,x=this.downlinkPrevStatMap_.get(a),E=u-x.totalPacketsLost,I=p-x.totalPacketsReceived,k=E<=0||I<0?0:Math.round(E/(E+I)*100),this.downlinkPrevStatMap_.set(a,{totalPacketsLost:u,totalPacketsReceived:p}),this.downlinkLossAndRTTMap_.set(a,{rtt:l,loss:k,userId:o[c].getUserId()});case 28:c++,O.next=10;break;case 31:if(Se(this.downlinkPrevStatMap_.keys()).forEach(function(N){C.isPeerConnectionDisconnected(N)&&(C.downlinkPrevStatMap_.delete(N),C.downlinkLossAndRTTMap_.delete(N))}),this.downlinkLossAndRTTMap_.size!==0){O.next=34;break}return O.abrupt("return");case 34:m=this.getAverageLossAndRTT(Se(this.downlinkLossAndRTTMap_.values())),T=m.rtt,v=m.loss,this.downlinkRTT_=T,this.downlinkLoss_=v,this.downlinkNetworkQuality=this.getNetworkQuality(v,T);case 38:case"end":return O.stop()}},i,this)})),function(){return n.apply(this,arguments)})},{key:"getStat",value:(t=H(f().mark(function i(r){var o,c,a,s;return f().wrap(function(l){for(;;)switch(l.prev=l.next){case 0:if(o={rtt:0,totalPacketsLost:0,totalPacketsReceived:0},r&&Mk()){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"&&$n(u.currentRoundTripTime)&&(o.rtt=Math.round(1e3*u.currentRoundTripTime)),u.type!=="inbound-rtp"||u.mediaType!==Ee&&u.mediaType!==Te||(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===hl?(this.uplinkRTT_=0,this.uplinkLoss_=0,this.uplinkNetworkQuality=6):i.state===ac&&this.uplinkNetworkQuality===6&&(this.uplinkNetworkQuality=5)}},{key:"handleUplinkConnectionStateChange",value:function(i){var r=i.state;r===an?(this.uplinkLoss_=0,this.uplinkRTT_=0,this.uplinkNetworkQuality=6):r===fn&&this.uplinkNetworkQuality===6&&(this.uplinkNetworkQuality=5)}},{key:"isPeerConnectionDisconnected",value:function(i){return!(!i||i.connectionState!==qM&&i.connectionState!==yb&&i.connectionState!==Uf)}},{key:"setUplinkConnection",value:function(i){this.uplinkConnection_=i,this.uplinkConnection_?this.uplinkConnection_.on(et.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_=_t.run(so,function(){i.handleDownlinkNetworkQuality(),Y.emit(Kp,{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(st.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&&(_t.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}(),QV=function(){function e(i){Q(this,e),this.log_=ye.createLogger({id:i.client.getUserId(),userId:i.client.getUserId(),sdkAppId:i.client.getSDKAppId()}),this.localStream_=null,this.prevDevices_=[],this.initialize()}var t,n;return Ie(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=H(f().mark(function i(){var r,o,c,a=this;return f().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,Tm();case 4:r=s.sent,o=r.filter(function(l){return a.prevDevices_.findIndex(function(u){var p=u.deviceId;return l.deviceId===p})<0}),c=this.prevDevices_.filter(function(l){return r.findIndex(function(u){var p=u.deviceId;return l.deviceId===p})<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=H(f().mark(function i(r){return f().wrap(function(o){for(;;)switch(o.prev=o.next){case 0:if(!r){o.next=4;break}return o.next=3,Tm();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(x){return x.kind===Fu}),s=r.filter(function(x){return x.kind===qs}),l=i.filter(function(x){return x.kind===Fu}),u=i.filter(function(x){return x.kind===qs}),p=a.length>0&&l.length===0&&((o=this.localStream_.getVideoTrack())===null||o===void 0?void 0:o.readyState)!=="live",k=s.length>0&&u.length===0&&((c=this.localStream_.getAudioTrack())===null||c===void 0?void 0:c.readyState)!=="live";if(k&&p)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});p&&(this.log_.info("new camera detected, but there was no camera before."),this.localStream_.recoverCapture({audio:!1,video:!0,cameraId:a[0].deviceId})),k&&(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===Ju){var l=this.localStream_.getMicrophoneGroupId(),u=i.filter(function(p){return p.deviceId===Ju&&p.kind===qs})[0];u&&u.groupId!==l&&(c=!0)}if(r.forEach(function(p){var k=p.deviceId;a.length>0&&k===a?o=!0:s.length>0&&k===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 km(){return km=H(f().mark(function e(){var t;return f().wrap(function(n){for(;;)switch(n.prev=n.next){case 0:if(!ml()&&!pl()){n.next=2;break}return n.abrupt("return",[]);case 2:return n.next=4,vl();case 4:return t=n.sent,n.abrupt("return",t.filter(function(i){return i.kind===Fu}).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)})),km.apply(this,arguments)}var Bk=new Set;function vl(){return Fk.apply(this,arguments)}function Fk(){return(Fk=H(f().mark(function e(){var t;return f().wrap(function(n){for(;;)switch(n.prev=n.next){case 0:if(!ml()&&!pl()){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){Bk.add("".concat(i.deviceId,"_").concat(i.kind))}),n.abrupt("return",t);case 7:case"end":return n.stop()}},e)}))).apply(this,arguments)}function Tm(){return xm.apply(this,arguments)}function xm(){return xm=H(f().mark(function e(){var t;return f().wrap(function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,vl();case 2:return t=n.sent,n.abrupt("return",t.filter(function(i){return i.kind!==qs||i.deviceId!=Qb}).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)})),xm.apply(this,arguments)}function Hk(){return Im.apply(this,arguments)}function Im(){return Im=H(f().mark(function e(){var t;return f().wrap(function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,vl();case 2:return t=n.sent,n.abrupt("return",t.filter(function(i){return i.kind===qs&&i.deviceId!==Qb}).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)})),Im.apply(this,arguments)}function Gk(){return wm.apply(this,arguments)}function wm(){return wm=H(f().mark(function e(){var t;return f().wrap(function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,vl();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)})),wm.apply(this,arguments)}function YV(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(Fu);return!!Bk.has(i)}function $V(e,t){return zk.apply(this,arguments)}function zk(){return(zk=H(f().mark(function e(t,n){var i,r;return f().wrap(function(o){for(;;)switch(o.prev=o.next){case 0:return o.next=2,Hk();case 2:if(i=o.sent,((r=i.find(function(c){return c.deviceId===Ju}))==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 Vn,Wk=Vi.exports,ZV=At,e6=Tt,t6=Zg,n6=Lr,r6=Xe,i6=Vt,a6=function(e,t,n,i){try{return i?t(e6(n)[0],n[1]):t(n)}catch(r){t6(e,"throw",r)}},o6=sh,s6=_u,c6=tn,qk=ws,u6=fu,l6=Cs,Jk=Array,Kk=function(e){var t=i6(e),n=s6(this),i=arguments.length,r=i>1?arguments[1]:void 0,o=r!==void 0;o&&(r=n6(r,i>2?arguments[2]:void 0));var c,a,s,l,u,p,k=l6(t),x=0;if(!k||this===Jk&&o6(k))for(c=c6(t),a=n?new this(c):Jk(c);c>x;x++)p=o?r(t[x],x):t[x],qk(a,x,p);else for(u=(l=u6(t,k)).next,a=n?new this:[];!(s=r6(u,l)).done;x++)p=o?a6(l,r,[s.value,x],!0):s.value,qk(a,x,p);return a.length=x,a},sa=pe,Cm=2147483647,d6=/[^\0-\u007E]/,Xk=/[.\u3002\uFF0E\uFF61]/g,Qk="Overflow: input needs wider integers to process",Yk=RangeError,h6=sa(Xk.exec),bo=Math.floor,Em=String.fromCharCode,$k=sa("".charCodeAt),Zk=sa([].join),Ti=sa([].push),f6=sa("".replace),p6=sa("".split),m6=sa("".toLowerCase),eT=function(e){return e+22+75*(e<26)},v6=function(e,t,n){var i=0;for(e=n?bo(e/700):e>>1,e+=bo(e/t);e>455;)e=bo(e/35),i+=36;return bo(i+36*e/(e+38))},g6=function(e){var t=[];e=function(T){for(var v=[],C=0,O=T.length;C<O;){var N=$k(T,C++);if(N>=55296&&N<=56319&&C<O){var j=$k(T,C++);(64512&j)==56320?Ti(v,((1023&N)<<10)+(1023&j)+65536):(Ti(v,N),C--)}else Ti(v,N)}return v}(e);var n,i,r=e.length,o=128,c=0,a=72;for(n=0;n<e.length;n++)(i=e[n])<128&&Ti(t,Em(i));var s=t.length,l=s;for(s&&Ti(t,"-");l<r;){var u=Cm;for(n=0;n<e.length;n++)(i=e[n])>=o&&i<u&&(u=i);var p=l+1;if(u-o>bo((Cm-c)/p))throw Yk(Qk);for(c+=(u-o)*p,o=u,n=0;n<e.length;n++){if((i=e[n])<o&&++c>Cm)throw Yk(Qk);if(i==o){for(var k=c,x=36;;){var E=x<=a?1:x>=a+26?26:x-a;if(k<E)break;var I=k-E,m=36-E;Ti(t,Em(eT(E+I%m))),k=bo(I/m),x+=36}Ti(t,Em(eT(k))),a=v6(c,p,l==s),c=0,l++}}c++,o++}return Zk(t,"")},_6=Me,Rm=_e,y6=ky,Am=re,tT=Lr,jn=pe,gl=Xt,Bn=function(e,t,n){return n.get&&Wk(n.get,t,{getter:!0}),n.set&&Wk(n.set,t,{setter:!0}),ZV.f(e,t,n)},b6=ai,Pm=kt,Dm=ek,So=Kk,tr=du,S6=fh.codeAt,k6=function(e){var t,n,i=[],r=p6(f6(m6(e),Xk,"."),".");for(t=0;t<r.length;t++)n=r[t],Ti(i,h6(d6,n)?"xn--"+g6(n):n);return Zk(i,".")},Fr=zt,T6=Hi,x6=gu,nT=xD,rT=Ke,I6=rT.set,_l=rT.getterFor("URL"),w6=nT.URLSearchParams,C6=nT.getState,uc=Am.URL,Lm=Am.TypeError,yl=Am.parseInt,E6=Math.floor,iT=Math.pow,Fn=jn("".charAt),nr=jn(/./.exec),lc=jn([].join),R6=jn(1 .toString),A6=jn([].pop),ko=jn([].push),aT=jn("".replace),P6=jn([].shift),D6=jn("".split),dc=jn("".slice),bl=jn("".toLowerCase),L6=jn([].unshift),Om="Invalid scheme",ca="Invalid host",oT="Invalid port",sT=/[a-z]/i,O6=/[\d+-.a-z]/i,Mm=/\d/,M6=/^0x/i,N6=/^[0-7]+$/,U6=/^\d+$/,cT=/^[\da-f]+$/i,V6=/[\0\t\n\r #%/:<>?@[\\\]^|]/,j6=/[\0\t\n\r #/:<>?@[\\\]^|]/,B6=/^[\u0000-\u0020]+|[\u0000-\u0020]+$/g,F6=/[\t\n\r]/g,hc=function(e){var t,n,i,r;if(typeof e=="number"){for(t=[],n=0;n<4;n++)L6(t,e%256),e=E6(e/256);return lc(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+=R6(e[n],16),n<7&&(t+=":")));return"["+t+"]"}return e},Sl={},uT=Dm({},Sl,{" ":1,'"':1,"<":1,">":1,"`":1}),lT=Dm({},uT,{"#":1,"?":1,"{":1,"}":1}),Nm=Dm({},lT,{"/":1,":":1,";":1,"=":1,"@":1,"[":1,"\\":1,"]":1,"^":1,"|":1}),xi=function(e,t){var n=S6(e,0);return n>32&&n<127&&!Pm(t,e)?e:encodeURIComponent(e)},kl={ftp:21,file:null,http:80,https:443,ws:80,wss:443},fc=function(e,t){var n;return e.length==2&&nr(sT,Fn(e,0))&&((n=Fn(e,1))==":"||!t&&n=="|")},dT=function(e){var t;return e.length>1&&fc(dc(e,0,2))&&(e.length==2||(t=Fn(e,2))==="/"||t==="\\"||t==="?"||t==="#")},H6=function(e){return e==="."||bl(e)==="%2e"},Um={},hT={},Vm={},fT={},pT={},jm={},mT={},vT={},Tl={},xl={},Bm={},Fm={},Hm={},Gm={},gT={},zm={},To={},xr={},_T={},ua={},Hr={},Wm=function(e,t,n){var i,r,o,c=Fr(e);if(t){if(r=this.parse(c))throw Lm(r);this.searchParams=null}else{if(n!==void 0&&(i=new Wm(n,!0)),r=this.parse(c,null,i))throw Lm(r);(o=C6(new w6)).bindURL(this),this.searchParams=o}};Wm.prototype={type:"URL",parse:function(e,t,n){var i,r,o,c,a,s=this,l=t||Um,u=0,p="",k=!1,x=!1,E=!1;for(e=Fr(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=aT(e,B6,"")),e=aT(e,F6,""),i=So(e);u<=i.length;){switch(r=i[u],l){case Um:if(!r||!nr(sT,r)){if(t)return Om;l=Vm;continue}p+=bl(r),l=hT;break;case hT:if(r&&(nr(O6,r)||r=="+"||r=="-"||r=="."))p+=bl(r);else{if(r!=":"){if(t)return Om;p="",l=Vm,u=0;continue}if(t&&(s.isSpecial()!=Pm(kl,p)||p=="file"&&(s.includesCredentials()||s.port!==null)||s.scheme=="file"&&!s.host))return;if(s.scheme=p,t)return void(s.isSpecial()&&kl[s.scheme]==s.port&&(s.port=null));p="",s.scheme=="file"?l=Gm:s.isSpecial()&&n&&n.scheme==s.scheme?l=fT:s.isSpecial()?l=vT:i[u+1]=="/"?(l=pT,u++):(s.cannotBeABaseURL=!0,ko(s.path,""),l=_T)}break;case Vm:if(!n||n.cannotBeABaseURL&&r!="#")return Om;if(n.cannotBeABaseURL&&r=="#"){s.scheme=n.scheme,s.path=tr(n.path),s.query=n.query,s.fragment="",s.cannotBeABaseURL=!0,l=Hr;break}l=n.scheme=="file"?Gm:jm;continue;case fT:if(r!="/"||i[u+1]!="/"){l=jm;continue}l=Tl,u++;break;case pT:if(r=="/"){l=xl;break}l=xr;continue;case jm:if(s.scheme=n.scheme,r==Vn)s.username=n.username,s.password=n.password,s.host=n.host,s.port=n.port,s.path=tr(n.path),s.query=n.query;else if(r=="/"||r=="\\"&&s.isSpecial())l=mT;else if(r=="?")s.username=n.username,s.password=n.password,s.host=n.host,s.port=n.port,s.path=tr(n.path),s.query="",l=ua;else{if(r!="#"){s.username=n.username,s.password=n.password,s.host=n.host,s.port=n.port,s.path=tr(n.path),s.path.length--,l=xr;continue}s.username=n.username,s.password=n.password,s.host=n.host,s.port=n.port,s.path=tr(n.path),s.query=n.query,s.fragment="",l=Hr}break;case mT:if(!s.isSpecial()||r!="/"&&r!="\\"){if(r!="/"){s.username=n.username,s.password=n.password,s.host=n.host,s.port=n.port,l=xr;continue}l=xl}else l=Tl;break;case vT:if(l=Tl,r!="/"||Fn(p,u+1)!="/")continue;u++;break;case Tl:if(r!="/"&&r!="\\"){l=xl;continue}break;case xl:if(r=="@"){k&&(p="%40"+p),k=!0,o=So(p);for(var I=0;I<o.length;I++){var m=o[I];if(m!=":"||E){var T=xi(m,Nm);E?s.password+=T:s.username+=T}else E=!0}p=""}else if(r==Vn||r=="/"||r=="?"||r=="#"||r=="\\"&&s.isSpecial()){if(k&&p=="")return"Invalid authority";u-=So(p).length+1,p="",l=Bm}else p+=r;break;case Bm:case Fm:if(t&&s.scheme=="file"){l=zm;continue}if(r!=":"||x){if(r==Vn||r=="/"||r=="?"||r=="#"||r=="\\"&&s.isSpecial()){if(s.isSpecial()&&p=="")return ca;if(t&&p==""&&(s.includesCredentials()||s.port!==null))return;if(c=s.parseHost(p))return c;if(p="",l=To,t)return;continue}r=="["?x=!0:r=="]"&&(x=!1),p+=r}else{if(p=="")return ca;if(c=s.parseHost(p))return c;if(p="",l=Hm,t==Fm)return}break;case Hm:if(!nr(Mm,r)){if(r==Vn||r=="/"||r=="?"||r=="#"||r=="\\"&&s.isSpecial()||t){if(p!=""){var v=yl(p,10);if(v>65535)return oT;s.port=s.isSpecial()&&v===kl[s.scheme]?null:v,p=""}if(t)return;l=To;continue}return oT}p+=r;break;case Gm:if(s.scheme="file",r=="/"||r=="\\")l=gT;else{if(!n||n.scheme!="file"){l=xr;continue}if(r==Vn)s.host=n.host,s.path=tr(n.path),s.query=n.query;else if(r=="?")s.host=n.host,s.path=tr(n.path),s.query="",l=ua;else{if(r!="#"){dT(lc(tr(i,u),""))||(s.host=n.host,s.path=tr(n.path),s.shortenPath()),l=xr;continue}s.host=n.host,s.path=tr(n.path),s.query=n.query,s.fragment="",l=Hr}}break;case gT:if(r=="/"||r=="\\"){l=zm;break}n&&n.scheme=="file"&&!dT(lc(tr(i,u),""))&&(fc(n.path[0],!0)?ko(s.path,n.path[0]):s.host=n.host),l=xr;continue;case zm:if(r==Vn||r=="/"||r=="\\"||r=="?"||r=="#"){if(!t&&fc(p))l=xr;else if(p==""){if(s.host="",t)return;l=To}else{if(c=s.parseHost(p))return c;if(s.host=="localhost"&&(s.host=""),t)return;p="",l=To}continue}p+=r;break;case To:if(s.isSpecial()){if(l=xr,r!="/"&&r!="\\")continue}else if(t||r!="?")if(t||r!="#"){if(r!=Vn&&(l=xr,r!="/"))continue}else s.fragment="",l=Hr;else s.query="",l=ua;break;case xr:if(r==Vn||r=="/"||r=="\\"&&s.isSpecial()||!t&&(r=="?"||r=="#")){if((a=bl(a=p))===".."||a==="%2e."||a===".%2e"||a==="%2e%2e"?(s.shortenPath(),r=="/"||r=="\\"&&s.isSpecial()||ko(s.path,"")):H6(p)?r=="/"||r=="\\"&&s.isSpecial()||ko(s.path,""):(s.scheme=="file"&&!s.path.length&&fc(p)&&(s.host&&(s.host=""),p=Fn(p,0)+":"),ko(s.path,p)),p="",s.scheme=="file"&&(r==Vn||r=="?"||r=="#"))for(;s.path.length>1&&s.path[0]==="";)P6(s.path);r=="?"?(s.query="",l=ua):r=="#"&&(s.fragment="",l=Hr)}else p+=xi(r,lT);break;case _T:r=="?"?(s.query="",l=ua):r=="#"?(s.fragment="",l=Hr):r!=Vn&&(s.path[0]+=xi(r,Sl));break;case ua:t||r!="#"?r!=Vn&&(r=="'"&&s.isSpecial()?s.query+="%27":s.query+=r=="#"?"%23":xi(r,Sl)):(s.fragment="",l=Hr);break;case Hr:r!=Vn&&(s.fragment+=xi(r,uT))}u++}},parseHost:function(e){var t,n,i;if(Fn(e,0)=="["){if(Fn(e,e.length-1)!="]"||(t=function(r){var o,c,a,s,l,u,p,k=[0,0,0,0,0,0,0,0],x=0,E=null,I=0,m=function(){return Fn(r,I)};if(m()==":"){if(Fn(r,1)!=":")return;I+=2,E=++x}for(;m();){if(x==8)return;if(m()!=":"){for(o=c=0;c<4&&nr(cT,m());)o=16*o+yl(m(),16),I++,c++;if(m()=="."){if(c==0||(I-=c,x>6))return;for(a=0;m();){if(s=null,a>0){if(!(m()=="."&&a<4))return;I++}if(!nr(Mm,m()))return;for(;nr(Mm,m());){if(l=yl(m(),10),s===null)s=l;else{if(s==0)return;s=10*s+l}if(s>255)return;I++}k[x]=256*k[x]+s,++a!=2&&a!=4||x++}if(a!=4)return;break}if(m()==":"){if(I++,!m())return}else if(m())return;k[x++]=o}else{if(E!==null)return;I++,E=++x}}if(E!==null)for(u=x-E,x=7;x!=0&&u>0;)p=k[x],k[x--]=k[E+u-1],k[E+--u]=p;else if(x!=8)return;return k}(dc(e,1,-1)),!t))return ca;this.host=t}else if(this.isSpecial()){if(e=k6(e),nr(V6,e)||(t=function(r){var o,c,a,s,l,u,p,k=D6(r,".");if(k.length&&k[k.length-1]==""&&k.length--,(o=k.length)>4)return r;for(c=[],a=0;a<o;a++){if((s=k[a])=="")return r;if(l=10,s.length>1&&Fn(s,0)=="0"&&(l=nr(M6,s)?16:8,s=dc(s,l==8?1:2)),s==="")u=0;else{if(!nr(l==10?U6:l==8?N6:cT,s))return r;u=yl(s,l)}ko(c,u)}for(a=0;a<o;a++)if(u=c[a],a==o-1){if(u>=iT(256,5-o))return null}else if(u>255)return null;for(p=A6(c),a=0;a<c.length;a++)p+=c[a]*iT(256,3-a);return p}(e),t===null))return ca;this.host=t}else{if(nr(j6,e))return ca;for(t="",n=So(e),i=0;i<n.length;i++)t+=xi(n[i],Sl);this.host=t}},cannotHaveUsernamePasswordPort:function(){return!this.host||this.cannotBeABaseURL||this.scheme=="file"},includesCredentials:function(){return this.username!=""||this.password!=""},isSpecial:function(){return Pm(kl,this.scheme)},shortenPath:function(){var e=this.path,t=e.length;!t||this.scheme=="file"&&t==1&&fc(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+=hc(r),o!==null&&(l+=":"+o)):t=="file"&&(l+="//"),l+=e.cannotBeABaseURL?c[0]:c.length?"/"+lc(c,"/"):"",a!==null&&(l+="?"+a),s!==null&&(l+="#"+s),l},setHref:function(e){var t=this.parse(e);if(t)throw Lm(t);this.searchParams.update()},getOrigin:function(){var e=this.scheme,t=this.port;if(e=="blob")try{return new xo(e.path[0]).origin}catch(n){return"null"}return e!="file"&&this.isSpecial()?e+"://"+hc(this.host)+(t!==null?":"+t:""):"null"},getProtocol:function(){return this.scheme+":"},setProtocol:function(e){this.parse(Fr(e)+":",Um)},getUsername:function(){return this.username},setUsername:function(e){var t=So(Fr(e));if(!this.cannotHaveUsernamePasswordPort()){this.username="";for(var n=0;n<t.length;n++)this.username+=xi(t[n],Nm)}},getPassword:function(){return this.password},setPassword:function(e){var t=So(Fr(e));if(!this.cannotHaveUsernamePasswordPort()){this.password="";for(var n=0;n<t.length;n++)this.password+=xi(t[n],Nm)}},getHost:function(){var e=this.host,t=this.port;return e===null?"":t===null?hc(e):hc(e)+":"+t},setHost:function(e){this.cannotBeABaseURL||this.parse(e,Bm)},getHostname:function(){var e=this.host;return e===null?"":hc(e)},setHostname:function(e){this.cannotBeABaseURL||this.parse(e,Fm)},getPort:function(){var e=this.port;return e===null?"":Fr(e)},setPort:function(e){this.cannotHaveUsernamePasswordPort()||((e=Fr(e))==""?this.port=null:this.parse(e,Hm))},getPathname:function(){var e=this.path;return this.cannotBeABaseURL?e[0]:e.length?"/"+lc(e,"/"):""},setPathname:function(e){this.cannotBeABaseURL||(this.path=[],this.parse(e,To))},getSearch:function(){var e=this.query;return e?"?"+e:""},setSearch:function(e){(e=Fr(e))==""?this.query=null:(Fn(e,0)=="?"&&(e=dc(e,1)),this.query="",this.parse(e,ua)),this.searchParams.update()},getSearchParams:function(){return this.searchParams.facade},getHash:function(){var e=this.fragment;return e?"#"+e:""},setHash:function(e){(e=Fr(e))!=""?(Fn(e,0)=="#"&&(e=dc(e,1)),this.fragment="",this.parse(e,Hr)):this.fragment=null},update:function(){this.query=this.searchParams.serialize()||null}};var xo=function(e){var t=b6(this,un),n=x6(arguments.length,1)>1?arguments[1]:void 0,i=I6(t,new Wm(e,!1,n));Rm||(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())},un=xo.prototype,Hn=function(e,t){return{get:function(){return _l(this)[e]()},set:t&&function(n){return _l(this)[t](n)},configurable:!0,enumerable:!0}};if(Rm&&(Bn(un,"href",Hn("serialize","setHref")),Bn(un,"origin",Hn("getOrigin")),Bn(un,"protocol",Hn("getProtocol","setProtocol")),Bn(un,"username",Hn("getUsername","setUsername")),Bn(un,"password",Hn("getPassword","setPassword")),Bn(un,"host",Hn("getHost","setHost")),Bn(un,"hostname",Hn("getHostname","setHostname")),Bn(un,"port",Hn("getPort","setPort")),Bn(un,"pathname",Hn("getPathname","setPathname")),Bn(un,"search",Hn("getSearch","setSearch")),Bn(un,"searchParams",Hn("getSearchParams")),Bn(un,"hash",Hn("getHash","setHash"))),gl(un,"toJSON",function(){return _l(this).serialize()},{enumerable:!0}),gl(un,"toString",function(){return _l(this).serialize()},{enumerable:!0}),uc){var yT=uc.createObjectURL,bT=uc.revokeObjectURL;yT&&gl(xo,"createObjectURL",tT(yT,uc)),bT&&gl(xo,"revokeObjectURL",tT(bT,uc))}T6(xo,"URL"),_6({global:!0,constructor:!0,forced:!y6,sham:!Rm},{URL:xo});var la,Il,G6=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"}),ST=!1,z6=function(){function e(n){Q(this,e),this.context_=n.context,this.addModuleToContext()}var t;return Ie(e,[{key:"addModuleToContext",value:(t=H(f().mark(function n(){return f().wrap(function(i){for(;;)switch(i.prev=i.next){case 0:return i.prev=0,i.next=3,this.context_.audioWorklet.addModule(URL.createObjectURL(G6));case 3:ye.info("worklet addModule success"),Y.emit(Xp),ST=!0,i.next=12;break;case 8:i.prev=8,i.t0=i.catch(0),ye.info("worklet addModule catch error. ".concat(i.t0.message)),Y.emit(Qp);case 12:case"end":return i.stop()}},n,this,[[0,8]])})),function(){return t.apply(this,arguments)})},{key:"initWorkletSuccess",get:function(){return ST}}]),e}(),pc=0,W6=function(){function e(t){Q(this,e);var n=t.track,i=t.log,r=t.stream;this.volume_=0,this.log_=i,this.track_=n,this.stream_=r,pc+=1,la||(la=US()),this.audioCtx_=la,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,Y.on(nc,this.resume,this),Y.on(Lp,this.handleAudioLevelInterval,this),w4?(Y.on(Xp,this.initAudioWorklet,this),Y.on(Qp,this.initScriptProcessor,this),this.preload()):this.initScriptProcessor()}return Ie(e,[{key:"preload",value:function(){Il?Il.initWorkletSuccess&&this.initAudioWorklet():Il=new z6({context:la})}},{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),pc-=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,Y.off(nc,this.resume,this),Y.off(Lp,this.handleAudioLevelInterval,this),Y.off(Xp,this.initAudioWorklet,this),Y.off(Qp,this.initScriptProcessor,this),pc>0&&(pc-=1),pc===0&&((t=la)===null||t===void 0||t.close(),la=null,Il=null)}},{key:"resume",value:function(){var t;(t=la)===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}(),q6=function(){function e(o){Q(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 bi,this.initializeElement(),this.state_="NONE",this.volumeMeter_=new W6({stream:this.stream_,track:this.gainedTrack_||this.track_,log:this.log_})}var t,n,i,r;return Ie(e,[{key:"isPlaying",get:function(){return this.state_===ro}},{key:"initializeElement",value:function(){if(this.isAudioElementInit()){var o=new MediaStream;o.addTrack(this.gainedTrack_||this.track_);var c=document.createElement(Ee);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=H(f().mark(function o(){var c;return f().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=ie({key:Zf,data:{media:"Audio",error:a.t0}}),this.log_.warn(c),!c.includes("NotAllowedError")){a.next=16;break}throw new ne({code:ee.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(li,this.handleElementEvent),this.element_.addEventListener(Mt,this.handleElementEvent),this.element_.addEventListener(di,this.handleElementEvent),this.element_.addEventListener(no,this.handleElementEvent)),this.track_.addEventListener(Mt,this.handleTrackEvent),this.track_.addEventListener(en,this.handleTrackEvent),this.track_.addEventListener(_r,this.handleTrackEvent),this.track_.readyState===Mt&&this.handleTrackEvent({type:Mt}),this.track_.muted&&this.handleTrackEvent({type:en})}},{key:"handleElementEvent",value:(i=H(f().mark(function o(c){var a,s,l,u,p,k,x,E=this;return f().wrap(function(I){for(;;)switch(I.prev=I.next){case 0:a=c.type,I.t0=a,I.next=I.t0===li?4:I.t0===Mt?9:I.t0===di?12:I.t0===no?21:32;break;case 4:return this.log_.info("audio player is playing"),this.state_=ro,Y.emit(Mp,{stream:this.stream_}),this.emitter_.emit(vn,{state:this.state_,reason:li}),I.abrupt("break",32);case 9:return this.log_.info("audio player is ended"),this.state_!==hi&&(this.state_=hi,this.emitter_.emit(vn,{state:this.state_,reason:Mt})),I.abrupt("break",32);case 12:return this.log_.info("audio player is paused"),this.state_=yr,this.emitter_.emit(vn,{state:this.state_,reason:di}),(s=this.div_&&document.getElementById(this.div_.id))||this.log_.warn("audio player has been remove, element ID: ".concat(this.div_.id)),l=co(),this.pausedRetryCount_>0&&($n(l)&&l<=70||!s)&&(this.resume(),this.pausedRetryCount_--),vi&&(this.interval_=_t.run(function(){E.element_&&E.state_===yr&&E.resume()},{delay:3e3})),I.abrupt("break",32);case 21:if(!this.element_||!this.element_.error){I.next=31;break}return u="".concat(bm(),"/").concat(na().name,"/").concat(na().version),I.next=25,xt.getSpeakers();case 25:p=I.sent,k=p[0].label,(x=p.find(function(m){return m.deviceId===E.outputDeviceId_}))&&(k=x.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(k)),xe.uploadEvent({log:"stat-".concat(this.stream_.getType(),"-audio-").concat(Vb,"-").concat(this.element_.error.code,"-").concat(u,"-").concat(k),userId:this.userId_,error:this.element_.error});case 31:return I.abrupt("break",32);case 32:case"end":return I.stop()}},o,this)})),function(o){return i.apply(this,arguments)})},{key:"handleTrackEvent",value:function(o){var c=o.type;switch(c){case Mt:this.log_.info("audio track is ended"),this.state_!==hi&&(this.state_=hi,this.emitter_.emit(vn,{state:this.state_,reason:Mt})),Y.emit(qp,{stream:this.stream_,type:c});break;case en:this.log_.info("audio track is unable to provide media output"),this.stream_.isRemote()||NS(),this.state_!==yr&&(this.state_=yr,this.emitter_.emit(vn,{state:this.state_,reason:en})),Y.emit(Wp,{stream:this.stream_,type:c});break;case _r:this.log_.info("audio track is able to provide media output"),this.state_===yr&&(this.state_=ro,this.emitter_.emit(vn,{state:this.state_,reason:_r}))}}},{key:"unbindEvents",value:function(){this.element_&&(this.element_.removeEventListener(li,this.handleElementEvent),this.element_.removeEventListener(Mt,this.handleElementEvent),this.element_.removeEventListener(di,this.handleElementEvent),this.element_.removeEventListener(no,this.handleElementEvent)),this.track_&&(this.track_.removeEventListener(Mt,this.handleTrackEvent),this.track_.removeEventListener(en,this.handleTrackEvent),this.track_.removeEventListener(_r,this.handleTrackEvent))}},{key:"setSinkId",value:(n=H(f().mark(function o(c){return f().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&&_t.clearTask(this.interval_)}},{key:"resume",value:(t=H(f().mark(function o(){var c;return f().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=ie({key:Zf,data:{media:"Audio",error:a.t0}}),this.log_.warn(c),!c.includes("NotAllowedError")){a.next=13;break}throw new ne({code:ee.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!(gi==="15.2"||gi==="15.3"||gi==="15.4")||this.stream_.getType()!=="local"||!this.muted_||(this.log_.info("audioElement is muted."),!1)}}]),e}(),J6=Xn.PROPER,K6=ue,kT=a0,X6=Ru.trim;Me({target:"String",proto:!0,forced:function(e){return K6(function(){return!!kT[e]()||"\u200B\x85\u180E"[e]()!=="\u200B\x85\u180E"||J6&&kT[e].name!==e})}("trim")},{trim:function(){return X6(this)}});var Gr="trtc_autoplay",qm="".concat(Gr,"_mask"),Io="".concat(Gr,"_wrapper"),TT="".concat(Gr,"_header"),Jm="".concat(Gr,"_content"),wl="".concat(Gr,"_action_wrapper"),Km="".concat(Gr,"_question"),Xm="".concat(Gr,"_collapse"),Cl="".concat(Gr,"_action_confirm"),xT="".concat(Gr,"_detail"),IT="#2473E8",Qm="dialog",Q6="".concat(Qm,"-show"),Y6="".concat(Qm,"-1"),$6="".concat(Qm,"-2"),wT=!1,CT=function(){return!!document.querySelector(".".concat(Io))},ET="".concat(oo,"/").concat(ra()?"zh-cn":"en","/tutorial-21-advanced-auto-play-policy.html"),RT="<br><a href='".concat(ET,"' target='_blank'>").concat(ra()?"\u5176\u4ED6\u65B9\u6848\uFF1F":"Any other solution?","</a>"),Z6="".concat(ra()?"\u6D4F\u89C8\u5668\u81EA\u52A8\u64AD\u653E\u7B56\u7565\uFF1A\u5728\u7528\u6237\u4E0E\u9875\u9762\u4EA7\u751F\u4EA4\u4E92\uFF08\u70B9\u51FB\u3001\u89E6\u6478\uFF09\u4E4B\u524D\uFF0C\u6D4F\u89C8\u5668\u7981\u6B62\u64AD\u653E\u6709\u58F0\u5A92\u4F53\u3002\u8BE5\u5F39\u7A97\u7528\u4E8E\u5E2E\u52A9\u7528\u6237\u6062\u590D\u97F3\u89C6\u9891\u64AD\u653E\u3002".concat(RT):"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(RT)),AT=function(){function e(){if(Q(this,e),this.dialogNode_=null,this.bodyPosition_="",this.content="\u97F3\u89C6\u9891\u64AD\u653E\u88AB\u6D4F\u89C8\u5668\u62E6\u622A\uFF0C\u8BF7\u70B9\u51FB\u201C\u6062\u590D\u64AD\u653E\u201D\u3002",ra()||(this.content='Media playback failed. Click the "Resume" to resume playback.'),!wT){var t=document.createElement("style");t.innerHTML=".".concat(qm,"{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(qm," div:not(.").concat(wl,"){display:block !important;}.").concat(Io,"{padding:14px;background:#fff;border-radius:3px;box-shadow:0px 3px 15px #434343;border:1px solid #d1cfcf;max-width:500px;}.").concat(Io," a{color:").concat(IT,";}.").concat(TT,"{overflow:hidden;text-overflow:ellipsis;font-size:16px;font-weight:600;}.").concat(Jm,"{margin:8px 0;}.").concat(wl,"{width:100%;display:flex !important;align-items:center;justify-content:right;float:right;}.").concat(Xm,"{margin-right:auto;cursor:pointer}.").concat(Km,"{height:100%;line-height:16px;cursor:pointer;}.").concat(Cl,"{margin-left:8px;color:#fff;background:").concat(IT,";padding:4px 12px;outline:none;border:1px solid;border-radius:3px;font-weight:bold;}.").concat(Cl,":hover{opacity:0.9;}.").concat(Xm,",.").concat(Cl,",.").concat(Jm,",.").concat(Km,"{font-size:14px;}@media screen and (max-width:750px){.").concat(Io,"{width:80vw;}}"),document.head.appendChild(t),wT=!0}this.showDetail_=!1,this.isCollapseClicked_=!1,this.isQuestionClicked_=!1,this.addDiaLog()}return Ie(e,[{key:"createDiaLog",value:function(){var t=document.createElement("template");t.innerHTML='<div class="'.concat(qm,`"><div class='`).concat(Io,"'><div class='").concat(TT,"'>").concat(location.host,"</div><div class='").concat(Jm,"'>").concat(this.content,"</div><div class='").concat(xT,`' style="visibility:hidden;width:100%;height:0;font-size:12px;color:gray;">`).concat(Z6,"</div><div class='").concat(wl,"'></div></div></div>").trim();var n=document.createElement("button");n.className=Cl,n.innerText=ra()?"\u6062\u590D\u64AD\u653E":"Resume",n.onclick=this.onConfirm.bind(this);var i=document.createElement("div");i.className=Km,i.innerHTML=`<?xml version="1.0" encoding="UTF-8"?>
93
57
  <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">
94
58
  <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"/>
95
59
  <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"/>
96
60
  <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"/>
97
61
  </svg>
98
- `,r.onclick=this.onQuestionClick.bind(this);var i=document.createElement("div");i.className=lv,i.innerText="".concat(ra()?"\u8BE6\u60C5 >":"Detail >"),i.onclick=this.onCollapseClick.bind(this);var o=t.content.firstChild,a=o.querySelector(".".concat(Ml));return a.appendChild(i),a.appendChild(r),a.appendChild(n),o}},{key:"addDiaLog",value:function(){w1()||(this.dialogNode_=this.createDiaLog(),document.body.appendChild(this.dialogNode_),this.dialogNode_.onclick=this.onConfirm.bind(this),this.dialogNode_.querySelector(".".concat(Io)).onclick=function(t){return t.stopPropagation()},this.bodyPosition_=document.body.style.position,document.body.style.position="fixed",ke.info("show autoplay dialog"),Ie.uploadEvent({log:X5}))}},{key:"deleteDiaLog",value:function(){this.dialogNode_&&(document.body.removeChild(this.dialogNode_),document.body.style.position=this.bodyPosition_,this.dialogNode_=null)}},{key:"onConfirm",value:function(){ke.warn("confirm clicked, try resume stream"),q.emit(ac),this.deleteDiaLog()}},{key:"onCollapseClick",value:function(){var t=this.dialogNode_.querySelector(".".concat(T1));t.style.visibility="".concat(this.showDetail_?"hidden":"visible"),t.style.height="".concat(this.showDetail_?0:"fit-content"),this.showDetail_=!this.showDetail_,this.isCollapseClicked_||Ie.uploadEvent({log:Q5}),this.isCollapseClicked_=!0}},{key:"onQuestionClick",value:function(){window.open(E1,"_blank"),this.isQuestionClicked_||Ie.uploadEvent({log:Y5}),this.isQuestionClicked_=!0}}]),e}(),A1=function(){function e(n){J(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 _i,this.initializeElement(),this.state_="NONE",this.pausedRetryCount_=5}var t;return ye(e,[{key:"isPlaying",get:function(){return this.state_===ro}},{key:"initializeElement",value:function(){var n=new MediaStream;n.addTrack(this.track_);var r=document.createElement(xe);r.srcObject=n,r.muted=!0;var i="width: 100%; height: 100%; object-fit: ".concat(this.objectFit_,";");this.mirror_&&(i+="transform: scaleX(-1);"),r.setAttribute("id","video_".concat(this.stream_.getId())),r.setAttribute("style",i),r.setAttribute("autoplay","autoplay"),r.setAttribute("playsinline","playsinline"),this.div_&&this.div_.appendChild(r),this.element_=r,this.handleEvents()}},{key:"setRect",value:function(n){var r=n.width,i=n.height;this.element_&&(this.element_.style.width=r+"px",this.element_.style.height=i+"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=N(p().mark(function n(){var r;return p().wrap(function(i){for(;;)switch(i.prev=i.next){case 0:return i.prev=0,i.next=3,this.element_.play();case 3:i.next=11;break;case 5:if(i.prev=5,i.t0=i.catch(0),r=ne({key:pf,data:{media:"Video",error:i.t0}}),this.log_.warn(r),!r.includes("NotAllowedError")){i.next=11;break}throw new ee({code:Y.PLAY_NOT_ALLOWED,message:r});case 11:case"end":return i.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(di,this.handleElementEvent),this.element_.addEventListener(Mt,this.handleElementEvent),this.element_.addEventListener(hi,this.handleElementEvent),this.element_.addEventListener(no,this.handleElementEvent),this.element_.addEventListener(Jp,this.handleElementEvent),this.track_.addEventListener(Mt,this.handleTrackEvent),this.track_.addEventListener(nn,this.handleTrackEvent),this.track_.addEventListener(_r,this.handleTrackEvent),this.track_.readyState===Mt&&this.handleTrackEvent({type:Mt}),this.track_.muted&&this.handleTrackEvent({type:nn})}},{key:"handleElementEvent",value:function(n){var r=this;switch(n.type){case di:this.log_.info("video player is playing"),this.state_=ro,q.emit(rc,{stream:this.stream_}),this.emitter_.emit(gn,{state:this.state_,reason:di}),this.interval_&&(yt.clearTask(this.interval_),this.interval_=null);break;case Mt:this.log_.info("video player is ended"),this.state_!==pi&&(this.state_=pi,this.emitter_.emit(gn,{state:this.state_,reason:Mt}));break;case hi: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_=yr,this.emitter_.emit(gn,{state:this.state_,reason:hi}),this.pausedRetryCount_>0&&!w1()&&(this.log_.info("video player auto resume when video paused"),this.resume(),this.pausedRetryCount_--),Qi&&(this.interval_=yt.run(function(){r.element_&&r.state_===yr&&r.resume()},{delay:3e3}));break;case no:if(this.element_&&this.element_.error){var i="".concat(Mm(),"/").concat(ta().name,"/").concat(ta().version);this.log_.error("video player error observed. code: ".concat(this.element_.error.code," message: ").concat(this.element_.error.message," deviceInfo: ").concat(i)),Ie.uploadEvent("stat-".concat(this.stream_.getType(),"-video-").concat(Fb,"-").concat(this.element_.error.code,"-").concat(i),this.element_.error)}break;case Jp:q.emit(nm,{stream:this.stream_})}}},{key:"handleTrackEvent",value:function(n){var r=n.type;switch(r){case Mt:this.log_.info("video track is ended"),q.emit(im,{stream:this.stream_,type:r}),this.state_!==pi&&(this.state_=pi,this.emitter_.emit(gn,{state:this.state_,reason:Mt}));break;case nn:this.log_.info("video track is unable to provide media output"),this.stream_.isRemote()||Vk(),q.emit(ic,{stream:this.stream_,type:r}),this.state_!==yr&&(this.state_=yr,this.emitter_.emit(gn,{state:this.state_,reason:nn}));break;case _r:this.log_.info("video track is able to provide media output"),q.emit(em,{stream:this.stream_}),this.state_===yr&&(this.state_=ro,this.emitter_.emit(gn,{state:this.state_,reason:_r}))}}},{key:"unbindEvents",value:function(){this.element_&&(this.element_.removeEventListener(di,this.handleElementEvent),this.element_.removeEventListener(Mt,this.handleElementEvent),this.element_.removeEventListener(hi,this.handleElementEvent),this.element_.removeEventListener(no,this.handleElementEvent),this.element_.removeEventListener(Jp,this.handleElementEvent)),this.track_&&(this.track_.removeEventListener(Mt,this.handleTrackEvent),this.track_.removeEventListener(nn,this.handleTrackEvent),this.track_.removeEventListener(_r,this.handleTrackEvent))}},{key:"stop",value:function(){this.unbindEvents(),this.div_&&this.div_.removeChild(this.element_),this.element_.srcObject=null,this.element_=null,this.interval_&&yt.clearTask(this.interval_)}},{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,r){this.emitter_.on(n,r)}},{key:"getElement",value:function(){return this.element_?this.element_:null}}]),e}(),hv=typeof ArrayBuffer!="undefined"&&typeof DataView!="undefined",Z5=$n,eB=vr,tB=RangeError,P1=function(e){if(e===void 0)return 0;var t=Z5(e),n=eB(t);if(t!==n)throw tB("Wrong length or index");return n},nB=Array,rB=Math.abs,Wr=Math.pow,iB=Math.floor,aB=Math.log,oB=Math.LN2,sB={pack:function(e,t,n){var r,i,o,a=nB(n),s=8*n-t-1,c=(1<<s)-1,u=c>>1,d=t===23?Wr(2,-24)-Wr(2,-77):0,h=e<0||e===0&&1/e<0?1:0,_=0;for((e=rB(e))!=e||e===1/0?(i=e!=e?1:0,r=c):(r=iB(aB(e)/oB),e*(o=Wr(2,-r))<1&&(r--,o*=2),(e+=r+u>=1?d/o:d*Wr(2,1-u))*o>=2&&(r++,o/=2),r+u>=c?(i=0,r=c):r+u>=1?(i=(e*o-1)*Wr(2,t),r+=u):(i=e*Wr(2,u-1)*Wr(2,t),r=0));t>=8;)a[_++]=255&i,i/=256,t-=8;for(r=r<<t|i,s+=t;s>0;)a[_++]=255&r,r/=256,s-=8;return a[--_]|=128*h,a},unpack:function(e,t){var n,r=e.length,i=8*r-t-1,o=(1<<i)-1,a=o>>1,s=i-7,c=r-1,u=e[c--],d=127&u;for(u>>=7;s>0;)d=256*d+e[c--],s-=8;for(n=d&(1<<-s)-1,d>>=-s,s+=t;s>0;)n=256*n+e[c--],s-=8;if(d===0)d=1-a;else{if(d===o)return n?NaN:u?-1/0:1/0;n+=Wr(2,t),d-=a}return(u?-1:1)*n*Wr(2,d-t)}},cB=Bt,D1=ai,uB=rn,L1=function(e){for(var t=cB(this),n=uB(t),r=arguments.length,i=D1(r>1?arguments[1]:void 0,n),o=r>2?arguments[2]:void 0,a=o===void 0?n:D1(o,n);a>i;)t[i++]=e;return t},Vl=te,pv=pe,fv=_e,lB=hv,O1=Yn,M1=Mn,N1=Ps,mv=oe,Ul=oi,dB=$n,hB=vr,Bl=P1,V1=sB,pB=xs,U1=Ba,fB=ii.f,mB=At.f,vB=L1,gB=yu,B1=Bi,_B=O1.PROPER,j1=O1.CONFIGURABLE,wo=Xe.get,F1=Xe.set,vv="ArrayBuffer",yB="DataView",G1="Wrong index",Wn=Vl.ArrayBuffer,rr=Wn,Eo=rr&&rr.prototype,wr=Vl.DataView,da=wr&&wr.prototype,H1=Object.prototype,SB=Vl.Array,jl=Vl.RangeError,bB=pv(vB),kB=pv([].reverse),z1=V1.pack,W1=V1.unpack,J1=function(e){return[255&e]},K1=function(e){return[255&e,e>>8&255]},q1=function(e){return[255&e,e>>8&255,e>>16&255,e>>24&255]},X1=function(e){return e[3]<<24|e[2]<<16|e[1]<<8|e[0]},TB=function(e){return z1(e,23,4)},xB=function(e){return z1(e,52,8)},Fl=function(e,t){mB(e.prototype,t,{get:function(){return wo(this)[t]}})},ki=function(e,t,n,r){var i=Bl(n),o=wo(e);if(i+t>o.byteLength)throw jl(G1);var a=wo(o.buffer).bytes,s=i+o.byteOffset,c=gB(a,s,s+t);return r?c:kB(c)},Ti=function(e,t,n,r,i,o){var a=Bl(n),s=wo(e);if(a+t>s.byteLength)throw jl(G1);for(var c=wo(s.buffer).bytes,u=a+s.byteOffset,d=r(+i),h=0;h<t;h++)c[u+h]=d[o?h:t-h-1]};if(lB){var Q1=_B&&Wn.name!==vv;if(mv(function(){Wn(1)})&&mv(function(){new Wn(-1)})&&!mv(function(){return new Wn,new Wn(1.5),new Wn(NaN),Wn.length!=1||Q1&&!j1}))Q1&&j1&&M1(Wn,"name",vv);else{(rr=function(e){return Ul(this,Eo),new Wn(Bl(e))}).prototype=Eo;for(var gv,Y1=fB(Wn),$1=0;Y1.length>$1;)(gv=Y1[$1++])in rr||M1(rr,gv,Wn[gv]);Eo.constructor=rr}U1&&pB(da)!==H1&&U1(da,H1);var Gl=new wr(new rr(2)),Z1=pv(da.setInt8);Gl.setInt8(0,2147483648),Gl.setInt8(1,2147483649),!Gl.getInt8(0)&&Gl.getInt8(1)||N1(da,{setInt8:function(e,t){Z1(this,e,t<<24>>24)},setUint8:function(e,t){Z1(this,e,t<<24>>24)}},{unsafe:!0})}else Eo=(rr=function(e){Ul(this,Eo);var t=Bl(e);F1(this,{bytes:bB(SB(t),0),byteLength:t}),fv||(this.byteLength=t)}).prototype,wr=function(e,t,n){Ul(this,da),Ul(e,Eo);var r=wo(e).byteLength,i=dB(t);if(i<0||i>r)throw jl("Wrong offset");if(i+(n=n===void 0?r-i:hB(n))>r)throw jl("Wrong length");F1(this,{buffer:e,byteLength:n,byteOffset:i}),fv||(this.buffer=e,this.byteLength=n,this.byteOffset=i)},da=wr.prototype,fv&&(Fl(rr,"byteLength"),Fl(wr,"buffer"),Fl(wr,"byteLength"),Fl(wr,"byteOffset")),N1(da,{getInt8:function(e){return ki(this,1,e)[0]<<24>>24},getUint8:function(e){return ki(this,1,e)[0]},getInt16:function(e){var t=ki(this,2,e,arguments.length>1?arguments[1]:void 0);return(t[1]<<8|t[0])<<16>>16},getUint16:function(e){var t=ki(this,2,e,arguments.length>1?arguments[1]:void 0);return t[1]<<8|t[0]},getInt32:function(e){return X1(ki(this,4,e,arguments.length>1?arguments[1]:void 0))},getUint32:function(e){return X1(ki(this,4,e,arguments.length>1?arguments[1]:void 0))>>>0},getFloat32:function(e){return W1(ki(this,4,e,arguments.length>1?arguments[1]:void 0),23)},getFloat64:function(e){return W1(ki(this,8,e,arguments.length>1?arguments[1]:void 0),52)},setInt8:function(e,t){Ti(this,1,e,J1,t)},setUint8:function(e,t){Ti(this,1,e,J1,t)},setInt16:function(e,t){Ti(this,2,e,K1,t,arguments.length>2?arguments[2]:void 0)},setUint16:function(e,t){Ti(this,2,e,K1,t,arguments.length>2?arguments[2]:void 0)},setInt32:function(e,t){Ti(this,4,e,q1,t,arguments.length>2?arguments[2]:void 0)},setUint32:function(e,t){Ti(this,4,e,q1,t,arguments.length>2?arguments[2]:void 0)},setFloat32:function(e,t){Ti(this,4,e,TB,t,arguments.length>2?arguments[2]:void 0)},setFloat64:function(e,t){Ti(this,8,e,xB,t,arguments.length>2?arguments[2]:void 0)}});B1(rr,vv),B1(wr,yB);var gc={ArrayBuffer:rr,DataView:wr},IB=Me,_v=pe,wB=oe,ex=It,tx=ai,EB=vr,CB=ju,yv=gc.ArrayBuffer,Sv=gc.DataView,nx=Sv.prototype,rx=_v(yv.prototype.slice),RB=_v(nx.getUint8),AB=_v(nx.setUint8);IB({target:"ArrayBuffer",proto:!0,unsafe:!0,forced:wB(function(){return!new yv(2).slice(1,void 0).byteLength})},{slice:function(e,t){if(rx&&t===void 0)return rx(ex(this),e);for(var n=ex(this).byteLength,r=tx(e,n),i=tx(t===void 0?n:t,n),o=new(CB(this,yv))(EB(i-r)),a=new Sv(this),s=new Sv(o),c=0;r<i;)AB(s,c++,RB(a,r++));return o}}),Me({global:!0,constructor:!0,forced:!hv},{DataView:gc.DataView});var PB=Me,DB=Fa,LB=pe([].reverse),ix=[1,2];PB({target:"Array",proto:!0,forced:String(ix)===String(ix.reverse())},{reverse:function(){return DB(this)&&(this.length=this.length),LB(this)}});var OB=Ut,MB=Bt,NB=yn,VB=rn,UB=TypeError,ax=function(e){return function(t,n,r,i){OB(n);var o=MB(t),a=NB(o),s=VB(o),c=e?s-1:0,u=e?-1:1;if(r<2)for(;;){if(c in a){i=a[c],c+=u;break}if(c+=u,e?c<0:s<=c)throw UB("Reduce of empty array with no initial value")}for(;e?c>=0:s>c;c+=u)c in a&&(i=n(i,a[c],c,o));return i}},bv={left:ax(!1),right:ax(!0)},BB=bv.left,ox=dr,jB=Gs;Me({target:"Array",proto:!0,forced:!Vs("reduce")||!jB&&ox>79&&ox<83},{reduce:function(e){var t=arguments.length;return BB(this,e,t,t>1?arguments[1]:void 0)}});var FB=Ds,GB="ArrayBuffer",sx=gc.ArrayBuffer;Me({global:!0,constructor:!0,forced:te.ArrayBuffer!==sx},{ArrayBuffer:sx}),FB(GB);var HB=Me,cx=Fa,zB=wu,WB=ot,ux=ai,JB=rn,KB=Sn,qB=Cs,XB=nt,QB=ja,YB=Ns("slice"),$B=XB("species"),kv=Array,ZB=Math.max;HB({target:"Array",proto:!0,forced:!YB},{slice:function(e,t){var n,r,i,o=KB(this),a=JB(o),s=ux(e,a),c=ux(t===void 0?a:t,a);if(cx(o)&&(n=o.constructor,(zB(n)&&(n===kv||cx(n.prototype))||WB(n)&&(n=n[$B])===null)&&(n=void 0),n===kv||n===void 0))return QB(o,s,c);for(r=new(n===void 0?kv:n)(ZB(c-s,0)),i=0;s<c;s++,i++)s in o&&qB(r,i,o[s]);return r.length=i,r}});var lx=te,ej=oe,tj=pe,nj=Wt,rj=Vu.trim,dx=sS,_c=lx.parseInt,hx=lx.Symbol,px=hx&&hx.iterator,fx=/^[+-]?0x/i,ij=tj(fx.exec),mx=_c(dx+"08")!==8||_c(dx+"0x16")!==22||px&&!ej(function(){_c(Object(px))})?function(e,t){var n=rj(nj(e));return _c(n,t>>>0||(ij(fx,n)?16:10))}:_c;Me({global:!0,forced:parseInt!=mx},{parseInt:mx});var _n,Co,Hl,Tv={exports:{}},aj=hv,xv=_e,hn=te,vx=at,zl=ot,xi=xt,Iv=Lr,oj=Xn,sj=Mn,wv=Qt,cj=At.f,uj=bn,Wl=xs,Ro=Ba,lj=nt,dj=Di,gx=Xe.enforce,hj=Xe.get,Jl=hn.Int8Array,Ev=Jl&&Jl.prototype,_x=hn.Uint8ClampedArray,yx=_x&&_x.prototype,Er=Jl&&Wl(Jl),ir=Ev&&Wl(Ev),pj=Object.prototype,Cv=hn.TypeError,Sx=lj("toStringTag"),Rv=dj("TYPED_ARRAY_TAG"),fj="TypedArrayConstructor",Jr=aj&&!!Ro&&Iv(hn.opera)!=="Opera",bx=!1,Kr={Int8Array:1,Uint8Array:1,Uint8ClampedArray:1,Int16Array:2,Uint16Array:2,Int32Array:4,Uint32Array:4,Float32Array:4,Float64Array:8},Av={BigInt64Array:8,BigUint64Array:8},kx=function(e){var t=Wl(e);if(zl(t)){var n=hj(t);return n&&xi(n,fj)?n.TypedArrayConstructor:kx(t)}},Tx=function(e){if(!zl(e))return!1;var t=Iv(e);return xi(Kr,t)||xi(Av,t)};for(_n in Kr)(Hl=(Co=hn[_n])&&Co.prototype)?gx(Hl).TypedArrayConstructor=Co:Jr=!1;for(_n in Av)(Hl=(Co=hn[_n])&&Co.prototype)&&(gx(Hl).TypedArrayConstructor=Co);if((!Jr||!vx(Er)||Er===Function.prototype)&&(Er=function(){throw Cv("Incorrect invocation")},Jr))for(_n in Kr)hn[_n]&&Ro(hn[_n],Er);if((!Jr||!ir||ir===pj)&&(ir=Er.prototype,Jr))for(_n in Kr)hn[_n]&&Ro(hn[_n].prototype,ir);if(Jr&&Wl(yx)!==ir&&Ro(yx,ir),xv&&!xi(ir,Sx))for(_n in bx=!0,cj(ir,Sx,{get:function(){return zl(this)?this[Rv]:void 0}}),Kr)hn[_n]&&sj(hn[_n],Rv,_n);var We={NATIVE_ARRAY_BUFFER_VIEWS:Jr,TYPED_ARRAY_TAG:bx&&Rv,aTypedArray:function(e){if(Tx(e))return e;throw Cv("Target is not a typed array")},aTypedArrayConstructor:function(e){if(vx(e)&&(!Ro||uj(Er,e)))return e;throw Cv(oj(e)+" is not a typed array constructor")},exportTypedArrayMethod:function(e,t,n,r){if(xv){if(n)for(var i in Kr){var o=hn[i];if(o&&xi(o.prototype,e))try{delete o.prototype[e]}catch(a){try{o.prototype[e]=t}catch(s){}}}ir[e]&&!n||wv(ir,e,n?t:Jr&&Ev[e]||t,r)}},exportTypedArrayStaticMethod:function(e,t,n){var r,i;if(xv){if(Ro){if(n){for(r in Kr)if((i=hn[r])&&xi(i,e))try{delete i[e]}catch(o){}}if(Er[e]&&!n)return;try{return wv(Er,e,n?t:Jr&&Er[e]||t)}catch(o){}}for(r in Kr)!(i=hn[r])||i[e]&&!n||wv(i,e,t)}},getTypedArrayConstructor:kx,isView:function(e){if(!zl(e))return!1;var t=Iv(e);return t==="DataView"||xi(Kr,t)||xi(Av,t)},isTypedArray:Tx,TypedArray:Er,TypedArrayPrototype:ir},xx=te,Pv=oe,mj=Tu,vj=We.NATIVE_ARRAY_BUFFER_VIEWS,gj=xx.ArrayBuffer,ha=xx.Int8Array,_j=!vj||!Pv(function(){ha(1)})||!Pv(function(){new ha(-1)})||!mj(function(e){new ha,new ha(null),new ha(1.5),new ha(e)},!0)||Pv(function(){return new ha(new gj(2),1,void 0).length!==1}),yj=$n,Sj=RangeError,bj=function(e){var t=yj(e);if(t<0)throw Sj("The argument can't be less than 0");return t},kj=RangeError,Ix=function(e,t){var n=bj(e);if(n%t)throw kj("Wrong offset");return n},Tj=Lr,xj=pe("".slice),Ij=Ca,wj=TypeError,wx=function(e){var t=Ij(e,"number");if(typeof t=="number")throw wj("Can't convert number to bigint");return BigInt(t)},Ej=Mr,Cj=Qe,Rj=xS,Aj=Bt,Pj=rn,Dj=bu,Lj=Rs,Oj=Th,Mj=function(e){return xj(Tj(e),0,3)==="Big"},Nj=We.aTypedArrayConstructor,Vj=wx,Ex=Me,Cx=te,Rx=Qe,Uj=_e,Bj=_j,Ao=We,Ax=gc,Px=oi,jj=et,yc=Mn,Fj=Kk,Gj=vr,Dx=P1,Dv=Ix,Lx=Ra,Sc=xt,Hj=Lr,Lv=ot,zj=Ri,Wj=Ua,Jj=bn,Kl=Ba,Kj=ii.f,Ox=function(e){var t,n,r,i,o,a,s,c,u=Rj(this),d=Aj(e),h=arguments.length,_=h>1?arguments[1]:void 0,y=_!==void 0,b=Lj(d);if(b&&!Oj(b))for(c=(s=Dj(d,b)).next,d=[];!(a=Cj(c,s)).done;)d.push(a.value);for(y&&h>2&&(_=Ej(_,arguments[2])),n=Pj(d),r=new(Nj(u))(n),i=Mj(r),t=0;n>t;t++)o=y?_(d[t],t):d[t],r[t]=i?Vj(o):+o;return r},qj=an.forEach,Xj=Ds,Mx=At,Nx=Se,Qj=xu,Ov=Xe.get,Yj=Xe.set,$j=Xe.enforce,Mv=Mx.f,Zj=Nx.f,e8=Math.round,Nv=Cx.RangeError,Vx=Ax.ArrayBuffer,t8=Vx.prototype,n8=Ax.DataView,ql=Ao.NATIVE_ARRAY_BUFFER_VIEWS,Ux=Ao.TYPED_ARRAY_TAG,Bx=Ao.TypedArray,bc=Ao.TypedArrayPrototype,r8=Ao.aTypedArrayConstructor,Vv=Ao.isTypedArray,Xl="BYTES_PER_ELEMENT",Uv="Wrong length",jx=function(e,t){r8(e);for(var n=0,r=t.length,i=new e(r);r>n;)i[n]=t[n++];return i},Ql=function(e,t){Mv(e,t,{get:function(){return Ov(this)[t]}})},Fx=function(e){var t;return Jj(t8,e)||(t=Hj(e))=="ArrayBuffer"||t=="SharedArrayBuffer"},Gx=function(e,t){return Vv(e)&&!zj(t)&&t in e&&Fj(+t)&&t>=0},Hx=function(e,t){return t=Lx(t),Gx(e,t)?jj(2,e[t]):Zj(e,t)},zx=function(e,t,n){return t=Lx(t),!(Gx(e,t)&&Lv(n)&&Sc(n,"value"))||Sc(n,"get")||Sc(n,"set")||n.configurable||Sc(n,"writable")&&!n.writable||Sc(n,"enumerable")&&!n.enumerable?Mv(e,t,n):(e[t]=n.value,e)};Uj?(ql||(Nx.f=Hx,Mx.f=zx,Ql(bc,"buffer"),Ql(bc,"byteOffset"),Ql(bc,"byteLength"),Ql(bc,"length")),Ex({target:"Object",stat:!0,forced:!ql},{getOwnPropertyDescriptor:Hx,defineProperty:zx}),Tv.exports=function(e,t,n){var r=e.match(/\d+$/)[0]/8,i=e+(n?"Clamped":"")+"Array",o="get"+e,a="set"+e,s=Cx[i],c=s,u=c&&c.prototype,d={},h=function(y,b){Mv(y,b,{get:function(){return function(f,g){var I=Ov(f);return I.view[o](g*r+I.byteOffset,!0)}(this,b)},set:function(f){return function(g,I,w){var j=Ov(g);n&&(w=(w=e8(w))<0?0:w>255?255:255&w),j.view[a](I*r+j.byteOffset,w,!0)}(this,b,f)},enumerable:!0})};ql?Bj&&(c=t(function(y,b,f,g){return Px(y,u),Qj(Lv(b)?Fx(b)?g!==void 0?new s(b,Dv(f,r),g):f!==void 0?new s(b,Dv(f,r)):new s(b):Vv(b)?jx(c,b):Rx(Ox,c,b):new s(Dx(b)),y,c)}),Kl&&Kl(c,Bx),qj(Kj(s),function(y){y in c||yc(c,y,s[y])}),c.prototype=u):(c=t(function(y,b,f,g){Px(y,u);var I,w,j,z=0,$=0;if(Lv(b)){if(!Fx(b))return Vv(b)?jx(c,b):Rx(Ox,c,b);I=b,$=Dv(f,r);var ue=b.byteLength;if(g===void 0){if(ue%r||(w=ue-$)<0)throw Nv(Uv)}else if((w=Gj(g)*r)+$>ue)throw Nv(Uv);j=w/r}else j=Dx(b),I=new Vx(w=j*r);for(Yj(y,{buffer:I,byteOffset:$,byteLength:w,length:j,view:new n8(I)});z<j;)h(y,z++)}),Kl&&Kl(c,Bx),u=c.prototype=Wj(bc)),u.constructor!==c&&yc(u,"constructor",c),$j(u).TypedArrayConstructor=c,Ux&&yc(u,Ux,i);var _=c!=s;d[i]=c,Ex({global:!0,constructor:!0,forced:_,sham:!ql},d),Xl in c||yc(c,Xl,r),Xl in u||yc(u,Xl,r),Xj(i)}):Tv.exports=function(){},(0,Tv.exports)("Uint8",function(e){return function(t,n,r){return e(this,t,n,r)}});var i8=Bt,Bv=ai,a8=rn,o8=Wy,s8=Math.min,c8=[].copyWithin||function(e,t){var n=i8(this),r=a8(n),i=Bv(e,r),o=Bv(t,r),a=arguments.length>2?arguments[2]:void 0,s=s8((a===void 0?r:Bv(a,r))-o,r-i),c=1;for(o<i&&i<o+s&&(c=-1,o+=s-1,i+=s-1);s-- >0;)o in n?n[i]=n[o]:o8(n,i),i+=c,o+=c;return n},Wx=We,u8=pe(c8),l8=Wx.aTypedArray;(0,Wx.exportTypedArrayMethod)("copyWithin",function(e,t){return u8(l8(this),e,t,arguments.length>2?arguments[2]:void 0)});var d8=an.every,h8=We.aTypedArray;(0,We.exportTypedArrayMethod)("every",function(e){return d8(h8(this),e,arguments.length>1?arguments[1]:void 0)});var p8=L1,f8=wx,m8=Lr,v8=Qe,g8=oe,_8=We.aTypedArray,y8=We.exportTypedArrayMethod,S8=pe("".slice);y8("fill",function(e){var t=arguments.length;_8(this);var n=S8(m8(this),0,3)==="Big"?f8(e):+e;return v8(p8,this,n,t>1?arguments[1]:void 0,t>2?arguments[2]:void 0)},g8(function(){var e=0;return new Int8Array(2).fill({valueOf:function(){return e++}}),e!==1}));var b8=rn,k8=ju,T8=We.aTypedArrayConstructor,x8=We.getTypedArrayConstructor,Yl=function(e){return T8(k8(e,x8(e)))},I8=function(e,t){for(var n=0,r=b8(t),i=new e(r);r>n;)i[n]=t[n++];return i},w8=Yl,E8=an.filter,C8=function(e,t){return I8(w8(e),t)},R8=We.aTypedArray;(0,We.exportTypedArrayMethod)("filter",function(e){var t=E8(R8(this),e,arguments.length>1?arguments[1]:void 0);return C8(this,t)});var A8=an.find,P8=We.aTypedArray;(0,We.exportTypedArrayMethod)("find",function(e){return A8(P8(this),e,arguments.length>1?arguments[1]:void 0)});var D8=an.findIndex,L8=We.aTypedArray;(0,We.exportTypedArrayMethod)("findIndex",function(e){return D8(L8(this),e,arguments.length>1?arguments[1]:void 0)});var O8=an.forEach,M8=We.aTypedArray;(0,We.exportTypedArrayMethod)("forEach",function(e){O8(M8(this),e,arguments.length>1?arguments[1]:void 0)});var N8=gs.includes,V8=We.aTypedArray;(0,We.exportTypedArrayMethod)("includes",function(e){return N8(V8(this),e,arguments.length>1?arguments[1]:void 0)});var U8=gs.indexOf,B8=We.aTypedArray;(0,We.exportTypedArrayMethod)("indexOf",function(e){return U8(B8(this),e,arguments.length>1?arguments[1]:void 0)});var j8=te,F8=oe,jv=pe,Jx=We,Fv=H_,Gv=nt("iterator"),Kx=j8.Uint8Array,G8=jv(Fv.values),H8=jv(Fv.keys),z8=jv(Fv.entries),Hv=Jx.aTypedArray,$l=Jx.exportTypedArrayMethod,Po=Kx&&Kx.prototype,Zl=!F8(function(){Po[Gv].call([1])}),qx=!!Po&&Po.values&&Po[Gv]===Po.values&&Po.values.name==="values",Xx=function(){return G8(Hv(this))};$l("entries",function(){return z8(Hv(this))},Zl),$l("keys",function(){return H8(Hv(this))},Zl),$l("values",Xx,Zl||!qx,{name:"values"}),$l(Gv,Xx,Zl||!qx,{name:"values"});var W8=We.aTypedArray,J8=We.exportTypedArrayMethod,K8=pe([].join);J8("join",function(e){return K8(W8(this),e)});var q8=ji,X8=Sn,Q8=$n,Y8=rn,$8=Vs,Z8=Math.min,zv=[].lastIndexOf,Qx=!!zv&&1/[1].lastIndexOf(1,-0)<0,eF=$8("lastIndexOf"),tF=Qx||!eF?function(e){if(Qx)return q8(zv,this,arguments)||0;var t=X8(this),n=Y8(t),r=n-1;for(arguments.length>1&&(r=Z8(r,Q8(arguments[1]))),r<0&&(r=n+r);r>=0;r--)if(r in t&&t[r]===e)return r||0;return-1}:zv,nF=ji,rF=tF,iF=We.aTypedArray;(0,We.exportTypedArrayMethod)("lastIndexOf",function(e){var t=arguments.length;return nF(rF,iF(this),t>1?[e,arguments[1]]:[e])});var aF=an.map,oF=Yl,sF=We.aTypedArray;(0,We.exportTypedArrayMethod)("map",function(e){return aF(sF(this),e,arguments.length>1?arguments[1]:void 0,function(t,n){return new(oF(t))(n)})});var cF=bv.left,uF=We.aTypedArray;(0,We.exportTypedArrayMethod)("reduce",function(e){var t=arguments.length;return cF(uF(this),e,t,t>1?arguments[1]:void 0)});var lF=bv.right,dF=We.aTypedArray;(0,We.exportTypedArrayMethod)("reduceRight",function(e){var t=arguments.length;return lF(dF(this),e,t,t>1?arguments[1]:void 0)});var hF=We.aTypedArray,pF=We.exportTypedArrayMethod,fF=Math.floor;pF("reverse",function(){for(var e,t=this,n=hF(t).length,r=fF(n/2),i=0;i<r;)e=t[i],t[i++]=t[--n],t[n]=e;return t});var Yx=te,$x=Qe,Wv=We,mF=rn,vF=Ix,gF=Bt,Zx=oe,_F=Yx.RangeError,Jv=Yx.Int8Array,eI=Jv&&Jv.prototype,tI=eI&&eI.set,yF=Wv.aTypedArray,SF=Wv.exportTypedArrayMethod,Kv=!Zx(function(){var e=new Uint8ClampedArray(2);return $x(tI,e,{length:1,0:3},1),e[1]!==3}),bF=Kv&&Wv.NATIVE_ARRAY_BUFFER_VIEWS&&Zx(function(){var e=new Jv(2);return e.set(1),e.set("2",1),e[0]!==0||e[1]!==2});SF("set",function(e){yF(this);var t=vF(arguments.length>1?arguments[1]:void 0,1),n=gF(e);if(Kv)return $x(tI,this,n,t);var r=this.length,i=mF(n),o=0;if(i+t>r)throw _F("Wrong length");for(;o<i;)this[t+o]=n[o++]},!Kv||bF);var kF=Yl,TF=ja,xF=We.aTypedArray;(0,We.exportTypedArrayMethod)("slice",function(e,t){for(var n=TF(xF(this),e,t),r=kF(this),i=0,o=n.length,a=new r(o);o>i;)a[i]=n[i++];return a},oe(function(){new Int8Array(1).slice()}));var IF=an.some,wF=We.aTypedArray;(0,We.exportTypedArrayMethod)("some",function(e){return IF(wF(this),e,arguments.length>1?arguments[1]:void 0)});var nI=qn.match(/firefox\/(\d+)/i),EF=!!nI&&+nI[1],CF=/MSIE|Trident/.test(qn),rI=qn.match(/AppleWebKit\/(\d+)\./),RF=!!rI&&+rI[1],AF=pe,qv=oe,PF=Ut,DF=w0,iI=EF,LF=CF,aI=dr,oI=RF,OF=We.aTypedArray,MF=We.exportTypedArrayMethod,kc=te.Uint16Array,Do=kc&&AF(kc.prototype.sort),NF=!(!Do||qv(function(){Do(new kc(2),null)})&&qv(function(){Do(new kc(2),{})})),sI=!!Do&&!qv(function(){if(aI)return aI<74;if(iI)return iI<67;if(LF)return!0;if(oI)return oI<602;var e,t,n=new kc(516),r=Array(516);for(e=0;e<516;e++)t=e%4,n[e]=515-e,r[e]=e-2*t+3;for(Do(n,function(i,o){return(i/4|0)-(o/4|0)}),e=0;e<516;e++)if(n[e]!==r[e])return!0});MF("sort",function(e){return e!==void 0&&PF(e),sI?Do(this,e):DF(OF(this),function(t){return function(n,r){return t!==void 0?+t(n,r)||0:r!=r?-1:n!=n?1:n===0&&r===0?1/n>0&&1/r<0?1:-1:n>r}}(e))},!sI||NF);var VF=vr,cI=ai,UF=Yl,BF=We.aTypedArray;(0,We.exportTypedArrayMethod)("subarray",function(e,t){var n=BF(this),r=n.length,i=cI(e,r);return new(UF(n))(n.buffer,n.byteOffset+i*n.BYTES_PER_ELEMENT,VF((t===void 0?r:cI(t,r))-i))});var jF=ji,uI=We,Xv=oe,lI=ja,ed=te.Int8Array,dI=uI.aTypedArray,FF=uI.exportTypedArrayMethod,hI=[].toLocaleString,GF=!!ed&&Xv(function(){hI.call(new ed(1))});FF("toLocaleString",function(){return jF(hI,GF?lI(dI(this)):dI(this),lI(arguments))},Xv(function(){return[1,2].toLocaleString()!=new ed([1,2]).toLocaleString()})||!Xv(function(){ed.prototype.toLocaleString.call([1,2])}));var HF=We.exportTypedArrayMethod,zF=oe,WF=pe,pI=te.Uint8Array,JF=pI&&pI.prototype||{},td=[].toString,KF=WF([].join);zF(function(){td.call({})})&&(td=function(){return KF(this)});var qF=JF.toString!=td;HF("toString",td,qF);var XF=function(){function e(t,n,r){J(this,e),this.isUplink_=r,this.connection_=t,this.log_=n,this.seiMessageList_=[],this.seiPayloadType_=243,this.mainVideoSenderOrReceiver_=null,this.mainVideoAbortController_=null,this.abortMap_=new Map,this.onSEIMessage=null}return ye(e,[{key:"isRunning",get:function(){return!!this.mainVideoAbortController_}},{key:"start",value:function(t){this.mainVideoSenderOrReceiver_=t;var n=t.createEncodedStreams(),r=n.readable,i=n.writable,o=new TransformStream({transform:this.isUplink_?this.encodeVideoFrame.bind(this):this.decodeVideoFrame.bind(this)});this.mainVideoAbortController_=new AbortController,r.pipeThrough(o).pipeTo(i,{signal:this.mainVideoAbortController_.signal}).catch(function(){})}},{key:"restart",value:function(t){this.stop(),this.start(t)}},{key:"stop",value:function(){var t;(t=this.mainVideoAbortController_)===null||t===void 0||t.abort(),this.mainVideoAbortController_=null}},{key:"destroy",value:function(){this.stop(),this.abortMap_.forEach(function(t){return t.abort()}),this.abortMap_.clear(),this.log_=null,this.onSEIMessage=null,this.mainVideoSenderOrReceiver_=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(r,i){if(i===1){if(r===t.mainVideoSenderOrReceiver_)return;t.isRunning?t.restart(r):t.start(r)}else{if(t.abortMap_.has(r))return;t.pipeSenderOrReceiver(r)}}):n.getReceivers().forEach(function(r,i){var o;t.abortMap_.has(r)||r===t.mainVideoSenderOrReceiver_||(i===1&&((o=r.track)===null||o===void 0?void 0:o.kind)===xe?t.isRunning?t.restart(r):t.start(r):t.pipeSenderOrReceiver(r))})}catch(r){this.log_.warn(r)}}},{key:"pipeSenderOrReceiver",value:function(t){var n=t.createEncodedStreams(),r=n.readable,i=n.writable,o=new AbortController;this.abortMap_.set(t,o),r.pipeTo(i,{signal:o.signal}).catch(function(){})}},{key:"clearUnusedSenderOrReceiver",value:function(t){var n=this;this.abortMap_.forEach(function(r,i){(n.isUplink_?t.getSenders():t.getReceivers()).find(function(o){return o===i})||(r.abort(),n.abortMap_.delete(i))})}},{key:"push",value:function(t,n){n&&n.seiPayloadType&&(this.seiPayloadType_=n.seiPayloadType),this.seiMessageList_.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,r=0,i=new DataView(t),o=0;o<t.byteLength;o++)switch(i.getUint8(o)){case 0:n++;break;case 1:n!==2&&n!==3||r++,n=0;break;default:n=0}return r}},{key:"encodeVideoFrame",value:function(t,n){try{if(this.connection_.isH264&&this.seiMessageList_.length>0&&!this.isEmptyFrame(t)){var r=9-this.getNaluCount(t.data);if(r<=0)return;for(var i=this.seiMessageList_.splice(0,r).reverse().map(this.encodeSEINalu.bind(this)),o=i.reduce(function(y,b){return y+b.dataView.byteLength},0),a=new ArrayBuffer(o+t.data.byteLength),s=new DataView(a),c=new DataView(t.data),u=0,d=0;d<i.length;d++)for(var h=0;h<i[d].dataView.byteLength;h++)s.setInt8(u++,i[d].dataView.getInt8(h));for(var _=0;_<t.data.byteLength;_++)s.setInt8(u++,c.getInt8(_));t.data=a,this.log_.debug("".concat(i.length," sei sent"))}}catch(y){this.log_.warn(y)}n.enqueue(t)}},{key:"decodeVideoFrame",value:function(t,n){var r=this;try{if(this.connection_.isH264&&!this.isEmptyFrame(t)&&this.hasSEI(t.data)){for(var i=[],o=new DataView(t.data),a=0,s=-1,c=-1,u=0;u<t.data.byteLength;u++){var d=o.getUint8(u);if(d===0)a++;else if(d===1){if(a===2||a===3){var h=u-a;if(s===-1?s=h:c===-1&&(c=h,i.push(new fI(new DataView(o.buffer.slice(s,c)))),s=h,c=-1),o.getUint8(u+1)!==6){t.data=new DataView(o.buffer.slice(h)).buffer;break}}a=0}else a=0}this.log_.debug("".concat(i.length," sei received")),In(this.onSEIMessage)&&i.reverse().forEach(function(_){r.onSEIMessage({seiPayloadType:_.seiPayloadType,data:_.seiPayload.buffer})})}}catch(_){this.log_.warn(_)}n.enqueue(t)}},{key:"encodeSEINalu",value:function(t){var n=t.byteLength,r=parseInt(n/255),i=n%255,o=[];o.push(0,0,0,1,6,this.seiPayloadType_);for(var a=0;a<r;a++)o.push(255);o.push(i);var s=new DataView(t);return o.push.apply(o,be(new Uint8Array(s.buffer))),o.push(128),new fI(new DataView(new Uint8Array(o).buffer),!0)}}]),e}(),fI=function(){function e(t){var n=arguments.length>1&&arguments[1]!==void 0&&arguments[1];J(this,e),this.dataView=t,this.isSEI&&(n?this.addPreventionByte():this.removePreventionByte())}return ye(e,[{key:"addPreventionByte",value:function(){for(var t=this.seiPayloadStartIndex,n=this.dataView.byteLength-2,r=[],i=0,o=t;o<=n;o++){var a=this.dataView.getInt8(o);switch(a){case 0:case 1:case 2:case 3:i===2&&(r.push(3),i=0),a==0?i++:i=0,r.push(a);break;default:i=0,r.push(a)}}r.push(this.dataView.getInt8(this.dataView.byteLength-1));var s=new DataView(new Uint8Array([].concat(be(new Uint8Array(this.dataView.buffer).slice(0,t)),r)).buffer);this.dataView=s}},{key:"removePreventionByte",value:function(){for(var t=this.seiPayloadStartIndex,n=this.dataView.byteLength-1,r=[],i=0,o=t;o<=n;o++)switch(this.dataView.getInt8(o)){case 0:i++,r.push(this.dataView.getInt8(o));break;case 3:i!==2&&r.push(this.dataView.getInt8(o)),i=0;break;default:r.push(this.dataView.getInt8(o)),i=0}var a=new DataView(new Uint8Array([].concat(be(new Uint8Array(this.dataView.buffer).slice(0,t)),r)).buffer);this.dataView=a}},{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,r=6;r<this.dataView.buffer.byteLength;r++){var i=this.dataView.getUint8(r);if(n++,i!==255){t+=i;break}t+=255}for(var o=new ArrayBuffer(t),a=new DataView(o),s=0;s<o.byteLength;s++,n++)a.setInt8(s,this.dataView.getInt8(n));return a}}]),e}(),Qv=function(){function e(n){J(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_=ke.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 _i,this.currentState_=sn,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_&&Lm&&(this.sei_=new XF(this,this.log_,this.isUplink_))}var t;return ye(e,[{key:"initialize",value:function(){var n={encodedInsertableStreams:this.enableSEI_&&Lm,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(sn))}},{key:"getDTLSTransportState",value:function(){if(!this.peerConnection_)return $u;var n=null;if(this.isUplink_){if(!bl()||this.peerConnection_.getSenders().length===0)return $u;n=this.peerConnection_.getSenders()[0].transport}else{if(!MT()||this.peerConnection_.getReceivers().length===0)return $u;n=this.peerConnection_.getReceivers()[0].transport}return n?n.state:$u}},{key:"onConnectionStateChange",value:function(n){var r=this.peerConnection_.iceConnectionState,i=this.getDTLSTransportState();if(this.log_.info("onConnectionStateChange() connectionState: "+n.target.connectionState),this.log_.info("ICE Transport state: ".concat(r,", DTLS Transport state: ").concat(i)),n.target.connectionState===Zu&&this.emitConnectionStateChangedEvent(Sb),n.target.connectionState===kb||n.target.connectionState===Yp){var o="".concat(this.isUplink_?"uplink":"downlink"," ICE/DTLS Transport connection ").concat(n.target.connectionState,". ICE Transport state: ").concat(r,", DTLS Transport state: ").concat(i),a=new ee({message:o,code:Y.ICE_TRANSPORT_ERROR});Ie.logFailedEvent({userId:this.client_.getUserId(),eventType:Mb,error:a}),this.emitConnectionStateChangedEvent(sn),this.isErrorObserved_||this.emitter_.emit(tt.ERROR,a)}n.target.connectionState!==Tb&&n.target.connectionState!==QN||(this.logSelectedCandidate(),Ie.logSuccessEvent({userId:this.client_.getUserId(),eventType:Mb}),this.emitConnectionStateChangedEvent(mn))}},{key:"emitConnectionStateChangedEvent",value:function(n){n!==this.currentState_&&(this.currentState_===bb&&n===Sb||(q.emit(sm,{client:this.client_,connection:this,prevState:this.currentState_,state:n}),this.emitter_.emit(tt.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,r){var i=this.client_.getUserId(),o={eventId:n,eventDesc:r,timestamp:on(),userId:i,tinyId:this.client_.getTinyId()};this.isUplink_||(o.remoteUserId=this.userId_,o.remoteTinyId=this.tinyId_),vn(i,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=N(p().mark(function n(){var r,i,o,a,s,c,u;return p().wrap(function(d){for(;;)switch(d.prev=d.next){case 0:if(this.peerConnection_){d.next=2;break}return d.abrupt("return");case 2:return d.next=4,this.peerConnection_.getStats();case 4:r=d.sent,i=ie(r),d.prev=6,i.s();case 8:if((o=i.n()).done){d.next=18;break}if((a=Te(o.value,2))[0],!Om(s=a[1])){d.next=16;break}return c=r.get(s.localCandidateId),u=r.get(s.remoteCandidateId),c&&this.log_.info("local candidate: ".concat(c.candidateType," ").concat(c.protocol,":").concat(c.ip||c.address,":").concat(c.port," ").concat(c.networkType||""," ").concat(c.candidateType==="relay"?"relayProtocol:"+c.relayProtocol:"")),u&&this.log_.info("remote candidate: ".concat(u.candidateType," ").concat(u.protocol,":").concat(u.ip||u.address,":").concat(u.port)),d.abrupt("break",18);case 16:d.next=8;break;case 18:d.next=23;break;case 20:d.prev=20,d.t0=d.catch(6),i.e(d.t0);case 23:return d.prev=23,i.f(),d.finish(23);case 26:case"end":return d.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(r,i){if(n.currentState_===mn)return r();var o=-1,a=function(u){u.state===mn&&(clearTimeout(o),c(),r())},s=function(u){u.client===n.client_&&(clearTimeout(o),c(),i(new ee({code:Y.API_CALL_ABORTED,message:ne({key:Z4,data:"leave room"})})))},c=function(){q.off(po,s,n),n.emitter_.off(tt.CONNECTION_STATE_CHANGED,a,n)};o=setTimeout(function(){c();var u=new ee({code:Y.API_CALL_TIMEOUT,message:"connection timeout"});i(u)},1e4),q.on(po,s,n),n.emitter_.on(tt.CONNECTION_STATE_CHANGED,a,n)}),this.waitForPeerConnectionConnectedPromise_=this.waitForPeerConnectionConnectedPromise_.then(function(r){return n.waitForPeerConnectionConnectedPromise_=null,r}).catch(function(r){throw n.waitForPeerConnectionConnectedPromise_=null,r})),this.waitForPeerConnectionConnectedPromise_}},{key:"getReconnectionCount",value:function(){return this.reconnectionCount_}},{key:"startReconnection",value:function(){this.isReconnecting_=!0,this.emitConnectionStateChangedEvent(bb),this.reconnect(),this.addEventInternal(this.isUplink_?i6:s6,"".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(sc,this.reconnect,this)}},{key:"on",value:function(n,r,i){this.emitter_.on(n,r,i)}},{key:"off",value:function(n,r,i){this.emitter_.off(n,r,i)}},{key:"setDelay",value:function(n){var r=n.audioDelay,i=n.videoDelay;this.delay_={audioDelay:r,videoDelay:i}}},{key:"getDelay",value:function(){return this.delay_}},{key:"isH264",get:function(){var n,r;return!((n=this.peerConnection_)===null||n===void 0||(r=n.remoteDescription)===null||r===void 0||!r.sdp.includes("H264"))}}]),e}(),QF=function(){function e(){J(this,e),this.set_=new Set,q.on(gl,this.add,this),q.on(lo,this.add,this),q.on(ho,this.delete,this),q.on(po,this.delete,this)}return ye(e,[{key:"add",value:function(t){var n=t.client,r=t.roomId;if(n.getMode()!=="rtc"){var i=this.getKey(n.getUserId(),r||n.getRoomId(),n.getSDKAppId(),n.getUseStringRoomId());this.set_.add(i)}}},{key:"delete",value:function(t){var n=t.client;if(n.getMode()!=="rtc"){var r=this.getKey(n.getUserId(),n.getRoomId(),n.getSDKAppId(),n.getUseStringRoomId());this.set_.delete(r)}}},{key:"getKey",value:function(t,n,r,i){return"".concat(r,"_").concat(n,"_").concat(t,"_").concat(i)}},{key:"isJoined",value:function(t){var n=t.userId,r=t.roomId,i=t.sdkAppId,o=t.client;return o.getMode()!=="rtc"&&this.set_.has(this.getKey(n,r,i,o.getUseStringRoomId()))}}]),e}(),YF=new QF;function mI(e,t,n,r){if(this.useStringRoomId_){if(!(Ft(e)&&/^[A-Za-z\d\s!#$%&()+\-:;<=.>?@[\]^_{}|~,]{1,64}$/.test(e)))throw new ee({code:Y.INVALID_PARAMETER,message:ne({key:O3,data:t,link:{className:r,fnName:n}})})}else if(!(xr(e)&&/^[1-9]\d*$/.test(String(e))&&e<4294967295))throw new ee({code:Y.INVALID_PARAMETER,message:ne({key:M3,data:t,link:{className:r,fnName:n}})})}function vI(e,t,n,r){if(!/^[A-Za-z\d_-]*$/.test(e))throw new ee({code:Y.INVALID_PARAMETER,message:ne({key:Y3,data:t,link:{className:r,fnName:n}})})}var $F={createClient:{name:"clientConfig",required:!0,type:kr,properties:{sdkAppId:{required:!0,type:Et,allowEmpty:!1},userId:{required:!0,type:bt,allowEmpty:!1},userSig:{required:!0,type:bt,allowEmpty:!1},mode:{required:!0,type:bt,values:["rtc",Yu]},useStringRoomId:{type:cn},autoSubscribe:{type:cn},enableAutoPlayDialog:{type:cn},streamId:{type:bt},userDefineRecordId:{type:bt},pureAudioPushMode:{type:Et,values:[1,2]},enableSEI:{type:cn}}},createStream:{name:"streamConfig",required:!0,type:kr,properties:{userId:{type:bt},audio:{type:cn},video:{type:cn},screen:{type:cn},screenAudio:{type:cn},microphoneId:{type:bt},cameraId:{type:bt},facingMode:{type:[bt,kr]},audioSource:{instanceOf:window.MediaStreamTrack},videoSource:{instanceOf:window.MediaStreamTrack}},validate:function(e){if(!ve(e.screen)&&e.screen&&ve(e.audio)&&(e.audio=!1),!(ve(e.audio)&&ve(e.video)||ve(e.audioSource)&&ve(e.videoSource)))throw new ee({code:Y.INVALID_PARAMETER,message:ne({key:L4})});if(!ve(e.screen)&&e.screen===!0&&e.video===!0)throw new ee({code:Y.INVALID_PARAMETER,message:ne({key:O4})});if(e.audio&&e.screenAudio)throw new ee({code:Y.INVALID_PARAMETER,message:ne({key:M4})});if(e.screen!==!0&&e.screenAudio===!0)throw new ee({code:Y.INVALID_PARAMETER,message:ne({key:N4})});if(!ve(e.screen)&&e.screen===!0&&!this.isScreenShareSupported())throw new ee({code:Y.INVALID_OPERATION,message:ne({key:B4})})}}},ZF={join:{name:"options",required:!0,type:kr,properties:{roomId:{required:!0,type:[Et,bt],allowEmpty:!1,validate:mI},role:{type:[bt],values:[Sr,qi]},privateMapKey:{type:[bt]}},validate:function(e){if(this.isJoined_)throw new ee({code:Y.INVALID_OPERATION,message:ne({key:L3})});if(this.checkDestroy(),YF.isJoined({userId:this.userId_,roomId:e.roomId,sdkAppId:this.sdkAppId_,client:this}))throw new ee({code:Y.INVALID_OPERATION,message:ne({key:S4,data:this.userId_})})}},publish:[{name:"stream",required:!0,instanceOf:mi,validate:function(e){if(!this.isJoined_)throw new ee({code:Y.INVALID_OPERATION,message:ne({key:B3})});if(this.mode_===Yu&&this.role_===qi)throw new ee({code:Y.INVALID_OPERATION,message:ne({key:F3})});if(!e.getIsReadyToPublish())throw new ee({code:Y.INVALID_OPERATION,message:ne({key:G3})});if(this.notPublishWithoutH264Supported_)throw new ee({code:Y.NOT_SUPPORTED_H264,message:ne({key:mk})})}},{name:"options",type:kr,defaultValue:{isAuxiliary:!1},properties:{isAuxiliary:{type:cn,defaultValue:!1,validate:function(){var e=arguments.length>0&&arguments[0]!==void 0&&arguments[0];if(e&&!Pm())throw new ee({code:Y.NOT_SUPPORTED,message:ne({key:j4})});if(this.uplinkConnection_&&(e&&this.uplinkConnection_.isAuxStreamPublished||!e&&this.uplinkConnection_.isMainStreamPublished))throw new ee({code:Y.INVALID_OPERATION,message:ne({key:H3,data:e?mt:"local"})});var t=this.localScreenStream_||be(this.connections_.values()).findIndex(function(n){return n.getTrackState().auxiliary})>=0;if(!this.enableMultiAuxStream_&&e&&t)throw new ee({code:Y.INVALID_OPERATION,message:ne({key:eV})})}}}}],unpublish:{name:"stream",required:!0,instanceOf:mi,validate:function(e){if(e!==this.localStream_&&e!==this.localAuxStream_){if(this.localStream_||this.localAuxStream_)throw new ee({code:Y.INVALID_PARAMETER,message:ne({key:j3})});this.log_.warn("Client currently has no published stream, please call publish() first.")}}},subscribe:[{name:"stream",required:!0,instanceOf:sf,validate:function(e){if(!e.getConnection())throw new ee({code:Y.INVALID_OPERATION,message:ne({key:df})});if(this.notSubscribeWithoutH264Supported_)throw new ee({code:Y.NOT_SUPPORTED_H264,message:ne({key:vk})})}},{name:"options",type:kr,properties:{audio:{type:cn},video:{type:cn},smallVideo:{type:cn}},validate:function(e){var t=e.audio,n=e.video,r=e.smallVideo;if(t===!1&&n===!1&&(ve(r)||r===!1))throw new ee({code:Y.INVALID_OPERATION,message:ne({key:J4})})}}],unsubscribe:{name:"stream",required:!0,instanceOf:sf,validate:function(e){if(!e.getConnection())throw new ee({code:Y.INVALID_OPERATION,message:ne({key:df})})}},switchRole:{name:"role",required:!0,values:[Sr,qi],validate:function(){if(this.mode_!==Yu)throw new ee({code:Y.INVALID_PARAMETER,message:ne({key:W3})});if(!this.isJoined_)throw new ee({code:Y.INVALID_OPERATION,message:ne({key:J3})})}},startPublishCDNStream:{name:"options",required:!1,properties:{streamId:{type:bt,validate:vI},streamType:{type:bt,values:["main","auxiliary"]},appId:{type:Et,allowEmpty:!1},bizId:{type:Et,allowEmpty:!1},url:{type:bt,allowEmpty:!1}},validate:function(){if(this.isDestroyed_)throw new ee({code:Y.INVALID_OPERATION,message:ne({key:hf,data:{funName:"startPublishCDNStream"}})})}},startMixTranscode:{name:"config",required:!0,type:kr,properties:{mode:{type:bt,values:["preset-layout","manual"]},streamId:{type:bt,validate:vI},videoWidth:{type:Et,notLessThanZero:!0},videoHeight:{type:Et,notLessThanZero:!0},videoBitrate:{type:Et,notLessThanZero:!0,allowEmpty:!1},videoFramerate:{type:Et,validate:function(e,t,n,r){if(e<=0||e>30)throw new ee({code:Y.INVALID_PARAMETER,message:ne({key:I4,link:{className:r,fnName:n}})})}},videoGop:{type:Et,validate:function(e,t,n,r){if(e<1||e>8)throw new ee({code:Y.INVALID_PARAMETER,message:ne({key:w4,link:{className:r,fnName:n}})})}},audioSampleRate:{type:Et,notLessThanZero:!0},audioBitrate:{type:Et,validate:function(e,t,n,r){if(e<32||e>192)throw new ee({code:Y.INVALID_PARAMETER,message:ne({key:E4,link:{className:r,fnName:n}})})}},audioChannels:{type:Et,values:[1,2]},backgroundColor:{type:Et},backgroundImage:{type:bt},mixUsers:{required:!0,type:t3,arrayItem:{require:!0,type:kr,properties:{userId:{required:!0,type:bt},roomId:{type:[bt,Et],validate:mI},pureAudio:{type:cn},width:{type:Et,notLessThanZero:!0},height:{type:Et,notLessThanZero:!0},locationX:{type:Et,notLessThanZero:!0},locationY:{type:Et,notLessThanZero:!0},zOrder:{type:Et},streamType:{type:bt,values:["main","auxiliary"]},renderMode:{type:Et,values:[0,1,2,4]}}}}},validate:function(e,t,n,r,i){var o=0,a=0,s=e.mixUsers,c=[];if(s.forEach(function(u,d){if(c.push(u.userId),!u.pureAudio){if(!u.zOrder||u.zOrder<1||u>15)throw new ee({code:Y.INVALID_PARAMETER,message:ne({key:C4,data:"config.mixUsers[".concat(d,"].zOrder"),link:{className:r,fnName:n}})});u.width+u.locationX>o&&(o=u.width+u.locationX),u.height+u.locationY>a&&(a=u.height+u.locationY)}}),c.indexOf(this.getUserId())<0)throw new ee({code:Y.INVALID_PARAMETER,message:ne({key:R4,link:{className:r,fnName:n}})});if(e.videoWidth<o||e.videoHeight<a)throw new ee({code:Y.INVALID_PARAMETER,message:ne({key:A4,link:{className:r,fnName:n}})})}},sendSEIMessage:[{name:"buffer",required:!0,instanceOf:ArrayBuffer,validate:function(e){if(!Lm)throw new ee({code:Y.NOT_SUPPORTED,message:ne({key:_k})});if(!this.enableSEI_)throw new ee({code:Y.INVALID_OPERATION,message:ne({key:K4})});if(e.byteLength>1e3)throw new ee({code:Y.INVALID_PARAMETER,message:ne({key:X4,data:e.byteLength})});if(e.byteLength===0)throw new ee({code:Y.INVALID_PARAMETER,message:ne({key:q4})});if(!this.uplinkConnection_||!this.localStream_)throw new ee({code:Y.INVALID_PARAMETER,message:ne({key:Q4})});if(!this.localStream_.hasVideo())throw new ee({code:Y.INVALID_OPERATION,message:ne({key:Y4})});var t=this.uplinkConnection_.isH264;if(!t)throw new ee({code:Y.NOT_SUPPORTED,message:ne({key:_k,data:t})})}},{name:"options",type:kr,properties:{seiPayloadType:{type:Et,values:[5,243]}}}]},e7={play:[{name:"elementId",required:!0,type:[bt,"HTMLDivElement"],validate:function(e,t,n){if(Ft(e)){var r=document.getElementById(e);if(!r)throw new ee({code:Y.INVALID_PARAMETER,message:ne({key:P4,data:{key:t,fnName:n}})});if(!(r instanceof HTMLDivElement))throw new ee({code:Y.INVALID_PARAMETER,message:ne({key:D4,data:{key:t,fnName:n,type:gi(r)}})})}}},{name:"options",type:kr,properties:{objectFit:{type:bt,values:["contain","cover","fill"]},muted:{type:cn},mirror:{type:cn}}}],addTrack:{name:qp,instanceOf:MediaStreamTrack,validate:function(e){if(this.isAddingTrack_)throw new ee({code:Y.INVALID_OPERATION,message:ne({key:u4})});if(this.isRemovingTrack_)throw new ee({code:Y.INVALID_OPERATION,message:ne({key:l4})});if(this.publishState_===Zs)throw new ee({code:Y.INVALID_OPERATION,message:ne({key:d4})});var t=this.getMediaStream();if(!t)throw new ee({code:Y.INVALID_OPERATION,message:ne({key:hk})});if(e.kind===Ce&&t.getAudioTracks().length>0||e.kind===xe&&t.getVideoTracks().length>0)throw new ee({code:Y.INVALID_OPERATION,message:ne({key:h4})});if(!yi()&&!bl())throw new ee({code:Y.NOT_SUPPORTED,message:ne({key:ff,data:gb})})}},removeTrack:{name:qp,instanceOf:MediaStreamTrack,validate:function(e){if(this.isAddingTrack_)throw new ee({code:Y.INVALID_OPERATION,message:ne({key:f4})});if(this.isRemovingTrack_)throw new ee({code:Y.INVALID_OPERATION,message:ne({key:m4})});if(this.publishState_===Zs)throw new ee({code:Y.INVALID_OPERATION,message:ne({key:v4})});var t=this.getMediaStream();if(!t)throw new ee({code:Y.INVALID_OPERATION,message:ne({key:hk})});if(t.getTracks().indexOf(e)===-1)throw new ee({code:Y.INVALID_PARAMETER,message:ne({key:g4})});if(!yi()){if(t.getTracks().length===1)throw new ee({code:Y.INVALID_OPERATION,message:ne({key:_4})});if(e.kind===Ce)throw new ee({code:Y.INVALID_PARAMETER,message:ne({key:p4})});if(!bl())throw new ee({code:Y.NOT_SUPPORTED,message:ne({key:ff,data:_b})})}}},replaceTrack:{name:qp,instanceOf:MediaStreamTrack,validate:function(e){var t=this.getMediaStream();if(!t)throw new ee({code:Y.INVALID_OPERATION,message:ne({key:c4})});if(this.publishState_===Zs)throw new ee({code:Y.INVALID_OPERATION,message:ne({key:dk})});if(e.kind===Ce&&t.getAudioTracks().length<=0||e.kind===xe&&t.getVideoTracks().length<=0)throw new ee({code:Y.INVALID_PARAMETER,message:ne({key:y4,data:e})});if(!Dm())throw new ee({code:Y.NOT_SUPPORTED,message:ne({key:ff,data:UN})})}}},Yt={TRTC:$F,CLIENT:ZF,LOCAL_STREAM:{switchDevice:[{name:"type",required:!0,type:bt,values:[Ce,xe]},{name:"deviceId",required:!0,type:bt,validate:function(){if(this.screen_&&!this.audio_||this.audioSource_||this.videoSource_)throw new ee({code:Y.INVALID_OPERATION,message:ne({key:o4})});if(this.publishState_===Zs)throw new ee({code:Y.INVALID_OPERATION,message:ne({key:s4})});if(!Dm())throw new ee({code:Y.NOT_SUPPORTED,message:ne({key:U4})})}}],setAudioCaptureVolume:{name:"volume",type:Et}},STREAM:e7};function nd(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return function(r,i,o){var a=o.value;return o.value=function(){for(var s=arguments.length,c=new Array(s),u=0;u<s;u++)c[u]=arguments[u];return gI.call(this,t,c,i,this.name_),a.apply(this,c)},o}}function wn(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return function(r,i,o){var a=o.value;return o.value=N(p().mark(function s(){var c,u,d,h=arguments;return p().wrap(function(_){for(;;)switch(_.prev=_.next){case 0:for(c=h.length,u=new Array(c),d=0;d<c;d++)u[d]=h[d];return gI.call(this,t,u,i,this.name_),_.abrupt("return",a.apply(this,u));case 3:case"end":return _.stop()}},s,this)})),o}}function gI(e,t,n,r){try{for(var i=0;i<e.length;i++)Yv.call(this,{rule:e[i],value:t[i],key:e[i].name,fnName:n,className:r})}catch(o){throw ke.error(o),o}}function Yv(e){var t=this,n=e.rule,r=e.value,i=e.key,o=e.fnName,a=e.className;if(ve(r)){if(n.required)throw new ee({code:Y.INVALID_PARAMETER,message:ne({key:g3,data:{key:i,rule:n,fnName:o,value:r},link:{className:a,fnName:o}})});if(ve(n.defaultValue))return;r=n.defaultValue}if(Array.isArray(n.type)){if(!n.type.map(function(h){return h.toLowerCase()}).includes(gi(r)))throw new ee({code:Y.INVALID_PARAMETER,message:ne({key:ak,data:{key:i,rule:n,fnName:o,value:r},link:{className:a,fnName:o}})})}else if(!ve(n.type)&&gi(r)!==n.type)throw new ee({code:Y.INVALID_PARAMETER,message:ne({key:ak,data:{key:i,rule:n,fnName:o,value:r},link:{className:a,fnName:o}})});if(n.allowEmpty===!1){var s=xr(r)&&(r===0||Number.isNaN(r)),c=Ft(r)&&r.trim()==="";if(s||c)throw new ee({code:Y.INVALID_PARAMETER,message:ne({key:_3,data:{key:i,rule:n,fnName:o,value:r},link:{className:a,fnName:o}})})}if(n.notLessThanZero&&xr(r)&&r<0)throw new ee({code:Y.INVALID_PARAMETER,message:ne({key:x4,data:{key:i,rule:n,fnName:o,value:r},link:{className:a,fnName:o}})});if(Ft(n.instanceOf)){if(!r||r.name_!==n.instanceOf)throw new ee({code:Y.INVALID_PARAMETER,message:ne({key:ok,data:{key:i,rule:n,fnName:o,value:r},link:{className:a,fnName:o}})})}else if(In(n.instanceOf)&&!(r instanceof n.instanceOf))throw new ee({code:Y.INVALID_PARAMETER,message:ne({key:ok,data:{key:i,rule:n,fnName:o,value:r},link:{className:a,fnName:o}})});if(n.values&&!n.values.includes(r))throw new ee({code:Y.INVALID_PARAMETER,message:ne({key:y3,data:{key:i,rule:n,fnName:o,value:r},link:{className:a,fnName:o}})});var u=n.properties;na(u)&&Ok(r)&&Object.keys(u).forEach(function(h){Yv.call(t,{rule:u[h],value:r&&r[h],key:"".concat(i,".").concat(h),fnName:o,className:a})});var d=n.arrayItem;na(d)&&ml(r)&&r.forEach(function(h,_){Yv.call(t,{rule:d,value:h,key:"".concat(i,"[").concat(_,"]"),fnName:o,className:a})}),In(n.validate)&&n.validate.call(this,r,i,o,a,this)}Me({target:"Number",stat:!0},{isNaN:function(e){return e!=e}});var t7=Me,n7=oe,r7=yh.f;t7({target:"Object",stat:!0,forced:n7(function(){return!Object.getOwnPropertyNames(1)})},{getOwnPropertyNames:r7});var _I,Tc,i7=KT;function xc(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{retries:5,timeout:2e3};return function(t,n,r){var i=oc({retryFunction:r.value,settings:e,onError:e.onError,onRetrying:e.onRetrying,onRetryFailed:e.onRetryFailed});return r.value=function(){for(var o=arguments.length,a=new Array(o),s=0;s<o;s++)a[s]=arguments[s];return i.apply(this,a)},r}}Me({target:"Array",stat:!0,forced:!Tu(function(e){Array.from(e)})},{from:i7});var yI,SI,bI,ar,pa=5e3,a7={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},$v=ye(function e(t){J(this,e),this.str_identifier=String(t.userId),this.uint64_tinyid=Number(t.tinyId),this.uint32_role=t.role}),o7=(_I=xc({timeout:500,retries:3}),Tc=function(){function e(i){var o=this;J(this,e),this.frameWorkType_=i.frameWorkType||30,this.component_=i.component||0,this.client_=i.client,this.keyPrefix_="key_point",this.storageKey_="".concat(this.keyPrefix_,"_").concat(this.client_.getUserId()),this.log_=ke.createLogger({id:"kpm|"+this.client_.getUserId(),userId:this.client_.getUserId(),sdkAppId:this.client_.getSDKAppId()}),Object.getOwnPropertyNames(this.__proto__).forEach(function(a){a.startsWith("handle")&&In(o[a])&&(o[a]=function(s){var c=s.fn,u=s.context;return N(p().mark(function d(){var h,_,y,b=arguments;return p().wrap(function(f){for(;;)switch(f.prev=f.next){case 0:for(f.prev=0,h=b.length,_=new Array(h),y=0;y<h;y++)_[y]=b[y];return f.next=4,c.apply(u||this,_);case 4:return f.abrupt("return",f.sent);case 7:f.prev=7,f.t0=f.catch(0),ke.error("".concat(c.name,"() error observed ")+f.t0);case 10:case"end":return f.stop()}},d,this,[[0,7]])}))}({fn:o[a],context:o}))}),this.initData(),this.installEvents(),this.intervalId_=yt.run(so,this.setStorage.bind(this),{delay:2e4})}var t,n,r;return ye(e,[{key:"initData",value:function(){this.firstPublishedUserList_=[],this.networkQuality_={totalUplinkRTT:0,totalUplinkLoss:0,count:0,totalDownlinkRTTAndLossMap:new Map},this.basicInfo={string_sdk_version:Vi,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:this.client_.getMode()==="live"?1:0,uint32_joining_duration:0,uint32_networkType:af[Of()],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(){q.on(gl,this.handleJoinStart,this),q.on(Jf,this.handleWSStart,this),q.on(_l,this.handleWSEnd,this),q.on(Bf,this.handleJoinSendCMD,this),q.on(jf,this.handleJoinReceivedCMDResponce,this),q.on(lo,this.handleJoinSuccess,this),q.on(ho,this.handleJoinFailed,this),q.on(zf,this.handleReceivedPublishUserList,this),q.on(sm,this.handleConnectionStateChanged,this),q.on(Ff,this.handleLeaveStart,this),q.on(po,this.handleLeaveSuccess,this),q.on(Gf,this.handleLeaveSendCMD,this),q.on(cm,this.handleSendSubscribeCMD,this),q.on(rc,this.handleVideoPlaying,this),q.on(Xf,this.handleAudioPlaying,this),q.on(um,this.handleNetworkQuality,this),q.on(Hf,this.handleHeartbeatStats,this),q.on(yl,this.handleRemoteStreamAdded,this),q.on(Qf,this.handleRemoteStreamSubscribeStart,this),q.on(Ur,this.handleRemoteStreamSubscribed,this),q.on(ia,this.handleRemoteStreamRemoved,this),q.on(nm,this.handleVideoLoadedData,this),q.on(tm,this.handlePlayStream,this),q.on(Wf,this.handlePublishStart,this),q.on(Yf,this.handleLocalStreamInitStart,this),q.on($f,this.handleLocalStreamInitEnd,this),q.on(Zf,this.handleLocalStreamInitFailed,this)}},{key:"uninstallEvents",value:function(){q.off(gl,this.handleJoinStart,this),q.off(Jf,this.handleWSStart,this),q.off(_l,this.handleWSEnd,this),q.off(Bf,this.handleJoinSendCMD,this),q.off(jf,this.handleJoinReceivedCMDResponce,this),q.off(zf,this.handleReceivedPublishUserList,this),q.off(sm,this.handleConnectionStateChanged,this),q.off(Ff,this.handleLeaveStart,this),q.off(po,this.handleLeaveSuccess,this),q.off(lo,this.handleJoinSuccess,this),q.off(ho,this.handleJoinFailed,this),q.off(Gf,this.handleLeaveSendCMD,this),q.off(cm,this.handleSendSubscribeCMD,this),q.off(rc,this.handleVideoPlaying,this),q.off(Xf,this.handleAudioPlaying,this),q.off(um,this.handleNetworkQuality,this),q.off(Hf,this.handleHeartbeatStats,this),q.off(yl,this.handleRemoteStreamAdded,this),q.off(Qf,this.handleRemoteStreamSubscribeStart,this),q.off(Ur,this.handleRemoteStreamSubscribed,this),q.off(ia,this.handleRemoteStreamRemoved,this),q.off(nm,this.handleVideoLoadedData,this),q.off(tm,this.handlePlayStream,this),q.off(Wf,this.handlePublishStart,this),q.off(Yf,this.handleLocalStreamInitStart,this),q.off($f,this.handleLocalStreamInitEnd,this),q.off(Zf,this.handleLocalStreamInitFailed,this)}},{key:"destroy",value:function(){this.uninstallEvents(),yt.clearTask(this.intervalId_),this.client_=null}},{key:"handleJoinStart",value:function(i){this.hitTest(i.client)&&this.pathJoinRoom_.uint64_start_time===0&&(this.pathJoinRoom_.uint64_start_time=Date.now(),this.checkStorage())}},{key:"handleWSStart",value:function(i){var o=i.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(i){var o=i.client,a=i.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(),a&&(this.pathJoinRoom_.int32_send_request_acc_ip_cmd_ret=a instanceof ee?Number(a.getExtraCode()||a.getCode()):Y.UNKNOWN,this.pathJoinRoom_.int32_end_ret=2))}},{key:"handleJoinSendCMD",value:function(i){this.hitTest(i.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(i){this.hitTest(i.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=i.code,i.code!==0&&(this.pathJoinRoom_.int32_end_ret=3))}},{key:"handleJoinSuccess",value:function(i){this.hitTest(i.client)&&this.pathJoinRoom_.uint64_end_time===0&&(this.pathJoinRoom_.uint64_end_time=Date.now(),this.pathJoinRoom_.int32_end_ret=0)}},{key:"handleJoinFailed",value:function(i){var o=i.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(i){this.hitTest(i.client)&&this.pathJoinRoom_.uint64_recv_userlist_time===0&&(this.pathJoinRoom_.uint64_recv_userlist_time=Date.now(),this.firstPublishedUserList_=i.data.data&&i.data.data.userList||[])}},{key:"handleConnectionStateChanged",value:function(i){var o=i.client,a=i.state,s=i.connection;if(this.hitTest(o)&&a===mn){this.client_.getUplinkConnection()===s&&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 c=this.pathMainVideoMap_.get("".concat(s.getUserId(),"_").concat(_t));c&&c.statsToReport.uint64_pc_connected_time===0&&(c.statsToReport.uint64_pc_connected_time=Date.now())}}},{key:"handleLeaveStart",value:function(i){this.hitTest(i.client)&&(this.pathLeaveRoom_.uint64_start_time=Date.now())}},{key:"handleLeaveSuccess",value:function(i){this.hitTest(i.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(i){this.hitTest(i.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(i){var o=i.client,a=i.stream;if(this.hitTest(o)){var s=a.getUserId(),c=a.getType(),u="".concat(s,"_").concat(c),d=this.remoteStreamStatsMap_.get(u);if(d)d.stream=a;else{var h={userId:s,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:H({},a7),stream:a};h.statsToReport.msg_user_info=new $v({userId:s,tinyId:a.getTinyId(),role:ao}),h.statsToReport.uint32_stream_type=c===_t?2:7,this.remoteStreamStatsMap_.set(u,h)}}}},{key:"handleRemoteStreamSubscribeStart",value:function(i){var o=i.client,a=i.stream;if(this.hitTest(o)){var s=a.getUserId(),c=a.getType(),u="".concat(s,"_").concat(c),d=this.remoteStreamStatsMap_.get(u);d&&d.subscribeStartTime===0&&(d.subscribeStartTime=Date.now())}}},{key:"handleSendSubscribeCMD",value:function(i){if(this.hitTest(i.client)){var o=new $v(i),a=Date.now(),s="".concat(i.userId,"_").concat(_t);i.trackState.video&&i.subscribeState.video&&!this.pathMainVideoMap_.has(s)&&this.pathMainVideoMap_.set(s,{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:i.userId,sendSubscribeCMDTime:a}),i.trackState.audio&&i.subscribeState.audio&&!this.pathMainAudioMap_.has(s)&&this.pathMainAudioMap_.set(s,{statsToReport:{msg_user_info:o,uint64_start_enter_time:this.pathJoinRoom_.uint64_start_time,uint64_play_first_frame_time:0},userId:i.userId,sendSubscribeCMDTime:a});var c="".concat(i.userId,"_").concat(Dt);i.trackState.auxiliary&&i.subscribeState.auxiliary&&!this.pathAuxiliaryMap_.has(c)&&this.pathAuxiliaryMap_.set(c,{sendSubscribeCMDTime:a})}}},{key:"handleRemoteStreamSubscribed",value:function(i){var o=i.client,a=i.stream;if(this.hitTest(o)){var s=a.getUserId(),c=a.getType(),u="".concat(s,"_").concat(c),d=this.remoteStreamStatsMap_.get(u);d&&d.subscribedTime===0&&(d.subscribedTime=Date.now(),d.stream=a)}}},{key:"handleRemoteStreamRemoved",value:function(i){var o=i.client,a=i.stream;if(this.hitTest(o)){var s=a.getUserId(),c=a.getType(),u=this.remoteStreamStatsMap_.get("".concat(s,"_").concat(c));u&&(u.stream=null)}}},{key:"handlePlayStream",value:function(i){var o=i.stream;if(o.isRemote()&&o.getConnection()&&this.hitTest(o.getConnection().getClient())){var a=o.getConnection().getUserId(),s="".concat(a,"_").concat(o.getType());if(this.remoteStreamStatsMap_.has(s)){var c=this.remoteStreamStatsMap_.get(s);c.playStreamTime===0&&(c.playStreamTime=Date.now())}}}},{key:"handleVideoLoadedData",value:function(i){var o=i.stream;if(o.isRemote()&&o.getConnection()&&this.hitTest(o.getConnection().getClient())){var a=o.getConnection().getUserId(),s="".concat(a,"_").concat(o.getType());if(this.pathMainVideoMap_.has(s)){var c=this.pathMainVideoMap_.get(s);c.statsToReport.uint64_combine_first_frame_time===0&&(c.statsToReport.uint64_combine_first_frame_time=Date.now())}}}},{key:"handleVideoPlaying",value:function(i){var o=i.stream;if(o.isRemote()&&o.getConnection()&&this.hitTest(o.getConnection().getClient())){var a=o.getConnection().getUserId(),s="".concat(a,"_").concat(o.getType()),c=Date.now();if(this.pathMainVideoMap_.has(s)){var u=this.pathMainVideoMap_.get(s);if(u.statsToReport.uint64_render_first_frame_time===0&&(u.statsToReport.uint64_render_first_frame_time=c),this.remoteStreamStatsMap_.has(s)){var d=this.remoteStreamStatsMap_.get(s),h=d.statsToReport,_=d.playStreamTime,y=d.subscribedTime;h.uint32_video_render_first===0&&_-y<=100&&(h.uint32_video_render_first=c-u.sendSubscribeCMDTime)}}if(o.getType()===Dt&&this.pathAuxiliaryMap_.has(s)&&this.remoteStreamStatsMap_.has(s)){var b=this.remoteStreamStatsMap_.get(s),f=b.statsToReport,g=b.playStreamTime,I=b.subscribedTime;f.uint32_video_render_first===0&&g-I<=100&&(f.uint32_video_render_first=c-this.pathAuxiliaryMap_.get(s).sendSubscribeCMDTime)}}}},{key:"handleAudioPlaying",value:function(i){if(i.stream.isRemote()&&i.stream.getConnection()&&this.hitTest(i.stream.getConnection().getClient())){var o=i.stream.getConnection().getUserId(),a="".concat(o,"_").concat(i.stream.getType());if(this.pathMainAudioMap_.has(a)){var s=this.pathMainAudioMap_.get(a);s.statsToReport.uint64_play_first_frame_time===0&&(s.statsToReport.uint64_play_first_frame_time=Date.now())}}}},{key:"handleNetworkQuality",value:function(i){var o=this;this.hitTest(i.client)&&(this.networkQuality_.totalUplinkLoss+=i.uplinkLoss,this.networkQuality_.totalUplinkRTT+=i.uplinkRTT,this.networkQuality_.count++,i.downlinkLossAndRTTMap.forEach(function(a){var s=a.rtt,c=a.loss,u=a.userId,d=o.networkQuality_.totalDownlinkRTTAndLossMap.get(u);d?(d.totalRTT+=s,d.totalLoss+=c,d.count++):o.networkQuality_.totalDownlinkRTTAndLossMap.set(u,{totalRTT:s,totalLoss:c,count:1})}))}},{key:"handleHeartbeatStats",value:function(i){var o=this;if(this.hitTest(i.client)){var a=i.stats,s=a.msg_up_stream_info,c=a.msg_down_stream_info;if(s.msg_video_status[0]){var u=s.msg_video_status[0],d=u.uint32_video_codec_bitrate,h=u.uint32_video_enc_fps,_=u.uint32_video_width,y=u.uint32_video_height;this.localStreamStats_.totalVideoBitrate+=d,this.localStreamStats_.totalVideoFPS+=h,this.localStreamStats_.totalVideoWidth+=_,this.localStreamStats_.totalVideoHeight+=y,this.localStreamStats_.videoCount++}if(s.msg_audio_status){var b=s.msg_audio_status.audioLevel;Math.floor(100*b)>0&&(this.localStreamStats_.totalAudioLevel+=b,this.localStreamStats_.audioLevelCount++)}c.forEach(function(f){var g=f.msg_user_info,I=f.msg_audio_status,w=f.msg_video_status,j=g.str_identifier;if(w.forEach(function(L){var k=L.uint32_video_stream_type===2,P=L.uint32_video_stream_type===7,A="".concat(j,"_").concat(k?_t:Dt);if(o.remoteStreamStatsMap_.has(A)){var U,T,v=o.remoteStreamStatsMap_.get(A);(k&&(U=v.stream)!==null&&U!==void 0&&U.isMainVideoSubscribed||P&&(T=v.stream)!==null&&T!==void 0&&T.isAuxVideoSubscribed)&&(v.totalVideoFPS+=L.uint32_video_receive_fps,v.totalVideoBitrate+=L.uint32_video_codec_bitrate,v.videoCount++,v.statsToReport.uint32_video_width===0&&(v.statsToReport.uint32_video_width=L.uint32_video_width),v.statsToReport.uint32_video_height===0&&(v.statsToReport.uint32_video_height=L.uint32_video_height))}}),I){var z="".concat(j,"_").concat(_t);if(o.remoteStreamStatsMap_.has(z)){var $,ue=o.remoteStreamStatsMap_.get(z);($=ue.stream)!==null&&$!==void 0&&$.isMainAudioSubscribed&&(ue.totalAudioBitrate+=I.uint32_audio_codec_bitrate,ue.audioCount++,Math.floor(100*I.audioLevel)>0&&(ue.totalAudioLevel+=I.audioLevel,ue.audioLevelCount++))}}})}}},{key:"handlePublishStart",value:function(i){var o=i.client;this.hitTest(o)&&this.localStreamStats_.publishStartTime===0&&(this.localStreamStats_.publishStartTime=Date.now())}},{key:"handleLocalStreamInitStart",value:function(i){var o=i.audio,a=i.video;o&&this.pathJoinRoom_.uint64_init_audio_start_time===0&&(this.pathJoinRoom_.uint64_init_audio_start_time=Date.now()),a&&this.pathJoinRoom_.uint64_init_camera_start_time===0&&(this.pathJoinRoom_.uint64_init_camera_start_time=Date.now())}},{key:"handleLocalStreamInitEnd",value:function(i){var o=i.audio,a=i.video;o&&this.pathJoinRoom_.uint64_init_audio_end_time===0&&(this.pathJoinRoom_.uint64_init_audio_end_time=Date.now()),a&&this.pathJoinRoom_.uint64_init_camera_end_time===0&&(this.pathJoinRoom_.uint64_init_camera_end_time=Date.now())}},{key:"handleLocalStreamInitFailed",value:function(i){var o=i.audio,a=i.video,s=i.error,c=s instanceof ee?s.getExtraCode()||s.getCode():{NotFoundError:1,NotAllowedError:2,NotReadableError:3,OverConstrainedError:4,AbortError:5}[s.name]||Y.UNKNOWN;o&&this.pathJoinRoom_.uint64_init_audio_end_time===0&&(this.pathJoinRoom_.int32_init_audio_ret=c,this.pathJoinRoom_.uint64_init_audio_end_time=Date.now()),a&&this.pathJoinRoom_.uint64_init_camera_end_time===0&&(this.pathJoinRoom_.int32_init_camera_ret=c,this.pathJoinRoom_.uint64_init_camera_end_time=Date.now())}},{key:"hasVideoFlag",value:function(i){return this.firstPublishedUserList_.findIndex(function(o){return o.userId===i&&1&o.flag})>=0}},{key:"hasAudioFlag",value:function(i){return this.firstPublishedUserList_.findIndex(function(o){return o.userId===i&&8&o.flag})>=0}},{key:"hasAuxFlag",value:function(i){return this.firstPublishedUserList_.findIndex(function(o){return o.userId===i&&4&o.flag})>=0}},{key:"hitTest",value:function(i){return i===this.client_}},{key:"checkStorage",value:(r=N(p().mark(function i(){var o;return p().wrap(function(a){for(;;)switch(a.prev=a.next){case 0:if(a.prev=0,!(o=_o.getItem(this.storageKey_))){a.next=6;break}return a.next=5,this.upload(o);case 5:_o.deleteItem(this.storageKey_);case 6:a.next=11;break;case 8:a.prev=8,a.t0=a.catch(0),this.log_.warn(a.t0);case 11:case"end":return a.stop()}},i,this,[[0,8]])})),function(){return r.apply(this,arguments)})},{key:"setStorage",value:function(){this.prepareReport();var i=this.getReportData();i.msg_path_enter_room.uint64_start_time!==0&&_o.setItem(this.storageKey_,i)}},{key:"prepareReport",value:function(){var i=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),a=Math.floor(this.localStreamStats_.totalVideoHeight/this.localStreamStats_.videoCount);this.localStreamStats_.statsToReport.uint32_video_big_resolution=o<<16|a}this.localStreamStats_.audioLevelCount>0&&(this.localStreamStats_.statsToReport.uint32_audio_capture_db=Math.floor(this.localStreamStats_.totalAudioLevel/this.localStreamStats_.audioLevelCount*100)),this.remoteStreamStatsMap_.forEach(function(s,c){var u=s.userId;if(i.networkQuality_.totalDownlinkRTTAndLossMap.has(u)){var d=i.networkQuality_.totalDownlinkRTTAndLossMap.get(u),h=d.totalLoss,_=d.count;s.statsToReport.uint32_avg_down_loss=Math.floor(h/_)}s.videoCount>0&&(s.statsToReport.uint32_video_avg_fps=Math.floor(s.totalVideoFPS/s.videoCount),s.statsToReport.uint32_video_avg_bitrate=Math.floor(s.totalVideoBitrate/s.videoCount)),s.audioCount>0&&(s.statsToReport.uint32_audio_recv_bitrate=s.statsToReport.uint32_audio_bitrate=Math.floor(s.totalAudioBitrate/s.audioCount)),s.audioLevelCount>0&&(s.statsToReport.uint32_audio_play_db=Math.floor(s.totalAudioLevel/s.audioLevelCount*100));var y=i.client_.getCallDurationCalculator();y&&(s.statsToReport.uint32_audio_play_time=y.getDuration(c,Ce),s.statsToReport.uint32_video_play_time=y.getDuration(c,xe)),s.statsToReport.uint32_video_render_first=Math.min(s.statsToReport.uint32_video_render_first,pa);var b=i.client_.getBadCaseDetector();if(b){var f=b.getDataFreezeDuration(c),g=f.dataFreeze,I=f.count,w=b.getRenderFreezeDuration(c).renderFreeze;s.statsToReport.uint32_video_block_count=I,s.statsToReport.uint32_video_block_time=Math.min(g,s.statsToReport.uint32_video_play_time),s.statsToReport.uint32_video_external_block_time=Math.min(w,s.statsToReport.uint32_video_play_time),b.isBlackStream(c)&&s.statsToReport.uint32_video_avg_fps===0?s.statsToReport.uint32_video_black_screen_subjective=1:s.statsToReport.uint32_video_black_screen_subjective=0}(s.subscribeStartTime===0||s.subscribeStartTime-s.streamAddedTime>100||s.playStreamTime===0)&&(i.pathMainAudioMap_.delete(c),i.pathMainVideoMap_.delete(c),s.statsToReport.uint32_video_render_first=0)}),this.pathMainAudioMap_.forEach(function(s,c){i.hasAudioFlag(s.userId)?s.statsToReport.uint64_play_first_frame_time-s.statsToReport.uint64_start_enter_time>pa&&(s.statsToReport.uint64_play_first_frame_time=s.statsToReport.uint64_start_enter_time+pa):i.pathMainAudioMap_.delete(c)}),this.pathMainVideoMap_.forEach(function(s,c){i.hasVideoFlag(s.userId)?s.statsToReport.uint64_render_first_frame_time-s.statsToReport.uint64_start_enter_time>pa&&(s.statsToReport.uint64_render_first_frame_time=s.statsToReport.uint64_start_enter_time+pa):i.pathMainVideoMap_.delete(c)}),this.pathJoinRoom_.uint64_end_time-this.pathJoinRoom_.uint64_start_time>pa&&(this.pathJoinRoom_.uint64_end_time=this.pathJoinRoom_.uint64_start_time+pa)}},{key:"getReportData",value:function(){var i=this.client_.getSignalInfo();return{uint32_sdk_app_id:Number(this.client_.getSDKAppId()),msg_user_info:new $v({userId:this.client_.getUserId(),tinyId:this.client_.getTinyId(),role:this.client_.getRole()===Sr?ao:Qp}),msg_basic_info:this.basicInfo,uint32_acc_ip:Nf(i.relayIp),uint32_client_ip:Nf(i.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:be(this.pathMainVideoMap_.values()).map(function(o){return o.statsToReport}),msg_quality_statistics:be(this.remoteStreamStatsMap_.values()).map(function(o){return o.statsToReport}),str_room_name:String(this.client_.getRoomId()),msg_path_recv_audio:be(this.pathMainAudioMap_.values()).map(function(o){return o.statsToReport}),uint32_info_client_ip:Nf(i.clientIp,"small"),error_code:[],msg_local_statistics:this.localStreamStats_.statsToReport,msg_function_state:Ii.getStateArray()}}},{key:"report",value:(n=N(p().mark(function i(){var o;return p().wrap(function(a){for(;;)switch(a.prev=a.next){case 0:return a.prev=0,o=this.getReportData(),a.next=4,this.upload(o);case 4:_o.deleteItem(this.storageKey_),Ii.clearStateArray(),this.initData(),a.next=12;break;case 9:a.prev=9,a.t0=a.catch(0),this.log_.warn(a.t0);case 12:case"end":return a.stop()}},i,this,[[0,9]])})),function(){return n.apply(this,arguments)})},{key:"upload",value:(t=N(p().mark(function i(o){var a,s,c;return p().wrap(function(u){for(;;)switch(u.prev=u.next){case 0:if(!(Zi||o.msg_path_enter_room.uint64_start_time===0||[cf,Qb,Yb].findIndex(function(d){return d===location.host})>=0)){u.next=2;break}return u.abrupt("return");case 2:return a=Number(this.client_.getSDKAppId()),s=pl(a,zN),u.next=6,vl({url:s,body:JSON.stringify(o)});case 6:if((c=u.sent).data==="ok"){u.next=9;break}throw"key point upload failed: ".concat(c.data);case 9:case"end":return u.stop()}},i,this)})),function(i){return t.apply(this,arguments)})}]),e}(),W(Tc.prototype,"upload",[_I],Object.getOwnPropertyDescriptor(Tc.prototype,"upload"),Tc.prototype),Tc),Ii=function(){function e(){J(this,e)}return ye(e,null,[{key:"handleFunctionState",value:function(t){var n,r,i,o,a=t.className,s=t.fnName,c=t.params;if(!(Zi||[cf,Qb,Yb].findIndex(function(_){return _===location.host})>=0)){var u,d=[];if(a)switch(s){case"createClient":(n=c[0])!==null&&n!==void 0&&n.mode&&d.push("".concat(a,".").concat(s,".").concat(c[0].mode)),(r=c[0])!==null&&r!==void 0&&r.useStringRoomId?d.push("".concat(a,".").concat(s,".stringRoomId")):d.push("".concat(a,".").concat(s,".intRoomId")),(i=c[0])!==null&&i!==void 0&&i.autoSubscribe?d.push("".concat(a,".").concat(s,".autoSubscribe")):d.push("".concat(a,".").concat(s,".manualSubscribe"));break;case"publish":(o=c[1])!==null&&o!==void 0&&o.isAuxiliary?d.push("".concat(a,".").concat(s,".isAuxiliary")):d.push("".concat(a,".").concat(s));break;case"setAudioProfile":case"setVideoProfile":case"setScreenProfile":case"setVideoContentHint":Ft(c[0])&&d.push("".concat(a,".").concat(s,".").concat(c[0]));break;default:d.push("".concat(a,".").concat(s))}else d.push(s);for(var h=0;h<d.length;h++){if(!(u=l3[d[h]]))return;this.stateMap.has(u)?this.stateMap.get(u).int32_call_times+=1:this.stateMap.set(u,{int32_id:u,int32_call_times:1})}}}},{key:"getStateArray",value:function(){return Array.from(this.stateMap.values())}},{key:"clearStateArray",value:function(){this.stateMap.clear()}}]),e}();function kt(e){return function(t,n,r){var i=r.value;return r.value=function(){for(var o=arguments.length,a=new Array(o),s=0;s<o;s++)a[s]=arguments[s];try{e||(e=this.name_),Ii.handleFunctionState({className:e,fnName:n,params:a}),e=void 0}catch(c){this.log_.info(c)}return i.apply(this,a)},r}}ut(Ii,"stateMap",new Map);var kI=(yI=wn.apply(void 0,be(Yt.STREAM.play)),SI=kt(),bI=kt(),ar=function(){function e(a){J(this,e),this.name_=s3,this.userId_=a.userId,this.isRemote_=a.isRemote,this.type_=a.type,this.log_=ke.createLogger({id:"s".concat(a.seq?a.seq:"","|").concat(this.userId_),userId:ve(a.client)?void 0:a.client.getUserId(),sdkAppId:ve(a.client)?void 0:a.client.getSDKAppId(),isLocal:!this.isRemote_,type:this.isRemote_?this.type_:""}),this.client_=null,ve(a.client)||(this.client_=a.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(s){var c=16*Math.random()|0;return(s=="x"?c:3&c|8).toString(16)}),this.audioOutputDeviceId_=0,this.audioVolume_=1,this.emitter_=jk(new _i,this.name_),this.connectionState_=sn,this.installEvents(),ve(a.mirror)||this.log_.warn('TRTC.createStream "mirror" option was deprecated since v4.12.1\uFF0Cplease use localStream.play to set up preview mirror. refer to '.concat(oo,"/en/LocalStream.html#play. TRTC.createStream \u63A5\u53E3\u7684 mirror \u9009\u9879\u4ECE v4.12.1 \u5F00\u59CB\u88AB\u5E9F\u5F03\uFF0C\u8BF7\u4F7F\u7528 localStream.play \u8BBE\u7F6E\u672C\u5730\u6D41\u9884\u89C8\u955C\u50CF\uFF0C\u53C2\u8003\u6587\u6863\uFF1A").concat(oo,"/zh-cn/LocalStream.html#play\u3002"))}var t,n,r,i,o;return ye(e,[{key:"installEvents",value:function(){q.on(ac,this.restartPlayback,this)}},{key:"uninstallEvents",value:function(){q.off(ac,this.restartPlayback,this)}},{key:"getType",value:function(){return this.type_}},{key:"getLogger",value:function(){return this.log_}},{key:"isSubscribed",get:function(){return this.type_===_t&&this.connection_.isMainStreamSubscribed||this.type_===Dt&&this.connection_.isAuxStreamSubscribed}},{key:"isMainVideoSubscribed",get:function(){var a=this.getSubscribedState();return this.type_===_t&&a&&a.video}},{key:"isMainAudioSubscribed",get:function(){var a=this.getSubscribedState();return this.type_===_t&&a&&a.audio}},{key:"isAuxVideoSubscribed",get:function(){var a=this.getSubscribedState();return this.type_===Dt&&a&&a.auxiliary}},{key:"isSmallVideoSubscribed",get:function(){var a=this.getSubscribedState();return this.type_===_t&&a&&a.smallVideo}},{key:"emitConnectionStateChanged",value:function(a){a.state!==this.connectionState_&&(a.state!==sn&&this.isRemote_&&!this.isSubscribed||(this.emitter_.emit(z6,a),this.connectionState_=a.state))}},{key:"setConnection",value:function(a){this.connection_!==a&&(a instanceof Qv?(this.connection_!==null&&this.connection_.off(tt.CONNECTION_STATE_CHANGED,this.emitConnectionStateChanged,this),a.on(tt.CONNECTION_STATE_CHANGED,this.emitConnectionStateChanged,this)):a===null&&this.connection_.off(tt.CONNECTION_STATE_CHANGED,this.emitConnectionStateChanged,this),this.connection_=a)}},{key:"getConnection",value:function(){return this.connection_}},{key:"play",value:(o=N(p().mark(function a(s,c){var u,d,h;return p().wrap(function(_){for(;;)switch(_.prev=_.next){case 0:if(this.log_.info("stream ".concat(this.isPlaying_?"update":"start to"," play with elementId: ").concat(s," and options: ").concat(JSON.stringify(c),".")),!this.isPlaying_){_.next=9;break}return c&&!ve(c.muted)&&(this.muted_=c.muted),c&&!ve(c.objectFit)&&(this.objectFit_=c.objectFit),this.isScreenShare()?this.mirror_=!1:c&&!ve(c.mirror)&&(this.mirror_=c.mirror),this.audioPlayer_&&this.audioPlayer_.setMuted(this.muted_),this.videoPlayer_&&(this.videoPlayer_.setObjectFit(this.objectFit_),this.videoPlayer_.setMirror(this.mirror_)),this.elementId_!==s&&(u=s,Ft(s)&&(u=document.getElementById(s)),u.appendChild(this.div_),this.elementId_=s),_.abrupt("return");case 9:return this.isPlaying_=!0,(d=document.createElement("div")).setAttribute("id","player_".concat(this.id_)),d.setAttribute("style","width: 100%; height: 100%; position: relative; background-color: black; overflow: hidden;"),h=s,Ft(s)&&(h=document.getElementById(s)),h.appendChild(d),this.elementId_=s,this.div_=d,this.isRemote_||(this.muted_=!0),c&&!ve(c.muted)&&(this.muted_=c.muted),this.isScreenShare()&&(this.objectFit_="contain"),c&&!ve(c.objectFit)&&(this.objectFit_=c.objectFit),this.isScreenShare()?this.mirror_=!1:(this.isRemote_||(this.mirror_=!0),c&&!ve(c.mirror)&&(this.mirror_=c.mirror)),q.emit(tm,{stream:this}),_.next=26,Promise.all([this.playAudio(),this.playVideo()]);case 26:q.emit(CV,{stream:this});case 27:case"end":return _.stop()}},a,this)})),function(a,s){return o.apply(this,arguments)})},{key:"playAudio",value:(i=N(p().mark(function a(){var s,c,u=this;return p().wrap(function(d){for(;;)switch(d.prev=d.next){case 0:if(this.hasAudio()&&(!this.isRemote_||this.isMainAudioSubscribed)){d.next=2;break}return d.abrupt("return");case 2:if(s=this.getAudioTrack(),this.audioPlayer_||!s){d.next=17;break}return this.log_.info("create AudioPlayer and play"),this.audioPlayer_=new W5({stream:this,track:s,gainedTrack:(c=this.gain_)===null||c===void 0?void 0:c.audioTrack,div:this.div_,muted:this.muted_,outputDeviceId:this.audioOutputDeviceId_,volume:this.audioVolume_}),this.audioPlayer_.on(gn,function(h){var _={type:Ce,state:h.state,reason:h.reason};q.emit(Wk,H({stream:u},_)),u.emitter_.emit(BT,_)}),d.prev=7,d.next=10,this.audioPlayer_.play();case 10:d.next=17;break;case 12:throw d.prev=12,d.t0=d.catch(7),this.client_&&this.client_.getEnableAutoPlayDialog()&&new R1,this.emitter_.emit(Nm,d.t0),d.t0;case 17:case"end":return d.stop()}},a,this,[[7,12]])})),function(){return i.apply(this,arguments)})},{key:"playVideo",value:(r=N(p().mark(function a(){var s,c=this;return p().wrap(function(u){for(;;)switch(u.prev=u.next){case 0:if(this.hasVideo()&&(!this.isRemote_||this.isMainVideoSubscribed||this.isAuxVideoSubscribed||this.isSmallVideoSubscribed)){u.next=2;break}return u.abrupt("return");case 2:if(s=this.getVideoTrack(),this.videoPlayer_||!s){u.next=18;break}return q.emit(rm,{stream:this}),this.log_.info("create VideoPlayer and play"),this.videoPlayer_=new A1({stream:this,track:s,div:this.div_,muted:this.muted_,objectFit:this.objectFit_,mirror:this.mirror_}),this.videoPlayer_.on(gn,function(d){var h={type:xe,state:d.state,reason:d.reason};q.emit(Wk,H({stream:c},h)),c.emitter_.emit(BT,h)}),u.prev=8,u.next=11,this.videoPlayer_.play();case 11:u.next=18;break;case 13:throw u.prev=13,u.t0=u.catch(8),this.client_&&this.client_.getEnableAutoPlayDialog()&&new R1,this.emitter_.emit(Nm,u.t0),u.t0;case 18:case"end":return u.stop()}},a,this,[[8,13]])})),function(){return r.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(a){}))}},{key:"restartVideo",value:function(){this.isPlaying_&&(this.stopVideo(),this.playVideo().catch(function(a){}))}},{key:"stop",value:function(){this.isPlaying_&&(this.isPlaying_=!1,this.stopAudio(),this.stopVideo(),this.div_.parentNode.removeChild(this.div_))}},{key:"resume",value:(n=N(p().mark(function a(){return p().wrap(function(s){for(;;)switch(s.prev=s.next){case 0:if(this.isPlaying_){s.next=2;break}return s.abrupt("return");case 2:if(this.log_.info("resume"),!this.audioPlayer_){s.next=6;break}return s.next=6,this.audioPlayer_.resume();case 6:if(!this.videoPlayer_){s.next=9;break}return s.next=9,this.videoPlayer_.resume();case 9:case"end":return s.stop()}},a,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(a){a.stop()}),this.mediaStream_=null),this.uninstallEvents())}},{key:"muteAudio",value:function(){return this.addRemoteEvent(!0,Ce),this.doEnableTrack(Ce,!1)}},{key:"muteVideo",value:function(){return this.addRemoteEvent(!0,xe),this.doEnableTrack(xe,!1)}},{key:"unmuteAudio",value:function(){return this.addRemoteEvent(!1,Ce),this.doEnableTrack(Ce,!0)}},{key:"unmuteVideo",value:function(){return this.addRemoteEvent(!1,xe),this.doEnableTrack(xe,!0)}},{key:"addRemoteEvent",value:function(a,s){if(this.isRemote_&&this.client_){var c=this.client_.getUserId(),u="".concat(a?nn:_r," remote ").concat(s);vn(c,{eventId:s===Ce?a?JU:qU:a?WU:KU,eventDesc:u,timestamp:new Date().getTime(),userId:c,tinyId:this.client_.getTinyId(),remoteUserId:this.userId_,remoteTinyId:this.connection_.getTinyId()})}}},{key:"doEnableTrack",value:function(a,s){var c=!1;return a===Ce?this.mediaStream_.getAudioTracks().forEach(function(u){c=!0,u.enabled=s}):this.mediaStream_.getVideoTracks().forEach(function(u){c=!0,u.enabled=s}),c}},{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=N(p().mark(function a(s){return p().wrap(function(c){for(;;)switch(c.prev=c.next){case 0:if(this.audioOutputDeviceId_=s,!this.audioPlayer_){c.next=4;break}return c.next=4,this.audioPlayer_.setSinkId(s);case 4:case"end":return c.stop()}},a,this)})),function(a){return t.apply(this,arguments)})},{key:"setAudioVolume",value:function(a){this.audioVolume_=a,this.log_.info("setAudioVolume to ".concat(a)),this.audioPlayer_&&this.audioPlayer_.setVolume(a)}},{key:"getAudioLevel",value:function(){var a=0;return this.audioPlayer_&&(a=this.audioPlayer_.getAudioLevel()),a}},{key:"getInternalAudioLevel",value:function(){var a=0;return this.audioPlayer_&&(a=this.audioPlayer_.getInternalAudioLevel()),a}},{key:"hasAudio",value:function(){if(this.isRemote_){if(!this.connection_)return!1;var a=this.connection_.getTrackState();return this.type_===_t&&a.audio}return!!this.getAudioTrack()}},{key:"hasVideo",value:function(){if(this.isRemote_){if(!this.connection_)return!1;var a=this.connection_.getTrackState();return this.type_===Dt?a.auxiliary:a.video}return!!this.getVideoTrack()}},{key:"getSubscribedState",value:function(){return this.isRemote_&&this.connection_?this.connection_.getSubscribeState():null}},{key:"getAudioTrack",value:function(){var a=null;if(this.mediaStream_){var s=this.mediaStream_.getAudioTracks();s.length>0&&(a=s[0])}return a}},{key:"getVideoTrack",value:function(){var a=null;if(this.mediaStream_){var s=this.mediaStream_.getVideoTracks();s.length>0&&(a=s[0])}return a}},{key:"getVideoFrame",value:function(){return this.videoPlayer_?this.videoPlayer_.getVideoFrame():null}},{key:"getMediaStream",value:function(){return this.mediaStream_}},{key:"setMediaStream",value:function(a){a!==this.mediaStream_&&(this.mediaStream_&&this.mediaStream_.getTracks().forEach(function(s){return s.stop()}),this.mediaStream_=a)}},{key:"updateVideoPlayingState",value:function(a){this.isPlaying_&&(a?(this.log_.info("playing state updated, play video"),this.playVideo().catch(function(s){})):(this.log_.info("playing state updated, stop video"),this.stopVideo()))}},{key:"updateAudioPlayingState",value:function(a){this.isPlaying_&&(a?(this.log_.info("playing state updated, play audio"),this.playAudio().catch(function(s){})):(this.log_.info("playing state updated, stop audio"),this.stopAudio()))}},{key:"on",value:function(a,s,c){this.emitter_.on(a,s,c)}},{key:"off",value:function(a,s,c){a==="*"?this.emitter_.removeAllListeners():this.emitter_.off(a,s,c)}},{key:"isRemote",value:function(){return this.isRemote_}},{key:"isScreenShare",value:function(){return!this.isRemote_&&this.screen_||this.isRemote_&&this.getType()===mt}},{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}(),W(ar.prototype,"play",[yI],Object.getOwnPropertyDescriptor(ar.prototype,"play"),ar.prototype),W(ar.prototype,"setAudioOutput",[SI],Object.getOwnPropertyDescriptor(ar.prototype,"setAudioOutput"),ar.prototype),W(ar.prototype,"getVideoFrame",[bI],Object.getOwnPropertyDescriptor(ar.prototype,"getVideoFrame"),ar.prototype),ar),Zv=function(e){Nt(n,e);var t=Ar(n);function n(r){var i;J(this,n);var o={isRemote:!0,type:r.type},a=H(H({},r),o);return(i=t.call(this,a)).name_=sf,i.isStreamAddedEventEmitted_=!1,i.isAbleToCallSubscription_=!0,i}return ye(n,[{key:"installEvents",value:function(){se($e(n.prototype),"installEvents",this).call(this),q.on(Ur,this.handleStreamSubscribed,this),q.on(Br,this.handleStreamUnsubscribed,this)}},{key:"uninstallEvents",value:function(){se($e(n.prototype),"uninstallEvents",this).call(this),q.off(Ur,this.handleStreamSubscribed,this),q.off(Br,this.handleStreamUnsubscribed,this)}},{key:"handleStreamSubscribed",value:function(r){r.client===this.client_&&r.stream===this&&this.connection_.getCurrentState()===mn&&this.emitConnectionStateChanged({prevState:sn,state:mn})}},{key:"handleStreamUnsubscribed",value:function(r){r.client===this.client_&&r.stream===this&&this.emitConnectionStateChanged({prevState:mn,state:sn})}},{key:"getType",value:function(){return se($e(n.prototype),"getType",this).call(this)}},{key:"getIsAbleToCallSubscription",value:function(){return this.isAbleToCallSubscription_}},{key:"setIsAbleToCallSubscription",value:function(r){this.isAbleToCallSubscription_=r}},{key:"setIsStreamAddedEventEmitted",value:function(r){this.isStreamAddedEventEmitted_=r}},{key:"getIsStreamAddedEventEmitted",value:function(){return this.isStreamAddedEventEmitted_}},{key:"getAudioTrack",value:function(){return this.connection_&&this.connection_.getTrackState().audio?se($e(n.prototype),"getAudioTrack",this).call(this):null}},{key:"getVideoTrack",value:function(){if(!this.connection_)return null;var r=this.connection_.getTrackState();return(this.type_!==_t||r.video)&&(this.type_!==Dt||r.auxiliary)?se($e(n.prototype),"getVideoTrack",this).call(this):null}},{key:"close",value:function(){se($e(n.prototype),"close",this).call(this)}}]),n}(kI),s7=function(){function e(i){J(this,e),this.client_=i.client,this.subscribedStreams_=new Map,this.unsubscribedStreams_=new Map,this.subscriptedOptions_=new Map,this.autoRecoveryFlags_=new Map}var t,n,r;return ye(e,[{key:"isEnabled",get:function(){return this.client_.getEnv()!=="webrtc"}},{key:"recover",value:(r=N(p().mark(function i(o){var a,s,c;return p().wrap(function(u){for(;;)switch(u.prev=u.next){case 0:if(a=o.getUserId(),s=o.getType(),this.hasAutoRecoveryFlag(a,s)){u.next=5;break}return u.abrupt("return");case 5:if(c=this.getUnsubscribedStream(a,s)?"unsubscribe":"subscribe",u.prev=6,ke.warn("recover() try to recover subscription [".concat(c,"][").concat(a,"][").concat(s,"]")),c!=="subscribe"){u.next=13;break}return u.next=11,this.recoverSubscription(a,o);case 11:u.next=15;break;case 13:return u.next=15,this.recoverUnsubscription(a,o);case 15:Ie.logSuccessEvent({userId:this.client_.getUserId(),eventType:Ub}),ke.warn("recover() recover successfully [".concat(c,"][").concat(a,"][").concat(s,"]")),u.next=23;break;case 19:u.prev=19,u.t0=u.catch(6),ke.error("recover() recover failed [".concat(c,"][").concat(a,"][").concat(s,"]"),u.t0),Ie.logFailedEvent({userId:this.client_.getUserId(),eventType:Ub,error:u.t0});case 23:this.deleteAutoRecoveryFlag(a,s);case 24:case"end":return u.stop()}},i,this,[[6,19]])})),function(i){return r.apply(this,arguments)})},{key:"recoverSubscription",value:(n=N(p().mark(function i(o,a){var s,c,u,d,h;return p().wrap(function(_){for(;;)switch(_.prev=_.next){case 0:if(s=this.getOptions(o,a.getType()),c=this.getSubscribedStream(o,a.getType()),s&&c){_.next=4;break}return _.abrupt("return");case 4:u=this.getStreamMuteState(c),d=u.isAudioMuted,h=u.isVideoMuted,this.mergeStream(c,a),this.recoverPlayingState(c),d&&c.doEnableTrack(Ce,!1),h&&c.doEnableTrack(xe,!1);case 9:case"end":return _.stop()}},i,this)})),function(i,o){return n.apply(this,arguments)})},{key:"recoverUnsubscription",value:(t=N(p().mark(function i(o,a){var s;return p().wrap(function(c){for(;;)switch(c.prev=c.next){case 0:if(s=this.getUnsubscribedStream(o,a.getType())){c.next=3;break}return c.abrupt("return");case 3:this.mergeStream(s,a);case 4:case"end":return c.stop()}},i,this)})),function(i,o){return t.apply(this,arguments)})},{key:"getStreamMuteState",value:function(i){var o={isAudioMuted:!1,isVideoMuted:!1},a=i.getMediaStream();return a&&(o.isAudioMuted=a.getAudioTracks().map(function(s){return s.enabled}).includes(!1),o.isVideoMuted=a.getVideoTracks().map(function(s){return s.enabled}).includes(!1)),o}},{key:"recoverPlayingState",value:function(i){var o=i.isPlaying(),a=i.getDiv();if(o&&a){var s=a.parentNode;i.stop(),i.play(s,{objectFit:i.getObjectFit(),muted:i.getMuted()})}}},{key:"mergeStream",value:function(i,o){var a=o.getConnection(),s=o.getMediaStream();i.setConnection(a),a.setRemoteStream(s.id,i),i.setMediaStream(s),i.updateAudioPlayingState(o.hasAudio()),i.updateVideoPlayingState(o.hasVideo())}},{key:"addSubscriptionRecord",value:function(i,o,a){var s=o.getType();if(this.subscribedStreams_.has(i))this.subscribedStreams_.get(i).set(s,o);else{var c=new Map;c.set(o.getType(),o),this.subscribedStreams_.set(i,c)}if(this.subscriptedOptions_.has(i))this.subscriptedOptions_.get(i).set(s,a);else{var u=new Map;u.set(o.getType(),a),this.subscriptedOptions_.set(i,u)}this.deleteUnsubscriptionRecord(i,s)}},{key:"addUnsubscriptionRecord",value:function(i,o){if(this.unsubscribedStreams_.has(i))this.unsubscribedStreams_.get(i).set(o.getType(),o);else{var a=new Map;a.set(o.getType(),o),this.unsubscribedStreams_.set(i,a)}this.deleteSubscriptionRecord(i,o.getType())}},{key:"getSubscribedStream",value:function(i,o){return this.subscribedStreams_.has(i)&&this.subscribedStreams_.get(i).has(o)?this.subscribedStreams_.get(i).get(o):null}},{key:"getOptions",value:function(i,o){return this.subscriptedOptions_.has(i)&&this.subscriptedOptions_.get(i).has(o)?this.subscriptedOptions_.get(i).get(o):null}},{key:"getUnsubscribedStream",value:function(i,o){return this.unsubscribedStreams_.has(i)&&this.unsubscribedStreams_.get(i).has(o)?this.unsubscribedStreams_.get(i).get(o):null}},{key:"deleteSubscriptionRecord",value:function(i,o){this.subscribedStreams_.has(i)&&this.subscribedStreams_.get(i).delete(o),this.subscriptedOptions_.has(i)&&this.subscriptedOptions_.get(i).delete(o)}},{key:"deleteUnsubscriptionRecord",value:function(i,o){this.unsubscribedStreams_.has(i)&&this.unsubscribedStreams_.get(i).delete(o)}},{key:"markAllStream",value:function(){for(var i=0,o=be(this.subscribedStreams_.entries());i<o.length;i++)for(var a=Te(o[i],2),s=a[0],c=0,u=be(a[1].entries());c<u.length;c++){var d=Te(u[c],1)[0];this.setAutoRecoveryFlag(s,d)}for(var h=0,_=be(this.unsubscribedStreams_.entries());h<_.length;h++)for(var y=Te(_[h],2),b=y[0],f=0,g=be(y[1].entries());f<g.length;f++){var I=Te(g[f],1)[0];this.setAutoRecoveryFlag(b,I)}}},{key:"setAutoRecoveryFlag",value:function(i,o){if(ke.info("setAutoRecoveryFlag() mark [".concat(i,"][").concat(o,"]")),this.autoRecoveryFlags_.has(i))this.autoRecoveryFlags_.get(i).set(o);else{var a=new Map;a.set(o),this.autoRecoveryFlags_.set(i,a)}}},{key:"hasAutoRecoveryFlag",value:function(i,o){return!!this.isEnabled&&this.autoRecoveryFlags_.has(i)&&this.autoRecoveryFlags_.get(i).has(o)}},{key:"deleteAutoRecoveryFlag",value:function(i,o){this.autoRecoveryFlags_.has(i)&&this.autoRecoveryFlags_.get(i).delete(o)}},{key:"delete",value:function(i){this.unsubscribedStreams_.delete(i),this.subscribedStreams_.delete(i),this.subscriptedOptions_.delete(i),this.autoRecoveryFlags_.delete(i)}}]),e}(),c7=function(){function e(t){J(this,e),this.player_=t,this.canvas_=document.createElement(hb),this.canvasCtx_=this.canvas_.getContext("2d")}return ye(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,r=t.videoWidth,i=r*this.canvas_.height/(n*this.canvas_.width);if(i>1.05||i<.95){var o=r*n/(this.canvas_.width*this.canvas_.height);this.setCanvasRect(r/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}(),u7=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"}),l7=function(){function e(t){J(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 ye(e,[{key:"initWorker",value:function(){try{this.worker=new Worker(URL.createObjectURL(u7)),ke.info("init worker processor success")}catch(t){ke.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}(),rd=function(){function e(n){J(this,e),this.localStream_=n,this.player_=null,this.processor_=null,this.initOffscreenSuccess_=!1}var t;return ye(e,[{key:"initialize",value:(t=N(p().mark(function n(){var r;return p().wrap(function(i){for(;;)switch(i.prev=i.next){case 0:if(!(G6()&&((r=navigator)===null||r===void 0?void 0:r.hardwareConcurrency)>=6)){i.next=13;break}return i.prev=1,i.next=4,this.initOffscreen();case 4:this.initOffscreenSuccess_=!0,ke.info("Initialize VideoGenerator successfully!"),i.next=11;break;case 8:i.prev=8,i.t0=i.catch(1),this.initCanvas();case 11:i.next=14;break;case 13:this.initCanvas();case 14:case"end":return i.stop()}},n,this,[[1,8]])})),function(){return t.apply(this,arguments)})},{key:"generateSmallVideoTrack",value:function(n){var r,i=n.height,o=n.width,a=n.frameRate,s=this.getSmallVideoProfile(o,i);return this.initOffscreenSuccess_?(this.processor_.setCanvasRect(s.width,s.height),r=this.processor_.generatorVideoTrack()):(this.processor_.setCanvasRect(s.width,s.height),this.player_.setRect({width:s.width,height:s.height}),r=this.processor_.generateVideoTrackFromCanvasCapture(a),this.interval_=yt.run(rl,this.render.bind(this),{fps:a})),r}},{key:"render",value:function(){this.processor_.canDrawVideoToCanvas&&this.processor_.drawVideoToCanvas()}},{key:"destroy",value:function(){yt.clearTask(this.interval_),this.processor_&&this.processor_.destroy()}},{key:"initOffscreen",value:function(){this.processor_=new l7({videoTrack:this.localStream_.getVideoTrack()})}},{key:"initCanvas",value:function(){this.player_=new A1({stream:this.localStream_,track:this.localStream_.getVideoTrack(),muted:!0,objectFit:"cover",mirror:!1}),this.player_.play().then(function(){ke.info("VideoGenerator: play local video success")}).catch(function(){ke.error("VideoGenerator: Failed to play local video")}),this.processor_=new c7(this.player_)}},{key:"getSmallVideoProfile",value:function(n,r){var i,o=this.localStream_.getVideoTrack(),a=this.localStream_.getVideoProfile();if(yo){var s=o.getSettings();s&&s.width&&s.height&&(a.width=s.width,a.height=s.height)}var c=a.width*a.height,u=n*r;return ke.info("big stream resolution: ".concat(a.width,"*").concat(a.height," small stream resolution: ").concat(n,"*").concat(r," ")),i=c>u?c/u:c/19200,{width:parseInt(a.width/Math.sqrt(i)),height:parseInt(a.height/Math.sqrt(i))}}}]),e}(),id=new Map,d7=function(){var e=N(p().mark(function t(n){var r,i,o;return p().wrap(function(a){for(;;)switch(a.prev=a.next){case 0:if(!kl()){a.next=2;break}return a.abrupt("return");case 2:return a.next=4,h7(n);case 4:if(r=a.sent,ke.info("getUserMedia with constraints: "+JSON.stringify(r)),!r.audio){a.next=11;break}return a.next=9,Tt.getMicrophones();case 9:i=a.sent,ke.info("microphones: ".concat(JSON.stringify(i)));case 11:if(!r.video){a.next=16;break}return a.next=14,Tt.getCameras();case 14:o=a.sent,ke.info("cameras: ".concat(JSON.stringify(o)));case 16:return a.prev=16,a.next=19,navigator.mediaDevices.getUserMedia(r);case 19:return a.abrupt("return",a.sent);case 22:if(a.prev=22,a.t0=a.catch(16),a.t0.name!=="NotFoundError"){a.next=29;break}if(!o||o.length!==0){a.next=27;break}throw new ee({code:Y.DEVICE_NOT_FOUND,message:ne({key:G4})});case 27:if(!i||i.length!==0){a.next=29;break}throw new ee({code:Y.DEVICE_NOT_FOUND,message:ne({key:F4})});case 29:throw new ee({code:Y.INITIALIZE_FAILED,name:a.t0.name,message:a.t0.message,constraint:a.t0.constraint});case 30:case"end":return a.stop()}},t,null,[[16,22]])}));return function(t){return e.apply(this,arguments)}}(),eg=oc({retryFunction:d7,settings:{retries:3,timeout:500},onError:function(e,t,n,r){ke.warn("getUserMedia error: ".concat(e)),e.name==="NotReadableError"?t():e.message.includes("deviceId")&&r[0].retryWhenExactFailed?(r[0].useExact=!1,t()):n(e)},onRetrying:function(e){ke.warn("getUserMedia retrying [".concat(e,"/3]"))}});function h7(e){return TI.apply(this,arguments)}function TI(){return(TI=N(p().mark(function e(t){var n,r,i,o,a,s;return p().wrap(function(c){for(;;)switch(c.prev=c.next){case 0:if(n={echoCancellation:t.echoCancellation,autoGainControl:t.autoGainControl,noiseSuppression:t.noiseSuppression},t.audio){c.next=5;break}n=!1,c.next=15;break;case 5:if(aa(t.microphoneId)){c.next=9;break}n=H({deviceId:t.useExact?{exact:t.microphoneId}:t.microphoneId,sampleRate:t.sampleRate,channelCount:t.channelCount},n),c.next=15;break;case 9:return n=H({sampleRate:t.sampleRate,channelCount:t.channelCount},n),c.next=12,Tt.getMicrophones();case 12:r=c.sent,(i=r.filter(function(u){return u.deviceId.length>0})).length>0&&(n.deviceId={exact:i[0].deviceId});case 15:return o={},a={ideal:t.width,max:t.width},s={ideal:t.height,max:t.height},Tr&&tc&&t.width*t.height<101376&&(a=t.width,s=t.height),o=!ve(t.facingMode)&&t.video?{facingMode:t.facingMode,width:a,height:s,frameRate:t.frameRate}:!aa(t.cameraId)&&t.video?{deviceId:t.useExact?{exact:t.cameraId}:t.cameraId,width:a,height:s,frameRate:t.frameRate}:!!t.video&&(!!ve(t.width)||{width:a,height:s,frameRate:t.frameRate}),c.abrupt("return",{audio:n,video:o});case 21:case"end":return c.stop()}},e)}))).apply(this,arguments)}var p7=function(){var e=N(p().mark(function t(n){var r,i,o,a,s,c,u,d,h;return p().wrap(function(_){for(;;)switch(_.prev=_.next){case 0:if(!kl()){_.next=2;break}return _.abrupt("return");case 2:if(r=null,!(ll&&Pf<74||Yi)){_.next=27;break}return i=tg(n),ke.info("getDisplayMedia with constraints: "+JSON.stringify(i)),_.next=8,navigator.mediaDevices.getDisplayMedia(i);case 8:if(o=_.sent,!n.screenAudio){_.next=14;break}return ke.warn("Your browser not support capture system audio"),_.abrupt("return",o);case 14:if(!n.audio){_.next=24;break}return a=xI(n),ke.info("getUserMedia with constraints: "+JSON.stringify(a)),_.next=19,navigator.mediaDevices.getUserMedia(a);case 19:return r=_.sent,o.addTrack(r.getAudioTracks()[0]),_.abrupt("return",o);case 24:return _.abrupt("return",o);case 25:_.next=53;break;case 27:if(!n.screenAudio){_.next=37;break}return n.audioConstraints={echoCancellation:n.echoCancellation,autoGainControl:n.autoGainControl,noiseSuppression:n.noiseSuppression,sampleRate:44100},s=tg(n),ke.info("getDisplayMedia with constraints: "+JSON.stringify(s)),_.next=33,navigator.mediaDevices.getDisplayMedia(s);case 33:return c=_.sent,_.abrupt("return",c);case 37:return u=tg(n),ke.info("getDisplayMedia with constraints: "+JSON.stringify(u)),_.next=41,navigator.mediaDevices.getDisplayMedia(u);case 41:if(d=_.sent,!n.audio){_.next=52;break}return h=xI(n),ke.info("getUserMedia with constraints: "+JSON.stringify(h)),_.next=47,navigator.mediaDevices.getUserMedia(h);case 47:return r=_.sent,d.addTrack(r.getAudioTracks()[0]),_.abrupt("return",d);case 52:return _.abrupt("return",d);case 53:case"end":return _.stop()}},t)}));return function(t){return e.apply(this,arguments)}}();function xI(e){var t={echoCancellation:e.echoCancellation,autoGainControl:e.autoGainControl,noiseSuppression:e.noiseSuppression,sampleRate:e.sampleRate,channelCount:e.channelCount};return ve(e.microphoneId)||(t.deviceId=e.microphoneId),{audio:t,video:!1}}function tg(e){var t={systemAudio:"include",selfBrowserSurface:"include",surfaceSwitching:"include"},n={width:Yi?{max:e.width}:{ideal:e.width,max:e.width},height:Yi?{max:e.height}:{ideal:e.height,max:e.height},frameRate:e.frameRate,displaySurface:"monitor"};return t.video=n,ve(e.audioConstraints)||(t.audio=e.audioConstraints),t}var II,wI,EI,CI,RI,AI,PI,DI,LI,OI,MI,rt,NI,Ic,ng=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}]]),rg=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}]]),VI=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}]]),fa=new Map,f7=(II=kt(mi),wI=kt(mi),EI=kt(mi),CI=kt(mi),RI=wn.apply(void 0,be(Yt.LOCAL_STREAM.switchDevice)),AI=wn(Yt.STREAM.addTrack),PI=wn(Yt.STREAM.removeTrack),DI=wn(Yt.STREAM.replaceTrack),LI=xc({retries:10,timeout:3e3,onRetryFailed:function(e){Ie.logFailedEvent({userId:this.client_?this.client_.getUserId():this.userId_,eventType:Vb,error:e}),this.emitter_.emit(Nm,new ee({code:Y.DEVICE_AUTO_RECOVER_FAILED,message:e.message}))}}),OI=nd(Yt.LOCAL_STREAM.setAudioCaptureVolume),MI=kt(mi),rt=function(e){Nt(b,e);var t,n,r,i,o,a,s,c,u,d,h,_,y=Ar(b);function b(f){var g;J(this,b);var I=H(H({},f),{isRemote:!1,type:"local"});return(g=y.call(this,I)).name_=mi,g.client_=null,g.video_=f.video,g.audio_=f.audio,g.cameraId_=f.cameraId,g.cameraGroupId_="",g.facingMode_=f.facingMode,g.microphoneId_=f.microphoneId,g.microphoneGroupId_="",g.microphoneLabel_="",g.videoSource_=f.videoSource,g.audioSource_=f.audioSource,g.screen_=f.screen,g.screenAudio_=f.screenAudio,g.audioProfile_={echoCancellation:!0,autoGainControl:!0,noiseSuppression:!0,sampleRate:48e3,channelCount:1,bitrate:40},g.screenAudio_&&(g.audioProfile_.echoCancellation=!0,g.audioProfile_.autoGainControl=!1,g.audioProfile_.noiseSuppression=!1),uo(f.echoCancellation)&&(g.audioProfile_.echoCancellation=f.echoCancellation),uo(f.autoGainControl)&&(g.audioProfile_.autoGainControl=f.autoGainControl),uo(f.noiseSuppression)&&(g.audioProfile_.noiseSuppression=f.noiseSuppression),g.videoProfile_=ng.get("480p_2"),g.screenProfile_=rg.get("1080p"),g.videoSetting_=null,g.muteState_={video:!1,audio:!1,auxVideo:!1},g.beautyStatus_=!1,g.prevAudioRecoverTime_=0,g.prevVideoRecoverTime_=0,g.isAudioRecovering_=!1,g.isVideoRecovering_=!1,g.initState(),g.canvas_=null,g.canvasInterval_=null,g.canvasTrack_=null,g.gain_={audioTrack:null,source:null,gainNode:null},g.captureVolume_=100,g.enableAutoRecoverCapture_=!!ve(f.enableAutoRecoverCapture)||f.enableAutoRecoverCapture,g.enableAutoRecoverOther_=!uo(f.enableAutoRecoverOther)||f.enableAutoRecoverOther,g.log_.info("stream created: ".concat(g.id_," autoRecover: ").concat(g.enableAutoRecoverCapture_)),g.isAIDenoiser=!1,g}return ye(b,[{key:"initState",value:function(){this.isAddingTrack_=!1,this.isRemovingTrack_=!1,this.setIsReadyToPublish(!1),this.setPublishState(Wb)}},{key:"installEvents",value:function(){se($e(b.prototype),"installEvents",this).call(this),q.on(im,this.onVideoTrackStopped,this),q.on(ic,this.onVideoTrackStopped,this),q.on(om,this.onAudioTrackStopped,this),q.on(am,this.onAudioTrackStopped,this)}},{key:"uninstallEvents",value:function(){se($e(b.prototype),"uninstallEvents",this).call(this),q.off(im,this.onVideoTrackStopped,this),q.off(ic,this.onVideoTrackStopped,this),q.off(om,this.onAudioTrackStopped,this),q.off(am,this.onAudioTrackStopped,this)}},{key:"initialize",value:function(){var f=this;return new Promise(function(g,I){if(Tl())I(new ee({code:Y.INVALID_OPERATION,message:ne({key:pk})}));else{if(ve(f.audio_)){var w=new MediaStream;return ve(f.audioSource_)||(w.addTrack(f.audioSource_),f.updateAudioPlayingState(!0)),ve(f.videoSource_)||(w.addTrack(f.videoSource_),f.updateVideoPlayingState(!0)),f.setMediaStream(w),Ie.logSuccessEvent({userId:f.client_?f.client_.getUserId():f.userId_,eventType:Ys,kind:"custom"}),f.setIsReadyToPublish(!0),g()}f.screen_?(f.log_.info("initialize stream audio: "+f.audio_+" screenAudio: "+f.screenAudio_+" screen: "+f.screen_),p7({audio:f.audio_,screenAudio:f.screenAudio_,microphoneId:f.microphoneId_,width:f.screenProfile_.width,height:f.screenProfile_.height,frameRate:f.screenProfile_.frameRate,sampleRate:f.audioProfile_.sampleRate,channelCount:f.audioProfile_.channelCount,autoGainControl:f.audioProfile_.autoGainControl,noiseSuppression:f.audioProfile_.noiseSuppression,echoCancellation:f.audioProfile_.echoCancellation}).then(function(j){f.setMediaStream(j),f.updateAudioPlayingState(f.audio_||f.screenAudio_),f.updateVideoPlayingState(!0);var z=f.getVideoTrack();return f.listenForScreenSharingStopped(z),f.setVideoContentHint(mb),f.updateDeviceIdInUse(),f.setIsReadyToPublish(!0),f.log_.info(JSON.stringify(z.getSettings())),Ie.logSuccessEvent({userId:f.client_?f.client_.getUserId():f.userId_,eventType:Ys,kind:"getDisplayMedia"}),g()}).catch(function(j){Ie.logFailedEvent({userId:f.client_?f.client_.getUserId():f.userId_,eventType:Ys,kind:"getDisplayMedia",error:j}),f.log_.error("getDisplayMedia error observed "+j),I(j instanceof ee?j:new ee({code:Y.INITIALIZE_FAILED,name:j.name,message:j.message}))})):(q.emit(Yf,{stream:f,audio:f.audio_,video:f.video_}),f.log_.info("initialize stream audio: "+f.audio_+" video: "+f.video_),eg({audio:f.audio_,video:f.video_,facingMode:f.facingMode_,cameraId:f.cameraId_,microphoneId:f.microphoneId_,width:f.videoProfile_.width,height:f.videoProfile_.height,frameRate:f.videoProfile_.frameRate,sampleRate:f.audioProfile_.sampleRate,channelCount:f.audioProfile_.channelCount,autoGainControl:f.audioProfile_.autoGainControl,noiseSuppression:f.audioProfile_.noiseSuppression,echoCancellation:f.audioProfile_.echoCancellation,useExact:!0,retryWhenExactFailed:!0}).then(function(j){return q.emit($f,{stream:f,audio:f.audio_,video:f.video_}),f.setMediaStream(j),j.getTracks().forEach(function(z){z.kind===xe&&yo&&(f.videoSetting_=z.getSettings()),F6&&f.log_.info("".concat(z.kind," capabilities: ").concat(JSON.stringify(z.getCapabilities())))}),f.updateAudioPlayingState(f.audio_),f.updateVideoPlayingState(f.video_),f.updateDeviceIdInUse(),f.log_.info("gotStream hasAudio: "+f.hasAudio()+" hasVideo: "+f.hasVideo()),f.setIsReadyToPublish(!0),Ie.logSuccessEvent({userId:f.client_?f.client_.getUserId():f.userId_,eventType:Ys,kind:"getUserMedia"}),g()}).catch(function(j){q.emit(Zf,{stream:f,audio:f.audio_,video:f.video_,error:j}),Ie.logFailedEvent({userId:f.client_?f.client_.getUserId():f.userId_,eventType:Ys,kind:"getUserMedia",error:j}),f.log_.error("getUserMedia error observed "+j),I(j)}))}})}},{key:"listenForScreenSharingStopped",value:function(f){var g=this;f.addEventListener("ended",function(I){g.log_.info("screen sharing was stopped because the video track is ended"),g.emitter_.emit(H6)})}},{key:"muteAudio",value:function(){var f=se($e(b.prototype),"muteAudio",this).call(this);return f&&(this.log_.info("localStream mute audio"),this.sendMutedFlag(Ce,!0)),f}},{key:"muteVideo",value:function(){var f=se($e(b.prototype),"muteVideo",this).call(this);return f&&(this.log_.info("localStream mute video"),this.sendMutedFlag(xe,!0)),f}},{key:"unmuteAudio",value:function(){var f=se($e(b.prototype),"unmuteAudio",this).call(this);return f&&(this.log_.info("localStream unmute audio"),this.sendMutedFlag(Ce,!1)),f}},{key:"unmuteVideo",value:function(){var f=se($e(b.prototype),"unmuteVideo",this).call(this);return f&&(this.log_.info("localStream unmute video"),this.sendMutedFlag(xe,!1)),f}},{key:"sendMutedFlag",value:function(f,g){this.setMuteState(f,g);var I=this.getConnection();if(I){I.sendMutedFlag(this.muteState_,this);var w=I.getUserId(),j=I.getTinyId(),z="".concat(g?nn:_r," local ").concat(f," track");vn(w,{eventId:f===Ce?g?NU:UU:g?VU:BU,eventDesc:z,timestamp:on(),userId:w,tinyId:j})}}},{key:"setMuteState",value:function(f,g){this.muteState_[f]=g,this.log_.info("set ".concat(f," muted state: [").concat(g?"mute":"unmute","]"))}},{key:"setAudioProfile",value:function(f){var g;V(f)==="object"?g=f:(g=VI.get(f))===void 0&&(g=VI.get("standard")),this.log_.info("setAudioProfile: "+JSON.stringify(g)),this.audioProfile_=H(H({},this.audioProfile_),g)}},{key:"setVideoProfile",value:(_=N(p().mark(function f(g){var I,w,j,z;return p().wrap(function($){for(;;)switch($.prev=$.next){case 0:if(!this.connection_||NT()){$.next=2;break}throw new ee({code:Y.NOT_SUPPORTED,message:ne({key:V4})});case 2:if(na(g)?w=H(H({},this.videoProfile_),g):Ft(g)&&(w=ng.get(g),ve(w)&&(w=ng.get("480p_2"))),(I=this.client_)!==null&&I!==void 0&&I.get2k4kFlag()&&(this.client_.get2k4kFlag()!==1&&!this.screen_&&w.height*w.width>=3686400?(w.width=1920,w.height=1080,this.log_.warn(tk)):Ii.handleFunctionState({fnName:"2K_4K"})),w&&w.width*w.height>921600&&xV&&(w.width=1280,w.height=720,this.log_.warn("reset to 1280 * 720 on iOS 13~14")),this.log_.info("setVideoProfile "+JSON.stringify(w)),!(j=this.getVideoTrack())){$.next=10;break}return $.next=10,j.applyConstraints(w);case 10:if(z=this.videoProfile_.bitrate!==w.bitrate,this.videoProfile_=w,!z||!this.connection_){$.next=16;break}return $.next=15,this.connection_.setBandwidth({bandwidth:w.bitrate,type:xe,videoType:Ku});case 15:this.connection_.sendMediaSettings(this);case 16:case"end":return $.stop()}},f,this)})),function(f){return _.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(f){var g=f;Ft(f)&&(g=rg.get(f)||rg.get("1080p")),this.log_.info("setScreenProfile "+JSON.stringify(f)),this.screenProfile_=g}},{key:"getVideoProfile",value:function(){return this.screen_?this.screenProfile_:this.videoProfile_}},{key:"getAudioProfile",value:function(){return this.audioProfile_}},{key:"setVideoContentHint",value:function(f){var g=this.getVideoTrack();g&&"contentHint"in g&&(this.log_.info("set video track contentHint to: "+f),g.contentHint=f,g.contentHint!==f&&this.log_.warn("Invalid video track contentHint: "+f))}},{key:"switchDevice",value:(h=N(p().mark(function f(g,I){var w,j,z,$,ue,L,k,P,A,U,T,v,E,C,O,F,K,re;return p().wrap(function(ce){for(;;)switch(ce.prev=ce.next){case 0:if(this.mediaStream_&&this.cameraId_!==I&&this.facingMode_!==I){ce.next=2;break}return ce.abrupt("return");case 2:if(j=g===xe,!(w=g===Ce)||I!==this.microphoneId_){ce.next=11;break}if(I===tl){ce.next=7;break}return ce.abrupt("return");case 7:return ce.next=9,Y6(this.microphoneGroupId_,this.microphoneLabel_);case 9:if(!ce.sent){ce.next=11;break}return ce.abrupt("return");case 11:return this.setIsReadyToPublish(!1),this.log_.info("switchDevice "+g+" to: "+I),w&&(z=this.getAudioTrack(),$=this.getMicrophoneTrackMixed(),z&&z.stop(),$&&$.stop()),j&&((ue=this.getVideoTrack())&&ue.stop(),Rf&&(L=this.getAudioTrack())&&(this.log_.info("stop audio track first in huawei env"),L.stop())),ce.prev=15,ce.next=18,eg({audio:w||Rf,video:j,facingMode:I===pb||I===fb?I:void 0,cameraId:j?I:this.cameraId_,microphoneId:w?I:this.microphoneId_,width:this.videoProfile_.width,height:this.videoProfile_.height,frameRate:this.videoProfile_.frameRate,sampleRate:this.audioProfile_.sampleRate,channelCount:this.audioProfile_.channelCount,useExact:!0,retryWhenExactFailed:!1});case 18:if(k=ce.sent,P=null,!w){ce.next=25;break}(A=k.getAudioTracks()[0])&&this.isAudioTrackMixed()?(U=this.getAudioTrack(),T=Tt.AudioMixerPlugin.getAudioTrackMap(),v=Tt.AudioMixerPlugin.mix({targetTrack:A,sourceList:T.get(U.id).sourceList,trackList:T.get(U.id).trackList}),P=v):P=A,ce.next=34;break;case 25:if(!(P=k.getVideoTracks()[0])||!this.isVideoTrackBeautified()){ce.next=30;break}return ce.next=29,this.generateBeautyTrack(P);case 29:P=ce.sent;case 30:if(!(E=k.getAudioTracks()[0])||!Rf){ce.next=34;break}return ce.next=34,this.replaceTrack(E);case 34:return ce.next=36,this.replaceTrack(P);case 36:this.updateDeviceIdInUse(),(C=this.getConnection())&&(O=C.getUserId(),F=C.getTinyId(),K=FU,re="switch camera",w&&(K=GU,re="switch microphone"),vn(O,{eventId:K,eventDesc:re,timestamp:on(),userId:O,tinyId:F})),this.log_.info("switch ".concat(w?"microphone":"camera"," success ")),w&&(this.audio_=!0),j&&(this.video_=!0,I!==fb&&I!==pb||(this.facingMode_=I)),this.setIsReadyToPublish(!0),ce.next=50;break;case 45:throw ce.prev=45,ce.t0=ce.catch(15),this.log_.error(ce.t0),w?this.recoverCapture({audio:!0,video:!1,microphoneId:this.microphoneId_}):this.recoverCapture({audio:!1,video:!0,cameraId:this.cameraId_,facingMode:this.facingMode_}),ce.t0;case 50:case"end":return ce.stop()}},f,this,[[15,45]])})),function(f,g){return h.apply(this,arguments)})},{key:"addTrack",value:(d=N(p().mark(function f(g){var I,w,j;return p().wrap(function(z){for(;;)switch(z.prev=z.next){case 0:if(z.prev=0,g.kind===xe&&yo&&(I=g.getSettings(),!this.videoSetting_||I.width===this.videoSetting_.width&&I.height===this.videoSetting_.height||this.log_.warn("video resolution of the track (".concat(I.width," x ").concat(I.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(g),this.mediaStream_.addTrack(g),!(w=this.getConnection())){z.next=11;break}return j=null,g.kind===xe&&(hl||dl)&&Mk(g)&&(j=this.getCanvasTrack()),z.next=11,w.addTrack(j||g,this);case 11:g.kind===Ce?(this.audio_=!0,this.updateAudioPlayingState(!0),this.captureVolume_!==100&&this.setAudioCaptureVolume(this.captureVolume_)):(this.video_=!0,this.updateVideoPlayingState(!0)),this.isAddingTrack_=!1,z.next=20;break;case 15:throw z.prev=15,z.t0=z.catch(0),this.mediaStream_.removeTrack(g),this.isAddingTrack_=!1,z.t0;case 20:case"end":return z.stop()}},f,this,[[0,15]])})),function(f){return d.apply(this,arguments)})},{key:"removeTrack",value:(u=N(p().mark(function f(g){var I;return p().wrap(function(w){for(;;)switch(w.prev=w.next){case 0:if(w.prev=0,this.isRemovingTrack_=!0,!(I=this.getConnection())){w.next=17;break}if(g.kind!==xe||!hl&&!dl||!this.canvasTrack_){w.next=10;break}return w.next=7,I.removeTrack(this.canvasTrack_,this);case 7:this.clearCanvas(),w.next=17;break;case 10:if(g.kind!==Ce||!this.gain_.audioTrack){w.next=15;break}return w.next=13,I.removeTrack(this.gain_.audioTrack,this);case 13:w.next=17;break;case 15:return w.next=17,I.removeTrack(g,this);case 17:this.mediaStream_.removeTrack(g),g.kind===Ce?(this.audio_=!1,this.updateAudioPlayingState(!1),this.stopGainNode()):(this.video_=!1,this.updateVideoPlayingState(!1)),this.isRemovingTrack_=!1,w.next=26;break;case 22:throw w.prev=22,w.t0=w.catch(0),this.isRemovingTrack_=!1,w.t0;case 26:case"end":return w.stop()}},f,this,[[0,22]])})),function(f){return u.apply(this,arguments)})},{key:"replaceTrack",value:(c=N(p().mark(function f(g){var I,w,j;return p().wrap(function(z){for(;;)switch(z.prev=z.next){case 0:if(g.kind===xe&&yo&&(I=g.getSettings(),!this.videoSetting_||I.width===this.videoSetting_.width&&I.height===this.videoSetting_.height||this.log_.warn("video resolution of the track (".concat(I.width," x ").concat(I.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(g),w=this.mediaStream_,g.kind!==Ce){z.next=12;break}if(w.removeTrack(w.getAudioTracks()[0]),w.addTrack(g),se($e(b.prototype),"restartAudio",this).call(this),!this.gain_.gainNode){z.next=10;break}return this.reconnectGainNode(g),z.abrupt("return");case 10:z.next=15;break;case 12:w.removeTrack(w.getVideoTracks()[0]),w.addTrack(g),se($e(b.prototype),"restartVideo",this).call(this);case 15:if(!(j=this.getConnection())){z.next=21;break}if(g.kind!==xe||!hl&&!dl||!this.canvasTrack_){z.next=19;break}return z.abrupt("return");case 19:return z.next=21,j.replaceTrack(g,this);case 21:case"end":return z.stop()}},f,this)})),function(f){return c.apply(this,arguments)})},{key:"recoverCapture",value:(s=N(p().mark(function f(g){var I,w,j,z,$,ue,L,k,P,A,U,T,v,E,C,O,F;return p().wrap(function(K){for(;;)switch(K.prev=K.next){case 0:if(!(!this.mediaStream_||!this.enableAutoRecoverCapture_||g.audio&&!g.video&&this.isAudioRecovering_||g.video&&!g.audio&&this.isVideoRecovering_)){K.next=2;break}return K.abrupt("return");case 2:return g.audio&&(this.isAudioRecovering_=!0),g.video&&(this.isVideoRecovering_=!0),this.log_.warn("recoverCapture() trying "+JSON.stringify(g)),I=this.audio_&&g.audio,w=this.video_&&g.video,K.prev=7,K.next=10,Tt.getCameras();case 10:return j=K.sent,K.next=13,Tt.getMicrophones();case 13:if(z=K.sent,w&&j.length===0&&(w=!1,this.log_.warn("recoverCapture() video flag is true, but no camera detected, set video to false")),I&&z.length===0&&(I=!1,this.log_.warn("recoverCapture() audio flag is true, but no microphone detected, set audio to false")),I||w){K.next=21;break}return g.audio&&(this.isAudioRecovering_=!1),g.video&&(this.isVideoRecovering_=!1),this.log_.warn("recoverCapture() both audio and video are false, aborted"),K.abrupt("return");case 21:return $=g&&j.findIndex(function(re){return re.deviceId===g.cameraId})>=0,ue=g&&z.findIndex(function(re){return re.deviceId===g.microphoneId})>=0,I&&((L=this.getAudioTrack())===null||L===void 0||L.stop()),w&&((k=this.getVideoTrack())===null||k===void 0||k.stop()),K.next=27,eg({audio:I,video:w,cameraId:$?g.cameraId:void 0,microphoneId:ue?g.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});case 27:P=K.sent,A=P.getTracks(),U=0;case 30:if(!(U<A.length)){K.next=57;break}if((T=A[U]).kind!==Ce||!this.isAudioTrackMixed()){K.next=43;break}if(v=this.getAudioTrack(),E=Tt.AudioMixerPlugin.getAudioTrackMap(),(C=E.get(v.id)).hasMicrophone){K.next=39;break}return T.stop(),K.abrupt("continue",54);case 39:return O=Tt.AudioMixerPlugin.mix({targetTrack:T,sourceList:C.sourceList,trackList:C.trackList}),K.next=42,this.replaceTrack(O);case 42:return K.abrupt("continue",54);case 43:if(T.kind!==xe||!this.isVideoTrackBeautified()){K.next=50;break}return K.next=46,this.generateBeautyTrack(T);case 46:return F=K.sent,K.next=49,this.replaceTrack(F);case 49:return K.abrupt("continue",54);case 50:return K.next=52,this.replaceTrack(T);case 52:if(T.readyState!=="ended"){K.next=54;break}throw new Error("new track is failed, muted ".concat(T.muted," readyState ").concat(T.readyState));case 54:U++,K.next=30;break;case 57:this.updateDeviceIdInUse(),Ie.logSuccessEvent({userId:this.client_?this.client_.getUserId():this.userId_,eventType:Vb}),g.audio&&(this.isAudioRecovering_=!1),g.video&&(this.isVideoRecovering_=!1),this.log_.warn("recoverCapture() successfully"),this.emitter_.emit(W6,{isCamera:g.video,isMicrophone:g.audio,cameraId:this.cameraId_,microphoneId:this.microphoneId_}),K.next=71;break;case 65:throw K.prev=65,K.t0=K.catch(7),g.audio&&(this.isAudioRecovering_=!1),g.video&&(this.isVideoRecovering_=!1),this.log_.warn("recoverCapture() failed, "+K.t0),K.t0;case 71:case"end":return K.stop()}},f,this,[[7,65]])})),function(f){return s.apply(this,arguments)})},{key:"updateDeviceIdInUse",value:function(){var f=this;if(!this.mediaStream_)return this.cameraId_="",this.cameraGroupId_="",this.microphoneId_="",void(this.microphoneGroupId_="");yo&&this.mediaStream_.getTracks().forEach(function(w){if(w.kind===Ce&&f.isAudioTrackMixed()){var j=f.getMicrophoneTrackMixed();if(j){var z=j.getSettings(),$=z.deviceId,ue=z.groupId;$&&(f.microphoneId_=$,f.microphoneGroupId_=ue,f.microphoneLabel_=j.label)}}else if(w.kind===xe&&f.isVideoTrackBeautified()){var L=f.getBeautyOriginTrack();if(L){var k=L.getSettings(),P=k.deviceId,A=k.groupId;P&&(f.cameraId_=P,f.cameraGroupId_=A)}}else{var U=w.getSettings(),T=U.deviceId,v=U.groupId;T&&(w.kind===Ce?(f.microphoneId_=T,f.microphoneGroupId_=v,f.microphoneLabel_=w.label):w.kind!==xe||f.screen_||(f.cameraId_=T,f.cameraGroupId_=v))}});var g=this.mediaStream_.getAudioTracks(),I=this.mediaStream_.getVideoTracks();g&&g.length===0&&(this.microphoneId_="",this.microphoneGroupId_=""),I&&I.length===0&&(this.cameraId_="",this.cameraGroupId_="")}},{key:"isAudioTrackMixed",value:function(){if(Tt.AudioMixerPlugin){var f=Tt.AudioMixerPlugin.getAudioTrackMap(),g=this.getAudioTrack();if(f&&g&&f.has(g.id))return!0}return!1}},{key:"getMicrophoneTrackMixed",value:function(){if(Tt.AudioMixerPlugin){var f=Tt.AudioMixerPlugin.getAudioTrackMap(),g=this.getAudioTrack();if(f&&g&&f.has(g.id)){var I=f.get(g.id);return I.hasMicrophone?I.microphoneTrack:null}}return null}},{key:"isVideoTrackBeautified",value:function(){if(Tt.beautyTrackMap){var f=Tt.beautyTrackMap,g=this.getVideoTrack();if(g&&f.has(g.id))return!0}return!1}},{key:"getBeautyOriginTrack",value:function(){if(Tt.beautyTrackMap){var f=Tt.beautyTrackMap,g=this.getVideoTrack();if(g&&f.has(g.id)){var I=f.get(g.id);if(I.originTrack)return I.originTrack}}return null}},{key:"generateBeautyTrack",value:(a=N(p().mark(function f(g){var I,w,j,z;return p().wrap(function($){for(;;)switch($.prev=$.next){case 0:if(I=null,w=this.getVideoTrack(),j=Tt.beautyTrackMap.get(w.id),z=j.param,j.type){$.next=8;break}I=j.pluginInstance.generateBeautyTrack(g),$.next=22;break;case 8:$.t0=j.type,$.next=$.t0==="beauty"?11:$.t0==="virtual"?13:$.t0==="mixed"?17:21;break;case 11:return I=j.pluginInstance.generateBeautyTrack(g),$.abrupt("break",22);case 13:return $.next=15,j.pluginInstance.generateVirtualTrack({videoTrack:g,type:z.type,img:z.img});case 15:case 19:return I=$.sent,$.abrupt("break",22);case 17:return $.next=19,j.pluginInstance.generateMixedTrack({videoTrack:g,type:z.type,img:z.img});case 21:return $.abrupt("break",22);case 22:return j.pluginInstance.deleteSource(w.id),this.log_.info("regenerate beauty track, track id = ".concat(g.id)),$.abrupt("return",I);case 25:case"end":return $.stop()}},f,this)})),function(f){return a.apply(this,arguments)})},{key:"getScreen",value:function(){return this.screen_}},{key:"hasScreenTrack",value:function(){if(this.screen_)return!0;var f=this.getVideoTrack();return!!f&&(f.contentHint===mb||f.contentHint===LN)}},{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(f){this.isReadyToPublish_=f}},{key:"setPublishState",value:function(f){this.publishState_=f}},{key:"setBeautyStatus",value:function(f){this.beautyStatus_=!!f}},{key:"getBeautyStatus",value:function(){return this.beautyStatus_}},{key:"syncMuteState",value:function(){var f=this.getAudioTrack(),g=this.getVideoTrack();if(f){var I=!f.enabled;this.setMuteState(Ce,I)}if(g){var w=!g.enabled;this.setMuteState(xe,w)}this.connection_&&this.connection_.sendMutedFlag(this.muteState_,this)}},{key:"keepMuteState",value:function(f){f instanceof MediaStreamTrack&&this.muteState_[f.kind]&&(f.enabled=!1,this.log_.warn("prev ".concat(f.kind," track is muted, keep mute state")))}},{key:"onVideoTrackStopped",value:(o=N(p().mark(function f(g){var I,w,j=this;return p().wrap(function(z){for(;;)switch(z.prev=z.next){case 0:if(I=g.stream,w=g.type,I===this&&this.video_&&this.cameraId_&&Q6(this.getVideoTrack())&&!this.isVideoRecovering_&&(w!==nn||!tc||!Yi)){z.next=3;break}return z.abrupt("return");case 3:if(!(Date.now()-this.prevVideoRecoverTime_<nl)){z.next=6;break}return setTimeout(function(){return j.onVideoTrackStopped({stream:I,type:w})},nl),z.abrupt("return");case 6:w===nn?setTimeout(function(){var $=j.getVideoTrack();$!=null&&$.muted&&document.visibilityState==="visible"&&j.recoverVideoCapture(w)},5e3):this.recoverVideoCapture(w);case 7:case"end":return z.stop()}},f,this)})),function(f){return o.apply(this,arguments)})},{key:"onAudioTrackStopped",value:(i=N(p().mark(function f(g){var I,w,j=this;return p().wrap(function(z){for(;;)switch(z.prev=z.next){case 0:if(I=g.stream,w=g.type,!(I!==this||!this.audio_||!this.microphoneId_||this.isAudioRecovering_||w===nn&&tc&&Yi)){z.next=3;break}return z.abrupt("return");case 3:if(!(Date.now()-this.prevAudioRecoverTime_<nl)){z.next=6;break}return setTimeout(function(){return j.onAudioTrackStopped({stream:I,type:w})},nl),z.abrupt("return");case 6:w===nn?setTimeout(function(){var $=j.getAudioTrack();$!=null&&$.muted&&document.visibilityState==="visible"&&j.recoverAudioCapture(w)},5e3):this.recoverAudioCapture(w);case 7:case"end":return z.stop()}},f,this)})),function(f){return i.apply(this,arguments)})},{key:"recoverAudioCapture",value:(r=N(p().mark(function f(g){return p().wrap(function(I){for(;;)switch(I.prev=I.next){case 0:return this.prevAudioRecoverTime_=Date.now(),Ie.uploadEvent({log:"stat-local-audio-".concat(g),userId:this.userId_}),I.t0=this,I.next=5,this.getRecoverCaptureDeviceId(!1);case 5:I.t1=I.sent,I.t2={audio:!0,video:!1,microphoneId:I.t1},I.t0.recoverCapture.call(I.t0,I.t2);case 8:case"end":return I.stop()}},f,this)})),function(f){return r.apply(this,arguments)})},{key:"recoverVideoCapture",value:(n=N(p().mark(function f(g){return p().wrap(function(I){for(;;)switch(I.prev=I.next){case 0:return this.prevVideoRecoverTime_=Date.now(),Ie.uploadEvent({log:"stat-local-video-".concat(g),userId:this.userId_}),I.t0=this,I.next=5,this.getRecoverCaptureDeviceId(!0);case 5:I.t1=I.sent,I.t2={audio:!1,video:!0,cameraId:I.t1},I.t0.recoverCapture.call(I.t0,I.t2);case 8:case"end":return I.stop()}},f,this)})),function(f){return n.apply(this,arguments)})},{key:"getRecoverCaptureDeviceId",value:(t=N(p().mark(function f(){var g,I,w,j,z=arguments;return p().wrap(function($){for(;;)switch($.prev=$.next){case 0:if(g=!(z.length>0&&z[0]!==void 0)||z[0],!(I=g?this.cameraId_:this.microphoneId_)||!this.enableAutoRecoverOther_){$.next=17;break}if(fa.has(I)?fa.set(I,fa.get(I)+1):fa.set(I,1),!((w=fa.get(I))>=3)){$.next=17;break}if(!g){$.next=12;break}return $.next=9,Tt.getCameras();case 9:$.t0=$.sent.find(function(ue){return!fa.has(ue.deviceId)}),$.next=15;break;case 12:return $.next=14,Tt.getMicrophones();case 14:$.t0=$.sent.find(function(ue){return!fa.has(ue.deviceId)});case 15:(j=$.t0)&&(this.log_.warn("".concat(g?"camera":"mic"," ").concat(I," capture fail ").concat(w," times, change new ").concat(j.deviceId)),I=j.deviceId);case 17:return $.abrupt("return",I);case 18:case"end":return $.stop()}},f,this)})),function(){return t.apply(this,arguments)})},{key:"setAudioVolume",value:function(f){se($e(b.prototype),"setAudioVolume",this).call(this,f)}},{key:"clearCanvas",value:function(){this.canvasInterval_&&(yt.clearTask(this.canvasInterval_),this.canvasInterval_=null,this.canvas_=null,this.canvasTrack_=null)}},{key:"getCanvasTrack",value:function(){var f=this;if(this.canvasTrack_)return this.canvasTrack_;this.log_.info("gen canvas track");var g=this.getVideoTrack().getSettings(),I=g.width,w=g.height,j=g.frameRate;this.canvas_=document.createElement("canvas");var z=this.canvas_.getContext("2d");this.canvas_.width=I,this.canvas_.height=w,this.canvasInterval_=yt.run(rl,function(){if(f.hasVideo()){var ue=f.getVideoTrack().getSettings();ue.width===f.canvas_.width&&ue.height===f.canvas_.height||(f.canvas_.width=ue.width,f.canvas_.height=ue.height)}f.videoPlayer_&&f.videoPlayer_.element_&&z.drawImage(f.videoPlayer_.element_,0,0,f.canvas_.width,f.canvas_.height)},{fps:Math.max(15,j)});var $=this.canvas_.captureStream();return this.canvasTrack_=$.getVideoTracks()[0],this.canvasTrack_}},{key:"setClient",value:function(f,g){f&&(this.log_.setUserId(f.getUserId()),this.log_.setSdkAppId(f.getSDKAppId()),g||this.syncMuteState()),this.client_=f}},{key:"setAudioCaptureVolume",value:function(){var f=this,g=arguments.length>0&&arguments[0]!==void 0?arguments[0]:100;if(!this.hasAudio()||g<0||!Dm())return!1;if(this.captureVolume_===g)return!0;this.captureVolume_=g,this.log_.info("setCaptureVolume "+g),g/=100;var I=Bk();if(this.gain_.gainNode)this.gain_.gainNode.gain.value=g;else{var w,j=new MediaStream;j.addTrack(this.getAudioTrack());var z=I.createMediaStreamDestination(),$=I.createMediaStreamSource(j),ue=I.createGain();ue.gain.value=g,$.connect(ue),ue.connect(z);var L=z.stream.getAudioTracks()[0],k=function(P){return f.log_.info("gained audio track ".concat(P))};L.onmute=function(){return k("muted")},L.onunmute=function(){return k("unmuted")},L.onended=function(){return k("ended")},this.gain_={source:$,audioTrack:L,gainNode:ue},(w=this.connection_)===null||w===void 0||w.replaceTrack(L),se($e(b.prototype),"restartAudio",this).call(this)}return!0}},{key:"getGainedTrack",value:function(){return this.gain_.audioTrack}},{key:"reconnectGainNode",value:function(f){this.log_.warn("reconnect gain node");var g=new MediaStream;g.addTrack(f);var I=Bk().createMediaStreamSource(g);I.connect(this.gain_.gainNode),this.gain_.source.disconnect(),this.gain_.source=I}},{key:"stopGainNode",value:function(){var f=this.gain_,g=f.audioTrack,I=f.source,w=f.gainNode;w&&(I.disconnect(),w.disconnect(),g.onmute=null,g.onunmute=null,g.onended=null,g.stop(),this.gain_={source:null,gainNode:null,audioTrack:null}),this.captureVolume_=100}},{key:"close",value:function(){this.setIsReadyToPublish(!1),this.stopGainNode(),se($e(b.prototype),"close",this).call(this)}},{key:"setIsAIDenoiser",value:function(f){this.isAIDenoiser=f}}]),b}(kI),W(rt.prototype,"setAudioProfile",[II],Object.getOwnPropertyDescriptor(rt.prototype,"setAudioProfile"),rt.prototype),W(rt.prototype,"setVideoProfile",[wI],Object.getOwnPropertyDescriptor(rt.prototype,"setVideoProfile"),rt.prototype),W(rt.prototype,"setScreenProfile",[EI],Object.getOwnPropertyDescriptor(rt.prototype,"setScreenProfile"),rt.prototype),W(rt.prototype,"setVideoContentHint",[CI],Object.getOwnPropertyDescriptor(rt.prototype,"setVideoContentHint"),rt.prototype),W(rt.prototype,"switchDevice",[RI],Object.getOwnPropertyDescriptor(rt.prototype,"switchDevice"),rt.prototype),W(rt.prototype,"addTrack",[AI],Object.getOwnPropertyDescriptor(rt.prototype,"addTrack"),rt.prototype),W(rt.prototype,"removeTrack",[PI],Object.getOwnPropertyDescriptor(rt.prototype,"removeTrack"),rt.prototype),W(rt.prototype,"replaceTrack",[DI],Object.getOwnPropertyDescriptor(rt.prototype,"replaceTrack"),rt.prototype),W(rt.prototype,"recoverCapture",[LI],Object.getOwnPropertyDescriptor(rt.prototype,"recoverCapture"),rt.prototype),W(rt.prototype,"setAudioCaptureVolume",[OI,MI],Object.getOwnPropertyDescriptor(rt.prototype,"setAudioCaptureVolume"),rt.prototype),rt),UI={voiceActivityDetection:!1},m7=(NI=xc({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)}}),Ic=function(e){Nt(ue,e);var t,n,r,i,o,a,s,c,u,d,h,_,y,b,f,g,I,w,j,z,$=Ar(ue);function ue(L){var k;return J(this,ue),(k=$.call(this,L)).localStream_=null,k.exchangeSDPTimeout_=-1,k.localAuxStream_=null,k.publishingStream_=null,k.isPublishingAuxStream_=!1,k.smallGenerator_=null,k.isSDPExchanging_=!1,k.ssrc_={audio:0,video:0,small:0,auxiliary:0},k.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},k.mixedAudioTrack_=null,k}return ye(ue,[{key:"isMainStreamPublished",get:function(){return!!this.localStream_}},{key:"isAuxStreamPublished",get:function(){return!!this.localAuxStream_}},{key:"publishState",get:function(){var L=this,k={audio:!1,bigVideo:!1,smallVideo:!1,auxVideo:!1};if(this.peerConnection_){var P,A,U,T,v=this.peerConnection_.getSenders();v&&(yi()?(k.audio=!((P=v[0])===null||P===void 0||!P.track),k.bigVideo=!((A=v[1])===null||A===void 0||!A.track),k.smallVideo=!((U=v[2])===null||U===void 0||!U.track),k.auxVideo=!((T=v[3])===null||T===void 0||!T.track)):v.forEach(function(E){E.track&&(E.track.kind===Ce?k.audio=!0:(k.bigVideo=!0,L.smallGenerator_&&(k.smallVideo=!0)))}))}return k}},{key:"initialize",value:function(){se($e(ue.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(){se($e(ue.prototype),"close",this).call(this),this.reset(),this.emitConnectionStateChangedEvent(sn),this.smallGenerator_&&(this.smallGenerator_.destroy(),this.smallGenerator_=null)}},{key:"installEvents",value:function(){this.emitter_.on(tt.ERROR,this.handleError,this),this.emitter_.on(tt.CONNECTION_STATE_CHANGED,this.handleConnectionStateChange,this)}},{key:"uninstallEvents",value:function(){this.emitter_.off(tt.ERROR,this.handleError,this),this.emitter_.off(tt.CONNECTION_STATE_CHANGED,this.handleConnectionStateChange,this)}},{key:"publish",value:(z=N(p().mark(function L(k,P){var A,U,T,v,E,C;return p().wrap(function(O){for(;;)switch(O.prev=O.next){case 0:if(this.publishingStream_=k,this.isPublishingAuxStream_=P,T=k.getVideoTrack(),v=null,!T||P||!this.client_.getIsEnableSmallStream()){O.next=9;break}return this.smallGenerator_=new rd(k),O.next=8,this.smallGenerator_.initialize();case 8:v=this.smallGenerator_.generateSmallVideoTrack(this.client_.smallStreamConfig_);case 9:if((A=this.client_)===null||A===void 0||!A.get2k4kFlag()){O.next=18;break}if(E=this.client_.get2k4kFlag()===1,C=k.getVideoProfile(),E||k.getScreen()||!(C.height*C.width>=3686400)){O.next=18;break}return C.width=1920,C.height=1080,this.log_.warn(tk),O.next=18,k.setVideoProfile(C);case 18:if(this.updateMediaSettings(k,P),!Pm()){O.next=24;break}return O.next=22,this.publishByTransceiver(k,v,P);case 22:O.next=26;break;case 24:return O.next=26,this.publishByAddTrack(k,v);case 26:return this.publishingStream_=null,this.isPublishingAuxStream_=!1,P?this.localAuxStream_=k:this.localStream_=k,(U=this.sei_)===null||U===void 0||U.handleEncodedStreams(),O.abrupt("return",k);case 31:case"end":return O.stop()}},L,this)})),function(L,k){return z.apply(this,arguments)})},{key:"publishByTransceiver",value:(j=N(p().mark(function L(k,P,A){var U,T,v,E,C,O,F;return p().wrap(function(K){for(;;)switch(K.prev=K.next){case 0:if(this.log_.info("publish by transceiver"),U=k.getMediaStream(),T=k.getAudioTrack(),v=k.getVideoTrack(),E=null,(hl||dl)&&Mk(v)&&(E=k.getCanvasTrack()),(C=this.peerConnection_.getTransceivers()).length!==0){K.next=16;break}return this.peerConnection_.addTransceiver(T||Ce,{direction:fi,streams:[U]}),this.peerConnection_.addTransceiver(A?xe:E||v||xe,{direction:fi,streams:[U]}),this.peerConnection_.addTransceiver(P||xe,{direction:fi,streams:[U]}),this.peerConnection_.addTransceiver(A?E||v:xe,{direction:fi,streams:[U]}),K.next=14,this.connect();case 14:K.next=46;break;case 16:if(O=[],!T){K.next=29;break}if(!C[0].sender.track){K.next=24;break}return this.mixAudioTrack(C[0].sender.track,T),K.next=22,C[0].sender.replaceTrack(this.mixedAudioTrack_);case 22:K.next=27;break;case 24:return K.next=26,C[0].sender.replaceTrack(T);case 26:O.push(0);case 27:return K.next=29,this.setBandwidth({bandwidth:k.getAudioBitrate(),type:Ce});case 29:if(!v){K.next=42;break}return F=A?3:1,K.next=33,C[F].sender.replaceTrack(E||v);case 33:return K.next=35,this.setBandwidth({bandwidth:k.getVideoBitrate(),type:xe,videoType:A?mt:Ku});case 35:if(O.push(F),!P){K.next=42;break}return K.next=39,C[2].sender.replaceTrack(P);case 39:return K.next=41,this.setBandwidth({bandwidth:this.client_.smallStreamConfig.bitrate,type:xe,videoType:Nr});case 41:O.push(2);case 42:return K.next=44,this.setTransceiverDirection(fi,O);case 44:return K.next=46,this.doPublishChange();case 46:case"end":return K.stop()}},L,this)})),function(L,k,P){return j.apply(this,arguments)})},{key:"publishByAddTrack",value:(w=N(p().mark(function L(k,P){var A,U,T,v;return p().wrap(function(E){for(;;)switch(E.prev=E.next){case 0:return this.log_.info("publish by addtrack"),A=k.getMediaStream(),U=k.getAudioTrack(),T=k.getVideoTrack(),U&&this.peerConnection_.addTrack(U,A),T&&(this.peerConnection_.addTrack(T,A),P&&((v=new MediaStream).addTrack(P),this.peerConnection_.addTrack(P,v))),E.next=8,this.connect();case 8:case"end":return E.stop()}},L,this)})),function(L,k){return w.apply(this,arguments)})},{key:"unpublish",value:(I=N(p().mark(function L(k){var P,A,U,T;return p().wrap(function(v){for(;;)switch(v.prev=v.next){case 0:if(yi()){v.next=2;break}return v.abrupt("return",this.doUnpublish());case 2:if(P=k.getAudioTrack(),A=k===this.localAuxStream_,U=this.peerConnection_.getSenders(),T=[],!P){v.next=17;break}if(!this.mixedAudioTrack_){v.next=14;break}return this.log_.info("has mixed audioTrack, use another audioTrack"),v.next=11,U[0].replaceTrack(A?this.localStream_.getAudioTrack():this.localAuxStream_.getAudioTrack());case 11:this.destroyMixedAudioTrack(),v.next=17;break;case 14:return v.next=16,U[0].replaceTrack(null);case 16:T.push(0);case 17:if(!A){v.next=25;break}return v.next=20,U[3].replaceTrack(null);case 20:this.localAuxStream_=null,this.mediaSettings_=H(H({},this.mediaSettings_),{},{auxVideoBps:0,auxVideoFps:0,auxVideoWidth:0,auxVideoHeight:0}),T.push(3),v.next=32;break;case 25:return v.next=27,U[1].replaceTrack(null);case 27:return v.next=29,U[2].replaceTrack(null);case 29:this.localStream_=null,this.mediaSettings_=H(H({},this.mediaSettings_),{},{videoWidth:0,videoHeight:0,videoBps:0,videoFps:0,audioFs:0,audioChannel:0,audioBps:0,smallVideoWidth:0,smallVideoHeight:0,smallVideoFps:0,smallVideoBps:0}),T.push(1,2);case 32:if(!this.localStream_&&!this.localAuxStream_){v.next=39;break}return v.next=35,this.setTransceiverDirection(io,T);case 35:return v.next=37,this.doPublishChange();case 37:v.next=41;break;case 39:return v.next=41,this.doUnpublish();case 41:case"end":return v.stop()}},L,this)})),function(L){return I.apply(this,arguments)})},{key:"doPublishChange",value:(g=N(p().mark(function L(){var k;return p().wrap(function(P){for(;;)switch(P.prev=P.next){case 0:return k={state:this.publishState,constraintConfig:this.mediaSettings_},P.next=3,this.signalChannel_.sendWaitForResponse({command:_U,data:k,responseCommand:vt.PUBLISH_STATE_CHANGE_RESULT});case 3:case"end":return P.stop()}},L,this)})),function(){return g.apply(this,arguments)})},{key:"doUnpublish",value:function(){var L=this;return this.signalChannel_.sendWaitForResponse({command:pT,commandDesc:"unpublish",responseCommand:vt.UNPUBLISH_RESULT}).then(function(){L.close()}).catch(function(){L.close()})}},{key:"updateMediaSettings",value:function(L,k){var P=this;this.localAuxStream_&&L===this.localAuxStream_&&(k=!0);var A=this.client_.getSystemResult().detail,U=A.isH264EncodeSupported,T=A.isVp8EncodeSupported;U?this.mediaSettings_.videoCodec="H264":T&&(this.mediaSettings_.videoCodec="VP8"),yo?L.getMediaStream().getTracks().forEach(function(v){var E=v.getSettings();if(v.kind===Ce){var C=1;E.channelCount&&(C=E.channelCount),P.mediaSettings_.audioChannel=C,P.mediaSettings_.audioBps=1e3*L.getAudioBitrate(),P.mediaSettings_.audioFs=E.sampleRate}else if(v.kind===xe){if(k)return P.mediaSettings_.auxVideoWidth=E.width,P.mediaSettings_.auxVideoHeight=E.height,P.mediaSettings_.auxVideoFps=E.frameRate,void(P.mediaSettings_.auxVideoBps=1e3*L.getVideoBitrate());P.client_.getIsEnableSmallStream()&&(P.mediaSettings_.smallVideoWidth=P.client_.smallStreamConfig.width,P.mediaSettings_.smallVideoHeight=P.client_.smallStreamConfig.height,P.mediaSettings_.smallVideoFps=P.client_.smallStreamConfig.frameRate,P.mediaSettings_.smallVideoBps=1e3*P.client_.smallStreamConfig.bitrate),P.mediaSettings_.videoWidth=E.width,P.mediaSettings_.videoHeight=E.height,P.mediaSettings_.videoFps=E.frameRate,P.mediaSettings_.videoBps=1e3*L.getVideoBitrate()}}):this.updateMediaSettingsFromProfile(L),this.log_.info("updateMediaSettings: "+JSON.stringify(this.mediaSettings_))}},{key:"updateMediaSettingsFromProfile",value:function(L){if(L){if(L.hasAudio()){var k=L.getAudioProfile();this.mediaSettings_.audioChannel=k.channelCount,this.mediaSettings_.audioBps=1e3*k.bitrate,this.mediaSettings_.audioFs=k.sampleRate}if(L.hasVideo()){var P=L.getVideoProfile();this.mediaSettings_.videoWidth=P.width,this.mediaSettings_.videoHeight=P.height,this.mediaSettings_.videoFps=P.frameRate,this.mediaSettings_.videoBps=1e3*P.bitrate}}}},{key:"sendMediaSettings",value:function(L){var k=this;this.updateMediaSettings(L),this.signalChannel_.sendWaitForResponse({command:MU,data:this.mediaSettings_,responseCommand:vt.UPDATE_CONSTRAINT_CONFIG_RES}).then(function(P){P.data.code!==0&&k.log_.warn(P.data.message)}).catch(this.log_.warn)}},{key:"addTrack",value:(f=N(p().mark(function L(k,P){var A,U;return p().wrap(function(T){for(;;)switch(T.prev=T.next){case 0:if(this.peerConnection_){T.next=2;break}return T.abrupt("return");case 2:if(U=P===this.localAuxStream_,this.log_.info("is adding ".concat(k.kind," track to current published local ").concat(U?mt:Ze," stream")),(A=this.sei_)===null||A===void 0||A.handleEncodedStreams(),!yi()){T.next=10;break}return T.next=8,this.addTrackByTransceiver(k,P);case 8:T.next=12;break;case 10:return T.next=12,this.addTrackBySender(k);case 12:vn(this.userId_,{eventId:k.kind===Ce?mT:fT,eventDesc:"add ".concat(k.kind," track to current published stream"),timestamp:on(),userId:this.userId_,tinyId:this.tinyId_});case 13:case"end":return T.stop()}},L,this)})),function(L,k){return f.apply(this,arguments)})},{key:"addTrackByTransceiver",value:(b=N(p().mark(function L(k,P){var A,U,T,v;return p().wrap(function(E){for(;;)switch(E.prev=E.next){case 0:if(A=P===this.localAuxStream_,U=this.peerConnection_.getTransceivers(),k.kind!==Ce){E.next=13;break}if(!U[0].sender.track){E.next=9;break}return this.mixAudioTrack(U[0].sender.track,k),E.next=7,U[0].sender.replaceTrack(this.mixedAudioTrack_);case 7:E.next=11;break;case 9:return E.next=11,U[0].sender.replaceTrack(k);case 11:E.next=26;break;case 13:return T=A?3:1,E.next=16,U[T].sender.replaceTrack(k);case 16:if(T!==1||!this.client_.getIsEnableSmallStream()){E.next=23;break}return this.smallGenerator_=new rd(this.localStream_),E.next=20,this.smallGenerator_.initialize();case 20:return v=this.smallGenerator_.generateSmallVideoTrack(this.client_.smallStreamConfig_),E.next=23,U[2].sender.replaceTrack(v);case 23:if(U[T].direction!==io){E.next=26;break}return E.next=26,this.setTransceiverDirection(fi,[T]);case 26:return this.updateMediaSettings(P,A),E.next=29,this.doPublishChange();case 29:case"end":return E.stop()}},L,this)})),function(L,k){return b.apply(this,arguments)})},{key:"addTrackBySender",value:(y=N(p().mark(function L(k){var P,A,U,T,v;return p().wrap(function(E){for(;;)switch(E.prev=E.next){case 0:if(!(yi()&&this.peerConnection_.getTransceivers().findIndex(function(C){return C.direction==="stopped"})>=0)){E.next=4;break}return this.log_.warn("transceiver is stopping, negotiate sdp first"),E.next=4,this.updateOffer(un.REMOVE,k);case 4:if(!(P=this.peerConnection_.getSenders().find(function(C){return C.track&&C.track.kind===k.kind}))){E.next=11;break}return this.log_.warn("sender already exists, remove sender first"),A=P.track,this.removeSender(P),E.next=11,this.updateOffer(un.REMOVE,A);case 11:if(U=this.localStream_.getMediaStream(),this.peerConnection_.addTrack(k,U),k.kind!==xe||!this.client_.getIsEnableSmallStream()){E.next=21;break}return this.smallGenerator_=new rd(this.localStream_),E.next=17,this.smallGenerator_.initialize();case 17:T=this.smallGenerator_.generateSmallVideoTrack(this.client_.smallStreamConfig_),(v=new MediaStream).addTrack(T),this.peerConnection_.addTrack(T,v);case 21:return E.next=23,this.updateOffer(un.ADD,k);case 23:case"end":return E.stop()}},L,this)})),function(L){return y.apply(this,arguments)})},{key:"isNeedToResetOfferOrder",value:function(){if(this.sdpSemantics_===nf||!this.peerConnection_||!this.peerConnection_.localDescription)return!1;for(var L=this.peerConnection_.localDescription.sdp,k=Fr(L),P=0;P<k.media.length;P++)if(k.media[P].mid===0&&k.media[P].type===xe)return!0;return!1}},{key:"removeSender",value:function(L){var k=null;yi()&&(k=this.peerConnection_.getTransceivers().find(function(P){return P.sender&&P.sender.track===L.track})),this.peerConnection_.removeTrack(L),k&&In(k.stop)&&(this.log_.info("stop transceiver"),k.stop())}},{key:"removeTrack",value:(_=N(p().mark(function L(k,P){return p().wrap(function(A){for(;;)switch(A.prev=A.next){case 0:if(this.peerConnection_){A.next=2;break}return A.abrupt("return");case 2:if(this.log_.info("is removing ".concat(k.kind," track from current published local ").concat(P===this.localAuxStream_?mt:Ze," stream")),!yi()){A.next=8;break}return A.next=6,this.removeTrackByTransceiver(k,P);case 6:A.next=10;break;case 8:return A.next=10,this.removeTrackBySender(k);case 10:vn(this.userId_,{eventId:k.kind===Ce?gT:vT,eventDesc:"remove ".concat(k.kind," track from current published stream"),timestamp:on(),userId:this.userId_,tinyId:this.tinyId_});case 11:case"end":return A.stop()}},L,this)})),function(L,k){return _.apply(this,arguments)})},{key:"removeTrackByTransceiver",value:(h=N(p().mark(function L(k,P){var A,U,T;return p().wrap(function(v){for(;;)switch(v.prev=v.next){case 0:if(A=P===this.localAuxStream_,U=this.peerConnection_.getTransceivers(),k.kind!==Ce){v.next=13;break}if(!this.mixedAudioTrack_){v.next=9;break}return v.next=6,U[0].sender.replaceTrack(A?this.localStream_.getAudioTrack():this.localAuxStream_.getAudioTrack());case 6:this.destroyMixedAudioTrack(),v.next=11;break;case 9:return v.next=11,U[0].sender.replaceTrack(null);case 11:v.next=23;break;case 13:return T=A?3:1,v.next=16,U[T].sender.replaceTrack(null);case 16:if(T!==1||!this.smallGenerator_){v.next=21;break}return this.smallGenerator_.destroy(),this.smallGenerator_=null,v.next=21,U[2].sender.replaceTrack(null);case 21:return v.next=23,this.setTransceiverDirection(io,[T]);case 23:return this.updateMediaSettings(P,A),v.next=26,this.doPublishChange();case 26:case"end":return v.stop()}},L,this)})),function(L,k){return h.apply(this,arguments)})},{key:"setTransceiverDirection",value:(d=N(p().mark(function L(k,P){var A,U,T,v,E,C;return p().wrap(function(O){for(;;)switch(O.prev=O.next){case 0:if(Tr){O.next=2;break}return O.abrupt("return");case 2:if(A=!1,U=!1,this.log_.info("setting transceiver ".concat(P.join(",")," direction to ").concat(k)),T=this.peerConnection_.getTransceivers(),P.forEach(function(F){T[F].direction!==k&&(T[F].direction=k,A=!0)}),!A){O.next=14;break}return this.log_.info("updating offer"),O.next=11,this.peerConnection_.createOffer();case 11:return v=O.sent,O.next=14,this.peerConnection_.setLocalDescription(v);case 14:if(E=-1,C=this.peerConnection_.remoteDescription.sdp.split(`\r
99
- `).map(function(F){if(F.match(new RegExp("a=(".concat(io,"|").concat(Kp,"|").concat(fi,")")))&&E++,P.includes(E)){if(k===io&&F.includes("a=".concat(Kp)))return U=!0,"a=".concat(k);if(k===fi&&F.includes("a=".concat(io)))return U=!0,"a=".concat(Kp)}return F}).join(`\r
100
- `),!U){O.next=20;break}return this.log_.info("updating answer"),O.next=20,this.peerConnection_.setRemoteDescription({type:"answer",sdp:C});case 20:case"end":return O.stop()}},L,this)})),function(L,k){return d.apply(this,arguments)})},{key:"removeTrackBySender",value:(u=N(p().mark(function L(k){var P,A,U=this;return p().wrap(function(T){for(;;)switch(T.prev=T.next){case 0:if(k.kind!==xe||!this.isNeedToResetOfferOrder()){T.next=7;break}return this.reset(),this.initialize(),(P=this.localStream_.getMediaStream())===null||P===void 0||P.removeTrack(k),T.next=6,this.publish(this.localStream_);case 6:return T.abrupt("return");case 7:return(A=this.peerConnection_.getSenders().find(function(v){return v.track===k}))&&(this.removeSender(A),k.kind===xe&&this.smallGenerator_&&(this.smallGenerator_.destroy(),this.smallGenerator_=null,this.peerConnection_.getSenders().forEach(function(v){v.track&&v.track.kind===xe&&U.removeSender(v)}))),T.next=11,this.updateOffer(un.REMOVE,k);case 11:case"end":return T.stop()}},L,this)})),function(L){return u.apply(this,arguments)})},{key:"replaceTrack",value:(c=N(p().mark(function L(k,P){var A,U,T,v,E,C,O;return p().wrap(function(F){for(;;)switch(F.prev=F.next){case 0:if((U=(A=this.peerConnection_)===null||A===void 0?void 0:A.getSenders())&&U.length!==0){F.next=3;break}throw new ee({code:Y.INVALID_OPERATION,message:ne({key:dk})});case 3:if(T=P===this.localAuxStream_,this.log_.info("is replacing ".concat(k.kind," track to current published local ").concat(T?mt:Ze," stream")),k.kind!==Ce||!U[0]){F.next=16;break}if(!(this.mixedAudioTrack_&&(v=this.localStream_)!==null&&v!==void 0&&v.hasAudio()&&(E=this.localAuxStream_)!==null&&E!==void 0&&E.hasAudio())){F.next=14;break}return this.destroyMixedAudioTrack(),C=T?this.localStream_.getAudioTrack():this.localAuxStream_.getAudioTrack(),this.mixAudioTrack(k,C),F.next=12,U[0].replaceTrack(this.mixedAudioTrack_);case 12:F.next=16;break;case 14:return F.next=16,U[0].replaceTrack(k);case 16:if(k.kind!==xe){F.next=32;break}if(P!==this.localStream_||!U[1]){F.next=29;break}return F.next=20,U[1].replaceTrack(k);case 20:if(!this.smallGenerator_||!U[2]){F.next=29;break}return this.log_.info("replacing smallVideo"),this.smallGenerator_.destroy(),this.smallGenerator_=new rd(this.localStream_),F.next=26,this.smallGenerator_.initialize();case 26:return O=this.smallGenerator_.generateSmallVideoTrack(this.client_.smallStreamConfig_),F.next=29,U[2].replaceTrack(O);case 29:if(P!==this.localAuxStream_||!U[3]){F.next=32;break}return F.next=32,U[3].replaceTrack(k);case 32:vn(this.userId_,{eventId:k.kind===Ce?zU:HU,eventDesc:"replace ".concat(k.kind," track from current published stream"),timestamp:on(),userId:this.userId_,tinyId:this.tinyId_});case 33:case"end":return F.stop()}},L,this)})),function(L,k){return c.apply(this,arguments)})},{key:"updateOffer",value:(s=N(p().mark(function L(k,P){var A,U,T,v,E,C,O;return p().wrap(function(F){for(;;)switch(F.prev=F.next){case 0:return F.prev=0,F.next=3,this.peerConnection_.createOffer(UI);case 3:return A=F.sent,Tr&&(A.sdp=this.setSDPDirection(A.sdp,"sendrecv")),F.next=7,this.peerConnection_.setLocalDescription(A);case 7:return U=this.updateMediaSettings(this.localStream_||this.localAuxStream_),T={action:k,trackId:P.id,kind:P.kind===xe?"bigVideo":P.kind,type:"offer",sdp:this.peerConnection_.localDescription.sdp,constraintConfig:U,state:this.publishState},this.log_.info("createOffer success, sending updated offer to remote server"),this.log_.debug("updatedOffer: "+T.sdp),F.next=13,this.signalChannel_.sendWaitForResponse({command:gU,data:T,responseCommand:vt.UPDATE_OFFER_RESULT,timeout:1e4,commandDesc:"update offer"});case 13:return v=F.sent,E=v.data,C=E.code,O=E.message,C!==0&&this.checkPublishResultCode(C,O),F.next=18,this.acceptAnswer(v.data.data);case 18:this.updateSSRC(A.sdp),Ie.logSuccessEvent({userId:this.client_.getUserId(),eventType:el,kind:"offer"}),F.next=27;break;case 22:throw F.prev=22,F.t0=F.catch(0),this.log_.error(F.t0),Ie.logFailedEvent({userId:this.client_.getUserId(),eventType:el,kind:"offer",error:F.t0}),F.t0;case 27:case"end":return F.stop()}},L,this,[[0,22]])})),function(L,k){return s.apply(this,arguments)})},{key:"setBandwidth",value:(a=N(p().mark(function L(k){var P,A,U,T,v,E,C,O;return p().wrap(function(F){for(;;)switch(F.prev=F.next){case 0:if(P=k.bandwidth,A=k.type,U=k.videoType,T=U===void 0?"":U,v=k.sdp,NT()||!v){F.next=3;break}return F.abrupt("return",A===xe?this.updateVideoBandwidthRestriction(v,P,T):this.updateAudioBandwidthRestriction(v,P));case 3:if(E=0,A===xe&&(E=T===Nr?2:T===mt?3:1),!(C=this.peerConnection_.getSenders()[E])){F.next=22;break}return(O=C.getParameters()).encodings&&O.encodings.length!==0||(O.encodings=[{}]),P==="unlimited"?delete O.encodings[0].maxBitrate:O.encodings[0].maxBitrate=1e3*P,F.prev=10,F.next=13,C.setParameters(O);case 13:return this.log_.info(T+A+" bandwidth was set to "+P+" kbps"),F.abrupt("return",v);case 17:if(F.prev=17,F.t0=F.catch(10),this.log_.info("failed to set bandwidth by setting maxBitrate: "+F.t0),!v){F.next=22;break}return F.abrupt("return",A===xe?this.updateVideoBandwidthRestriction(v,P,T):this.updateAudioBandwidthRestriction(v,P));case 22:return F.abrupt("return",v);case 23:case"end":return F.stop()}},L,this,[[10,17]])})),function(L){return a.apply(this,arguments)})},{key:"updateVideoBandwidthRestriction",value:function(L,k,P){var A="AS";Tr&&(A="TIAS",k*=1e3);var U=0,T=-1;return P===Nr?U=1:P===mt&&(U=2),L=L.replace(/m=video (.*)\r\nc=IN (.*)\r\n/g,function(v){return++T===U?"".concat(v,"b=").concat(A,":").concat(k,`\r
101
- `):v}),L}},{key:"updateAudioBandwidthRestriction",value:function(L,k){var P="AS";return Tr&&(P="TIAS",k*=1e3),L=L.replace(/m=audio (.*)\r\nc=IN (.*)\r\n/,`m=audio $1\r
62
+ `,i.onclick=this.onQuestionClick.bind(this);var r=document.createElement("div");r.className=Xm,r.innerText="".concat(ra()?"\u8BE6\u60C5 >":"Detail >"),r.onclick=this.onCollapseClick.bind(this);var o=t.content.firstChild,c=o.querySelector(".".concat(wl));return c.appendChild(r),c.appendChild(i),c.appendChild(n),o}},{key:"addDiaLog",value:function(){CT()||(this.dialogNode_=this.createDiaLog(),document.body.appendChild(this.dialogNode_),this.dialogNode_.onclick=this.onConfirm.bind(this),this.dialogNode_.querySelector(".".concat(Io)).onclick=function(t){return t.stopPropagation()},this.bodyPosition_=document.body.style.position,document.body.style.position="fixed",ye.info("show autoplay dialog"),xe.uploadEvent({log:Q6}))}},{key:"deleteDiaLog",value:function(){this.dialogNode_&&(document.body.removeChild(this.dialogNode_),document.body.style.position=this.bodyPosition_,this.dialogNode_=null)}},{key:"onConfirm",value:function(){ye.warn("confirm clicked, try resume stream"),Y.emit(nc),this.deleteDiaLog()}},{key:"onCollapseClick",value:function(){var t=this.dialogNode_.querySelector(".".concat(xT));t.style.visibility="".concat(this.showDetail_?"hidden":"visible"),t.style.height="".concat(this.showDetail_?0:"fit-content"),this.showDetail_=!this.showDetail_,this.isCollapseClicked_||xe.uploadEvent({log:Y6}),this.isCollapseClicked_=!0}},{key:"onQuestionClick",value:function(){window.open(ET,"_blank"),this.isQuestionClicked_||xe.uploadEvent({log:$6}),this.isQuestionClicked_=!0}}]),e}(),PT=function(){function e(n){Q(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 bi,this.initializeElement(),this.state_="NONE",this.pausedRetryCount_=5}var t;return Ie(e,[{key:"isPlaying",get:function(){return this.state_===ro}},{key:"initializeElement",value:function(){var n=new MediaStream;n.addTrack(this.track_);var i=document.createElement(Te);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.div_&&this.div_.appendChild(i),this.element_=i,this.handleEvents()}},{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=H(f().mark(function n(){var i;return f().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=ie({key:Zf,data:{media:"Video",error:r.t0}}),this.log_.warn(i),!i.includes("NotAllowedError")){r.next=11;break}throw new ne({code:ee.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(li,this.handleElementEvent),this.element_.addEventListener(Mt,this.handleElementEvent),this.element_.addEventListener(di,this.handleElementEvent),this.element_.addEventListener(no,this.handleElementEvent),this.element_.addEventListener(Pf,this.handleElementEvent),this.track_.addEventListener(Mt,this.handleTrackEvent),this.track_.addEventListener(en,this.handleTrackEvent),this.track_.addEventListener(_r,this.handleTrackEvent),this.track_.readyState===Mt&&this.handleTrackEvent({type:Mt}),this.track_.muted&&this.handleTrackEvent({type:en})}},{key:"handleElementEvent",value:function(n){var i=this;switch(n.type){case li:this.log_.info("video player is playing"),this.state_=ro,Y.emit(ec,{stream:this.stream_}),this.emitter_.emit(vn,{state:this.state_,reason:li}),this.interval_&&(_t.clearTask(this.interval_),this.interval_=null);break;case Mt:this.log_.info("video player is ended"),this.state_!==hi&&(this.state_=hi,this.emitter_.emit(vn,{state:this.state_,reason:Mt}));break;case di: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_=yr,this.emitter_.emit(vn,{state:this.state_,reason:di}),this.pausedRetryCount_>0&&!CT()&&(this.log_.info("video player auto resume when video paused"),this.resume(),this.pausedRetryCount_--),vi&&(this.interval_=_t.run(function(){i.element_&&i.state_===yr&&i.resume()},{delay:3e3}));break;case no:if(this.element_&&this.element_.error){var r="".concat(bm(),"/").concat(na().name,"/").concat(na().version);this.log_.error("video player error observed. code: ".concat(this.element_.error.code," message: ").concat(this.element_.error.message," deviceInfo: ").concat(r)),xe.uploadEvent({log:"stat-".concat(this.stream_.getType(),"-video-").concat(Vb,"-").concat(this.element_.error.code,"-").concat(r),userId:this.userId_,error:this.element_.error})}break;case Pf:Y.emit(Hp,{stream:this.stream_})}}},{key:"handleTrackEvent",value:function(n){var i=n.type;switch(i){case Mt:this.log_.info("video track is ended"),Y.emit(zp,{stream:this.stream_,type:i}),this.state_!==hi&&(this.state_=hi,this.emitter_.emit(vn,{state:this.state_,reason:Mt}));break;case en:this.log_.info("video track is unable to provide media output"),this.stream_.isRemote()||NS(),Y.emit(tc,{stream:this.stream_,type:i}),this.state_!==yr&&(this.state_=yr,this.emitter_.emit(vn,{state:this.state_,reason:en}));break;case _r:this.log_.info("video track is able to provide media output"),Y.emit(Bp,{stream:this.stream_}),this.state_===yr&&(this.state_=ro,this.emitter_.emit(vn,{state:this.state_,reason:_r}))}}},{key:"unbindEvents",value:function(){this.element_&&(this.element_.removeEventListener(li,this.handleElementEvent),this.element_.removeEventListener(Mt,this.handleElementEvent),this.element_.removeEventListener(di,this.handleElementEvent),this.element_.removeEventListener(no,this.handleElementEvent),this.element_.removeEventListener(Pf,this.handleElementEvent)),this.track_&&(this.track_.removeEventListener(Mt,this.handleTrackEvent),this.track_.removeEventListener(en,this.handleTrackEvent),this.track_.removeEventListener(_r,this.handleTrackEvent))}},{key:"stop",value:function(){this.unbindEvents(),this.div_&&this.div_.removeChild(this.element_),this.element_.srcObject=null,this.element_=null,this.interval_&&_t.clearTask(this.interval_)}},{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}}]),e}(),Ym=typeof ArrayBuffer!="undefined"&&typeof DataView!="undefined",e5=Qn,t5=vr,n5=RangeError,DT=function(e){if(e===void 0)return 0;var t=e5(e),n=t5(t);if(t!==n)throw n5("Wrong length or index");return n},r5=Array,i5=Math.abs,zr=Math.pow,a5=Math.floor,o5=Math.log,s5=Math.LN2,c5={pack:function(e,t,n){var i,r,o,c=r5(n),a=8*n-t-1,s=(1<<a)-1,l=s>>1,u=t===23?zr(2,-24)-zr(2,-77):0,p=e<0||e===0&&1/e<0?1:0,k=0;for((e=i5(e))!=e||e===1/0?(r=e!=e?1:0,i=s):(i=a5(o5(e)/s5),e*(o=zr(2,-i))<1&&(i--,o*=2),(e+=i+l>=1?u/o:u*zr(2,1-l))*o>=2&&(i++,o/=2),i+l>=s?(r=0,i=s):i+l>=1?(r=(e*o-1)*zr(2,t),i+=l):(r=e*zr(2,l-1)*zr(2,t),i=0));t>=8;)c[k++]=255&r,r/=256,t-=8;for(i=i<<t|r,a+=t;a>0;)c[k++]=255&i,i/=256,a-=8;return c[--k]|=128*p,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+=zr(2,t),u-=c}return(l?-1:1)*n*zr(2,u-t)}},u5=Vt,LT=ii,l5=tn,OT=function(e){for(var t=u5(this),n=l5(t),i=arguments.length,r=LT(i>1?arguments[1]:void 0,n),o=i>2?arguments[2]:void 0,c=o===void 0?n:LT(o,n);c>r;)t[r++]=e;return t},El=re,$m=pe,Zm=_e,d5=Ym,MT=Xn,NT=Ln,UT=Rs,ev=ue,Rl=ai,h5=Qn,f5=vr,Al=DT,VT=c5,p5=ks,jT=ja,m5=ri.f,v5=At.f,g5=OT,_5=du,BT=Hi,y5=MT.PROPER,FT=MT.CONFIGURABLE,wo=Ke.get,HT=Ke.set,tv="ArrayBuffer",b5="DataView",GT="Wrong index",Gn=El.ArrayBuffer,rr=Gn,Co=rr&&rr.prototype,Ir=El.DataView,da=Ir&&Ir.prototype,zT=Object.prototype,S5=El.Array,Pl=El.RangeError,k5=$m(g5),T5=$m([].reverse),WT=VT.pack,qT=VT.unpack,JT=function(e){return[255&e]},KT=function(e){return[255&e,e>>8&255]},XT=function(e){return[255&e,e>>8&255,e>>16&255,e>>24&255]},QT=function(e){return e[3]<<24|e[2]<<16|e[1]<<8|e[0]},x5=function(e){return WT(e,23,4)},I5=function(e){return WT(e,52,8)},Dl=function(e,t){v5(e.prototype,t,{get:function(){return wo(this)[t]}})},Ii=function(e,t,n,i){var r=Al(n),o=wo(e);if(r+t>o.byteLength)throw Pl(GT);var c=wo(o.buffer).bytes,a=r+o.byteOffset,s=_5(c,a,a+t);return i?s:T5(s)},wi=function(e,t,n,i,r,o){var c=Al(n),a=wo(e);if(c+t>a.byteLength)throw Pl(GT);for(var s=wo(a.buffer).bytes,l=c+a.byteOffset,u=i(+r),p=0;p<t;p++)s[l+p]=u[o?p:t-p-1]};if(d5){var YT=y5&&Gn.name!==tv;if(ev(function(){Gn(1)})&&ev(function(){new Gn(-1)})&&!ev(function(){return new Gn,new Gn(1.5),new Gn(NaN),Gn.length!=1||YT&&!FT}))YT&&FT&&NT(Gn,"name",tv);else{(rr=function(e){return Rl(this,Co),new Gn(Al(e))}).prototype=Co;for(var nv,$T=m5(Gn),ZT=0;$T.length>ZT;)(nv=$T[ZT++])in rr||NT(rr,nv,Gn[nv]);Co.constructor=rr}jT&&p5(da)!==zT&&jT(da,zT);var Ll=new Ir(new rr(2)),e1=$m(da.setInt8);Ll.setInt8(0,2147483648),Ll.setInt8(1,2147483649),!Ll.getInt8(0)&&Ll.getInt8(1)||UT(da,{setInt8:function(e,t){e1(this,e,t<<24>>24)},setUint8:function(e,t){e1(this,e,t<<24>>24)}},{unsafe:!0})}else Co=(rr=function(e){Rl(this,Co);var t=Al(e);HT(this,{bytes:k5(S5(t),0),byteLength:t}),Zm||(this.byteLength=t)}).prototype,Ir=function(e,t,n){Rl(this,da),Rl(e,Co);var i=wo(e).byteLength,r=h5(t);if(r<0||r>i)throw Pl("Wrong offset");if(r+(n=n===void 0?i-r:f5(n))>i)throw Pl("Wrong length");HT(this,{buffer:e,byteLength:n,byteOffset:r}),Zm||(this.buffer=e,this.byteLength=n,this.byteOffset=r)},da=Ir.prototype,Zm&&(Dl(rr,"byteLength"),Dl(Ir,"buffer"),Dl(Ir,"byteLength"),Dl(Ir,"byteOffset")),UT(da,{getInt8:function(e){return Ii(this,1,e)[0]<<24>>24},getUint8:function(e){return Ii(this,1,e)[0]},getInt16:function(e){var t=Ii(this,2,e,arguments.length>1?arguments[1]:void 0);return(t[1]<<8|t[0])<<16>>16},getUint16:function(e){var t=Ii(this,2,e,arguments.length>1?arguments[1]:void 0);return t[1]<<8|t[0]},getInt32:function(e){return QT(Ii(this,4,e,arguments.length>1?arguments[1]:void 0))},getUint32:function(e){return QT(Ii(this,4,e,arguments.length>1?arguments[1]:void 0))>>>0},getFloat32:function(e){return qT(Ii(this,4,e,arguments.length>1?arguments[1]:void 0),23)},getFloat64:function(e){return qT(Ii(this,8,e,arguments.length>1?arguments[1]:void 0),52)},setInt8:function(e,t){wi(this,1,e,JT,t)},setUint8:function(e,t){wi(this,1,e,JT,t)},setInt16:function(e,t){wi(this,2,e,KT,t,arguments.length>2?arguments[2]:void 0)},setUint16:function(e,t){wi(this,2,e,KT,t,arguments.length>2?arguments[2]:void 0)},setInt32:function(e,t){wi(this,4,e,XT,t,arguments.length>2?arguments[2]:void 0)},setUint32:function(e,t){wi(this,4,e,XT,t,arguments.length>2?arguments[2]:void 0)},setFloat32:function(e,t){wi(this,4,e,x5,t,arguments.length>2?arguments[2]:void 0)},setFloat64:function(e,t){wi(this,8,e,I5,t,arguments.length>2?arguments[2]:void 0)}});BT(rr,tv),BT(Ir,b5);var mc={ArrayBuffer:rr,DataView:Ir},w5=Me,rv=pe,C5=ue,t1=Tt,n1=ii,E5=vr,R5=Du,iv=mc.ArrayBuffer,av=mc.DataView,r1=av.prototype,i1=rv(iv.prototype.slice),A5=rv(r1.getUint8),P5=rv(r1.setUint8);w5({target:"ArrayBuffer",proto:!0,unsafe:!0,forced:C5(function(){return!new iv(2).slice(1,void 0).byteLength})},{slice:function(e,t){if(i1&&t===void 0)return i1(t1(this),e);for(var n=t1(this).byteLength,i=n1(e,n),r=n1(t===void 0?n:t,n),o=new(R5(this,iv))(E5(r-i)),c=new av(this),a=new av(o),s=0;i<r;)P5(a,s++,A5(c,i++));return o}}),Me({global:!0,constructor:!0,forced:!Ym},{DataView:mc.DataView});var D5=Me,L5=Fa,O5=pe([].reverse),a1=[1,2];D5({target:"Array",proto:!0,forced:String(a1)===String(a1.reverse())},{reverse:function(){return L5(this)&&(this.length=this.length),O5(this)}});var M5=Ut,N5=Vt,U5=_n,V5=tn,j5=TypeError,o1=function(e){return function(t,n,i,r){M5(n);var o=N5(t),c=U5(o),a=V5(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 j5("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}},ov={left:o1(!1),right:o1(!0)},B5=ov.left,s1=dr,F5=Bs;Me({target:"Array",proto:!0,forced:!Ms("reduce")||!F5&&s1>79&&s1<83},{reduce:function(e){var t=arguments.length;return B5(this,e,t,t>1?arguments[1]:void 0)}});var H5=As,G5="ArrayBuffer",c1=mc.ArrayBuffer;Me({global:!0,constructor:!0,forced:re.ArrayBuffer!==c1},{ArrayBuffer:c1}),H5(G5);var z5=Me,u1=Fa,W5=_u,q5=at,l1=ii,J5=tn,K5=yn,X5=ws,Q5=tt,Y5=Ba,$5=Os("slice"),Z5=Q5("species"),sv=Array,ej=Math.max;z5({target:"Array",proto:!0,forced:!$5},{slice:function(e,t){var n,i,r,o=K5(this),c=J5(o),a=l1(e,c),s=l1(t===void 0?c:t,c);if(u1(o)&&(n=o.constructor,(W5(n)&&(n===sv||u1(n.prototype))||q5(n)&&(n=n[Z5])===null)&&(n=void 0),n===sv||n===void 0))return Y5(o,a,s);for(i=new(n===void 0?sv:n)(ej(s-a,0)),r=0;a<s;a++,r++)a in o&&X5(i,r,o[a]);return i.length=r,i}});var d1=re,tj=ue,nj=pe,rj=zt,ij=Ru.trim,h1=a0,vc=d1.parseInt,f1=d1.Symbol,p1=f1&&f1.iterator,m1=/^[+-]?0x/i,aj=nj(m1.exec),v1=vc(h1+"08")!==8||vc(h1+"0x16")!==22||p1&&!tj(function(){vc(Object(p1))})?function(e,t){var n=ij(rj(e));return vc(n,t>>>0||(aj(m1,n)?16:10))}:vc;Me({global:!0,forced:parseInt!=v1},{parseInt:v1});var gn,Eo,Ol,cv={exports:{}},oj=Ym,uv=_e,ln=re,g1=it,Ml=at,Ci=kt,lv=Pr,sj=Jn,cj=Ln,dv=Xt,uj=At.f,lj=bn,Nl=ks,Ro=ja,dj=tt,hj=Mi,_1=Ke.enforce,fj=Ke.get,Ul=ln.Int8Array,hv=Ul&&Ul.prototype,y1=ln.Uint8ClampedArray,b1=y1&&y1.prototype,wr=Ul&&Nl(Ul),ir=hv&&Nl(hv),pj=Object.prototype,fv=ln.TypeError,S1=dj("toStringTag"),pv=hj("TYPED_ARRAY_TAG"),mj="TypedArrayConstructor",Wr=oj&&!!Ro&&lv(ln.opera)!=="Opera",k1=!1,qr={Int8Array:1,Uint8Array:1,Uint8ClampedArray:1,Int16Array:2,Uint16Array:2,Int32Array:4,Uint32Array:4,Float32Array:4,Float64Array:8},mv={BigInt64Array:8,BigUint64Array:8},T1=function(e){var t=Nl(e);if(Ml(t)){var n=fj(t);return n&&Ci(n,mj)?n.TypedArrayConstructor:T1(t)}},x1=function(e){if(!Ml(e))return!1;var t=lv(e);return Ci(qr,t)||Ci(mv,t)};for(gn in qr)(Ol=(Eo=ln[gn])&&Eo.prototype)?_1(Ol).TypedArrayConstructor=Eo:Wr=!1;for(gn in mv)(Ol=(Eo=ln[gn])&&Eo.prototype)&&(_1(Ol).TypedArrayConstructor=Eo);if((!Wr||!g1(wr)||wr===Function.prototype)&&(wr=function(){throw fv("Incorrect invocation")},Wr))for(gn in qr)ln[gn]&&Ro(ln[gn],wr);if((!Wr||!ir||ir===pj)&&(ir=wr.prototype,Wr))for(gn in qr)ln[gn]&&Ro(ln[gn].prototype,ir);if(Wr&&Nl(b1)!==ir&&Ro(b1,ir),uv&&!Ci(ir,S1))for(gn in k1=!0,uj(ir,S1,{get:function(){return Ml(this)?this[pv]:void 0}}),qr)ln[gn]&&cj(ln[gn],pv,gn);var Ge={NATIVE_ARRAY_BUFFER_VIEWS:Wr,TYPED_ARRAY_TAG:k1&&pv,aTypedArray:function(e){if(x1(e))return e;throw fv("Target is not a typed array")},aTypedArrayConstructor:function(e){if(g1(e)&&(!Ro||lj(wr,e)))return e;throw fv(sj(e)+" is not a typed array constructor")},exportTypedArrayMethod:function(e,t,n,i){if(uv){if(n)for(var r in qr){var o=ln[r];if(o&&Ci(o.prototype,e))try{delete o.prototype[e]}catch(c){try{o.prototype[e]=t}catch(a){}}}ir[e]&&!n||dv(ir,e,n?t:Wr&&hv[e]||t,i)}},exportTypedArrayStaticMethod:function(e,t,n){var i,r;if(uv){if(Ro){if(n){for(i in qr)if((r=ln[i])&&Ci(r,e))try{delete r[e]}catch(o){}}if(wr[e]&&!n)return;try{return dv(wr,e,n?t:Wr&&wr[e]||t)}catch(o){}}for(i in qr)!(r=ln[i])||r[e]&&!n||dv(r,e,t)}},getTypedArrayConstructor:T1,isView:function(e){if(!Ml(e))return!1;var t=lv(e);return t==="DataView"||Ci(qr,t)||Ci(mv,t)},isTypedArray:x1,TypedArray:wr,TypedArrayPrototype:ir},I1=re,vv=ue,vj=mu,gj=Ge.NATIVE_ARRAY_BUFFER_VIEWS,_j=I1.ArrayBuffer,ha=I1.Int8Array,yj=!gj||!vv(function(){ha(1)})||!vv(function(){new ha(-1)})||!vj(function(e){new ha,new ha(null),new ha(1.5),new ha(e)},!0)||vv(function(){return new ha(new _j(2),1,void 0).length!==1}),bj=Qn,Sj=RangeError,kj=function(e){var t=bj(e);if(t<0)throw Sj("The argument can't be less than 0");return t},Tj=RangeError,w1=function(e,t){var n=kj(e);if(n%t)throw Tj("Wrong offset");return n},xj=Pr,Ij=pe("".slice),wj=Ra,Cj=TypeError,C1=function(e){var t=wj(e,"number");if(typeof t=="number")throw Cj("Can't convert number to bigint");return BigInt(t)},Ej=Lr,Rj=Xe,Aj=k0,Pj=Vt,Dj=tn,Lj=fu,Oj=Cs,Mj=sh,Nj=function(e){return Ij(xj(e),0,3)==="Big"},Uj=Ge.aTypedArrayConstructor,Vj=C1,E1=Me,R1=re,A1=Xe,jj=_e,Bj=yj,Ao=Ge,P1=mc,D1=ai,Fj=Ze,gc=Ln,Hj=JS,Gj=vr,L1=DT,gv=w1,O1=Aa,_c=kt,zj=Pr,_v=at,Wj=Di,qj=Va,Jj=bn,Vl=ja,Kj=ri.f,M1=function(e){var t,n,i,r,o,c,a,s,l=Aj(this),u=Pj(e),p=arguments.length,k=p>1?arguments[1]:void 0,x=k!==void 0,E=Oj(u);if(E&&!Mj(E))for(s=(a=Lj(u,E)).next,u=[];!(c=Rj(s,a)).done;)u.push(c.value);for(x&&p>2&&(k=Ej(k,arguments[2])),n=Dj(u),i=new(Uj(l))(n),r=Nj(i),t=0;n>t;t++)o=x?k(u[t],t):u[t],i[t]=r?Vj(o):+o;return i},Xj=nn.forEach,Qj=As,N1=At,U1=be,Yj=vu,yv=Ke.get,$j=Ke.set,Zj=Ke.enforce,bv=N1.f,e8=U1.f,t8=Math.round,Sv=R1.RangeError,V1=P1.ArrayBuffer,n8=V1.prototype,r8=P1.DataView,jl=Ao.NATIVE_ARRAY_BUFFER_VIEWS,j1=Ao.TYPED_ARRAY_TAG,B1=Ao.TypedArray,yc=Ao.TypedArrayPrototype,i8=Ao.aTypedArrayConstructor,kv=Ao.isTypedArray,Bl="BYTES_PER_ELEMENT",Tv="Wrong length",F1=function(e,t){i8(e);for(var n=0,i=t.length,r=new e(i);i>n;)r[n]=t[n++];return r},Fl=function(e,t){bv(e,t,{get:function(){return yv(this)[t]}})},H1=function(e){var t;return Jj(n8,e)||(t=zj(e))=="ArrayBuffer"||t=="SharedArrayBuffer"},G1=function(e,t){return kv(e)&&!Wj(t)&&t in e&&Hj(+t)&&t>=0},z1=function(e,t){return t=O1(t),G1(e,t)?Fj(2,e[t]):e8(e,t)},W1=function(e,t,n){return t=O1(t),!(G1(e,t)&&_v(n)&&_c(n,"value"))||_c(n,"get")||_c(n,"set")||n.configurable||_c(n,"writable")&&!n.writable||_c(n,"enumerable")&&!n.enumerable?bv(e,t,n):(e[t]=n.value,e)};jj?(jl||(U1.f=z1,N1.f=W1,Fl(yc,"buffer"),Fl(yc,"byteOffset"),Fl(yc,"byteLength"),Fl(yc,"length")),E1({target:"Object",stat:!0,forced:!jl},{getOwnPropertyDescriptor:z1,defineProperty:W1}),cv.exports=function(e,t,n){var i=e.match(/\d+$/)[0]/8,r=e+(n?"Clamped":"")+"Array",o="get"+e,c="set"+e,a=R1[r],s=a,l=s&&s.prototype,u={},p=function(x,E){bv(x,E,{get:function(){return function(I,m){var T=yv(I);return T.view[o](m*i+T.byteOffset,!0)}(this,E)},set:function(I){return function(m,T,v){var C=yv(m);n&&(v=(v=t8(v))<0?0:v>255?255:255&v),C.view[c](T*i+C.byteOffset,v,!0)}(this,E,I)},enumerable:!0})};jl?Bj&&(s=t(function(x,E,I,m){return D1(x,l),Yj(_v(E)?H1(E)?m!==void 0?new a(E,gv(I,i),m):I!==void 0?new a(E,gv(I,i)):new a(E):kv(E)?F1(s,E):A1(M1,s,E):new a(L1(E)),x,s)}),Vl&&Vl(s,B1),Xj(Kj(a),function(x){x in s||gc(s,x,a[x])}),s.prototype=l):(s=t(function(x,E,I,m){D1(x,l);var T,v,C,O=0,N=0;if(_v(E)){if(!H1(E))return kv(E)?F1(s,E):A1(M1,s,E);T=E,N=gv(I,i);var j=E.byteLength;if(m===void 0){if(j%i||(v=j-N)<0)throw Sv(Tv)}else if((v=Gj(m)*i)+N>j)throw Sv(Tv);C=v/i}else C=L1(E),T=new V1(v=C*i);for($j(x,{buffer:T,byteOffset:N,byteLength:v,length:C,view:new r8(T)});O<C;)p(x,O++)}),Vl&&Vl(s,B1),l=s.prototype=qj(yc)),l.constructor!==s&&gc(l,"constructor",s),Zj(l).TypedArrayConstructor=s,j1&&gc(l,j1,r);var k=s!=a;u[r]=s,E1({global:!0,constructor:!0,forced:k,sham:!jl},u),Bl in s||gc(s,Bl,i),Bl in l||gc(l,Bl,i),Qj(r)}):cv.exports=function(){},(0,cv.exports)("Uint8",function(e){return function(t,n,i){return e(this,t,n,i)}});var a8=Vt,xv=ii,o8=tn,s8=G_,c8=Math.min,u8=[].copyWithin||function(e,t){var n=a8(this),i=o8(n),r=xv(e,i),o=xv(t,i),c=arguments.length>2?arguments[2]:void 0,a=c8((c===void 0?i:xv(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]:s8(n,r),r+=s,o+=s;return n},q1=Ge,l8=pe(u8),d8=q1.aTypedArray;(0,q1.exportTypedArrayMethod)("copyWithin",function(e,t){return l8(d8(this),e,t,arguments.length>2?arguments[2]:void 0)});var h8=nn.every,f8=Ge.aTypedArray;(0,Ge.exportTypedArrayMethod)("every",function(e){return h8(f8(this),e,arguments.length>1?arguments[1]:void 0)});var p8=OT,m8=C1,v8=Pr,g8=Xe,_8=ue,y8=Ge.aTypedArray,b8=Ge.exportTypedArrayMethod,S8=pe("".slice);b8("fill",function(e){var t=arguments.length;y8(this);var n=S8(v8(this),0,3)==="Big"?m8(e):+e;return g8(p8,this,n,t>1?arguments[1]:void 0,t>2?arguments[2]:void 0)},_8(function(){var e=0;return new Int8Array(2).fill({valueOf:function(){return e++}}),e!==1}));var k8=tn,T8=Du,x8=Ge.aTypedArrayConstructor,I8=Ge.getTypedArrayConstructor,Hl=function(e){return x8(T8(e,I8(e)))},w8=function(e,t){for(var n=0,i=k8(t),r=new e(i);i>n;)r[n]=t[n++];return r},C8=Hl,E8=nn.filter,R8=function(e,t){return w8(C8(e),t)},A8=Ge.aTypedArray;(0,Ge.exportTypedArrayMethod)("filter",function(e){var t=E8(A8(this),e,arguments.length>1?arguments[1]:void 0);return R8(this,t)});var P8=nn.find,D8=Ge.aTypedArray;(0,Ge.exportTypedArrayMethod)("find",function(e){return P8(D8(this),e,arguments.length>1?arguments[1]:void 0)});var L8=nn.findIndex,O8=Ge.aTypedArray;(0,Ge.exportTypedArrayMethod)("findIndex",function(e){return L8(O8(this),e,arguments.length>1?arguments[1]:void 0)});var M8=nn.forEach,N8=Ge.aTypedArray;(0,Ge.exportTypedArrayMethod)("forEach",function(e){M8(N8(this),e,arguments.length>1?arguments[1]:void 0)});var U8=_s.includes,V8=Ge.aTypedArray;(0,Ge.exportTypedArrayMethod)("includes",function(e){return U8(V8(this),e,arguments.length>1?arguments[1]:void 0)});var j8=_s.indexOf,B8=Ge.aTypedArray;(0,Ge.exportTypedArrayMethod)("indexOf",function(e){return j8(B8(this),e,arguments.length>1?arguments[1]:void 0)});var F8=re,H8=ue,Iv=pe,J1=Ge,wv=Fg,Cv=tt("iterator"),K1=F8.Uint8Array,G8=Iv(wv.values),z8=Iv(wv.keys),W8=Iv(wv.entries),Ev=J1.aTypedArray,Gl=J1.exportTypedArrayMethod,Po=K1&&K1.prototype,zl=!H8(function(){Po[Cv].call([1])}),X1=!!Po&&Po.values&&Po[Cv]===Po.values&&Po.values.name==="values",Q1=function(){return G8(Ev(this))};Gl("entries",function(){return W8(Ev(this))},zl),Gl("keys",function(){return z8(Ev(this))},zl),Gl("values",Q1,zl||!X1,{name:"values"}),Gl(Cv,Q1,zl||!X1,{name:"values"});var q8=Ge.aTypedArray,J8=Ge.exportTypedArrayMethod,K8=pe([].join);J8("join",function(e){return K8(q8(this),e)});var X8=Gi,Q8=yn,Y8=Qn,$8=tn,Z8=Ms,eB=Math.min,Rv=[].lastIndexOf,Y1=!!Rv&&1/[1].lastIndexOf(1,-0)<0,tB=Z8("lastIndexOf"),nB=Y1||!tB?function(e){if(Y1)return X8(Rv,this,arguments)||0;var t=Q8(this),n=$8(t),i=n-1;for(arguments.length>1&&(i=eB(i,Y8(arguments[1]))),i<0&&(i=n+i);i>=0;i--)if(i in t&&t[i]===e)return i||0;return-1}:Rv,rB=Gi,iB=nB,aB=Ge.aTypedArray;(0,Ge.exportTypedArrayMethod)("lastIndexOf",function(e){var t=arguments.length;return rB(iB,aB(this),t>1?[e,arguments[1]]:[e])});var oB=nn.map,sB=Hl,cB=Ge.aTypedArray;(0,Ge.exportTypedArrayMethod)("map",function(e){return oB(cB(this),e,arguments.length>1?arguments[1]:void 0,function(t,n){return new(sB(t))(n)})});var uB=ov.left,lB=Ge.aTypedArray;(0,Ge.exportTypedArrayMethod)("reduce",function(e){var t=arguments.length;return uB(lB(this),e,t,t>1?arguments[1]:void 0)});var dB=ov.right,hB=Ge.aTypedArray;(0,Ge.exportTypedArrayMethod)("reduceRight",function(e){var t=arguments.length;return dB(hB(this),e,t,t>1?arguments[1]:void 0)});var fB=Ge.aTypedArray,pB=Ge.exportTypedArrayMethod,mB=Math.floor;pB("reverse",function(){for(var e,t=this,n=fB(t).length,i=mB(n/2),r=0;r<i;)e=t[r],t[r++]=t[--n],t[n]=e;return t});var $1=re,Z1=Xe,Av=Ge,vB=tn,gB=w1,_B=Vt,ex=ue,yB=$1.RangeError,Pv=$1.Int8Array,tx=Pv&&Pv.prototype,nx=tx&&tx.set,bB=Av.aTypedArray,SB=Av.exportTypedArrayMethod,Dv=!ex(function(){var e=new Uint8ClampedArray(2);return Z1(nx,e,{length:1,0:3},1),e[1]!==3}),kB=Dv&&Av.NATIVE_ARRAY_BUFFER_VIEWS&&ex(function(){var e=new Pv(2);return e.set(1),e.set("2",1),e[0]!==0||e[1]!==2});SB("set",function(e){bB(this);var t=gB(arguments.length>1?arguments[1]:void 0,1),n=_B(e);if(Dv)return Z1(nx,this,n,t);var i=this.length,r=vB(n),o=0;if(r+t>i)throw yB("Wrong length");for(;o<r;)this[t+o]=n[o++]},!Dv||kB);var TB=Hl,xB=Ba,IB=Ge.aTypedArray;(0,Ge.exportTypedArrayMethod)("slice",function(e,t){for(var n=xB(IB(this),e,t),i=TB(this),r=0,o=n.length,c=new i(o);o>r;)c[r]=n[r++];return c},ue(function(){new Int8Array(1).slice()}));var wB=nn.some,CB=Ge.aTypedArray;(0,Ge.exportTypedArrayMethod)("some",function(e){return wB(CB(this),e,arguments.length>1?arguments[1]:void 0)});var rx=qn.match(/firefox\/(\d+)/i),EB=!!rx&&+rx[1],RB=/MSIE|Trident/.test(qn),ix=qn.match(/AppleWebKit\/(\d+)\./),AB=!!ix&&+ix[1],PB=pe,Lv=ue,DB=Ut,LB=xy,ax=EB,OB=RB,ox=dr,sx=AB,MB=Ge.aTypedArray,NB=Ge.exportTypedArrayMethod,bc=re.Uint16Array,Do=bc&&PB(bc.prototype.sort),UB=!(!Do||Lv(function(){Do(new bc(2),null)})&&Lv(function(){Do(new bc(2),{})})),cx=!!Do&&!Lv(function(){if(ox)return ox<74;if(ax)return ax<67;if(OB)return!0;if(sx)return sx<602;var e,t,n=new bc(516),i=Array(516);for(e=0;e<516;e++)t=e%4,n[e]=515-e,i[e]=e-2*t+3;for(Do(n,function(r,o){return(r/4|0)-(o/4|0)}),e=0;e<516;e++)if(n[e]!==i[e])return!0});NB("sort",function(e){return e!==void 0&&DB(e),cx?Do(this,e):LB(MB(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))},!cx||UB);var VB=vr,ux=ii,jB=Hl,BB=Ge.aTypedArray;(0,Ge.exportTypedArrayMethod)("subarray",function(e,t){var n=BB(this),i=n.length,r=ux(e,i);return new(jB(n))(n.buffer,n.byteOffset+r*n.BYTES_PER_ELEMENT,VB((t===void 0?i:ux(t,i))-r))});var FB=Gi,lx=Ge,Ov=ue,dx=Ba,Wl=re.Int8Array,hx=lx.aTypedArray,HB=lx.exportTypedArrayMethod,fx=[].toLocaleString,GB=!!Wl&&Ov(function(){fx.call(new Wl(1))});HB("toLocaleString",function(){return FB(fx,GB?dx(hx(this)):hx(this),dx(arguments))},Ov(function(){return[1,2].toLocaleString()!=new Wl([1,2]).toLocaleString()})||!Ov(function(){Wl.prototype.toLocaleString.call([1,2])}));var zB=Ge.exportTypedArrayMethod,WB=ue,qB=pe,px=re.Uint8Array,JB=px&&px.prototype||{},ql=[].toString,KB=qB([].join);WB(function(){ql.call({})})&&(ql=function(){return KB(this)});var XB=JB.toString!=ql;zB("toString",ql,XB);var QB=function(){function e(t,n,i){Q(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 Ie(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 p,k;return n.decodeVideoFrame(l,u,t===((p=n.connection_)===null||p===void 0||(k=p.getPeerConnection())===null||k===void 0?void 0:k.getReceivers()[$b]))}}),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===aN||r===Yb){var o=r===Yb?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!==oN&&r!==$b||((o=i.track)===null||o===void 0?void 0:o.kind)!==Te?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(E,I){return E+I.dataView.byteLength},0),a=new ArrayBuffer(c+t.data.byteLength),s=new DataView(a),l=new DataView(t.data),u=0,p=0;p<o.length;p++)for(var k=0;k<o[p].dataView.byteLength;k++)s.setInt8(u++,o[p].dataView.getInt8(k));for(var x=0;x<t.data.byteLength;x++)s.setInt8(u++,l.getInt8(x));t.data=a,this.log_.debug("".concat(o.length," sei sent"))}}catch(E){this.log_.warn(E)}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 p=c.getUint8(u);if(p===0)a++;else if(p===1){if(a===2||a===3){var k=u-a;s===-1?s=k:l===-1&&(l=k,o.push(new mx(new DataView(c.buffer.slice(s,l)))),s=k,l=-1);var x=c.getUint8(u+1)===6;if(!x){t.data=new DataView(c.buffer.slice(k)).buffer;break}}a=0}else a=0}this.log_.debug("".concat(o.length," sei received")),pn(this.onSEIMessage)&&o.reverse().forEach(function(E){i.onSEIMessage({seiPayloadType:E.seiPayloadType,data:E.seiPayload.buffer,isFromAuxiliary:r})})}}catch(E){this.log_.warn(E)}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 mx(new DataView(new Uint8Array(o).buffer),!0)}}]),e}(),mx=function(){function e(t){var n=arguments.length>1&&arguments[1]!==void 0&&arguments[1];Q(this,e),this.dataView=t,this.isSEI&&(n?this.addPreventionByte():this.removePreventionByte())}return Ie(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}(),Mv=function(){function e(n){Q(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_=ye.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 bi,this.currentState_=an,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_&&_m&&(this.sei_=new QB(this,this.log_,this.isUplink_))}var t;return Ie(e,[{key:"initialize",value:function(){var n={encodedInsertableStreams:this.enableSEI_&&_m,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(an))}},{key:"getDTLSTransportState",value:function(){if(!this.peerConnection_)return zu;var n=null;if(this.isUplink_){if(!fl()||this.peerConnection_.getSenders().length===0)return zu;n=this.peerConnection_.getSenders()[0].transport}else{if(!Mk()||this.peerConnection_.getReceivers().length===0)return zu;n=this.peerConnection_.getReceivers()[0].transport}return n?n.state:zu}},{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===Wu&&this.emitConnectionStateChangedEvent(_b),n.target.connectionState===yb||n.target.connectionState===Uf){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 ne({message:o,code:ee.ICE_TRANSPORT_ERROR});xe.logFailedEvent({userId:this.client_.getUserId(),eventType:Db,error:c}),this.emitConnectionStateChangedEvent(an),this.isErrorObserved_||this.emitter_.emit(et.ERROR,c)}n.target.connectionState!==bb&&n.target.connectionState!==JM||(this.logSelectedCandidate(),xe.logSuccessEvent({userId:this.client_.getUserId(),eventType:Db}),this.emitConnectionStateChangedEvent(fn))}},{key:"emitConnectionStateChangedEvent",value:function(n){n!==this.currentState_&&(this.currentState_===Nf&&n===_b||(Y.emit(dl,{client:this.client_,connection:this,prevState:this.currentState_,state:n}),this.emitter_.emit(et.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:rn(),userId:r,tinyId:this.client_.getTinyId()};this.isUplink_||(o.remoteUserId=this.userId_,o.remoteTinyId=this.tinyId_),mn(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=H(f().mark(function n(){var i,r,o,c,a,s,l;return f().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=oe(i),u.prev=6,r.s();case 8:if((o=r.n()).done){u.next=18;break}if((c=ke(o.value,2))[0],!ym(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_===fn)return i();var o=-1,c=function(l){l.state===fn&&(clearTimeout(o),s(),i())},a=function(l){l.client===n.client_&&(clearTimeout(o),s(),r(new ne({code:ee.API_CALL_ABORTED,message:ie({key:$3,data:"leave room"})})))},s=function(){Y.off(fo,a,n),n.emitter_.off(et.CONNECTION_STATE_CHANGED,c,n)};o=setTimeout(function(){s();var l=new ne({code:ee.API_CALL_TIMEOUT,message:"connection timeout"});r(l)},1e4),Y.on(fo,a,n),n.emitter_.on(et.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(Nf),this.reconnect(),this.addEventInternal(this.isUplink_?oV:uV,"".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(ic,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;return!((n=this.peerConnection_)===null||n===void 0||(i=n.remoteDescription)===null||i===void 0||!i.sdp.includes("H264"))}}]),e}(),YB=function(){function e(){Q(this,e),this.set_=new Set,Y.on(cl,this.add,this),Y.on(ho,this.add,this),Y.on(ia,this.delete,this),Y.on(fo,this.delete,this)}return Ie(e,[{key:"add",value:function(t){var n=t.client,i=t.roomId;if(n.getMode()!=="rtc"){var 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;if(n.getMode()!=="rtc"){var 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 o.getMode()!=="rtc"&&this.set_.has(this.getKey(n,i,r,o.getUseStringRoomId()))}}]),e}(),$B=new YB;function vx(e,t,n,i){if(this.useStringRoomId_){if(!(Bt(e)&&/^[A-Za-z\d\s!#$%&()+\-:;<=.>?@[\]^_{}|~,]{1,64}$/.test(e)))throw new ne({code:ee.INVALID_PARAMETER,message:ie({key:LN,data:t,link:{className:i,fnName:n}})})}else if(!($n(e)&&/^[1-9]\d*$/.test(String(e))&&e<4294967295))throw new ne({code:ee.INVALID_PARAMETER,message:ie({key:ON,data:t,link:{className:i,fnName:n}})})}function gx(e,t,n,i){if(!/^[A-Za-z\d_-]*$/.test(e))throw new ne({code:ee.INVALID_PARAMETER,message:ie({key:QN,data:t,link:{className:i,fnName:n}})})}var ZB={createClient:{name:"clientConfig",required:!0,type:kr,properties:{sdkAppId:{required:!0,type:wt,allowEmpty:!1},userId:{required:!0,type:bt,allowEmpty:!1},userSig:{required:!0,type:bt,allowEmpty:!1},mode:{required:!0,type:bt,values:["rtc",Gu]},useStringRoomId:{type:on},autoSubscribe:{type:on},enableAutoPlayDialog:{type:on},streamId:{type:bt},userDefineRecordId:{type:bt},pureAudioPushMode:{type:wt,values:[1,2]},enableSEI:{type:on}}},createStream:{name:"streamConfig",required:!0,type:kr,properties:{userId:{type:bt},audio:{type:on},video:{type:on},screen:{type:on},screenAudio:{type:on},microphoneId:{type:bt},cameraId:{type:bt},facingMode:{type:[bt,kr]},audioSource:{instanceOf:window.MediaStreamTrack},videoSource:{instanceOf:window.MediaStreamTrack}},validate:function(e){if(!ge(e.screen)&&e.screen&&ge(e.audio)&&(e.audio=!1),!(ge(e.audio)&&ge(e.video)||ge(e.audioSource)&&ge(e.videoSource)))throw new ne({code:ee.INVALID_PARAMETER,message:ie({key:D3})});if(!ge(e.screen)&&e.screen===!0&&e.video===!0)throw new ne({code:ee.INVALID_PARAMETER,message:ie({key:L3})});if(e.audio&&e.screenAudio)throw new ne({code:ee.INVALID_PARAMETER,message:ie({key:O3})});if(e.screen!==!0&&e.screenAudio===!0)throw new ne({code:ee.INVALID_PARAMETER,message:ie({key:M3})});if(!ge(e.screen)&&e.screen===!0&&!this.isScreenShareSupported())throw new ne({code:ee.INVALID_OPERATION,message:ie({key:V3})})}}},eF={join:{name:"options",required:!0,type:kr,properties:{roomId:{required:!0,type:[wt,bt],allowEmpty:!1,validate:vx},role:{type:[bt],values:[br,Qi]},privateMapKey:{type:[bt]}},validate:function(e){if(this.isJoined_)throw new ne({code:ee.INVALID_OPERATION,message:ie({key:DN})});if(this.checkDestroy(),$B.isJoined({userId:this.userId_,roomId:e.roomId,sdkAppId:this.sdkAppId_,client:this}))throw new ne({code:ee.INVALID_OPERATION,message:ie({key:y3,data:this.userId_})})}},publish:[{name:"stream",required:!0,instanceOf:pi,validate:function(e){if(!this.isJoined_)throw new ne({code:ee.INVALID_OPERATION,message:ie({key:VN})});if(this.mode_===Gu&&this.role_===Qi)throw new ne({code:ee.INVALID_OPERATION,message:ie({key:BN})});if(!e.getIsReadyToPublish())throw new ne({code:ee.INVALID_OPERATION,message:ie({key:FN})});if(this.notPublishWithoutH264Supported_)throw new ne({code:ee.NOT_SUPPORTED_H264,message:ie({key:pS})})}},{name:"options",type:kr,defaultValue:{isAuxiliary:!1},properties:{isAuxiliary:{type:on,defaultValue:!1,validate:function(){var e=arguments.length>0&&arguments[0]!==void 0&&arguments[0];if(e&&!vm())throw new ne({code:ee.NOT_SUPPORTED,message:ie({key:j3})});if(this.uplinkConnection_&&(e&&this.uplinkConnection_.isAuxStreamPublished||!e&&this.uplinkConnection_.isMainStreamPublished))throw new ne({code:ee.INVALID_OPERATION,message:ie({key:HN,data:e?pt:"local"})});var t=this.localScreenStream_||Se(this.connections_.values()).findIndex(function(n){return n.getTrackState().auxiliary})>=0;if(!this.enableMultiAuxStream_&&e&&t)throw new ne({code:ee.INVALID_OPERATION,message:ie({key:Z3})})}}}}],unpublish:{name:"stream",required:!0,instanceOf:pi,validate:function(e){if(e!==this.localStream_&&e!==this.localAuxStream_){if(this.localStream_||this.localAuxStream_)throw new ne({code:ee.INVALID_PARAMETER,message:ie({key:jN})});this.log_.warn("Client currently has no published stream, please call publish() first.")}}},subscribe:[{name:"stream",required:!0,instanceOf:qf,validate:function(e){if(!e.getConnection())throw new ne({code:ee.INVALID_OPERATION,message:ie({key:Yf})});if(this.notSubscribeWithoutH264Supported_)throw new ne({code:ee.NOT_SUPPORTED_H264,message:ie({key:mS})})}},{name:"options",type:kr,properties:{audio:{type:on},video:{type:on},smallVideo:{type:on}},validate:function(e){var t=e.audio,n=e.video,i=e.smallVideo;if(t===!1&&n===!1&&(ge(i)||i===!1))throw new ne({code:ee.INVALID_OPERATION,message:ie({key:W3})})}}],unsubscribe:{name:"stream",required:!0,instanceOf:qf,validate:function(e){if(!e.getConnection())throw new ne({code:ee.INVALID_OPERATION,message:ie({key:Yf})})}},switchRole:{name:"role",required:!0,values:[br,Qi],validate:function(){if(this.mode_!==Gu)throw new ne({code:ee.INVALID_PARAMETER,message:ie({key:zN})});if(!this.isJoined_)throw new ne({code:ee.INVALID_OPERATION,message:ie({key:WN})})}},startPublishCDNStream:{name:"options",required:!1,properties:{streamId:{type:bt,validate:gx},streamType:{type:bt,values:["main","auxiliary"]},appId:{type:wt,allowEmpty:!1},bizId:{type:wt,allowEmpty:!1},url:{type:bt,allowEmpty:!1}},validate:function(){if(this.isDestroyed_)throw new ne({code:ee.INVALID_OPERATION,message:ie({key:$f,data:{funName:"startPublishCDNStream"}})})}},startMixTranscode:{name:"config",required:!0,type:kr,properties:{mode:{type:bt,values:["preset-layout","manual"]},streamId:{type:bt,validate:gx},videoWidth:{type:wt,notLessThanZero:!0},videoHeight:{type:wt,notLessThanZero:!0},videoBitrate:{type:wt,notLessThanZero:!0,allowEmpty:!1},videoFramerate:{type:wt,validate:function(e,t,n,i){if(e<=0||e>30)throw new ne({code:ee.INVALID_PARAMETER,message:ie({key:x3,link:{className:i,fnName:n}})})}},videoGOP:{type:wt,validate:function(e,t,n,i){if(e<1||e>8)throw new ne({code:ee.INVALID_PARAMETER,message:ie({key:I3,link:{className:i,fnName:n}})})}},audioSampleRate:{type:wt,notLessThanZero:!0},audioBitrate:{type:wt,validate:function(e,t,n,i){if(e<32||e>192)throw new ne({code:ee.INVALID_PARAMETER,message:ie({key:w3,link:{className:i,fnName:n}})})}},audioChannels:{type:wt,values:[1,2]},backgroundColor:{type:wt},backgroundImage:{type:bt},mixUsers:{required:!0,type:$M,arrayItem:{require:!0,type:kr,properties:{userId:{required:!0,type:bt},roomId:{type:[bt,wt],validate:vx},pureAudio:{type:on},width:{type:wt,notLessThanZero:!0},height:{type:wt,notLessThanZero:!0},locationX:{type:wt,notLessThanZero:!0},locationY:{type:wt,notLessThanZero:!0},zOrder:{type:wt},streamType:{type:bt,values:["main","auxiliary"]},renderMode:{type:wt,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 ne({code:ee.INVALID_PARAMETER,message:ie({key:C3,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 ne({code:ee.INVALID_PARAMETER,message:ie({key:E3,link:{className:i,fnName:n}})});if(e.videoWidth<o||e.videoHeight<c)throw new ne({code:ee.INVALID_PARAMETER,message:ie({key:R3,link:{className:i,fnName:n}})})}},sendSEIMessage:[{name:"buffer",required:!0,instanceOf:ArrayBuffer,validate:function(e){if(!_m)throw new ne({code:ee.NOT_SUPPORTED,message:ie({key:gS})});if(!this.enableSEI_)throw new ne({code:ee.INVALID_OPERATION,message:ie({key:q3})});if(e.byteLength>1e3)throw new ne({code:ee.INVALID_PARAMETER,message:ie({key:K3,data:e.byteLength})});if(e.byteLength===0)throw new ne({code:ee.INVALID_PARAMETER,message:ie({key:J3})});if(!this.uplinkConnection_||!this.localStream_)throw new ne({code:ee.INVALID_PARAMETER,message:ie({key:X3})});if(!this.localStream_.hasVideo())throw new ne({code:ee.INVALID_OPERATION,message:ie({key:Q3})});var t=this.uplinkConnection_.isH264;if(!t)throw new ne({code:ee.NOT_SUPPORTED,message:ie({key:gS,data:t})})}},{name:"options",type:kr,properties:{seiPayloadType:{type:wt,values:[5,243]}}}]},tF={switchDevice:[{name:"type",required:!0,type:bt,values:[Ee,Te]},{name:"deviceId",required:!0,type:bt,validate:function(){if(this.screen_&&!this.audio_||this.audioSource_||this.videoSource_)throw new ne({code:ee.INVALID_OPERATION,message:ie({key:a3})});if(this.publishState_===Ys)throw new ne({code:ee.INVALID_OPERATION,message:ie({key:o3})});if(!gm())throw new ne({code:ee.NOT_SUPPORTED,message:ie({key:U3})})}}],setAudioCaptureVolume:{name:"volume",type:wt}},nF={play:[{name:"elementId",required:!0,type:[bt,"HTMLDivElement"],validate:function(e,t,n){if(Bt(e)){var i=document.getElementById(e);if(!i)throw new ne({code:ee.INVALID_PARAMETER,message:ie({key:A3,data:{key:t,fnName:n}})});if(!(i instanceof HTMLDivElement))throw new ne({code:ee.INVALID_PARAMETER,message:ie({key:P3,data:{key:t,fnName:n,type:yi(i)}})})}}},{name:"options",type:kr,properties:{objectFit:{type:bt,values:["contain","cover","fill"]},muted:{type:on},mirror:{type:on}}}],addTrack:{name:Lf,instanceOf:window.MediaStreamTrack,validate:function(e){if(this.isAddingTrack_)throw new ne({code:ee.INVALID_OPERATION,message:ie({key:c3})});if(this.isRemovingTrack_)throw new ne({code:ee.INVALID_OPERATION,message:ie({key:u3})});if(this.publishState_===Ys)throw new ne({code:ee.INVALID_OPERATION,message:ie({key:l3})});var t=this.getMediaStream();if(!t)throw new ne({code:ee.INVALID_OPERATION,message:ie({key:dS})});if(e.kind===Ee&&t.getAudioTracks().length>0||e.kind===Te&&t.getVideoTracks().length>0)throw new ne({code:ee.INVALID_OPERATION,message:ie({key:d3})});if(!ki()&&!fl())throw new ne({code:ee.NOT_SUPPORTED,message:ie({key:ep,data:mb})})}},removeTrack:{name:Lf,instanceOf:window.MediaStreamTrack,validate:function(e){if(this.isAddingTrack_)throw new ne({code:ee.INVALID_OPERATION,message:ie({key:f3})});if(this.isRemovingTrack_)throw new ne({code:ee.INVALID_OPERATION,message:ie({key:p3})});if(this.publishState_===Ys)throw new ne({code:ee.INVALID_OPERATION,message:ie({key:m3})});var t=this.getMediaStream();if(!t)throw new ne({code:ee.INVALID_OPERATION,message:ie({key:dS})});if(t.getTracks().indexOf(e)===-1)throw new ne({code:ee.INVALID_PARAMETER,message:ie({key:v3})});if(!ki()){if(t.getTracks().length===1)throw new ne({code:ee.INVALID_OPERATION,message:ie({key:g3})});if(e.kind===Ee)throw new ne({code:ee.INVALID_PARAMETER,message:ie({key:h3})});if(!fl())throw new ne({code:ee.NOT_SUPPORTED,message:ie({key:ep,data:vb})})}}},replaceTrack:{name:Lf,instanceOf:window.MediaStreamTrack,validate:function(e){var t=this.getMediaStream();if(!t)throw new ne({code:ee.INVALID_OPERATION,message:ie({key:s3})});if(this.publishState_===Ys)throw new ne({code:ee.INVALID_OPERATION,message:ie({key:lS})});if(e.kind===Ee&&t.getAudioTracks().length<=0||e.kind===Te&&t.getVideoTracks().length<=0)throw new ne({code:ee.INVALID_PARAMETER,message:ie({key:_3,data:e})});if(!gm())throw new ne({code:ee.NOT_SUPPORTED,message:ie({key:ep,data:MM})})}}},Qt={TRTC:ZB,CLIENT:eF,LOCAL_STREAM:tF,STREAM:nF};function Jl(){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 _x.call(this,t,s,r,this.name_),c.apply(this,s)},o}}function xn(){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=H(f().mark(function a(){var s,l,u,p=arguments;return f().wrap(function(k){for(;;)switch(k.prev=k.next){case 0:for(s=p.length,l=new Array(s),u=0;u<s;u++)l[u]=p[u];return _x.call(this,t,l,r,this.name_),k.abrupt("return",c.apply(this,l));case 3:case"end":return k.stop()}},a,this)})),o}}function _x(e,t,n,i){try{for(var r=0;r<e.length;r++)Nv.call(this,{rule:e[r],value:t[r],key:e[r].name,fnName:n,className:i})}catch(o){throw ye.error(o),o}}function Nv(e){var t=this,n=e.rule,i=e.value,r=e.key,o=e.fnName,c=e.className;if(ge(i)){if(n.required)throw new ne({code:ee.INVALID_PARAMETER,message:ie({key:vN,data:{key:r,rule:n,fnName:o,value:i},link:{className:c,fnName:o}})});if(ge(n.defaultValue))return;i=n.defaultValue}if(Array.isArray(n.type)){if(!n.type.map(function(p){return p.toLowerCase()}).includes(yi(i)))throw new ne({code:ee.INVALID_PARAMETER,message:ie({key:iS,data:{key:r,rule:n,fnName:o,value:i},link:{className:c,fnName:o}})})}else if(!ge(n.type)&&yi(i)!==n.type)throw new ne({code:ee.INVALID_PARAMETER,message:ie({key:iS,data:{key:r,rule:n,fnName:o,value:i},link:{className:c,fnName:o}})});if(n.allowEmpty===!1){var a=$n(i)&&(i===0||Number.isNaN(i)),s=Bt(i)&&i.trim()==="";if(a||s)throw new ne({code:ee.INVALID_PARAMETER,message:ie({key:gN,data:{key:r,rule:n,fnName:o,value:i},link:{className:c,fnName:o}})})}if(n.notLessThanZero&&$n(i)&&i<0)throw new ne({code:ee.INVALID_PARAMETER,message:ie({key:T3,data:{key:r,rule:n,fnName:o,value:i},link:{className:c,fnName:o}})});if(Bt(n.instanceOf)){if(!i||i.name_!==n.instanceOf)throw new ne({code:ee.INVALID_PARAMETER,message:ie({key:aS,data:{key:r,rule:n,fnName:o,value:i},link:{className:c,fnName:o}})})}else if(pn(n.instanceOf)&&!(i instanceof n.instanceOf))throw new ne({code:ee.INVALID_PARAMETER,message:ie({key:aS,data:{key:r,rule:n,fnName:o,value:i},link:{className:c,fnName:o}})});if(n.values&&!n.values.includes(i))throw new ne({code:ee.INVALID_PARAMETER,message:ie({key:_N,data:{key:r,rule:n,fnName:o,value:i},link:{className:c,fnName:o}})});var l=n.properties;_i(l)&&LS(i)&&Object.keys(l).forEach(function(p){Nv.call(t,{rule:l[p],value:i&&i[p],key:"".concat(r,".").concat(p),fnName:o,className:c})});var u=n.arrayItem;_i(u)&&uo(i)&&i.forEach(function(p,k){Nv.call(t,{rule:u,value:p,key:"".concat(r,"[").concat(k,"]"),fnName:o,className:c})}),pn(n.validate)&&n.validate.call(this,i,r,o,c,this)}Me({target:"Number",stat:!0},{isNaN:function(e){return e!=e}});var rF=Me,iF=ue,aF=rh.f;rF({target:"Object",stat:!0,forced:iF(function(){return!Object.getOwnPropertyNames(1)})},{getOwnPropertyNames:aF});var yx,Sc,oF=Kk;function Lo(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{retries:5,timeout:2e3};return function(t,n,i){var r=rc({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}}Me({target:"Array",stat:!0,forced:!mu(function(e){Array.from(e)})},{from:oF});var bx,Sx,kx,ar,fa=5e3,sF={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},Uv=Ie(function e(t){Q(this,e),this.str_identifier=String(t.userId),this.uint64_tinyid=Number(t.tinyId),this.uint32_role=t.role}),cF=(yx=Lo({timeout:500,retries:3}),Sc=function(){function e(r){var o=this;Q(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_=ye.createLogger({id:"kpm|"+this.client_.getUserId(),userId:this.client_.getUserId(),sdkAppId:this.client_.getSDKAppId()}),Object.getOwnPropertyNames(this.__proto__).forEach(function(c){c.startsWith("handle")&&pn(o[c])&&(o[c]=function(a){var s=a.fn,l=a.context;return H(f().mark(function u(){var p,k,x,E=arguments;return f().wrap(function(I){for(;;)switch(I.prev=I.next){case 0:for(I.prev=0,p=E.length,k=new Array(p),x=0;x<p;x++)k[x]=E[x];return I.next=4,s.apply(l||this,k);case 4:return I.abrupt("return",I.sent);case 7:I.prev=7,I.t0=I.catch(0),ye.error("".concat(s.name,"() error observed ")+I.t0);case 10:case"end":return I.stop()}},u,this,[[0,7]])}))}({fn:o[c],context:o}))}),this.initData(),this.installEvents(),this.intervalId_=_t.run(so,this.setStorage.bind(this),{delay:2e4})}var t,n,i;return Ie(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:Bi,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:zf[bp()],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(){Y.on(cl,this.handleJoinStart,this),Y.on(Dp,this.handleWSStart,this),Y.on(ul,this.handleWSEnd,this),Y.on(Ip,this.handleJoinSendCMD,this),Y.on(wp,this.handleJoinReceivedCMDResponce,this),Y.on(ho,this.handleJoinSuccess,this),Y.on(ia,this.handleJoinFailed,this),Y.on(Ap,this.handleReceivedPublishUserList,this),Y.on(dl,this.handleConnectionStateChanged,this),Y.on(Cp,this.handleLeaveStart,this),Y.on(fo,this.handleLeaveSuccess,this),Y.on(Ep,this.handleLeaveSendCMD,this),Y.on(Jp,this.handleSendSubscribeCMD,this),Y.on(ec,this.handleVideoPlaying,this),Y.on(Mp,this.handleAudioPlaying,this),Y.on(Kp,this.handleNetworkQuality,this),Y.on(Rp,this.handleHeartbeatStats,this),Y.on(ll,this.handleRemoteStreamAdded,this),Y.on(Np,this.handleRemoteStreamSubscribeStart,this),Y.on(Ur,this.handleRemoteStreamSubscribed,this),Y.on(aa,this.handleRemoteStreamRemoved,this),Y.on(Hp,this.handleVideoLoadedData,this),Y.on(Fp,this.handlePlayStream,this),Y.on(Pp,this.handlePublishStart,this),Y.on(Up,this.handleLocalStreamInitStart,this),Y.on(Vp,this.handleLocalStreamInitEnd,this),Y.on(jp,this.handleLocalStreamInitFailed,this)}},{key:"uninstallEvents",value:function(){Y.off(cl,this.handleJoinStart,this),Y.off(Dp,this.handleWSStart,this),Y.off(ul,this.handleWSEnd,this),Y.off(Ip,this.handleJoinSendCMD,this),Y.off(wp,this.handleJoinReceivedCMDResponce,this),Y.off(Ap,this.handleReceivedPublishUserList,this),Y.off(dl,this.handleConnectionStateChanged,this),Y.off(Cp,this.handleLeaveStart,this),Y.off(fo,this.handleLeaveSuccess,this),Y.off(ho,this.handleJoinSuccess,this),Y.off(ia,this.handleJoinFailed,this),Y.off(Ep,this.handleLeaveSendCMD,this),Y.off(Jp,this.handleSendSubscribeCMD,this),Y.off(ec,this.handleVideoPlaying,this),Y.off(Mp,this.handleAudioPlaying,this),Y.off(Kp,this.handleNetworkQuality,this),Y.off(Rp,this.handleHeartbeatStats,this),Y.off(ll,this.handleRemoteStreamAdded,this),Y.off(Np,this.handleRemoteStreamSubscribeStart,this),Y.off(Ur,this.handleRemoteStreamSubscribed,this),Y.off(aa,this.handleRemoteStreamRemoved,this),Y.off(Hp,this.handleVideoLoadedData,this),Y.off(Fp,this.handlePlayStream,this),Y.off(Pp,this.handlePublishStart,this),Y.off(Up,this.handleLocalStreamInitStart,this),Y.off(Vp,this.handleLocalStreamInitEnd,this),Y.off(jp,this.handleLocalStreamInitFailed,this)}},{key:"destroy",value:function(){this.uninstallEvents(),_t.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 ne?Number(c.getExtraCode()||c.getCode()):ee.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===fn){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(gt));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 p={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:q({},sF),stream:c};p.statsToReport.msg_user_info=new Uv({userId:a,tinyId:c.getTinyId(),role:ao}),p.statsToReport.uint32_stream_type=s===gt?2:7,this.remoteStreamStatsMap_.set(l,p)}}}},{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 Uv(r),c=Date.now(),a="".concat(r.userId,"_").concat(gt);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(Dt);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),p=u.statsToReport,k=u.playStreamTime,x=u.subscribedTime;p.uint32_video_render_first===0&&k-x<=100&&(p.uint32_video_render_first=s-l.sendSubscribeCMDTime)}}if(o.getType()===Dt&&this.pathAuxiliaryMap_.has(a)&&this.remoteStreamStatsMap_.has(a)){var E=this.remoteStreamStatsMap_.get(a),I=E.statsToReport,m=E.playStreamTime,T=E.subscribedTime;I.uint32_video_render_first===0&&m-T<=100&&(I.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,p=l.uint32_video_enc_fps,k=l.uint32_video_width,x=l.uint32_video_height;this.localStreamStats_.totalVideoBitrate+=u,this.localStreamStats_.totalVideoFPS+=p,this.localStreamStats_.totalVideoWidth+=k,this.localStreamStats_.totalVideoHeight+=x,this.localStreamStats_.videoCount++}if(a.msg_audio_status){var E=a.msg_audio_status.audioLevel;Math.floor(100*E)>0&&(this.localStreamStats_.totalAudioLevel+=E,this.localStreamStats_.audioLevelCount++)}s.forEach(function(I){var m=I.msg_user_info,T=I.msg_audio_status,v=I.msg_video_status,C=m.str_identifier;if(v.forEach(function(_){var b=_.uint32_video_stream_type===2,R=_.uint32_video_stream_type===7,P="".concat(C,"_").concat(b?gt:Dt);if(o.remoteStreamStatsMap_.has(P)){var V,S,h=o.remoteStreamStatsMap_.get(P);(b&&(V=h.stream)!==null&&V!==void 0&&V.isMainVideoSubscribed||R&&(S=h.stream)!==null&&S!==void 0&&S.isAuxVideoSubscribed)&&(h.totalVideoFPS+=_.uint32_video_receive_fps,h.totalVideoBitrate+=_.uint32_video_codec_bitrate,h.videoCount++,h.statsToReport.uint32_video_width===0&&(h.statsToReport.uint32_video_width=_.uint32_video_width),h.statsToReport.uint32_video_height===0&&(h.statsToReport.uint32_video_height=_.uint32_video_height))}}),T){var O="".concat(C,"_").concat(gt);if(o.remoteStreamStatsMap_.has(O)){var N,j=o.remoteStreamStatsMap_.get(O);(N=j.stream)!==null&&N!==void 0&&N.isMainAudioSubscribed&&(j.totalAudioBitrate+=T.uint32_audio_codec_bitrate,j.audioCount++,Math.floor(100*T.audioLevel)>0&&(j.totalAudioLevel+=T.audioLevel,j.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 ne?a.getExtraCode()||a.getCode():{NotFoundError:1,NotAllowedError:2,NotReadableError:3,OverConstrainedError:4,AbortError:5}[a.name]||ee.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=H(f().mark(function r(){var o;return f().wrap(function(c){for(;;)switch(c.prev=c.next){case 0:if(c.prev=0,!(o=_o.getItem(this.storageKey_))){c.next=6;break}return c.next=5,this.upload(o);case 5:_o.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&&_o.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),p=u.totalLoss,k=u.count;a.statsToReport.uint32_avg_down_loss=Math.floor(p/k)}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 x=r.client_.getCallDurationCalculator();x&&(a.statsToReport.uint32_audio_play_time=x.getDuration(s,Ee),a.statsToReport.uint32_video_play_time=x.getDuration(s,Te)),a.statsToReport.uint32_video_render_first=Math.min(a.statsToReport.uint32_video_render_first,fa);var E=r.client_.getBadCaseDetector();if(E){var I=E.getDataFreezeDuration(s),m=I.dataFreeze,T=I.count,v=E.getRenderFreezeDuration(s).renderFreeze;a.statsToReport.uint32_video_block_count=T,a.statsToReport.uint32_video_block_time=Math.min(m,a.statsToReport.uint32_video_play_time),a.statsToReport.uint32_video_external_block_time=Math.min(v,a.statsToReport.uint32_video_play_time),E.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>fa&&(a.statsToReport.uint64_play_first_frame_time=a.statsToReport.uint64_start_enter_time+fa):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>fa&&(a.statsToReport.uint64_render_first_frame_time=a.statsToReport.uint64_start_enter_time+fa):r.pathMainVideoMap_.delete(s)}),this.pathJoinRoom_.uint64_end_time-this.pathJoinRoom_.uint64_start_time>fa&&(this.pathJoinRoom_.uint64_end_time=this.pathJoinRoom_.uint64_start_time+fa)}},{key:"getReportData",value:function(){var r=this.client_.getSignalInfo();return{uint32_sdk_app_id:Number(this.client_.getSDKAppId()),msg_user_info:new Uv({userId:this.client_.getUserId(),tinyId:this.client_.getTinyId(),role:this.client_.getRole()===br?ao:Mf}),msg_basic_info:this.basicInfo,uint32_acc_ip:kp(r.relayIp),uint32_client_ip:kp(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:kp(r.clientIp,"small"),error_code:[],msg_local_statistics:this.localStreamStats_.statsToReport,msg_function_state:Ei.getStateArray()}}},{key:"report",value:(n=H(f().mark(function r(){var o;return f().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:_o.deleteItem(this.storageKey_),Ei.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=H(f().mark(function r(o){var c,a,s;return f().wrap(function(l){for(;;)switch(l.prev=l.next){case 0:if(!(ea||o.msg_path_enter_room.uint64_start_time===0||[Jf,Jb,Kb].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=al(c,FM),l.next=6,sl({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}(),X(Sc.prototype,"upload",[yx],Object.getOwnPropertyDescriptor(Sc.prototype,"upload"),Sc.prototype),Sc),Ei=function(){function e(){Q(this,e)}return Ie(e,null,[{key:"handleFunctionState",value:function(t){var n,i,r,o,c=t.className,a=t.fnName,s=t.params;if(!(ea||[Jf,Jb,Kb].findIndex(function(k){return k===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":Bt(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 p=0;p<u.length;p++){if(!(l=uN[u[p]]))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 St(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_),Ei.handleFunctionState({className:e,fnName:n,params:c}),e=void 0}catch(s){this.log_.info(s)}return r.apply(this,c)},i}}$e(Ei,"stateMap",new Map);var Tx=(bx=xn.apply(void 0,Se(Qt.STREAM.play)),Sx=St(),kx=St(),ar=function(){function e(c){Q(this,e),this.name_=iN,this.userId_=c.userId,this.isRemote_=c.isRemote,this.type_=c.type,this.log_=ye.createLogger({id:"s".concat(c.seq?c.seq:"","|").concat(this.userId_),userId:ge(c.client)?void 0:c.client.getUserId(),sdkAppId:ge(c.client)?void 0:c.client.getSDKAppId(),isLocal:!this.isRemote_,type:this.isRemote_?this.type_:""}),this.client_=null,ge(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_=jS(new bi,this.name_),this.connectionState_=an,this.installEvents(),ge(c.mirror)||this.log_.warn('TRTC.createStream "mirror" option was deprecated since v4.12.1\uFF0Cplease use localStream.play to set up preview mirror. refer to '.concat(oo,"/en/LocalStream.html#play. TRTC.createStream \u63A5\u53E3\u7684 mirror \u9009\u9879\u4ECE v4.12.1 \u5F00\u59CB\u88AB\u5E9F\u5F03\uFF0C\u8BF7\u4F7F\u7528 localStream.play \u8BBE\u7F6E\u672C\u5730\u6D41\u9884\u89C8\u955C\u50CF\uFF0C\u53C2\u8003\u6587\u6863\uFF1A").concat(oo,"/zh-cn/LocalStream.html#play\u3002"))}var t,n,i,r,o;return Ie(e,[{key:"installEvents",value:function(){Y.on(nc,this.restartPlayback,this)}},{key:"uninstallEvents",value:function(){Y.off(nc,this.restartPlayback,this)}},{key:"getType",value:function(){return this.type_}},{key:"getLogger",value:function(){return this.log_}},{key:"isSubscribed",get:function(){return this.type_===gt&&this.connection_.isMainStreamSubscribed||this.type_===Dt&&this.connection_.isAuxStreamSubscribed}},{key:"isMainVideoSubscribed",get:function(){var c=this.getSubscribedState();return this.type_===gt&&c&&c.video}},{key:"isMainAudioSubscribed",get:function(){var c=this.getSubscribedState();return this.type_===gt&&c&&c.audio}},{key:"isAuxVideoSubscribed",get:function(){var c=this.getSubscribedState();return this.type_===Dt&&c&&c.auxiliary}},{key:"isSmallVideoSubscribed",get:function(){var c=this.getSubscribedState();return this.type_===gt&&c&&c.smallVideo}},{key:"emitConnectionStateChanged",value:function(c){c.state!==this.connectionState_&&(c.state!==an&&this.isRemote_&&!this.isSubscribed||(this.emitter_.emit(WV,c),this.connectionState_=c.state))}},{key:"setConnection",value:function(c){this.connection_!==c&&(c instanceof Mv?(this.connection_!==null&&this.connection_.off(et.CONNECTION_STATE_CHANGED,this.emitConnectionStateChanged,this),c.on(et.CONNECTION_STATE_CHANGED,this.emitConnectionStateChanged,this)):c===null&&this.connection_.off(et.CONNECTION_STATE_CHANGED,this.emitConnectionStateChanged,this),this.connection_=c)}},{key:"getConnection",value:function(){return this.connection_}},{key:"play",value:(o=H(f().mark(function c(a,s){var l,u,p;return f().wrap(function(k){for(;;)switch(k.prev=k.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_){k.next=9;break}return s&&!ge(s.muted)&&(this.muted_=s.muted),s&&!ge(s.objectFit)&&(this.objectFit_=s.objectFit),this.isScreenShare()?this.mirror_=!1:s&&!ge(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,Bt(a)&&(l=document.getElementById(a)),l.appendChild(this.div_),this.elementId_=a),k.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;"),p=a,Bt(a)&&(p=document.getElementById(a)),p.appendChild(u),this.elementId_=a,this.div_=u,this.isRemote_||(this.muted_=!0),s&&!ge(s.muted)&&(this.muted_=s.muted),this.isScreenShare()&&(this.objectFit_="contain"),s&&!ge(s.objectFit)&&(this.objectFit_=s.objectFit),this.isScreenShare()?this.mirror_=!1:(this.isRemote_||(this.mirror_=!0),s&&!ge(s.mirror)&&(this.mirror_=s.mirror)),Y.emit(Fp,{stream:this}),k.next=26,Promise.all([this.playAudio(),this.playVideo()]);case 26:Y.emit(A4,{stream:this});case 27:case"end":return k.stop()}},c,this)})),function(c,a){return o.apply(this,arguments)})},{key:"playAudio",value:(r=H(f().mark(function c(){var a,s,l=this;return f().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=17;break}return this.log_.info("create AudioPlayer and play"),this.audioPlayer_=new q6({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(vn,function(p){var k={type:Ee,state:p.state,reason:p.reason};Y.emit(WS,q({stream:l},k)),l.emitter_.emit(jk,k)}),u.prev=7,u.next=10,this.audioPlayer_.play();case 10:u.next=17;break;case 12:throw u.prev=12,u.t0=u.catch(7),this.client_&&this.client_.getEnableAutoPlayDialog()&&new AT,this.emitter_.emit(Sm,u.t0),u.t0;case 17:case"end":return u.stop()}},c,this,[[7,12]])})),function(){return r.apply(this,arguments)})},{key:"playVideo",value:(i=H(f().mark(function c(){var a,s=this;return f().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 Y.emit(Gp,{stream:this}),this.log_.info("create VideoPlayer and play"),this.videoPlayer_=new PT({stream:this,track:a,div:this.div_,muted:this.muted_,objectFit:this.objectFit_,mirror:this.mirror_}),this.videoPlayer_.on(vn,function(u){var p={type:Te,state:u.state,reason:u.reason};Y.emit(WS,q({stream:s},p)),s.emitter_.emit(jk,p)}),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 AT,this.emitter_.emit(Sm,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=H(f().mark(function c(){return f().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,Ee),this.doEnableTrack(Ee,!1)}},{key:"muteVideo",value:function(){return this.addRemoteEvent(!0,Te),this.doEnableTrack(Te,!1)}},{key:"unmuteAudio",value:function(){return this.addRemoteEvent(!1,Ee),this.doEnableTrack(Ee,!0)}},{key:"unmuteVideo",value:function(){return this.addRemoteEvent(!1,Te),this.doEnableTrack(Te,!0)}},{key:"addRemoteEvent",value:function(c,a){if(this.isRemote_&&this.client_){var s=this.client_.getUserId(),l="".concat(c?en:_r," remote ").concat(a);mn(s,{eventId:a===Ee?c?KU:QU:c?JU:XU,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===Ee?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=H(f().mark(function c(a){var s;return f().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,Gk();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_===gt&&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_===Dt?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){this.isPlaying_&&(c?(this.log_.info("playing state updated, play video"),this.playVideo().catch(function(a){})):(this.log_.info("playing state updated, stop video"),this.stopVideo()))}},{key:"updateAudioPlayingState",value:function(c){this.isPlaying_&&(c?(this.log_.info("playing state updated, play audio"),this.playAudio().catch(function(a){})):(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()===pt}},{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}(),X(ar.prototype,"play",[bx],Object.getOwnPropertyDescriptor(ar.prototype,"play"),ar.prototype),X(ar.prototype,"setAudioOutput",[Sx],Object.getOwnPropertyDescriptor(ar.prototype,"setAudioOutput"),ar.prototype),X(ar.prototype,"getVideoFrame",[kx],Object.getOwnPropertyDescriptor(ar.prototype,"getVideoFrame"),ar.prototype),ar),Vv=function(e){Ct(n,e);var t=Er(n);function n(i){var r;Q(this,n);var o={isRemote:!0,type:i.type},c=q(q({},i),o);return(r=t.call(this,c)).name_=qf,r.isStreamAddedEventEmitted_=!1,r.isAbleToCallSubscription_=!0,r}return Ie(n,[{key:"installEvents",value:function(){le(Qe(n.prototype),"installEvents",this).call(this),Y.on(Ur,this.handleStreamSubscribed,this),Y.on(Vr,this.handleStreamUnsubscribed,this)}},{key:"uninstallEvents",value:function(){le(Qe(n.prototype),"uninstallEvents",this).call(this),Y.off(Ur,this.handleStreamSubscribed,this),Y.off(Vr,this.handleStreamUnsubscribed,this)}},{key:"handleStreamSubscribed",value:function(i){i.client===this.client_&&i.stream===this&&this.connection_.getCurrentState()===fn&&this.emitConnectionStateChanged({prevState:an,state:fn})}},{key:"handleStreamUnsubscribed",value:function(i){i.client===this.client_&&i.stream===this&&this.emitConnectionStateChanged({prevState:fn,state:an})}},{key:"getType",value:function(){return le(Qe(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?le(Qe(n.prototype),"getAudioTrack",this).call(this):null}},{key:"getVideoTrack",value:function(){if(!this.connection_)return null;var i=this.connection_.getTrackState();return(this.type_!==gt||i.video)&&(this.type_!==Dt||i.auxiliary)?le(Qe(n.prototype),"getVideoTrack",this).call(this):null}},{key:"close",value:function(){le(Qe(n.prototype),"close",this).call(this)}}]),n}(Tx),uF=function(){function e(r){Q(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 Ie(e,[{key:"isEnabled",get:function(){return this.client_.getEnv()!=="webrtc"}},{key:"recover",value:(i=H(f().mark(function r(o){var c,a,s;return f().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,ye.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:xe.logSuccessEvent({userId:this.client_.getUserId(),eventType:Mb}),ye.warn("recover() recover successfully [".concat(s,"][").concat(c,"][").concat(a,"]")),l.next=23;break;case 19:l.prev=19,l.t0=l.catch(6),ye.error("recover() recover failed [".concat(s,"][").concat(c,"][").concat(a,"]"),l.t0),xe.logFailedEvent({userId:this.client_.getUserId(),eventType:Mb,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=H(f().mark(function r(o,c){var a,s,l,u,p;return f().wrap(function(k){for(;;)switch(k.prev=k.next){case 0:if(a=this.getOptions(o,c.getType()),s=this.getSubscribedStream(o,c.getType()),a&&s){k.next=4;break}return k.abrupt("return");case 4:l=this.getStreamMuteState(s),u=l.isAudioMuted,p=l.isVideoMuted,this.mergeStream(s,c),this.recoverPlayingState(s),u&&s.doEnableTrack(Ee,!1),p&&s.doEnableTrack(Te,!1);case 9:case"end":return k.stop()}},r,this)})),function(r,o){return n.apply(this,arguments)})},{key:"recoverUnsubscription",value:(t=H(f().mark(function r(o,c){var a;return f().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=ke(o[r],2),a=c[0],s=0,l=Se(c[1].entries());s<l.length;s++){var u=ke(l[s],1)[0];this.setAutoRecoveryFlag(a,u)}for(var p=0,k=Se(this.unsubscribedStreams_.entries());p<k.length;p++)for(var x=ke(k[p],2),E=x[0],I=0,m=Se(x[1].entries());I<m.length;I++){var T=ke(m[I],1)[0];this.setAutoRecoveryFlag(E,T)}}},{key:"setAutoRecoveryFlag",value:function(r,o){if(ye.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}(),lF=function(){function e(t){Q(this,e),this.player_=t,this.canvas_=document.createElement(lb),this.canvasCtx_=this.canvas_.getContext("2d")}return Ie(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}(),dF=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"}),hF=function(){function e(t){Q(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 Ie(e,[{key:"initWorker",value:function(){try{this.worker=new Worker(URL.createObjectURL(dF)),ye.info("init worker processor success")}catch(t){ye.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}(),Kl=function(){function e(n){Q(this,e),this.localStream_=n,this.player_=null,this.processor_=null,this.initOffscreenSuccess_=!1}var t;return Ie(e,[{key:"initialize",value:(t=H(f().mark(function n(){var i;return f().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,ye.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_=_t.run(Xu,this.render.bind(this),{fps:c})),i}},{key:"render",value:function(){this.processor_.canDrawVideoToCanvas&&this.processor_.drawVideoToCanvas()}},{key:"destroy",value:function(){_t.clearTask(this.interval_),this.processor_&&this.processor_.destroy()}},{key:"initOffscreen",value:function(){this.processor_=new hF({videoTrack:this.localStream_.getVideoTrack()})}},{key:"initCanvas",value:function(){this.player_=new PT({stream:this.localStream_,track:this.localStream_.getVideoTrack(),muted:!0,objectFit:"cover",mirror:!1}),this.player_.play().then(function(){ye.info("VideoGenerator: play local video success")}).catch(function(){ye.error("VideoGenerator: Failed to play local video")}),this.processor_=new lF(this.player_)}},{key:"getSmallVideoProfile",value:function(n,i){var r,o=this.localStream_.getVideoTrack(),c=this.localStream_.getVideoProfile();if(yo){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 ye.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}(),Xl=new Map,fF=function(){var e=H(f().mark(function t(n){var i,r,o,c,a,s,l;return f().wrap(function(u){for(;;)switch(u.prev=u.next){case 0:if(!pl()){u.next=2;break}return u.abrupt("return");case 2:return u.next=4,pF(n);case 4:if(i=u.sent,ye.info("getUserMedia with constraints: "+JSON.stringify(i)),!i.audio){u.next=11;break}return u.next=9,xt.getMicrophones();case 9:r=u.sent,ye.info("microphones: ".concat(lo(r,["deviceId","label"])));case 11:if(!i.video){u.next=16;break}return u.next=14,xt.getCameras();case 14:o=u.sent,ye.info("cameras: ".concat(lo(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 ne({code:ee.DEVICE_NOT_FOUND,message:ie({key:F3})});case 27:if(!r||r.length!==0){u.next=29;break}throw new ne({code:ee.DEVICE_NOT_FOUND,message:ie({key:B3})});case 29:throw i.audio&&((c=r)===null||c===void 0?void 0:c.length)>0&&(s=r.find(function(p){return p.deviceId===n.microphoneId}))&&s.getCapabilities&&ye.warn(lo(s.getCapabilities(),Qf)),i.video&&((a=o)===null||a===void 0?void 0:a.length)>0&&(l=o.find(function(p){return p.deviceId===n.cameraId}))&&l.getCapabilities&&ye.warn(lo(l.getCapabilities(),Qf)),new ne({code:ee.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)}}(),jv=rc({retryFunction:fF,settings:{retries:3,timeout:500},onError:function(e,t,n,i){ye.warn("getUserMedia error: ".concat(e)),e.name==="NotReadableError"?(i[0].video&&(i[0].maxResoution=!1,i[0].frameRate=i[0].frameRate>10?10:5),t()):e.message.includes("deviceId")&&i[0].retryWhenExactFailed?(i[0].useExact=!1,t()):n(e)},onRetrying:function(e){ye.warn("getUserMedia retrying [".concat(e,"/3]"))}});function pF(e){return{audio:mF(e),video:vF(e)}}function mF(e){if(!e.audio)return!1;var t={};return Si(e.microphoneId)||(t.deviceId=e.useExact?{exact:e.microphoneId}:e.microphoneId),$n(e.channelCount)&&e.channelCount>1&&(t.channelCount=e.channelCount),Zn(e.echoCancellation)&&!e.echoCancellation&&(t.echoCancellation=!1),Zn(e.noiseSuppression)&&!e.noiseSuppression&&(t.noiseSuppression=!1),Zn(e.autoGainControl)&&!e.autoGainControl&&(t.autoGainControl=!1),!!Si(t)||t}function vF(e){if(!e.video)return!1;var t=e.maxResoution,n=t===void 0||t,i={};return e.cameraId?i.deviceId=e.useExact?{exact:e.cameraId}:e.cameraId:e.facingMode&&(i.facingMode=e.facingMode),e.width&&(i.width={ideal:e.width},n&&(i.width.max=e.width)),e.height&&(i.height={ideal:e.height},n&&(i.height.max=e.height)),Tr&&Zs&&e.width&&e.height&&e.width*e.height<101376&&(i.width=e.width,i.height=e.height),e.frameRate&&(i.frameRate=e.frameRate),!!Si(i)||i}var gF=function(){var e=H(f().mark(function t(n){var i,r,o,c,a,s,l,u,p;return f().wrap(function(k){for(;;)switch(k.prev=k.next){case 0:if(!pl()){k.next=2;break}return k.abrupt("return");case 2:if(i=null,!(nl&&gp<74||Zi)){k.next=27;break}return r=Bv(n),ye.info("getDisplayMedia with constraints: "+JSON.stringify(r)),k.next=8,navigator.mediaDevices.getDisplayMedia(r);case 8:if(o=k.sent,!n.screenAudio){k.next=14;break}return ye.warn("Your browser not support capture system audio"),k.abrupt("return",o);case 14:if(!n.audio){k.next=24;break}return c=xx(n),ye.info("getUserMedia with constraints: "+JSON.stringify(c)),k.next=19,navigator.mediaDevices.getUserMedia(c);case 19:return i=k.sent,o.addTrack(i.getAudioTracks()[0]),k.abrupt("return",o);case 24:return k.abrupt("return",o);case 25:k.next=53;break;case 27:if(!n.screenAudio){k.next=37;break}return n.audioConstraints={echoCancellation:n.echoCancellation,autoGainControl:n.autoGainControl,noiseSuppression:n.noiseSuppression,sampleRate:44100},a=Bv(n),ye.info("getDisplayMedia with constraints: "+JSON.stringify(a)),k.next=33,navigator.mediaDevices.getDisplayMedia(a);case 33:return s=k.sent,k.abrupt("return",s);case 37:return l=Bv(n),ye.info("getDisplayMedia with constraints: "+JSON.stringify(l)),k.next=41,navigator.mediaDevices.getDisplayMedia(l);case 41:if(u=k.sent,!n.audio){k.next=52;break}return p=xx(n),ye.info("getUserMedia with constraints: "+JSON.stringify(p)),k.next=47,navigator.mediaDevices.getUserMedia(p);case 47:return i=k.sent,u.addTrack(i.getAudioTracks()[0]),k.abrupt("return",u);case 52:return k.abrupt("return",u);case 53:case"end":return k.stop()}},t)}));return function(t){return e.apply(this,arguments)}}();function xx(e){var t={echoCancellation:e.echoCancellation,autoGainControl:e.autoGainControl,noiseSuppression:e.noiseSuppression,sampleRate:e.sampleRate,channelCount:e.channelCount};return ge(e.microphoneId)||(t.deviceId=e.microphoneId),{audio:t,video:!1}}function Bv(e){var t={systemAudio:"include",selfBrowserSurface:"include",surfaceSwitching:"include"},n={width:Zi?{max:e.width}:{ideal:e.width,max:e.width},height:Zi?{max:e.height}:{ideal:e.height,max:e.height},frameRate:e.frameRate,displaySurface:"monitor"};return t.video=n,ge(e.audioConstraints)||(t.audio=e.audioConstraints),t}var Ix,wx,Cx,Ex,Rx,Ax,Px,Dx,Lx,Ox,Mx,nt,Nx,kc,Fv=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}]]),Hv=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}]]),Ux=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}]]),pa=new Map,_F=(Ix=St(pi),wx=St(pi),Cx=St(pi),Ex=St(pi),Rx=xn.apply(void 0,Se(Qt.LOCAL_STREAM.switchDevice)),Ax=xn(Qt.STREAM.addTrack),Px=xn(Qt.STREAM.removeTrack),Dx=xn(Qt.STREAM.replaceTrack),Lx=Lo({retries:10,timeout:3e3,onRetryFailed:function(e){xe.logFailedEvent({userId:this.client_?this.client_.getUserId():this.userId_,eventType:Ob,error:e}),this.emitter_.emit(Sm,new ne({code:ee.DEVICE_AUTO_RECOVER_FAILED,message:e.message}))}}),Ox=Jl(Qt.LOCAL_STREAM.setAudioCaptureVolume),Mx=St(pi),nt=function(e){Ct(I,e);var t,n,i,r,o,c,a,s,l,u,p,k,x,E=Er(I);function I(m){var T;Q(this,I);var v=q(q({},m),{isRemote:!1,type:"local"});return(T=E.call(this,v)).name_=pi,T.client_=null,T.video_=m.video,T.audio_=m.audio,T.cameraId_=m.cameraId,T.cameraGroupId_="",T.facingMode_=m.facingMode,T.microphoneId_=m.microphoneId,T.microphoneGroupId_="",T.microphoneLabel_="",T.videoSource_=m.videoSource,T.audioSource_=m.audioSource,T.screen_=m.screen,T.screenAudio_=m.screenAudio,T.audioProfile_={echoCancellation:!0,autoGainControl:!0,noiseSuppression:!0,sampleRate:48e3,channelCount:1,bitrate:40},T.screenAudio_&&(T.audioProfile_.echoCancellation=!0,T.audioProfile_.autoGainControl=!1,T.audioProfile_.noiseSuppression=!1),Zn(m.echoCancellation)&&(T.audioProfile_.echoCancellation=m.echoCancellation),Zn(m.autoGainControl)&&(T.audioProfile_.autoGainControl=m.autoGainControl),Zn(m.noiseSuppression)&&(T.audioProfile_.noiseSuppression=m.noiseSuppression),T.videoProfile_=Fv.get("480p_2"),T.screenProfile_=Hv.get("1080p"),T.videoSetting_=null,T.muteState_={video:!1,audio:!1,auxVideo:!1},T.beautyStatus_=!1,T.prevAudioRecoverTime_=0,T.prevVideoRecoverTime_=0,T.isAudioRecovering_=!1,T.isVideoRecovering_=!1,T.initState(),T.canvas_=null,T.canvasInterval_=null,T.canvasTrack_=null,T.gain_={audioTrack:null,source:null,gainNode:null},T.captureVolume_=100,T.enableAutoRecoverCapture_=!!ge(m.enableAutoRecoverCapture)||m.enableAutoRecoverCapture,T.enableAutoRecoverOther_=!Zn(m.enableAutoRecoverOther)||m.enableAutoRecoverOther,T.log_.info("stream created: ".concat(T.id_," autoRecover: ").concat(T.enableAutoRecoverCapture_)),T.isAIDenoiser=!1,T}return Ie(I,[{key:"initState",value:function(){this.isAddingTrack_=!1,this.isRemovingTrack_=!1,this.setIsReadyToPublish(!1),this.setPublishState(Hb)}},{key:"installEvents",value:function(){le(Qe(I.prototype),"installEvents",this).call(this),Y.on(zp,this.onVideoTrackStopped,this),Y.on(tc,this.onVideoTrackStopped,this),Y.on(qp,this.onAudioTrackStopped,this),Y.on(Wp,this.onAudioTrackStopped,this)}},{key:"uninstallEvents",value:function(){le(Qe(I.prototype),"uninstallEvents",this).call(this),Y.off(zp,this.onVideoTrackStopped,this),Y.off(tc,this.onVideoTrackStopped,this),Y.off(qp,this.onAudioTrackStopped,this),Y.off(Wp,this.onAudioTrackStopped,this)}},{key:"initialize",value:function(){var m=this;return new Promise(function(T,v){if(ml())v(new ne({code:ee.INVALID_OPERATION,message:ie({key:hS})}));else{if(ge(m.audio_)){var C=new MediaStream;return ge(m.audioSource_)||(C.addTrack(m.audioSource_),m.updateAudioPlayingState(!0)),ge(m.videoSource_)||(C.addTrack(m.videoSource_),m.updateVideoPlayingState(!0)),m.setMediaStream(C),xe.logSuccessEvent({userId:m.client_?m.client_.getUserId():m.userId_,eventType:Xs,kind:"custom"}),m.setIsReadyToPublish(!0),T()}m.screen_?(m.log_.info("initialize stream audio: "+m.audio_+" screenAudio: "+m.screenAudio_+" screen: "+m.screen_),gF({audio:m.audio_,screenAudio:m.screenAudio_,microphoneId:m.microphoneId_,width:m.screenProfile_.width,height:m.screenProfile_.height,frameRate:m.screenProfile_.frameRate,sampleRate:m.audioProfile_.sampleRate,channelCount:m.audioProfile_.channelCount,autoGainControl:m.audioProfile_.autoGainControl,noiseSuppression:m.audioProfile_.noiseSuppression,echoCancellation:m.audioProfile_.echoCancellation}).then(function(O){m.setMediaStream(O),m.updateAudioPlayingState(m.audio_||m.screenAudio_),m.updateVideoPlayingState(!0);var N=m.getVideoTrack();return N.applyConstraints&&N.applyConstraints({frameRate:{min:m.screenProfile_.frameRate,ideal:m.screenProfile_.frameRate},width:m.screenProfile_.width,height:m.screenProfile_.height}).catch(function(j){m.warn("screen applyConstraints failed: ".concat(j))}),m.listenForScreenSharingStopped(N),m.setVideoContentHint(fb),m.updateDeviceIdInUse(),m.setIsReadyToPublish(!0),m.log_.info(JSON.stringify(N.getSettings())),xe.logSuccessEvent({userId:m.client_?m.client_.getUserId():m.userId_,eventType:Xs,kind:"getDisplayMedia"}),T()}).catch(function(O){xe.logFailedEvent({userId:m.client_?m.client_.getUserId():m.userId_,eventType:Xs,kind:"getDisplayMedia",error:O}),m.log_.error("getDisplayMedia error observed "+O),v(O instanceof ne?O:new ne({code:ee.INITIALIZE_FAILED,name:O.name,message:O.message}))})):(Y.emit(Up,{stream:m,audio:m.audio_,video:m.video_}),m.log_.info("initialize stream audio: "+m.audio_+" video: "+m.video_),jv({audio:m.audio_,video:m.video_,facingMode:m.facingMode_,cameraId:m.cameraId_,microphoneId:m.microphoneId_,width:m.videoProfile_.width,height:m.videoProfile_.height,frameRate:m.videoProfile_.frameRate,sampleRate:m.audioProfile_.sampleRate,channelCount:m.audioProfile_.channelCount,autoGainControl:m.audioProfile_.autoGainControl,noiseSuppression:m.audioProfile_.noiseSuppression,echoCancellation:m.audioProfile_.echoCancellation,useExact:!0,retryWhenExactFailed:!0}).then(function(O){return Y.emit(Vp,{stream:m,audio:m.audio_,video:m.video_}),m.setMediaStream(O),O.getTracks().forEach(function(N){if(yo){var j=N.getSettings();m.log_.debug("".concat(N.kind," settings: ").concat(JSON.stringify(j))),N.kind===Te&&(m.videoSetting_=j)}HV&&m.log_.info("".concat(N.kind," capabilities: ").concat(lo(N.getCapabilities(),Qf)))}),m.updateAudioPlayingState(m.audio_),m.updateVideoPlayingState(m.video_),m.updateDeviceIdInUse(),m.log_.info("gotStream hasAudio: "+m.hasAudio()+" hasVideo: "+m.hasVideo()),m.setIsReadyToPublish(!0),xe.logSuccessEvent({userId:m.client_?m.client_.getUserId():m.userId_,eventType:Xs,kind:"getUserMedia"}),T()}).catch(function(O){Y.emit(jp,{stream:m,audio:m.audio_,video:m.video_,error:O}),xe.logFailedEvent({userId:m.client_?m.client_.getUserId():m.userId_,eventType:Xs,kind:"getUserMedia",error:O}),m.log_.error("getUserMedia error observed "+O),v(O)}))}})}},{key:"listenForScreenSharingStopped",value:function(m){var T=this;m.addEventListener("ended",function(v){T.log_.info("screen sharing was stopped because the video track is ended"),T.emitter_.emit(zV)})}},{key:"muteAudio",value:function(){var m=le(Qe(I.prototype),"muteAudio",this).call(this);return m&&(this.log_.info("localStream mute audio"),this.sendMutedFlag(Ee,!0)),m}},{key:"muteVideo",value:function(){var m=le(Qe(I.prototype),"muteVideo",this).call(this);return m&&(this.log_.info("localStream mute video"),this.sendMutedFlag(Te,!0)),m}},{key:"unmuteAudio",value:function(){var m=le(Qe(I.prototype),"unmuteAudio",this).call(this);return m&&(this.log_.info("localStream unmute audio"),this.sendMutedFlag(Ee,!1)),m}},{key:"unmuteVideo",value:function(){var m=le(Qe(I.prototype),"unmuteVideo",this).call(this);return m&&(this.log_.info("localStream unmute video"),this.sendMutedFlag(Te,!1)),m}},{key:"sendMutedFlag",value:function(m,T){this.setMuteState(m,T);var v=this.getConnection();if(v){v.sendMutedFlag(this.muteState_,this);var C=v.getUserId(),O=v.getTinyId(),N="".concat(T?en:_r," local ").concat(m," track");mn(C,{eventId:m===Ee?T?VU:BU:T?jU:FU,eventDesc:N,timestamp:rn(),userId:C,tinyId:O})}}},{key:"setMuteState",value:function(m,T){this.muteState_[m]=T,this.log_.info("set ".concat(m," muted state: [").concat(T?"mute":"unmute","]"))}},{key:"setAudioProfile",value:(x=H(f().mark(function m(T){var v,C,O;return f().wrap(function(N){for(;;)switch(N.prev=N.next){case 0:if(G(T)==="object"?v=T:(v=Ux.get(T))===void 0&&(v=Ux.get("standard")),this.log_.info("setAudioProfile: "+JSON.stringify(v)),!(C=this.getAudioTrack())){N.next=6;break}return N.next=6,C.applyConstraints(v);case 6:if(O=this.audioProfile_.bitrate!==v.bitrate,this.audioProfile_=q(q({},this.audioProfile_),v),!O||!this.connection_){N.next=12;break}return N.next=11,this.connection_.setBandwidth({bandwidth:this.audioProfile_.bitrate,type:Ee});case 11:this.connection_.sendMediaSettings(this);case 12:case"end":return N.stop()}},m,this)})),function(m){return x.apply(this,arguments)})},{key:"setVideoProfile",value:(k=H(f().mark(function m(T){var v,C,O,N;return f().wrap(function(j){for(;;)switch(j.prev=j.next){case 0:if(!this.connection_||Nk()){j.next=2;break}throw new ne({code:ee.NOT_SUPPORTED,message:ie({key:N3})});case 2:if(_i(T)?C=q(q({},this.videoProfile_),T):Bt(T)&&(C=Fv.get(T),ge(C)&&(C=Fv.get("480p_2"))),(v=this.client_)!==null&&v!==void 0&&v.get2k4kFlag()&&(this.client_.get2k4kFlag()!==1&&!this.screen_&&C.height*C.width>=3686400?(C.width=1920,C.height=1080,this.log_.warn(eS)):Ei.handleFunctionState({fnName:"2K_4K"})),C&&C.width*C.height>921600&&x4&&(C.width=1280,C.height=720,this.log_.warn("reset to 1280 * 720 on iOS 13~14")),this.log_.info("setVideoProfile "+JSON.stringify(C)),!(O=this.getVideoTrack())){j.next=10;break}return j.next=10,O.applyConstraints(C);case 10:if(N=this.videoProfile_.bitrate!==C.bitrate,this.videoProfile_=C,!N||!this.connection_){j.next=16;break}return j.next=15,this.connection_.setBandwidth({bandwidth:C.bitrate,type:Te,videoType:ju});case 15:this.connection_.sendMediaSettings(this);case 16:case"end":return j.stop()}},m,this)})),function(m){return k.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(m){var T=m;Bt(m)&&(T=Hv.get(m)||Hv.get("1080p")),this.log_.info("setScreenProfile "+JSON.stringify(m)),this.screenProfile_=T}},{key:"getVideoProfile",value:function(){return this.screen_?this.screenProfile_:this.videoProfile_}},{key:"getAudioProfile",value:function(){return this.audioProfile_}},{key:"setVideoContentHint",value:function(m){var T=this.getVideoTrack();T&&"contentHint"in T&&(this.log_.info("set video track contentHint to: "+m),T.contentHint=m,T.contentHint!==m&&this.log_.warn("Invalid video track contentHint: "+m))}},{key:"switchDevice",value:(p=H(f().mark(function m(T,v){var C,O,N,j,_,b,R,P,V,S,h,y,A,D,U,K,J,ce;return f().wrap(function(ae){for(;;)switch(ae.prev=ae.next){case 0:if(this.mediaStream_&&this.cameraId_!==v&&this.facingMode_!==v){ae.next=2;break}return ae.abrupt("return");case 2:if(O=T===Te,!(C=T===Ee)||v!==this.microphoneId_){ae.next=11;break}if(v===Ju){ae.next=7;break}return ae.abrupt("return");case 7:return ae.next=9,$V(this.microphoneGroupId_,this.microphoneLabel_);case 9:if(!ae.sent){ae.next=11;break}return ae.abrupt("return");case 11:return this.setIsReadyToPublish(!1),this.log_.info("switchDevice "+T+" to: "+v),C&&(N=this.getAudioTrack(),j=this.getMicrophoneTrackMixed(),N&&N.stop(),j&&j.stop()),O&&((_=this.getVideoTrack())&&_.stop(),mp&&(b=this.getAudioTrack())&&(this.log_.info("stop audio track first in huawei env"),b.stop())),ae.prev=15,ae.next=18,jv({audio:C||mp,video:O,facingMode:v===db||v===hb?v:void 0,cameraId:O?v:this.cameraId_,microphoneId:C?v:this.microphoneId_,width:this.videoProfile_.width,height:this.videoProfile_.height,frameRate:this.videoProfile_.frameRate,sampleRate:this.audioProfile_.sampleRate,channelCount:this.audioProfile_.channelCount,useExact:!0,retryWhenExactFailed:!1});case 18:if(R=ae.sent,P=null,!C){ae.next=25;break}(V=R.getAudioTracks()[0])&&this.isAudioTrackMixed()?(S=this.getAudioTrack(),h=xt.AudioMixerPlugin.getAudioTrackMap(),y=xt.AudioMixerPlugin.mix({targetTrack:V,sourceList:h.get(S.id).sourceList,trackList:h.get(S.id).trackList}),P=y):P=V,ae.next=34;break;case 25:if(!(P=R.getVideoTracks()[0])||!this.isVideoTrackBeautified()){ae.next=30;break}return ae.next=29,this.generateBeautyTrack(P);case 29:P=ae.sent;case 30:if(!(A=R.getAudioTracks()[0])||!mp){ae.next=34;break}return ae.next=34,this.replaceTrack(A);case 34:return ae.next=36,this.replaceTrack(P);case 36:this.updateDeviceIdInUse(),(D=this.getConnection())&&(U=D.getUserId(),K=D.getTinyId(),J=GU,ce="switch camera",C&&(J=zU,ce="switch microphone"),mn(U,{eventId:J,eventDesc:ce,timestamp:rn(),userId:U,tinyId:K})),this.log_.info("switch ".concat(C?"microphone":"camera"," success ")),C&&(this.audio_=!0),O&&(this.video_=!0,v!==hb&&v!==db||(this.facingMode_=v)),this.setIsReadyToPublish(!0),ae.next=50;break;case 45:throw ae.prev=45,ae.t0=ae.catch(15),this.log_.error(ae.t0),C?this.recoverCapture({audio:!0,video:!1,microphoneId:this.microphoneId_}):this.recoverCapture({audio:!1,video:!0,cameraId:this.cameraId_,facingMode:this.facingMode_}),ae.t0;case 50:case"end":return ae.stop()}},m,this,[[15,45]])})),function(m,T){return p.apply(this,arguments)})},{key:"addTrack",value:(u=H(f().mark(function m(T){var v,C,O;return f().wrap(function(N){for(;;)switch(N.prev=N.next){case 0:if(N.prev=0,T.kind===Te&&yo&&(v=T.getSettings(),!this.videoSetting_||v.width===this.videoSetting_.width&&v.height===this.videoSetting_.height||this.log_.warn("video resolution of the track (".concat(v.width," x ").concat(v.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(T),this.mediaStream_.addTrack(T),!(C=this.getConnection())){N.next=11;break}return O=null,T.kind===Te&&(il||rl)&&OS(T)&&(O=this.getCanvasTrack()),N.next=11,C.addTrack(O||T,this);case 11:T.kind===Ee?(this.audio_=!0,this.updateAudioPlayingState(!0),this.captureVolume_!==100&&this.setAudioCaptureVolume(this.captureVolume_)):(this.video_=!0,this.updateVideoPlayingState(!0)),this.isAddingTrack_=!1,N.next=20;break;case 15:throw N.prev=15,N.t0=N.catch(0),this.mediaStream_.removeTrack(T),this.isAddingTrack_=!1,N.t0;case 20:case"end":return N.stop()}},m,this,[[0,15]])})),function(m){return u.apply(this,arguments)})},{key:"removeTrack",value:(l=H(f().mark(function m(T){var v;return f().wrap(function(C){for(;;)switch(C.prev=C.next){case 0:if(C.prev=0,this.isRemovingTrack_=!0,!(v=this.getConnection())){C.next=17;break}if(T.kind!==Te||!il&&!rl||!this.canvasTrack_){C.next=10;break}return C.next=7,v.removeTrack(this.canvasTrack_,this);case 7:this.clearCanvas(),C.next=17;break;case 10:if(T.kind!==Ee||!this.gain_.audioTrack){C.next=15;break}return C.next=13,v.removeTrack(this.gain_.audioTrack,this);case 13:C.next=17;break;case 15:return C.next=17,v.removeTrack(T,this);case 17:this.mediaStream_.removeTrack(T),T.kind===Ee?(this.audio_=!1,this.updateAudioPlayingState(!1),this.stopGainNode()):(this.video_=!1,this.updateVideoPlayingState(!1)),this.isRemovingTrack_=!1,C.next=26;break;case 22:throw C.prev=22,C.t0=C.catch(0),this.isRemovingTrack_=!1,C.t0;case 26:case"end":return C.stop()}},m,this,[[0,22]])})),function(m){return l.apply(this,arguments)})},{key:"replaceTrack",value:(s=H(f().mark(function m(T){var v,C,O;return f().wrap(function(N){for(;;)switch(N.prev=N.next){case 0:if(T.kind===Te&&yo&&(v=T.getSettings(),!this.videoSetting_||v.width===this.videoSetting_.width&&v.height===this.videoSetting_.height||this.log_.warn("video resolution of the track (".concat(v.width," x ").concat(v.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(T),C=this.mediaStream_,T.kind!==Ee){N.next=12;break}if(C.removeTrack(C.getAudioTracks()[0]),C.addTrack(T),le(Qe(I.prototype),"restartAudio",this).call(this),!this.gain_.gainNode){N.next=10;break}return this.reconnectGainNode(T),N.abrupt("return");case 10:N.next=15;break;case 12:C.removeTrack(C.getVideoTracks()[0]),C.addTrack(T),le(Qe(I.prototype),"restartVideo",this).call(this);case 15:if(!(O=this.getConnection())){N.next=21;break}if(T.kind!==Te||!il&&!rl||!this.canvasTrack_){N.next=19;break}return N.abrupt("return");case 19:return N.next=21,O.replaceTrack(T,this);case 21:case"end":return N.stop()}},m,this)})),function(m){return s.apply(this,arguments)})},{key:"recoverCapture",value:(a=H(f().mark(function m(T){var v,C,O,N,j,_,b,R,P,V,S,h,y,A,D,U,K;return f().wrap(function(J){for(;;)switch(J.prev=J.next){case 0:if(!(!this.mediaStream_||!this.enableAutoRecoverCapture_||T.audio&&!T.video&&this.isAudioRecovering_||T.video&&!T.audio&&this.isVideoRecovering_)){J.next=2;break}return J.abrupt("return");case 2:return T.audio&&(this.isAudioRecovering_=!0),T.video&&(this.isVideoRecovering_=!0),this.log_.warn("recoverCapture() trying "+JSON.stringify(T)),v=this.audio_&&T.audio,C=this.video_&&T.video,J.prev=7,J.next=10,xt.getCameras();case 10:return O=J.sent,J.next=13,xt.getMicrophones();case 13:if(N=J.sent,C&&O.length===0&&(C=!1,this.log_.warn("recoverCapture() video flag is true, but no camera detected, set video to false")),v&&N.length===0&&(v=!1,this.log_.warn("recoverCapture() audio flag is true, but no microphone detected, set audio to false")),v||C){J.next=21;break}return T.audio&&(this.isAudioRecovering_=!1),T.video&&(this.isVideoRecovering_=!1),this.log_.warn("recoverCapture() both audio and video are false, aborted"),J.abrupt("return");case 21:return j=T&&O.findIndex(function(ce){return ce.deviceId===T.cameraId})>=0,_=T&&N.findIndex(function(ce){return ce.deviceId===T.microphoneId})>=0,v&&((b=this.getAudioTrack())===null||b===void 0||b.stop()),C&&((R=this.getVideoTrack())===null||R===void 0||R.stop()),J.next=27,jv({audio:v,video:C,cameraId:j?T.cameraId:void 0,microphoneId:_?T.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});case 27:P=J.sent,V=P.getTracks(),S=0;case 30:if(!(S<V.length)){J.next=57;break}if((h=V[S]).kind!==Ee||!this.isAudioTrackMixed()){J.next=43;break}if(y=this.getAudioTrack(),A=xt.AudioMixerPlugin.getAudioTrackMap(),(D=A.get(y.id)).hasMicrophone){J.next=39;break}return h.stop(),J.abrupt("continue",54);case 39:return U=xt.AudioMixerPlugin.mix({targetTrack:h,sourceList:D.sourceList,trackList:D.trackList}),J.next=42,this.replaceTrack(U);case 42:return J.abrupt("continue",54);case 43:if(h.kind!==Te||!this.isVideoTrackBeautified()){J.next=50;break}return J.next=46,this.generateBeautyTrack(h);case 46:return K=J.sent,J.next=49,this.replaceTrack(K);case 49:return J.abrupt("continue",54);case 50:return J.next=52,this.replaceTrack(h);case 52:if(h.readyState!=="ended"){J.next=54;break}throw new Error("new track is failed, muted ".concat(h.muted," readyState ").concat(h.readyState));case 54:S++,J.next=30;break;case 57:this.updateDeviceIdInUse(),xe.logSuccessEvent({userId:this.client_?this.client_.getUserId():this.userId_,eventType:Ob}),T.audio&&(this.isAudioRecovering_=!1),T.video&&(this.isVideoRecovering_=!1),this.log_.warn("recoverCapture() successfully"),this.emitter_.emit(qV,{isCamera:T.video,isMicrophone:T.audio,cameraId:this.cameraId_,microphoneId:this.microphoneId_}),J.next=71;break;case 65:throw J.prev=65,J.t0=J.catch(7),T.audio&&(this.isAudioRecovering_=!1),T.video&&(this.isVideoRecovering_=!1),this.log_.warn("recoverCapture() failed, "+J.t0),J.t0;case 71:case"end":return J.stop()}},m,this,[[7,65]])})),function(m){return a.apply(this,arguments)})},{key:"updateDeviceIdInUse",value:function(){var m=this;if(!this.mediaStream_)return this.cameraId_="",this.cameraGroupId_="",this.microphoneId_="",void(this.microphoneGroupId_="");yo&&this.mediaStream_.getTracks().forEach(function(C){if(C.kind===Ee&&m.isAudioTrackMixed()){var O=m.getMicrophoneTrackMixed();if(O){var N=O.getSettings(),j=N.deviceId,_=N.groupId;j&&(m.microphoneId_=j,m.microphoneGroupId_=_,m.microphoneLabel_=O.label)}}else if(C.kind===Te&&m.isVideoTrackBeautified()){var b=m.getBeautyOriginTrack();if(b){var R=b.getSettings(),P=R.deviceId,V=R.groupId;P&&(m.cameraId_=P,m.cameraGroupId_=V)}}else{var S=C.getSettings(),h=S.deviceId,y=S.groupId;h&&(C.kind===Ee?(m.microphoneId_=h,m.microphoneGroupId_=y,m.microphoneLabel_=C.label):C.kind!==Te||m.screen_||(m.cameraId_=h,m.cameraGroupId_=y))}});var T=this.mediaStream_.getAudioTracks(),v=this.mediaStream_.getVideoTracks();T&&T.length===0&&(this.microphoneId_="",this.microphoneGroupId_=""),v&&v.length===0&&(this.cameraId_="",this.cameraGroupId_="")}},{key:"isAudioTrackMixed",value:function(){if(xt.AudioMixerPlugin){var m=xt.AudioMixerPlugin.getAudioTrackMap(),T=this.getAudioTrack();if(m&&T&&m.has(T.id))return!0}return!1}},{key:"getMicrophoneTrackMixed",value:function(){if(xt.AudioMixerPlugin){var m=xt.AudioMixerPlugin.getAudioTrackMap(),T=this.getAudioTrack();if(m&&T&&m.has(T.id)){var v=m.get(T.id);return v.hasMicrophone?v.microphoneTrack:null}}return null}},{key:"isVideoTrackBeautified",value:function(){if(xt.beautyTrackMap){var m=xt.beautyTrackMap,T=this.getVideoTrack();if(T&&m.has(T.id))return!0}return!1}},{key:"getBeautyOriginTrack",value:function(){if(xt.beautyTrackMap){var m=xt.beautyTrackMap,T=this.getVideoTrack();if(T&&m.has(T.id)){var v=m.get(T.id);if(v.originTrack)return v.originTrack}}return null}},{key:"generateBeautyTrack",value:(c=H(f().mark(function m(T){var v,C,O,N;return f().wrap(function(j){for(;;)switch(j.prev=j.next){case 0:if(v=null,C=this.getVideoTrack(),O=xt.beautyTrackMap.get(C.id),N=O.param,O.type){j.next=8;break}v=O.pluginInstance.generateBeautyTrack(T),j.next=22;break;case 8:j.t0=O.type,j.next=j.t0==="beauty"?11:j.t0==="virtual"?13:j.t0==="mixed"?17:21;break;case 11:return v=O.pluginInstance.generateBeautyTrack(T),j.abrupt("break",22);case 13:return j.next=15,O.pluginInstance.generateVirtualTrack({videoTrack:T,type:N.type,img:N.img});case 15:case 19:return v=j.sent,j.abrupt("break",22);case 17:return j.next=19,O.pluginInstance.generateMixedTrack({videoTrack:T,type:N.type,img:N.img});case 21:return j.abrupt("break",22);case 22:return O.pluginInstance.deleteSource(C.id),this.log_.info("regenerate beauty track, track id = ".concat(T.id)),j.abrupt("return",v);case 25:case"end":return j.stop()}},m,this)})),function(m){return c.apply(this,arguments)})},{key:"getScreen",value:function(){return this.screen_}},{key:"hasScreenTrack",value:function(){if(this.screen_)return!0;var m=this.getVideoTrack();return!!m&&(m.contentHint===fb||m.contentHint===AM)}},{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(m){this.isReadyToPublish_=m}},{key:"setPublishState",value:function(m){this.publishState_=m}},{key:"setBeautyStatus",value:function(m){this.beautyStatus_=!!m}},{key:"getBeautyStatus",value:function(){return this.beautyStatus_}},{key:"syncMuteState",value:function(){var m=this.getAudioTrack(),T=this.getVideoTrack();if(m){var v=!m.enabled;this.setMuteState(Ee,v)}if(T){var C=!T.enabled;this.setMuteState(Te,C)}this.connection_&&this.connection_.sendMutedFlag(this.muteState_,this)}},{key:"keepMuteState",value:function(m){m instanceof window.MediaStreamTrack&&this.muteState_[m.kind]&&(m.enabled=!1,this.log_.warn("prev ".concat(m.kind," track is muted, keep mute state")))}},{key:"onVideoTrackStopped",value:(o=H(f().mark(function m(T){var v,C,O=this;return f().wrap(function(N){for(;;)switch(N.prev=N.next){case 0:if(v=T.stream,C=T.type,v===this&&this.video_&&this.cameraId_&&YV(this.getVideoTrack())&&!this.isVideoRecovering_&&(C!==en||!Zs||!Zi)){N.next=3;break}return N.abrupt("return");case 3:if(!(Date.now()-this.prevVideoRecoverTime_<Ku)){N.next=6;break}return setTimeout(function(){return O.onVideoTrackStopped({stream:v,type:C})},Ku),N.abrupt("return");case 6:C===en?setTimeout(function(){var j=O.getVideoTrack();j!=null&&j.muted&&document.visibilityState==="visible"&&O.recoverVideoCapture(C)},5e3):this.recoverVideoCapture(C);case 7:case"end":return N.stop()}},m,this)})),function(m){return o.apply(this,arguments)})},{key:"onAudioTrackStopped",value:(r=H(f().mark(function m(T){var v,C,O=this;return f().wrap(function(N){for(;;)switch(N.prev=N.next){case 0:if(v=T.stream,C=T.type,!(v!==this||!this.audio_||!this.microphoneId_||this.isAudioRecovering_||C===en&&Zs&&Zi)){N.next=3;break}return N.abrupt("return");case 3:if(!(Date.now()-this.prevAudioRecoverTime_<Ku)){N.next=6;break}return setTimeout(function(){return O.onAudioTrackStopped({stream:v,type:C})},Ku),N.abrupt("return");case 6:C===en?setTimeout(function(){var j=O.getAudioTrack();j!=null&&j.muted&&document.visibilityState==="visible"&&O.recoverAudioCapture(C)},5e3):this.recoverAudioCapture(C);case 7:case"end":return N.stop()}},m,this)})),function(m){return r.apply(this,arguments)})},{key:"recoverAudioCapture",value:(i=H(f().mark(function m(T){return f().wrap(function(v){for(;;)switch(v.prev=v.next){case 0:return this.prevAudioRecoverTime_=Date.now(),xe.uploadEvent({log:"stat-local-audio-".concat(T),userId:this.userId_}),v.t0=this,v.next=5,this.getRecoverCaptureDeviceId(!1);case 5:v.t1=v.sent,v.t2={audio:!0,video:!1,microphoneId:v.t1},v.t0.recoverCapture.call(v.t0,v.t2);case 8:case"end":return v.stop()}},m,this)})),function(m){return i.apply(this,arguments)})},{key:"recoverVideoCapture",value:(n=H(f().mark(function m(T){return f().wrap(function(v){for(;;)switch(v.prev=v.next){case 0:return this.prevVideoRecoverTime_=Date.now(),xe.uploadEvent({log:"stat-local-video-".concat(T),userId:this.userId_}),v.t0=this,v.next=5,this.getRecoverCaptureDeviceId(!0);case 5:v.t1=v.sent,v.t2={audio:!1,video:!0,cameraId:v.t1},v.t0.recoverCapture.call(v.t0,v.t2);case 8:case"end":return v.stop()}},m,this)})),function(m){return n.apply(this,arguments)})},{key:"getRecoverCaptureDeviceId",value:(t=H(f().mark(function m(){var T,v,C,O,N=arguments;return f().wrap(function(j){for(;;)switch(j.prev=j.next){case 0:if(T=!(N.length>0&&N[0]!==void 0)||N[0],!(v=T?this.cameraId_:this.microphoneId_)||!this.enableAutoRecoverOther_){j.next=17;break}if(pa.has(v)?pa.set(v,pa.get(v)+1):pa.set(v,1),!((C=pa.get(v))>=3)){j.next=17;break}if(!T){j.next=12;break}return j.next=9,xt.getCameras();case 9:j.t0=j.sent.find(function(_){return!pa.has(_.deviceId)}),j.next=15;break;case 12:return j.next=14,xt.getMicrophones();case 14:j.t0=j.sent.find(function(_){return!pa.has(_.deviceId)});case 15:(O=j.t0)&&(this.log_.warn("".concat(T?"camera":"mic"," ").concat(v," capture fail ").concat(C," times, change new ").concat(O.deviceId)),v=O.deviceId);case 17:return j.abrupt("return",v);case 18:case"end":return j.stop()}},m,this)})),function(){return t.apply(this,arguments)})},{key:"setAudioVolume",value:function(m){le(Qe(I.prototype),"setAudioVolume",this).call(this,m)}},{key:"clearCanvas",value:function(){this.canvasInterval_&&(_t.clearTask(this.canvasInterval_),this.canvasInterval_=null,this.canvas_=null,this.canvasTrack_=null)}},{key:"getCanvasTrack",value:function(){var m=this;if(this.canvasTrack_)return this.canvasTrack_;this.log_.info("gen canvas track");var T=this.getVideoTrack().getSettings(),v=T.width,C=T.height,O=T.frameRate;this.canvas_=document.createElement("canvas");var N=this.canvas_.getContext("2d");this.canvas_.width=v,this.canvas_.height=C,this.canvasInterval_=_t.run(Xu,function(){if(m.hasVideo()){var _=m.getVideoTrack().getSettings();_.width===m.canvas_.width&&_.height===m.canvas_.height||(m.canvas_.width=_.width,m.canvas_.height=_.height)}m.videoPlayer_&&m.videoPlayer_.element_&&N.drawImage(m.videoPlayer_.element_,0,0,m.canvas_.width,m.canvas_.height)},{fps:Math.max(15,O)});var j=this.canvas_.captureStream();return this.canvasTrack_=j.getVideoTracks()[0],this.canvasTrack_}},{key:"setClient",value:function(m,T){m&&(this.log_.setUserId(m.getUserId()),this.log_.setSdkAppId(m.getSDKAppId()),T||this.syncMuteState()),this.client_=m}},{key:"setAudioCaptureVolume",value:function(){var m=this,T=arguments.length>0&&arguments[0]!==void 0?arguments[0]:100;if(!this.hasAudio()||T<0||!gm())return!1;if(this.captureVolume_===T)return!0;this.captureVolume_=T,this.log_.info("setCaptureVolume "+T),T/=100;var v=VS();if(this.gain_.gainNode)this.gain_.gainNode.gain.value=T;else{var C,O=new MediaStream;O.addTrack(this.getAudioTrack());var N=v.createMediaStreamDestination(),j=v.createMediaStreamSource(O),_=v.createGain();_.gain.value=T,j.connect(_),_.connect(N);var b=N.stream.getAudioTracks()[0],R=function(P){return m.log_.info("gained audio track ".concat(P))};b.onmute=function(){return R("muted")},b.onunmute=function(){return R("unmuted")},b.onended=function(){return R("ended")},this.gain_={source:j,audioTrack:b,gainNode:_},(C=this.connection_)===null||C===void 0||C.replaceTrack(b),le(Qe(I.prototype),"restartAudio",this).call(this)}return!0}},{key:"getGainedTrack",value:function(){return this.gain_.audioTrack}},{key:"reconnectGainNode",value:function(m){this.log_.warn("reconnect gain node");var T=new MediaStream;T.addTrack(m);var v=VS().createMediaStreamSource(T);v.connect(this.gain_.gainNode),this.gain_.source.disconnect(),this.gain_.source=v}},{key:"stopGainNode",value:function(){var m=this.gain_,T=m.audioTrack,v=m.source,C=m.gainNode;C&&(v.disconnect(),C.disconnect(),T.onmute=null,T.onunmute=null,T.onended=null,T.stop(),this.gain_={source:null,gainNode:null,audioTrack:null}),this.captureVolume_=100}},{key:"close",value:function(){this.setIsReadyToPublish(!1),this.stopGainNode(),le(Qe(I.prototype),"close",this).call(this)}},{key:"setIsAIDenoiser",value:function(m){this.isAIDenoiser=m}}]),I}(Tx),X(nt.prototype,"setAudioProfile",[Ix],Object.getOwnPropertyDescriptor(nt.prototype,"setAudioProfile"),nt.prototype),X(nt.prototype,"setVideoProfile",[wx],Object.getOwnPropertyDescriptor(nt.prototype,"setVideoProfile"),nt.prototype),X(nt.prototype,"setScreenProfile",[Cx],Object.getOwnPropertyDescriptor(nt.prototype,"setScreenProfile"),nt.prototype),X(nt.prototype,"setVideoContentHint",[Ex],Object.getOwnPropertyDescriptor(nt.prototype,"setVideoContentHint"),nt.prototype),X(nt.prototype,"switchDevice",[Rx],Object.getOwnPropertyDescriptor(nt.prototype,"switchDevice"),nt.prototype),X(nt.prototype,"addTrack",[Ax],Object.getOwnPropertyDescriptor(nt.prototype,"addTrack"),nt.prototype),X(nt.prototype,"removeTrack",[Px],Object.getOwnPropertyDescriptor(nt.prototype,"removeTrack"),nt.prototype),X(nt.prototype,"replaceTrack",[Dx],Object.getOwnPropertyDescriptor(nt.prototype,"replaceTrack"),nt.prototype),X(nt.prototype,"recoverCapture",[Lx],Object.getOwnPropertyDescriptor(nt.prototype,"recoverCapture"),nt.prototype),X(nt.prototype,"setAudioCaptureVolume",[Ox,Mx],Object.getOwnPropertyDescriptor(nt.prototype,"setAudioCaptureVolume"),nt.prototype),nt),Vx={voiceActivityDetection:!1},yF=(Nx=Lo({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)}}),kc=function(e){Ct(j,e);var t,n,i,r,o,c,a,s,l,u,p,k,x,E,I,m,T,v,C,O,N=Er(j);function j(_){var b;return Q(this,j),(b=N.call(this,_)).localStream_=null,b.exchangeSDPTimeout_=-1,b.localAuxStream_=null,b.publishingStream_=null,b.isPublishingAuxStream_=!1,b.smallGenerator_=null,b.isSDPExchanging_=!1,b.ssrc_={audio:0,video:0,small:0,auxiliary:0},b.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},b.mixedAudioTrack_=null,b}return Ie(j,[{key:"isMainStreamPublished",get:function(){return!!this.localStream_}},{key:"isAuxStreamPublished",get:function(){return!!this.localAuxStream_}},{key:"publishState",get:function(){var _=this,b={audio:!1,bigVideo:!1,smallVideo:!1,auxVideo:!1};if(this.peerConnection_){var R,P,V,S,h=this.peerConnection_.getSenders();h&&(ki()?(b.audio=!((R=h[0])===null||R===void 0||!R.track),b.bigVideo=!((P=h[1])===null||P===void 0||!P.track),b.smallVideo=!((V=h[2])===null||V===void 0||!V.track),b.auxVideo=!((S=h[3])===null||S===void 0||!S.track)):h.forEach(function(y){y.track&&(y.track.kind===Ee?b.audio=!0:(b.bigVideo=!0,_.smallGenerator_&&(b.smallVideo=!0)))}))}return b}},{key:"initialize",value:function(){le(Qe(j.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(){le(Qe(j.prototype),"close",this).call(this),this.reset(),this.emitConnectionStateChangedEvent(an),this.smallGenerator_&&(this.smallGenerator_.destroy(),this.smallGenerator_=null)}},{key:"installEvents",value:function(){this.emitter_.on(et.ERROR,this.handleError,this),this.emitter_.on(et.CONNECTION_STATE_CHANGED,this.handleConnectionStateChange,this)}},{key:"uninstallEvents",value:function(){this.emitter_.off(et.ERROR,this.handleError,this),this.emitter_.off(et.CONNECTION_STATE_CHANGED,this.handleConnectionStateChange,this)}},{key:"publish",value:(O=H(f().mark(function _(b,R){var P,V,S,h;return f().wrap(function(y){for(;;)switch(y.prev=y.next){case 0:if(this.publishingStream_=b,this.isPublishingAuxStream_=R,V=b.getVideoTrack(),S=null,!V||R||!this.client_.getIsEnableSmallStream()){y.next=9;break}return this.smallGenerator_=new Kl(b),y.next=8,this.smallGenerator_.initialize();case 8:S=this.smallGenerator_.generateSmallVideoTrack(this.client_.smallStreamConfig_);case 9:if(h=b.getVideoProfile(),!this.client_.get2k4kFlag()){y.next=18;break}if(this.client_.get2k4kFlag()===1||b.getScreen()||!(h.height*h.width>=3686400)){y.next=18;break}return h.width=1920,h.height=1080,this.log_.warn(eS),y.next=18,b.setVideoProfile(h);case 18:if(!($i&&co()===115&&h.width*h.height<=230400)){y.next=22;break}return this.log_.warn("fallback video to 480p"),y.next=22,b.setVideoProfile("480p_2");case 22:if(this.updateMediaSettings(b,R),!vm()){y.next=33;break}if(!vi||T4!==11){y.next=29;break}return y.next=27,this.publishByAddTrack(b,S);case 27:y.next=31;break;case 29:return y.next=31,this.publishByTransceiver(b,S,R);case 31:y.next=35;break;case 33:return y.next=35,this.publishByAddTrack(b,S);case 35:return this.publishingStream_=null,this.isPublishingAuxStream_=!1,R?this.localAuxStream_=b:this.localStream_=b,(P=this.sei_)===null||P===void 0||P.handleEncodedStreams(),y.abrupt("return",b);case 40:case"end":return y.stop()}},_,this)})),function(_,b){return O.apply(this,arguments)})},{key:"publishByTransceiver",value:(C=H(f().mark(function _(b,R,P){var V,S,h,y,A,D,U;return f().wrap(function(K){for(;;)switch(K.prev=K.next){case 0:if(this.log_.info("publish by transceiver"),V=b.getMediaStream(),S=b.getAudioTrack(),h=b.getVideoTrack(),y=null,(il||rl)&&OS(h)&&(y=b.getCanvasTrack()),(A=this.peerConnection_.getTransceivers()).length!==0){K.next=16;break}return this.peerConnection_.addTransceiver(S||Ee,{direction:fi,streams:[V]}),this.peerConnection_.addTransceiver(P?Te:y||h||Te,{direction:fi,streams:[V]}),this.peerConnection_.addTransceiver(R||Te,{direction:fi,streams:[V]}),this.peerConnection_.addTransceiver(P?y||h:Te,{direction:fi,streams:[V]}),K.next=14,this.connect();case 14:K.next=46;break;case 16:if(D=[],!S){K.next=29;break}if(!A[0].sender.track){K.next=24;break}return this.mixAudioTrack(A[0].sender.track,S),K.next=22,A[0].sender.replaceTrack(this.mixedAudioTrack_);case 22:K.next=27;break;case 24:return K.next=26,A[0].sender.replaceTrack(S);case 26:D.push(0);case 27:return K.next=29,this.setBandwidth({bandwidth:b.getAudioBitrate(),type:Ee});case 29:if(!h){K.next=42;break}return U=P?3:1,K.next=33,A[U].sender.replaceTrack(y||h);case 33:return K.next=35,this.setBandwidth({bandwidth:b.getVideoBitrate(),type:Te,videoType:P?pt:ju});case 35:if(D.push(U),!R){K.next=42;break}return K.next=39,A[2].sender.replaceTrack(R);case 39:return K.next=41,this.setBandwidth({bandwidth:this.client_.smallStreamConfig.bitrate,type:Te,videoType:Or});case 41:D.push(2);case 42:return K.next=44,this.setTransceiverDirection(fi,D);case 44:return K.next=46,this.doPublishChange();case 46:case"end":return K.stop()}},_,this)})),function(_,b,R){return C.apply(this,arguments)})},{key:"publishByAddTrack",value:(v=H(f().mark(function _(b,R){var P,V,S,h;return f().wrap(function(y){for(;;)switch(y.prev=y.next){case 0:return this.log_.info("publish by addtrack"),P=b.getMediaStream(),V=b.getAudioTrack(),S=b.getVideoTrack(),V&&this.peerConnection_.addTrack(V,P),S&&(this.peerConnection_.addTrack(S,P),R&&((h=new MediaStream).addTrack(R),this.peerConnection_.addTrack(R,h))),y.next=8,this.connect();case 8:case"end":return y.stop()}},_,this)})),function(_,b){return v.apply(this,arguments)})},{key:"unpublish",value:(T=H(f().mark(function _(b){var R,P,V,S;return f().wrap(function(h){for(;;)switch(h.prev=h.next){case 0:if(ki()){h.next=2;break}return h.abrupt("return",this.doUnpublish());case 2:if(R=b.getAudioTrack(),P=b===this.localAuxStream_,V=[],!this.peerConnection_){h.next=33;break}if(S=this.peerConnection_.getSenders(),!R){h.next=18;break}if(!this.mixedAudioTrack_){h.next=15;break}return this.log_.info("has mixed audioTrack, use another audioTrack"),h.next=12,S[0].replaceTrack(P?this.localStream_.getAudioTrack():this.localAuxStream_.getAudioTrack());case 12:this.destroyMixedAudioTrack(),h.next=18;break;case 15:return h.next=17,S[0].replaceTrack(null);case 17:V.push(0);case 18:if(!P){h.next=26;break}return h.next=21,S[3].replaceTrack(null);case 21:this.localAuxStream_=null,this.mediaSettings_=q(q({},this.mediaSettings_),{},{auxVideoBps:0,auxVideoFps:0,auxVideoWidth:0,auxVideoHeight:0}),V.push(3),h.next=33;break;case 26:return h.next=28,S[1].replaceTrack(null);case 28:return h.next=30,S[2].replaceTrack(null);case 30:this.localStream_=null,this.mediaSettings_=q(q({},this.mediaSettings_),{},{videoWidth:0,videoHeight:0,videoBps:0,videoFps:0,audioFs:0,audioChannel:0,audioBps:0,smallVideoWidth:0,smallVideoHeight:0,smallVideoFps:0,smallVideoBps:0}),V.push(1,2);case 33:if(!this.localStream_&&!this.localAuxStream_){h.next=40;break}return h.next=36,this.setTransceiverDirection(io,V);case 36:return h.next=38,this.doPublishChange();case 38:h.next=42;break;case 40:return h.next=42,this.doUnpublish();case 42:case"end":return h.stop()}},_,this)})),function(_){return T.apply(this,arguments)})},{key:"doPublishChange",value:(m=H(f().mark(function _(){var b,R;return f().wrap(function(P){for(;;)switch(P.prev=P.next){case 0:return b={state:this.publishState,constraintConfig:this.mediaSettings_},P.next=3,this.signalChannel_.sendWaitForResponse({command:bU,data:b,responseCommand:mt.PUBLISH_STATE_CHANGE_RESULT});case 3:R=P.sent,this.checkPublishResultCode(R.data.code,R.data.message);case 5:case"end":return P.stop()}},_,this)})),function(){return m.apply(this,arguments)})},{key:"doUnpublish",value:function(){var _=this;return this.signalChannel_.sendWaitForResponse({command:fk,commandDesc:"unpublish",responseCommand:mt.UNPUBLISH_RESULT}).then(function(){_.close()}).catch(function(){_.close()})}},{key:"updateMediaSettings",value:function(_,b){var R=this;this.localAuxStream_&&_===this.localAuxStream_&&(b=!0);var P=this.client_.getSystemResult().detail,V=P.isH264EncodeSupported,S=P.isVp8EncodeSupported;if(V?this.mediaSettings_.videoCodec="H264":S&&(this.mediaSettings_.videoCodec="VP8"),yo){var h=_.getMediaStream();h==null||h.getTracks().forEach(function(y){var A=y.getSettings();if(y.kind===Ee){var D=1;A.channelCount&&(D=A.channelCount),R.mediaSettings_.audioChannel=D,R.mediaSettings_.audioBps=1e3*_.getAudioBitrate(),R.mediaSettings_.audioFs=A.sampleRate}else if(y.kind===Te){if(b)return R.mediaSettings_.auxVideoWidth=A.width,R.mediaSettings_.auxVideoHeight=A.height,R.mediaSettings_.auxVideoFps=A.frameRate,void(R.mediaSettings_.auxVideoBps=1e3*_.getVideoBitrate());R.client_.getIsEnableSmallStream()&&(R.mediaSettings_.smallVideoWidth=R.client_.smallStreamConfig.width,R.mediaSettings_.smallVideoHeight=R.client_.smallStreamConfig.height,R.mediaSettings_.smallVideoFps=R.client_.smallStreamConfig.frameRate,R.mediaSettings_.smallVideoBps=1e3*R.client_.smallStreamConfig.bitrate),R.mediaSettings_.videoWidth=A.width,R.mediaSettings_.videoHeight=A.height,R.mediaSettings_.videoFps=A.frameRate,R.mediaSettings_.videoBps=1e3*_.getVideoBitrate()}})}else this.updateMediaSettingsFromProfile(_);this.log_.info("updateMediaSettings: "+JSON.stringify(this.mediaSettings_))}},{key:"updateMediaSettingsFromProfile",value:function(_){if(_){if(_.hasAudio()){var b=_.getAudioProfile();this.mediaSettings_.audioChannel=b.channelCount,this.mediaSettings_.audioBps=1e3*b.bitrate,this.mediaSettings_.audioFs=b.sampleRate}if(_.hasVideo()){var R=_.getVideoProfile();this.mediaSettings_.videoWidth=R.width,this.mediaSettings_.videoHeight=R.height,this.mediaSettings_.videoFps=R.frameRate,this.mediaSettings_.videoBps=1e3*R.bitrate}}}},{key:"sendMediaSettings",value:function(_){var b=this;this.updateMediaSettings(_),this.signalChannel_.sendWaitForResponse({command:UU,data:this.mediaSettings_,responseCommand:mt.UPDATE_CONSTRAINT_CONFIG_RES}).then(function(R){R.data.code!==0&&b.log_.warn(R.data.message)}).catch(this.log_.warn)}},{key:"addTrack",value:(I=H(f().mark(function _(b,R){var P,V;return f().wrap(function(S){for(;;)switch(S.prev=S.next){case 0:if(this.peerConnection_){S.next=2;break}return S.abrupt("return");case 2:if(V=R===this.localAuxStream_,this.log_.info("is adding ".concat(b.kind," track to current published local ").concat(V?pt:Ye," stream")),(P=this.sei_)===null||P===void 0||P.handleEncodedStreams(),!ki()){S.next=10;break}return S.next=8,this.addTrackByTransceiver(b,R);case 8:S.next=12;break;case 10:return S.next=12,this.addTrackBySender(b);case 12:mn(this.userId_,{eventId:b.kind===Ee?mk:pk,eventDesc:"add ".concat(b.kind," track to current published stream"),timestamp:rn(),userId:this.userId_,tinyId:this.tinyId_});case 13:case"end":return S.stop()}},_,this)})),function(_,b){return I.apply(this,arguments)})},{key:"addTrackByTransceiver",value:(E=H(f().mark(function _(b,R){var P,V,S,h;return f().wrap(function(y){for(;;)switch(y.prev=y.next){case 0:if(P=R===this.localAuxStream_,V=this.peerConnection_.getTransceivers(),b.kind!==Ee){y.next=13;break}if(!V[0].sender.track){y.next=9;break}return this.mixAudioTrack(V[0].sender.track,b),y.next=7,V[0].sender.replaceTrack(this.mixedAudioTrack_);case 7:y.next=11;break;case 9:return y.next=11,V[0].sender.replaceTrack(b);case 11:y.next=26;break;case 13:return S=P?3:1,y.next=16,V[S].sender.replaceTrack(b);case 16:if(S!==1||!this.client_.getIsEnableSmallStream()){y.next=23;break}return this.smallGenerator_=new Kl(this.localStream_),y.next=20,this.smallGenerator_.initialize();case 20:return h=this.smallGenerator_.generateSmallVideoTrack(this.client_.smallStreamConfig_),y.next=23,V[2].sender.replaceTrack(h);case 23:if(V[S].direction!==io){y.next=26;break}return y.next=26,this.setTransceiverDirection(fi,[S]);case 26:return this.updateMediaSettings(R,P),y.next=29,this.doPublishChange();case 29:case"end":return y.stop()}},_,this)})),function(_,b){return E.apply(this,arguments)})},{key:"addTrackBySender",value:(x=H(f().mark(function _(b){var R,P,V,S,h;return f().wrap(function(y){for(;;)switch(y.prev=y.next){case 0:if(!(ki()&&this.peerConnection_.getTransceivers().findIndex(function(A){return A.direction==="stopped"})>=0)){y.next=4;break}return this.log_.warn("transceiver is stopping, negotiate sdp first"),y.next=4,this.updateOffer(sn.REMOVE,b);case 4:if(!(R=this.peerConnection_.getSenders().find(function(A){return A.track&&A.track.kind===b.kind}))){y.next=11;break}return this.log_.warn("sender already exists, remove sender first"),P=R.track,this.removeSender(R),y.next=11,this.updateOffer(sn.REMOVE,P);case 11:if(V=this.localStream_.getMediaStream(),this.peerConnection_.addTrack(b,V),b.kind!==Te||!this.client_.getIsEnableSmallStream()){y.next=21;break}return this.smallGenerator_=new Kl(this.localStream_),y.next=17,this.smallGenerator_.initialize();case 17:S=this.smallGenerator_.generateSmallVideoTrack(this.client_.smallStreamConfig_),(h=new MediaStream).addTrack(S),this.peerConnection_.addTrack(S,h);case 21:return y.next=23,this.updateOffer(sn.ADD,b);case 23:case"end":return y.stop()}},_,this)})),function(_){return x.apply(this,arguments)})},{key:"isNeedToResetOfferOrder",value:function(){if(this.sdpSemantics_===Hf||!this.peerConnection_||!this.peerConnection_.localDescription)return!1;for(var _=this.peerConnection_.localDescription.sdp,b=Br(_),R=0;R<b.media.length;R++)if(b.media[R].mid===0&&b.media[R].type===Te)return!0;return!1}},{key:"removeSender",value:function(_){var b=null;ki()&&(b=this.peerConnection_.getTransceivers().find(function(R){return R.sender&&R.sender.track===_.track})),this.peerConnection_.removeTrack(_),b&&pn(b.stop)&&(this.log_.info("stop transceiver"),b.stop())}},{key:"removeTrack",value:(k=H(f().mark(function _(b,R){return f().wrap(function(P){for(;;)switch(P.prev=P.next){case 0:if(this.peerConnection_){P.next=2;break}return P.abrupt("return");case 2:if(this.log_.info("is removing ".concat(b.kind," track from current published local ").concat(R===this.localAuxStream_?pt:Ye," stream")),!ki()){P.next=8;break}return P.next=6,this.removeTrackByTransceiver(b,R);case 6:P.next=10;break;case 8:return P.next=10,this.removeTrackBySender(b);case 10:mn(this.userId_,{eventId:b.kind===Ee?gk:vk,eventDesc:"remove ".concat(b.kind," track from current published stream"),timestamp:rn(),userId:this.userId_,tinyId:this.tinyId_});case 11:case"end":return P.stop()}},_,this)})),function(_,b){return k.apply(this,arguments)})},{key:"removeTrackByTransceiver",value:(p=H(f().mark(function _(b,R){var P,V,S;return f().wrap(function(h){for(;;)switch(h.prev=h.next){case 0:if(P=R===this.localAuxStream_,V=this.peerConnection_.getTransceivers(),b.kind!==Ee){h.next=13;break}if(!this.mixedAudioTrack_){h.next=9;break}return h.next=6,V[0].sender.replaceTrack(P?this.localStream_.getAudioTrack():this.localAuxStream_.getAudioTrack());case 6:this.destroyMixedAudioTrack(),h.next=11;break;case 9:return h.next=11,V[0].sender.replaceTrack(null);case 11:h.next=23;break;case 13:return S=P?3:1,h.next=16,V[S].sender.replaceTrack(null);case 16:if(S!==1||!this.smallGenerator_){h.next=21;break}return this.smallGenerator_.destroy(),this.smallGenerator_=null,h.next=21,V[2].sender.replaceTrack(null);case 21:return h.next=23,this.setTransceiverDirection(io,[S]);case 23:return this.updateMediaSettings(R,P),h.next=26,this.doPublishChange();case 26:case"end":return h.stop()}},_,this)})),function(_,b){return p.apply(this,arguments)})},{key:"setTransceiverDirection",value:(u=H(f().mark(function _(b,R){var P,V,S,h,y,A;return f().wrap(function(D){for(;;)switch(D.prev=D.next){case 0:if(Tr){D.next=2;break}return D.abrupt("return");case 2:if(P=!1,V=!1,this.log_.info("setting transceiver ".concat(R.join(",")," direction to ").concat(b)),S=this.peerConnection_.getTransceivers(),R.forEach(function(U){S[U].direction!==b&&(S[U].direction=b,P=!0)}),!P){D.next=14;break}return this.log_.info("updating offer"),D.next=11,this.peerConnection_.createOffer();case 11:return h=D.sent,D.next=14,this.peerConnection_.setLocalDescription(h);case 14:if(y=-1,A=this.peerConnection_.remoteDescription.sdp.split(`\r
63
+ `).map(function(U){if(U.match(new RegExp("a=(".concat(io,"|").concat(Df,"|").concat(fi,")")))&&y++,R.includes(y)){if(b===io&&U.includes("a=".concat(Df)))return V=!0,"a=".concat(b);if(b===fi&&U.includes("a=".concat(io)))return V=!0,"a=".concat(Df)}return U}).join(`\r
64
+ `),!V){D.next=20;break}return this.log_.info("updating answer"),D.next=20,this.peerConnection_.setRemoteDescription({type:"answer",sdp:A});case 20:case"end":return D.stop()}},_,this)})),function(_,b){return u.apply(this,arguments)})},{key:"removeTrackBySender",value:(l=H(f().mark(function _(b){var R,P,V=this;return f().wrap(function(S){for(;;)switch(S.prev=S.next){case 0:if(b.kind!==Te||!this.isNeedToResetOfferOrder()){S.next=7;break}return this.reset(),this.initialize(),(R=this.localStream_.getMediaStream())===null||R===void 0||R.removeTrack(b),S.next=6,this.publish(this.localStream_);case 6:return S.abrupt("return");case 7:return(P=this.peerConnection_.getSenders().find(function(h){return h.track===b}))&&(this.removeSender(P),b.kind===Te&&this.smallGenerator_&&(this.smallGenerator_.destroy(),this.smallGenerator_=null,this.peerConnection_.getSenders().forEach(function(h){h.track&&h.track.kind===Te&&V.removeSender(h)}))),S.next=11,this.updateOffer(sn.REMOVE,b);case 11:case"end":return S.stop()}},_,this)})),function(_){return l.apply(this,arguments)})},{key:"replaceTrack",value:(s=H(f().mark(function _(b,R){var P,V,S,h,y,A,D;return f().wrap(function(U){for(;;)switch(U.prev=U.next){case 0:if((V=(P=this.peerConnection_)===null||P===void 0?void 0:P.getSenders())&&V.length!==0){U.next=3;break}throw new ne({code:ee.INVALID_OPERATION,message:ie({key:lS})});case 3:if(S=R===this.localAuxStream_,this.log_.info("is replacing ".concat(b.kind," track to current published local ").concat(S?pt:Ye," stream")),b.kind!==Ee||!V[0]){U.next=16;break}if(!(this.mixedAudioTrack_&&(h=this.localStream_)!==null&&h!==void 0&&h.hasAudio()&&(y=this.localAuxStream_)!==null&&y!==void 0&&y.hasAudio())){U.next=14;break}return this.destroyMixedAudioTrack(),A=S?this.localStream_.getAudioTrack():this.localAuxStream_.getAudioTrack(),this.mixAudioTrack(b,A),U.next=12,V[0].replaceTrack(this.mixedAudioTrack_);case 12:U.next=16;break;case 14:return U.next=16,V[0].replaceTrack(b);case 16:if(b.kind!==Te){U.next=32;break}if(R!==this.localStream_||!V[1]){U.next=29;break}return U.next=20,V[1].replaceTrack(b);case 20:if(!this.smallGenerator_||!V[2]){U.next=29;break}return this.log_.info("replacing smallVideo"),this.smallGenerator_.destroy(),this.smallGenerator_=new Kl(this.localStream_),U.next=26,this.smallGenerator_.initialize();case 26:return D=this.smallGenerator_.generateSmallVideoTrack(this.client_.smallStreamConfig_),U.next=29,V[2].replaceTrack(D);case 29:if(R!==this.localAuxStream_||!V[3]){U.next=32;break}return U.next=32,V[3].replaceTrack(b);case 32:mn(this.userId_,{eventId:b.kind===Ee?qU:WU,eventDesc:"replace ".concat(b.kind," track from current published stream"),timestamp:rn(),userId:this.userId_,tinyId:this.tinyId_});case 33:case"end":return U.stop()}},_,this)})),function(_,b){return s.apply(this,arguments)})},{key:"updateOffer",value:(a=H(f().mark(function _(b,R){var P,V,S,h,y,A,D;return f().wrap(function(U){for(;;)switch(U.prev=U.next){case 0:return U.prev=0,U.next=3,this.peerConnection_.createOffer(Vx);case 3:return P=U.sent,Tr&&(P.sdp=this.setSDPDirection(P.sdp,"sendrecv")),U.next=7,this.peerConnection_.setLocalDescription(P);case 7:return V=this.updateMediaSettings(this.localStream_||this.localAuxStream_),S={action:b,trackId:R.id,kind:R.kind===Te?"bigVideo":R.kind,type:"offer",sdp:this.peerConnection_.localDescription.sdp,constraintConfig:V,state:this.publishState},this.log_.info("createOffer success, sending updated offer to remote server"),this.log_.debug("updatedOffer: "+S.sdp),U.next=13,this.signalChannel_.sendWaitForResponse({command:yU,data:S,responseCommand:mt.UPDATE_OFFER_RESULT,timeout:1e4,commandDesc:"update offer"});case 13:return h=U.sent,y=h.data,A=y.code,D=y.message,A!==0&&this.checkPublishResultCode(A,D),U.next=18,this.acceptAnswer(h.data.data);case 18:this.updateSSRC(P.sdp),xe.logSuccessEvent({userId:this.client_.getUserId(),eventType:qu,kind:"offer"}),U.next=27;break;case 22:throw U.prev=22,U.t0=U.catch(0),this.log_.error(U.t0),xe.logFailedEvent({userId:this.client_.getUserId(),eventType:qu,kind:"offer",error:U.t0}),U.t0;case 27:case"end":return U.stop()}},_,this,[[0,22]])})),function(_,b){return a.apply(this,arguments)})},{key:"setBandwidth",value:(c=H(f().mark(function _(b){var R,P,V,S,h,y,A,D;return f().wrap(function(U){for(;;)switch(U.prev=U.next){case 0:if(R=b.bandwidth,P=b.type,V=b.videoType,S=V===void 0?"":V,h=b.sdp,Nk()||!h){U.next=3;break}return U.abrupt("return",P===Te?this.updateVideoBandwidthRestriction(h,R,S):this.updateAudioBandwidthRestriction(h,R));case 3:if(y=0,P===Te&&(y=S===Or?2:S===pt?3:1),!(A=this.peerConnection_.getSenders()[y])){U.next=22;break}return(D=A.getParameters()).encodings&&D.encodings.length!==0||(D.encodings=[{}]),R==="unlimited"?delete D.encodings[0].maxBitrate:D.encodings[0].maxBitrate=1e3*R,U.prev=10,U.next=13,A.setParameters(D);case 13:return this.log_.info(S+P+" bandwidth was set to "+R+" kbps"),U.abrupt("return",h);case 17:if(U.prev=17,U.t0=U.catch(10),this.log_.info("failed to set bandwidth by setting maxBitrate: "+U.t0),!h){U.next=22;break}return U.abrupt("return",P===Te?this.updateVideoBandwidthRestriction(h,R,S):this.updateAudioBandwidthRestriction(h,R));case 22:return U.abrupt("return",h);case 23:case"end":return U.stop()}},_,this,[[10,17]])})),function(_){return c.apply(this,arguments)})},{key:"updateVideoBandwidthRestriction",value:function(_,b,R){var P="AS";Tr&&(P="TIAS",b*=1e3);var V=0,S=-1;return R===Or?V=1:R===pt&&(V=2),_=_.replace(/m=video (.*)\r\nc=IN (.*)\r\n/g,function(h){return++S===V?"".concat(h,"b=").concat(P,":").concat(b,`\r
65
+ `):h}),_}},{key:"updateAudioBandwidthRestriction",value:function(_,b){var R="AS";return Tr&&(R="TIAS",b*=1e3),_=_.replace(/m=audio (.*)\r\nc=IN (.*)\r\n/,`m=audio $1\r
102
66
  c=IN $2\r
103
- b=`+P+":"+k+`\r
104
- `)}},{key:"removeBandwidthRestriction",value:function(L){return L.replace(/b=AS:.*\r\n/,"").replace(/b=TIAS:.*\r\n/,"")}},{key:"removeVideoOrientation",value:function(L){return L.replace(/urn:3gpp:video-orientation/,"")}},{key:"connect",value:(o=N(p().mark(function L(){return p().wrap(function(k){for(;;)switch(k.prev=k.next){case 0:return k.prev=0,k.next=3,this.exchangeSDP();case 3:return k.next=5,this.waitForPeerConnectionConnected();case 5:k.next=11;break;case 7:throw k.prev=7,k.t0=k.catch(0),this.closePeerConnection(!0),k.t0;case 11:case"end":return k.stop()}},L,this,[[0,7]])})),function(){return o.apply(this,arguments)})},{key:"exchangeSDP",value:(i=N(p().mark(function L(){return p().wrap(function(k){for(;;)switch(k.prev=k.next){case 0:return k.prev=0,this.isSDPExchanging_=!0,k.next=4,this.createOffer();case 4:return this.log_.info("createOffer success, sending offer to remote server"),k.next=7,this.doExchangeSDP();case 7:this.isSDPExchanging_=!1,k.next=14;break;case 10:throw k.prev=10,k.t0=k.catch(0),this.isSDPExchanging_=!1,k.t0;case 14:case"end":return k.stop()}},L,this,[[0,10]])})),function(){return i.apply(this,arguments)})},{key:"createOffer",value:(r=N(p().mark(function L(){var k;return p().wrap(function(P){for(;;)switch(P.prev=P.next){case 0:return P.prev=0,P.next=3,this.peerConnection_.createOffer(UI);case 3:return k=P.sent,P.next=6,this.peerConnection_.setLocalDescription(k);case 6:this.updateSSRC(k.sdp),Ie.logSuccessEvent({userId:this.client_.getUserId(),eventType:el,kind:"offer"}),P.next=14;break;case 10:throw P.prev=10,P.t0=P.catch(0),Ie.logFailedEvent({userId:this.client_.getUserId(),eventType:el,kind:"offer",error:P.t0}),P.t0;case 14:case"end":return P.stop()}},L,this,[[0,10]])})),function(){return r.apply(this,arguments)})},{key:"doExchangeSDP",value:function(){var L=this;return new Promise(function(k,P){L.exchangeSDPTimeout_=setTimeout(function(){L.signalChannel_.off(vt.PUBLISH_RESULT,A),L.clearExchangeSDPTimeout();var T=new ee({code:Y.API_CALL_TIMEOUT,message:ne({key:x3})});P(T)},1e4);var A=function(){var T=N(p().mark(function v(E){var C,O,F;return p().wrap(function(K){for(;;)switch(K.prev=K.next){case 0:if(K.prev=0,L.clearExchangeSDPTimeout(),C=E.data,O=C.code,F=C.message,O!==0){K.next=9;break}return K.next=6,L.acceptAnswer(E.data.data);case 6:k(),K.next=10;break;case 9:L.checkPublishResultCode(O,F);case 10:K.next=15;break;case 12:K.prev=12,K.t0=K.catch(0),P(K.t0);case 15:case"end":return K.stop()}},v,null,[[0,12]])}));return function(v){return T.apply(this,arguments)}}(),U={type:L.peerConnection_.localDescription.type,sdp:L.removeVideoOrientation(L.peerConnection_.localDescription.sdp),screen:(L.publishingStream_||L.localStream_).hasScreenTrack(),state:L.publishState,constraintConfig:L.mediaSettings_};L.signalChannel_.once(vt.PUBLISH_RESULT,A),L.log_.debug("sending sdp offer: "+U.sdp),L.signalChannel_.send(TU,U)})}},{key:"setSDPDirection",value:function(L,k){var P=arguments.length>2&&arguments[2]!==void 0?arguments[2]:"all",A=Fr(L);return A.media.forEach(function(U){P!=="all"&&U.type!==P||(U.direction=k)}),mo(A)}},{key:"acceptAnswer",value:(n=N(p().mark(function L(k){var P,A,U,T,v,E,C;return p().wrap(function(O){for(;;)switch(O.prev=O.next){case 0:if(O.prev=0,P=this.removeVideoOrientation(k.sdp),!(A=this.publishingStream_||this.localStream_)){O.next=15;break}if(U=A.getVideoBitrate(),T=A.getAudioBitrate(),!U){O.next=11;break}return v=this.isPublishingAuxStream_?mt:Ku,O.next=10,this.setBandwidth({bandwidth:U,type:xe,sdp:P,videoType:v});case 10:P=O.sent;case 11:if(!T){O.next=15;break}return O.next=14,this.setBandwidth({bandwidth:T,type:Ce,sdp:P});case 14:P=O.sent;case 15:if(!this.client_.getIsEnableSmallStream()){O.next=20;break}return E=this.client_.smallStreamConfig,O.next=19,this.setBandwidth({bandwidth:E.bitrate,type:xe,videoType:Nr,sdp:P});case 19:P=O.sent;case 20:return C={type:k.type,sdp:P},O.next=23,this.peerConnection_.setRemoteDescription(C);case 23:this.log_.debug("accepted answer: "+P),Ie.logSuccessEvent({userId:this.client_.getUserId(),eventType:Ob,kind:"answer"}),O.next=32;break;case 27:throw O.prev=27,O.t0=O.catch(0),Ie.logFailedEvent({userId:this.client_.getUserId(),eventType:Ob,kind:"answer",error:O.t0}),this.log_.error("failed to accept remote answer "+O.t0),O.t0;case 32:case"end":return O.stop()}},L,this,[[0,27]])})),function(L){return n.apply(this,arguments)})},{key:"sendMutedFlag",value:function(L,k){if(k!==this.localAuxStream_){var P={audio:L.audio,bigVideo:L.video,auxVideo:L.auxVideo};this.log_.info("send muted state: ".concat(JSON.stringify(P))),this.signalChannel_.send(kU,P)}}},{key:"getIsReconnecting",value:function(){return this.isReconnecting_}},{key:"reconnect",value:(t=N(p().mark(function L(){var k,P,A=this;return p().wrap(function(U){for(;;)switch(U.prev=U.next){case 0:if(this.reconnectionTimer_===-1){U.next=3;break}return this.log_.warn("reconnect() uplink is reconnecting, ignore current reconnection"),U.abrupt("return");case 3:if(!(this.reconnectionCount_>=30)){U.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(),k=new ee({code:Y.UPLINK_RECONNECTION_FAILED,message:ne({key:E3})}),Ie.logFailedEvent({userId:this.client_.getUserId(),eventType:Pb,error:k}),this.addEventInternal(o6,"uplink-connection reconnect fail"),this.emitConnectionStateChangedEvent(sn),this.emitter_.emit(tt.ERROR,k),U.abrupt("return");case 12:if(this.signalChannel_.getCurrentState()===cc){U.next=16;break}return this.log_.warn("reconnect() signal channel is not connected, suspend reconnection until signal is connected"),this.signalChannel_.once(sc,this.reconnect,this),U.abrupt("return");case 16:if(this.reconnectionCount_++,U.prev=17,this.log_.warn("reconnect() try to reconnect uplink [".concat(this.reconnectionCount_,"/").concat(30,"]")),P=Mf(this.reconnectionCount_),this.reconnectionTimer_=setTimeout(function(){A.log_.warn("reconnect() uplink reconnect timeout(".concat(P/1e3,"s), try again")),A.clearReconnectionTimer(),A.reconnect()},P),!(this.isSDPExchanging_||this.peerConnection_&&this.peerConnection_.connectionState===Zu)){U.next=23;break}return U.abrupt("return");case 23:return U.next=25,this.signalChannel_.sendWaitForResponse({command:pT,responseCommand:vt.UNPUBLISH_RESULT,enableLog:!1});case 25:if(this.reset(),this.initialize(),!this.localStream_){U.next=30;break}return U.next=30,this.publish(this.localStream_);case 30:if(!this.localAuxStream_){U.next=33;break}return U.next=33,this.publish(this.localAuxStream_,!0);case 33:Ie.logSuccessEvent({userId:this.client_.getUserId(),eventType:Pb}),this.log_.warn("reconnect() uplink reconnect successfully"),this.addEventInternal(a6,"uplink-connection reconnect success"),this.stopReconnection(),this.localStream_.syncMuteState(),U.next=42;break;case 40:U.prev=40,U.t0=U.catch(17);case 42:case"end":return U.stop()}},L,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(L){L.getCode()===Y.ICE_TRANSPORT_ERROR&&(this.isFirstConnection_&&(this.isFirstConnection_=!1,Ie.logFailedEvent({userId:this.client_.getUserId(),eventType:Ab,error:L})),this.isReconnecting_||this.startReconnection())}},{key:"handleConnectionStateChange",value:function(L){L.state===mn&&this.isFirstConnection_&&(this.isFirstConnection_=!1,Ie.logSuccessEvent({userId:this.client_.getUserId(),eventType:Ab}),this.addEventInternal(ZU,"uplink-connection is connected"))}},{key:"updateSSRC",value:function(L){var k=this;try{Fr(L).media.forEach(function(P,A){if(P.type===Ce){var U=P.ssrcs[0];U&&(k.ssrc_.audio=U.id)}else{if(k.sdpSemantics_===nf)return void P.ssrcGroups.forEach(function(v,E){var C=Number(v.ssrcs.split(" ")[0]);E===0?k.ssrc_.video=C:E===1&&(k.ssrc_.small=C)});var T=P.ssrcs[0];if(!T)return;switch(A){case 1:k.ssrc_.video=T.id;break;case 2:k.ssrc_.small=T.id;break;case 3:k.ssrc_.auxiliary=T.id}}})}catch(P){}}},{key:"getVideoTrackId",value:function(){var L=arguments.length>0&&arguments[0]!==void 0?arguments[0]:xe;if(this.peerConnection_){var k=this.peerConnection_.getSenders();if(L===xe&&k[1]&&k[1].track)return k[1].track.id;if(L===Nr&&k[2]&&k[2].track)return k[2].track.id;if(L===mt&&k[3]&&k[3].track)return k[3].track.id}if(this.localStream_&&L===xe){var P=this.localStream_.getVideoTrack();if(P)return P.id}if(this.localAuxStream_&&L===mt){var A=this.localAuxStream_.getVideoTrack();if(A)return A.id}return""}},{key:"getSSRC",value:function(){return this.ssrc_}},{key:"checkPublishResultCode",value:function(L,k){if(L!==0)throw L===1028?(this.log_.error(vi.NOT_SUPPORTED_H264ENCODE),new ee({code:Y.NOT_SUPPORTED_H264,message:ne({key:mk})})):new ee({code:Y.UNKNOWN,message:ne({key:gk,data:{signalResponse:vt.PUBLISH_RESULT,code:L,message:k}})})}},{key:"getLocalStream",value:function(){return this.localStream_}},{key:"sendSEI",value:function(L,k){this.sei_.push(L,k)}},{key:"mixAudioTrack",value:function(L,k){this.log_.info("mix audio track"),this.mixedAudioTrack_=function(P){var A=Uk(),U=A.createMediaStreamDestination(),T=[];P.forEach(function(E){var C=new MediaStream;C.addTrack(E);var O=A.createMediaStreamSource(C);O.connect(U),T.push(O)});var v=U.stream.getAudioTracks()[0];return id.set(v,{destination:U,track:v,mediaStreamSourceList:T}),v}([L,k])}},{key:"destroyMixedAudioTrack",value:function(){this.mixedAudioTrack_&&(this.log_.info("destroy audio track"),function(L){if(id.has(L)){var k=id.get(L),P=k.destination,A=k.track,U=k.mediaStreamSourceList;A.stop(),P.disconnect(),U.forEach(function(T){T.disconnect()}),id.delete(L)}}(this.mixedAudioTrack_),this.mixedAudioTrack_=null)}}]),ue}(Qv),W(Ic.prototype,"publish",[NI],Object.getOwnPropertyDescriptor(Ic.prototype,"publish"),Ic.prototype),Ic),v7=pe,BI=Ps,ad=Es.exports.getWeakData,g7=oi,_7=It,y7=Ct,ig=ot,S7=As,jI=xt,b7=Xe.set,k7=Xe.getterFor,T7=an.find,x7=an.findIndex,I7=v7([].splice),w7=0,od=function(e){return e.frozen||(e.frozen=new FI)},FI=function(){this.entries=[]},ag=function(e,t){return T7(e.entries,function(n){return n[0]===t})};FI.prototype={get:function(e){var t=ag(this,e);if(t)return t[1]},has:function(e){return!!ag(this,e)},set:function(e,t){var n=ag(this,e);n?n[1]=t:this.entries.push([e,t])},delete:function(e){var t=x7(this.entries,function(n){return n[0]===e});return~t&&I7(this.entries,t,1),!!~t}};var wc,E7={getConstructor:function(e,t,n,r){var i=e(function(c,u){g7(c,o),b7(c,{type:t,id:w7++,frozen:void 0}),y7(u)||S7(u,c[r],{that:c,AS_ENTRIES:n})}),o=i.prototype,a=k7(t),s=function(c,u,d){var h=a(c),_=ad(_7(u),!0);return _===!0?od(h).set(u,d):_[h.id]=d,c};return BI(o,{delete:function(c){var u=a(this);if(!ig(c))return!1;var d=ad(c);return d===!0?od(u).delete(c):d&&jI(d,u.id)&&delete d[u.id]},has:function(c){var u=a(this);if(!ig(c))return!1;var d=ad(c);return d===!0?od(u).has(c):d&&jI(d,u.id)}}),BI(o,n?{get:function(c){var u=a(this);if(ig(c)){var d=ad(c);return d===!0?od(u).get(c):d?d[u.id]:void 0}},set:function(c,u){return s(this,c,u)}}:{add:function(c){return s(this,c,!0)}}),i}},GI=te,sd=pe,C7=Ps,R7=Es.exports,A7=wh,HI=E7,cd=ot,ud=Q_,ld=Xe.enforce,P7=x,D7=!GI.ActiveXObject&&"ActiveXObject"in GI,zI=function(e){return function(){return e(this,arguments.length?arguments[0]:void 0)}},L7=A7("WeakMap",zI,HI);if(P7&&D7){wc=HI.getConstructor(zI,"WeakMap",!0),R7.enable();var Ec=L7.prototype,WI=sd(Ec.delete),dd=sd(Ec.has),JI=sd(Ec.get),KI=sd(Ec.set);C7(Ec,{delete:function(e){if(cd(e)&&!ud(e)){var t=ld(this);return t.frozen||(t.frozen=new wc),WI(this,e)||t.frozen.delete(e)}return WI(this,e)},has:function(e){if(cd(e)&&!ud(e)){var t=ld(this);return t.frozen||(t.frozen=new wc),dd(this,e)||t.frozen.has(e)}return dd(this,e)},get:function(e){if(cd(e)&&!ud(e)){var t=ld(this);return t.frozen||(t.frozen=new wc),dd(this,e)?JI(this,e):t.frozen.get(e)}return JI(this,e)},set:function(e,t){if(cd(e)&&!ud(e)){var n=ld(this);n.frozen||(n.frozen=new wc),dd(this,e)?KI(this,e,t):n.frozen.set(e,t)}else KI(this,e,t);return this}})}var O7=Me,hd=Js,M7=oe,qI=Pn,XI=at,N7=ju,QI=lb,V7=Qt,og=hd&&hd.prototype;if(O7({target:"Promise",proto:!0,real:!0,forced:!!hd&&M7(function(){og.finally.call({then:function(){}},function(){})})},{finally:function(e){var t=N7(this,qI("Promise")),n=XI(e);return this.then(n?function(r){return QI(t,e()).then(function(){return r})}:e,n?function(r){return QI(t,e()).then(function(){throw r})}:e)}}),XI(hd)){var YI=qI("Promise").prototype.finally;og.finally!==YI&&V7(og,"finally",YI,{unsafe:!0})}var $I,ZI,ew,tw,or,Lo=new WeakMap;function nw(){return function(e,t,n){var r=n.value,i=function o(a){var s=a.fn,c=a.args,u=a.context,d=a.resolve,h=a.reject;s.apply(u,c).then(d,h).finally(function(){var _=Lo.get(u);_&&(_.shift(),_[0]&&o(H({},_[0])))})};return n.value=function(){for(var o=this,a=arguments.length,s=new Array(a),c=0;c<a;c++)s[c]=arguments[c];return new Promise(function(u,d){if(Lo.has(o)){var h=Lo.get(o),_=h.length;h.push({fn:r,args:s,context:o,resolve:u,reject:d,name:t}),_===0&&i({fn:r,args:s,context:o,resolve:u,reject:d})}else Lo.set(o,[{fn:r,args:s,context:o,resolve:u,reject:d,name:t}]),i({fn:r,args:s,context:o,resolve:u,reject:d})})},n}}var U7=($I=nw(),ZI=xc({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)}}),ew=nw(),tw=function(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:1e4;return function(t,n,r){var i=r.value;return r.value=function(){for(var o=this,a=arguments.length,s=new Array(a),c=0;c<a;c++)s[c]=arguments[c];return new Promise(function(u,d){var h=setTimeout(function(){return d(new Error("".concat(n," timeout")))},e);i.apply(o,s).then(u,d).finally(function(){clearTimeout(h)})})},r}}(),or=function(e){Nt(u,e);var t,n,r,i,o,a,s,c=Ar(u);function u(d){var h;return J(this,u),(h=c.call(this,d)).remoteStreams_=new Map,h.autoSubscribe=d.autoSubscribe,h.trackState_={audio:d.trackState.audio,video:d.trackState.video,auxiliary:d.trackState.auxiliary,smallVideo:d.trackState.smallVideo},h.ssrc_={audio:0,video:0,auxiliary:0},h.subscribeState_={audio:d.autoSubscribe,video:d.autoSubscribe,auxiliary:d.autoSubscribe,smallVideo:!1},h.isSDPExchanging_=!1,h.installEvents(),h}return ye(u,[{key:"getMixUserList",value:function(){return this.mixUserList_?this.mixUserList_.map(function(d){var h=d.userId,_=d.flag;return{userId:h,hasAudio:!!(8&_),hasVideo:!!(1&_),hasAuxiliary:!!(4&_)}}):void 0}},{key:"setMixUserList",value:function(d){(!this.mixUserList_||ml(this.mixUserList_)&&!function(h,_){if(_.length===h.length){var y,b=ie(_);try{var f=function(){var I=y.value,w=h.find(function(j){return j.userId===I.userId});if(!w||w.flag!==I.flag)return{v:!1}};for(b.s();!(y=b.n()).done;){var g=f();if(V(g)==="object")return g.v}}catch(I){b.e(I)}finally{b.f()}return!0}return!1}(this.mixUserList_,d))&&(this.mixUserList_=d,this.emitter_.emit(tt.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(d){return d.getType()===Ze?!this.trackState_.audio&&!this.trackState_.video:!this.trackState_.auxiliary}},{key:"initialize",value:function(){se($e(u.prototype),"initialize",this).call(this),this.peerConnection_.ontrack=this.onTrack.bind(this)}},{key:"close",value:function(){var d,h,_,y=this;se($e(u.prototype),"close",this).call(this),this.trackState_.audio=!1,this.trackState_.video=!1,this.trackState_.smallVideo=!1,this.trackState_.auxiliary=!1,this.emitConnectionStateChangedEvent(sn),d=this,h=function(b){b.fn;var f=b.args,g=b.resolve,I=b.reject,w=b.name;if(w==="subscribe"){if(!y.client_.getIsJoined())return I(new ee({code:Y.API_CALL_ABORTED,message:ne({key:mf,data:{message:"leave room",stream:f[0]}})}));if(y.isStreamUnpublished(f[0]))return I(new ee({code:Y.API_CALL_ABORTED,message:ne({key:mf,data:{message:"remote user ".concat(y.userId_," unpublished stream"),stream:f[0]}})}))}else if(w==="unsubscribe")return g();g()},(_=Lo.get(d))===null||_===void 0||_.forEach(h),Lo.delete(d),this.remoteStreams_.forEach(function(b){var f=b;f.setConnection(null),f.uninstallEvents(),f.getIsStreamAddedEventEmitted()&&y.emitter_.emit(tt.STREAM_REMOVED,{stream:f})}),this.remoteStreams_.clear(),this.uninstallEvents()}},{key:"installEvents",value:function(){var d=this;q.on(Bn,this.onRemoteStreamUpdate,this),this.emitter_.on(tt.ERROR,function(h){h.getCode()===Y.ICE_TRANSPORT_ERROR&&(d.isFirstConnection_&&(d.isFirstConnection_=!1,Ie.logFailedEvent({userId:d.client_.getUserId(),eventType:Db,error:h})),d.isReconnecting_||d.startReconnection())}),this.emitter_.on(tt.CONNECTION_STATE_CHANGED,function(h){h.state===mn&&d.isFirstConnection_&&(d.isFirstConnection_=!1,Ie.logSuccessEvent({userId:d.client_.getUserId(),eventType:Db}),d.addEventInternal(e6,"downlink-connection is connected"))})}},{key:"uninstallEvents",value:function(){q.removeListener(Bn,this.onRemoteStreamUpdate,this)}},{key:"onRemoteStreamUpdate",value:function(d){if(this.hitTest(d.tinyId)&&d.client===this.client_){this.updateTrackState(d.action,d.kind);var h=d.kind===mt?Qs:br,_=this.remoteStreams_.get(h);if(!_)return;d.action===un.ADD?this.handleRemoteAddTrack(d.kind,_):this.handleRemoteRemoveTrack(d.kind,_)}}},{key:"handleRemoteAddTrack",value:function(d,h){this.log_.info("remote add ".concat(d," track")),d===Ce?h.updateAudioPlayingState(this.subscribeState_.audio):h.updateVideoPlayingState(d===mt?this.subscribeState_.auxiliary:this.subscribeState_.video||this.subscribeState_.smallVideo),h.getIsStreamAddedEventEmitted()?this.emitter_.emit(tt.STREAM_UPDATED,{stream:h}):(this.emitter_.emit(tt.STREAM_ADDED,{stream:h}),this.currentState_===mn&&h.emitConnectionStateChanged({prevState:sn,state:mn}))}},{key:"handleRemoteRemoveTrack",value:function(d,h){h.getIsStreamAddedEventEmitted()&&(this.log_.info("remote remove ".concat(d," track")),d===mt||!this.trackState_.audio&&!this.trackState_.video?(this.log_.info("remote stream ".concat(h.getType()," removed")),this.currentState_===mn&&h.emitConnectionStateChanged({prevState:mn,state:sn}),this.emitter_.emit(tt.STREAM_REMOVED,{stream:h})):(d===Ce?h.updateAudioPlayingState(!1):(d!==qu||this.isSmallStreamSubscribed)&&h.updateVideoPlayingState(!1),this.emitter_.emit(tt.STREAM_UPDATED,{stream:h})))}},{key:"updateTrackState",value:function(d,h){var _=d===un.ADD;switch(h){case Ce:this.trackState_.audio=_;break;case xe:this.trackState_.video=_;break;case mt:this.trackState_.auxiliary=_;break;case qu:this.trackState_.smallVideo=_}this.log_.info("trackState updated: ".concat(JSON.stringify(this.trackState_)))}},{key:"onTrack",value:function(d){var h=d.streams[0],_=d.track;if(this.log_.info("ontrack() kind: ".concat(_.kind," id: ").concat(_.id," streamId: ").concat(h.id)),this.sdpSemantics_===$s){var y=function(w){var j=er.parse(w),z={audio:[],video:[]};return j.media.forEach(function($){if($.ssrcs){var ue=$.ssrcs[0].id>>16&255;if($.type===Ce)z.audio.push(br);else if($.type==xe){var L=ue===KN?br:Qs;z.video.push(L)}}}),z}(this.peerConnection_.remoteDescription.sdp);if(_.kind===Ce){if(y.audio.length===0||h.id!==br)return void this.log_.debug("skip this invalid audio track")}else if(y.video.indexOf(h.id)===-1)return void this.log_.debug("skip this invalid video track: ".concat(_.id," msid: ").concat(h.id))}Ie.logEvent({eventType:"ontrack",kind:_.kind});var b=!1,f=this.remoteStreams_.get(h.id),g=h.id===br?_t:Dt;if(ve(f)&&((f=new Zv({type:g,userId:this.userId_,client:this.client_})).setConnection(this),this.remoteStreams_.set(h.id,f),b=!0),f.setMediaStream(h),_.kind===Ce?f.updateAudioPlayingState(this.subscribeState_.audio):g===_t?f.updateVideoPlayingState(this.subscribeState_.video||this.subscribeState_.smallVideo):f.updateVideoPlayingState(this.subscribeState_.auxiliary),(g!==Dt||this.trackState_.auxiliary)&&(g!==_t||this.trackState_.audio||this.trackState_.video)){var I=this.client_.getSubscriptionManager();I&&I.hasAutoRecoveryFlag(this.userId_,g)||(b?this.emitter_.emit(tt.STREAM_ADDED,{stream:f}):this.emitter_.emit(tt.STREAM_UPDATED,{stream:f}))}}},{key:"addRRTRLine",value:function(d){var h=d.split(`\r
105
- `),_=new Map;h.forEach(function(w,j){/^a=rtcp-fb:/.test(w)&&h[j+1]&&!/^a=rtcp-fb:/.test(h[j+1])&&w.match(/^a=rtcp-fb:\d+/)&&_.set(j+1,w.match(/^a=rtcp-fb:\d+/)[0]+" rrtr")});for(var y=be(_),b=0;b<y.length;b++){var f=Te(y[b],2),g=f[0],I=f[1];h.splice(g+b,0,I)}return h.join(`\r
106
- `)}},{key:"addSPSDescription",value:function(d){var h=Fr(d);return h.media.forEach(function(_){_.type===xe&&_.fmtp.forEach(function(y){y.config+=";sps-pps-idr-in-keyframe=1"})}),mo(h)}},{key:"removeSDESDescription",value:function(d){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"],_=Fr(d);return _.media.forEach(function(y){y.ext=y.ext.filter(function(b){return!h.includes(b.uri)})}),mo(_)}},{key:"isSubscriptionStateNotChanged",value:function(d,h){return d.getType()===_t?(h==null?void 0:h.audio)===this.subscribeState_.audio&&(h==null?void 0:h.video)===this.subscribeState_.video&&this.isSubscribeSmall(h):d.getType()===Dt?!ve(h.video)&&this.subscribeState_.auxiliary===h.video:void 0}},{key:"isSubscribeSmall",value:function(d){return ve(d.smallVideo)&&!this.subscribeState_.smallVideo}},{key:"subscribe",value:(s=N(p().mark(function d(h,_){var y,b,f,g,I,w;return p().wrap(function(j){for(;;)switch(j.prev=j.next){case 0:if(j.prev=0,f=_.emitEvent,g=f===void 0||f,I=h.getType(),((y=this.peerConnection_)===null||y===void 0?void 0:y.connectionState)!==qN&&((b=this.peerConnection_)===null||b===void 0?void 0:b.connectionState)!==Zu){j.next=6;break}return j.next=6,this.waitForPeerConnectionConnected();case 6:if(!this.isSubscriptionStateNotChanged(h,_)){j.next=13;break}if(this.peerConnection_){j.next=11;break}return this.initialize(),j.next=11,this.connect();case 11:return g&&ve(_.smallVideo)&&this.emitter_.emit(tt.STREAM_SUBSCRIBED,{stream:h,result:!0}),j.abrupt("return",h);case 13:if(I===Ze?(ve(_.audio)||(this.subscribeState_.audio=_.audio),ve(_.video)||(this.subscribeState_.video=_.video),this.subscribeState_.smallVideo=(_==null?void 0:_.smallVideo)||!1,this.addEventInternal(this.subscribeState_.audio?_T:_m,this.subscribeState_.audio?"subscribe audio":"unsubscribe audio"),this.addEventInternal(this.subscribeState_.video?_T:_m,this.subscribeState_.video?"subscribe video":"unsubscribe video"),this.addEventInternal(this.subscribeState_.smallVideo?l6:d6,this.subscribeState_.smallVideo?"subscribe smallVideo":"unsubscribe smallVideo")):ve(_.video)||(this.subscribeState_.auxiliary=_.video),this.log_.info("subscribe ".concat(I," stream with options ").concat(JSON.stringify(_)," current state: ").concat(JSON.stringify(this.subscribeState_))),!this.peerConnection_&&!this.isSDPExchanging_){j.next=23;break}return w=tf,this.isMainStreamSubscribed||this.isAuxStreamSubscribed||(w=ef),j.next=20,this.sendSubscription(w);case 20:I===Ze?(h.updateAudioPlayingState(this.subscribeState_.audio),h.updateVideoPlayingState(this.subscribeState_.video||this.subscribeState_.smallVideo)):h.updateVideoPlayingState(this.subscribeState_.auxiliary),j.next=26;break;case 23:return this.initialize(),j.next=26,this.connect();case 26:return g&&this.emitter_.emit(tt.STREAM_SUBSCRIBED,{stream:h,result:!0}),j.abrupt("return",h);case 30:if(j.prev=30,j.t0=j.catch(0),!this.client_.getIsJoined()||!this.isStreamUnpublished(h)){j.next=35;break}throw this.log_.warn("".concat(j.t0.message," ").concat(JSON.stringify(this.trackState_))),new ee({code:Y.REMOTE_STREAM_NOT_EXIST,message:"remote user ".concat(this.userId_," unpublished stream")});case 35:throw j.t0;case 36:case"end":return j.stop()}},d,this,[[0,30]])})),function(d,h){return s.apply(this,arguments)})},{key:"unsubscribe",value:(a=N(p().mark(function d(h){var _,y,b;return p().wrap(function(f){for(;;)switch(f.prev=f.next){case 0:if((_=h.getType())!==Ze){f.next=10;break}if(this.isMainStreamSubscribed){f.next=5;break}return this.log_.info("main stream already unsubscribed"),f.abrupt("return",h);case 5:this.subscribeState_.audio=!1,this.subscribeState_.video=!1,this.subscribeState_.smallVideo=!1,f.next=14;break;case 10:if(this.isAuxStreamSubscribed){f.next=13;break}return this.log_.info("auxiliary stream already unsubscribed"),f.abrupt("return",h);case 13:this.subscribeState_.auxiliary=!1;case 14:return y=ef,(_===_t&&this.isAuxStreamSubscribed||_===Dt&&this.isMainStreamSubscribed)&&(y=tf),this.log_.info("unsubscribe ".concat(_," stream with ").concat(JSON.stringify(this.subscribeState_))),f.next=19,this.sendSubscription(y);case 19:return h.updateVideoPlayingState(!1),h.updateAudioPlayingState(!1),y===ef&&((b=h.getMediaStream())&&b.getTracks().forEach(function(g){return b.removeTrack(g)}),this.closePeerConnection(),this.emitConnectionStateChangedEvent(sn)),this.addEventInternal(_m,"unsubscribe audio"),this.addEventInternal(jU,"unsubscribe video"),f.abrupt("return",h);case 25:case"end":return f.stop()}},d,this)})),function(d){return a.apply(this,arguments)})},{key:"sendSubscription",value:function(d){var h=this,_={srcTinyId:this.tinyId_,srcUserId:this.userId_},y=IU,b=vt.UNSUBSCRIBE_RESULT;return d===tf&&(_={audio:this.subscribeState_.audio,bigVideo:this.subscribeState_.video,auxVideo:this.subscribeState_.auxiliary,smallVideo:this.subscribeState_.smallVideo,srcTinyId:this.tinyId_},y=wU,b=vt.SUBSCRIBE_CHANGE_RESULT),this.signalChannel_.sendWaitForResponse({command:y,data:_,responseCommand:b,timeout:1e4}).then(function(f){var g=f.data;if(g.code!==0){var I=new ee({code:g.code,message:ne({key:T3,data:{type:d,message:g.message}})});throw h.log_.error(I),I}})}},{key:"connect",value:(o=N(p().mark(function d(){return p().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()}},d,this,[[0,7]])})),function(){return o.apply(this,arguments)})},{key:"exchangeSDP",value:(i=N(p().mark(function d(){var h,_,y,b,f,g;return p().wrap(function(I){for(;;)switch(I.prev=I.next){case 0:return I.prev=0,this.isSDPExchanging_=!0,I.next=4,this.createOffer();case 4:return this.log_.info("createOffer success, sending offer to remote server"),h=this.peerConnection_.localDescription,_=h.type,y=h.sdp,b={type:_,sdp:y,srcUserId:this.userId_,srcTinyId:this.tinyId_,audio:this.subscribeState_.audio,bigVideo:this.subscribeState_.video,auxVideo:this.subscribeState_.auxiliary,smallVideo:this.subscribeState_.smallVideo},q.emit(cm,{client:this.client_,connection:this,userId:this.userId_,tinyId:this.tinyId_,role:ao,subscribeState:this.subscribeState_,trackState:this.trackState_}),I.next=10,this.signalChannel_.sendWaitForResponse({command:xU,commandDesc:"exchange sdp",data:b,responseCommand:vt.SUBSCRIBE_RESULT,timeout:1e4});case 10:if(f=I.sent,this.peerConnection_){I.next=15;break}throw g=new ee({code:Y.INVALID_OPERATION,message:ne({key:W4})}),this.log_.warn(g),g;case 15:return I.next=17,this.onSubscribeResult(f);case 17:this.isSDPExchanging_=!1,I.next=24;break;case 20:throw I.prev=20,I.t0=I.catch(0),this.isSDPExchanging_=!1,I.t0;case 24:case"end":return I.stop()}},d,this,[[0,20]])})),function(){return i.apply(this,arguments)})},{key:"createOffer",value:(r=N(p().mark(function d(){var h,_;return p().wrap(function(y){for(;;)switch(y.prev=y.next){case 0:return h={voiceActivityDetection:!1},Pm()&&this.sdpSemantics_===$s?(this.peerConnection_.addTransceiver(Ce,{direction:"recvonly"}),this.peerConnection_.addTransceiver(xe,{direction:"recvonly"}),this.peerConnection_.addTransceiver(xe,{direction:"recvonly"})):(h.offerToReceiveAudio=!0,h.offerToReceiveVideo=!0),y.next=4,this.peerConnection_.createOffer(h);case 4:return _=y.sent,y.next=7,DT();case 7:return y.sent.isH264DecodeSupported||(this.log_.warn("remove h264 desc from sdp"),_.sdp=I6(_.sdp)),_.sdp=this.addRRTRLine(_.sdp),_.sdp=this.addSPSDescription(_.sdp),_.sdp=x6(_.sdp),this.sdpSemantics_===$s&&(_.sdp=this.removeSDESDescription(_.sdp)),y.next=16,this.peerConnection_.setLocalDescription(_);case 16:case"end":return y.stop()}},d,this)})),function(){return r.apply(this,arguments)})},{key:"onSubscribeResult",value:(n=N(p().mark(function d(h){var _,y,b,f,g,I,w,j=this;return p().wrap(function(z){for(;;)switch(z.prev=z.next){case 0:if(_=h&&h.data||{},y=_.code,b=_.message,f=b===void 0?"":b,g=h&&h.data&&h.data.data||{},I=g.type,w=g.sdp,y!==77393){z.next=5;break}throw this.log_.error(vi.NOT_SUPPORTED_H264DECODE),new ee({code:Y.NOT_SUPPORTED_H264,message:ne({key:vk})});case 5:if(z.prev=5,y===0){z.next=8;break}throw new ee({code:y,message:ne({key:w3,data:{errMsg:f}})});case 8:return this.log_.debug("accept remote answer: "+w),z.next=11,this.peerConnection_.setRemoteDescription({type:I,sdp:w});case 11:this.sei_&&(this.sei_.handleEncodedStreams(),this.sei_.onSEIMessage=function($){j.emitter_.emit(tt.SEI_MESSAGE,H(H({},$),{},{userId:j.userId_}))}),this.updateSSRC(w),z.next=19;break;case 15:throw z.prev=15,z.t0=z.catch(5),this.log_.error(z.t0),z.t0;case 19:case"end":return z.stop()}},d,this,[[5,15]])})),function(d){return n.apply(this,arguments)})},{key:"updateSSRC",value:function(d){var h=this;try{Fr(d).media.forEach(function(_){if(_.type===Ce){var y=_.ssrcs.find(function(g){return g.value.includes(br)});y&&(h.ssrc_.audio=y.id)}else{var b=_.ssrcs.find(function(g){return g.value.includes(br)}),f=_.ssrcs.find(function(g){return g.value.includes(Qs)});b&&(h.ssrc_.video=b.id),f&&(h.ssrc_.auxiliary=f.id)}})}catch(_){}}},{key:"setRemoteStream",value:function(d,h){this.remoteStreams_.set(d,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(br)}},{key:"getAuxStream",value:function(){return this.remoteStreams_.get(Qs)}},{key:"getMainStreamVideoTrackId",value:function(){var d=this.getMainStream();if(d){var h=d.getVideoTrack();if(h)return h.id}return""}},{key:"getAuxStreamVideoTrackId",value:function(){var d=this.getAuxStream();if(d){var h=d.getVideoTrack();if(h)return h.id}return""}},{key:"reconnect",value:(t=N(p().mark(function d(){var h,_,y=this;return p().wrap(function(b){for(;;)switch(b.prev=b.next){case 0:if(this.reconnectionTimer_===-1){b.next=3;break}return this.log_.warn("reconnect() downlink is reconnecting, ignore current reconnection"),b.abrupt("return");case 3:if(!(this.reconnectionCount_>=30)){b.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 ee({code:Y.DOWNLINK_RECONNECTION_FAILED,message:ne({key:I3})}),Ie.logFailedEvent({userId:this.client_.getUserId(),eventType:Lb,error:h}),this.addEventInternal(u6,"downlink-connection reconnect fail"),this.emitConnectionStateChangedEvent(sn),this.emitter_.emit(tt.ERROR,h),b.abrupt("return");case 12:if(this.signalChannel_.getCurrentState()===cc){b.next=16;break}return this.log_.warn("reconnect() signal channel is not connected, suspend reconnection until signal is connected"),this.signalChannel_.once(sc,this.reconnect,this),b.abrupt("return");case 16:if(this.reconnectionCount_++,this.log_.warn("reconnect() try to reconnect downlink [".concat(this.reconnectionCount_,"/").concat(30,"]")),_=Mf(this.reconnectionCount_),this.reconnectionTimer_=setTimeout(function(){y.log_.warn("reconnect() downlink [".concat(y.userId_,"] reconnect timeout(").concat(_/1e3,"s), try again")),y.clearReconnectionTimer(),y.reconnect()},_),!(this.isSDPExchanging_||this.peerConnection_&&this.peerConnection_.connectionState===Zu)){b.next=22;break}return b.abrupt("return");case 22:return b.prev=22,this.closePeerConnection(),this.initialize(),b.next=27,this.connect();case 27:this.stopReconnection(),this.log_.warn("reconnect() downlink reconnect successfully"),Ie.logSuccessEvent({userId:this.client_.getUserId(),eventType:Lb}),this.addEventInternal(c6,"downlink-connection reconnect success"),this.recoverSubscription(),b.next=36;break;case 34:b.prev=34,b.t0=b.catch(22);case 36:case"end":return b.stop()}},d,this,[[22,34]])})),function(){return t.apply(this,arguments)})},{key:"recoverSubscription",value:function(){var d=this,h=this.client_.getSubscriptionManager();h&&be(this.remoteStreams_.values()).forEach(function(_){h.hasAutoRecoveryFlag(d.userId_,_.getType())&&h.recover(_)})}},{key:"getIsReconnecting",value:function(){return this.isReconnecting_}},{key:"getSubscribedMainStream",value:function(){var d=null;return this.isMainStreamSubscribed&&(d=this.remoteStreams_.get(br)),d}},{key:"clearReconnectionTimer",value:function(){this.reconnectionTimer_!==-1&&(clearTimeout(this.reconnectionTimer_),this.reconnectionTimer_=-1)}},{key:"startReconnection",value:function(){var d=this.client_.getSubscriptionManager();if(d){var h,_=ie(this.remoteStreams_.values());try{for(_.s();!(h=_.n()).done;){var y=h.value,b=y.getType();(b===_t&&(this.trackState_.audio||this.trackState_.video)||b===Dt&&this.trackState_.auxiliary)&&d.setAutoRecoveryFlag(this.userId_,y.getType())}}catch(f){_.e(f)}finally{_.f()}}se($e(u.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}}]),u}(Qv),W(or.prototype,"subscribe",[$I,ZI],Object.getOwnPropertyDescriptor(or.prototype,"subscribe"),or.prototype),W(or.prototype,"unsubscribe",[ew],Object.getOwnPropertyDescriptor(or.prototype,"unsubscribe"),or.prototype),W(or.prototype,"exchangeSDP",[tw],Object.getOwnPropertyDescriptor(or.prototype,"exchangeSDP"),or.prototype),or),pd=function(){function e(){J(this,e),this.startTime=0,this.endTime=0,this.start()}return ye(e,[{key:"start",value:function(){this.startTime===0&&(this.startTime=Pt())}},{key:"stop",value:function(){this.endTime===0&&(this.endTime=Pt())}},{key:"getDuration",value:function(){return this.endTime===0?Pt()-this.startTime:this.endTime-this.startTime}}]),e}(),B7=function(){function e(i){J(this,e),this.client_=i.client,this.intervalId_=-1,this.statsCalculator_=i.stats,this.prevStats_=null,this.renderFreezeMap_=new Map,this.remoteStreamMap_=new Map,this.dataFreezeMap_=new Map,this.monitorFreezeData_=new Map}var t,n,r;return ye(e,[{key:"installEvents",value:function(){q.on(rm,this.handlePlayVideoStart,this),q.on(ic,this.onVideoTrackMuted,this),q.on(em,this.onVideoTrackUnmuted,this),q.on(ia,this.handleStreamStopped,this),q.on(Br,this.handleStreamStopped,this),q.on(rc,this.handleVideoPlaying,this)}},{key:"uninstallEvents",value:function(){q.off(rm,this.handlePlayVideoStart,this),q.off(ic,this.onVideoTrackMuted,this),q.off(em,this.onVideoTrackUnmuted,this),q.off(ia,this.handleStreamStopped,this),q.off(Br,this.handleStreamStopped,this),q.off(rc,this.handleVideoPlaying,this)}},{key:"start",value:function(){var i=this;this.intervalId_===-1&&(this.installEvents(),this.intervalId_=yt.run(N(p().mark(function o(){return p().wrap(function(a){for(;;)switch(a.prev=a.next){case 0:return a.prev=0,a.next=3,i.detectFPS();case 3:a.next=7;break;case 5:a.prev=5,a.t0=a.catch(0);case 7:case"end":return a.stop()}},o,null,[[0,5]])})),{delay:1e3}))}},{key:"stop",value:function(){this.intervalId_!==-1&&(this.uninstallEvents(),yt.clearTask(this.intervalId_),this.intervalId_=-1,this.renderFreezeMap_.clear(),this.dataFreezeMap_.clear(),this.remoteStreamMap_.clear())}},{key:"onVideoTrackMuted",value:function(i){var o=i.stream;if(o.getClient()===this.client_&&o.isRemote()){var a=o.userId_,s=o.type_,c="".concat(a,"_").concat(s),u=this.dataFreezeMap_.get(c),d=new pd;u?u.durationItemList.push(d):this.dataFreezeMap_.set(c,{userId:a,type:s,durationItemList:[d],isFreezing:function(){var h=this.durationItemList[this.durationItemList.length-1];return h&&h.endTime===0}})}}},{key:"onVideoTrackUnmuted",value:function(i){var o=i.stream;if(o.getClient()===this.client_&&o.isRemote()){var a=o.userId_,s=o.type_,c="".concat(a,"_").concat(s);this.stopDataFreeze({key:c,userId:a,type:s})}}},{key:"handleStreamStopped",value:function(i){var o=i.client,a=i.stream;if(o===this.client_){var s=a.getUserId(),c=a.getType(),u="".concat(s,"_").concat(c);this.stopDataFreeze({key:u,userId:s,type:c})}}},{key:"stopDataFreeze",value:function(i){var o=i.key,a=i.userId,s=i.type,c=this.dataFreezeMap_.get(o);if(c&&c.isFreezing()){var u=c.durationItemList[c.durationItemList.length-1];u.stop();var d=u.getDuration();d>500?(Ie.logEvent({eventType:"videoFrozenCount",delta:d}),this.monitorFreezeData_.set(o,{userId:a,type:s,duration:d})):c.durationItemList.pop()}}},{key:"getTotalDuration",value:function(i){return i.reduce(function(o,a){var s=a.getDuration();return o+Math.min(s,5e3)},0)}},{key:"getStats",value:(r=N(p().mark(function i(){var o,a,s,c,u,d,h,_,y,b,f;return p().wrap(function(g){for(;;)switch(g.prev=g.next){case 0:o=this.client_.getConnections(),a={},s=ie(o),g.prev=3,s.s();case 5:if((c=s.n()).done){g.next=20;break}if(u=Te(c.value,2),d=u[0],(h=u[1]).getPeerConnection()){g.next=9;break}return g.abrupt("continue",18);case 9:return _=h.getSubscribeState(),y=h.getTrackState(),g.next=13,this.statsCalculator_.getReceiverStats(h);case 13:b=g.sent,(f={userId:b.userId,tinyId:d,hasVideo:y.video&&_.video,hasAuxiliary:y.auxiliary&&_.auxiliary,video:{framesDecoded:0},auxiliary:{framesDecoded:0}}).hasVideo&&(f.video.framesDecoded=b.video.framesDecoded),f.hasAuxiliary&&(f.auxiliary.framesDecoded=b.auxiliary.framesDecoded),a[b.userId]=f;case 18:g.next=5;break;case 20:g.next=25;break;case 22:g.prev=22,g.t0=g.catch(3),s.e(g.t0);case 25:return g.prev=25,s.f(),g.finish(25);case 28:return g.abrupt("return",a);case 29:case"end":return g.stop()}},i,this,[[3,22,25,28]])})),function(){return r.apply(this,arguments)})},{key:"detectFPS",value:(n=N(p().mark(function i(){var o,a,s,c,u,d;return p().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=p().keys(o);case 7:if((h.t1=h.t0()).done){h.next=17;break}if(a=h.t1.value,this.prevStats_[a]){h.next=11;break}return h.abrupt("continue",7);case 11:s=o[a].tinyId,c=this.client_.getMutedStates(),o[a].hasVideo&&this.prevStats_[a].hasVideo&&c.has(s)&&!c.get(s).videoMuted&&(u=o[a].video.framesDecoded-this.prevStats_[a].video.framesDecoded,this.handleRenderFreeze({userId:a,type:_t,fps:u})),o[a].hasAuxiliary&&this.prevStats_[a].hasAuxiliary&&(d=o[a].auxiliary.framesDecoded-this.prevStats_[a].auxiliary.framesDecoded,this.handleRenderFreeze({userId:a,type:Dt,fps:d})),h.next=7;break;case 17:this.prevStats_=o;case 18:case"end":return h.stop()}},i,this)})),function(){return n.apply(this,arguments)})},{key:"handleRenderFreeze",value:(t=N(p().mark(function i(o){var a,s,c,u,d,h,_,y;return p().wrap(function(b){for(;;)switch(b.prev=b.next){case 0:a=o.userId,s=o.fps,c=o.type,u="".concat(a,"_").concat(c),d=this.renderFreezeMap_.get(u),s<=2?(h=Pt(),d&&!d.isFreeze&&(d.freezeTimeline.push({startTime:h,endTime:void 0}),d.isFreeze=!0),d||this.renderFreezeMap_.set(u,{userId:a,type:c,isFreeze:!0,freezeTimeline:[{startTime:h,endTime:void 0}],renderFreezeTotal:0})):d&&d.isFreeze&&(d.isFreeze=!1,(_=d.freezeTimeline.pop()).endTime=Pt(),y=_.endTime-_.startTime,d.freezeTimeline.push(_),d.renderFreezeTotal+=Math.min(5e3,y));case 4:case"end":return b.stop()}},i,this)})),function(i){return t.apply(this,arguments)})},{key:"handlePlayVideoStart",value:function(i){var o=i.stream;if(o.getClient()===this.client_&&o.isRemote()&&o.hasVideo()){var a="".concat(o.getUserId(),"_").concat(o.getType());this.remoteStreamMap_.has(a)||this.remoteStreamMap_.set(a,{isPlayingFired:!1})}}},{key:"handleVideoPlaying",value:function(i){var o=i.stream;if(o.isRemote()&&o.getClient()===this.client_){var a="".concat(o.getUserId(),"_").concat(o.getType());this.remoteStreamMap_.has(a)&&(this.remoteStreamMap_.get(a).isPlayingFired=!0)}}},{key:"getDataFreezeDuration",value:function(i){var o={dataFreeze:0,count:0},a=this.dataFreezeMap_.get(i);if(a){if(a.isFreezing()){var s=a.durationItemList[a.durationItemList.length-1];s.stop(),s.getDuration()<500&&a.durationItemList.pop()}o.dataFreeze=this.getTotalDuration(a.durationItemList),o.count=a.durationItemList.length}return o}},{key:"getRenderFreezeDuration",value:function(i){var o=this.renderFreezeMap_.get(i),a=0,s=0;if(o)if(o.isFreeze){var c=Pt()-o.freezeTimeline[o.freezeTimeline.length-1].startTime;a=o.renderFreezeTotal+Math.min(c,5e3),s=o.freezeTimeline.length}else a=o.renderFreezeTotal;return{renderFreeze:a,count:s}}},{key:"getMonitorFreeze",value:function(){return this.monitorFreezeData_}},{key:"isBlackStream",value:function(i){return!!this.remoteStreamMap_.has(i)&&!this.remoteStreamMap_.get(i).isPlayingFired}},{key:"resetMonitor",value:function(){this.monitorFreezeData_.clear()}}]),e}(),sg=ye(function e(t){J(this,e),this.userId=t.userId,this.tinyId=t.tinyId,this.role=t.role===ao?Sr:qi}),rw={exports:{}};(function(e){(function(t){function n(g,I){var w=(65535&g)+(65535&I);return(g>>16)+(I>>16)+(w>>16)<<16|65535&w}function r(g,I,w,j,z,$){return n((ue=n(n(I,g),n(j,$)))<<(L=z)|ue>>>32-L,w);var ue,L}function i(g,I,w,j,z,$,ue){return r(I&w|~I&j,g,I,z,$,ue)}function o(g,I,w,j,z,$,ue){return r(I&j|w&~j,g,I,z,$,ue)}function a(g,I,w,j,z,$,ue){return r(I^w^j,g,I,z,$,ue)}function s(g,I,w,j,z,$,ue){return r(w^(I|~j),g,I,z,$,ue)}function c(g,I){var w,j,z,$,ue;g[I>>5]|=128<<I%32,g[14+(I+64>>>9<<4)]=I;var L=1732584193,k=-271733879,P=-1732584194,A=271733878;for(w=0;w<g.length;w+=16)j=L,z=k,$=P,ue=A,L=i(L,k,P,A,g[w],7,-680876936),A=i(A,L,k,P,g[w+1],12,-389564586),P=i(P,A,L,k,g[w+2],17,606105819),k=i(k,P,A,L,g[w+3],22,-1044525330),L=i(L,k,P,A,g[w+4],7,-176418897),A=i(A,L,k,P,g[w+5],12,1200080426),P=i(P,A,L,k,g[w+6],17,-1473231341),k=i(k,P,A,L,g[w+7],22,-45705983),L=i(L,k,P,A,g[w+8],7,1770035416),A=i(A,L,k,P,g[w+9],12,-1958414417),P=i(P,A,L,k,g[w+10],17,-42063),k=i(k,P,A,L,g[w+11],22,-1990404162),L=i(L,k,P,A,g[w+12],7,1804603682),A=i(A,L,k,P,g[w+13],12,-40341101),P=i(P,A,L,k,g[w+14],17,-1502002290),L=o(L,k=i(k,P,A,L,g[w+15],22,1236535329),P,A,g[w+1],5,-165796510),A=o(A,L,k,P,g[w+6],9,-1069501632),P=o(P,A,L,k,g[w+11],14,643717713),k=o(k,P,A,L,g[w],20,-373897302),L=o(L,k,P,A,g[w+5],5,-701558691),A=o(A,L,k,P,g[w+10],9,38016083),P=o(P,A,L,k,g[w+15],14,-660478335),k=o(k,P,A,L,g[w+4],20,-405537848),L=o(L,k,P,A,g[w+9],5,568446438),A=o(A,L,k,P,g[w+14],9,-1019803690),P=o(P,A,L,k,g[w+3],14,-187363961),k=o(k,P,A,L,g[w+8],20,1163531501),L=o(L,k,P,A,g[w+13],5,-1444681467),A=o(A,L,k,P,g[w+2],9,-51403784),P=o(P,A,L,k,g[w+7],14,1735328473),L=a(L,k=o(k,P,A,L,g[w+12],20,-1926607734),P,A,g[w+5],4,-378558),A=a(A,L,k,P,g[w+8],11,-2022574463),P=a(P,A,L,k,g[w+11],16,1839030562),k=a(k,P,A,L,g[w+14],23,-35309556),L=a(L,k,P,A,g[w+1],4,-1530992060),A=a(A,L,k,P,g[w+4],11,1272893353),P=a(P,A,L,k,g[w+7],16,-155497632),k=a(k,P,A,L,g[w+10],23,-1094730640),L=a(L,k,P,A,g[w+13],4,681279174),A=a(A,L,k,P,g[w],11,-358537222),P=a(P,A,L,k,g[w+3],16,-722521979),k=a(k,P,A,L,g[w+6],23,76029189),L=a(L,k,P,A,g[w+9],4,-640364487),A=a(A,L,k,P,g[w+12],11,-421815835),P=a(P,A,L,k,g[w+15],16,530742520),L=s(L,k=a(k,P,A,L,g[w+2],23,-995338651),P,A,g[w],6,-198630844),A=s(A,L,k,P,g[w+7],10,1126891415),P=s(P,A,L,k,g[w+14],15,-1416354905),k=s(k,P,A,L,g[w+5],21,-57434055),L=s(L,k,P,A,g[w+12],6,1700485571),A=s(A,L,k,P,g[w+3],10,-1894986606),P=s(P,A,L,k,g[w+10],15,-1051523),k=s(k,P,A,L,g[w+1],21,-2054922799),L=s(L,k,P,A,g[w+8],6,1873313359),A=s(A,L,k,P,g[w+15],10,-30611744),P=s(P,A,L,k,g[w+6],15,-1560198380),k=s(k,P,A,L,g[w+13],21,1309151649),L=s(L,k,P,A,g[w+4],6,-145523070),A=s(A,L,k,P,g[w+11],10,-1120210379),P=s(P,A,L,k,g[w+2],15,718787259),k=s(k,P,A,L,g[w+9],21,-343485551),L=n(L,j),k=n(k,z),P=n(P,$),A=n(A,ue);return[L,k,P,A]}function u(g){var I,w="",j=32*g.length;for(I=0;I<j;I+=8)w+=String.fromCharCode(g[I>>5]>>>I%32&255);return w}function d(g){var I,w=[];for(w[(g.length>>2)-1]=void 0,I=0;I<w.length;I+=1)w[I]=0;var j=8*g.length;for(I=0;I<j;I+=8)w[I>>5]|=(255&g.charCodeAt(I/8))<<I%32;return w}function h(g){var I,w,j="0123456789abcdef",z="";for(w=0;w<g.length;w+=1)I=g.charCodeAt(w),z+=j.charAt(I>>>4&15)+j.charAt(15&I);return z}function _(g){return unescape(encodeURIComponent(g))}function y(g){return function(I){return u(c(d(I),8*I.length))}(_(g))}function b(g,I){return function(w,j){var z,$,ue=d(w),L=[],k=[];for(L[15]=k[15]=void 0,ue.length>16&&(ue=c(ue,8*w.length)),z=0;z<16;z+=1)L[z]=909522486^ue[z],k[z]=1549556828^ue[z];return $=c(L.concat(d(j)),512+8*j.length),u(c(k.concat($),640))}(_(g),_(I))}function f(g,I,w){return I?w?b(I,g):h(b(I,g)):w?y(g):h(y(g))}e.exports?e.exports=f:t.md5=f})(ae)})(rw);var fd=rw.exports,j7=function(){function e(o){J(this,e),this.client_=o.client,this.signalChannel_=o.signalChannel,this.log_=ke.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,r,i;return ye(e,[{key:"isPresetLayoutMode",get:function(){return this.config_&&this.config_.mode===rf.PRESET_LAYOUT}},{key:"installEvents",value:function(){q.on(Ur,this.onStreamSubscribed,this),q.on(Br,this.onStreamUnsubscribed,this),this.client_.on("stream-removed",this.onStreamRemoved,this)}},{key:"uninstallEvents",value:function(){q.off(Ur,this.onStreamSubscribed,this),q.off(Br,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 a=o.client,s=o.stream;a===this.client_&&(this.remoteStreamMap_.set(s.getId(),{remoteStream:s,isUsed:!1}),this.isMixing_&&this.hasAvailablePlaceHolder()&&this.startMixTranscode(this.config_))}},{key:"onStreamUnsubscribed",value:function(o){var a=o.client,s=o.stream;a===this.client_&&this.onStreamRemoved({stream:s})}},{key:"onStreamRemoved",value:function(o){var a=o.stream;if(this.remoteStreamMap_.has(a.getId())){var s=this.remoteStreamMap_.get(a.getId()).isUsed;this.remoteStreamMap_.delete(a.getId()),this.isMixing_&&this.isPresetLayoutMode&&s&&this.startMixTranscode(this.config_)}}},{key:"startMixTranscode",value:(i=N(p().mark(function o(a){var s,c,u;return p().wrap(function(d){for(;;)switch(d.prev=d.next){case 0:if(d.prev=0,this.resetIsUsedFlag(),this.config_=a,s=this.getInputParam(a,this.remoteStreamMap_),c=this.getOutputParam(a),u=this.getOutputSessionId({config:a,roomId:this.client_.getRoomId(),userId:this.client_.getUserId()}),!this.isMixing_||!this.data_||u===this.data_.outputSessionId){d.next=10;break}return this.log_.info("startMixTranscode() streamId changed, stop mixing before start"),d.next=10,this.doStopMixTranscode();case 10:return d.next=12,this.doStartMixTranscode({outputSessionId:u,inputParam:s,outputParam:c});case 12:d.next=18;break;case 14:throw d.prev=14,d.t0=d.catch(0),this.resetIsUsedFlag(),d.t0;case 18:case"end":return d.stop()}},o,this,[[0,14]])})),function(o){return i.apply(this,arguments)})},{key:"doStartMixTranscode",value:(r=N(p().mark(function o(a){var s,c,u,d,h,_,y,b;return p().wrap(function(f){for(;;)switch(f.prev=f.next){case 0:return s=a.outputSessionId,c=a.inputParam,u=a.outputParam,d={roomId:String(this.client_.getRoomId()),mcuRequestTime:Date.now(),outputSessionId:s,inputParam:c,outputParam:u},this.data_=d,this.log_.info("startMixTranscode: ".concat(JSON.stringify(d))),this.isMixing_=!0,f.prev=5,f.next=8,this.signalChannel_.sendWaitForResponse({command:PU,data:d,timeout:5e3,responseCommand:vt.START_MIX_TRANSCODE_RES,commandDesc:"startMixTranscode"});case 8:if(h=f.sent,_=h.data,y=_.code,b=_.message,y===0){f.next=15;break}throw y===-102083&&(b="Please enable relayed-push in ".concat($b," and try later, refer to ").concat(uf,"tutorial-26-advanced-publish-cdn-stream.html")),this.log_.error("startMixTranscode failed, errCode: ".concat(y," errMsg: ").concat(b)),this.isMixing_=!1,new ee({code:Y.START_MIX_TRANSCODE_FAILED,message:ne({key:b4,data:{message:b},link:{className:"Client",fnName:"startMixTranscode"}})});case 15:f.next=21;break;case 17:throw f.prev=17,f.t0=f.catch(5),this.isMixing_=!1,f.t0;case 21:case"end":return f.stop()}},o,this,[[5,17]])})),function(o){return r.apply(this,arguments)})},{key:"reStartMixTranscode",value:function(){this.isMixing_&&this.startMixTranscode(this.config_)}},{key:"stopMixTranscode",value:(n=N(p().mark(function o(){return p().wrap(function(a){for(;;)switch(a.prev=a.next){case 0:if(this.isMixing_){a.next=2;break}throw new ee({code:Y.INVALID_OPERATION,message:ne({key:T4})});case 2:return a.next=4,this.doStopMixTranscode();case 4:this.resetIsUsedFlag();case 5:case"end":return a.stop()}},o,this)})),function(){return n.apply(this,arguments)})},{key:"doStopMixTranscode",value:(t=N(p().mark(function o(){var a,s,c,u,d;return p().wrap(function(h){for(;;)switch(h.prev=h.next){case 0:return a={mcuRequestTime:Date.now(),outputSessionId:this.data_.outputSessionId,streamType:this.data_.outputParam.streamType},this.log_.info("stopMixTranscode: ".concat(JSON.stringify(a))),h.next=4,this.signalChannel_.sendWaitForResponse({command:DU,data:a,timeout:5e3,responseCommand:vt.STOP_MIX_TRANSCODE_RES,commandDesc:"stopMixTranscode"});case 4:if(s=h.sent,c=s.data,u=c.code,d=c.message,u!==0){h.next=10;break}this.isMixing_=!1,h.next=12;break;case 10:throw this.log_.error("stopMixTranscode failed, errCode: ".concat(u," errMsg: ").concat(d)),new ee({code:Y.STOP_MIX_TRANSCODE_FAILED,message:ne({key:k4,data:{message:d},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 a=o.config,s=o.userId,c=o.roomId;return Ft(a.streamId)&&a.streamId.length>0?a.streamId:fd("".concat(c,"_").concat(s,"_main"))}},{key:"getInputParam",value:function(o,a){var s=this,c=o.mixUsers.map(function(u){return{userId:u.userId,roomId:String(u.roomId||s.client_.getRoomId()),width:u.width||0,height:u.height||0,locationX:u.locationX||0,locationY:u.locationY||0,zOrder:u.zOrder,streamType:ve(u.streamType)||u.streamType!==Dt?0:1,inputType:u.pureAudio?zb.IT_PURE_AUDIO:zb.IT_AUDIO_VIDEO,renderMode:u.renderMode||0}});return o.mode===rf.PRESET_LAYOUT&&(c.forEach(function(u){if(u.userId===Hb.REMOTE){var d=be(a.values()).find(function(h){return!h.isUsed});d&&(u.userId=d.remoteStream.getUserId(),u.streamType=d.remoteStream.getType()===Dt?1:0,d.isUsed=!0)}}),c=c.filter(function(u){return u.userId!==Hb.REMOTE})),c}},{key:"getOutputParam",value:function(o){var a=o.streamId||"";return{streamId:a,streamType:a.length>0?1:0,width:ve(o.videoWidth)?640:o.videoWidth,height:ve(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}(),F7=function(){function e(s){J(this,e),this.client_=s.client,this.signalChannel_=s.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,r,i,o,a;return ye(e,[{key:"setSignalChannel",value:function(s){this.signalChannel_=s.signalChannel}},{key:"getIsPublishingTencentCDN",value:function(){return this.publishTencentMainStreamObj_.isPublishing_||this.publishTencentAuxStreamObj_.isPublishing_}},{key:"getIsPublishingGivenCDN",value:function(){return this.isPublishingGivenCDN_}},{key:"generatePublishCDNStreamId",value:function(s,c){if(!s){var u="".concat(this.client_.getRoomId(),"_").concat(this.client_.getUserId(),"_").concat(c);return/^[A-Za-z\d_-]*$/.test(u)||(u=fd(u)),"".concat(this.client_.getSDKAppId(),"_").concat(u)}return s}},{key:"generatePublishCDNSessionId",value:function(s){return fd("".concat(this.client_.getRoomId(),"_").concat(this.client_.getUserId(),"_").concat(s))}},{key:"startPublishTencentCDN",value:(a=N(p().mark(function s(c){var u,d,h,_;return p().wrap(function(y){for(;;)switch(y.prev=y.next){case 0:if(c.streamType===Vn?(this.publishTencentAuxStreamObj_.params_=c,this.publishTencentAuxStreamObj_.isPublishing_=!0):(this.publishTencentMainStreamObj_.params_=c,this.publishTencentMainStreamObj_.isPublishing_=!0),this.client_.isJoined_){y.next=3;break}return y.abrupt("return");case 3:return u=this.generatePublishCDNStreamId(c.streamId,c.streamType),d=this.generatePublishCDNSessionId(c.streamType),h=c.streamType===Vn?1:0,_={requestTime:Date.now(),sessionId:d,streamId:u,streamType:h},y.next=9,this.doStartPublishTencentCDN(_,c.streamType);case 9:case"end":return y.stop()}},s,this)})),function(s){return a.apply(this,arguments)})},{key:"doStartPublishTencentCDN",value:(o=N(p().mark(function s(c,u){var d,h,_,y;return p().wrap(function(b){for(;;)switch(b.prev=b.next){case 0:return b.prev=0,ke.info("startPublishTencentCDN: "+JSON.stringify(c)),b.next=4,this.signalChannel_.sendWaitForResponseWithRetry({command:EU,data:c,timeout:2e3,responseCommand:vt.START_PUBLISH_TENCENT_CDN_RES,commandDesc:"startPublishCDNStream",retries:2});case 4:if(d=b.sent,h=d.data,_=h.code,y=h.message,_!==0){b.next=10;break}u===Vn?this.publishTencentAuxStreamObj_.streamId_=c.streamId:this.publishTencentMainStreamObj_.streamId_=c.streamId,b.next=14;break;case 10:throw u===Vn?this.publishTencentAuxStreamObj_.isPublishing_=!1:this.publishTencentMainStreamObj_.isPublishing_=!1,_===-102083&&(y="Please enable relayed-push in ".concat($b," and try later, refer to ").concat(uf,"tutorial-26-advanced-publish-cdn-stream.html")),ke.error("startPublishTencentCDN failed, errCode: ".concat(_,", errMsg: ").concat(y)),new ee({code:Y.START_PUBLISH_CDN_FAILED,message:ne({key:uk,data:{message:y},link:{className:"Client",fnName:"startPublishCDNStream"}})});case 14:b.next=20;break;case 16:throw b.prev=16,b.t0=b.catch(0),u===Vn?this.publishTencentAuxStreamObj_.isPublishing_=!1:this.publishTencentMainStreamObj_.isPublishing_=!1,b.t0;case 20:case"end":return b.stop()}},s,this,[[0,16]])})),function(s,c){return o.apply(this,arguments)})},{key:"resetPublishTencentParam",value:function(s){s===Ze&&(this.publishTencentMainStreamObj_={params_:null,streamId_:void 0,isPublishing_:!1}),s===Vn&&(this.publishTencentAuxStreamObj_={params_:null,streamId_:void 0,isPublishing_:!1})}},{key:"stopPublishTencentCDN",value:(i=N(p().mark(function s(){return p().wrap(function(c){for(;;)switch(c.prev=c.next){case 0:if(this.client_.isJoined_){c.next=4;break}return this.resetPublishTencentParam(Ze),this.resetPublishTencentParam(Vn),c.abrupt("return");case 4:if(!this.publishTencentMainStreamObj_.isPublishing_){c.next=7;break}return c.next=7,this.doStopPublishTencentCDN(Ze);case 7:if(!this.publishTencentAuxStreamObj_.isPublishing_){c.next=10;break}return c.next=10,this.doStopPublishTencentCDN(Vn);case 10:case"end":return c.stop()}},s,this)})),function(){return i.apply(this,arguments)})},{key:"doStopPublishTencentCDN",value:(r=N(p().mark(function s(c){var u,d,h,_,y;return p().wrap(function(b){for(;;)switch(b.prev=b.next){case 0:return u={requestTime:Date.now(),sessionId:fd("".concat(this.client_.getRoomId(),"_").concat(this.client_.getUserId(),"_").concat(c))},ke.info("stopPublishTencentCDN: "+JSON.stringify(u)),b.next=4,this.signalChannel_.sendWaitForResponse({command:CU,data:u,timeout:5e3,responseCommand:vt.STOP_PUBLISH_TENCENT_CDN_RES,commandDesc:"stopPublishCDNStream"});case 4:if(d=b.sent,h=d.data,_=h.code,y=h.message,_!==0){b.next=10;break}this.resetPublishTencentParam(c),b.next=17;break;case 10:if(_!==-102069){b.next=15;break}ke.warn("stopPublishTencentCDN failed, can not stopPublishTencentCDN in auto relayed-push mode"),this.resetPublishTencentParam(c),b.next=17;break;case 15:throw ke.error("stopPublishTencentCDN failed, errCode: ".concat(_," errMsg: ").concat(y)),new ee({code:Y.STOP_PUBLISH_CDN_FAILED,message:ne({key:lk,data:{message:y},link:{className:"Client",fnName:"stopPublishCDNStream"}})});case 17:case"end":return b.stop()}},s,this)})),function(s){return r.apply(this,arguments)})},{key:"startPublishGivenCDN",value:(n=N(p().mark(function s(c){var u,d,h,_,y,b;return p().wrap(function(f){for(;;)switch(f.prev=f.next){case 0:if(u=c.streamType===Ze?this.publishTencentMainStreamObj_.streamId_:this.publishTencentAuxStreamObj_.streamId_,d={pushRequestTime:Date.now(),pushAppId:c.appId,pushBizId:c.bizId,pushCdnUrl:c.url,pushStreamType:c.streamType,pushStreamId:u},ke.info("startPublishGivenCDN: "+JSON.stringify(d)),this.publishGivenCDNData_=d,this.isPublishingGivenCDN_=!0,this.client_.isJoined_){f.next=7;break}return f.abrupt("return");case 7:return f.prev=7,f.next=10,this.signalChannel_.sendWaitForResponse({command:RU,data:d,timeout:5e3,responseCommand:vt.START_PUBLISH_GIVEN_CDN_RES,commandDesc:"startPublishCDNStream"});case 10:if(h=f.sent,_=h.data,y=_.code,b=_.message,y===0){f.next=17;break}throw ke.error("startPublishGivenCDN failed, errCode: ".concat(y,", errMsg: ").concat(b)),this.publishGivenCDNData_=null,this.isPublishingGivenCDN_=!1,new ee({code:Y.START_PUBLISH_CDN_FAILED,message:ne({key:uk,data:{message:b},link:{className:"Client",fnName:"startPublishCDNStream"}})});case 17:f.next=24;break;case 19:throw f.prev=19,f.t0=f.catch(7),this.publishGivenCDNData_=null,this.isPublishingGivenCDN_=!1,f.t0;case 24:case"end":return f.stop()}},s,this,[[7,19]])})),function(s){return n.apply(this,arguments)})},{key:"stopPublishGivenCDN",value:(t=N(p().mark(function s(){var c,u,d,h,_,y,b,f,g,I;return p().wrap(function(w){for(;;)switch(w.prev=w.next){case 0:if(this.client_.isJoined_){w.next=4;break}return this.publishGivenCDNData_=null,this.isPublishingGivenCDN_=!1,w.abrupt("return");case 4:return c=this.publishGivenCDNData_,u=c.pushAppId,d=c.pushBizId,h=c.pushCdnUrl,_=c.pushStreamType,y={pushRequestTime:Date.now(),pushAppId:u,pushBizId:d,pushCdnUrl:h,pushStreamType:_},ke.info("stopPublishGivenCDN: "+JSON.stringify(y)),w.next=9,this.signalChannel_.sendWaitForResponse({command:AU,data:y,timeout:5e3,responseCommand:vt.STOP_PUBLISH_GIVEN_CDN_RES,commandDesc:"stopPublishCDNStream"});case 9:if(b=w.sent,f=b.data,g=f.code,I=f.message,g!==0){w.next=16;break}this.publishGivenCDNData_=null,this.isPublishingGivenCDN_=!1,w.next=18;break;case 16:throw ke.error("stopPublishGivenCDN failed, errCode: ".concat(g," errMsg: ").concat(I)),new ee({code:Y.STOP_PUBLISH_CDN_FAILED,message:ne({key:lk,data:{message:I},link:{className:"Client",fnName:"stopPublishCDNStream"}})});case 18:case"end":return w.stop()}},s,this)})),function(){return t.apply(this,arguments)})},{key:"handleCDNConfigForJoinData",value:function(s){var c,u=s;if(this.publishTencentMainStreamObj_.isPublishing_||this.publishTencentAuxStreamObj_.isPublishing_){var d={};Ft(u)&&(d=JSON.parse(u)),d.Str_uc_params||(d.Str_uc_params={}),this.publishTencentMainStreamObj_.isPublishing_&&(this.publishTencentMainStreamObj_.streamId_?d.Str_uc_params.userdefine_streamid_main=this.publishTencentMainStreamObj_.streamId_:this.publishTencentMainStreamObj_.params_&&(d.Str_uc_params.userdefine_streamid_main=this.generatePublishCDNStreamId(this.publishTencentMainStreamObj_.params_.streamId,Ze))),this.publishTencentAuxStreamObj_.isPublishing_&&(this.publishTencentAuxStreamObj_.streamId_?d.Str_uc_params.userdefine_streamid_aux=this.publishTencentAuxStreamObj_.streamId_:this.publishTencentAuxStreamObj_.params_&&(d.Str_uc_params.userdefine_streamid_aux=this.generatePublishCDNStreamId(this.publishTencentAuxStreamObj_.params_.streamId,Vn))),u=JSON.stringify(d)}if(this.isPublishingGivenCDN_){var h=this.publishGivenCDNData_,_=h.pushAppId,y=h.pushBizId,b=h.pushCdnUrl,f=h.pushStreamType,g=h.pushStreamId;c={pushRequestTime:Date.now(),pushAppId:_,pushBizId:y,pushCdnUrl:b,pushStreamType:f,pushStreamId:g}}return{bussinessInfo:u,pushUserCdnInfo:c}}},{key:"reset",value:function(){this.resetPublishTencentParam(Ze),this.resetPublishTencentParam(Vn),this.publishGivenCDNData_=null,this.isPublishingGivenCDN_=!1}}]),e}(),G7=function(){function e(t){J(this,e),this.client_=t.client,this.durationMap_=new Map,this.installEvents()}return ye(e,[{key:"installEvents",value:function(){q.on(Ur,this.handleSubscribed,this),q.on(Bn,this.handleStreamTrackUpdated,this),q.on(Br,this.handleStreamStopped,this),q.on(ia,this.handleStreamStopped,this)}},{key:"uninstallEvents",value:function(){q.off(Ur,this.handleSubscribed,this),q.off(Bn,this.handleStreamTrackUpdated,this),q.off(Br,this.handleStreamStopped,this),q.off(ia,this.handleStreamStopped,this)}},{key:"handleSubscribed",value:function(t){var n=t.client,r=t.stream;if(n===this.client_){var i=r.getUserId(),o=r.getType(),a="".concat(i,"_").concat(o);if(r.hasAudio())if(r.isMainAudioSubscribed){var s=new pd,c=this.durationMap_.get(a);c?this.isRecording(c.audio)||c.audio.push(s):this.durationMap_.set(a,{userId:i,type:o,audio:[s],video:[]})}else this.stopDurationItem(a,Ce);if(r.hasVideo())if(o===_t&&r.isMainVideoSubscribed||o===Dt&&r.isAuxVideoSubscribed){var u=new pd,d=this.durationMap_.get(a);d?this.isRecording(d.video)||d.video.push(u):this.durationMap_.set(a,{userId:i,type:o,audio:[],video:[u]})}else this.stopDurationItem(a,xe)}}},{key:"handleStreamStopped",value:function(t){var n=t.client,r=t.stream;if(this.clientHitTest(n)){var i=r.getUserId(),o=r.getType(),a="".concat(i,"_").concat(o);this.stopDurationItem(a,Ce),this.stopDurationItem(a,xe)}}},{key:"handleStreamTrackUpdated",value:function(t){var n=t.client,r=t.userId,i=t.tinyId,o=t.kind,a=t.action;if(this.clientHitTest(n)&&this.client_.getConnections().has(i)){var s=o===mt?o:_t,c="".concat(r,"_").concat(s);if(a===un.ADD){var u=this.client_.getConnections().get(i).getSubscribeState();if(o===Ce&&!u.audio||o===xe&&!u.video||o===mt&&!u.auxiliary)return;var d=new pd,h=this.durationMap_.get(c);h?(o!==Ce||this.isRecording(h.audio)||h.audio.push(d),o===Ce||this.isRecording(h.video)||h.video.push(d)):this.durationMap_.set(c,{userId:r,type:s,audio:o===Ce?[d]:[],video:o===Ce?[]:[d]})}else this.stopDurationItem(c,o===Ce?Ce:xe)}}},{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 r=this.durationMap_.get(t)[n].find(function(i){return i.endTime===0});r&&r.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(r,i){return r+i.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 Cc(){return function(e,t,n){var r=n.value,i=new Set;return n.value=N(p().mark(function o(){var a,s,c,u,d=arguments;return p().wrap(function(h){for(;;)switch(h.prev=h.next){case 0:if(!i.has(this)){h.next=2;break}throw new ee({code:Y.INVALID_OPERATION,message:ne({key:v3,data:{name:t}})});case 2:for(h.prev=2,i.add(this),a=d.length,s=new Array(a),c=0;c<a;c++)s[c]=d[c];return h.next=7,r.apply(this,s);case 7:return u=h.sent,i.delete(this),h.abrupt("return",u);case 12:throw h.prev=12,h.t0=h.catch(2),i.delete(this),h.t0;case 16:case"end":return h.stop()}},o,this,[[2,12]])})),n}}function H7(e){return cg.apply(this,arguments)}function cg(){return cg=N(p().mark(function e(t){var n,r,i,o,a,s,c,u,d,h,_,y,b;return p().wrap(function(f){for(;;)switch(f.prev=f.next){case 0:return n=t.userId,r=t.sdkAppId,i=t.useStringRoomId,o=t.roomId,a=t.userSig,s={delta:0,count:[1,1],msg:[]},f.prev=2,(c=new FormData).append("userId",String(n)),c.append("sdkAppId",String(r)),c.append("isStrGroupId",i),c.append("groupId",String(o)),c.append("sdkVersion",Vi),c.append("userSig",String(a)),of&&c.append("oversea",!0),u=Pt(),f.next=14,W7(c,s,r);case 14:return(d=f.sent).config&&d.config.loggerDomain&&Xp(d.config.loggerDomain),s.delta=Pt()-u,iw({stat:s,userId:n}),f.abrupt("return",d);case 21:throw f.prev=21,f.t0=f.catch(2),h=ml(f.t0)?f.t0[0]:f.t0,_=xr(h.code)?h.code:0,y="get websocket url failed: ".concat(h.message.includes("timeout")?"timeout":h.message),b=new ee({code:Y.SCHEDULE_FAILED,extraCode:_,message:ne({key:sk,data:{error:y,code:_}})}),ke.error(b),iw({stat:s,userId:n,roomId:o,error:b}),b;case 30:case"end":return f.stop()}},e,null,[[2,21]])})),cg.apply(this,arguments)}function iw(e){var t=e.stat,n=e.userId,r=e.error;r?Ie.logFailedEvent({eventType:Gb,error:r,userId:n}):Ie.logSuccessEvent({eventType:Gb,delta:t.delta,userId:n}),Ie.uploadEvent({log:"stat-schedule:"+JSON.stringify(t),userId:n})}function aw(e){var t,n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:Ze;return t=of||(Lk(e)?n===Ze?a3:o3:n===Ze?r3:i3),"https://".concat(t,"/api/v1/config")}function z7(e,t,n){return new Promise(function(r,i){vl({url:e,body:t,timeout:n.timeout}).then(function(o){o.data.code===0?r(o.data.data):i({code:o.data.code,message:o.data.msg})}).catch(i)})}var ow=function(e,t){return oc({retryFunction:z7,settings:{retries:3,timeout:0},onError:t,onRetrying:e})};function W7(e,t,n){return new Promise(function(r,i){var o,a=null;(o=[ow(function(s){return t.count[0]=s+1},function(s,c){t.msg[0]=s.message,a||c()})(aw(n,Ze),e,{get timeout(){return 1e3*fl(2+t.count[0])}}),ow(function(s){return t.count[1]=s+1},function(s,c){t.msg[1]=s.message,a||c()})(aw(n,Ki),e,{get timeout(){return 1e3*fl(2+t.count[1])}})],new Promise(function(s,c){var u=[];o.forEach(function(d){d.then(s).catch(function(h){u.push(h),u.length===o.length&&c(u)})})})).then(function(s){r(a=s)}).catch(i)})}var sw,cw,uw,lw,dw,hw,pw,fw,mw,vw,gw,_w,yw,Sw,bw,kw,Tw,xw,Iw,ww,Ew,Cw,Rw,Aw,Pw,Dw,Lw,Ow,Mw,Nw,Ae,J7=function(){function e(){J(this,e)}return ye(e,[{key:"call",value:function(t,n){return In(this[t])?this[t](n):Promise.reject(new ee({code:Y.INVALID_PARAMETER,message:ne({key:z4,data:{name:t}})}))}},{key:"updatePrivateMapKey",value:function(t){var n=t.privateMapKey;return t.client.setProperty("privateMapKey",n),Promise.resolve()}}]),e}(),K7=new J7,md,vd,gd,ug,Vw,Uw,Bw,jw,Fw,Gw,$t,q7=(sw=Cc(),cw=wn(Yt.CLIENT.join),uw=Cc(),lw=xc({retries:3}),dw=Cc(),hw=wn.apply(void 0,be(Yt.CLIENT.publish)),pw=kt(ln),fw=Cc(),mw=wn(Yt.CLIENT.unpublish),vw=wn.apply(void 0,be(Yt.CLIENT.subscribe)),gw=wn(Yt.CLIENT.unsubscribe),_w=Cc(),yw=wn(Yt.CLIENT.switchRole),Sw=kt(ln),bw=wn(Yt.CLIENT.startPublishCDNStream),kw=kt(ln),Tw=kt(ln),xw=wn(Yt.CLIENT.startMixTranscode),Iw=kt(ln),ww=kt(ln),Ew=kt(ln),Cw=kt(ln),Rw=kt(ln),Aw=kt(ln),Pw=kt(ln),Dw=nd.apply(void 0,be(Yt.CLIENT.sendSEIMessage)),Lw=kt(ln),md={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}},vd=md.timesInSecond,gd=md.maxSizeInSecond,ug=md.getSize,Ow=function(e,t,n){var r=n.value,i=new Map;return q.on(Kf,function(o){var a=o.client;return i.delete(a)}),n.value=function(){var o=i.get(this);o||(o={callCountInSecond:0,timestamp:0,totalSizeInSecond:0},i.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 a=arguments.length,s=new Array(a),c=0;c<a;c++)s[c]=arguments[c];if(ug&&(o.totalSizeInSecond+=ug.apply(void 0,s)),o.timestamp!==0&&Date.now()-o.timestamp<1e3&&(o.callCountInSecond>=vd||o.totalSizeInSecond>gd))throw new ee({code:Y.INVALID_OPERATION,message:ne({key:$4,data:{isTimes:o.callCountInSecond>=vd,isSize:o.totalSizeInSecond>gd,name:t,timesInSecond:vd,maxSizeInSecond:gd}})});return o.callCountInSecond++,r.apply(this,s)},n},Mw=kt(ln),Nw=kt(ln),Ae=function(){function e(T){var v,E;J(this,e),this.name_=ln,this.mode_=T.mode,this.sdpSemantics_=nf,ve(T.sdpSemantics)?function(){var C;if(ve(window.RTCRtpTransceiver)||!("currentDirection"in RTCRtpTransceiver.prototype))return!1;var O=null,F=!1;try{(O=new RTCPeerConnection({sdpSemantics:$s})).addTransceiver(Ce),F=!0}catch(K){}return(C=O)===null||C===void 0||C.close(),F}()&&(this.sdpSemantics_=$s):this.sdpSemantics_=T.sdpSemantics,this.sdkAppId_=T.sdkAppId,this.userId_=T.userId,this.log_=ke.createLogger({id:"c".concat(T.seq,"|").concat(this.userId_),userId:this.userId_,sdkAppId:this.sdkAppId_}),this.userSig_=T.userSig,this.roomId_=0,this.useStringRoomId_=T.useStringRoomId||!1,this.pureAudioPushMode_=null,this.version_=T.version,this.log_.info("using sdpSemantics: "+this.sdpSemantics_),this.signalChannel_=null,this.role_=Sr,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_=jk(new _i,this.name_),this.isJoined_=!1,this.heartbeat_=-1,this.lastHeartBeatTime_=-1,this.stats_=new K6(this),this.joinTimeout_=-1,this.changeBigSmallRecords_=new Map,this.networkQuality_=null,this.badCaseDetector_=null,this.networkType_=Of(),this.autoSubscribe_=!!ve(T.autoSubscribe)||T.autoSubscribe,this.joinedTimestamp_=0,this.joinOptions_={},this.basis_=(E={browser:ta().name+"/"+ta().version,os:Mm(),displayResolution:U6(),isScreenShareSupported:OT(),isWebRTCSupported:Cm(),isGetUserMediaSupported:B6(),isWebAudioSupported:j6(),isWebSocketsSupported:"WebSocket"in window&&window.WebSocket.CLOSING===2,isWebCodecSupported:(v={AudioDecoder:!1,AudioEncoder:!1,VideoDecoder:!1,VideoEncoder:!1,ImageDecoder:!1},ve(window.AudioDecoder)||(v.AudioDecoder=!0),ve(window.AudioEncoder)||(v.AudioEncoder=!0),ve(window.VideoDecoder)||(v.VideoDecoder=!0),ve(window.VideoEncoder)||(v.VideoEncoder=!0),ve(window.ImageDecoder)||(v.ImageDecoder=!0),v),isMediaSessionSupported:"mediaSession"in navigator&&!ve(navigator.mediaSession.setActionHandler),isWebTransportSupported:!ve(window.WebTransport)},navigator.userAgent.includes("miniProgram")&&(E.browser="mini/".concat(E.browser)),E),this.initBussinessInfo_(T),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 F7({client:this}),this.keyPointManager_=new o7({client:this,frameWorkType:T.frameWorkType,component:T.component}),this.isPublishing_=!1,this.isEnableSmallStream_=!1,this.smallStreamConfig_={bitrate:100,frameRate:15,height:120,width:160},this.turnServers_=[],this.iceTransportPolicy_=T.iceTransportPolicy,this.schedule_={domains:null,iceServers:null,iceTransportPolicy:null,trtcCapability:null},this.enableAutoPlayDialog_=!!ve(T.enableAutoPlayDialog)||T.enableAutoPlayDialog,this.enableMultiAuxStream_=!ve(T.enableMultiAuxStream)&&T.enableMultiAuxStream,this.signalInfo_={},this.enableSEI_=!ve(T.enableSEI)&&T.enableSEI,this.isDestroyed_=!1}var t,n,r,i,o,a,s,c,u,d,h,_,y,b,f,g,I,w,j,z,$,ue,L,k,P,A,U;return ye(e,[{key:"initBussinessInfo_",value:function(T){this.bussinessInfo_=T.bussinessInfo;var v={};if(Ft(T.bussinessInfo)&&(v=JSON.parse(T.bussinessInfo)),!ve(T.pureAudioPushMode)){if(!Number.isInteger(Number(T.pureAudioPushMode)))throw new ee({code:Y.INVALID_PARAMETER,message:ne({key:C3})});this.pureAudioPushMode_=T.pureAudioPushMode,v.Str_uc_params||(v.Str_uc_params={}),v.Str_uc_params.pure_audio_push_mod=this.pureAudioPushMode_}if(!ve(T.streamId)){if(!(Ft(T.streamId)&&String(T.streamId)&&String(T.streamId).length<=64))throw new ee({code:Y.INVALID_PARAMETER,message:ne({key:R3})});v.Str_uc_params||(v.Str_uc_params={}),v.Str_uc_params.userdefine_streamid_main=T.streamId}if(!ve(T.userDefineRecordId)){if(T.userDefineRecordId.match(/^[A-Za-z0-9_-]{1,64}$/gi)===null)throw new ee({code:Y.INVALID_PARAMETER,message:ne({key:A3})});v.Str_uc_params||(v.Str_uc_params={}),v.Str_uc_params.userdefine_record_id=T.userDefineRecordId}if(!ve(T.userDefinePushArgs)){if(!(Ft(T.userDefinePushArgs)&&String(T.userDefinePushArgs)&&String(T.userDefinePushArgs).length<=256))throw new ee({code:Y.INVALID_PARAMETER,message:ne({key:P3})});v.Str_uc_params||(v.Str_uc_params={}),v.Str_uc_params.userdefine_push_args=T.userDefinePushArgs}aa(v)||(this.bussinessInfo_=JSON.stringify(v))}},{key:"schedule",value:(U=N(p().mark(function T(v){var E;return p().wrap(function(C){for(;;)switch(C.prev=C.next){case 0:return C.next=2,H7({userId:this.userId_,sdkAppId:this.sdkAppId_,roomId:v,useStringRoomId:this.useStringRoomId_,version:this.version_,userSig:this.userSig_});case 2:(E=C.sent)&&(this.log_.info("schedule: ".concat(JSON.stringify(E))),E.trtcCapability=E==null?void 0:E.trtcAutoConf,this.schedule_=H(H({},this.schedule_),E),q.emit(zk,this.schedule_));case 4:case"end":return C.stop()}},T,this)})),function(T){return U.apply(this,arguments)})},{key:"getSignalChannelUrl",value:function(){var T={mainUrl:"",backupUrl:""},v=Dk();return v?T.mainUrl=T.backupUrl="wss://".concat(v,".rtc.qq.com"):this.proxy_?T.mainUrl=T.backupUrl=this.proxy_:this.unifiedProxy_?T.mainUrl=T.backupUrl="wss://".concat(this.unifiedProxy_):Array.isArray(this.schedule_.domains)&&this.schedule_.domains.length>0&&(T.mainUrl=T.backupUrl="wss://".concat(this.schedule_.domains[0]),this.schedule_.domains[1]&&(T.backupUrl="wss://".concat(this.schedule_.domains[1]))),T}},{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(T){var v=this;this.log_.info("setup signal channel");var E=this.getSignalChannelUrl(),C=E.mainUrl,O=E.backupUrl;return this.signalChannel_=new m6({sdkAppId:this.sdkAppId_,userId:this.userId_,userSig:this.userSig_,roomId:T.roomId,url:C,backupUrl:O,signalDomainWhenUnifiedProxy:this.unifiedProxy_?this.schedule_.domains[0]:void 0,client:this}),this.networkQuality_||(this.networkQuality_=new q6({connections:this.connections_,signalChannel:this.signalChannel_,userId:this.userId_,client:this}),this.networkQuality_.on(ct.NETWORK_QUALITY,function(F){v.emitter_.emit(ct.NETWORK_QUALITY,F)})),this.deviceDetector_||(this.deviceDetector_=new X6({client:this})),this.subscriptionManager_||(this.subscriptionManager_=new s7({client:this})),this.badCaseDetector_||(this.badCaseDetector_=new B7({client:this,stats:this.stats_})),this.callDurationCalculator_||(this.callDurationCalculator_=new G7({client:this})),this.mixTranscodeManager_||(this.mixTranscodeManager_=new j7({client:this,signalChannel:this.signalChannel_})),this.publishCDNManager_&&this.publishCDNManager_.setSignalChannel({signalChannel:this.signalChannel_}),this.signalChannel_.on(mm,function(F){v.log_.info("SignalChannel state changed from ".concat(F.prevState," to ").concat(F.state)),v.emitter_.emit(ct.CONNECTION_STATE_CHANGED,F)}),this.signalChannel_.on(vm,function(F){v.reset(),v.emitter_.emit(ct.ERROR,F)}),this.signalChannel_.once(lT,function(F){v.tinyId_=F.signalInfo.tinyId,q.emit(_l,{client:v})}),this.signalChannel_.on(vt.PEER_JOIN,this.onPeerJoin,this),this.signalChannel_.on(vt.PEER_LEAVE,this.onPeerLeave,this),this.signalChannel_.on(vt.UPDATE_REMOTE_MUTE_STAT,function(F){Date.now()-v.lastHeartBeatTime_>=1e4&&v.doHeartbeat(),q.emit(zf,{client:v,data:F.data}),v.onPublishedUserList(F.data),v.onUpdateRemoteMuteStat(F.data)}),this.signalChannel_.on(vt.CLIENT_BANNED,function(F){var K,re=F.data.data.reason;if(Ie.uploadEvent({log:"stat-banned:".concat(re),userId:v.userId_}),re===ON)K="you got banned by the admin";else if(re===MN)K="duplicated userId joining the room";else if(re===VN)K="the room has been disbanded by the admin",re=re.replace("_","-");else if(re===NN)return v.log_.warn("".concat(re," last heart beat time: ").concat(v.lastHeartBeatTime_," interval: ").concat(Date.now()-v.lastHeartBeatTime_,", visibility: ").concat(document.visibilityState)),void v.reJoin();v.log_[re==="kick"?"error":"info"]("user was banned because of [".concat(re,"]")),v.reset(),v.emitter_.emit(ct.CLIENT_BANNED,{reason:re,message:ne({key:X3,data:{message:K,reason:re}})||re})}),q.emit(Jf,{client:this}),this.signalChannel_.connect()}},{key:"preJoin",value:(A=N(p().mark(function T(v){var E,C,O,F;return p().wrap(function(K){for(;;)switch(K.prev=K.next){case 0:return this.joinOptions_=v,K.next=3,Am();case 3:if(this.checkSystemResult_=K.sent,this.checkDestroy(),(E=Dk())||(E=Qu,this.proxy_&&(this.proxy_.startsWith(BN)?E=FN:this.proxy_.startsWith(jN)&&(E=GN))),this.env_=E,Ie.setConfig({env:E,sdkAppId:this.sdkAppId_,userId:this.userId_,roomId:v.roomId}),this.uploadTrtcStats(),C=this.checkSystemResult_.detail,O=C.isH264EncodeSupported,F=C.isVp8EncodeSupported,Cm()&&(O||F)){K.next=13;break}throw new ee({code:Y.NOT_SUPPORTED,message:ne({key:fk})});case 13:case"end":return K.stop()}},T,this)})),function(T){return A.apply(this,arguments)})},{key:"join",value:(P=N(p().mark(function T(v){var E,C=this;return p().wrap(function(O){for(;;)switch(O.prev=O.next){case 0:return this.roomId_=v.roomId,ve(v.role)||(this.role_=v.role),ve(v.privateMapKey)||(this.privateMapKey_=v.privateMapKey),E=Pt(),q.emit(gl,{client:this}),vn(this.userId_,{eventId:XU,eventDesc:"joining room",timestamp:on(),userId:this.userId_,tinyId:this.tinyId_}),O.next=8,this.preJoin(v);case 8:return O.abrupt("return",new Promise(function(){var F=N(p().mark(function K(re,ce){return p().wrap(function(ge){for(;;)switch(ge.prev=ge.next){case 0:if(C.joinReject_=ce,ge.prev=1,C.proxy_||C.schedule_.domains){ge.next=5;break}return ge.next=5,C.schedule(v.roomId);case 5:return C.checkDestroy(),ge.next=8,C.initialize(v);case 8:return ge.next=10,C.doJoin(v);case 10:C.signalInfo_=C.signalChannel_.getSignalInfo(),q.emit(lo,{client:C}),C.joinedTimestamp_=Pt(),Ie.logSuccessEvent({userId:C.userId_,eventType:YN,delta:C.joinedTimestamp_-E}),Ie.logSuccessEvent({userId:C.userId_,eventType:xb}),Ie.uploadEvent({log:"stat-autoplay-dialog:".concat(C.enableAutoPlayDialog_),userId:C.userId_}),Ie.uploadEvent({log:"stat-conv-".concat(Zi,"-").concat(location.hostname),userId:C.userId_}),re(),ge.next=26;break;case 20:ge.prev=20,ge.t0=ge.catch(1),q.emit(ho,{client:C,error:ge.t0}),Ie.logFailedEvent({userId:C.userId_,eventType:xb,error:ge.t0}),C.reset(),ce(ge.t0);case 26:C.joinReject_=null;case 27:case"end":return ge.stop()}},K,null,[[1,20]])}));return function(K,re){return F.apply(this,arguments)}}()));case 9:case"end":return O.stop()}},T,this)})),function(T){return P.apply(this,arguments)})},{key:"checkDestroy",value:function(){if(this.isDestroyed_)throw new ee({code:Y.INVALID_OPERATION,message:ne({key:hf,data:{funName:"join"}})})}},{key:"uploadTrtcStats",value:(k=N(p().mark(function T(){var v,E,C,O,F,K,re,ce,ge,Ye,Ve,Ge,Ke;return p().wrap(function(He){for(;;)switch(He.prev=He.next){case 0:return He.prev=0,He.next=3,Tt.getMicrophones();case 3:C=He.sent,v=C&&C.length,He.next=9;break;case 7:He.prev=7,He.t0=He.catch(0);case 9:return He.prev=9,He.next=12,Tt.getCameras();case 12:O=He.sent,E=O&&O.length,He.next=18;break;case 16:He.prev=16,He.t1=He.catch(9);case 18:F={microphone:v,camera:E},K=this.checkSystemResult_.detail,re=K.isH264EncodeSupported,ce=K.isVp8EncodeSupported,ge=K.isH264DecodeSupported,Ye=K.isVp8DecodeSupported,Ve={webRTC:this.basis_.isWebRTCSupported,getUserMedia:this.basis_.isGetUserMediaSupported,webSocket:this.basis_.isWebSocketsSupported,screenShare:this.basis_.isScreenShareSupported,webAudio:this.basis_.isWebAudioSupported,h264Encode:re,h264Decode:ge,vp8Encode:ce,vp8Decode:Ye},Ge={browser:this.basis_.browser,os:this.basis_.os,trtc:Ve,devices:F},Ke={isWebCodecSupported:this.basis_.isWebCodecSupported,isMediaSessionSupported:this.basis_.isMediaSessionSupported,isWebTransportSupported:this.basis_.isWebTransportSupported},Ie.uploadEvent({log:"trtcstats-"+JSON.stringify(Ge),userId:this.userId_}),this.log_.info("TrtcStats-"+JSON.stringify(Ge)),Ie.uploadEvent({log:"trtcadvancedstats-"+JSON.stringify(Ke),userId:this.userId_});case 26:case"end":return He.stop()}},T,this,[[0,7],[9,16]])})),function(){return k.apply(this,arguments)})},{key:"doJoin",value:function(T){var v=this;return new Promise(function(E,C){v.log_.info("Join() => joining room: ".concat(v.roomId_," useStringRoomId: ").concat(v.useStringRoomId_," mode: ").concat(v.mode_," role: ").concat(v.role_));var O={roomId:String(v.roomId_),useStringRoomId:v.useStringRoomId_,privateMapKey:v.privateMapKey_,trtcRole:v.role_===Sr?ao:Qp,trtcScene:v.mode_===Yu?JN:WN,sdpSemantics:v.sdpSemantics_,version:EV(v.version_),ua:navigator&&navigator.userAgent||"",autoSubscribe:v.autoSubscribe_,terminalType:co?4:gf?2:vf?3:tc?12:Ck?5:Rk?13:1,netType:af[Of()],bussinessInfo:v.bussinessInfo_,receiveMix:!0};if(v.publishCDNManager_){var F=v.publishCDNManager_.handleCDNConfigForJoinData(v.bussinessInfo_),K=F.bussinessInfo,re=F.pushUserCdnInfo;Object.assign(O,{bussinessInfo:K,pushUserCdnInfo:re})}v.log_.debug("join room signal data: ".concat(JSON.stringify(O))),v.joinTimeout_=setTimeout(function(){v.log_.error("join room timeout observed"),C(new ee({code:Y.JOIN_ROOM_FAILED,message:ne({key:N3})}))},5e3),q.emit(Bf,{client:v}),v.signalChannel_.once(dT,function(ce){v.clearJoinTimeout(),q.emit(_l,{client:v,error:ce}),C(ce)}),v.signalChannel_.send(yU,O),v.signalChannel_.once(vt.JOIN_ROOM_RESULT,function(ce){v.clearJoinTimeout();var ge=ce.data,Ye=ge.code,Ve=ge.message,Ge=ge.data;v.onPublishedUserList({data:{userList:Ge.publishers}}),q.emit(jf,{client:v,code:Ye}),Ye===0?(v.isJoined_=!0,v.log_.info("Join room success, start heartbeat"),v.startHeartbeat(),v.badCaseDetector_&&v.badCaseDetector_.start(),v.syncUserList(),v.startSyncUserListInterval(),E()):(v.log_.error("Join room failed result: "+Ye+" error: "+Ve),C(new ee({code:Y.JOIN_ROOM_FAILED,extraCode:Ye,message:ne({key:sk,data:{error:Ve,code:Ye}})})))})})}},{key:"reJoin",value:(L=N(p().mark(function T(){return p().wrap(function(v){for(;;)switch(v.prev=v.next){case 0:if(this.isJoined_){v.next=3;break}return this.log_.warn("reJoin abort"),v.abrupt("return");case 3:return this.isJoined_=!1,v.prev=4,this.log_.warn("reJoin pending: ".concat(this.joinOptions_.roomId)),this.subscriptionManager_&&this.subscriptionManager_.markAllStream(),this.signalChannel_.close(),v.next=10,this.signalChannel_.connect();case 10:return v.next=12,this.doJoin(H(H({},this.joinOptions_),{},{role:this.role_,privateMapKey:this.privateMapKey_}));case 12:this.log_.warn("reJoin success"),Ie.logSuccessEvent({userId:this.userId_,eventType:Ib}),this.checkConnectionsToReconnect(),this.uplinkConnection_&&!this.uplinkConnection_.getIsReconnecting()&&this.uplinkConnection_.startReconnection(),this.mixTranscodeManager_&&this.mixTranscodeManager_.reStartMixTranscode(),v.next=25;break;case 19:v.prev=19,v.t0=v.catch(4),this.log_.warn("reJoin fail "+v.t0),this.reset(),Ie.logFailedEvent({userId:this.userId_,eventType:Ib,error:v.t0}),this.emitter_.emit(ct.ERROR,new ee({code:Y.JOIN_ROOM_FAILED,message:ne({key:V3,data:{roomId:this.joinOptions_.roomId}})}));case 25:case"end":return v.stop()}},T,this,[[4,19]])})),function(){return L.apply(this,arguments)})},{key:"leave",value:(ue=N(p().mark(function T(){var v;return p().wrap(function(E){for(;;)switch(E.prev=E.next){case 0:return q.emit(Ff,{client:this}),vn(this.userId_,{eventId:QU,eventDesc:"leaving room",timestamp:on(),userId:this.userId_,tinyId:this.tinyId_}),E.prev=2,E.next=5,this.doHeartbeat();case 5:E.next=9;break;case 7:E.prev=7,E.t0=E.catch(2);case 9:this.doLeave(),q.emit(po,{client:this}),Ie.logSuccessEvent({userId:this.userId_,eventType:$N}),v=Math.floor((Pt()-this.joinedTimestamp_)/1e3),Ie.logSuccessEvent({userId:this.userId_,eventType:ZN,delta:v});case 14:case"end":return E.stop()}},T,this,[[2,7]])})),function(){return ue.apply(this,arguments)})},{key:"doLeave",value:function(){this.isJoined_&&(q.emit(Gf,{client:this}),this.log_.info("leave() => leaving room"),this.signalChannel_.send(SU),this.reset())}},{key:"clearNetworkQuality",value:function(){this.networkQuality_&&(this.networkQuality_.stop(),this.networkQuality_=null)}},{key:"closeConnections",value:function(){var T=this;this.connections_.forEach(function(v){T.closeDownLink(v.getTinyId())})}},{key:"clearJoinTimeout",value:function(){clearTimeout(this.joinTimeout_),this.joinTimeout_=-1}},{key:"destroy",value:function(){var T,v,E;if(this.isJoined_)throw this.log_.warn(vi.INVALID_DESTROY),new ee({code:Y.INVALID_OPERATION,message:ne({key:U3})});this.isDestroyed_||(this.log_.info("destroy client"),this.joinReject_&&(this.joinReject_(new ee({code:Y.INVALID_OPERATION,message:ne({key:hf,data:{funName:"join"}})})),this.clearJoinTimeout(),this.reset()),this.off("*"),(T=this.callDurationCalculator_)===null||T===void 0||T.destroy(),(v=this.keyPointManager_)===null||v===void 0||v.destroy(),(E=this.deviceDetector_)===null||E===void 0||E.destroy(),this.callDurationCalculator_=null,this.keyPointManager_=null,this.deviceDetector_=null,this.badCaseDetector_=null,this.publishCDNManager_=null,this.isDestroyed_=!0,q.emit(Kf,{client:this}))}},{key:"reset",value:function(){this.isJoined_=!1,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_=yt.run(so,this.syncUserList.bind(this)))}},{key:"stopSyncUserListInterval",value:function(){yt.clearTask(this.syncUserListInterval_),this.syncUserListInterval_=-1}},{key:"syncUserList",value:($=N(p().mark(function T(){var v,E=this;return p().wrap(function(C){for(;;)switch(C.prev=C.next){case 0:return C.prev=0,C.next=3,this.getUserList();case 3:v=C.sent,this.userMap_.size!==0&&this.userMap_.forEach(function(O){v.findIndex(function(F){return F.userId===O.userId})<0&&(E.log_.info("peer leave detected: ".concat(O.userId)),E.cleanUser({userId:O.userId,tinyId:O.tinyId}))}),v.forEach(function(O){var F=O.userId;E.userMap_.has(F)||F===E.userId_||(E.userMap_.set(F,O),E.emitter_.emit(ct.PEER_JOIN,{userId:F}))}),C.next=11;break;case 8:C.prev=8,C.t0=C.catch(0),this.log_.warn("sync user list failed: "+C.t0);case 11:case"end":return C.stop()}},T,this,[[0,8]])})),function(){return $.apply(this,arguments)})},{key:"getUserList",value:function(){return this.signalChannel_?this.signalChannel_.sendWaitForResponse({command:LU,responseCommand:vt.USER_LIST_RES,enableLog:!1,timeout:2e3}).then(function(T){var v=T.data,E=v.code,C=v.message;if(E===0)return(v.data&&v.data.userList||[]).map(function(O){var F=O.userId,K=O.srcTinyId,re=O.role;return new sg({userId:F,tinyId:K,role:re})});throw ne({key:gk,data:{signalResponse:vt.USER_LIST_RES,code:E,message:C}})}):[]}},{key:"publish",value:(z=N(p().mark(function T(v){var E,C,O,F,K,re,ce,ge,Ye=this,Ve=arguments;return p().wrap(function(Ge){for(;;)switch(Ge.prev=Ge.next){case 0:return E=Ve.length>1&&Ve[1]!==void 0?Ve[1]:{isAuxiliary:!1},v.setPublishState(Zs),this.isPublishing_=!0,C=Pt(),q.emit(Wf,{client:this,stream:v}),O=E.isAuxiliary,F=O?mt:Ze,K=v.getScreen(),this.log_.info("publish() => publishing ".concat(K?Wp+" ":"").concat(F," stream ").concat(v.getId())),re=this.uplinkConnection_,Ge.prev=10,re||((re=new m7({userId:this.userId_,tinyId:this.tinyId_,client:this,isUplink:!0,signalChannel:this.signalChannel_,enableSEI:this.enableSEI_})).initialize(),re.on(tt.ERROR,function(Ke){var He=Ke.getCode();He!==Y.ICE_TRANSPORT_ERROR&&(He===Y.UPLINK_RECONNECTION_FAILED&&Ye.closeUplink(),Ye.emitter_.emit(ct.ERROR,Ke))})),v.setConnection(re),Ge.next=15,re.publish(v,O);case 15:this.log_.info("local ".concat(K?Wp+" ":"").concat(F," stream is published")),this.isPublishing_=!1,O?this.localAuxStream_=v:(this.localStream_=v,this.deviceDetector_&&this.deviceDetector_.setLocalStream(this.localStream_),this.localStream_.getBeautyStatus()&&this.log_.info("beauty stream is published successfully")),v.setPublishState(n3),v.setClient(this,O),this.uplinkConnection_=re,ce=Pt(),ge=ce-C,Ie.logSuccessEvent({userId:this.userId_,eventType:wb}),Ie.logSuccessEvent({userId:this.userId_,eventType:e3,delta:ge}),v.hasAudio()&&vn(this.userId_,{eventId:mT,eventDesc:"publish audio track",timestamp:on(),userId:this.userId_,tinyId:this.tinyId_}),v.hasVideo()&&vn(this.userId_,{eventId:fT,eventDesc:"publish video track",timestamp:on(),userId:this.userId_,tinyId:this.tinyId_}),this.networkQuality_&&this.networkQuality_.setUplinkConnection(this.uplinkConnection_),q.emit(AV,{localStream:v,isAuxiliary:O,client:this}),this.notPublishWithoutH264Supported_=!1,v.isAIDenoiser&&Ii.handleFunctionState({fnName:"AI_DENOISER"}),Ge.next=42;break;case 33:throw Ge.prev=33,Ge.t0=Ge.catch(10),Ge.t0 instanceof ee&&Ge.t0.getCode()===Y.NOT_SUPPORTED_H264&&(this.notPublishWithoutH264Supported_=!0),v.setPublishState(Wb),re.close(),this.log_.error("failed to publish stream "+Ge.t0),this.isPublishing_=!1,Ie.logFailedEvent({userId:this.userId_,eventType:wb,error:Ge.t0}),Ge.t0;case 42:case"end":return Ge.stop()}},T,this,[[10,33]])})),function(T){return z.apply(this,arguments)})},{key:"unpublish",value:(j=N(p().mark(function T(v){var E,C;return p().wrap(function(O){for(;;)switch(O.prev=O.next){case 0:if(this.uplinkConnection_){O.next=2;break}return O.abrupt("return");case 2:return E=v===this.localAuxStream_,C=v.getScreen(),this.log_.info("unpublish() => unpublishing local ".concat(C?Wp+" ":"").concat(E?mt:Ze," stream")),O.prev=5,O.next=8,this.uplinkConnection_.unpublish(v);case 8:v.setClient(null),v.setConnection(null),E?this.localAuxStream_=null:(this.localStream_=null,v.hasAudio()&&vn(this.userId_,{eventId:gT,eventDesc:"unpublish audio track",timestamp:on(),userId:this.userId_,tinyId:this.tinyId_}),v.hasVideo()&&vn(this.userId_,{eventId:vT,eventDesc:"unpublish video track",timestamp:on(),userId:this.userId_,tinyId:this.tinyId_})),this.localStream_||this.localAuxStream_||this.closeUplink(),Ie.logSuccessEvent({userId:this.userId_,eventType:Eb}),O.next=19;break;case 15:throw O.prev=15,O.t0=O.catch(5),Ie.logFailedEvent({userId:this.userId_,eventType:Eb,error:O.t0}),O.t0;case 19:case"end":return O.stop()}},T,this,[[5,15]])})),function(T){return j.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(T){var v=this.connections_.get(T);v&&(v.getIsReconnecting()&&v.stopReconnection(),this.subscriptionManager_&&this.subscriptionManager_.delete(v.getUserId()),v.close(),this.connections_.delete(T),this.mutedStates_.delete(T))}},{key:"subscribe",value:(w=N(p().mark(function T(v,E){var C,O,F;return p().wrap(function(K){for(;;)switch(K.prev=K.next){case 0:return this.log_.info("subscribe() => subscribe to [".concat(v.getUserId(),"] ").concat(v.getType()," stream with options: ").concat(JSON.stringify(E))),ve(E)&&(E={audio:!0,video:!0}),ve(E.audio)&&(E.audio=!0),ve(E.smallVideo)?ve(E.video)&&(E.video=!0):E.smallVideo?ve(E.video)?(E.video=!1,E.smallVideo=!0):E.video&&(E.video=!0,delete E.smallVideo,this.log_.warn("options.video and options.smallVideo can't be both true")):ve(E.video)&&(E.video=!0,delete E.smallVideo),E.video&&this.changeBigSmallRecords_.delete(v.getUserId()),C=v.getConnection(),E.smallVideo&&(C.getTrackState().smallVideo||(this.setRemoteVideoStreamType(v,"small"),E.video=!0,delete E.smallVideo)),K.prev=7,q.emit(Qf,{client:this,stream:v}),K.next=11,C.subscribe(v,E);case 11:this.subscriptionManager_&&this.subscriptionManager_.addSubscriptionRecord(v.getUserId(),v,E),this.notSubscribeWithoutH264Supported_=!1,Ie.logSuccessEvent({userId:this.userId_,eventType:Cb}),K.next=24;break;case 16:throw K.prev=16,K.t0=K.catch(7),(O=K.t0 instanceof ee?K.t0.getCode():Y.UNKNOWN)===Y.NOT_SUPPORTED_H264&&(this.notSubscribeWithoutH264Supported_=!0),(F=new ee(O===Y.REMOTE_STREAM_NOT_EXIST?{code:Y.API_CALL_ABORTED,message:ne({key:mf,data:{message:K.t0.message,stream:v}})}:{code:O,message:ne({key:z3,data:{message:K.t0.message,stream:v}})})).getCode()===Y.API_CALL_ABORTED?this.log_.warn(F):this.log_.error(F),Ie.logFailedEvent({userId:this.userId_,eventType:Cb,error:F}),F;case 24:case"end":return K.stop()}},T,this,[[7,16]])})),function(T,v){return w.apply(this,arguments)})},{key:"unsubscribe",value:(I=N(p().mark(function T(v){var E;return p().wrap(function(C){for(;;)switch(C.prev=C.next){case 0:return this.log_.info("unsubscribe() => unsubscribe to [".concat(v.getUserId(),"] ").concat(v.getType()," stream")),C.prev=1,E=v.getConnection(),C.next=5,E.unsubscribe(v);case 5:this.subscriptionManager_&&this.subscriptionManager_.addUnsubscriptionRecord(v.getUserId(),v),q.emit(Br,{client:this,stream:v}),Ie.logSuccessEvent({userId:this.userId_,eventType:Rb}),C.next=14;break;case 10:throw C.prev=10,C.t0=C.catch(1),Ie.logFailedEvent({userId:this.userId_,eventType:Rb,error:C.t0}),C.t0;case 14:case"end":return C.stop()}},T,this,[[1,10]])})),function(T){return I.apply(this,arguments)})},{key:"switchRole",value:(g=N(p().mark(function T(v){return p().wrap(function(E){for(;;)switch(E.prev=E.next){case 0:if(this.role_!==v){E.next=2;break}return E.abrupt("return");case 2:return v===qi&&this.uplinkConnection_&&this.closeUplink(),this.log_.info("switchRole() => switch role to: "+v),E.next=6,this.doSwitchRole(v);case 6:case"end":return E.stop()}},T,this)})),function(T){return g.apply(this,arguments)})},{key:"doSwitchRole",value:function(T){var v,E,C=this,O={command:OU,data:{role:T===Sr?ao:Qp,privateMapKey:this.privateMapKey_},responseCommand:vt.SWITCH_ROLE_RES,retries:((v=this.schedule_.config)===null||v===void 0||(E=v.retries)===null||E===void 0?void 0:E.switchRole)||1};return this.log_.info("switchRole signal data: "+JSON.stringify(O.data)),this.signalChannel_.sendWaitForResponseWithRetry(O).then(function(F){var K=F.data,re=K.code,ce=K.message;if(re!==0)throw new ee({code:Y.SWITCH_ROLE_FAILED,message:ne({key:q3,data:{errMsg:ce,errCode:re}})});C.role_=T}).catch(function(F){throw F instanceof ee&&F.getCode()===Y.API_CALL_TIMEOUT&&(F=new ee({code:Y.SWITCH_ROLE_FAILED,message:ne({key:K3})})),C.log_.error(F),F})}},{key:"on",value:function(T,v,E){this.emitter_.on(T,v,E)}},{key:"off",value:function(T,v,E){T==="*"?this.emitter_.removeAllListeners():this.emitter_.off(T,v,E)}},{key:"getRemoteMutedState",value:function(){var T=this,v=[];return this.mutedStates_.forEach(function(E,C,O){var F=T.connections_.get(C);F&&v.push(H({userId:F.getUserId()},E))}),v}},{key:"getTransportStats",value:(f=N(p().mark(function T(){var v,E,C,O,F,K,re;return p().wrap(function(ce){for(;;)switch(ce.prev=ce.next){case 0:if(v={rtt:0,downlinksRTT:{}},!this.uplinkConnection_){ce.next=6;break}return ce.next=4,this.stats_.getSenderStats(this.uplinkConnection_);case 4:E=ce.sent,v.rtt=E.rtt;case 6:C=ie(this.connections_),ce.prev=7,C.s();case 9:if((O=C.n()).done){ce.next=17;break}return(F=Te(O.value,2))[0],K=F[1],ce.next=13,this.stats_.getReceiverStats(K);case 13:re=ce.sent,v.downlinksRTT[re.userId]=re.rtt;case 15:ce.next=9;break;case 17:ce.next=22;break;case 19:ce.prev=19,ce.t0=ce.catch(7),C.e(ce.t0);case 22:return ce.prev=22,C.f(),ce.finish(22);case 25:return ce.abrupt("return",v);case 26:case"end":return ce.stop()}},T,this,[[7,19,22,25]])})),function(){return f.apply(this,arguments)})},{key:"getLocalAudioStats",value:(b=N(p().mark(function T(){var v,E;return p().wrap(function(C){for(;;)switch(C.prev=C.next){case 0:if((v={})[this.userId_]={bytesSent:0,packetsSent:0},!this.uplinkConnection_){C.next=7;break}return C.next=5,this.stats_.getSenderStats(this.uplinkConnection_);case 5:E=C.sent,v[this.userId_]={bytesSent:E.audio.bytesSent,packetsSent:E.audio.packetsSent};case 7:return C.abrupt("return",v);case 8:case"end":return C.stop()}},T,this)})),function(){return b.apply(this,arguments)})},{key:"getLocalVideoStats",value:(y=N(p().mark(function T(){var v,E;return p().wrap(function(C){for(;;)switch(C.prev=C.next){case 0:if((v={})[this.userId_]={bytesSent:0,packetsSent:0,framesEncoded:0,framesSent:0,frameWidth:0,frameHeight:0},!this.uplinkConnection_){C.next=7;break}return C.next=5,this.stats_.getSenderStats(this.uplinkConnection_);case 5:E=C.sent,v[this.userId_]={bytesSent:E.video.bytesSent,packetsSent:E.video.packetsSent,framesEncoded:E.video.framesEncoded,framesSent:E.video.framesSent,frameWidth:E.video.frameWidth,frameHeight:E.video.frameHeight};case 7:return C.abrupt("return",v);case 8:case"end":return C.stop()}},T,this)})),function(){return y.apply(this,arguments)})},{key:"getRemoteAudioStats",value:(_=N(p().mark(function T(){var v,E,C,O,F,K,re,ce;return p().wrap(function(ge){for(;;)switch(ge.prev=ge.next){case 0:v={},E=ie(this.connections_),ge.prev=2,E.s();case 4:if((C=E.n()).done){ge.next=13;break}return(O=Te(C.value,2))[0],F=O[1],K=F.getDelay(),re=K.audioDelay,ge.next=9,this.stats_.getReceiverStats(F);case 9:(ce=ge.sent).hasAudio&&(v[ce.userId]={bytesReceived:ce.audio.bytesReceived,packetsReceived:ce.audio.packetsReceived,packetsLost:ce.audio.packetsLost,end2EndDelay:re});case 11:ge.next=4;break;case 13:ge.next=18;break;case 15:ge.prev=15,ge.t0=ge.catch(2),E.e(ge.t0);case 18:return ge.prev=18,E.f(),ge.finish(18);case 21:return ge.abrupt("return",v);case 22:case"end":return ge.stop()}},T,this,[[2,15,18,21]])})),function(){return _.apply(this,arguments)})},{key:"getRemoteVideoStats",value:(h=N(p().mark(function T(){var v,E,C,O,F,K,re,ce,ge,Ye=arguments;return p().wrap(function(Ve){for(;;)switch(Ve.prev=Ve.next){case 0:v=Ye.length>0&&Ye[0]!==void 0?Ye[0]:_t,E={},C=ie(this.connections_),Ve.prev=3,C.s();case 5:if((O=C.n()).done){Ve.next=15;break}return(F=Te(O.value,2))[0],K=F[1],Ve.next=9,this.stats_.getReceiverStats(K);case 9:re=Ve.sent,ce=K.getDelay(),ge=ce.videoDelay,v===_t&&re.hasVideo&&(E[re.userId]={bytesReceived:re.video.bytesReceived,packetsReceived:re.video.packetsReceived,packetsLost:re.video.packetsLost,framesDecoded:re.video.framesDecoded,frameWidth:re.video.frameWidth,frameHeight:re.video.frameHeight,end2EndDelay:ge}),v===Dt&&re.hasAuxiliary&&(E[re.userId]={bytesReceived:re.auxiliary.bytesReceived,packetsReceived:re.auxiliary.packetsReceived,packetsLost:re.auxiliary.packetsLost,framesDecoded:re.auxiliary.framesDecoded,frameWidth:re.auxiliary.frameWidth,frameHeight:re.auxiliary.frameHeight,end2EndDelay:ge});case 13:Ve.next=5;break;case 15:Ve.next=20;break;case 17:Ve.prev=17,Ve.t0=Ve.catch(3),C.e(Ve.t0);case 20:return Ve.prev=20,C.f(),Ve.finish(20);case 23:return Ve.abrupt("return",E);case 24:case"end":return Ve.stop()}},T,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_=yt.run(so,this.doHeartbeat.bind(this),{delay:2e3}))}},{key:"stopHeartbeat",value:function(){this.heartbeat_!==-1&&(this.log_.info("stopHeartbeat"),yt.clearTask(this.heartbeat_),this.heartbeat_=-1,this.lastHeartBeatTime_=-1)}},{key:"doHeartbeat",value:(d=N(p().mark(function T(){var v,E,C,O,F,K;return p().wrap(function(re){for(;;)switch(re.prev=re.next){case 0:return E=this.badCaseDetector_.getMonitorFreeze(),re.next=3,this.stats_.getStatsReport({uplinkConnection:this.uplinkConnection_,downlinkConnections:this.connections_,freezeMap:E});case 3:if(C=re.sent,q.emit(Hf,{client:this,stats:C}),(v=this.badCaseDetector_)===null||v===void 0||v.resetMonitor(),this.signalChannel_){re.next=8;break}return re.abrupt("return");case 8:O=this.signalChannel_.isConnected()?h6(this.userId_):[],F=H(H({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:af[this.networkType_]}},C),{},{msg_event_msg:O}),this.signalChannel_.send(bU,F),K=Date.now(),this.lastHeartBeatTime_>0&&K-this.lastHeartBeatTime_>1e4&&this.log_.warn("heartbeat took ".concat(K-this.lastHeartBeatTime_)),this.lastHeartBeatTime_=K,!this.isRelayChanged_&&this.isRelayMaybeFailed()&&(this.reJoin(),this.isRelayChanged_=!0);case 15:case"end":return re.stop()}},T,this)})),function(){return d.apply(this,arguments)})},{key:"onRemoteStreamAdded",value:function(T){var v=T.content,E=v.userId,C=v.tinyId,O=v.audio,F=v.bigVideo,K=v.auxVideo,re=v.smallVideo;if(E!==null){this.userMap_.has(E)||(this.userMap_.set(E,new sg({userId:E,tinyId:C,role:Sr})),this.emitter_.emit(ct.PEER_JOIN,{userId:E}));var ce=this.connections_.get(C);if(ce){if(ce.getIsReconnecting())return;this.log_.warn("duplicated stream-added observed, rebuild the connection"),ce.close(),this.connections_.delete(C)}var ge={audio:O,video:F,auxiliary:K,smallVideo:re};this.log_.info("remote peer [".concat(E,"] published stream. trackState: ").concat(JSON.stringify(ge))),this.createDownlinkConnection({userId:E,tinyId:C,trackState:ge})}else this.log_.warn("received null userId on stream added")}},{key:"createDownlinkConnection",value:function(T){var v=this,E=T.userId,C=T.tinyId,O=T.trackState,F=new U7({userId:E,tinyId:C,client:this,isUplink:!1,signalChannel:this.signalChannel_,autoSubscribe:this.autoSubscribe_,trackState:O,enableSEI:this.enableSEI_});this.connections_.set(C,F),this.installDownlinkEvents(F,E,C),this.autoSubscribe_?(F.initialize(),F.connect().catch(function(){!F.getMainStream()&&F.hasMainStream()&&v.initRemoteStream({type:_t,userId:E,downlinkConnection:F}),!F.getAuxStream()&&F.hasAuxStream()&&v.initRemoteStream({type:Dt,userId:E,downlinkConnection:F})})):(F.hasMainStream()&&this.initRemoteStream({type:_t,userId:E,downlinkConnection:F}),F.hasAuxStream()&&this.initRemoteStream({type:Dt,userId:E,downlinkConnection:F}))}},{key:"initRemoteStream",value:function(T){var v=T.type,E=T.userId,C=T.downlinkConnection,O=new Zv({type:v,userId:E,client:this});O.setConnection(C),C.setRemoteStream(v===_t?br:Qs,O),O.setIsStreamAddedEventEmitted(!0),q.emit(yl,{client:this,stream:O}),this.emitter_.emit(ct.STREAM_ADDED,{stream:O})}},{key:"installDownlinkEvents",value:function(T,v,E){var C=this;T.on(tt.SEI_MESSAGE,function(O){C.emitter_.emit(ct.SEI_MESSAGE,O)}),T.on(tt.STREAM_ADDED,function(O){O.stream.setIsStreamAddedEventEmitted(!0),q.emit(yl,{client:C,stream:O.stream}),C.emitter_.emit(ct.STREAM_ADDED,{stream:O.stream})}),T.on(tt.STREAM_REMOVED,function(O){C.changeBigSmallRecords_.delete(O.stream.getUserId()),O.stream.stop(),O.stream.setIsStreamAddedEventEmitted(!1),C.subscriptionManager_&&C.subscriptionManager_.deleteAutoRecoveryFlag(O.stream.getUserId(),O.stream.getType()),q.emit(ia,{client:C,stream:O.stream}),C.emitter_.emit(ct.STREAM_REMOVED,{stream:O.stream})}),T.on(tt.STREAM_UPDATED,function(O){q.emit(RV,{client:C,stream:O.stream});var F=T.getMixUserList();F&&(O.mixUserList=F),C.emitter_.emit(ct.STREAM_UPDATED,O)}),T.on(tt.STREAM_SUBSCRIBED,function(O){q.emit(Ur,{client:C,stream:O.stream}),C.emitter_.emit(ct.STREAM_SUBSCRIBED,{stream:O.stream})}),T.on(tt.ERROR,function(O){var F=O.getCode();F!==Y.ICE_TRANSPORT_ERROR&&(F===Y.DOWNLINK_RECONNECTION_FAILED&&C.closeDownLink(E),C.emitter_.emit(ct.ERROR,O))})}},{key:"onPeerJoin",value:function(T){var v=T.data.data,E=v.srcTinyId,C=v.userId,O=v.role;this.userMap_.has(C)||(this.userMap_.set(C,new sg({userId:C,tinyId:E,role:O})),this.emitter_.emit(ct.PEER_JOIN,{userId:C}))}},{key:"onPeerLeave",value:function(T){var v=T.data.data,E=v.srcTinyId,C=v.userId,O=v.reason,F=O===void 0?0:O;this.log_.info("peer leave [".concat(C,"]: ").concat(c3[F])),this.cleanUser({userId:C,tinyId:E})}},{key:"cleanUser",value:function(T){var v=T.userId,E=T.tinyId;this.userMap_.delete(v),this.closeDownLink(E),this.emitter_.emit(ct.PEER_LEAVE,{userId:v})}},{key:"onPublishedUserList",value:function(T){var v=this;try{var E=be(T.data.userList);T.data.mixRobotList&&E.push.apply(E,be(T.data.mixRobotList));var C=E.map(function(O){return O.userId});this.connections_.forEach(function(O){var F=O.getUserId(),K=O.getTinyId();C.findIndex(function(re){return re===F})<0&&(v.log_.info("peer unpublished detected [".concat(F,"]")),v.closeDownLink(K))}),E.forEach(function(O){var F=O.userId,K=O.srcTinyId,re=O.flag,ce=O.mixUserList;if(F!==v.userId_){var ge=!!(1&re),Ye=!!(8&re),Ve=!!(4&re),Ge=!!(2&re),Ke=v.connections_.get(K);if((Ge||ge)&&v.checkSubscribeBigSmallVideo(Ke,Ge),Ke){var He=Ke.getTrackState(),Cr=He.audio,ma=He.video,Rc=He.auxiliary,Hw=He.smallVideo;ml(ce)&&Ke.setMixUserList(ce),!ma&&ge&&q.emit(Bn,{client:v,tinyId:K,userId:F,action:un.ADD,kind:xe}),!Cr&&Ye&&q.emit(Bn,{client:v,tinyId:K,userId:F,action:un.ADD,kind:Ce}),!Rc&&Ve&&q.emit(Bn,{client:v,tinyId:K,userId:F,action:un.ADD,kind:mt}),!Hw&&Ge&&q.emit(Bn,{client:v,tinyId:K,userId:F,action:un.ADD,kind:qu}),ma&&!ge&&q.emit(Bn,{client:v,tinyId:K,userId:F,action:un.REMOVE,kind:xe}),Cr&&!Ye&&q.emit(Bn,{client:v,tinyId:K,userId:F,action:un.REMOVE,kind:Ce}),Rc&&!Ve&&q.emit(Bn,{client:v,tinyId:K,userId:F,action:un.REMOVE,kind:mt}),Hw&&!Ge&&q.emit(Bn,{client:v,tinyId:K,userId:F,action:un.REMOVE,kind:qu})}else v.log_.info("peer published detected [".concat(F,"]")),v.onRemoteStreamAdded({content:{audio:Ye,bigVideo:ge,auxVideo:Ve,smallVideo:Ge,userId:F,tinyId:K}})}})}catch(O){}}},{key:"onUpdateRemoteMuteStat",value:function(T){var v=this,E=T.data;(E&&E.userList||[]).forEach(function(C){var O=C.srcTinyId,F=C.userId;if(O!==0&&O!==v.tinyId_){var K=v.connections_.get(O);if(K){var re=K.getMainStream();if(re&&re.getIsStreamAddedEventEmitted()){var ce=!!(1&C.flag),ge=!!(8&C.flag),Ye=!!(2&C.flag),Ve=!!(64&C.flag),Ge=!!(16&C.flag),Ke=v.mutedStates_.get(O);if(Ke===void 0)return v.mutedStates_.set(O,{hasAudio:ge,hasVideo:ce,hasSmall:Ye,audioMuted:Ve,videoMuted:Ge}),ce?Ge?v.emitter_.emit(ct.MUTE_VIDEO,{userId:F}):v.emitter_.emit(ct.UNMUTE_VIDEO,{userId:F}):v.emitter_.emit(ct.MUTE_VIDEO,{userId:F}),void(ge?Ve?v.emitter_.emit(ct.MUTE_AUDIO,{userId:F}):v.emitter_.emit(ct.UNMUTE_AUDIO,{userId:F}):v.emitter_.emit(ct.MUTE_AUDIO,{userId:F}));var He=!Ke.audioMuted&&Ke.hasAudio,Cr=!Ve&&ge,ma=!Ke.videoMuted&&Ke.hasVideo,Rc=!Ge&&ce;v.mutedStates_.set(O,{hasAudio:ge,hasVideo:ce,hasSmall:Ye,audioMuted:Ve,videoMuted:Ge}),He!==Cr&&(Cr?v.emitter_.emit(ct.UNMUTE_AUDIO,{userId:F}):v.emitter_.emit(ct.MUTE_AUDIO,{userId:F})),ma!==Rc&&(Rc?v.emitter_.emit(ct.UNMUTE_VIDEO,{userId:F}):v.emitter_.emit(ct.MUTE_VIDEO,{userId:F}))}}else v.mutedStates_.delete(O)}})}},{key:"getEnv",value:function(){return this.env_}},{key:"getSubscriptionManager",value:function(){return this.subscriptionManager_}},{key:"startPublishCDNStream",value:(u=N(p().mark(function T(){var v,E=arguments;return p().wrap(function(C){for(;;)switch(C.prev=C.next){case 0:if(v=E.length>0&&E[0]!==void 0?E[0]:{},this.log_.info("startPublishCDNStream with params: ".concat(JSON.stringify(v),"; isJoined: ").concat(this.isJoined_,"; hasMainStream: ").concat(!!this.localStream_,"; hasAuxStream: ").concat(!!this.localAuxStream_,";")),v.streamType=v.streamType||Ze,v.streamType===mt&&(v.streamType=Vn),v.streamId=v.streamId||"",!this.isJoined_){C.next=10;break}if(v.streamType!==Ze||this.localStream_){C.next=8;break}throw new ee({code:Y.INVALID_OPERATION,message:ne({key:ck})});case 8:if(v.streamType!==Vn||this.localAuxStream_){C.next=10;break}throw new ee({code:Y.INVALID_OPERATION,message:ne({key:ck})});case 10:return C.next=12,this.publishCDNManager_.startPublishTencentCDN(v);case 12:if(!(v.appId&&v.bizId&&v.url)){C.next=15;break}return C.next=15,this.publishCDNManager_.startPublishGivenCDN(v);case 15:case"end":return C.stop()}},T,this)})),function(){return u.apply(this,arguments)})},{key:"stopPublishCDNStream",value:(c=N(p().mark(function T(){return p().wrap(function(v){for(;;)switch(v.prev=v.next){case 0:if(this.publishCDNManager_.getIsPublishingTencentCDN()){v.next=2;break}throw new ee({code:Y.INVALID_OPERATION,message:ne({key:Q3})});case 2:return this.log_.info("stopPublishCDNStream"),v.next=5,this.publishCDNManager_.stopPublishTencentCDN();case 5:if(!this.publishCDNManager_.getIsPublishingGivenCDN()){v.next=8;break}return v.next=8,this.publishCDNManager_.stopPublishGivenCDN();case 8:case"end":return v.stop()}},T,this)})),function(){return c.apply(this,arguments)})},{key:"startMixTranscode",value:(s=N(p().mark(function T(v){return p().wrap(function(E){for(;;)switch(E.prev=E.next){case 0:if(this.isJoined_&&this.mixTranscodeManager_){E.next=2;break}throw new ee({code:Y.INVALID_OPERATION,message:ne({key:$3})});case 2:return ve(v.mode)&&(v.mode=rf.MANUAL),E.prev=3,this.log_.info("startMixTranscode with config ".concat(JSON.stringify(v))),Ie.uploadEvent({log:"mix-transcode-mode:".concat(v.mode),userId:this.userId_}),E.next=8,this.mixTranscodeManager_.startMixTranscode(v);case 8:Ie.logSuccessEvent({userId:this.userId_,eventType:Bb}),E.next=15;break;case 11:throw E.prev=11,E.t0=E.catch(3),Ie.logFailedEvent({userId:this.userId_,eventType:Bb,error:E.t0}),E.t0;case 15:case"end":return E.stop()}},T,this,[[3,11]])})),function(T){return s.apply(this,arguments)})},{key:"stopMixTranscode",value:(a=N(p().mark(function T(){return p().wrap(function(v){for(;;)switch(v.prev=v.next){case 0:if(this.isJoined_&&this.mixTranscodeManager_){v.next=2;break}throw new ee({code:Y.INVALID_OPERATION,message:ne({key:Z3})});case 2:return v.prev=2,v.next=5,this.mixTranscodeManager_.stopMixTranscode();case 5:Ie.logSuccessEvent({userId:this.userId_,eventType:jb}),v.next=12;break;case 8:throw v.prev=8,v.t0=v.catch(2),Ie.logFailedEvent({userId:this.userId_,eventType:jb,error:v.t0}),v.t0;case 12:case"end":return v.stop()}},T,this,[[2,8]])})),function(){return a.apply(this,arguments)})},{key:"getSystemResult",value:function(){return this.checkSystemResult_}},{key:"enableAudioVolumeEvaluation",value:function(){var T=this,v=arguments.length>0&&arguments[0]!==void 0?arguments[0]:2e3,E=arguments.length>1&&arguments[1]!==void 0&&arguments[1];if(!xr(v))throw new ee({code:Y.INVALID_PARAMETER,message:ne({key:e4})});if(this.log_.info("enableAudioVolumeEvaluation with interval: "+v),v<=0)return this.enableAudioVolumeEvaluation_=!1,yt.clearTask(this.audioVolumeIntervalId_),void(this.audioVolumeIntervalId_=null);v=Math.floor(Math.max(v,16)),q.emit(qf,{interval:v}),this.audioVolumeIntervalId_&&(yt.clearTask(this.audioVolumeIntervalId_),this.audioVolumeIntervalId_=null),this.enableAudioVolumeEvaluation_=!0,this.audioVolumeIntervalId_=yt.run(rl,function(){var C=[];if(T.localStream_){var O=Math.floor(100*T.localStream_.getAudioLevel());C.push({userId:T.userId_,audioVolume:O,stream:T.localStream_})}T.connections_.forEach(function(F){var K=F.getSubscribedMainStream();if(K){var re=Math.floor(100*K.getAudioLevel());C.push({userId:F.getUserId(),audioVolume:re,stream:K})}}),T.emitter_.emit(ct.AUDIO_VOLUME,{result:C})},{fps:1e3/v,backgroundTask:E})}},{key:"callExperimentalAPI",value:function(T,v){return K7.call(T,H({client:this},v))}},{key:"setProperty",value:function(T,v){var E="".concat(T,"_");ve(this[E])||(this[E]=v)}},{key:"uploadAllCallStats",value:function(){var T=this;this.callDurationCalculator_.getDurationMap().forEach(function(v,E){var C={userId:v.userId,type:v.type,duration:T.callDurationCalculator_.getDuration(E,xe),dataFreeze:T.badCaseDetector_.getDataFreezeDuration(E).dataFreeze,renderFreeze:T.badCaseDetector_.getRenderFreezeDuration(E).renderFreeze};Ie.uploadEvent({log:"callStats-"+JSON.stringify(C),userId:T.userId_})}),this.badCaseDetector_.stop(),this.callDurationCalculator_.reset()}},{key:"enableSmallStream",value:(o=N(p().mark(function T(){return p().wrap(function(v){for(;;)switch(v.prev=v.next){case 0:if(!this.isPublished()&&!this.isPublishing_){v.next=2;break}throw new ee({code:Y.INVALID_OPERATION,message:ne({key:t4})});case 2:if(!UT()){v.next=7;break}this.setIsEnableSmallStream(!0),this.log_.info("SmallStream successfully enabled"),v.next=8;break;case 7:throw new ee({code:Y.INVALID_OPERATION,message:ne({key:r4})});case 8:case"end":return v.stop()}},T,this)})),function(){return o.apply(this,arguments)})},{key:"disableSmallStream",value:(i=N(p().mark(function T(){return p().wrap(function(v){for(;;)switch(v.prev=v.next){case 0:if(!this.isPublished()&&!this.isPublishing_){v.next=2;break}throw new ee({code:Y.INVALID_OPERATION,message:ne({key:n4})});case 2:this.setIsEnableSmallStream(!1),this.log_.info("SmallStream successfully disabled");case 4:case"end":return v.stop()}},T,this)})),function(){return i.apply(this,arguments)})},{key:"setSmallStreamProfile",value:function(T){var v=this;T&&T.framerate&&(T.frameRate=T.framerate),T.width*T.height>307200&&(T.width=320,T.height=240,this.log_.info("Small stream resolution is beyond limitation, which is invalid. Reset to 320 * 240")),Object.keys(this.smallStreamConfig_).forEach(function(re){T[re]&&(v.smallStreamConfig_[re]=T[re])});var E=this.smallStreamConfig_,C=E.width,O=E.height,F=E.bitrate,K=E.frameRate;if(this.log_.info("setSmallStreamProfile: bitrate=".concat(F,", frameRate=").concat(K,", height=").concat(O,", width=").concat(C)),C<0||O<0||F<0||K<0)throw new ee({code:Y.INVALID_PARAMETER,message:ne({key:i4})})}},{key:"setRemoteVideoStreamType",value:(r=N(p().mark(function T(v,E){return p().wrap(function(C){for(;;)switch(C.prev=C.next){case 0:if(v instanceof Zv){C.next=2;break}throw new ee({code:Y.INVALID_PARAMETER,message:ne({key:a4})});case 2:if(v.getConnection()){C.next=4;break}throw new ee({code:Y.INVALID_OPERATION,message:ne({key:df})});case 4:if(v.getType()!==Dt){C.next=6;break}return C.abrupt("return");case 6:C.t0=E,C.next=C.t0===Jb||C.t0===Kb?9:12;break;case 9:return C.next=11,this.changeVideoType(v,E);case 11:case 12:return C.abrupt("break",13);case 13:case"end":return C.stop()}},T,this)})),function(T,v){return r.apply(this,arguments)})},{key:"changeVideoType",value:(n=N(p().mark(function T(v,E){var C,O;return p().wrap(function(F){for(;;)switch(F.prev=F.next){case 0:C=v.getUserId(),O={stream:v,options:{video:E===Jb,smallVideo:E===Kb},isSubscribing:!1,reSubscribeCount:10},this.changeBigSmallRecords_.set(C,O),this.log_.info("set [".concat(C,"] ").concat(v.getType()," stream video prefer type: ").concat(E));case 5:case"end":return F.stop()}},T,this)})),function(T,v){return n.apply(this,arguments)})},{key:"checkSubscribeBigSmallVideo",value:(t=N(p().mark(function T(v,E){var C,O,F,K,re,ce,ge,Ye,Ve,Ge,Ke;return p().wrap(function(He){for(;;)switch(He.prev=He.next){case 0:if(v!=null&&v.isBigStreamSubscribed||v!=null&&v.isSmallStreamSubscribed){He.next=2;break}return He.abrupt("return");case 2:if(C=v.getUserId(),this.changeBigSmallRecords_.has(C)){He.next=5;break}return He.abrupt("return");case 5:if(O=this.changeBigSmallRecords_.get(C),F=v.getSubscribeState(),K=F.video,re=F.smallVideo,ce=O.stream,ge=O.options,Ye=O.isSubscribing,Ve=O.reSubscribeCount,!(ge.video&&K||ge.smallVideo&&re&&E)){He.next=10;break}return He.abrupt("return");case 10:if(Ge={video:ge.video,smallVideo:ge.smallVideo},!(E&&v.isBigStreamSubscribed||v.isSmallStreamSubscribed)){He.next=31;break}if(He.prev=12,!(ge&&ce&&!Ye&&Ve>=1)){He.next=24;break}return O.isSubscribing=!0,O.reSubscribeCount=Ve-1,Ke=ce.getConnection(),!E&&Ke.isSmallStreamSubscribed&&(Ge={video:!0,smallVideo:!1}),Ge.emitEvent=!1,He.next=21,Ke==null?void 0:Ke.subscribe(ce,Ge);case 21:this.log_.info("change [".concat(C,"] to ").concat(Ge.smallVideo?"small":"big"," video successfully. count ").concat(10-O.reSubscribeCount,".")),O.isSubscribing=!1,O.reSubscribeCount=10;case 24:He.next=31;break;case 26:He.prev=26,He.t0=He.catch(12),this.log_.info("change [".concat(C,"] to ").concat(Ge.smallVideo?"small":"big"," video failed. count ").concat(10-O.reSubscribeCount,".")),O.isSubscribing=!1,Ve===0&&this.changeBigSmallRecords_.delete(C);case 31:case"end":return He.stop()}},T,this,[[12,26]])})),function(T,v){return t.apply(this,arguments)})},{key:"setIsEnableSmallStream",value:function(T){this.isEnableSmallStream_=T}},{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 T=be(this.connections_.values());return this.uplinkConnection_&&T.push(this.uplinkConnection_),T}},{key:"isRelayMaybeFailed",value:function(){if(!this.signalChannel_.isOnline)return!1;var T=this.getAllConnections();if(T.length===0)return!1;for(var v=0;v<T.length;v++)if(T[v].getReconnectionCount()<6)return!1;return!0}},{key:"getUseStringRoomId",value:function(){return this.useStringRoomId_}},{key:"checkConnectionsToReconnect",value:function(){var T=this;this.getAllConnections().forEach(function(v){if(!v.getIsReconnecting()){var E=v.getPeerConnection();E&&E.connectionState===Yp&&(T.log_.warn("[".concat(v.getUserId(),"] pc is closed but not reconnect")),v.startReconnection())}})}},{key:"getEnableAutoPlayDialog",value:function(){return this.enableAutoPlayDialog_}},{key:"sendSEIMessage",value:function(T,v){this.uplinkConnection_.sendSEI(T,v)}},{key:"setProxyServer",value:function(T){if(this.log_.info("set proxy server: ".concat(JSON.stringify(T))),Ft(T)){if(!T.startsWith("wss://"))throw new ee({code:Y.INVALID_PARAMETER,message:ne({key:D3})});this.proxy_=T}else if(na(T)){var v=T.websocketProxy,E=T.loggerProxy,C=T.scheduleProxy,O=T.unifiedProxy;v&&(this.proxy_=v),E&&Xp(E),C&&Xb(C),O&&(this.unifiedProxy_=O,Xp("https://".concat(O)),Xb(O))}}},{key:"setTurnServer",value:function(T){this.log_.info("set turn server: "+JSON.stringify(T));var v=[];Array.isArray(T)?T.forEach(function(E){return v.push(Nk(E))}):na(T)&&v.push(Nk(T)),this.turnServers_=v}},{key:"get2k4kFlag",value:function(){var T,v;return(T=this.schedule_)===null||T===void 0||(v=T.trtcCapability)===null||v===void 0?void 0:v["2k4k"]}}]),e}(),W(Ae.prototype,"join",[sw,cw],Object.getOwnPropertyDescriptor(Ae.prototype,"join"),Ae.prototype),W(Ae.prototype,"leave",[uw],Object.getOwnPropertyDescriptor(Ae.prototype,"leave"),Ae.prototype),W(Ae.prototype,"getUserList",[lw],Object.getOwnPropertyDescriptor(Ae.prototype,"getUserList"),Ae.prototype),W(Ae.prototype,"publish",[dw,hw,pw],Object.getOwnPropertyDescriptor(Ae.prototype,"publish"),Ae.prototype),W(Ae.prototype,"unpublish",[fw,mw],Object.getOwnPropertyDescriptor(Ae.prototype,"unpublish"),Ae.prototype),W(Ae.prototype,"subscribe",[vw],Object.getOwnPropertyDescriptor(Ae.prototype,"subscribe"),Ae.prototype),W(Ae.prototype,"unsubscribe",[gw],Object.getOwnPropertyDescriptor(Ae.prototype,"unsubscribe"),Ae.prototype),W(Ae.prototype,"switchRole",[_w,yw,Sw],Object.getOwnPropertyDescriptor(Ae.prototype,"switchRole"),Ae.prototype),W(Ae.prototype,"startPublishCDNStream",[bw,kw],Object.getOwnPropertyDescriptor(Ae.prototype,"startPublishCDNStream"),Ae.prototype),W(Ae.prototype,"stopPublishCDNStream",[Tw],Object.getOwnPropertyDescriptor(Ae.prototype,"stopPublishCDNStream"),Ae.prototype),W(Ae.prototype,"startMixTranscode",[xw,Iw],Object.getOwnPropertyDescriptor(Ae.prototype,"startMixTranscode"),Ae.prototype),W(Ae.prototype,"stopMixTranscode",[ww],Object.getOwnPropertyDescriptor(Ae.prototype,"stopMixTranscode"),Ae.prototype),W(Ae.prototype,"enableAudioVolumeEvaluation",[Ew],Object.getOwnPropertyDescriptor(Ae.prototype,"enableAudioVolumeEvaluation"),Ae.prototype),W(Ae.prototype,"enableSmallStream",[Cw],Object.getOwnPropertyDescriptor(Ae.prototype,"enableSmallStream"),Ae.prototype),W(Ae.prototype,"disableSmallStream",[Rw],Object.getOwnPropertyDescriptor(Ae.prototype,"disableSmallStream"),Ae.prototype),W(Ae.prototype,"setSmallStreamProfile",[Aw],Object.getOwnPropertyDescriptor(Ae.prototype,"setSmallStreamProfile"),Ae.prototype),W(Ae.prototype,"setRemoteVideoStreamType",[Pw],Object.getOwnPropertyDescriptor(Ae.prototype,"setRemoteVideoStreamType"),Ae.prototype),W(Ae.prototype,"sendSEIMessage",[Dw,Lw,Ow],Object.getOwnPropertyDescriptor(Ae.prototype,"sendSEIMessage"),Ae.prototype),W(Ae.prototype,"setProxyServer",[Mw],Object.getOwnPropertyDescriptor(Ae.prototype,"setProxyServer"),Ae.prototype),W(Ae.prototype,"setTurnServer",[Nw],Object.getOwnPropertyDescriptor(Ae.prototype,"setTurnServer"),Ae.prototype),Ae),X7=0,Q7=0,Y7=(Vw=kt(ec),Uw=kt(ec),Bw=kt(ec),jw=nd(Yt.TRTC.createClient),Fw=kt(ec),Gw=nd(Yt.TRTC.createStream),$t=function(){function e(){J(this,e),this.name_=ec,this.VERSION=Vi,this.Logger={loggerManager:ke,LogLevel:Un,setLogLevel:function(n){ke.setLogLevel(n),n<=1&&IV()},enableUploadLog:function(){Ii.handleFunctionState({fnName:"TRTC.enableUploadLog"}),ke.enableUploadLog()},disableUploadLog:function(){ke.warn("disableUploadLog"),Ii.handleFunctionState({fnName:"TRTC.disableUploadLog"}),ke.disableUploadLog()}}}var t;return ye(e,[{key:"checkSystemRequirements",value:(t=N(p().mark(function n(){return p().wrap(function(r){for(;;)switch(r.prev=r.next){case 0:return r.next=2,Am();case 2:return r.abrupt("return",r.sent);case 3:case"end":return r.stop()}},n)})),function(){return t.apply(this,arguments)})},{key:"isScreenShareSupported",value:function(){return OT()}},{key:"isSmallStreamSupported",value:function(){return UT()}},{key:"getDevices",value:function(){return Um()}},{key:"getCameras",value:function(){return function(){return Vm.apply(this,arguments)}()}},{key:"getMicrophones",value:function(){return GT()}},{key:"getSpeakers",value:function(){return function(){return Fm.apply(this,arguments)}()}},{key:"createClient",value:function(n){Jk&&(Jk=!1,ke.getLogLevel()!=Tt.Logger.LogLevel.NONE&&(console.info("******************************************************************************"),console.info("* TRTC Web SDK"),console.info("* API Document: "+"".concat(uf,"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("******************************************************************************")),ke.info("TRTC Web SDK Version: 4.15.10"),ke.info("UserAgent: "+navigator.userAgent),ke.info("URL of current page: "+location.href));var r={version:this.VERSION},i=new q7(H(H(H({},r),n),{},{seq:++X7}));return q.emit(Hk,{client:i}),i}},{key:"createStream",value:function(n){return new f7(H(H({},n),{},{seq:++Q7}))}}]),e}(),W($t.prototype,"checkSystemRequirements",[Vw],Object.getOwnPropertyDescriptor($t.prototype,"checkSystemRequirements"),$t.prototype),W($t.prototype,"isScreenShareSupported",[Uw],Object.getOwnPropertyDescriptor($t.prototype,"isScreenShareSupported"),$t.prototype),W($t.prototype,"isSmallStreamSupported",[Bw],Object.getOwnPropertyDescriptor($t.prototype,"isSmallStreamSupported"),$t.prototype),W($t.prototype,"createClient",[jw,Fw],Object.getOwnPropertyDescriptor($t.prototype,"createClient"),$t.prototype),W($t.prototype,"createStream",[Gw],Object.getOwnPropertyDescriptor($t.prototype,"createStream"),$t.prototype),$t),Tt=new Y7;return Tt})});var mg=dg((y9,fg)=>{"use strict";var Oo=typeof Reflect=="object"?Reflect:null,qw=Oo&&typeof Oo.apply=="function"?Oo.apply:function(H,p,V){return Function.prototype.apply.call(H,p,V)},Sd;Oo&&typeof Oo.ownKeys=="function"?Sd=Oo.ownKeys:Object.getOwnPropertySymbols?Sd=function(H){return Object.getOwnPropertyNames(H).concat(Object.getOwnPropertySymbols(H))}:Sd=function(H){return Object.getOwnPropertyNames(H)};function o9(Z){console&&console.warn&&console.warn(Z)}var Qw=Number.isNaN||function(H){return H!==H};function ft(){ft.init.call(this)}fg.exports=ft;fg.exports.once=l9;ft.EventEmitter=ft;ft.prototype._events=void 0;ft.prototype._eventsCount=0;ft.prototype._maxListeners=void 0;var Xw=10;function bd(Z){if(typeof Z!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof Z)}Object.defineProperty(ft,"defaultMaxListeners",{enumerable:!0,get:function(){return Xw},set:function(Z){if(typeof Z!="number"||Z<0||Qw(Z))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+Z+".");Xw=Z}});ft.init=function(){(this._events===void 0||this._events===Object.getPrototypeOf(this)._events)&&(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0};ft.prototype.setMaxListeners=function(H){if(typeof H!="number"||H<0||Qw(H))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+H+".");return this._maxListeners=H,this};function Yw(Z){return Z._maxListeners===void 0?ft.defaultMaxListeners:Z._maxListeners}ft.prototype.getMaxListeners=function(){return Yw(this)};ft.prototype.emit=function(H){for(var p=[],V=1;V<arguments.length;V++)p.push(arguments[V]);var X=H==="error",N=this._events;if(N!==void 0)X=X&&N.error===void 0;else if(!X)return!1;if(X){var J;if(p.length>0&&(J=p[0]),J instanceof Error)throw J;var Pe=new Error("Unhandled error."+(J?" ("+J.message+")":""));throw Pe.context=J,Pe}var ye=N[H];if(ye===void 0)return!1;if(typeof ye=="function")qw(ye,this,p);else for(var ut=ye.length,Nt=nE(ye,ut),V=0;V<ut;++V)qw(Nt[V],this,p);return!0};function $w(Z,H,p,V){var X,N,J;if(bd(p),N=Z._events,N===void 0?(N=Z._events=Object.create(null),Z._eventsCount=0):(N.newListener!==void 0&&(Z.emit("newListener",H,p.listener?p.listener:p),N=Z._events),J=N[H]),J===void 0)J=N[H]=p,++Z._eventsCount;else if(typeof J=="function"?J=N[H]=V?[p,J]:[J,p]:V?J.unshift(p):J.push(p),X=Yw(Z),X>0&&J.length>X&&!J.warned){J.warned=!0;var Pe=new Error("Possible EventEmitter memory leak detected. "+J.length+" "+String(H)+" listeners added. Use emitter.setMaxListeners() to increase limit");Pe.name="MaxListenersExceededWarning",Pe.emitter=Z,Pe.type=H,Pe.count=J.length,o9(Pe)}return Z}ft.prototype.addListener=function(H,p){return $w(this,H,p,!1)};ft.prototype.on=ft.prototype.addListener;ft.prototype.prependListener=function(H,p){return $w(this,H,p,!0)};function s9(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length===0?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function Zw(Z,H,p){var V={fired:!1,wrapFn:void 0,target:Z,type:H,listener:p},X=s9.bind(V);return X.listener=p,V.wrapFn=X,X}ft.prototype.once=function(H,p){return bd(p),this.on(H,Zw(this,H,p)),this};ft.prototype.prependOnceListener=function(H,p){return bd(p),this.prependListener(H,Zw(this,H,p)),this};ft.prototype.removeListener=function(H,p){var V,X,N,J,Pe;if(bd(p),X=this._events,X===void 0)return this;if(V=X[H],V===void 0)return this;if(V===p||V.listener===p)--this._eventsCount===0?this._events=Object.create(null):(delete X[H],X.removeListener&&this.emit("removeListener",H,V.listener||p));else if(typeof V!="function"){for(N=-1,J=V.length-1;J>=0;J--)if(V[J]===p||V[J].listener===p){Pe=V[J].listener,N=J;break}if(N<0)return this;N===0?V.shift():c9(V,N),V.length===1&&(X[H]=V[0]),X.removeListener!==void 0&&this.emit("removeListener",H,Pe||p)}return this};ft.prototype.off=ft.prototype.removeListener;ft.prototype.removeAllListeners=function(H){var p,V,X;if(V=this._events,V===void 0)return this;if(V.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):V[H]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete V[H]),this;if(arguments.length===0){var N=Object.keys(V),J;for(X=0;X<N.length;++X)J=N[X],J!=="removeListener"&&this.removeAllListeners(J);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(p=V[H],typeof p=="function")this.removeListener(H,p);else if(p!==void 0)for(X=p.length-1;X>=0;X--)this.removeListener(H,p[X]);return this};function eE(Z,H,p){var V=Z._events;if(V===void 0)return[];var X=V[H];return X===void 0?[]:typeof X=="function"?p?[X.listener||X]:[X]:p?u9(X):nE(X,X.length)}ft.prototype.listeners=function(H){return eE(this,H,!0)};ft.prototype.rawListeners=function(H){return eE(this,H,!1)};ft.listenerCount=function(Z,H){return typeof Z.listenerCount=="function"?Z.listenerCount(H):tE.call(Z,H)};ft.prototype.listenerCount=tE;function tE(Z){var H=this._events;if(H!==void 0){var p=H[Z];if(typeof p=="function")return 1;if(p!==void 0)return p.length}return 0}ft.prototype.eventNames=function(){return this._eventsCount>0?Sd(this._events):[]};function nE(Z,H){for(var p=new Array(H),V=0;V<H;++V)p[V]=Z[V];return p}function c9(Z,H){for(;H+1<Z.length;H++)Z[H]=Z[H+1];Z.pop()}function u9(Z){for(var H=new Array(Z.length),p=0;p<H.length;++p)H[p]=Z[p].listener||Z[p];return H}function l9(Z,H){return new Promise(function(p,V){function X(J){Z.removeListener(H,N),V(J)}function N(){typeof Z.removeListener=="function"&&Z.removeListener("error",X),p([].slice.call(arguments))}rE(Z,H,N,{once:!0}),H!=="error"&&d9(Z,X,{once:!0})})}function d9(Z,H,p){typeof Z.on=="function"&&rE(Z,"error",H,p)}function rE(Z,H,p,V){if(typeof Z.on=="function")V.once?Z.once(H,p):Z.on(H,p);else if(typeof Z.addEventListener=="function")Z.addEventListener(H,function X(N){V.once&&Z.removeEventListener(H,X),p(N)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof Z)}});var aE=dg((vg,gg)=>{(function(Z,H){typeof vg=="object"&&typeof gg!="undefined"?gg.exports=H(Rr()):typeof define=="function"&&define.amd?define(["trtc-js-sdk"],H):(Z=typeof globalThis!="undefined"?globalThis:Z||self).RTCBeautyPlugin=H(Z.TRTC)})(vg,function(Z){function H(se){return se&&typeof se=="object"&&"default"in se?se:{default:se}}var p=H(Z);function V(){V=function(){return se};var se={},Te=Object.prototype,be=Te.hasOwnProperty,Be=typeof Symbol=="function"?Symbol:{},ze=Be.iterator||"@@iterator",ie=Be.asyncIterator||"@@asyncIterator",W=Be.toStringTag||"@@toStringTag";function ae(de,le,Ne){return Object.defineProperty(de,le,{value:Ne,enumerable:!0,configurable:!0,writable:!0}),de[le]}try{ae({},"")}catch(de){ae=function(le,Ne,Je){return le[Ne]=Je}}function B(de,le,Ne,Je){var De=le&&le.prototype instanceof oe?le:oe,lt=Object.create(De.prototype),it=new et(Je||[]);return lt._invoke=function(Vt,en,pe){var Lt="suspendedStart";return function(qt,lr){if(Lt==="executing")throw new Error("Generator is already running");if(Lt==="completed"){if(qt==="throw")throw lr;return Kn()}for(pe.method=qt,pe.arg=lr;;){var wi=pe.delegate;if(wi){var yn=ur(wi,pe);if(yn){if(yn===Se)continue;return yn}}if(pe.method==="next")pe.sent=pe._sent=pe.arg;else if(pe.method==="throw"){if(Lt==="suspendedStart")throw Lt="completed",pe.arg;pe.dispatchException(pe.arg)}else pe.method==="return"&&pe.abrupt("return",pe.arg);Lt="executing";var Ct=te(Vt,en,pe);if(Ct.type==="normal"){if(Lt=pe.done?"completed":"suspendedYield",Ct.arg===Se)continue;return{value:Ct.arg,done:pe.done}}Ct.type==="throw"&&(Lt="completed",pe.method="throw",pe.arg=Ct.arg)}}}(de,Ne,it),lt}function te(de,le,Ne){try{return{type:"normal",arg:de.call(le,Ne)}}catch(Je){return{type:"throw",arg:Je}}}se.wrap=B;var Se={};function oe(){}function _e(){}function Oe(){}var Jt={};ae(Jt,ze,function(){return this});var Zt=Object.getPrototypeOf,Qe=Zt&&Zt(Zt(zt([])));Qe&&Qe!==Te&&be.call(Qe,ze)&&(Jt=Qe);var Kt=Oe.prototype=oe.prototype=Object.create(Jt);function ht(de){["next","throw","return"].forEach(function(le){ae(de,le,function(Ne){return this._invoke(le,Ne)})})}function Jn(de,le){function Ne(De,lt,it,Vt){var en=te(de[De],de,lt);if(en.type!=="throw"){var pe=en.arg,Lt=pe.value;return Lt&&typeof Lt=="object"&&be.call(Lt,"__await")?le.resolve(Lt.__await).then(function(qt){Ne("next",qt,it,Vt)},function(qt){Ne("throw",qt,it,Vt)}):le.resolve(Lt).then(function(qt){pe.value=qt,it(pe)},function(qt){return Ne("throw",qt,it,Vt)})}Vt(en.arg)}var Je;this._invoke=function(De,lt){function it(){return new le(function(Vt,en){Ne(De,lt,Vt,en)})}return Je=Je?Je.then(it,it):it()}}function ur(de,le){var Ne=de.iterator[le.method];if(Ne===void 0){if(le.delegate=null,le.method==="throw"){if(de.iterator.return&&(le.method="return",le.arg=void 0,ur(de,le),le.method==="throw"))return Se;le.method="throw",le.arg=new TypeError("The iterator does not provide a 'throw' method")}return Se}var Je=te(Ne,de.iterator,le.arg);if(Je.type==="throw")return le.method="throw",le.arg=Je.arg,le.delegate=null,Se;var De=Je.arg;return De?De.done?(le[de.resultName]=De.value,le.next=de.nextLoc,le.method!=="return"&&(le.method="next",le.arg=void 0),le.delegate=null,Se):De:(le.method="throw",le.arg=new TypeError("iterator result is not an object"),le.delegate=null,Se)}function Ht(de){var le={tryLoc:de[0]};1 in de&&(le.catchLoc=de[1]),2 in de&&(le.finallyLoc=de[2],le.afterLoc=de[3]),this.tryEntries.push(le)}function An(de){var le=de.completion||{};le.type="normal",delete le.arg,de.completion=le}function et(de){this.tryEntries=[{tryLoc:"root"}],de.forEach(Ht,this),this.reset(!0)}function zt(de){if(de){var le=de[ze];if(le)return le.call(de);if(typeof de.next=="function")return de;if(!isNaN(de.length)){var Ne=-1,Je=function De(){for(;++Ne<de.length;)if(be.call(de,Ne))return De.value=de[Ne],De.done=!1,De;return De.value=void 0,De.done=!0,De};return Je.next=Je}}return{next:Kn}}function Kn(){return{value:void 0,done:!0}}return _e.prototype=Oe,ae(Kt,"constructor",Oe),ae(Oe,"constructor",_e),_e.displayName=ae(Oe,W,"GeneratorFunction"),se.isGeneratorFunction=function(de){var le=typeof de=="function"&&de.constructor;return!!le&&(le===_e||(le.displayName||le.name)==="GeneratorFunction")},se.mark=function(de){return Object.setPrototypeOf?Object.setPrototypeOf(de,Oe):(de.__proto__=Oe,ae(de,W,"GeneratorFunction")),de.prototype=Object.create(Kt),de},se.awrap=function(de){return{__await:de}},ht(Jn.prototype),ae(Jn.prototype,ie,function(){return this}),se.AsyncIterator=Jn,se.async=function(de,le,Ne,Je,De){De===void 0&&(De=Promise);var lt=new Jn(B(de,le,Ne,Je),De);return se.isGeneratorFunction(le)?lt:lt.next().then(function(it){return it.done?it.value:lt.next()})},ht(Kt),ae(Kt,W,"Generator"),ae(Kt,ze,function(){return this}),ae(Kt,"toString",function(){return"[object Generator]"}),se.keys=function(de){var le=[];for(var Ne in de)le.push(Ne);return le.reverse(),function Je(){for(;le.length;){var De=le.pop();if(De in de)return Je.value=De,Je.done=!1,Je}return Je.done=!0,Je}},se.values=zt,et.prototype={constructor:et,reset:function(de){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(An),!de)for(var le in this)le.charAt(0)==="t"&&be.call(this,le)&&!isNaN(+le.slice(1))&&(this[le]=void 0)},stop:function(){this.done=!0;var de=this.tryEntries[0].completion;if(de.type==="throw")throw de.arg;return this.rval},dispatchException:function(de){if(this.done)throw de;var le=this;function Ne(en,pe){return lt.type="throw",lt.arg=de,le.next=en,pe&&(le.method="next",le.arg=void 0),!!pe}for(var Je=this.tryEntries.length-1;Je>=0;--Je){var De=this.tryEntries[Je],lt=De.completion;if(De.tryLoc==="root")return Ne("end");if(De.tryLoc<=this.prev){var it=be.call(De,"catchLoc"),Vt=be.call(De,"finallyLoc");if(it&&Vt){if(this.prev<De.catchLoc)return Ne(De.catchLoc,!0);if(this.prev<De.finallyLoc)return Ne(De.finallyLoc)}else if(it){if(this.prev<De.catchLoc)return Ne(De.catchLoc,!0)}else{if(!Vt)throw new Error("try statement without catch or finally");if(this.prev<De.finallyLoc)return Ne(De.finallyLoc)}}}},abrupt:function(de,le){for(var Ne=this.tryEntries.length-1;Ne>=0;--Ne){var Je=this.tryEntries[Ne];if(Je.tryLoc<=this.prev&&be.call(Je,"finallyLoc")&&this.prev<Je.finallyLoc){var De=Je;break}}De&&(de==="break"||de==="continue")&&De.tryLoc<=le&&le<=De.finallyLoc&&(De=null);var lt=De?De.completion:{};return lt.type=de,lt.arg=le,De?(this.method="next",this.next=De.finallyLoc,Se):this.complete(lt)},complete:function(de,le){if(de.type==="throw")throw de.arg;return de.type==="break"||de.type==="continue"?this.next=de.arg:de.type==="return"?(this.rval=this.arg=de.arg,this.method="return",this.next="end"):de.type==="normal"&&le&&(this.next=le),Se},finish:function(de){for(var le=this.tryEntries.length-1;le>=0;--le){var Ne=this.tryEntries[le];if(Ne.finallyLoc===de)return this.complete(Ne.completion,Ne.afterLoc),An(Ne),Se}},catch:function(de){for(var le=this.tryEntries.length-1;le>=0;--le){var Ne=this.tryEntries[le];if(Ne.tryLoc===de){var Je=Ne.completion;if(Je.type==="throw"){var De=Je.arg;An(Ne)}return De}}throw new Error("illegal catch attempt")},delegateYield:function(de,le,Ne){return this.delegate={iterator:zt(de),resultName:le,nextLoc:Ne},this.method==="next"&&(this.arg=void 0),Se}},se}function X(se){return X=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(Te){return typeof Te}:function(Te){return Te&&typeof Symbol=="function"&&Te.constructor===Symbol&&Te!==Symbol.prototype?"symbol":typeof Te},X(se)}function N(se,Te,be,Be,ze,ie,W){try{var ae=se[ie](W),B=ae.value}catch(te){return void be(te)}ae.done?Te(B):Promise.resolve(B).then(Be,ze)}function J(se){return function(){var Te=this,be=arguments;return new Promise(function(Be,ze){var ie=se.apply(Te,be);function W(B){N(ie,Be,ze,W,ae,"next",B)}function ae(B){N(ie,Be,ze,W,ae,"throw",B)}W(void 0)})}}function Pe(se,Te){if(!(se instanceof Te))throw new TypeError("Cannot call a class as a function")}function ye(se,Te){for(var be=0;be<Te.length;be++){var Be=Te[be];Be.enumerable=Be.enumerable||!1,Be.configurable=!0,"value"in Be&&(Be.writable=!0),Object.defineProperty(se,Be.key,Be)}}function ut(se,Te,be){return Te&&ye(se.prototype,Te),be&&ye(se,be),Object.defineProperty(se,"prototype",{writable:!1}),se}function Nt(se,Te,be){var Be=function(te,Se,oe){var _e=new RegExp("\\b".concat(Se," \\w+ (\\w+)"),"ig");te.replace(_e,function(Oe,Jt){return oe[Jt]=0,Oe})},ze=function(te,Se,oe){var _e=te.createShader(oe);return te.shaderSource(_e,Se),te.compileShader(_e),te.getShaderParameter(_e,te.COMPILE_STATUS)?_e:(console.log(te.getShaderInfoLog(_e)),null)};this.uniform={},this.attribute={};var ie=ze(se,Te,se.VERTEX_SHADER),W=ze(se,be,se.FRAGMENT_SHADER);for(var ae in this.id=se.createProgram(),se.attachShader(this.id,ie),se.attachShader(this.id,W),se.linkProgram(this.id),se.getProgramParameter(this.id,se.LINK_STATUS)||console.log(se.getProgramInfoLog(this.id)),se.useProgram(this.id),Be(Te,"attribute",this.attribute),this.attribute)this.attribute[ae]=se.getAttribLocation(this.id,ae);for(var B in Be(Te,"uniform",this.uniform),Be(be,"uniform",this.uniform),this.uniform)this.uniform[B]=se.getUniformLocation(this.id,B)}function $e(se,Te,be,Be){for(var ze=[],ie=0;ie<Te.length;++ie)ze.push(Dc(se,Te[ie],se[cr[ie]]));return function(W,ae,B,te){var Se=W.createProgram();return ae.forEach(function(oe){W.attachShader(Se,oe)}),B&&B.forEach(function(oe,_e){W.bindAttribLocation(Se,te?te[_e]:_e,oe)}),W.linkProgram(Se),W.getProgramParameter(Se,W.LINK_STATUS)?Se:(W.deleteProgram(Se),null)}(se,ze,be,Be)}var cr=["VERTEX_SHADER","FRAGMENT_SHADER"];function Dc(se,Te,be){var Be=se.createShader(be);return se.shaderSource(Be,Te),se.compileShader(Be),se.getShaderParameter(Be,se.COMPILE_STATUS)?Be:(se.deleteShader(Be),null)}var Go=function(){function se(Te){Pe(this,se),this.canvas=Te.canvas,this.video=Te.video,this.width=Te.width||640,this.height=Te.height||480,this.vertexBuffer=null,this.currentProgram=null,this.applied=!1,this.beautyParams={beauty:.5,brightness:.5,ruddy:.5},this.gl=this.createGL(Te.canvas),this.sourceTexture=this.gl.createTexture()}return ut(se,[{key:"setRect",value:function(Te,be){this.width=Te,this.height=be}},{key:"apply",value:function(Te){if(!this.vertexBuffer){var be=new Float32Array([-1,-1,0,1,1,-1,1,1,-1,1,0,0,-1,1,0,0,1,-1,1,1,1,1,1,0]);this.vertexBuffer=this.gl.createBuffer(),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this.vertexBuffer),this.gl.bufferData(this.gl.ARRAY_BUFFER,be,this.gl.STATIC_DRAW),this.gl.pixelStorei(this.gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!0)}this.gl.viewport(0,0,this.width,this.height),this.gl.bindTexture(this.gl.TEXTURE_2D,this.sourceTexture),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_WRAP_S,this.gl.CLAMP_TO_EDGE),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_WRAP_T,this.gl.CLAMP_TO_EDGE),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_MIN_FILTER,this.gl.NEAREST),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_MAG_FILTER,this.gl.NEAREST),this.applied?this.gl.texSubImage2D(this.gl.TEXTURE_2D,0,0,0,this.gl.RGB,this.gl.UNSIGNED_BYTE,Te):(this.gl.texImage2D(this.gl.TEXTURE_2D,0,this.gl.RGB,this.gl.RGB,this.gl.UNSIGNED_BYTE,Te),this.applied=!0);var Be=this.beautyParams,ze=Be.beauty,ie=Be.brightness,W=Be.ruddy,ae=2/this.width,B=2/this.height,te=this.compileBeautyShader();this.gl.uniform2f(te.uniform.singleStepOffset,ae,B);var Se=new Float32Array([1-.8*ze,1-.6*ze,.1+.45*W,.1+.45*W]);this.gl.uniform4fv(te.uniform.params,Se),this.gl.uniform1f(te.uniform.brightness,.12*ie),this.gl.bindTexture(this.gl.TEXTURE_2D,this.sourceTexture),this.gl.bindFramebuffer(this.gl.FRAMEBUFFER,null),this.gl.uniform1f(this.currentProgram.uniform.flipY,1),this.gl.drawArrays(this.gl.TRIANGLES,0,6)}},{key:"compileBeautyShader",value:function(){if(this.currentProgram)return this.currentProgram;this.currentProgram=new Nt(this.gl,["precision highp float;","attribute vec2 pos;","attribute vec2 uv;","varying vec2 vUv;","uniform float flipY;","void main(void) {","vUv = uv;","gl_Position = vec4(pos.x, pos.y*flipY, 0.0, 1.);","}"].join(`
67
+ b=`+R+":"+b+`\r
68
+ `)}},{key:"removeBandwidthRestriction",value:function(_){return _.replace(/b=AS:.*\r\n/,"").replace(/b=TIAS:.*\r\n/,"")}},{key:"removeVideoOrientation",value:function(_){return _.replace(/urn:3gpp:video-orientation/,"")}},{key:"connect",value:(o=H(f().mark(function _(){return f().wrap(function(b){for(;;)switch(b.prev=b.next){case 0:return b.prev=0,b.next=3,this.exchangeSDP();case 3:return b.next=5,this.waitForPeerConnectionConnected();case 5:b.next=11;break;case 7:throw b.prev=7,b.t0=b.catch(0),this.closePeerConnection(!0),b.t0;case 11:case"end":return b.stop()}},_,this,[[0,7]])})),function(){return o.apply(this,arguments)})},{key:"exchangeSDP",value:(r=H(f().mark(function _(){return f().wrap(function(b){for(;;)switch(b.prev=b.next){case 0:return b.prev=0,this.isSDPExchanging_=!0,b.next=4,this.createOffer();case 4:return this.log_.info("createOffer success, sending offer to remote server"),b.next=7,this.doExchangeSDP();case 7:this.isSDPExchanging_=!1,b.next=14;break;case 10:throw b.prev=10,b.t0=b.catch(0),this.isSDPExchanging_=!1,b.t0;case 14:case"end":return b.stop()}},_,this,[[0,10]])})),function(){return r.apply(this,arguments)})},{key:"createOffer",value:(i=H(f().mark(function _(){var b;return f().wrap(function(R){for(;;)switch(R.prev=R.next){case 0:return R.prev=0,R.next=3,this.peerConnection_.createOffer(Vx);case 3:return b=R.sent,R.next=6,this.peerConnection_.setLocalDescription(b);case 6:this.updateSSRC(b.sdp),xe.logSuccessEvent({userId:this.client_.getUserId(),eventType:qu,kind:"offer"}),R.next=14;break;case 10:throw R.prev=10,R.t0=R.catch(0),xe.logFailedEvent({userId:this.client_.getUserId(),eventType:qu,kind:"offer",error:R.t0}),R.t0;case 14:case"end":return R.stop()}},_,this,[[0,10]])})),function(){return i.apply(this,arguments)})},{key:"doExchangeSDP",value:function(){var _=this;return new Promise(function(b,R){_.exchangeSDPTimeout_=setTimeout(function(){_.signalChannel_.off(mt.PUBLISH_RESULT,P),_.clearExchangeSDPTimeout();var S=new ne({code:ee.API_CALL_TIMEOUT,message:ie({key:TN})});R(S)},1e4);var P=function(){var S=H(f().mark(function h(y){var A,D,U;return f().wrap(function(K){for(;;)switch(K.prev=K.next){case 0:if(K.prev=0,_.clearExchangeSDPTimeout(),A=y.data,D=A.code,U=A.message,D!==0){K.next=9;break}return K.next=6,_.acceptAnswer(y.data.data);case 6:b(),K.next=10;break;case 9:_.checkPublishResultCode(D,U);case 10:K.next=15;break;case 12:K.prev=12,K.t0=K.catch(0),R(K.t0);case 15:case"end":return K.stop()}},h,null,[[0,12]])}));return function(h){return S.apply(this,arguments)}}(),V={type:_.peerConnection_.localDescription.type,sdp:_.removeVideoOrientation(_.peerConnection_.localDescription.sdp),screen:(_.publishingStream_||_.localStream_).hasScreenTrack(),state:_.publishState,constraintConfig:_.mediaSettings_};_.signalChannel_.once(mt.PUBLISH_RESULT,P),_.log_.debug("sending sdp offer: "+V.sdp),_.signalChannel_.send(IU,V)})}},{key:"setSDPDirection",value:function(_,b){var R=arguments.length>2&&arguments[2]!==void 0?arguments[2]:"all",P=Br(_);return P.media.forEach(function(V){R!=="all"&&V.type!==R||(V.direction=b)}),mo(P)}},{key:"acceptAnswer",value:(n=H(f().mark(function _(b){var R,P,V,S,h,y,A;return f().wrap(function(D){for(;;)switch(D.prev=D.next){case 0:if(D.prev=0,R=this.removeVideoOrientation(b.sdp),!(P=this.publishingStream_||this.localStream_)){D.next=15;break}if(V=P.getVideoBitrate(),S=P.getAudioBitrate(),!V){D.next=11;break}return h=this.isPublishingAuxStream_?pt:ju,D.next=10,this.setBandwidth({bandwidth:V,type:Te,sdp:R,videoType:h});case 10:R=D.sent;case 11:if(!S){D.next=15;break}return D.next=14,this.setBandwidth({bandwidth:S,type:Ee,sdp:R});case 14:R=D.sent;case 15:if(!this.client_.getIsEnableSmallStream()){D.next=20;break}return y=this.client_.smallStreamConfig,D.next=19,this.setBandwidth({bandwidth:y.bitrate,type:Te,videoType:Or,sdp:R});case 19:R=D.sent;case 20:return A={type:b.type,sdp:R},D.next=23,this.peerConnection_.setRemoteDescription(A);case 23:this.log_.debug("accepted answer: "+R),xe.logSuccessEvent({userId:this.client_.getUserId(),eventType:Pb,kind:"answer"}),D.next=32;break;case 27:throw D.prev=27,D.t0=D.catch(0),xe.logFailedEvent({userId:this.client_.getUserId(),eventType:Pb,kind:"answer",error:D.t0}),this.log_.error("failed to accept remote answer "+D.t0),D.t0;case 32:case"end":return D.stop()}},_,this,[[0,27]])})),function(_){return n.apply(this,arguments)})},{key:"sendMutedFlag",value:function(_,b){if(b!==this.localAuxStream_){var R={audio:_.audio,bigVideo:_.video,auxVideo:_.auxVideo};this.log_.info("send muted state: ".concat(JSON.stringify(R))),this.signalChannel_.send(xU,R)}}},{key:"getIsReconnecting",value:function(){return this.isReconnecting_}},{key:"reconnect",value:(t=H(f().mark(function _(){var b,R,P=this;return f().wrap(function(V){for(;;)switch(V.prev=V.next){case 0:if(this.reconnectionTimer_===-1){V.next=3;break}return this.log_.warn("reconnect() uplink is reconnecting, ignore current reconnection"),V.abrupt("return");case 3:if(!(this.reconnectionCount_>=30)){V.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(),b=new ne({code:ee.UPLINK_RECONNECTION_FAILED,message:ie({key:wN})}),xe.logFailedEvent({userId:this.client_.getUserId(),eventType:Eb,error:b}),this.addEventInternal(cV,"uplink-connection reconnect fail"),this.emitConnectionStateChangedEvent(an),this.emitter_.emit(et.ERROR,b),V.abrupt("return");case 12:if(this.signalChannel_.getCurrentState()===ac){V.next=16;break}return this.log_.warn("reconnect() signal channel is not connected, suspend reconnection until signal is connected"),this.signalChannel_.once(ic,this.reconnect,this),V.abrupt("return");case 16:if(this.reconnectionCount_++,V.prev=17,this.log_.warn("reconnect() try to reconnect uplink [".concat(this.reconnectionCount_,"/").concat(30,"]")),R=Sp(this.reconnectionCount_),this.reconnectionTimer_=setTimeout(function(){P.log_.warn("reconnect() uplink reconnect timeout(".concat(R/1e3,"s), try again")),P.clearReconnectionTimer(),P.reconnect()},R),!(this.isSDPExchanging_||this.peerConnection_&&this.peerConnection_.connectionState===Wu)){V.next=23;break}return V.abrupt("return");case 23:return V.next=25,this.signalChannel_.sendWaitForResponse({command:fk,responseCommand:mt.UNPUBLISH_RESULT,enableLog:!1});case 25:if(this.reset(),this.initialize(),!this.localStream_){V.next=30;break}return V.next=30,this.publish(this.localStream_);case 30:if(!this.localAuxStream_){V.next=33;break}return V.next=33,this.publish(this.localAuxStream_,!0);case 33:xe.logSuccessEvent({userId:this.client_.getUserId(),eventType:Eb}),this.log_.warn("reconnect() uplink reconnect successfully"),this.addEventInternal(sV,"uplink-connection reconnect success"),this.stopReconnection(),this.localStream_.syncMuteState(),V.next=42;break;case 40:V.prev=40,V.t0=V.catch(17);case 42:case"end":return V.stop()}},_,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(_){_.getCode()===ee.ICE_TRANSPORT_ERROR&&(this.isFirstConnection_&&(this.isFirstConnection_=!1,xe.logFailedEvent({userId:this.client_.getUserId(),eventType:Cb,error:_})),this.isReconnecting_||this.startReconnection())}},{key:"handleConnectionStateChange",value:function(_){_.state===fn&&this.isFirstConnection_&&(this.isFirstConnection_=!1,xe.logSuccessEvent({userId:this.client_.getUserId(),eventType:Cb}),this.addEventInternal(tV,"uplink-connection is connected"))}},{key:"updateSSRC",value:function(_){var b=this;try{Br(_).media.forEach(function(R,P){if(R.type===Ee){var V=R.ssrcs[0];V&&(b.ssrc_.audio=V.id)}else{if(b.sdpSemantics_===Hf)return void R.ssrcGroups.forEach(function(h,y){var A=Number(h.ssrcs.split(" ")[0]);y===0?b.ssrc_.video=A:y===1&&(b.ssrc_.small=A)});var S=R.ssrcs[0];if(!S)return;switch(P){case 1:b.ssrc_.video=S.id;break;case 2:b.ssrc_.small=S.id;break;case 3:b.ssrc_.auxiliary=S.id}}})}catch(R){}}},{key:"getVideoTrackId",value:function(){var _=arguments.length>0&&arguments[0]!==void 0?arguments[0]:Te;if(this.peerConnection_){var b=this.peerConnection_.getSenders();if(_===Te&&b[1]&&b[1].track)return b[1].track.id;if(_===Or&&b[2]&&b[2].track)return b[2].track.id;if(_===pt&&b[3]&&b[3].track)return b[3].track.id}if(this.localStream_&&_===Te){var R=this.localStream_.getVideoTrack();if(R)return R.id}if(this.localAuxStream_&&_===pt){var P=this.localAuxStream_.getVideoTrack();if(P)return P.id}return""}},{key:"getSSRC",value:function(){return this.ssrc_}},{key:"checkPublishResultCode",value:function(_,b){if(_!==0)throw _===1028?(this.log_.error(mi.NOT_SUPPORTED_H264ENCODE),new ne({code:ee.NOT_SUPPORTED_H264,message:ie({key:pS})})):new ne({code:ee.UNKNOWN,message:ie({key:vS,data:{signalResponse:mt.PUBLISH_RESULT,code:_,message:b}})})}},{key:"getLocalStream",value:function(){return this.localStream_}},{key:"sendSEI",value:function(_,b){this.sei_.push(_,b)}},{key:"mixAudioTrack",value:function(_,b){this.log_.info("mix audio track"),this.mixedAudioTrack_=function(R){var P=US(),V=P.createMediaStreamDestination(),S=[];R.forEach(function(y){var A=new MediaStream;A.addTrack(y);var D=P.createMediaStreamSource(A);D.connect(V),S.push(D)});var h=V.stream.getAudioTracks()[0];return Xl.set(h,{destination:V,track:h,mediaStreamSourceList:S}),h}([_,b])}},{key:"destroyMixedAudioTrack",value:function(){this.mixedAudioTrack_&&(this.log_.info("destroy audio track"),function(_){if(Xl.has(_)){var b=Xl.get(_),R=b.destination,P=b.track,V=b.mediaStreamSourceList;P.stop(),R.disconnect(),V.forEach(function(S){S.disconnect()}),Xl.delete(_)}}(this.mixedAudioTrack_),this.mixedAudioTrack_=null)}}]),j}(Mv),X(kc.prototype,"publish",[Nx],Object.getOwnPropertyDescriptor(kc.prototype,"publish"),kc.prototype),kc),bF=pe,jx=Rs,Ql=Is.exports.getWeakData,SF=ai,kF=Tt,TF=Et,Gv=at,xF=Es,Bx=kt,IF=Ke.set,wF=Ke.getterFor,CF=nn.find,EF=nn.findIndex,RF=bF([].splice),AF=0,Yl=function(e){return e.frozen||(e.frozen=new Fx)},Fx=function(){this.entries=[]},zv=function(e,t){return CF(e.entries,function(n){return n[0]===t})};Fx.prototype={get:function(e){var t=zv(this,e);if(t)return t[1]},has:function(e){return!!zv(this,e)},set:function(e,t){var n=zv(this,e);n?n[1]=t:this.entries.push([e,t])},delete:function(e){var t=EF(this.entries,function(n){return n[0]===e});return~t&&RF(this.entries,t,1),!!~t}};var Tc,PF={getConstructor:function(e,t,n,i){var r=e(function(s,l){SF(s,o),IF(s,{type:t,id:AF++,frozen:void 0}),TF(l)||xF(l,s[i],{that:s,AS_ENTRIES:n})}),o=r.prototype,c=wF(t),a=function(s,l,u){var p=c(s),k=Ql(kF(l),!0);return k===!0?Yl(p).set(l,u):k[p.id]=u,s};return jx(o,{delete:function(s){var l=c(this);if(!Gv(s))return!1;var u=Ql(s);return u===!0?Yl(l).delete(s):u&&Bx(u,l.id)&&delete u[l.id]},has:function(s){var l=c(this);if(!Gv(s))return!1;var u=Ql(s);return u===!0?Yl(l).has(s):u&&Bx(u,l.id)}}),jx(o,n?{get:function(s){var l=c(this);if(Gv(s)){var u=Ql(s);return u===!0?Yl(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}},Hx=re,$l=pe,DF=Rs,LF=Is.exports,OF=lh,Gx=PF,Zl=at,ed=Kg,td=Ke.enforce,MF=L,NF=!Hx.ActiveXObject&&"ActiveXObject"in Hx,zx=function(e){return function(){return e(this,arguments.length?arguments[0]:void 0)}},UF=OF("WeakMap",zx,Gx);if(MF&&NF){Tc=Gx.getConstructor(zx,"WeakMap",!0),LF.enable();var xc=UF.prototype,Wx=$l(xc.delete),nd=$l(xc.has),qx=$l(xc.get),Jx=$l(xc.set);DF(xc,{delete:function(e){if(Zl(e)&&!ed(e)){var t=td(this);return t.frozen||(t.frozen=new Tc),Wx(this,e)||t.frozen.delete(e)}return Wx(this,e)},has:function(e){if(Zl(e)&&!ed(e)){var t=td(this);return t.frozen||(t.frozen=new Tc),nd(this,e)||t.frozen.has(e)}return nd(this,e)},get:function(e){if(Zl(e)&&!ed(e)){var t=td(this);return t.frozen||(t.frozen=new Tc),nd(this,e)?qx(this,e):t.frozen.get(e)}return qx(this,e)},set:function(e,t){if(Zl(e)&&!ed(e)){var n=td(this);n.frozen||(n.frozen=new Tc),nd(this,e)?Jx(this,e,t):n.frozen.set(e,t)}else Jx(this,e,t);return this}})}var VF=Me,rd=zs,jF=ue,Kx=Rn,Xx=it,BF=Du,Qx=cb,FF=Xt,Wv=rd&&rd.prototype;if(VF({target:"Promise",proto:!0,real:!0,forced:!!rd&&jF(function(){Wv.finally.call({then:function(){}},function(){})})},{finally:function(e){var t=BF(this,Kx("Promise")),n=Xx(e);return this.then(n?function(i){return Qx(t,e()).then(function(){return i})}:e,n?function(i){return Qx(t,e()).then(function(){throw i})}:e)}}),Xx(rd)){var Yx=Kx("Promise").prototype.finally;Wv.finally!==Yx&&FF(Wv,"finally",Yx,{unsafe:!0})}var $x,Zx,eI,tI,or,Oo=new WeakMap;function nI(){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,p=c.reject;a.apply(l,s).then(u,p).finally(function(){var k=Oo.get(l);k&&(k.shift(),k[0]&&o(q({},k[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(Oo.has(o)){var p=Oo.get(o),k=p.length;p.push({fn:i,args:a,context:o,resolve:l,reject:u,name:t}),k===0&&r({fn:i,args:a,context:o,resolve:l,reject:u})}else Oo.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 HF=($x=nI(),Zx=Lo({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)}}),eI=nI(),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 p=setTimeout(function(){return u(new Error("".concat(n," timeout")))},e);r.apply(o,a).then(l,u).finally(function(){clearTimeout(p)})})},i}}(),or=function(e){Ct(l,e);var t,n,i,r,o,c,a,s=Er(l);function l(u){var p;return Q(this,l),(p=s.call(this,u)).remoteStreams_=new Map,p.autoSubscribe=u.autoSubscribe,p.trackState_={audio:u.trackState.audio,video:u.trackState.video,auxiliary:u.trackState.auxiliary,smallVideo:u.trackState.smallVideo},p.ssrc_={audio:0,video:0,auxiliary:0},p.subscribeState_={audio:u.autoSubscribe,video:u.autoSubscribe,auxiliary:u.autoSubscribe,smallVideo:!1},p.isSDPExchanging_=!1,p.installEvents(),p}return Ie(l,[{key:"getMixUserList",value:function(){return this.mixUserList_?this.mixUserList_.map(function(u){var p=u.userId,k=u.flag;return{userId:p,hasAudio:!!(8&k),hasVideo:!!(1&k),hasAuxiliary:!!(4&k)}}):void 0}},{key:"setMixUserList",value:function(u){(!this.mixUserList_||uo(this.mixUserList_)&&!function(p,k){if(k.length===p.length){var x,E=oe(k);try{var I=function(){var T=x.value,v=p.find(function(C){return C.userId===T.userId});if(!v||v.flag!==T.flag)return{v:!1}};for(E.s();!(x=E.n()).done;){var m=I();if(G(m)==="object")return m.v}}catch(T){E.e(T)}finally{E.f()}return!0}return!1}(this.mixUserList_,u))&&(this.mixUserList_=u,this.emitter_.emit(et.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()===Ye?!this.trackState_.audio&&!this.trackState_.video:!this.trackState_.auxiliary}},{key:"initialize",value:function(){le(Qe(l.prototype),"initialize",this).call(this),this.peerConnection_.ontrack=this.onTrack.bind(this)}},{key:"close",value:function(){var u,p,k,x=this;le(Qe(l.prototype),"close",this).call(this),this.trackState_.audio=!1,this.trackState_.video=!1,this.trackState_.smallVideo=!1,this.trackState_.auxiliary=!1,this.emitConnectionStateChangedEvent(an),u=this,p=function(E){E.fn;var I=E.args,m=E.resolve,T=E.reject,v=E.name;if(v==="subscribe"){if(!x.client_.getIsJoined())return T(new ne({code:ee.API_CALL_ABORTED,message:ie({key:tp,data:{message:"leave room",stream:I[0]}})}));if(x.isStreamUnpublished(I[0]))return T(new ne({code:ee.API_CALL_ABORTED,message:ie({key:tp,data:{message:"remote user ".concat(x.userId_," unpublished stream"),stream:I[0]}})}))}else if(v==="unsubscribe")return m();m()},(k=Oo.get(u))===null||k===void 0||k.forEach(p),Oo.delete(u),this.remoteStreams_.forEach(function(E){var I=E;I.setConnection(null),I.uninstallEvents(),I.getIsStreamAddedEventEmitted()&&x.emitter_.emit(et.STREAM_REMOVED,{stream:I})}),this.remoteStreams_.clear(),this.uninstallEvents()}},{key:"installEvents",value:function(){var u=this;Y.on(Un,this.onRemoteStreamUpdate,this),this.emitter_.on(et.ERROR,function(p){p.getCode()===ee.ICE_TRANSPORT_ERROR&&(u.isFirstConnection_&&(u.isFirstConnection_=!1,xe.logFailedEvent({userId:u.client_.getUserId(),eventType:Rb,error:p})),u.isReconnecting_||u.startReconnection())}),this.emitter_.on(et.CONNECTION_STATE_CHANGED,function(p){p.state===fn&&u.isFirstConnection_&&(u.isFirstConnection_=!1,xe.logSuccessEvent({userId:u.client_.getUserId(),eventType:Rb}),u.addEventInternal(nV,"downlink-connection is connected"))})}},{key:"uninstallEvents",value:function(){Y.removeListener(Un,this.onRemoteStreamUpdate,this)}},{key:"onRemoteStreamUpdate",value:function(u){if(this.hitTest(u.tinyId)&&u.client===this.client_){this.updateTrackState(u.action,u.kind);var p=u.kind===pt?Ks:Sr,k=this.remoteStreams_.get(p);if(!k)return;u.action===sn.ADD?this.handleRemoteAddTrack(u.kind,k):this.handleRemoteRemoveTrack(u.kind,k)}}},{key:"handleRemoteAddTrack",value:function(u,p){this.log_.info("remote add ".concat(u," track")),u===Ee?p.updateAudioPlayingState(this.subscribeState_.audio):p.updateVideoPlayingState(u===pt?this.subscribeState_.auxiliary:this.subscribeState_.video||this.subscribeState_.smallVideo),p.getIsStreamAddedEventEmitted()?this.emitter_.emit(et.STREAM_UPDATED,{stream:p}):(this.emitter_.emit(et.STREAM_ADDED,{stream:p}),this.currentState_===fn&&p.emitConnectionStateChanged({prevState:an,state:fn}))}},{key:"handleRemoteRemoveTrack",value:function(u,p){p.getIsStreamAddedEventEmitted()&&(this.log_.info("remote remove ".concat(u," track")),u===pt||!this.trackState_.audio&&!this.trackState_.video?(this.log_.info("remote stream ".concat(p.getType()," removed")),this.currentState_===fn&&p.emitConnectionStateChanged({prevState:fn,state:an}),this.emitter_.emit(et.STREAM_REMOVED,{stream:p})):(u===Ee?p.updateAudioPlayingState(!1):(u!==Bu||this.isSmallStreamSubscribed)&&p.updateVideoPlayingState(!1),this.emitter_.emit(et.STREAM_UPDATED,{stream:p})))}},{key:"updateTrackState",value:function(u,p){var k=u===sn.ADD;switch(p){case Ee:this.trackState_.audio=k;break;case Te:this.trackState_.video=k;break;case pt:this.trackState_.auxiliary=k;break;case Bu:this.trackState_.smallVideo=k}this.log_.info("trackState updated: ".concat(JSON.stringify(this.trackState_)))}},{key:"onTrack",value:function(u){var p=u.streams[0],k=u.track;if(this.log_.info("ontrack() kind: ".concat(k.kind," id: ").concat(k.id," streamId: ").concat(p.id)),this.sdpSemantics_===Qs){var x=function(v){var C=er.parse(v),O={audio:[],video:[]};return C.media.forEach(function(N){if(N.ssrcs){var j=N.ssrcs[0].id>>16&255;if(N.type===Ee)O.audio.push(Sr);else if(N.type==Te){var _=j===zM?Sr:Ks;O.video.push(_)}}}),O}(this.peerConnection_.remoteDescription.sdp);if(k.kind===Ee){if(x.audio.length===0||p.id!==Sr)return void this.log_.debug("skip this invalid audio track")}else if(x.video.indexOf(p.id)===-1)return void this.log_.debug("skip this invalid video track: ".concat(k.id," msid: ").concat(p.id))}xe.logEvent({eventType:"ontrack",kind:k.kind});var E=!1,I=this.remoteStreams_.get(p.id),m=p.id===Sr?gt:Dt;if(ge(I)&&((I=new Vv({type:m,userId:this.userId_,client:this.client_})).setConnection(this),this.remoteStreams_.set(p.id,I),E=!0),I.setMediaStream(p),k.kind===Ee?I.updateAudioPlayingState(this.subscribeState_.audio):m===gt?I.updateVideoPlayingState(this.subscribeState_.video||this.subscribeState_.smallVideo):I.updateVideoPlayingState(this.subscribeState_.auxiliary),(m!==Dt||this.trackState_.auxiliary)&&(m!==gt||this.trackState_.audio||this.trackState_.video)){var T=this.client_.getSubscriptionManager();T&&T.hasAutoRecoveryFlag(this.userId_,m)||(E?this.emitter_.emit(et.STREAM_ADDED,{stream:I}):this.emitter_.emit(et.STREAM_UPDATED,{stream:I}))}}},{key:"addRRTRLine",value:function(u){var p=u.split(`\r
69
+ `),k=new Map;p.forEach(function(v,C){/^a=rtcp-fb:/.test(v)&&p[C+1]&&!/^a=rtcp-fb:/.test(p[C+1])&&v.match(/^a=rtcp-fb:\d+/)&&k.set(C+1,v.match(/^a=rtcp-fb:\d+/)[0]+" rrtr")});for(var x=Se(k),E=0;E<x.length;E++){var I=ke(x[E],2),m=I[0],T=I[1];p.splice(m+E,0,T)}return p.join(`\r
70
+ `)}},{key:"addSPSDescription",value:function(u){var p=Br(u);return p.media.forEach(function(k){k.type===Te&&k.fmtp.forEach(function(x){x.config+=";sps-pps-idr-in-keyframe=1"})}),mo(p)}},{key:"removeSDESDescription",value:function(u){var p=["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"],k=Br(u);return k.media.forEach(function(x){x.ext=x.ext.filter(function(E){return!p.includes(E.uri)})}),mo(k)}},{key:"isSubscriptionStateNotChanged",value:function(u,p){return u.getType()===gt?(p==null?void 0:p.audio)===this.subscribeState_.audio&&(p==null?void 0:p.video)===this.subscribeState_.video&&this.isSubscribeSmall(p):u.getType()===Dt?!ge(p.video)&&this.subscribeState_.auxiliary===p.video:void 0}},{key:"isSubscribeSmall",value:function(u){return ge(u.smallVideo)&&!this.subscribeState_.smallVideo}},{key:"subscribe",value:(a=H(f().mark(function u(p,k){var x,E,I,m,T,v;return f().wrap(function(C){for(;;)switch(C.prev=C.next){case 0:if(C.prev=0,I=k.emitEvent,m=I===void 0||I,T=p.getType(),((x=this.peerConnection_)===null||x===void 0?void 0:x.connectionState)!==WM&&((E=this.peerConnection_)===null||E===void 0?void 0:E.connectionState)!==Wu){C.next=6;break}return C.next=6,this.waitForPeerConnectionConnected();case 6:if(!this.isSubscriptionStateNotChanged(p,k)){C.next=13;break}if(this.peerConnection_){C.next=11;break}return this.initialize(),C.next=11,this.connect();case 11:return m&&ge(k.smallVideo)&&this.emitter_.emit(et.STREAM_SUBSCRIBED,{stream:p,result:!0}),C.abrupt("return",p);case 13:if(T===Ye?(ge(k.audio)||(this.subscribeState_.audio=k.audio),ge(k.video)||(this.subscribeState_.video=k.video),this.subscribeState_.smallVideo=(k==null?void 0:k.smallVideo)||!1,this.addEventInternal(this.subscribeState_.audio?_k:rm,this.subscribeState_.audio?"subscribe audio":"unsubscribe audio"),this.addEventInternal(this.subscribeState_.video?_k:rm,this.subscribeState_.video?"subscribe video":"unsubscribe video"),this.addEventInternal(this.subscribeState_.smallVideo?hV:fV,this.subscribeState_.smallVideo?"subscribe smallVideo":"unsubscribe smallVideo")):ge(k.video)||(this.subscribeState_.auxiliary=k.video),this.log_.info("subscribe ".concat(T," stream with options ").concat(JSON.stringify(k)," current state: ").concat(JSON.stringify(this.subscribeState_))),!this.peerConnection_&&!this.isSDPExchanging_){C.next=23;break}return v=Ff,this.isMainStreamSubscribed||this.isAuxStreamSubscribed||(v=Bf),C.next=20,this.sendSubscription(v);case 20:T===Ye?(p.updateAudioPlayingState(this.subscribeState_.audio),p.updateVideoPlayingState(this.subscribeState_.video||this.subscribeState_.smallVideo)):p.updateVideoPlayingState(this.subscribeState_.auxiliary),C.next=26;break;case 23:return this.initialize(),C.next=26,this.connect();case 26:return m&&this.emitter_.emit(et.STREAM_SUBSCRIBED,{stream:p,result:!0}),C.abrupt("return",p);case 30:if(C.prev=30,C.t0=C.catch(0),!this.client_.getIsJoined()||!this.isStreamUnpublished(p)){C.next=35;break}throw this.log_.warn("".concat(C.t0.message," ").concat(JSON.stringify(this.trackState_))),new ne({code:ee.REMOTE_STREAM_NOT_EXIST,message:"remote user ".concat(this.userId_," unpublished stream")});case 35:throw C.t0;case 36:case"end":return C.stop()}},u,this,[[0,30]])})),function(u,p){return a.apply(this,arguments)})},{key:"unsubscribe",value:(c=H(f().mark(function u(p){var k,x,E;return f().wrap(function(I){for(;;)switch(I.prev=I.next){case 0:if((k=p.getType())!==Ye){I.next=10;break}if(this.isMainStreamSubscribed){I.next=5;break}return this.log_.info("main stream already unsubscribed"),I.abrupt("return",p);case 5:this.subscribeState_.audio=!1,this.subscribeState_.video=!1,this.subscribeState_.smallVideo=!1,I.next=14;break;case 10:if(this.isAuxStreamSubscribed){I.next=13;break}return this.log_.info("auxiliary stream already unsubscribed"),I.abrupt("return",p);case 13:this.subscribeState_.auxiliary=!1;case 14:return x=Bf,(k===gt&&this.isAuxStreamSubscribed||k===Dt&&this.isMainStreamSubscribed)&&(x=Ff),this.log_.info("unsubscribe ".concat(k," stream with ").concat(JSON.stringify(this.subscribeState_))),I.next=19,this.sendSubscription(x);case 19:return p.updateVideoPlayingState(!1),p.updateAudioPlayingState(!1),x===Bf&&((E=p.getMediaStream())&&E.getTracks().forEach(function(m){return E.removeTrack(m)}),this.closePeerConnection(),this.emitConnectionStateChangedEvent(an)),this.addEventInternal(rm,"unsubscribe audio"),this.addEventInternal(HU,"unsubscribe video"),I.abrupt("return",p);case 25:case"end":return I.stop()}},u,this)})),function(u){return c.apply(this,arguments)})},{key:"sendSubscription",value:function(u){var p=this,k={srcTinyId:this.tinyId_,srcUserId:this.userId_},x=CU,E=mt.UNSUBSCRIBE_RESULT;return u===Ff&&(k={audio:this.subscribeState_.audio,bigVideo:this.subscribeState_.video,auxVideo:this.subscribeState_.auxiliary,smallVideo:this.subscribeState_.smallVideo,srcTinyId:this.tinyId_},x=EU,E=mt.SUBSCRIBE_CHANGE_RESULT),this.signalChannel_.sendWaitForResponse({command:x,data:k,responseCommand:E,timeout:1e4}).then(function(I){var m=I.data;if(m.code!==0){var T=new ne({code:m.code,message:ie({key:kN,data:{type:u,message:m.message}})});throw p.log_.error(T),T}})}},{key:"connect",value:(o=H(f().mark(function u(){return f().wrap(function(p){for(;;)switch(p.prev=p.next){case 0:return p.prev=0,p.next=3,this.exchangeSDP();case 3:return p.next=5,this.waitForPeerConnectionConnected();case 5:p.next=11;break;case 7:throw p.prev=7,p.t0=p.catch(0),this.closePeerConnection(!0),p.t0;case 11:case"end":return p.stop()}},u,this,[[0,7]])})),function(){return o.apply(this,arguments)})},{key:"exchangeSDP",value:(r=H(f().mark(function u(){var p,k,x,E,I,m;return f().wrap(function(T){for(;;)switch(T.prev=T.next){case 0:return T.prev=0,this.isSDPExchanging_=!0,T.next=4,this.createOffer();case 4:return this.log_.info("createOffer success, sending offer to remote server"),p=this.peerConnection_.localDescription,k=p.type,x=p.sdp,E={type:k,sdp:x,srcUserId:this.userId_,srcTinyId:this.tinyId_,audio:this.subscribeState_.audio,bigVideo:this.subscribeState_.video,auxVideo:this.subscribeState_.auxiliary,smallVideo:this.subscribeState_.smallVideo},Y.emit(Jp,{client:this.client_,connection:this,userId:this.userId_,tinyId:this.tinyId_,role:ao,subscribeState:this.subscribeState_,trackState:this.trackState_}),T.next=10,this.signalChannel_.sendWaitForResponse({command:wU,commandDesc:"exchange sdp",data:E,responseCommand:mt.SUBSCRIBE_RESULT,timeout:1e4});case 10:if(I=T.sent,this.peerConnection_){T.next=15;break}throw m=new ne({code:ee.INVALID_OPERATION,message:ie({key:z3})}),this.log_.warn(m),m;case 15:return T.next=17,this.onSubscribeResult(I);case 17:this.isSDPExchanging_=!1,T.next=24;break;case 20:throw T.prev=20,T.t0=T.catch(0),this.isSDPExchanging_=!1,T.t0;case 24:case"end":return T.stop()}},u,this,[[0,20]])})),function(){return r.apply(this,arguments)})},{key:"createOffer",value:(i=H(f().mark(function u(){var p,k;return f().wrap(function(x){for(;;)switch(x.prev=x.next){case 0:return p={voiceActivityDetection:!1},vm()&&this.sdpSemantics_===Qs?(this.peerConnection_.addTransceiver(Ee,{direction:"recvonly"}),this.peerConnection_.addTransceiver(Te,{direction:"recvonly"}),this.peerConnection_.addTransceiver(Te,{direction:"recvonly"})):(p.offerToReceiveAudio=!0,p.offerToReceiveVideo=!0),x.next=4,this.peerConnection_.createOffer(p);case 4:return k=x.sent,x.next=7,Dk();case 7:return x.sent.isH264DecodeSupported||(this.log_.warn("remove h264 desc from sdp"),k.sdp=(E=k.sdp,I=void 0,(I=Br(E)).media.forEach(function(m){if(m.type===Te){var T=new Set;m.rtp.forEach(function(C){var O=C.payload;return C.codec==="H264"&&T.add(O)}),m.fmtp.forEach(function(C){var O=C.payload,N=C.config.match(/apt=(\d+)/);N&&N[1]&&T.has(Number(N[1]))&&T.add(O)});var v=function(C){var O=C.payload;return!T.has(O)};m.rtp=m.rtp.filter(v),m.rtcpFb=m.rtcpFb.filter(v),m.fmtp=m.fmtp.filter(v),m.payloads=m.payloads.split(" ").filter(function(C){return!T.has(Number(C))}).join(" ")}}),mo(I))),k.sdp=this.addRRTRLine(k.sdp),k.sdp=this.addSPSDescription(k.sdp),k.sdp=wV(k.sdp),this.sdpSemantics_===Qs&&(k.sdp=this.removeSDESDescription(k.sdp)),x.next=16,this.peerConnection_.setLocalDescription(k);case 16:case"end":return x.stop()}var E,I},u,this)})),function(){return i.apply(this,arguments)})},{key:"onSubscribeResult",value:(n=H(f().mark(function u(p){var k,x,E,I,m,T,v,C=this;return f().wrap(function(O){for(;;)switch(O.prev=O.next){case 0:if(k=p&&p.data||{},x=k.code,E=k.message,I=E===void 0?"":E,m=p&&p.data&&p.data.data||{},T=m.type,v=m.sdp,x!==77393){O.next=5;break}throw this.log_.error(mi.NOT_SUPPORTED_H264DECODE),new ne({code:ee.NOT_SUPPORTED_H264,message:ie({key:mS})});case 5:if(O.prev=5,x===0){O.next=8;break}throw new ne({code:x,message:ie({key:IN,data:{errMsg:I}})});case 8:return this.log_.debug("accept remote answer: "+v),O.next=11,this.peerConnection_.setRemoteDescription({type:T,sdp:v});case 11:this.sei_&&(this.sei_.handleEncodedStreams(),this.sei_.onSEIMessage=function(N){C.emitter_.emit(et.SEI_MESSAGE,q(q({},N),{},{userId:C.userId_}))}),this.updateSSRC(v),O.next=19;break;case 15:throw O.prev=15,O.t0=O.catch(5),this.log_.error(O.t0),O.t0;case 19:case"end":return O.stop()}},u,this,[[5,15]])})),function(u){return n.apply(this,arguments)})},{key:"updateSSRC",value:function(u){var p=this;try{Br(u).media.forEach(function(k){if(k.type===Ee){var x=k.ssrcs.find(function(m){return m.value.includes(Sr)});x&&(p.ssrc_.audio=x.id)}else{var E=k.ssrcs.find(function(m){return m.value.includes(Sr)}),I=k.ssrcs.find(function(m){return m.value.includes(Ks)});E&&(p.ssrc_.video=E.id),I&&(p.ssrc_.auxiliary=I.id)}})}catch(k){}}},{key:"setRemoteStream",value:function(u,p){this.remoteStreams_.set(u,p)}},{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(Sr)}},{key:"getAuxStream",value:function(){return this.remoteStreams_.get(Ks)}},{key:"getMainStreamVideoTrackId",value:function(){var u=this.getMainStream();if(u){var p=u.getVideoTrack();if(p)return p.id}return""}},{key:"getAuxStreamVideoTrackId",value:function(){var u=this.getAuxStream();if(u){var p=u.getVideoTrack();if(p)return p.id}return""}},{key:"reconnect",value:(t=H(f().mark(function u(){var p,k,x=this;return f().wrap(function(E){for(;;)switch(E.prev=E.next){case 0:if(this.reconnectionTimer_===-1){E.next=3;break}return this.log_.warn("reconnect() downlink is reconnecting, ignore current reconnection"),E.abrupt("return");case 3:if(!(this.reconnectionCount_>=30)){E.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(),p=new ne({code:ee.DOWNLINK_RECONNECTION_FAILED,message:ie({key:xN})}),xe.logFailedEvent({userId:this.client_.getUserId(),eventType:Ab,error:p}),this.addEventInternal(dV,"downlink-connection reconnect fail"),this.emitConnectionStateChangedEvent(an),this.emitter_.emit(et.ERROR,p),E.abrupt("return");case 12:if(this.signalChannel_.getCurrentState()===ac){E.next=16;break}return this.log_.warn("reconnect() signal channel is not connected, suspend reconnection until signal is connected"),this.signalChannel_.once(ic,this.reconnect,this),E.abrupt("return");case 16:if(this.reconnectionCount_++,this.log_.warn("reconnect() try to reconnect downlink [".concat(this.reconnectionCount_,"/").concat(30,"]")),k=Sp(this.reconnectionCount_),this.reconnectionTimer_=setTimeout(function(){x.log_.warn("reconnect() downlink [".concat(x.userId_,"] reconnect timeout(").concat(k/1e3,"s), try again")),x.clearReconnectionTimer(),x.reconnect()},k),!(this.isSDPExchanging_||this.peerConnection_&&this.peerConnection_.connectionState===Wu)){E.next=22;break}return E.abrupt("return");case 22:return E.prev=22,this.closePeerConnection(),this.initialize(),E.next=27,this.connect();case 27:this.stopReconnection(),this.log_.warn("reconnect() downlink reconnect successfully"),xe.logSuccessEvent({userId:this.client_.getUserId(),eventType:Ab}),this.addEventInternal(lV,"downlink-connection reconnect success"),this.recoverSubscription(),E.next=36;break;case 34:E.prev=34,E.t0=E.catch(22);case 36:case"end":return E.stop()}},u,this,[[22,34]])})),function(){return t.apply(this,arguments)})},{key:"recoverSubscription",value:function(){var u=this,p=this.client_.getSubscriptionManager();p&&Se(this.remoteStreams_.values()).forEach(function(k){p.hasAutoRecoveryFlag(u.userId_,k.getType())&&p.recover(k)})}},{key:"getIsReconnecting",value:function(){return this.isReconnecting_}},{key:"getSubscribedMainStream",value:function(){var u=null;return this.isMainStreamSubscribed&&(u=this.remoteStreams_.get(Sr)),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 p,k=oe(this.remoteStreams_.values());try{for(k.s();!(p=k.n()).done;){var x=p.value,E=x.getType();(E===gt&&(this.trackState_.audio||this.trackState_.video)||E===Dt&&this.trackState_.auxiliary)&&u.setAutoRecoveryFlag(this.userId_,x.getType())}}catch(I){k.e(I)}finally{k.f()}}le(Qe(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}(Mv),X(or.prototype,"subscribe",[$x,Zx],Object.getOwnPropertyDescriptor(or.prototype,"subscribe"),or.prototype),X(or.prototype,"unsubscribe",[eI],Object.getOwnPropertyDescriptor(or.prototype,"unsubscribe"),or.prototype),X(or.prototype,"exchangeSDP",[tI],Object.getOwnPropertyDescriptor(or.prototype,"exchangeSDP"),or.prototype),or),id=function(){function e(){Q(this,e),this.startTime=0,this.endTime=0,this.start()}return Ie(e,[{key:"start",value:function(){this.startTime===0&&(this.startTime=Pt())}},{key:"stop",value:function(){this.endTime===0&&(this.endTime=Pt())}},{key:"getDuration",value:function(){return this.endTime===0?Pt()-this.startTime:this.endTime-this.startTime}}]),e}(),GF=function(){function e(r){Q(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 Ie(e,[{key:"installEvents",value:function(){Y.on(Gp,this.handlePlayVideoStart,this),Y.on(tc,this.onVideoTrackMuted,this),Y.on(Bp,this.onVideoTrackUnmuted,this),Y.on(aa,this.handleStreamStopped,this),Y.on(Vr,this.handleStreamStopped,this),Y.on(ec,this.handleVideoPlaying,this)}},{key:"uninstallEvents",value:function(){Y.off(Gp,this.handlePlayVideoStart,this),Y.off(tc,this.onVideoTrackMuted,this),Y.off(Bp,this.onVideoTrackUnmuted,this),Y.off(aa,this.handleStreamStopped,this),Y.off(Vr,this.handleStreamStopped,this),Y.off(ec,this.handleVideoPlaying,this)}},{key:"start",value:function(){var r=this;this.intervalId_===-1&&(this.installEvents(),this.intervalId_=_t.run(H(f().mark(function o(){return f().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(),_t.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 id;l?l.durationItemList.push(u):this.dataFreezeMap_.set(s,{userId:c,type:a,durationItemList:[u],isFreezing:function(){var p=this.durationItemList[this.durationItemList.length-1];return p&&p.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?(xe.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=H(f().mark(function r(){var o,c,a,s,l,u,p,k,x,E,I;return f().wrap(function(m){for(;;)switch(m.prev=m.next){case 0:o=this.client_.getConnections(),c={},a=oe(o),m.prev=3,a.s();case 5:if((s=a.n()).done){m.next=20;break}if(l=ke(s.value,2),u=l[0],(p=l[1]).getPeerConnection()){m.next=9;break}return m.abrupt("continue",18);case 9:return k=p.getSubscribeState(),x=p.getTrackState(),m.next=13,this.statsCalculator_.getReceiverStats(p);case 13:E=m.sent,(I={userId:E.userId,tinyId:u,hasVideo:x.video&&k.video,hasAuxiliary:x.auxiliary&&k.auxiliary,video:{framesDecoded:0},auxiliary:{framesDecoded:0}}).hasVideo&&(I.video.framesDecoded=E.video.framesDecoded),I.hasAuxiliary&&(I.auxiliary.framesDecoded=E.auxiliary.framesDecoded),c[E.userId]=I;case 18:m.next=5;break;case 20:m.next=25;break;case 22:m.prev=22,m.t0=m.catch(3),a.e(m.t0);case 25:return m.prev=25,a.f(),m.finish(25);case 28:return m.abrupt("return",c);case 29:case"end":return m.stop()}},r,this,[[3,22,25,28]])})),function(){return i.apply(this,arguments)})},{key:"detectFPS",value:(n=H(f().mark(function r(){var o,c,a,s,l,u;return f().wrap(function(p){for(;;)switch(p.prev=p.next){case 0:return p.next=2,this.getStats();case 2:if(o=p.sent,this.prevStats_){p.next=6;break}return this.prevStats_=o,p.abrupt("return");case 6:p.t0=f().keys(o);case 7:if((p.t1=p.t0()).done){p.next=17;break}if(c=p.t1.value,this.prevStats_[c]){p.next=11;break}return p.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:gt,fps:l})),o[c].hasAuxiliary&&this.prevStats_[c].hasAuxiliary&&(u=o[c].auxiliary.framesDecoded-this.prevStats_[c].auxiliary.framesDecoded,this.handleRenderFreeze({userId:c,type:Dt,fps:u})),p.next=7;break;case 17:this.prevStats_=o;case 18:case"end":return p.stop()}},r,this)})),function(){return n.apply(this,arguments)})},{key:"handleRenderFreeze",value:(t=H(f().mark(function r(o){var c,a,s,l,u,p,k,x;return f().wrap(function(E){for(;;)switch(E.prev=E.next){case 0:c=o.userId,a=o.fps,s=o.type,l="".concat(c,"_").concat(s),u=this.renderFreezeMap_.get(l),a<=2?(p=Pt(),u&&!u.isFreeze&&(u.freezeTimeline.push({startTime:p,endTime:void 0}),u.isFreeze=!0),u||this.renderFreezeMap_.set(l,{userId:c,type:s,isFreeze:!0,freezeTimeline:[{startTime:p,endTime:void 0}],renderFreezeTotal:0})):u&&u.isFreeze&&(u.isFreeze=!1,(k=u.freezeTimeline.pop()).endTime=Pt(),x=k.endTime-k.startTime,u.freezeTimeline.push(k),u.renderFreezeTotal+=Math.min(5e3,x));case 4:case"end":return E.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=Pt()-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}(),qv=Ie(function e(t){Q(this,e),this.userId=t.userId,this.tinyId=t.tinyId,this.role=t.role===ao?br:Qi}),rI={exports:{}};(function(e){(function(t){function n(m,T){var v=(65535&m)+(65535&T);return(m>>16)+(T>>16)+(v>>16)<<16|65535&v}function i(m,T,v,C,O,N){return n((j=n(n(T,m),n(C,N)))<<(_=O)|j>>>32-_,v);var j,_}function r(m,T,v,C,O,N,j){return i(T&v|~T&C,m,T,O,N,j)}function o(m,T,v,C,O,N,j){return i(T&C|v&~C,m,T,O,N,j)}function c(m,T,v,C,O,N,j){return i(T^v^C,m,T,O,N,j)}function a(m,T,v,C,O,N,j){return i(v^(T|~C),m,T,O,N,j)}function s(m,T){var v,C,O,N,j;m[T>>5]|=128<<T%32,m[14+(T+64>>>9<<4)]=T;var _=1732584193,b=-271733879,R=-1732584194,P=271733878;for(v=0;v<m.length;v+=16)C=_,O=b,N=R,j=P,_=r(_,b,R,P,m[v],7,-680876936),P=r(P,_,b,R,m[v+1],12,-389564586),R=r(R,P,_,b,m[v+2],17,606105819),b=r(b,R,P,_,m[v+3],22,-1044525330),_=r(_,b,R,P,m[v+4],7,-176418897),P=r(P,_,b,R,m[v+5],12,1200080426),R=r(R,P,_,b,m[v+6],17,-1473231341),b=r(b,R,P,_,m[v+7],22,-45705983),_=r(_,b,R,P,m[v+8],7,1770035416),P=r(P,_,b,R,m[v+9],12,-1958414417),R=r(R,P,_,b,m[v+10],17,-42063),b=r(b,R,P,_,m[v+11],22,-1990404162),_=r(_,b,R,P,m[v+12],7,1804603682),P=r(P,_,b,R,m[v+13],12,-40341101),R=r(R,P,_,b,m[v+14],17,-1502002290),_=o(_,b=r(b,R,P,_,m[v+15],22,1236535329),R,P,m[v+1],5,-165796510),P=o(P,_,b,R,m[v+6],9,-1069501632),R=o(R,P,_,b,m[v+11],14,643717713),b=o(b,R,P,_,m[v],20,-373897302),_=o(_,b,R,P,m[v+5],5,-701558691),P=o(P,_,b,R,m[v+10],9,38016083),R=o(R,P,_,b,m[v+15],14,-660478335),b=o(b,R,P,_,m[v+4],20,-405537848),_=o(_,b,R,P,m[v+9],5,568446438),P=o(P,_,b,R,m[v+14],9,-1019803690),R=o(R,P,_,b,m[v+3],14,-187363961),b=o(b,R,P,_,m[v+8],20,1163531501),_=o(_,b,R,P,m[v+13],5,-1444681467),P=o(P,_,b,R,m[v+2],9,-51403784),R=o(R,P,_,b,m[v+7],14,1735328473),_=c(_,b=o(b,R,P,_,m[v+12],20,-1926607734),R,P,m[v+5],4,-378558),P=c(P,_,b,R,m[v+8],11,-2022574463),R=c(R,P,_,b,m[v+11],16,1839030562),b=c(b,R,P,_,m[v+14],23,-35309556),_=c(_,b,R,P,m[v+1],4,-1530992060),P=c(P,_,b,R,m[v+4],11,1272893353),R=c(R,P,_,b,m[v+7],16,-155497632),b=c(b,R,P,_,m[v+10],23,-1094730640),_=c(_,b,R,P,m[v+13],4,681279174),P=c(P,_,b,R,m[v],11,-358537222),R=c(R,P,_,b,m[v+3],16,-722521979),b=c(b,R,P,_,m[v+6],23,76029189),_=c(_,b,R,P,m[v+9],4,-640364487),P=c(P,_,b,R,m[v+12],11,-421815835),R=c(R,P,_,b,m[v+15],16,530742520),_=a(_,b=c(b,R,P,_,m[v+2],23,-995338651),R,P,m[v],6,-198630844),P=a(P,_,b,R,m[v+7],10,1126891415),R=a(R,P,_,b,m[v+14],15,-1416354905),b=a(b,R,P,_,m[v+5],21,-57434055),_=a(_,b,R,P,m[v+12],6,1700485571),P=a(P,_,b,R,m[v+3],10,-1894986606),R=a(R,P,_,b,m[v+10],15,-1051523),b=a(b,R,P,_,m[v+1],21,-2054922799),_=a(_,b,R,P,m[v+8],6,1873313359),P=a(P,_,b,R,m[v+15],10,-30611744),R=a(R,P,_,b,m[v+6],15,-1560198380),b=a(b,R,P,_,m[v+13],21,1309151649),_=a(_,b,R,P,m[v+4],6,-145523070),P=a(P,_,b,R,m[v+11],10,-1120210379),R=a(R,P,_,b,m[v+2],15,718787259),b=a(b,R,P,_,m[v+9],21,-343485551),_=n(_,C),b=n(b,O),R=n(R,N),P=n(P,j);return[_,b,R,P]}function l(m){var T,v="",C=32*m.length;for(T=0;T<C;T+=8)v+=String.fromCharCode(m[T>>5]>>>T%32&255);return v}function u(m){var T,v=[];for(v[(m.length>>2)-1]=void 0,T=0;T<v.length;T+=1)v[T]=0;var C=8*m.length;for(T=0;T<C;T+=8)v[T>>5]|=(255&m.charCodeAt(T/8))<<T%32;return v}function p(m){var T,v,C="0123456789abcdef",O="";for(v=0;v<m.length;v+=1)T=m.charCodeAt(v),O+=C.charAt(T>>>4&15)+C.charAt(15&T);return O}function k(m){return unescape(encodeURIComponent(m))}function x(m){return function(T){return l(s(u(T),8*T.length))}(k(m))}function E(m,T){return function(v,C){var O,N,j=u(v),_=[],b=[];for(_[15]=b[15]=void 0,j.length>16&&(j=s(j,8*v.length)),O=0;O<16;O+=1)_[O]=909522486^j[O],b[O]=1549556828^j[O];return N=s(_.concat(u(C)),512+8*C.length),l(s(b.concat(N),640))}(k(m),k(T))}function I(m,T,v){return T?v?E(T,m):p(E(T,m)):v?x(m):p(x(m))}e.exports?e.exports=I:t.md5=I})(se)})(rI);var ad=rI.exports,zF=function(){function e(o){Q(this,e),this.client_=o.client,this.signalChannel_=o.signalChannel,this.log_=ye.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 Ie(e,[{key:"isPresetLayoutMode",get:function(){return this.config_&&this.config_.mode===Gf.PRESET_LAYOUT}},{key:"installEvents",value:function(){Y.on(Ur,this.onStreamSubscribed,this),Y.on(Vr,this.onStreamUnsubscribed,this),this.client_.on("stream-removed",this.onStreamRemoved,this)}},{key:"uninstallEvents",value:function(){Y.off(Ur,this.onStreamSubscribed,this),Y.off(Vr,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=H(f().mark(function o(c){var a,s,l;return f().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=H(f().mark(function o(c){var a,s,l,u,p,k,x,E;return f().wrap(function(I){for(;;)switch(I.prev=I.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,I.prev=5,I.next=8,this.signalChannel_.sendWaitForResponse({command:LU,data:u,timeout:5e3,responseCommand:mt.START_MIX_TRANSCODE_RES,commandDesc:"startMixTranscode"});case 8:if(p=I.sent,k=p.data,x=k.code,E=k.message,x===0){I.next=15;break}throw x===-102083&&(E="Please enable relayed-push in ".concat(Xb," and try later, refer to ").concat(Kf,"tutorial-26-advanced-publish-cdn-stream.html")),this.log_.error("startMixTranscode failed, errCode: ".concat(x," errMsg: ").concat(E)),this.isMixing_=!1,new ne({code:ee.START_MIX_TRANSCODE_FAILED,message:ie({key:b3,data:{message:E},link:{className:"Client",fnName:"startMixTranscode"}})});case 15:I.next=21;break;case 17:throw I.prev=17,I.t0=I.catch(5),this.isMixing_=!1,I.t0;case 21:case"end":return I.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=H(f().mark(function o(){return f().wrap(function(c){for(;;)switch(c.prev=c.next){case 0:if(this.isMixing_){c.next=2;break}throw new ne({code:ee.INVALID_OPERATION,message:ie({key:k3})});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=H(f().mark(function o(){var c,a,s,l,u;return f().wrap(function(p){for(;;)switch(p.prev=p.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))),p.next=4,this.signalChannel_.sendWaitForResponse({command:OU,data:c,timeout:5e3,responseCommand:mt.STOP_MIX_TRANSCODE_RES,commandDesc:"stopMixTranscode"});case 4:if(a=p.sent,s=a.data,l=s.code,u=s.message,l!==0){p.next=10;break}this.isMixing_=!1,p.next=12;break;case 10:throw this.log_.error("stopMixTranscode failed, errCode: ".concat(l," errMsg: ").concat(u)),new ne({code:ee.STOP_MIX_TRANSCODE_FAILED,message:ie({key:S3,data:{message:u},link:{className:"Client",fnName:"stopMixTranscode"}})});case 12:case"end":return p.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 Bt(c.streamId)&&c.streamId.length>0?c.streamId:ad("".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:ge(l.streamType)||l.streamType!==Dt?0:1,inputType:l.pureAudio?Fb.IT_PURE_AUDIO:Fb.IT_AUDIO_VIDEO,renderMode:l.renderMode||0}});return o.mode===Gf.PRESET_LAYOUT&&(s.forEach(function(l){if(l.userId===Bb.REMOTE){var u=Se(c.values()).find(function(p){return!p.isUsed});u&&(l.userId=u.remoteStream.getUserId(),l.streamType=u.remoteStream.getType()===Dt?1:0,u.isUsed=!0)}}),s=s.filter(function(l){return l.userId!==Bb.REMOTE})),s}},{key:"getOutputParam",value:function(o){var c=o.streamId||"";return{streamId:c,streamType:c.length>0?1:0,width:ge(o.videoWidth)?640:o.videoWidth,height:ge(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}(),WF=function(){function e(a){Q(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 Ie(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=ad(l)),"".concat(this.client_.getSDKAppId(),"_").concat(l)}return a}},{key:"generatePublishCDNSessionId",value:function(a){return ad("".concat(this.client_.getRoomId(),"_").concat(this.client_.getUserId(),"_").concat(a))}},{key:"startPublishTencentCDN",value:(c=H(f().mark(function a(s){var l,u,p,k;return f().wrap(function(x){for(;;)switch(x.prev=x.next){case 0:if(s.streamType===Mn?(this.publishTencentAuxStreamObj_.params_=s,this.publishTencentAuxStreamObj_.isPublishing_=!0):(this.publishTencentMainStreamObj_.params_=s,this.publishTencentMainStreamObj_.isPublishing_=!0),this.client_.isJoined_){x.next=3;break}return x.abrupt("return");case 3:return l=this.generatePublishCDNStreamId(s.streamId,s.streamType),u=this.generatePublishCDNSessionId(s.streamType),p=s.streamType===Mn?1:0,k={requestTime:Date.now(),sessionId:u,streamId:l,streamType:p},x.next=9,this.doStartPublishTencentCDN(k,s.streamType);case 9:case"end":return x.stop()}},a,this)})),function(a){return c.apply(this,arguments)})},{key:"doStartPublishTencentCDN",value:(o=H(f().mark(function a(s,l){var u,p,k,x;return f().wrap(function(E){for(;;)switch(E.prev=E.next){case 0:return E.prev=0,ye.info("startPublishTencentCDN: "+JSON.stringify(s)),E.next=4,this.signalChannel_.sendWaitForResponseWithRetry({command:RU,data:s,timeout:2e3,responseCommand:mt.START_PUBLISH_TENCENT_CDN_RES,commandDesc:"startPublishCDNStream",retries:2});case 4:if(u=E.sent,p=u.data,k=p.code,x=p.message,k!==0){E.next=10;break}l===Mn?this.publishTencentAuxStreamObj_.streamId_=s.streamId:this.publishTencentMainStreamObj_.streamId_=s.streamId,E.next=14;break;case 10:throw l===Mn?this.publishTencentAuxStreamObj_.isPublishing_=!1:this.publishTencentMainStreamObj_.isPublishing_=!1,k===-102083&&(x="Please enable relayed-push in ".concat(Xb," and try later, refer to ").concat(Kf,"tutorial-26-advanced-publish-cdn-stream.html")),ye.error("startPublishTencentCDN failed, errCode: ".concat(k,", errMsg: ").concat(x)),new ne({code:ee.START_PUBLISH_CDN_FAILED,message:ie({key:cS,data:{message:x},link:{className:"Client",fnName:"startPublishCDNStream"}})});case 14:E.next=20;break;case 16:throw E.prev=16,E.t0=E.catch(0),l===Mn?this.publishTencentAuxStreamObj_.isPublishing_=!1:this.publishTencentMainStreamObj_.isPublishing_=!1,E.t0;case 20:case"end":return E.stop()}},a,this,[[0,16]])})),function(a,s){return o.apply(this,arguments)})},{key:"resetPublishTencentParam",value:function(a){a===Ye&&(this.publishTencentMainStreamObj_={params_:null,streamId_:void 0,isPublishing_:!1}),a===Mn&&(this.publishTencentAuxStreamObj_={params_:null,streamId_:void 0,isPublishing_:!1})}},{key:"stopPublishTencentCDN",value:(r=H(f().mark(function a(){return f().wrap(function(s){for(;;)switch(s.prev=s.next){case 0:if(this.client_.isJoined_){s.next=4;break}return this.resetPublishTencentParam(Ye),this.resetPublishTencentParam(Mn),s.abrupt("return");case 4:if(!this.publishTencentMainStreamObj_.isPublishing_){s.next=7;break}return s.next=7,this.doStopPublishTencentCDN(Ye);case 7:if(!this.publishTencentAuxStreamObj_.isPublishing_){s.next=10;break}return s.next=10,this.doStopPublishTencentCDN(Mn);case 10:case"end":return s.stop()}},a,this)})),function(){return r.apply(this,arguments)})},{key:"doStopPublishTencentCDN",value:(i=H(f().mark(function a(s){var l,u,p,k,x;return f().wrap(function(E){for(;;)switch(E.prev=E.next){case 0:return l={requestTime:Date.now(),sessionId:ad("".concat(this.client_.getRoomId(),"_").concat(this.client_.getUserId(),"_").concat(s))},ye.info("stopPublishTencentCDN: "+JSON.stringify(l)),E.next=4,this.signalChannel_.sendWaitForResponse({command:AU,data:l,timeout:5e3,responseCommand:mt.STOP_PUBLISH_TENCENT_CDN_RES,commandDesc:"stopPublishCDNStream"});case 4:if(u=E.sent,p=u.data,k=p.code,x=p.message,k!==0){E.next=10;break}this.resetPublishTencentParam(s),E.next=17;break;case 10:if(k!==-102069){E.next=15;break}ye.warn("stopPublishTencentCDN failed, can not stopPublishTencentCDN in auto relayed-push mode"),this.resetPublishTencentParam(s),E.next=17;break;case 15:throw ye.error("stopPublishTencentCDN failed, errCode: ".concat(k," errMsg: ").concat(x)),new ne({code:ee.STOP_PUBLISH_CDN_FAILED,message:ie({key:uS,data:{message:x},link:{className:"Client",fnName:"stopPublishCDNStream"}})});case 17:case"end":return E.stop()}},a,this)})),function(a){return i.apply(this,arguments)})},{key:"startPublishGivenCDN",value:(n=H(f().mark(function a(s){var l,u,p,k,x,E;return f().wrap(function(I){for(;;)switch(I.prev=I.next){case 0:if(l=s.streamType===Ye?this.publishTencentMainStreamObj_.streamId_:this.publishTencentAuxStreamObj_.streamId_,u={pushRequestTime:Date.now(),pushAppId:s.appId,pushBizId:s.bizId,pushCdnUrl:s.url,pushStreamType:s.streamType,pushStreamId:l},ye.info("startPublishGivenCDN: "+JSON.stringify(u)),this.publishGivenCDNData_=u,this.isPublishingGivenCDN_=!0,this.client_.isJoined_){I.next=7;break}return I.abrupt("return");case 7:return I.prev=7,I.next=10,this.signalChannel_.sendWaitForResponse({command:PU,data:u,timeout:5e3,responseCommand:mt.START_PUBLISH_GIVEN_CDN_RES,commandDesc:"startPublishCDNStream"});case 10:if(p=I.sent,k=p.data,x=k.code,E=k.message,x===0){I.next=17;break}throw ye.error("startPublishGivenCDN failed, errCode: ".concat(x,", errMsg: ").concat(E)),this.publishGivenCDNData_=null,this.isPublishingGivenCDN_=!1,new ne({code:ee.START_PUBLISH_CDN_FAILED,message:ie({key:cS,data:{message:E},link:{className:"Client",fnName:"startPublishCDNStream"}})});case 17:I.next=24;break;case 19:throw I.prev=19,I.t0=I.catch(7),this.publishGivenCDNData_=null,this.isPublishingGivenCDN_=!1,I.t0;case 24:case"end":return I.stop()}},a,this,[[7,19]])})),function(a){return n.apply(this,arguments)})},{key:"stopPublishGivenCDN",value:(t=H(f().mark(function a(){var s,l,u,p,k,x,E,I,m,T;return f().wrap(function(v){for(;;)switch(v.prev=v.next){case 0:if(this.client_.isJoined_){v.next=4;break}return this.publishGivenCDNData_=null,this.isPublishingGivenCDN_=!1,v.abrupt("return");case 4:return s=this.publishGivenCDNData_,l=s.pushAppId,u=s.pushBizId,p=s.pushCdnUrl,k=s.pushStreamType,x={pushRequestTime:Date.now(),pushAppId:l,pushBizId:u,pushCdnUrl:p,pushStreamType:k},ye.info("stopPublishGivenCDN: "+JSON.stringify(x)),v.next=9,this.signalChannel_.sendWaitForResponse({command:DU,data:x,timeout:5e3,responseCommand:mt.STOP_PUBLISH_GIVEN_CDN_RES,commandDesc:"stopPublishCDNStream"});case 9:if(E=v.sent,I=E.data,m=I.code,T=I.message,m!==0){v.next=16;break}this.publishGivenCDNData_=null,this.isPublishingGivenCDN_=!1,v.next=18;break;case 16:throw ye.error("stopPublishGivenCDN failed, errCode: ".concat(m," errMsg: ").concat(T)),new ne({code:ee.STOP_PUBLISH_CDN_FAILED,message:ie({key:uS,data:{message:T},link:{className:"Client",fnName:"stopPublishCDNStream"}})});case 18:case"end":return v.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={};Bt(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,Ye))),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,Mn))),l=JSON.stringify(u)}if(this.isPublishingGivenCDN_){var p=this.publishGivenCDNData_,k=p.pushAppId,x=p.pushBizId,E=p.pushCdnUrl,I=p.pushStreamType,m=p.pushStreamId;s={pushRequestTime:Date.now(),pushAppId:k,pushBizId:x,pushCdnUrl:E,pushStreamType:I,pushStreamId:m}}return{bussinessInfo:l,pushUserCdnInfo:s}}},{key:"reset",value:function(){this.resetPublishTencentParam(Ye),this.resetPublishTencentParam(Mn),this.publishGivenCDNData_=null,this.isPublishingGivenCDN_=!1}}]),e}(),qF=function(){function e(t){Q(this,e),this.client_=t.client,this.durationMap_=new Map,this.installEvents()}return Ie(e,[{key:"installEvents",value:function(){Y.on(Ur,this.handleSubscribed,this),Y.on(Un,this.handleStreamTrackUpdated,this),Y.on(Vr,this.handleStreamStopped,this),Y.on(aa,this.handleStreamStopped,this)}},{key:"uninstallEvents",value:function(){Y.off(Ur,this.handleSubscribed,this),Y.off(Un,this.handleStreamTrackUpdated,this),Y.off(Vr,this.handleStreamStopped,this),Y.off(aa,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 id,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,Ee);if(i.hasVideo())if(o===gt&&i.isMainVideoSubscribed||o===Dt&&i.isAuxVideoSubscribed){var l=new id,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,Te)}}},{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,Ee),this.stopDurationItem(c,Te)}}},{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===pt?o:gt,s="".concat(i,"_").concat(a);if(c===sn.ADD){var l=this.client_.getConnections().get(r).getSubscribeState();if(o===Ee&&!l.audio||o===Te&&!l.video||o===pt&&!l.auxiliary)return;var u=new id,p=this.durationMap_.get(s);p?(o!==Ee||this.isRecording(p.audio)||p.audio.push(u),o===Ee||this.isRecording(p.video)||p.video.push(u)):this.durationMap_.set(s,{userId:i,type:a,audio:o===Ee?[u]:[],video:o===Ee?[]:[u]})}else this.stopDurationItem(s,o===Ee?Ee:Te)}}},{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 Ic(){return function(e,t,n){var i=n.value,r=new Set;return n.value=H(f().mark(function o(){var c,a,s,l,u=arguments;return f().wrap(function(p){for(;;)switch(p.prev=p.next){case 0:if(!r.has(this)){p.next=2;break}throw new ne({code:ee.INVALID_OPERATION,message:ie({key:mN,data:{name:t}})});case 2:for(p.prev=2,r.add(this),c=u.length,a=new Array(c),s=0;s<c;s++)a[s]=u[s];return p.next=7,i.apply(this,a);case 7:return l=p.sent,r.delete(this),p.abrupt("return",l);case 12:throw p.prev=12,p.t0=p.catch(2),r.delete(this),p.t0;case 16:case"end":return p.stop()}},o,this,[[2,12]])})),n}}var Jv=null,Kv=!0;function ma(e){Zn(e)&&e!==Kv&&(Kv=e,ye.info("setIsNeedToSchedule "+e))}function JF(e){return Xv.apply(this,arguments)}function Xv(){return Xv=H(f().mark(function e(t){var n,i,r,o,c,a,s,l,u,p,k,x,E;return f().wrap(function(I){for(;;)switch(I.prev=I.next){case 0:if(n=t.userId,i=t.sdkAppId,r=t.useStringRoomId,o=t.roomId,c=t.userSig,Kv||!Jv){I.next=3;break}return I.abrupt("return",{isCached:!0,result:Jv});case 3:return a={delta:0,count:[1,1],msg:[]},I.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",Bi),s.append("userSig",String(c)),Wf&&s.append("oversea",!0),l=Pt(),I.next=16,XF(s,a,i);case 16:return(u=I.sent).config&&(u.config.loggerDomain&&Of(u.config.loggerDomain),Zn(u.config.scheduleCache)&&ma(!u.config.scheduleCache)),a.delta=Pt()-l,iI({stat:a,userId:n}),Jv=u,I.abrupt("return",{isCached:!1,result:u});case 24:throw I.prev=24,I.t0=I.catch(4),p=uo(I.t0)?I.t0[0]:I.t0,k=$n(p.code)?p.code:0,x="get websocket url failed: ".concat(p.message.includes("timeout")?"timeout":p.message),E=new ne({code:ee.SCHEDULE_FAILED,extraCode:k,message:ie({key:oS,data:{error:x,code:k}})}),ye.error(E),iI({stat:a,userId:n,roomId:o,error:E}),E;case 33:case"end":return I.stop()}},e,null,[[4,24]])})),Xv.apply(this,arguments)}function iI(e){var t=e.stat,n=e.userId,i=e.error;i?xe.logFailedEvent({eventType:jb,error:i,userId:n}):xe.logSuccessEvent({eventType:jb,delta:t.delta,userId:n}),xe.uploadEvent({log:"stat-schedule:"+JSON.stringify(t),userId:n})}function aI(e){var t,n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:Ye;return t=Wf||(DS(e)?n===Ye?nN:rN:n===Ye?eN:tN),"https://".concat(t,"/api/v1/config")}function KF(e,t,n){return new Promise(function(i,r){sl({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)})}Y.on(ia,function(){return ma(!0)}),Y.on(E4,function(){return ma(!0)}),Y.on(R4,function(){return ma(!0)}),Y.on(zS,function(){return ma(!0)}),Y.on(dl,function(e){e.state===Nf&&ma(!0)});var oI=function(e,t){return rc({retryFunction:KF,settings:{retries:3,timeout:0},onError:t,onRetrying:e})};function XF(e,t,n){return new Promise(function(i,r){var o,c=null;(o=[oI(function(a){return t.count[0]=a+1},function(a,s){t.msg[0]=a.message,c||s()})(aI(n,Ye),e,{get timeout(){return 1e3*ol(2+t.count[0])}}),oI(function(a){return t.count[1]=a+1},function(a,s){t.msg[1]=a.message,c||s()})(aI(n,Mr),e,{get timeout(){return 1e3*ol(2+t.count[1])}})],new Promise(function(a,s){var l=[];o.forEach(function(u){u.then(a).catch(function(p){l.push(p),l.length===o.length&&s(l)})})})).then(function(a){i(c=a)}).catch(r)})}var sI,cI,uI,lI,dI,hI,fI,pI,mI,vI,gI,_I,yI,bI,SI,kI,TI,xI,II,wI,CI,EI,RI,AI,PI,DI,LI,OI,MI,NI,UI,Pe,QF=function(){function e(){Q(this,e)}return Ie(e,[{key:"call",value:function(t,n){return pn(this[t])?this[t](n):Promise.reject(new ne({code:ee.INVALID_PARAMETER,message:ie({key:G3,data:{name:t}})}))}},{key:"updatePrivateMapKey",value:function(t){var n=t.privateMapKey;return t.client.setProperty("privateMapKey",n),Promise.resolve()}}]),e}(),YF=new QF,od,sd,cd,Qv,VI,jI,BI,FI,HI,GI,Yt,$F=(sI=Ic(),cI=xn(Qt.CLIENT.join),uI=Lo({retries:1,timeout:0,onError:function(e,t,n){this.isUsingCachedSchedule_?(this.log_.warn("is using cached schedule, retry join"),ma(!0),this.reset(),t()):(Y.emit(ia,{client:this,error:e}),xe.logFailedEvent({userId:this.userId_,eventType:Sb,error:e}),this.reset(),this.log_.error(e),n(e))}}),lI=Ic(),dI=Lo({retries:3}),hI=Ic(),fI=xn.apply(void 0,Se(Qt.CLIENT.publish)),pI=St(cn),mI=Ic(),vI=xn(Qt.CLIENT.unpublish),gI=xn.apply(void 0,Se(Qt.CLIENT.subscribe)),_I=xn(Qt.CLIENT.unsubscribe),yI=Ic(),bI=xn(Qt.CLIENT.switchRole),SI=St(cn),kI=xn(Qt.CLIENT.startPublishCDNStream),TI=St(cn),xI=St(cn),II=xn(Qt.CLIENT.startMixTranscode),wI=St(cn),CI=St(cn),EI=St(cn),RI=St(cn),AI=St(cn),PI=St(cn),DI=St(cn),LI=Jl.apply(void 0,Se(Qt.CLIENT.sendSEIMessage)),OI=St(cn),od={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}},sd=od.timesInSecond,cd=od.maxSizeInSecond,Qv=od.getSize,MI=function(e,t,n){var i=n.value,r=new Map;return Y.on(Op,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(Qv&&(o.totalSizeInSecond+=Qv.apply(void 0,a)),o.timestamp!==0&&Date.now()-o.timestamp<1e3&&(o.callCountInSecond>=sd||o.totalSizeInSecond>cd))throw new ne({code:ee.INVALID_OPERATION,message:ie({key:Y3,data:{isTimes:o.callCountInSecond>=sd,isSize:o.totalSizeInSecond>cd,name:t,timesInSecond:sd,maxSizeInSecond:cd}})});return o.callCountInSecond++,i.apply(this,a)},n},NI=St(cn),UI=St(cn),Pe=function(){function e(S){var h,y;Q(this,e),this.name_=cn,this.mode_=S.mode,this.sdpSemantics_=Hf,ge(S.sdpSemantics)?function(){var A;if(ge(window.RTCRtpTransceiver)||!("currentDirection"in RTCRtpTransceiver.prototype))return!1;var D=null,U=!1;try{(D=new RTCPeerConnection({sdpSemantics:Qs})).addTransceiver(Ee),U=!0}catch(K){}return(A=D)===null||A===void 0||A.close(),U}()&&(this.sdpSemantics_=Qs):this.sdpSemantics_=S.sdpSemantics,this.sdkAppId_=S.sdkAppId,this.userId_=S.userId,this.log_=ye.createLogger({id:"c".concat(S.seq,"|").concat(this.userId_),userId:this.userId_,sdkAppId:this.sdkAppId_}),this.userSig_=S.userSig,this.roomId_=0,this.useStringRoomId_=S.useStringRoomId||!1,this.pureAudioPushMode_=null,this.version_=S.version,this.log_.info("using sdpSemantics: "+this.sdpSemantics_),this.signalChannel_=null,this.role_=br,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_=jS(new bi,this.name_),this.isJoined_=!1,this.heartbeat_=-1,this.lastHeartBeatTime_=-1,this.stats_=new KV(this),this.joinTimeout_=-1,this.changeBigSmallRecords_=new Map,this.networkQuality_=null,this.badCaseDetector_=null,this.networkType_=bp(),this.autoSubscribe_=!!ge(S.autoSubscribe)||S.autoSubscribe,this.joinedTimestamp_=0,this.joinOptions_={},this.basis_=(y={browser:na().name+"/"+na().version,os:bm(),displayResolution:jV(),isScreenShareSupported:Ok(),isWebRTCSupported:fm(),isGetUserMediaSupported:BV(),isWebAudioSupported:FV(),isWebSocketsSupported:"WebSocket"in window&&window.WebSocket.CLOSING===2,isWebCodecSupported:(h={AudioDecoder:!1,AudioEncoder:!1,VideoDecoder:!1,VideoEncoder:!1,ImageDecoder:!1},ge(window.AudioDecoder)||(h.AudioDecoder=!0),ge(window.AudioEncoder)||(h.AudioEncoder=!0),ge(window.VideoDecoder)||(h.VideoDecoder=!0),ge(window.VideoEncoder)||(h.VideoEncoder=!0),ge(window.ImageDecoder)||(h.ImageDecoder=!0),h),isMediaSessionSupported:"mediaSession"in navigator&&!ge(navigator.mediaSession.setActionHandler),isWebTransportSupported:!ge(window.WebTransport)},navigator.userAgent.includes("miniProgram")&&(y.browser="mini/".concat(y.browser)),y),this.initBussinessInfo_(S),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 WF({client:this}),this.keyPointManager_=new cF({client:this,frameWorkType:S.frameWorkType,component:S.component}),this.isPublishing_=!1,this.isEnableSmallStream_=!1,this.smallStreamConfig_={bitrate:100,frameRate:15,height:120,width:160},this.turnServers_=[],this.iceTransportPolicy_=S.iceTransportPolicy,this.schedule_={domains:null,iceServers:null,iceTransportPolicy:null,trtcCapability:null},this.isUsingCachedSchedule_=!1,this.enableAutoPlayDialog_=!!ge(S.enableAutoPlayDialog)||S.enableAutoPlayDialog,this.enableMultiAuxStream_=!ge(S.enableMultiAuxStream)&&S.enableMultiAuxStream,this.signalInfo_={},this.enableSEI_=!ge(S.enableSEI)&&S.enableSEI,this.isDestroyed_=!1}var t,n,i,r,o,c,a,s,l,u,p,k,x,E,I,m,T,v,C,O,N,j,_,b,R,P,V;return Ie(e,[{key:"initBussinessInfo_",value:function(S){this.bussinessInfo_=S.bussinessInfo;var h={};if(Bt(S.bussinessInfo)&&(h=JSON.parse(S.bussinessInfo)),!ge(S.pureAudioPushMode)){if(!Number.isInteger(Number(S.pureAudioPushMode)))throw new ne({code:ee.INVALID_PARAMETER,message:ie({key:CN})});this.pureAudioPushMode_=S.pureAudioPushMode,h.Str_uc_params||(h.Str_uc_params={}),h.Str_uc_params.pure_audio_push_mod=this.pureAudioPushMode_}if(!ge(S.streamId)){if(!(Bt(S.streamId)&&String(S.streamId)&&String(S.streamId).length<=64))throw new ne({code:ee.INVALID_PARAMETER,message:ie({key:EN})});h.Str_uc_params||(h.Str_uc_params={}),h.Str_uc_params.userdefine_streamid_main=S.streamId}if(!ge(S.userDefineRecordId)){if(S.userDefineRecordId.match(/^[A-Za-z0-9_-]{1,64}$/gi)===null)throw new ne({code:ee.INVALID_PARAMETER,message:ie({key:RN})});h.Str_uc_params||(h.Str_uc_params={}),h.Str_uc_params.userdefine_record_id=S.userDefineRecordId}if(!ge(S.userDefinePushArgs)){if(!(Bt(S.userDefinePushArgs)&&String(S.userDefinePushArgs)&&String(S.userDefinePushArgs).length<=256))throw new ne({code:ee.INVALID_PARAMETER,message:ie({key:AN})});h.Str_uc_params||(h.Str_uc_params={}),h.Str_uc_params.userdefine_push_args=S.userDefinePushArgs}S.enableServerAudioMix&&(h.Str_uc_params||(h.Str_uc_params={}),h.Str_uc_params.enable_server_audio_mix=1,h.Str_uc_params.uc_biz_type=1e3),Si(h)||(this.bussinessInfo_=JSON.stringify(h))}},{key:"schedule",value:(V=H(f().mark(function S(h){var y,A,D;return f().wrap(function(U){for(;;)switch(U.prev=U.next){case 0:return U.next=2,JF({userId:this.userId_,sdkAppId:this.sdkAppId_,roomId:h,useStringRoomId:this.useStringRoomId_,version:this.version_,userSig:this.userSig_});case 2:y=U.sent,A=y.result,D=y.isCached,this.isUsingCachedSchedule_=D,A&&(this.log_.info("schedule with cache:".concat(D," : ").concat(JSON.stringify(A))),A.trtcCapability=A==null?void 0:A.trtcAutoConf,this.schedule_=q(q({},this.schedule_),A),Y.emit(GS,this.schedule_));case 7:case"end":return U.stop()}},S,this)})),function(S){return V.apply(this,arguments)})},{key:"getSignalChannelUrl",value:function(){var S={mainUrl:"",backupUrl:""},h=PS();return h?S.mainUrl=S.backupUrl="wss://".concat(h,".rtc.qq.com"):this.proxy_?S.mainUrl=S.backupUrl=this.proxy_:this.unifiedProxy_?S.mainUrl=S.backupUrl="wss://".concat(this.unifiedProxy_):Array.isArray(this.schedule_.domains)&&this.schedule_.domains.length>0&&(S.mainUrl=S.backupUrl="wss://".concat(this.schedule_.domains[0]),this.schedule_.domains[1]&&(S.backupUrl="wss://".concat(this.schedule_.domains[1]))),S}},{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(S){var h=this;this.log_.info("setup signal channel");var y=this.getSignalChannelUrl(),A=y.mainUrl,D=y.backupUrl;return this.signalChannel_=new gV({sdkAppId:this.sdkAppId_,userId:this.userId_,userSig:this.userSig_,roomId:S.roomId,url:A,backupUrl:D,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(st.NETWORK_QUALITY,function(U){h.emitter_.emit(st.NETWORK_QUALITY,U)})),this.deviceDetector_||(this.deviceDetector_=new QV({client:this})),this.subscriptionManager_||(this.subscriptionManager_=new uF({client:this})),this.badCaseDetector_||(this.badCaseDetector_=new GF({client:this,stats:this.stats_})),this.callDurationCalculator_||(this.callDurationCalculator_=new qF({client:this})),this.mixTranscodeManager_||(this.mixTranscodeManager_=new zF({client:this,signalChannel:this.signalChannel_})),this.publishCDNManager_&&this.publishCDNManager_.setSignalChannel({signalChannel:this.signalChannel_}),this.signalChannel_.on(em,function(U){h.log_.info("SignalChannel state changed from ".concat(U.prevState," to ").concat(U.state)),h.emitter_.emit(st.CONNECTION_STATE_CHANGED,U)}),this.signalChannel_.on(tm,function(U){h.reset(),h.emitter_.emit(st.ERROR,U)}),this.signalChannel_.once(lk,function(U){h.tinyId_=U.signalInfo.tinyId,Y.emit(ul,{client:h})}),this.signalChannel_.on(mt.PEER_JOIN,this.onPeerJoin,this),this.signalChannel_.on(mt.PEER_LEAVE,this.onPeerLeave,this),this.signalChannel_.on(mt.UPDATE_REMOTE_MUTE_STAT,function(U){Date.now()-h.lastHeartBeatTime_>=1e4&&h.doHeartbeat(),Y.emit(Ap,{client:h,data:U.data}),h.onPublishedUserList(U.data),h.onUpdateRemoteMuteStat(U.data)}),this.signalChannel_.on(mt.CLIENT_BANNED,function(U){var K,J=U.data.data.reason;if(xe.uploadEvent({log:"stat-banned:".concat(J),userId:h.userId_}),J===PM)K="you got banned by the admin";else if(J===DM)K="duplicated userId joining the room";else if(J===OM)K="the room has been disbanded by the admin",J=J.replace("_","-");else if(J===LM)return h.log_.warn("".concat(J," last heart beat time: ").concat(h.lastHeartBeatTime_," interval: ").concat(Date.now()-h.lastHeartBeatTime_,", visibility: ").concat(document.visibilityState)),void h.reJoin();h.log_[J==="kick"?"error":"info"]("user was banned because of [".concat(J,"]")),h.reset(),h.emitter_.emit(st.CLIENT_BANNED,{reason:J,message:ie({key:KN,data:{message:K,reason:J}})||J})}),Y.emit(Dp,{client:this}),this.signalChannel_.connect()}},{key:"preJoin",value:(P=H(f().mark(function S(h){var y,A,D,U;return f().wrap(function(K){for(;;)switch(K.prev=K.next){case 0:return this.joinOptions_=h,K.next=3,mm();case 3:if(this.checkSystemResult_=K.sent,this.checkDestroy(),(y=PS())||(y=Hu,this.proxy_&&(this.proxy_.startsWith(NM)?y=VM:this.proxy_.startsWith(UM)&&(y=jM))),this.env_=y,xe.setConfig({env:y,sdkAppId:this.sdkAppId_,userId:this.userId_,roomId:h.roomId}),this.uploadTrtcStats(),A=this.checkSystemResult_.detail,D=A.isH264EncodeSupported,U=A.isVp8EncodeSupported,fm()&&(D||U)){K.next=13;break}throw new ne({code:ee.NOT_SUPPORTED,message:ie({key:fS})});case 13:case"end":return K.stop()}},S,this)})),function(S){return P.apply(this,arguments)})},{key:"join",value:(R=H(f().mark(function S(h){var y,A=this;return f().wrap(function(D){for(;;)switch(D.prev=D.next){case 0:return this.roomId_=h.roomId,ge(h.role)||(this.role_=h.role),ge(h.privateMapKey)||(this.privateMapKey_=h.privateMapKey),y=Pt(),Y.emit(cl,{client:this}),mn(this.userId_,{eventId:YU,eventDesc:"joining room",timestamp:rn(),userId:this.userId_,tinyId:this.tinyId_}),D.next=8,this.preJoin(h);case 8:return D.abrupt("return",new Promise(function(){var U=H(f().mark(function K(J,ce){return f().wrap(function(ae){for(;;)switch(ae.prev=ae.next){case 0:if(A.joinReject_=ce,ae.prev=1,A.proxy_||A.schedule_.domains){ae.next=5;break}return ae.next=5,A.schedule(h.roomId);case 5:return A.checkDestroy(),ae.next=8,A.initialize(h);case 8:return ae.next=10,A.doJoin(h);case 10:A.signalInfo_=A.signalChannel_.getSignalInfo(),Y.emit(ho,{client:A}),A.joinedTimestamp_=Pt(),xe.logSuccessEvent({userId:A.userId_,eventType:KM,delta:A.joinedTimestamp_-y}),xe.logSuccessEvent({userId:A.userId_,eventType:Sb}),xe.uploadEvent({log:"stat-autoplay-dialog:".concat(A.enableAutoPlayDialog_),userId:A.userId_}),xe.uploadEvent({log:"stat-conv-".concat(ea,"-").concat(location.hostname),userId:A.userId_}),J(),ae.next=23;break;case 20:ae.prev=20,ae.t0=ae.catch(1),ce(ae.t0);case 23:A.joinReject_=null;case 24:case"end":return ae.stop()}},K,null,[[1,20]])}));return function(K,J){return U.apply(this,arguments)}}()));case 9:case"end":return D.stop()}},S,this)})),function(S){return R.apply(this,arguments)})},{key:"checkDestroy",value:function(){if(this.isDestroyed_)throw new ne({code:ee.INVALID_OPERATION,message:ie({key:$f,data:{funName:"join"}})})}},{key:"uploadTrtcStats",value:(b=H(f().mark(function S(){var h,y,A,D,U,K,J,ce,ae,qe,Ue,Fe,lt;return f().wrap(function(ze){for(;;)switch(ze.prev=ze.next){case 0:return ze.prev=0,ze.next=3,xt.getMicrophones();case 3:A=ze.sent,h=A&&A.length,ze.next=9;break;case 7:ze.prev=7,ze.t0=ze.catch(0);case 9:return ze.prev=9,ze.next=12,xt.getCameras();case 12:D=ze.sent,y=D&&D.length,ze.next=18;break;case 16:ze.prev=16,ze.t1=ze.catch(9);case 18:U={microphone:h,camera:y},K=this.checkSystemResult_.detail,J=K.isH264EncodeSupported,ce=K.isVp8EncodeSupported,ae=K.isH264DecodeSupported,qe=K.isVp8DecodeSupported,Ue={webRTC:this.basis_.isWebRTCSupported,getUserMedia:this.basis_.isGetUserMediaSupported,webSocket:this.basis_.isWebSocketsSupported,screenShare:this.basis_.isScreenShareSupported,webAudio:this.basis_.isWebAudioSupported,h264Encode:J,h264Decode:ae,vp8Encode:ce,vp8Decode:qe},Fe={browser:this.basis_.browser,os:this.basis_.os,trtc:Ue,devices:U},lt={isWebCodecSupported:this.basis_.isWebCodecSupported,isMediaSessionSupported:this.basis_.isMediaSessionSupported,isWebTransportSupported:this.basis_.isWebTransportSupported},xe.uploadEvent({log:"trtcstats-"+JSON.stringify(Fe),userId:this.userId_}),this.log_.info("TrtcStats-"+JSON.stringify(Fe)),xe.uploadEvent({log:"trtcadvancedstats-"+JSON.stringify(lt),userId:this.userId_});case 26:case"end":return ze.stop()}},S,this,[[0,7],[9,16]])})),function(){return b.apply(this,arguments)})},{key:"doJoin",value:function(S){var h=this;return new Promise(function(y,A){h.log_.info("Join() => joining room: ".concat(h.roomId_," useStringRoomId: ").concat(h.useStringRoomId_," mode: ").concat(h.mode_," role: ").concat(h.role_));var D={roomId:String(h.roomId_),useStringRoomId:h.useStringRoomId_,privateMapKey:h.privateMapKey_,trtcRole:h.role_===br?ao:Mf,trtcScene:h.mode_===Gu?GM:HM,sdpSemantics:h.sdpSemantics_,version:C4(h.version_),ua:navigator&&navigator.userAgent||"",autoSubscribe:h.autoSubscribe_,terminalType:$i?4:rp?2:np?3:Zs?12:CS?5:ES?13:1,netType:zf[bp()],bussinessInfo:h.bussinessInfo_,receiveMix:!0};if(h.publishCDNManager_){var U=h.publishCDNManager_.handleCDNConfigForJoinData(h.bussinessInfo_),K=U.bussinessInfo,J=U.pushUserCdnInfo;Object.assign(D,{bussinessInfo:K,pushUserCdnInfo:J})}h.log_.debug("join room signal data: ".concat(JSON.stringify(D))),h.joinTimeout_=setTimeout(function(){A(new ne({code:ee.JOIN_ROOM_FAILED,message:ie({key:MN})}))},5e3),Y.emit(Ip,{client:h}),h.signalChannel_.once(dk,function(ce){h.clearJoinTimeout(),Y.emit(ul,{client:h,error:ce}),A(ce)}),h.signalChannel_.send(SU,D),h.signalChannel_.once(mt.JOIN_ROOM_RESULT,function(ce){h.clearJoinTimeout();var ae=ce.data,qe=ae.code,Ue=ae.message,Fe=ae.data;h.onPublishedUserList({data:{userList:Fe.publishers}}),Y.emit(wp,{client:h,code:qe}),qe===0?(h.isJoined_=!0,h.log_.info("Join room success, start heartbeat"),h.startHeartbeat(),h.badCaseDetector_&&h.badCaseDetector_.start(),h.syncUserList(),h.startSyncUserListInterval(),y()):(h.log_.error("Join room failed result: "+qe+" error: "+Ue),A(new ne({code:ee.JOIN_ROOM_FAILED,extraCode:qe,message:ie({key:oS,data:{error:Ue,code:qe}})})))})})}},{key:"reJoin",value:(_=H(f().mark(function S(){return f().wrap(function(h){for(;;)switch(h.prev=h.next){case 0:if(this.isJoined_){h.next=3;break}return this.log_.warn("reJoin abort"),h.abrupt("return");case 3:return this.isJoined_=!1,h.prev=4,this.log_.warn("reJoin pending: ".concat(this.joinOptions_.roomId)),this.subscriptionManager_&&this.subscriptionManager_.markAllStream(),this.signalChannel_.close(),h.next=10,this.signalChannel_.connect();case 10:return h.next=12,this.doJoin(q(q({},this.joinOptions_),{},{role:this.role_,privateMapKey:this.privateMapKey_}));case 12:this.log_.warn("reJoin success"),xe.logSuccessEvent({userId:this.userId_,eventType:kb}),this.checkConnectionsToReconnect(),this.uplinkConnection_&&!this.uplinkConnection_.getIsReconnecting()&&this.uplinkConnection_.startReconnection(),this.mixTranscodeManager_&&this.mixTranscodeManager_.reStartMixTranscode(),h.next=25;break;case 19:h.prev=19,h.t0=h.catch(4),this.log_.warn("reJoin fail "+h.t0),this.reset(),xe.logFailedEvent({userId:this.userId_,eventType:kb,error:h.t0}),this.emitter_.emit(st.ERROR,new ne({code:ee.JOIN_ROOM_FAILED,message:ie({key:NN,data:{roomId:this.joinOptions_.roomId}})}));case 25:case"end":return h.stop()}},S,this,[[4,19]])})),function(){return _.apply(this,arguments)})},{key:"leave",value:(j=H(f().mark(function S(){var h;return f().wrap(function(y){for(;;)switch(y.prev=y.next){case 0:return Y.emit(Cp,{client:this}),mn(this.userId_,{eventId:$U,eventDesc:"leaving room",timestamp:rn(),userId:this.userId_,tinyId:this.tinyId_}),y.prev=2,y.next=5,this.doHeartbeat();case 5:y.next=9;break;case 7:y.prev=7,y.t0=y.catch(2);case 9:this.doLeave(),Y.emit(fo,{client:this}),xe.logSuccessEvent({userId:this.userId_,eventType:XM}),h=Math.floor((Pt()-this.joinedTimestamp_)/1e3),xe.logSuccessEvent({userId:this.userId_,eventType:QM,delta:h});case 14:case"end":return y.stop()}},S,this,[[2,7]])})),function(){return j.apply(this,arguments)})},{key:"doLeave",value:function(){this.isJoined_&&(Y.emit(Ep,{client:this}),this.log_.info("leave() => leaving room"),this.signalChannel_.send(kU),this.reset())}},{key:"clearNetworkQuality",value:function(){this.networkQuality_&&(this.networkQuality_.stop(),this.networkQuality_=null)}},{key:"closeConnections",value:function(){var S=this;this.connections_.forEach(function(h){S.closeDownLink(h.getTinyId())})}},{key:"clearJoinTimeout",value:function(){clearTimeout(this.joinTimeout_),this.joinTimeout_=-1}},{key:"destroy",value:function(){var S,h,y;if(this.isJoined_)throw this.log_.warn(mi.INVALID_DESTROY),new ne({code:ee.INVALID_OPERATION,message:ie({key:UN})});this.isDestroyed_||(this.log_.info("destroy client"),this.joinReject_&&(this.joinReject_(new ne({code:ee.INVALID_OPERATION,message:ie({key:$f,data:{funName:"join"}})})),this.clearJoinTimeout(),this.reset()),this.off("*"),(S=this.callDurationCalculator_)===null||S===void 0||S.destroy(),(h=this.keyPointManager_)===null||h===void 0||h.destroy(),(y=this.deviceDetector_)===null||y===void 0||y.destroy(),this.callDurationCalculator_=null,this.keyPointManager_=null,this.deviceDetector_=null,this.badCaseDetector_=null,this.publishCDNManager_=null,this.isDestroyed_=!0,Y.emit(Op,{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_=_t.run(so,this.syncUserList.bind(this)))}},{key:"stopSyncUserListInterval",value:function(){_t.clearTask(this.syncUserListInterval_),this.syncUserListInterval_=-1}},{key:"syncUserList",value:(N=H(f().mark(function S(){var h,y=this;return f().wrap(function(A){for(;;)switch(A.prev=A.next){case 0:return A.prev=0,A.next=3,this.getUserList();case 3:h=A.sent,this.userMap_.size!==0&&this.userMap_.forEach(function(D){h.findIndex(function(U){return U.userId===D.userId})<0&&(y.log_.info("peer leave detected: ".concat(D.userId)),y.cleanUser({userId:D.userId,tinyId:D.tinyId}))}),h.forEach(function(D){var U=D.userId;y.userMap_.has(U)||U===y.userId_||(y.userMap_.set(U,D),y.emitter_.emit(st.PEER_JOIN,{userId:U}))}),A.next=11;break;case 8:A.prev=8,A.t0=A.catch(0),this.log_.warn("sync user list failed: "+A.t0);case 11:case"end":return A.stop()}},S,this,[[0,8]])})),function(){return N.apply(this,arguments)})},{key:"getUserList",value:function(){return this.signalChannel_?this.signalChannel_.sendWaitForResponse({command:MU,responseCommand:mt.USER_LIST_RES,enableLog:!1,timeout:2e3}).then(function(S){var h=S.data,y=h.code,A=h.message;if(y===0)return(h.data&&h.data.userList||[]).map(function(D){var U=D.userId,K=D.srcTinyId,J=D.role;return new qv({userId:U,tinyId:K,role:J})});throw ie({key:vS,data:{signalResponse:mt.USER_LIST_RES,code:y,message:A}})}):[]}},{key:"publish",value:(O=H(f().mark(function S(h){var y,A,D,U,K,J,ce,ae,qe=this,Ue=arguments;return f().wrap(function(Fe){for(;;)switch(Fe.prev=Fe.next){case 0:return y=Ue.length>1&&Ue[1]!==void 0?Ue[1]:{isAuxiliary:!1},h.setPublishState(Ys),this.isPublishing_=!0,A=Pt(),Y.emit(Pp,{client:this,stream:h}),D=y.isAuxiliary,U=D?pt:Ye,K=h.getScreen(),this.log_.info("publish() => publishing ".concat(K?Af+" ":"").concat(U," stream ").concat(h.getId())),J=this.uplinkConnection_,Fe.prev=10,J||((J=new yF({userId:this.userId_,tinyId:this.tinyId_,client:this,isUplink:!0,signalChannel:this.signalChannel_,enableSEI:this.enableSEI_})).initialize(),J.on(et.ERROR,function(lt){var ze=lt.getCode();ze!==ee.ICE_TRANSPORT_ERROR&&(ze===ee.UPLINK_RECONNECTION_FAILED&&qe.closeUplink(),qe.emitter_.emit(st.ERROR,lt))})),h.setConnection(J),Fe.next=15,J.publish(h,D);case 15:this.log_.info("local ".concat(K?Af+" ":"").concat(U," stream is published")),this.isPublishing_=!1,D?this.localAuxStream_=h:(this.localStream_=h,this.deviceDetector_&&this.deviceDetector_.setLocalStream(this.localStream_),this.localStream_.getBeautyStatus()&&this.log_.info("beauty stream is published successfully")),h.setPublishState(ZM),h.setClient(this,D),this.uplinkConnection_=J,ce=Pt(),ae=ce-A,xe.logSuccessEvent({userId:this.userId_,eventType:Tb}),xe.logSuccessEvent({userId:this.userId_,eventType:YM,delta:ae}),h.hasAudio()&&mn(this.userId_,{eventId:mk,eventDesc:"publish audio track",timestamp:rn(),userId:this.userId_,tinyId:this.tinyId_}),h.hasVideo()&&mn(this.userId_,{eventId:pk,eventDesc:"publish video track",timestamp:rn(),userId:this.userId_,tinyId:this.tinyId_}),this.networkQuality_&&this.networkQuality_.setUplinkConnection(this.uplinkConnection_),Y.emit(D4,{localStream:h,isAuxiliary:D,client:this}),this.notPublishWithoutH264Supported_=!1,h.isAIDenoiser&&Ei.handleFunctionState({fnName:"AI_DENOISER"}),Fe.next=42;break;case 33:throw Fe.prev=33,Fe.t0=Fe.catch(10),Fe.t0 instanceof ne&&Fe.t0.getCode()===ee.NOT_SUPPORTED_H264&&(this.notPublishWithoutH264Supported_=!0),h.setPublishState(Hb),J.close(),this.log_.error("failed to publish stream "+Fe.t0),this.isPublishing_=!1,xe.logFailedEvent({userId:this.userId_,eventType:Tb,error:Fe.t0}),Fe.t0;case 42:case"end":return Fe.stop()}},S,this,[[10,33]])})),function(S){return O.apply(this,arguments)})},{key:"unpublish",value:(C=H(f().mark(function S(h){var y,A;return f().wrap(function(D){for(;;)switch(D.prev=D.next){case 0:if(this.uplinkConnection_){D.next=2;break}return D.abrupt("return");case 2:return y=h===this.localAuxStream_,A=h.getScreen(),this.log_.info("unpublish() => unpublishing local ".concat(A?Af+" ":"").concat(y?pt:Ye," stream")),D.prev=5,D.next=8,this.uplinkConnection_.unpublish(h);case 8:h.setClient(null),h.setConnection(null),y?this.localAuxStream_=null:(this.localStream_=null,h.hasAudio()&&mn(this.userId_,{eventId:gk,eventDesc:"unpublish audio track",timestamp:rn(),userId:this.userId_,tinyId:this.tinyId_}),h.hasVideo()&&mn(this.userId_,{eventId:vk,eventDesc:"unpublish video track",timestamp:rn(),userId:this.userId_,tinyId:this.tinyId_})),this.localStream_||this.localAuxStream_||this.closeUplink(),xe.logSuccessEvent({userId:this.userId_,eventType:xb}),D.next=19;break;case 15:throw D.prev=15,D.t0=D.catch(5),xe.logFailedEvent({userId:this.userId_,eventType:xb,error:D.t0}),D.t0;case 19:case"end":return D.stop()}},S,this,[[5,15]])})),function(S){return C.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(S){var h=this.connections_.get(S);h&&(h.getIsReconnecting()&&h.stopReconnection(),this.subscriptionManager_&&this.subscriptionManager_.delete(h.getUserId()),h.close(),this.connections_.delete(S),this.mutedStates_.delete(S))}},{key:"subscribe",value:(v=H(f().mark(function S(h,y){var A,D,U;return f().wrap(function(K){for(;;)switch(K.prev=K.next){case 0:return this.log_.info("subscribe() => subscribe to [".concat(h.getUserId(),"] ").concat(h.getType()," stream with options: ").concat(JSON.stringify(y))),ge(y)&&(y={audio:!0,video:!0}),ge(y.audio)&&(y.audio=!0),ge(y.smallVideo)?ge(y.video)&&(y.video=!0):y.smallVideo?ge(y.video)?(y.video=!1,y.smallVideo=!0):y.video&&(y.video=!0,delete y.smallVideo,this.log_.warn("options.video and options.smallVideo can't be both true")):ge(y.video)&&(y.video=!0,delete y.smallVideo),y.video&&this.changeBigSmallRecords_.delete(h.getUserId()),A=h.getConnection(),y.smallVideo&&(A.getTrackState().smallVideo||(this.setRemoteVideoStreamType(h,"small"),y.video=!0,delete y.smallVideo)),K.prev=7,Y.emit(Np,{client:this,stream:h}),K.next=11,A.subscribe(h,y);case 11:this.subscriptionManager_&&this.subscriptionManager_.addSubscriptionRecord(h.getUserId(),h,y),this.notSubscribeWithoutH264Supported_=!1,xe.logSuccessEvent({userId:this.userId_,eventType:Ib}),K.next=24;break;case 16:throw K.prev=16,K.t0=K.catch(7),(D=K.t0 instanceof ne?K.t0.getCode():ee.UNKNOWN)===ee.NOT_SUPPORTED_H264&&(this.notSubscribeWithoutH264Supported_=!0),(U=new ne(D===ee.REMOTE_STREAM_NOT_EXIST?{code:ee.API_CALL_ABORTED,message:ie({key:tp,data:{message:K.t0.message,stream:h}})}:{code:D,message:ie({key:GN,data:{message:K.t0.message,stream:h}})})).getCode()===ee.API_CALL_ABORTED?this.log_.warn(U):this.log_.error(U),xe.logFailedEvent({userId:this.userId_,eventType:Ib,error:U}),U;case 24:case"end":return K.stop()}},S,this,[[7,16]])})),function(S,h){return v.apply(this,arguments)})},{key:"unsubscribe",value:(T=H(f().mark(function S(h){var y;return f().wrap(function(A){for(;;)switch(A.prev=A.next){case 0:return this.log_.info("unsubscribe() => unsubscribe to [".concat(h.getUserId(),"] ").concat(h.getType()," stream")),A.prev=1,y=h.getConnection(),A.next=5,y.unsubscribe(h);case 5:this.subscriptionManager_&&this.subscriptionManager_.addUnsubscriptionRecord(h.getUserId(),h),Y.emit(Vr,{client:this,stream:h}),xe.logSuccessEvent({userId:this.userId_,eventType:wb}),A.next=14;break;case 10:throw A.prev=10,A.t0=A.catch(1),xe.logFailedEvent({userId:this.userId_,eventType:wb,error:A.t0}),A.t0;case 14:case"end":return A.stop()}},S,this,[[1,10]])})),function(S){return T.apply(this,arguments)})},{key:"switchRole",value:(m=H(f().mark(function S(h){return f().wrap(function(y){for(;;)switch(y.prev=y.next){case 0:if(this.role_!==h){y.next=2;break}return y.abrupt("return");case 2:return h===Qi&&this.uplinkConnection_&&this.closeUplink(),this.log_.info("switchRole() => switch role to: "+h),y.next=6,this.doSwitchRole(h);case 6:case"end":return y.stop()}},S,this)})),function(S){return m.apply(this,arguments)})},{key:"doSwitchRole",value:function(S){var h,y,A=this,D={command:NU,data:{role:S===br?ao:Mf,privateMapKey:this.privateMapKey_},responseCommand:mt.SWITCH_ROLE_RES,retries:((h=this.schedule_.config)===null||h===void 0||(y=h.retries)===null||y===void 0?void 0:y.switchRole)||1};return this.log_.info("switchRole signal data: "+JSON.stringify(D.data)),this.signalChannel_.sendWaitForResponseWithRetry(D).then(function(U){var K=U.data,J=K.code,ce=K.message;if(J!==0)throw new ne({code:ee.SWITCH_ROLE_FAILED,message:ie({key:JN,data:{errMsg:ce,errCode:J}})});A.role_=S}).catch(function(U){throw U instanceof ne&&U.getCode()===ee.API_CALL_TIMEOUT&&(U=new ne({code:ee.SWITCH_ROLE_FAILED,message:ie({key:qN})})),A.log_.error(U),U})}},{key:"on",value:function(S,h,y){this.emitter_.on(S,h,y)}},{key:"off",value:function(S,h,y){S==="*"?this.emitter_.removeAllListeners():this.emitter_.off(S,h,y)}},{key:"getRemoteMutedState",value:function(){var S=this,h=[];return this.mutedStates_.forEach(function(y,A,D){var U=S.connections_.get(A);U&&h.push(q({userId:U.getUserId()},y))}),h}},{key:"getTransportStats",value:(I=H(f().mark(function S(){var h,y,A,D,U,K,J;return f().wrap(function(ce){for(;;)switch(ce.prev=ce.next){case 0:if(h={rtt:0,downlinksRTT:{}},!this.uplinkConnection_){ce.next=6;break}return ce.next=4,this.stats_.getSenderStats(this.uplinkConnection_);case 4:y=ce.sent,h.rtt=y.rtt;case 6:A=oe(this.connections_),ce.prev=7,A.s();case 9:if((D=A.n()).done){ce.next=17;break}return(U=ke(D.value,2))[0],K=U[1],ce.next=13,this.stats_.getReceiverStats(K);case 13:J=ce.sent,h.downlinksRTT[J.userId]=J.rtt;case 15:ce.next=9;break;case 17:ce.next=22;break;case 19:ce.prev=19,ce.t0=ce.catch(7),A.e(ce.t0);case 22:return ce.prev=22,A.f(),ce.finish(22);case 25:return ce.abrupt("return",h);case 26:case"end":return ce.stop()}},S,this,[[7,19,22,25]])})),function(){return I.apply(this,arguments)})},{key:"getLocalAudioStats",value:(E=H(f().mark(function S(){var h,y;return f().wrap(function(A){for(;;)switch(A.prev=A.next){case 0:if((h={})[this.userId_]={bytesSent:0,packetsSent:0},!this.uplinkConnection_){A.next=7;break}return A.next=5,this.stats_.getSenderStats(this.uplinkConnection_);case 5:y=A.sent,h[this.userId_]={bytesSent:y.audio.bytesSent,packetsSent:y.audio.packetsSent};case 7:return A.abrupt("return",h);case 8:case"end":return A.stop()}},S,this)})),function(){return E.apply(this,arguments)})},{key:"getLocalVideoStats",value:(x=H(f().mark(function S(){var h,y;return f().wrap(function(A){for(;;)switch(A.prev=A.next){case 0:if((h={})[this.userId_]={bytesSent:0,packetsSent:0,framesEncoded:0,framesSent:0,frameWidth:0,frameHeight:0},!this.uplinkConnection_){A.next=7;break}return A.next=5,this.stats_.getSenderStats(this.uplinkConnection_);case 5:y=A.sent,h[this.userId_]={bytesSent:y.video.bytesSent,packetsSent:y.video.packetsSent,framesEncoded:y.video.framesEncoded,framesSent:y.video.framesSent,frameWidth:y.video.frameWidth,frameHeight:y.video.frameHeight};case 7:return A.abrupt("return",h);case 8:case"end":return A.stop()}},S,this)})),function(){return x.apply(this,arguments)})},{key:"getRemoteAudioStats",value:(k=H(f().mark(function S(){var h,y,A,D,U,K,J,ce;return f().wrap(function(ae){for(;;)switch(ae.prev=ae.next){case 0:h={},y=oe(this.connections_),ae.prev=2,y.s();case 4:if((A=y.n()).done){ae.next=13;break}return(D=ke(A.value,2))[0],U=D[1],K=U.getDelay(),J=K.audioDelay,ae.next=9,this.stats_.getReceiverStats(U);case 9:(ce=ae.sent).hasAudio&&(h[ce.userId]={bytesReceived:ce.audio.bytesReceived,packetsReceived:ce.audio.packetsReceived,packetsLost:ce.audio.packetsLost,end2EndDelay:J});case 11:ae.next=4;break;case 13:ae.next=18;break;case 15:ae.prev=15,ae.t0=ae.catch(2),y.e(ae.t0);case 18:return ae.prev=18,y.f(),ae.finish(18);case 21:return ae.abrupt("return",h);case 22:case"end":return ae.stop()}},S,this,[[2,15,18,21]])})),function(){return k.apply(this,arguments)})},{key:"getRemoteVideoStats",value:(p=H(f().mark(function S(){var h,y,A,D,U,K,J,ce,ae,qe=arguments;return f().wrap(function(Ue){for(;;)switch(Ue.prev=Ue.next){case 0:h=qe.length>0&&qe[0]!==void 0?qe[0]:gt,y={},A=oe(this.connections_),Ue.prev=3,A.s();case 5:if((D=A.n()).done){Ue.next=15;break}return(U=ke(D.value,2))[0],K=U[1],Ue.next=9,this.stats_.getReceiverStats(K);case 9:J=Ue.sent,ce=K.getDelay(),ae=ce.videoDelay,h===gt&&J.hasVideo&&(y[J.userId]={bytesReceived:J.video.bytesReceived,packetsReceived:J.video.packetsReceived,packetsLost:J.video.packetsLost,framesDecoded:J.video.framesDecoded,frameWidth:J.video.frameWidth,frameHeight:J.video.frameHeight,end2EndDelay:ae}),h===Dt&&J.hasAuxiliary&&(y[J.userId]={bytesReceived:J.auxiliary.bytesReceived,packetsReceived:J.auxiliary.packetsReceived,packetsLost:J.auxiliary.packetsLost,framesDecoded:J.auxiliary.framesDecoded,frameWidth:J.auxiliary.frameWidth,frameHeight:J.auxiliary.frameHeight,end2EndDelay:ae});case 13:Ue.next=5;break;case 15:Ue.next=20;break;case 17:Ue.prev=17,Ue.t0=Ue.catch(3),A.e(Ue.t0);case 20:return Ue.prev=20,A.f(),Ue.finish(20);case 23:return Ue.abrupt("return",y);case 24:case"end":return Ue.stop()}},S,this,[[3,17,20,23]])})),function(){return p.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_=_t.run(so,this.doHeartbeat.bind(this),{delay:2e3}))}},{key:"stopHeartbeat",value:function(){this.heartbeat_!==-1&&(this.log_.info("stopHeartbeat"),_t.clearTask(this.heartbeat_),this.heartbeat_=-1,this.lastHeartBeatTime_=-1)}},{key:"doHeartbeat",value:(u=H(f().mark(function S(){var h,y,A,D,U,K;return f().wrap(function(J){for(;;)switch(J.prev=J.next){case 0:return y=this.badCaseDetector_.getMonitorFreeze(),J.next=3,this.stats_.getStatsReport({uplinkConnection:this.uplinkConnection_,downlinkConnections:this.connections_,freezeMap:y});case 3:if(A=J.sent,Y.emit(Rp,{client:this,stats:A}),(h=this.badCaseDetector_)===null||h===void 0||h.resetMonitor(),this.signalChannel_){J.next=8;break}return J.abrupt("return");case 8:D=this.signalChannel_.isConnected()?pV(this.userId_):[],U=q(q({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:zf[this.networkType_]}},A),{},{msg_event_msg:D}),this.signalChannel_.send(TU,U),K=Date.now(),this.lastHeartBeatTime_>0&&K-this.lastHeartBeatTime_>1e4&&this.log_.warn("heartbeat took ".concat(K-this.lastHeartBeatTime_)),this.lastHeartBeatTime_=K,!this.isRelayChanged_&&this.isRelayMaybeFailed()&&(this.reJoin(),this.isRelayChanged_=!0);case 15:case"end":return J.stop()}},S,this)})),function(){return u.apply(this,arguments)})},{key:"onRemoteStreamAdded",value:function(S){var h=S.content,y=h.userId,A=h.tinyId,D=h.audio,U=h.bigVideo,K=h.auxVideo,J=h.smallVideo;if(y!==null){this.userMap_.has(y)||(this.userMap_.set(y,new qv({userId:y,tinyId:A,role:br})),this.emitter_.emit(st.PEER_JOIN,{userId:y}));var ce=this.connections_.get(A);if(ce){if(ce.getIsReconnecting())return;this.log_.warn("duplicated stream-added observed, rebuild the connection"),ce.close(),this.connections_.delete(A)}var ae={audio:D,video:U,auxiliary:K,smallVideo:J};this.log_.info("remote peer [".concat(y,"] published stream. trackState: ").concat(JSON.stringify(ae))),this.createDownlinkConnection({userId:y,tinyId:A,trackState:ae})}else this.log_.warn("received null userId on stream added")}},{key:"createDownlinkConnection",value:function(S){var h=this,y=S.userId,A=S.tinyId,D=S.trackState,U=new HF({userId:y,tinyId:A,client:this,isUplink:!1,signalChannel:this.signalChannel_,autoSubscribe:this.autoSubscribe_,trackState:D,enableSEI:this.enableSEI_});this.connections_.set(A,U),this.installDownlinkEvents(U,y,A),this.autoSubscribe_?(U.initialize(),U.connect().catch(function(){!U.getMainStream()&&U.hasMainStream()&&h.initRemoteStream({type:gt,userId:y,downlinkConnection:U}),!U.getAuxStream()&&U.hasAuxStream()&&h.initRemoteStream({type:Dt,userId:y,downlinkConnection:U})})):(U.hasMainStream()&&this.initRemoteStream({type:gt,userId:y,downlinkConnection:U}),U.hasAuxStream()&&this.initRemoteStream({type:Dt,userId:y,downlinkConnection:U}))}},{key:"initRemoteStream",value:function(S){var h=S.type,y=S.userId,A=S.downlinkConnection,D=new Vv({type:h,userId:y,client:this});D.setConnection(A),A.setRemoteStream(h===gt?Sr:Ks,D),D.setIsStreamAddedEventEmitted(!0),Y.emit(ll,{client:this,stream:D}),this.emitter_.emit(st.STREAM_ADDED,{stream:D})}},{key:"installDownlinkEvents",value:function(S,h,y){var A=this;S.on(et.SEI_MESSAGE,function(D){A.emitter_.emit(st.SEI_MESSAGE,D)}),S.on(et.STREAM_ADDED,function(D){D.stream.setIsStreamAddedEventEmitted(!0),Y.emit(ll,{client:A,stream:D.stream}),A.emitter_.emit(st.STREAM_ADDED,{stream:D.stream})}),S.on(et.STREAM_REMOVED,function(D){A.changeBigSmallRecords_.delete(D.stream.getUserId()),D.stream.stop(),D.stream.setIsStreamAddedEventEmitted(!1),A.subscriptionManager_&&A.subscriptionManager_.deleteAutoRecoveryFlag(D.stream.getUserId(),D.stream.getType()),Y.emit(aa,{client:A,stream:D.stream}),A.emitter_.emit(st.STREAM_REMOVED,{stream:D.stream})}),S.on(et.STREAM_UPDATED,function(D){Y.emit(P4,{client:A,stream:D.stream});var U=S.getMixUserList();U&&(D.mixUserList=U),A.emitter_.emit(st.STREAM_UPDATED,D)}),S.on(et.STREAM_SUBSCRIBED,function(D){Y.emit(Ur,{client:A,stream:D.stream}),A.emitter_.emit(st.STREAM_SUBSCRIBED,{stream:D.stream})}),S.on(et.ERROR,function(D){var U=D.getCode();U!==ee.ICE_TRANSPORT_ERROR&&(U===ee.DOWNLINK_RECONNECTION_FAILED&&A.closeDownLink(y),A.emitter_.emit(st.ERROR,D))})}},{key:"onPeerJoin",value:function(S){var h=S.data.data,y=h.srcTinyId,A=h.userId,D=h.role;this.userMap_.has(A)||(this.userMap_.set(A,new qv({userId:A,tinyId:y,role:D})),this.emitter_.emit(st.PEER_JOIN,{userId:A}))}},{key:"onPeerLeave",value:function(S){var h=S.data.data,y=h.srcTinyId,A=h.userId,D=h.reason,U=D===void 0?0:D;this.log_.info("peer leave [".concat(A,"]: ").concat(sN[U])),this.cleanUser({userId:A,tinyId:y})}},{key:"cleanUser",value:function(S){var h=S.userId,y=S.tinyId;this.userMap_.delete(h),this.closeDownLink(y),this.emitter_.emit(st.PEER_LEAVE,{userId:h})}},{key:"onPublishedUserList",value:function(S){var h=this;try{var y=Se(S.data.userList);S.data.mixRobotList&&y.push.apply(y,Se(S.data.mixRobotList)),S.data.fakeMixUser&&y.push(S.data.fakeMixUser);var A=y.map(function(D){return D.userId});this.connections_.forEach(function(D){var U=D.getUserId(),K=D.getTinyId();A.findIndex(function(J){return J===U})<0&&(h.log_.info("peer unpublished detected [".concat(U,"]")),h.closeDownLink(K))}),y.forEach(function(D){var U=D.userId,K=D.srcTinyId,J=D.flag,ce=D.mixUserList;if(U!==h.userId_){var ae=!!(1&J),qe=!!(8&J),Ue=!!(4&J),Fe=!!(2&J),lt=h.connections_.get(K);if((Fe||ae)&&h.checkSubscribeBigSmallVideo(lt,Fe),lt){var ze=lt.getTrackState(),wc=ze.audio,ud=ze.video,Cc=ze.auxiliary,zI=ze.smallVideo;uo(ce)&&lt.setMixUserList(ce),!ud&&ae&&Y.emit(Un,{client:h,tinyId:K,userId:U,action:sn.ADD,kind:Te}),!wc&&qe&&Y.emit(Un,{client:h,tinyId:K,userId:U,action:sn.ADD,kind:Ee}),!Cc&&Ue&&Y.emit(Un,{client:h,tinyId:K,userId:U,action:sn.ADD,kind:pt}),!zI&&Fe&&Y.emit(Un,{client:h,tinyId:K,userId:U,action:sn.ADD,kind:Bu}),ud&&!ae&&Y.emit(Un,{client:h,tinyId:K,userId:U,action:sn.REMOVE,kind:Te}),wc&&!qe&&Y.emit(Un,{client:h,tinyId:K,userId:U,action:sn.REMOVE,kind:Ee}),Cc&&!Ue&&Y.emit(Un,{client:h,tinyId:K,userId:U,action:sn.REMOVE,kind:pt}),zI&&!Fe&&Y.emit(Un,{client:h,tinyId:K,userId:U,action:sn.REMOVE,kind:Bu})}else h.log_.info("peer published detected [".concat(U,"]")),h.onRemoteStreamAdded({content:{audio:qe,bigVideo:ae,auxVideo:Ue,smallVideo:Fe,userId:U,tinyId:K}})}})}catch(D){}}},{key:"onUpdateRemoteMuteStat",value:function(S){var h=this,y=S.data;(y&&y.userList||[]).forEach(function(A){var D=A.srcTinyId,U=A.userId;if(D!==0&&D!==h.tinyId_){var K=h.connections_.get(D);if(K){var J=K.getMainStream();if(J&&J.getIsStreamAddedEventEmitted()){var ce=!!(1&A.flag),ae=!!(8&A.flag),qe=!!(2&A.flag),Ue=!!(64&A.flag),Fe=!!(16&A.flag),lt=h.mutedStates_.get(D);if(lt===void 0)return h.mutedStates_.set(D,{hasAudio:ae,hasVideo:ce,hasSmall:qe,audioMuted:Ue,videoMuted:Fe}),ce?Fe?h.emitter_.emit(st.MUTE_VIDEO,{userId:U}):h.emitter_.emit(st.UNMUTE_VIDEO,{userId:U}):h.emitter_.emit(st.MUTE_VIDEO,{userId:U}),void(ae?Ue?h.emitter_.emit(st.MUTE_AUDIO,{userId:U}):h.emitter_.emit(st.UNMUTE_AUDIO,{userId:U}):h.emitter_.emit(st.MUTE_AUDIO,{userId:U}));var ze=!lt.audioMuted&&lt.hasAudio,wc=!Ue&&ae,ud=!lt.videoMuted&&lt.hasVideo,Cc=!Fe&&ce;h.mutedStates_.set(D,{hasAudio:ae,hasVideo:ce,hasSmall:qe,audioMuted:Ue,videoMuted:Fe}),ze!==wc&&(wc?h.emitter_.emit(st.UNMUTE_AUDIO,{userId:U}):h.emitter_.emit(st.MUTE_AUDIO,{userId:U})),ud!==Cc&&(Cc?h.emitter_.emit(st.UNMUTE_VIDEO,{userId:U}):h.emitter_.emit(st.MUTE_VIDEO,{userId:U}))}}else h.mutedStates_.delete(D)}})}},{key:"getEnv",value:function(){return this.env_}},{key:"getSubscriptionManager",value:function(){return this.subscriptionManager_}},{key:"startPublishCDNStream",value:(l=H(f().mark(function S(){var h,y=arguments;return f().wrap(function(A){for(;;)switch(A.prev=A.next){case 0:if(h=y.length>0&&y[0]!==void 0?y[0]:{},this.log_.info("startPublishCDNStream with params: ".concat(JSON.stringify(h),"; isJoined: ").concat(this.isJoined_,"; hasMainStream: ").concat(!!this.localStream_,"; hasAuxStream: ").concat(!!this.localAuxStream_,";")),h.streamType=h.streamType||Ye,h.streamType===pt&&(h.streamType=Mn),h.streamId=h.streamId||"",!this.isJoined_){A.next=10;break}if(h.streamType!==Ye||this.localStream_){A.next=8;break}throw new ne({code:ee.INVALID_OPERATION,message:ie({key:sS})});case 8:if(h.streamType!==Mn||this.localAuxStream_){A.next=10;break}throw new ne({code:ee.INVALID_OPERATION,message:ie({key:sS})});case 10:return A.next=12,this.publishCDNManager_.startPublishTencentCDN(h);case 12:if(!(h.appId&&h.bizId&&h.url)){A.next=15;break}return A.next=15,this.publishCDNManager_.startPublishGivenCDN(h);case 15:case"end":return A.stop()}},S,this)})),function(){return l.apply(this,arguments)})},{key:"stopPublishCDNStream",value:(s=H(f().mark(function S(){return f().wrap(function(h){for(;;)switch(h.prev=h.next){case 0:if(this.publishCDNManager_.getIsPublishingTencentCDN()){h.next=2;break}throw new ne({code:ee.INVALID_OPERATION,message:ie({key:XN})});case 2:return this.log_.info("stopPublishCDNStream"),h.next=5,this.publishCDNManager_.stopPublishTencentCDN();case 5:if(!this.publishCDNManager_.getIsPublishingGivenCDN()){h.next=8;break}return h.next=8,this.publishCDNManager_.stopPublishGivenCDN();case 8:case"end":return h.stop()}},S,this)})),function(){return s.apply(this,arguments)})},{key:"startMixTranscode",value:(a=H(f().mark(function S(h){return f().wrap(function(y){for(;;)switch(y.prev=y.next){case 0:if(this.isJoined_&&this.mixTranscodeManager_){y.next=2;break}throw new ne({code:ee.INVALID_OPERATION,message:ie({key:YN})});case 2:return ge(h.mode)&&(h.mode=Gf.MANUAL),y.prev=3,this.log_.info("startMixTranscode with config ".concat(JSON.stringify(h))),xe.uploadEvent({log:"mix-transcode-mode:".concat(h.mode),userId:this.userId_}),y.next=8,this.mixTranscodeManager_.startMixTranscode(h);case 8:xe.logSuccessEvent({userId:this.userId_,eventType:Nb}),y.next=15;break;case 11:throw y.prev=11,y.t0=y.catch(3),xe.logFailedEvent({userId:this.userId_,eventType:Nb,error:y.t0}),y.t0;case 15:case"end":return y.stop()}},S,this,[[3,11]])})),function(S){return a.apply(this,arguments)})},{key:"stopMixTranscode",value:(c=H(f().mark(function S(){return f().wrap(function(h){for(;;)switch(h.prev=h.next){case 0:if(this.isJoined_&&this.mixTranscodeManager_){h.next=2;break}throw new ne({code:ee.INVALID_OPERATION,message:ie({key:$N})});case 2:return h.prev=2,h.next=5,this.mixTranscodeManager_.stopMixTranscode();case 5:xe.logSuccessEvent({userId:this.userId_,eventType:Ub}),h.next=12;break;case 8:throw h.prev=8,h.t0=h.catch(2),xe.logFailedEvent({userId:this.userId_,eventType:Ub,error:h.t0}),h.t0;case 12:case"end":return h.stop()}},S,this,[[2,8]])})),function(){return c.apply(this,arguments)})},{key:"getSystemResult",value:function(){return this.checkSystemResult_}},{key:"enableAudioVolumeEvaluation",value:function(){var S=this,h=arguments.length>0&&arguments[0]!==void 0?arguments[0]:2e3,y=arguments.length>1&&arguments[1]!==void 0&&arguments[1];if(!$n(h))throw new ne({code:ee.INVALID_PARAMETER,message:ie({key:ZN})});if(this.log_.info("enableAudioVolumeEvaluation with interval: "+h),h<=0)return this.enableAudioVolumeEvaluation_=!1,_t.clearTask(this.audioVolumeIntervalId_),void(this.audioVolumeIntervalId_=null);h=Math.floor(Math.max(h,16)),Y.emit(Lp,{interval:h}),this.audioVolumeIntervalId_&&(_t.clearTask(this.audioVolumeIntervalId_),this.audioVolumeIntervalId_=null),this.enableAudioVolumeEvaluation_=!0,this.audioVolumeIntervalId_=_t.run(Xu,function(){var A=[];if(S.localStream_){var D=Math.floor(100*S.localStream_.getAudioLevel());A.push({userId:S.userId_,audioVolume:D,stream:S.localStream_})}S.connections_.forEach(function(U){var K=U.getSubscribedMainStream();if(K){var J=Math.floor(100*K.getAudioLevel());A.push({userId:U.getUserId(),audioVolume:J,stream:K})}}),S.emitter_.emit(st.AUDIO_VOLUME,{result:A})},{fps:1e3/h,backgroundTask:y})}},{key:"callExperimentalAPI",value:function(S,h){return YF.call(S,q({client:this},h))}},{key:"setProperty",value:function(S,h){var y="".concat(S,"_");ge(this[y])||(this[y]=h)}},{key:"uploadAllCallStats",value:function(){var S=this;this.callDurationCalculator_.getDurationMap().forEach(function(h,y){var A={userId:h.userId,type:h.type,duration:S.callDurationCalculator_.getDuration(y,Te),dataFreeze:S.badCaseDetector_.getDataFreezeDuration(y).dataFreeze,renderFreeze:S.badCaseDetector_.getRenderFreezeDuration(y).renderFreeze};xe.uploadEvent({log:"callStats-"+JSON.stringify(A),userId:S.userId_})}),this.badCaseDetector_.stop(),this.callDurationCalculator_.reset()}},{key:"enableSmallStream",value:(o=H(f().mark(function S(){return f().wrap(function(h){for(;;)switch(h.prev=h.next){case 0:if(!this.isPublished()&&!this.isPublishing_){h.next=2;break}throw new ne({code:ee.INVALID_OPERATION,message:ie({key:e3})});case 2:if(!Vk()){h.next=7;break}this.setIsEnableSmallStream(!0),this.log_.info("SmallStream successfully enabled"),h.next=8;break;case 7:throw new ne({code:ee.INVALID_OPERATION,message:ie({key:n3})});case 8:case"end":return h.stop()}},S,this)})),function(){return o.apply(this,arguments)})},{key:"disableSmallStream",value:(r=H(f().mark(function S(){return f().wrap(function(h){for(;;)switch(h.prev=h.next){case 0:if(!this.isPublished()&&!this.isPublishing_){h.next=2;break}throw new ne({code:ee.INVALID_OPERATION,message:ie({key:t3})});case 2:this.setIsEnableSmallStream(!1),this.log_.info("SmallStream successfully disabled");case 4:case"end":return h.stop()}},S,this)})),function(){return r.apply(this,arguments)})},{key:"setSmallStreamProfile",value:function(S){var h=this;S&&S.framerate&&(S.frameRate=S.framerate),S.width*S.height>307200&&(S.width=320,S.height=240,this.log_.info("Small stream resolution is beyond limitation, which is invalid. Reset to 320 * 240")),Object.keys(this.smallStreamConfig_).forEach(function(J){S[J]&&(h.smallStreamConfig_[J]=S[J])});var y=this.smallStreamConfig_,A=y.width,D=y.height,U=y.bitrate,K=y.frameRate;if(this.log_.info("setSmallStreamProfile: bitrate=".concat(U,", frameRate=").concat(K,", height=").concat(D,", width=").concat(A)),A<0||D<0||U<0||K<0)throw new ne({code:ee.INVALID_PARAMETER,message:ie({key:r3})})}},{key:"setRemoteVideoStreamType",value:(i=H(f().mark(function S(h,y){return f().wrap(function(A){for(;;)switch(A.prev=A.next){case 0:if(h instanceof Vv){A.next=2;break}throw new ne({code:ee.INVALID_PARAMETER,message:ie({key:i3})});case 2:if(h.getConnection()){A.next=4;break}throw new ne({code:ee.INVALID_OPERATION,message:ie({key:Yf})});case 4:if(h.getType()!==Dt){A.next=6;break}return A.abrupt("return");case 6:A.t0=y,A.next=A.t0===Gb||A.t0===zb?9:12;break;case 9:return A.next=11,this.changeVideoType(h,y);case 11:case 12:return A.abrupt("break",13);case 13:case"end":return A.stop()}},S,this)})),function(S,h){return i.apply(this,arguments)})},{key:"changeVideoType",value:(n=H(f().mark(function S(h,y){var A,D;return f().wrap(function(U){for(;;)switch(U.prev=U.next){case 0:A=h.getUserId(),D={stream:h,options:{video:y===Gb,smallVideo:y===zb},isSubscribing:!1,reSubscribeCount:10},this.changeBigSmallRecords_.set(A,D),this.log_.info("set [".concat(A,"] ").concat(h.getType()," stream video prefer type: ").concat(y));case 5:case"end":return U.stop()}},S,this)})),function(S,h){return n.apply(this,arguments)})},{key:"checkSubscribeBigSmallVideo",value:(t=H(f().mark(function S(h,y){var A,D,U,K,J,ce,ae,qe,Ue,Fe,lt;return f().wrap(function(ze){for(;;)switch(ze.prev=ze.next){case 0:if(h!=null&&h.isBigStreamSubscribed||h!=null&&h.isSmallStreamSubscribed){ze.next=2;break}return ze.abrupt("return");case 2:if(A=h.getUserId(),this.changeBigSmallRecords_.has(A)){ze.next=5;break}return ze.abrupt("return");case 5:if(D=this.changeBigSmallRecords_.get(A),U=h.getSubscribeState(),K=U.video,J=U.smallVideo,ce=D.stream,ae=D.options,qe=D.isSubscribing,Ue=D.reSubscribeCount,!(ae.video&&K||ae.smallVideo&&J&&y)){ze.next=10;break}return ze.abrupt("return");case 10:if(Fe={video:ae.video,smallVideo:ae.smallVideo},!(y&&h.isBigStreamSubscribed||h.isSmallStreamSubscribed)){ze.next=31;break}if(ze.prev=12,!(ae&&ce&&!qe&&Ue>=1)){ze.next=24;break}return D.isSubscribing=!0,D.reSubscribeCount=Ue-1,lt=ce.getConnection(),!y&&lt.isSmallStreamSubscribed&&(Fe={video:!0,smallVideo:!1}),Fe.emitEvent=!1,ze.next=21,lt==null?void 0:lt.subscribe(ce,Fe);case 21:this.log_.info("change [".concat(A,"] to ").concat(Fe.smallVideo?"small":"big"," video successfully. count ").concat(10-D.reSubscribeCount,".")),D.isSubscribing=!1,D.reSubscribeCount=10;case 24:ze.next=31;break;case 26:ze.prev=26,ze.t0=ze.catch(12),this.log_.info("change [".concat(A,"] to ").concat(Fe.smallVideo?"small":"big"," video failed. count ").concat(10-D.reSubscribeCount,".")),D.isSubscribing=!1,Ue===0&&this.changeBigSmallRecords_.delete(A);case 31:case"end":return ze.stop()}},S,this,[[12,26]])})),function(S,h){return t.apply(this,arguments)})},{key:"setIsEnableSmallStream",value:function(S){this.isEnableSmallStream_=S}},{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 S=Se(this.connections_.values());return this.uplinkConnection_&&S.push(this.uplinkConnection_),S}},{key:"isRelayMaybeFailed",value:function(){if(!this.signalChannel_.isOnline)return!1;var S=this.getAllConnections();if(S.length===0)return!1;for(var h=0;h<S.length;h++)if(S[h].getReconnectionCount()<6)return!1;return!0}},{key:"getUseStringRoomId",value:function(){return this.useStringRoomId_}},{key:"checkConnectionsToReconnect",value:function(){var S=this;this.getAllConnections().forEach(function(h){if(!h.getIsReconnecting()){var y=h.getPeerConnection();y&&y.connectionState===Uf&&(S.log_.warn("[".concat(h.getUserId(),"] pc is closed but not reconnect")),h.startReconnection())}})}},{key:"getEnableAutoPlayDialog",value:function(){return this.enableAutoPlayDialog_}},{key:"sendSEIMessage",value:function(S,h){this.uplinkConnection_.sendSEI(S,h)}},{key:"setProxyServer",value:function(S){if(this.log_.info("set proxy server: ".concat(JSON.stringify(S))),Bt(S)){if(!S.startsWith("wss://"))throw new ne({code:ee.INVALID_PARAMETER,message:ie({key:PN})});this.proxy_=S}else if(_i(S)){var h=S.websocketProxy,y=S.loggerProxy,A=S.scheduleProxy,D=S.unifiedProxy;h&&(this.proxy_=h),y&&Of(y),A&&qb(A),D&&(this.unifiedProxy_=D,Of("https://".concat(D)),qb(D))}}},{key:"setTurnServer",value:function(S){this.log_.info("set turn server: "+JSON.stringify(S));var h=[];Array.isArray(S)?S.forEach(function(y){return h.push(MS(y))}):_i(S)&&h.push(MS(S)),this.turnServers_=h}},{key:"get2k4kFlag",value:function(){var S,h;return((S=this.schedule_)===null||S===void 0||(h=S.trtcCapability)===null||h===void 0?void 0:h["2k4k"])||2}}]),e}(),X(Pe.prototype,"join",[sI,cI,uI],Object.getOwnPropertyDescriptor(Pe.prototype,"join"),Pe.prototype),X(Pe.prototype,"leave",[lI],Object.getOwnPropertyDescriptor(Pe.prototype,"leave"),Pe.prototype),X(Pe.prototype,"getUserList",[dI],Object.getOwnPropertyDescriptor(Pe.prototype,"getUserList"),Pe.prototype),X(Pe.prototype,"publish",[hI,fI,pI],Object.getOwnPropertyDescriptor(Pe.prototype,"publish"),Pe.prototype),X(Pe.prototype,"unpublish",[mI,vI],Object.getOwnPropertyDescriptor(Pe.prototype,"unpublish"),Pe.prototype),X(Pe.prototype,"subscribe",[gI],Object.getOwnPropertyDescriptor(Pe.prototype,"subscribe"),Pe.prototype),X(Pe.prototype,"unsubscribe",[_I],Object.getOwnPropertyDescriptor(Pe.prototype,"unsubscribe"),Pe.prototype),X(Pe.prototype,"switchRole",[yI,bI,SI],Object.getOwnPropertyDescriptor(Pe.prototype,"switchRole"),Pe.prototype),X(Pe.prototype,"startPublishCDNStream",[kI,TI],Object.getOwnPropertyDescriptor(Pe.prototype,"startPublishCDNStream"),Pe.prototype),X(Pe.prototype,"stopPublishCDNStream",[xI],Object.getOwnPropertyDescriptor(Pe.prototype,"stopPublishCDNStream"),Pe.prototype),X(Pe.prototype,"startMixTranscode",[II,wI],Object.getOwnPropertyDescriptor(Pe.prototype,"startMixTranscode"),Pe.prototype),X(Pe.prototype,"stopMixTranscode",[CI],Object.getOwnPropertyDescriptor(Pe.prototype,"stopMixTranscode"),Pe.prototype),X(Pe.prototype,"enableAudioVolumeEvaluation",[EI],Object.getOwnPropertyDescriptor(Pe.prototype,"enableAudioVolumeEvaluation"),Pe.prototype),X(Pe.prototype,"enableSmallStream",[RI],Object.getOwnPropertyDescriptor(Pe.prototype,"enableSmallStream"),Pe.prototype),X(Pe.prototype,"disableSmallStream",[AI],Object.getOwnPropertyDescriptor(Pe.prototype,"disableSmallStream"),Pe.prototype),X(Pe.prototype,"setSmallStreamProfile",[PI],Object.getOwnPropertyDescriptor(Pe.prototype,"setSmallStreamProfile"),Pe.prototype),X(Pe.prototype,"setRemoteVideoStreamType",[DI],Object.getOwnPropertyDescriptor(Pe.prototype,"setRemoteVideoStreamType"),Pe.prototype),X(Pe.prototype,"sendSEIMessage",[LI,OI,MI],Object.getOwnPropertyDescriptor(Pe.prototype,"sendSEIMessage"),Pe.prototype),X(Pe.prototype,"setProxyServer",[NI],Object.getOwnPropertyDescriptor(Pe.prototype,"setProxyServer"),Pe.prototype),X(Pe.prototype,"setTurnServer",[UI],Object.getOwnPropertyDescriptor(Pe.prototype,"setTurnServer"),Pe.prototype),Pe),ZF=0,e7=0,t7=(VI=St($s),jI=St($s),BI=St($s),FI=Jl(Qt.TRTC.createClient),HI=St($s),GI=Jl(Qt.TRTC.createStream),Yt=function(){function e(){Q(this,e),this.name_=$s,this.VERSION=Bi,this.Logger={loggerManager:ye,LogLevel:Nn,setLogLevel:function(n){ye.setLogLevel(n),n<=1&&I4()},enableUploadLog:function(){Ei.handleFunctionState({fnName:"TRTC.enableUploadLog"}),ye.enableUploadLog()},disableUploadLog:function(){ye.warn("disableUploadLog"),Ei.handleFunctionState({fnName:"TRTC.disableUploadLog"}),ye.disableUploadLog()}}}var t;return Ie(e,[{key:"checkSystemRequirements",value:(t=H(f().mark(function n(){return f().wrap(function(i){for(;;)switch(i.prev=i.next){case 0:return i.next=2,mm();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 Ok()}},{key:"isSmallStreamSupported",value:function(){return Vk()}},{key:"getDevices",value:function(){return Tm()}},{key:"getCameras",value:function(){return function(){return km.apply(this,arguments)}()}},{key:"getMicrophones",value:function(){return Hk()}},{key:"getSpeakers",value:function(){return Gk()}},{key:"createClient",value:function(n){(function(){if(qS&&(qS=!1,ye.getLogLevel()!=xt.Logger.LogLevel.NONE&&(console.info("******************************************************************************"),console.info("* TRTC Web SDK"),console.info("* API Document: "+"".concat(Kf,"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("******************************************************************************")),ye.info("TRTC Web SDK Version: 4.15.14"),ye.info("UserAgent: "+navigator.userAgent),ye.info("URL of current page: "+location.href),navigator.userAgentData&&pn(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(","))),ye.info(c)}).catch(function(){})}catch(o){}})();var i={version:this.VERSION},r=new $F(q(q(q({},i),n),{},{seq:++ZF}));return Y.emit(HS,{client:r}),r}},{key:"createStream",value:function(n){return new _F(q(q({},n),{},{seq:++e7}))}}]),e}(),X(Yt.prototype,"checkSystemRequirements",[VI],Object.getOwnPropertyDescriptor(Yt.prototype,"checkSystemRequirements"),Yt.prototype),X(Yt.prototype,"isScreenShareSupported",[jI],Object.getOwnPropertyDescriptor(Yt.prototype,"isScreenShareSupported"),Yt.prototype),X(Yt.prototype,"isSmallStreamSupported",[BI],Object.getOwnPropertyDescriptor(Yt.prototype,"isSmallStreamSupported"),Yt.prototype),X(Yt.prototype,"createClient",[FI,HI],Object.getOwnPropertyDescriptor(Yt.prototype,"createClient"),Yt.prototype),X(Yt.prototype,"createStream",[GI],Object.getOwnPropertyDescriptor(Yt.prototype,"createStream"),Yt.prototype),Yt),xt=new t7;return xt})});var ng=$v((T7,tg)=>{"use strict";var Mo=typeof Reflect=="object"?Reflect:null,XI=Mo&&typeof Mo.apply=="function"?Mo.apply:function(q,f,G){return Function.prototype.apply.call(q,f,G)},hd;Mo&&typeof Mo.ownKeys=="function"?hd=Mo.ownKeys:Object.getOwnPropertySymbols?hd=function(q){return Object.getOwnPropertyNames(q).concat(Object.getOwnPropertySymbols(q))}:hd=function(q){return Object.getOwnPropertyNames(q)};function l7(te){console&&console.warn&&console.warn(te)}var YI=Number.isNaN||function(q){return q!==q};function ft(){ft.init.call(this)}tg.exports=ft;tg.exports.once=p7;ft.EventEmitter=ft;ft.prototype._events=void 0;ft.prototype._eventsCount=0;ft.prototype._maxListeners=void 0;var QI=10;function fd(te){if(typeof te!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof te)}Object.defineProperty(ft,"defaultMaxListeners",{enumerable:!0,get:function(){return QI},set:function(te){if(typeof te!="number"||te<0||YI(te))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+te+".");QI=te}});ft.init=function(){(this._events===void 0||this._events===Object.getPrototypeOf(this)._events)&&(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0};ft.prototype.setMaxListeners=function(q){if(typeof q!="number"||q<0||YI(q))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+q+".");return this._maxListeners=q,this};function $I(te){return te._maxListeners===void 0?ft.defaultMaxListeners:te._maxListeners}ft.prototype.getMaxListeners=function(){return $I(this)};ft.prototype.emit=function(q){for(var f=[],G=1;G<arguments.length;G++)f.push(arguments[G]);var $=q==="error",H=this._events;if(H!==void 0)$=$&&H.error===void 0;else if(!$)return!1;if($){var Q;if(f.length>0&&(Q=f[0]),Q instanceof Error)throw Q;var Re=new Error("Unhandled error."+(Q?" ("+Q.message+")":""));throw Re.context=Q,Re}var Ie=H[q];if(Ie===void 0)return!1;if(typeof Ie=="function")XI(Ie,this,f);else for(var $e=Ie.length,Ct=rw(Ie,$e),G=0;G<$e;++G)XI(Ct[G],this,f);return!0};function ZI(te,q,f,G){var $,H,Q;if(fd(f),H=te._events,H===void 0?(H=te._events=Object.create(null),te._eventsCount=0):(H.newListener!==void 0&&(te.emit("newListener",q,f.listener?f.listener:f),H=te._events),Q=H[q]),Q===void 0)Q=H[q]=f,++te._eventsCount;else if(typeof Q=="function"?Q=H[q]=G?[f,Q]:[Q,f]:G?Q.unshift(f):Q.push(f),$=$I(te),$>0&&Q.length>$&&!Q.warned){Q.warned=!0;var Re=new Error("Possible EventEmitter memory leak detected. "+Q.length+" "+String(q)+" listeners added. Use emitter.setMaxListeners() to increase limit");Re.name="MaxListenersExceededWarning",Re.emitter=te,Re.type=q,Re.count=Q.length,l7(Re)}return te}ft.prototype.addListener=function(q,f){return ZI(this,q,f,!1)};ft.prototype.on=ft.prototype.addListener;ft.prototype.prependListener=function(q,f){return ZI(this,q,f,!0)};function d7(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length===0?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function ew(te,q,f){var G={fired:!1,wrapFn:void 0,target:te,type:q,listener:f},$=d7.bind(G);return $.listener=f,G.wrapFn=$,$}ft.prototype.once=function(q,f){return fd(f),this.on(q,ew(this,q,f)),this};ft.prototype.prependOnceListener=function(q,f){return fd(f),this.prependListener(q,ew(this,q,f)),this};ft.prototype.removeListener=function(q,f){var G,$,H,Q,Re;if(fd(f),$=this._events,$===void 0)return this;if(G=$[q],G===void 0)return this;if(G===f||G.listener===f)--this._eventsCount===0?this._events=Object.create(null):(delete $[q],$.removeListener&&this.emit("removeListener",q,G.listener||f));else if(typeof G!="function"){for(H=-1,Q=G.length-1;Q>=0;Q--)if(G[Q]===f||G[Q].listener===f){Re=G[Q].listener,H=Q;break}if(H<0)return this;H===0?G.shift():h7(G,H),G.length===1&&($[q]=G[0]),$.removeListener!==void 0&&this.emit("removeListener",q,Re||f)}return this};ft.prototype.off=ft.prototype.removeListener;ft.prototype.removeAllListeners=function(q){var f,G,$;if(G=this._events,G===void 0)return this;if(G.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):G[q]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete G[q]),this;if(arguments.length===0){var H=Object.keys(G),Q;for($=0;$<H.length;++$)Q=H[$],Q!=="removeListener"&&this.removeAllListeners(Q);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(f=G[q],typeof f=="function")this.removeListener(q,f);else if(f!==void 0)for($=f.length-1;$>=0;$--)this.removeListener(q,f[$]);return this};function tw(te,q,f){var G=te._events;if(G===void 0)return[];var $=G[q];return $===void 0?[]:typeof $=="function"?f?[$.listener||$]:[$]:f?f7($):rw($,$.length)}ft.prototype.listeners=function(q){return tw(this,q,!0)};ft.prototype.rawListeners=function(q){return tw(this,q,!1)};ft.listenerCount=function(te,q){return typeof te.listenerCount=="function"?te.listenerCount(q):nw.call(te,q)};ft.prototype.listenerCount=nw;function nw(te){var q=this._events;if(q!==void 0){var f=q[te];if(typeof f=="function")return 1;if(f!==void 0)return f.length}return 0}ft.prototype.eventNames=function(){return this._eventsCount>0?hd(this._events):[]};function rw(te,q){for(var f=new Array(q),G=0;G<q;++G)f[G]=te[G];return f}function h7(te,q){for(;q+1<te.length;q++)te[q]=te[q+1];te.pop()}function f7(te){for(var q=new Array(te.length),f=0;f<q.length;++f)q[f]=te[f].listener||te[f];return q}function p7(te,q){return new Promise(function(f,G){function $(Q){te.removeListener(q,H),G(Q)}function H(){typeof te.removeListener=="function"&&te.removeListener("error",$),f([].slice.call(arguments))}iw(te,q,H,{once:!0}),q!=="error"&&m7(te,$,{once:!0})})}function m7(te,q,f){typeof te.on=="function"&&iw(te,"error",q,f)}function iw(te,q,f,G){if(typeof te.on=="function")G.once?te.once(q,f):te.on(q,f);else if(typeof te.addEventListener=="function")te.addEventListener(q,function $(H){G.once&&te.removeEventListener(q,$),f(H)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof te)}});var ow=$v((rg,ig)=>{(function(te,q){typeof rg=="object"&&typeof ig!="undefined"?ig.exports=q(Cr()):typeof define=="function"&&define.amd?define(["trtc-js-sdk"],q):(te=typeof globalThis!="undefined"?globalThis:te||self).RTCBeautyPlugin=q(te.TRTC)})(rg,function(te){function q(le){return le&&typeof le=="object"&&"default"in le?le:{default:le}}var f=q(te);function G(){G=function(){return le};var le={},ke=Object.prototype,Se=ke.hasOwnProperty,je=typeof Symbol=="function"?Symbol:{},He=je.iterator||"@@iterator",oe=je.asyncIterator||"@@asyncIterator",X=je.toStringTag||"@@toStringTag";function se(he,de,Ne){return Object.defineProperty(he,de,{value:Ne,enumerable:!0,configurable:!0,writable:!0}),he[de]}try{se({},"")}catch(he){se=function(de,Ne,We){return de[Ne]=We}}function z(he,de,Ne,We){var De=de&&de.prototype instanceof ue?de:ue,ct=Object.create(De.prototype),rt=new Ze(We||[]);return ct._invoke=function(Nt,Zt,pe){var Lt="suspendedStart";return function(Jt,lr){if(Lt==="executing")throw new Error("Generator is already running");if(Lt==="completed"){if(Jt==="throw")throw lr;return Wn()}for(pe.method=Jt,pe.arg=lr;;){var Ri=pe.delegate;if(Ri){var _n=ur(Ri,pe);if(_n){if(_n===be)continue;return _n}}if(pe.method==="next")pe.sent=pe._sent=pe.arg;else if(pe.method==="throw"){if(Lt==="suspendedStart")throw Lt="completed",pe.arg;pe.dispatchException(pe.arg)}else pe.method==="return"&&pe.abrupt("return",pe.arg);Lt="executing";var Et=re(Nt,Zt,pe);if(Et.type==="normal"){if(Lt=pe.done?"completed":"suspendedYield",Et.arg===be)continue;return{value:Et.arg,done:pe.done}}Et.type==="throw"&&(Lt="completed",pe.method="throw",pe.arg=Et.arg)}}}(he,Ne,rt),ct}function re(he,de,Ne){try{return{type:"normal",arg:he.call(de,Ne)}}catch(We){return{type:"throw",arg:We}}}le.wrap=z;var be={};function ue(){}function _e(){}function Oe(){}var Wt={};se(Wt,He,function(){return this});var $t=Object.getPrototypeOf,Xe=$t&&$t($t(Gt([])));Xe&&Xe!==ke&&Se.call(Xe,He)&&(Wt=Xe);var qt=Oe.prototype=ue.prototype=Object.create(Wt);function dt(he){["next","throw","return"].forEach(function(de){se(he,de,function(Ne){return this._invoke(de,Ne)})})}function zn(he,de){function Ne(De,ct,rt,Nt){var Zt=re(he[De],he,ct);if(Zt.type!=="throw"){var pe=Zt.arg,Lt=pe.value;return Lt&&typeof Lt=="object"&&Se.call(Lt,"__await")?de.resolve(Lt.__await).then(function(Jt){Ne("next",Jt,rt,Nt)},function(Jt){Ne("throw",Jt,rt,Nt)}):de.resolve(Lt).then(function(Jt){pe.value=Jt,rt(pe)},function(Jt){return Ne("throw",Jt,rt,Nt)})}Nt(Zt.arg)}var We;this._invoke=function(De,ct){function rt(){return new de(function(Nt,Zt){Ne(De,ct,Nt,Zt)})}return We=We?We.then(rt,rt):rt()}}function ur(he,de){var Ne=he.iterator[de.method];if(Ne===void 0){if(de.delegate=null,de.method==="throw"){if(he.iterator.return&&(de.method="return",de.arg=void 0,ur(he,de),de.method==="throw"))return be;de.method="throw",de.arg=new TypeError("The iterator does not provide a 'throw' method")}return be}var We=re(Ne,he.iterator,de.arg);if(We.type==="throw")return de.method="throw",de.arg=We.arg,de.delegate=null,be;var De=We.arg;return De?De.done?(de[he.resultName]=De.value,de.next=he.nextLoc,de.method!=="return"&&(de.method="next",de.arg=void 0),de.delegate=null,be):De:(de.method="throw",de.arg=new TypeError("iterator result is not an object"),de.delegate=null,be)}function Ht(he){var de={tryLoc:he[0]};1 in he&&(de.catchLoc=he[1]),2 in he&&(de.finallyLoc=he[2],de.afterLoc=he[3]),this.tryEntries.push(de)}function En(he){var de=he.completion||{};de.type="normal",delete de.arg,he.completion=de}function Ze(he){this.tryEntries=[{tryLoc:"root"}],he.forEach(Ht,this),this.reset(!0)}function Gt(he){if(he){var de=he[He];if(de)return de.call(he);if(typeof he.next=="function")return he;if(!isNaN(he.length)){var Ne=-1,We=function De(){for(;++Ne<he.length;)if(Se.call(he,Ne))return De.value=he[Ne],De.done=!1,De;return De.value=void 0,De.done=!0,De};return We.next=We}}return{next:Wn}}function Wn(){return{value:void 0,done:!0}}return _e.prototype=Oe,se(qt,"constructor",Oe),se(Oe,"constructor",_e),_e.displayName=se(Oe,X,"GeneratorFunction"),le.isGeneratorFunction=function(he){var de=typeof he=="function"&&he.constructor;return!!de&&(de===_e||(de.displayName||de.name)==="GeneratorFunction")},le.mark=function(he){return Object.setPrototypeOf?Object.setPrototypeOf(he,Oe):(he.__proto__=Oe,se(he,X,"GeneratorFunction")),he.prototype=Object.create(qt),he},le.awrap=function(he){return{__await:he}},dt(zn.prototype),se(zn.prototype,oe,function(){return this}),le.AsyncIterator=zn,le.async=function(he,de,Ne,We,De){De===void 0&&(De=Promise);var ct=new zn(z(he,de,Ne,We),De);return le.isGeneratorFunction(de)?ct:ct.next().then(function(rt){return rt.done?rt.value:ct.next()})},dt(qt),se(qt,X,"Generator"),se(qt,He,function(){return this}),se(qt,"toString",function(){return"[object Generator]"}),le.keys=function(he){var de=[];for(var Ne in he)de.push(Ne);return de.reverse(),function We(){for(;de.length;){var De=de.pop();if(De in he)return We.value=De,We.done=!1,We}return We.done=!0,We}},le.values=Gt,Ze.prototype={constructor:Ze,reset:function(he){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(En),!he)for(var de in this)de.charAt(0)==="t"&&Se.call(this,de)&&!isNaN(+de.slice(1))&&(this[de]=void 0)},stop:function(){this.done=!0;var he=this.tryEntries[0].completion;if(he.type==="throw")throw he.arg;return this.rval},dispatchException:function(he){if(this.done)throw he;var de=this;function Ne(Zt,pe){return ct.type="throw",ct.arg=he,de.next=Zt,pe&&(de.method="next",de.arg=void 0),!!pe}for(var We=this.tryEntries.length-1;We>=0;--We){var De=this.tryEntries[We],ct=De.completion;if(De.tryLoc==="root")return Ne("end");if(De.tryLoc<=this.prev){var rt=Se.call(De,"catchLoc"),Nt=Se.call(De,"finallyLoc");if(rt&&Nt){if(this.prev<De.catchLoc)return Ne(De.catchLoc,!0);if(this.prev<De.finallyLoc)return Ne(De.finallyLoc)}else if(rt){if(this.prev<De.catchLoc)return Ne(De.catchLoc,!0)}else{if(!Nt)throw new Error("try statement without catch or finally");if(this.prev<De.finallyLoc)return Ne(De.finallyLoc)}}}},abrupt:function(he,de){for(var Ne=this.tryEntries.length-1;Ne>=0;--Ne){var We=this.tryEntries[Ne];if(We.tryLoc<=this.prev&&Se.call(We,"finallyLoc")&&this.prev<We.finallyLoc){var De=We;break}}De&&(he==="break"||he==="continue")&&De.tryLoc<=de&&de<=De.finallyLoc&&(De=null);var ct=De?De.completion:{};return ct.type=he,ct.arg=de,De?(this.method="next",this.next=De.finallyLoc,be):this.complete(ct)},complete:function(he,de){if(he.type==="throw")throw he.arg;return he.type==="break"||he.type==="continue"?this.next=he.arg:he.type==="return"?(this.rval=this.arg=he.arg,this.method="return",this.next="end"):he.type==="normal"&&de&&(this.next=de),be},finish:function(he){for(var de=this.tryEntries.length-1;de>=0;--de){var Ne=this.tryEntries[de];if(Ne.finallyLoc===he)return this.complete(Ne.completion,Ne.afterLoc),En(Ne),be}},catch:function(he){for(var de=this.tryEntries.length-1;de>=0;--de){var Ne=this.tryEntries[de];if(Ne.tryLoc===he){var We=Ne.completion;if(We.type==="throw"){var De=We.arg;En(Ne)}return De}}throw new Error("illegal catch attempt")},delegateYield:function(he,de,Ne){return this.delegate={iterator:Gt(he),resultName:de,nextLoc:Ne},this.method==="next"&&(this.arg=void 0),be}},le}function $(le){return $=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(ke){return typeof ke}:function(ke){return ke&&typeof Symbol=="function"&&ke.constructor===Symbol&&ke!==Symbol.prototype?"symbol":typeof ke},$(le)}function H(le,ke,Se,je,He,oe,X){try{var se=le[oe](X),z=se.value}catch(re){return void Se(re)}se.done?ke(z):Promise.resolve(z).then(je,He)}function Q(le){return function(){var ke=this,Se=arguments;return new Promise(function(je,He){var oe=le.apply(ke,Se);function X(z){H(oe,je,He,X,se,"next",z)}function se(z){H(oe,je,He,X,se,"throw",z)}X(void 0)})}}function Re(le,ke){if(!(le instanceof ke))throw new TypeError("Cannot call a class as a function")}function Ie(le,ke){for(var Se=0;Se<ke.length;Se++){var je=ke[Se];je.enumerable=je.enumerable||!1,je.configurable=!0,"value"in je&&(je.writable=!0),Object.defineProperty(le,je.key,je)}}function $e(le,ke,Se){return ke&&Ie(le.prototype,ke),Se&&Ie(le,Se),Object.defineProperty(le,"prototype",{writable:!1}),le}function Ct(le,ke,Se){var je=function(re,be,ue){var _e=new RegExp("\\b".concat(be," \\w+ (\\w+)"),"ig");re.replace(_e,function(Oe,Wt){return ue[Wt]=0,Oe})},He=function(re,be,ue){var _e=re.createShader(ue);return re.shaderSource(_e,be),re.compileShader(_e),re.getShaderParameter(_e,re.COMPILE_STATUS)?_e:(console.log(re.getShaderInfoLog(_e)),null)};this.uniform={},this.attribute={};var oe=He(le,ke,le.VERTEX_SHADER),X=He(le,Se,le.FRAGMENT_SHADER);for(var se in this.id=le.createProgram(),le.attachShader(this.id,oe),le.attachShader(this.id,X),le.linkProgram(this.id),le.getProgramParameter(this.id,le.LINK_STATUS)||console.log(le.getProgramInfoLog(this.id)),le.useProgram(this.id),je(ke,"attribute",this.attribute),this.attribute)this.attribute[se]=le.getAttribLocation(this.id,se);for(var z in je(ke,"uniform",this.uniform),je(Se,"uniform",this.uniform),this.uniform)this.uniform[z]=le.getUniformLocation(this.id,z)}function Qe(le,ke,Se,je){for(var He=[],oe=0;oe<ke.length;++oe)He.push(Rc(le,ke[oe],le[cr[oe]]));return function(X,se,z,re){var be=X.createProgram();return se.forEach(function(ue){X.attachShader(be,ue)}),z&&z.forEach(function(ue,_e){X.bindAttribLocation(be,re?re[_e]:_e,ue)}),X.linkProgram(be),X.getProgramParameter(be,X.LINK_STATUS)?be:(X.deleteProgram(be),null)}(le,He,Se,je)}var cr=["VERTEX_SHADER","FRAGMENT_SHADER"];function Rc(le,ke,Se){var je=le.createShader(Se);return le.shaderSource(je,ke),le.compileShader(je),le.getShaderParameter(je,le.COMPILE_STATUS)?je:(le.deleteShader(je),null)}var Go=function(){function le(ke){Re(this,le),this.canvas=ke.canvas,this.video=ke.video,this.width=ke.width||640,this.height=ke.height||480,this.vertexBuffer=null,this.currentProgram=null,this.applied=!1,this.beautyParams={beauty:.5,brightness:.5,ruddy:.5},this.gl=this.createGL(ke.canvas),this.sourceTexture=this.gl.createTexture()}return $e(le,[{key:"setRect",value:function(ke,Se){this.width=ke,this.height=Se}},{key:"apply",value:function(ke){if(!this.vertexBuffer){var Se=new Float32Array([-1,-1,0,1,1,-1,1,1,-1,1,0,0,-1,1,0,0,1,-1,1,1,1,1,1,0]);this.vertexBuffer=this.gl.createBuffer(),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this.vertexBuffer),this.gl.bufferData(this.gl.ARRAY_BUFFER,Se,this.gl.STATIC_DRAW),this.gl.pixelStorei(this.gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!0)}this.gl.viewport(0,0,this.width,this.height),this.gl.bindTexture(this.gl.TEXTURE_2D,this.sourceTexture),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_WRAP_S,this.gl.CLAMP_TO_EDGE),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_WRAP_T,this.gl.CLAMP_TO_EDGE),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_MIN_FILTER,this.gl.NEAREST),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_MAG_FILTER,this.gl.NEAREST),this.applied?this.gl.texSubImage2D(this.gl.TEXTURE_2D,0,0,0,this.gl.RGB,this.gl.UNSIGNED_BYTE,ke):(this.gl.texImage2D(this.gl.TEXTURE_2D,0,this.gl.RGB,this.gl.RGB,this.gl.UNSIGNED_BYTE,ke),this.applied=!0);var je=this.beautyParams,He=je.beauty,oe=je.brightness,X=je.ruddy,se=2/this.width,z=2/this.height,re=this.compileBeautyShader();this.gl.uniform2f(re.uniform.singleStepOffset,se,z);var be=new Float32Array([1-.8*He,1-.6*He,.1+.45*X,.1+.45*X]);this.gl.uniform4fv(re.uniform.params,be),this.gl.uniform1f(re.uniform.brightness,.12*oe),this.gl.bindTexture(this.gl.TEXTURE_2D,this.sourceTexture),this.gl.bindFramebuffer(this.gl.FRAMEBUFFER,null),this.gl.uniform1f(this.currentProgram.uniform.flipY,1),this.gl.drawArrays(this.gl.TRIANGLES,0,6)}},{key:"compileBeautyShader",value:function(){if(this.currentProgram)return this.currentProgram;this.currentProgram=new Ct(this.gl,["precision highp float;","attribute vec2 pos;","attribute vec2 uv;","varying vec2 vUv;","uniform float flipY;","void main(void) {","vUv = uv;","gl_Position = vec4(pos.x, pos.y*flipY, 0.0, 1.);","}"].join(`
107
71
  `),["precision highp float;","uniform vec2 singleStepOffset;","uniform sampler2D texture;","uniform vec4 params;","uniform float brightness;","varying vec2 vUv;","const highp vec3 W = vec3(0.299,0.587,0.114);","const mat3 saturateMatrix = mat3(1.1102,-0.0598,-0.061,-0.0774,1.0826,-0.1186,-0.0228,-0.0228,1.1772);","vec2 blurCoordinates[24];","float hardLight(float color){","if(color <= 0.5){","color = color * color * 2.0;","} else {","color = 1.0 - ((1.0 - color)*(1.0 - color) * 2.0);","}","return color;","}","void main(){","vec3 centralColor = texture2D(texture, vUv).rgb;","blurCoordinates[0] = vUv.xy + singleStepOffset * vec2(0.0, -10.0);","blurCoordinates[1] = vUv.xy + singleStepOffset * vec2(0.0, 10.0);","blurCoordinates[2] = vUv.xy + singleStepOffset * vec2(-10.0, 0.0);","blurCoordinates[3] = vUv.xy + singleStepOffset * vec2(10.0, 0.0);","blurCoordinates[4] = vUv.xy + singleStepOffset * vec2(5.0, -8.0);","blurCoordinates[5] = vUv.xy + singleStepOffset * vec2(5.0, 8.0);","blurCoordinates[6] = vUv.xy + singleStepOffset * vec2(-5.0, 8.0);","blurCoordinates[7] = vUv.xy + singleStepOffset * vec2(-5.0, -8.0);","blurCoordinates[8] = vUv.xy + singleStepOffset * vec2(8.0, -5.0);","blurCoordinates[9] = vUv.xy + singleStepOffset * vec2(8.0, 5.0);","blurCoordinates[10] = vUv.xy + singleStepOffset * vec2(-8.0, 5.0);","blurCoordinates[11] = vUv.xy + singleStepOffset * vec2(-8.0, -5.0);","blurCoordinates[12] = vUv.xy + singleStepOffset * vec2(0.0, -6.0);","blurCoordinates[13] = vUv.xy + singleStepOffset * vec2(0.0, 6.0);","blurCoordinates[14] = vUv.xy + singleStepOffset * vec2(6.0, 0.0);","blurCoordinates[15] = vUv.xy + singleStepOffset * vec2(-6.0, 0.0);","blurCoordinates[16] = vUv.xy + singleStepOffset * vec2(-4.0, -4.0);","blurCoordinates[17] = vUv.xy + singleStepOffset * vec2(-4.0, 4.0);","blurCoordinates[18] = vUv.xy + singleStepOffset * vec2(4.0, -4.0);","blurCoordinates[19] = vUv.xy + singleStepOffset * vec2(4.0, 4.0);","blurCoordinates[20] = vUv.xy + singleStepOffset * vec2(-2.0, -2.0);","blurCoordinates[21] = vUv.xy + singleStepOffset * vec2(-2.0, 2.0);","blurCoordinates[22] = vUv.xy + singleStepOffset * vec2(2.0, -2.0);","blurCoordinates[23] = vUv.xy + singleStepOffset * vec2(2.0, 2.0);","float sampleColor = centralColor.g * 22.0;","sampleColor += texture2D(texture, blurCoordinates[0]).g;","sampleColor += texture2D(texture, blurCoordinates[1]).g;","sampleColor += texture2D(texture, blurCoordinates[2]).g;","sampleColor += texture2D(texture, blurCoordinates[3]).g;","sampleColor += texture2D(texture, blurCoordinates[4]).g;","sampleColor += texture2D(texture, blurCoordinates[5]).g;","sampleColor += texture2D(texture, blurCoordinates[6]).g;","sampleColor += texture2D(texture, blurCoordinates[7]).g;","sampleColor += texture2D(texture, blurCoordinates[8]).g;","sampleColor += texture2D(texture, blurCoordinates[9]).g;","sampleColor += texture2D(texture, blurCoordinates[10]).g;","sampleColor += texture2D(texture, blurCoordinates[11]).g;","sampleColor += texture2D(texture, blurCoordinates[12]).g * 2.0;","sampleColor += texture2D(texture, blurCoordinates[13]).g * 2.0;","sampleColor += texture2D(texture, blurCoordinates[14]).g * 2.0;","sampleColor += texture2D(texture, blurCoordinates[15]).g * 2.0;","sampleColor += texture2D(texture, blurCoordinates[16]).g * 2.0;","sampleColor += texture2D(texture, blurCoordinates[17]).g * 2.0;","sampleColor += texture2D(texture, blurCoordinates[18]).g * 2.0;","sampleColor += texture2D(texture, blurCoordinates[19]).g * 2.0;","sampleColor += texture2D(texture, blurCoordinates[20]).g * 3.0;","sampleColor += texture2D(texture, blurCoordinates[21]).g * 3.0;","sampleColor += texture2D(texture, blurCoordinates[22]).g * 3.0;","sampleColor += texture2D(texture, blurCoordinates[23]).g * 3.0;","sampleColor = sampleColor / 62.0;","float highPass = centralColor.g - sampleColor + 0.5;","for(int i = 0; i < 5;i++){","highPass = hardLight(highPass);","}","float luminance = dot(centralColor, W);","float alpha = pow(luminance, params.r);","vec3 smoothColor = centralColor + (centralColor-vec3(highPass))*alpha*0.1;","smoothColor.r = clamp(pow(smoothColor.r, params.g),0.0,1.0);","smoothColor.g = clamp(pow(smoothColor.g, params.g),0.0,1.0);","smoothColor.b = clamp(pow(smoothColor.b, params.g),0.0,1.0);","vec3 screen = vec3(1.0) - (vec3(1.0)-smoothColor) * (vec3(1.0)-centralColor);","vec3 lighten = max(smoothColor, centralColor);","vec3 softLight = 2.0 * centralColor*smoothColor + centralColor*centralColor - 2.0 * centralColor*centralColor * smoothColor;","gl_FragColor = vec4(mix(centralColor, screen, alpha), 1.0);","gl_FragColor.rgb = mix(gl_FragColor.rgb, lighten, alpha);","gl_FragColor.rgb = mix(gl_FragColor.rgb, softLight, params.b);","vec3 satColor = gl_FragColor.rgb * saturateMatrix;","gl_FragColor.rgb = mix(gl_FragColor.rgb, satColor, params.a);","gl_FragColor.rgb = vec3(gl_FragColor.rgb + vec3(brightness));","}"].join(`
108
- `));var Te=Float32Array.BYTES_PER_ELEMENT,be=4*Te;return this.gl.enableVertexAttribArray(this.currentProgram.attribute.pos),this.gl.vertexAttribPointer(this.currentProgram.attribute.pos,2,this.gl.FLOAT,!1,be,0),this.gl.enableVertexAttribArray(this.currentProgram.attribute.uv),this.gl.vertexAttribPointer(this.currentProgram.attribute.uv,2,this.gl.FLOAT,!1,be,2*Te),this.currentProgram}},{key:"createGL",value:function(Te){var be=Te.getContext("webgl2");if(be||Te.getContext("experimental-webgl",{preserveDrawingBuffer:!0}),!be)throw"Couldn't get WebGL context";return be}},{key:"setBeautyParams",value:function(Te){this.beautyParams=Te}},{key:"reset",value:function(){this.applied=!1}}]),se}(),Ho=function(){function se(ie){Pe(this,se),this.canvas=ie.canvas,this.video=ie.video,this.width=ie.width||640,this.height=ie.height||480,this.onoverload=ie.onoverload,this.gl=this.createGL(ie.canvas),this.vao=this.gl.createVertexArray(),this.positionBuffer=this.gl.createBuffer(),this.sourceTexture=this.gl.createTexture(),this.program=null,this.blurParams={resolutionLocation:null,imageLocation0:null,imageLocation1:null},this.virtualParams={resolutionLocation:null,imageLocation0:null,imageLocation1:null,imageLocation2:null,imageOldLocation0:null,imageOldLocation1:null,imageOldLocation2:null,imageOldLocation3:null,imageOldLocation4:null,imageOldLocation5:null},this.virtualLocation={postProcessTypeLocation:null,sigmaLocation:null,bSigmaLocation:null,mSizeLocation:null,overlayTypeLocation:null,hardThresholdLocation:null,sigmoidClipLocation:null},this.maskBuffer=[],this.frameBuffer=[],this.virtualOption={postProcess:2,sigma:100,bSigma:10,kSize:19,overlayType:0,hardThreshold:.5,sigmoidClip:1},this.type=0,this.frameRate=0,this.rafId=null,this.timeoutId=null,this.img=new Image,this.imgCropCanvas=document.createElement("canvas"),this.imgCropCanvasCtx=this.imgCropCanvas.getContext("2d"),this.imgMap=new Map,this.tempImg=new Image,this.tempImg.crossOrigin="anonymous",this.isRender=!1,this.enable=!1,this.processingTimes=[],this.frameCount=0}var Te,be,Be,ze;return ut(se,[{key:"loadResources",value:(ze=J(V().mark(function ie(){return V().wrap(function(W){for(;;)switch(W.prev=W.next){case 0:return W.next=2,new window.SelfieSegmentation({locateFile:function(ae){return"https://web.sdk.qcloud.com/trtc/webrtc/download/segmentation/".concat(ae)}});case 2:return this.selfieSegmentation=W.sent,W.next=5,this.selfieSegmentation.initialize();case 5:case"end":return W.stop()}},ie,this)})),function(){return ze.apply(this,arguments)})},{key:"setEnable",value:function(ie){this.enable=ie}},{key:"initVirtualParams",value:(Be=J(V().mark(function ie(W){var ae,B;return V().wrap(function(te){for(;;)switch(te.prev=te.next){case 0:if(ae=W.img,B=W.type,this.type=B==="blur"?0:1,!ae){te.next=5;break}return te.next=5,this.setBackground(ae);case 5:this.type===0?this.initBackgroundBlurProgram():this.type===1&&this.initVirtualBackgroundProgram();case 6:case"end":return te.stop()}},ie,this)})),function(ie){return Be.apply(this,arguments)})},{key:"setBackground",value:(be=J(V().mark(function ie(W){var ae=this;return V().wrap(function(B){for(;;)switch(B.prev=B.next){case 0:return B.abrupt("return",new Promise(function(te,Se){try{W instanceof HTMLImageElement?(ae.img=W,te()):(ae.tempImg.onload=function(){ae.imgCropCanvasCtx.drawImage(ae.tempImg,0,0,ae.width,ae.height);var oe=ae.imgCropCanvas.toDataURL("image/jpeg",.5);ae.img.src=oe,ae.imgMap.set(W,oe),te()},ae.imgMap.has(W)?(ae.img.src=ae.imgMap.get(W),te()):ae.tempImg.src=W)}catch(oe){Se("please check the img parameter!")}}));case 1:case"end":return B.stop()}},ie)})),function(ie){return be.apply(this,arguments)})},{key:"setRect",value:function(ie,W){this.width=ie,this.height=W,this.imgCropCanvas.width=this.width,this.imgCropCanvas.height=this.height,this.imgCropCanvasCtx.fillStyle="#000",this.imgCropCanvasCtx.fillRect(0,0,this.width,this.height),this.img.width=ie,this.img.height=W,this.img.src=this.imgCropCanvas.toDataURL("image/jpeg",.5),this.tempImg.width=ie,this.tempImg.height=W}},{key:"createGL",value:function(ie){var W=ie.getContext("webgl2");if(W||ie.getContext("experimental-webgl",{preserveDrawingBuffer:!0}),!W)throw"Couldn't get WebGL context";return W}},{key:"setRectangle",value:function(ie,W,ae,B,te){var Se=W,oe=W+B,_e=ae,Oe=ae+te;ie.bufferData(ie.ARRAY_BUFFER,new Float32Array([Se,_e,oe,_e,Se,Oe,Se,Oe,oe,_e,oe,Oe]),ie.STATIC_DRAW)}},{key:"startVirtual",value:function(ie){this.frameRate=ie,this.selfieSegmentation.setOptions({selfieMode:!1,modelSelection:0,effect:"background"}),this.type===0?this.selfieSegmentation.onResults(this.onBlurResult.bind(this)):this.selfieSegmentation.onResults(this.onVirtualResults.bind(this)),this.startTime=new Date().getTime(),this.isRender=!0,this.enable=!0,this.installEvents()}},{key:"render",value:(Te=J(V().mark(function ie(){var W,ae,B=this;return V().wrap(function(te){for(;;)switch(te.prev=te.next){case 0:if(this.isRender){te.next=2;break}return te.abrupt("return");case 2:if(!((W=new Date().getTime())-this.startTime>1e3/this.frameRate)){te.next=12;break}if(!this.enable||this.video.readyState!==this.video.HAVE_ENOUGH_DATA){te.next=7;break}return te.next=7,this.selfieSegmentation.send({image:this.video});case 7:ae=W-this.startTime,this.processingTimes.push(ae),this.processingTimes.length>100&&this.processingTimes.shift(),this.frameCount>=100?this.processingTimes.reduce(function(Se,oe){return Se+oe},0)/this.processingTimes.length>100&&(console.log("frameRate is too low, trigger overload."),this.onoverload&&typeof this.onoverload=="function"&&this.onoverload(),this.frameCount=0,this.processingTimes=[]):this.frameCount+=1,this.startTime=W;case 12:document.hidden?(this.timeoutId&&clearTimeout(this.timeoutId),this.rafId&&cancelAnimationFrame(this.rafId),this.timeoutId=setTimeout(function(){B.render()},1e3/this.frameRate)):(this.timeoutId&&clearTimeout(this.timeoutId),this.rafId&&cancelAnimationFrame(this.rafId),this.rafId=requestAnimationFrame(this.render.bind(this)));case 13:case"end":return te.stop()}},ie,this)})),function(){return Te.apply(this,arguments)})},{key:"installEvents",value:function(){window.addEventListener("visibilitychange",this.render.bind(this))}},{key:"uninstallEvents",value:function(){window.addEventListener("visibilitychange",this.render.bind(this))}},{key:"reset",value:function(){this.isRender=!1,cancelAnimationFrame(this.rafId),clearTimeout(this.timeoutId),this.gl.clear(this.gl.COLOR_BUFFER_BIT|this.gl.DEPTH_BUFFER_BIT),this.gl.deleteProgram(this.program),this.gl.deleteTexture(this.sourceTexture),this.uninstallEvents()}},{key:"destroy",value:function(){this.reset(),this.gl.deleteBuffer(this.positionBuffer)}},{key:"initBackgroundBlurProgram",value:function(){var ie=this.gl,W={vertexShaderSource:`#version 300 es
72
+ `));var ke=Float32Array.BYTES_PER_ELEMENT,Se=4*ke;return this.gl.enableVertexAttribArray(this.currentProgram.attribute.pos),this.gl.vertexAttribPointer(this.currentProgram.attribute.pos,2,this.gl.FLOAT,!1,Se,0),this.gl.enableVertexAttribArray(this.currentProgram.attribute.uv),this.gl.vertexAttribPointer(this.currentProgram.attribute.uv,2,this.gl.FLOAT,!1,Se,2*ke),this.currentProgram}},{key:"createGL",value:function(ke){var Se=ke.getContext("webgl2");if(Se||ke.getContext("experimental-webgl",{preserveDrawingBuffer:!0}),!Se)throw"Couldn't get WebGL context";return Se}},{key:"setBeautyParams",value:function(ke){this.beautyParams=ke}},{key:"reset",value:function(){this.applied=!1}}]),le}(),zo=function(){function le(oe){Re(this,le),this.canvas=oe.canvas,this.video=oe.video,this.width=oe.width||640,this.height=oe.height||480,this.onoverload=oe.onoverload,this.gl=this.createGL(oe.canvas),this.vao=this.gl.createVertexArray(),this.positionBuffer=this.gl.createBuffer(),this.sourceTexture=this.gl.createTexture(),this.program=null,this.blurParams={resolutionLocation:null,imageLocation0:null,imageLocation1:null},this.virtualParams={resolutionLocation:null,imageLocation0:null,imageLocation1:null,imageLocation2:null,imageOldLocation0:null,imageOldLocation1:null,imageOldLocation2:null,imageOldLocation3:null,imageOldLocation4:null,imageOldLocation5:null},this.virtualLocation={postProcessTypeLocation:null,sigmaLocation:null,bSigmaLocation:null,mSizeLocation:null,overlayTypeLocation:null,hardThresholdLocation:null,sigmoidClipLocation:null},this.maskBuffer=[],this.frameBuffer=[],this.virtualOption={postProcess:2,sigma:100,bSigma:10,kSize:19,overlayType:0,hardThreshold:.5,sigmoidClip:1},this.type=0,this.frameRate=0,this.rafId=null,this.timeoutId=null,this.img=new Image,this.imgCropCanvas=document.createElement("canvas"),this.imgCropCanvasCtx=this.imgCropCanvas.getContext("2d"),this.imgMap=new Map,this.tempImg=new Image,this.tempImg.crossOrigin="anonymous",this.isRender=!1,this.enable=!1,this.processingTimes=[],this.frameCount=0}var ke,Se,je,He;return $e(le,[{key:"loadResources",value:(He=Q(G().mark(function oe(){return G().wrap(function(X){for(;;)switch(X.prev=X.next){case 0:return X.next=2,new window.SelfieSegmentation({locateFile:function(se){return"https://web.sdk.qcloud.com/trtc/webrtc/download/segmentation/".concat(se)}});case 2:return this.selfieSegmentation=X.sent,X.next=5,this.selfieSegmentation.initialize();case 5:case"end":return X.stop()}},oe,this)})),function(){return He.apply(this,arguments)})},{key:"setEnable",value:function(oe){this.enable=oe}},{key:"initVirtualParams",value:(je=Q(G().mark(function oe(X){var se,z;return G().wrap(function(re){for(;;)switch(re.prev=re.next){case 0:if(se=X.img,z=X.type,this.type=z==="blur"?0:1,!se){re.next=5;break}return re.next=5,this.setBackground(se);case 5:this.type===0?this.initBackgroundBlurProgram():this.type===1&&this.initVirtualBackgroundProgram();case 6:case"end":return re.stop()}},oe,this)})),function(oe){return je.apply(this,arguments)})},{key:"setBackground",value:(Se=Q(G().mark(function oe(X){var se=this;return G().wrap(function(z){for(;;)switch(z.prev=z.next){case 0:return z.abrupt("return",new Promise(function(re,be){try{X instanceof HTMLImageElement?(se.img=X,re()):(se.tempImg.onload=function(){se.imgCropCanvasCtx.drawImage(se.tempImg,0,0,se.width,se.height);var ue=se.imgCropCanvas.toDataURL("image/jpeg",.5);se.img.src=ue,se.imgMap.set(X,ue),re()},se.imgMap.has(X)?(se.img.src=se.imgMap.get(X),re()):se.tempImg.src=X)}catch(ue){be("please check the img parameter!")}}));case 1:case"end":return z.stop()}},oe)})),function(oe){return Se.apply(this,arguments)})},{key:"setRect",value:function(oe,X){this.width=oe,this.height=X,this.imgCropCanvas.width=this.width,this.imgCropCanvas.height=this.height,this.imgCropCanvasCtx.fillStyle="#000",this.imgCropCanvasCtx.fillRect(0,0,this.width,this.height),this.img.width=oe,this.img.height=X,this.img.src=this.imgCropCanvas.toDataURL("image/jpeg",.5),this.tempImg.width=oe,this.tempImg.height=X}},{key:"createGL",value:function(oe){var X=oe.getContext("webgl2");if(X||oe.getContext("experimental-webgl",{preserveDrawingBuffer:!0}),!X)throw"Couldn't get WebGL context";return X}},{key:"setRectangle",value:function(oe,X,se,z,re){var be=X,ue=X+z,_e=se,Oe=se+re;oe.bufferData(oe.ARRAY_BUFFER,new Float32Array([be,_e,ue,_e,be,Oe,be,Oe,ue,_e,ue,Oe]),oe.STATIC_DRAW)}},{key:"startVirtual",value:function(oe){this.frameRate=oe,this.selfieSegmentation.setOptions({selfieMode:!1,modelSelection:0,effect:"background"}),this.type===0?this.selfieSegmentation.onResults(this.onBlurResult.bind(this)):this.selfieSegmentation.onResults(this.onVirtualResults.bind(this)),this.startTime=new Date().getTime(),this.isRender=!0,this.enable=!0,this.installEvents()}},{key:"render",value:(ke=Q(G().mark(function oe(){var X,se,z=this;return G().wrap(function(re){for(;;)switch(re.prev=re.next){case 0:if(this.isRender){re.next=2;break}return re.abrupt("return");case 2:if(!((X=new Date().getTime())-this.startTime>1e3/this.frameRate)){re.next=12;break}if(!this.enable||this.video.readyState!==this.video.HAVE_ENOUGH_DATA){re.next=7;break}return re.next=7,this.selfieSegmentation.send({image:this.video});case 7:se=X-this.startTime,this.processingTimes.push(se),this.processingTimes.length>100&&this.processingTimes.shift(),this.frameCount>=100?this.processingTimes.reduce(function(be,ue){return be+ue},0)/this.processingTimes.length>100&&(console.log("frameRate is too low, trigger overload."),this.onoverload&&typeof this.onoverload=="function"&&this.onoverload(),this.frameCount=0,this.processingTimes=[]):this.frameCount+=1,this.startTime=X;case 12:document.hidden?(this.timeoutId&&clearTimeout(this.timeoutId),this.rafId&&cancelAnimationFrame(this.rafId),this.timeoutId=setTimeout(function(){z.render()},1e3/this.frameRate)):(this.timeoutId&&clearTimeout(this.timeoutId),this.rafId&&cancelAnimationFrame(this.rafId),this.rafId=requestAnimationFrame(this.render.bind(this)));case 13:case"end":return re.stop()}},oe,this)})),function(){return ke.apply(this,arguments)})},{key:"installEvents",value:function(){window.addEventListener("visibilitychange",this.render.bind(this))}},{key:"uninstallEvents",value:function(){window.addEventListener("visibilitychange",this.render.bind(this))}},{key:"reset",value:function(){this.isRender=!1,cancelAnimationFrame(this.rafId),clearTimeout(this.timeoutId),this.gl.clear(this.gl.COLOR_BUFFER_BIT|this.gl.DEPTH_BUFFER_BIT),this.gl.deleteProgram(this.program),this.gl.deleteTexture(this.sourceTexture),this.uninstallEvents()}},{key:"destroy",value:function(){this.reset(),this.gl.deleteBuffer(this.positionBuffer)}},{key:"initBackgroundBlurProgram",value:function(){var oe=this.gl,X={vertexShaderSource:`#version 300 es
109
73
 
110
74
  // an attribute is an input (in) to a vertex shader.
111
75
  // It will receive data from a buffer
@@ -284,7 +248,7 @@ b=`+P+":"+k+`\r
284
248
 
285
249
  outColor = (1.0 - color0.r) * gaussianBlur + color0.r * color1;
286
250
  }
287
- `},ae=W.vertexShaderSource,B=W.fragmentShaderSource;this.program=$e(ie,[ae,B]);var te=ie.getAttribLocation(this.program,"position"),Se=ie.getAttribLocation(this.program,"texCoord");this.blurParams.resolutionLocation=ie.getUniformLocation(this.program,"resolution"),this.blurParams.imageLocation0=ie.getUniformLocation(this.program,"u_image0"),this.blurParams.imageLocation1=ie.getUniformLocation(this.program,"u_image1"),ie.bindVertexArray(this.vao),ie.bindBuffer(ie.ARRAY_BUFFER,this.positionBuffer),ie.enableVertexAttribArray(te),ie.vertexAttribPointer(te,2,ie.FLOAT,!1,0,0),ie.bindBuffer(ie.ARRAY_BUFFER,ie.createBuffer()),ie.bufferData(ie.ARRAY_BUFFER,new Float32Array([0,0,1,0,0,1,0,1,1,0,1,1]),ie.STATIC_DRAW),ie.enableVertexAttribArray(Se),ie.vertexAttribPointer(Se,2,ie.FLOAT,!1,0,0)}},{key:"onBlurResult",value:function(ie){for(var W=ie.segmentationMask,ae=ie.image,B=this.gl,te=[],Se=[W,ae],oe=0;oe<2;++oe){var _e=B.createTexture();B.bindTexture(B.TEXTURE_2D,_e),B.texParameteri(B.TEXTURE_2D,B.TEXTURE_WRAP_S,B.CLAMP_TO_EDGE),B.texParameteri(B.TEXTURE_2D,B.TEXTURE_WRAP_T,B.CLAMP_TO_EDGE),B.texParameteri(B.TEXTURE_2D,B.TEXTURE_MIN_FILTER,B.NEAREST),B.texParameteri(B.TEXTURE_2D,B.TEXTURE_MAG_FILTER,B.NEAREST),B.texImage2D(B.TEXTURE_2D,0,B.RGBA,B.RGBA,B.UNSIGNED_BYTE,Se[oe]),te.push(_e)}B.bindBuffer(B.ARRAY_BUFFER,this.positionBuffer),this.setRectangle(B,0,0,this.width,this.height),B.viewport(0,0,this.width,this.height),B.clearColor(0,0,0,0),B.clear(B.COLOR_BUFFER_BIT|B.DEPTH_BUFFER_BIT),B.useProgram(this.program),B.bindVertexArray(this.vao);var Oe=this.blurParams,Jt=Oe.resolutionLocation,Zt=Oe.imageLocation0,Qe=Oe.imageLocation1;B.uniform2f(Jt,this.width,this.height),B.uniform1i(Zt,0),B.uniform1i(Qe,1),B.activeTexture(B.TEXTURE0),B.bindTexture(B.TEXTURE_2D,te[0]),B.activeTexture(B.TEXTURE1),B.bindTexture(B.TEXTURE_2D,te[1]),B.drawArrays(B.TRIANGLES,0,6)}},{key:"initVirtualBackgroundProgram",value:function(){var ie=this.gl,W={vertexShaderSource:`#version 300 es
251
+ `},se=X.vertexShaderSource,z=X.fragmentShaderSource;this.program=Qe(oe,[se,z]);var re=oe.getAttribLocation(this.program,"position"),be=oe.getAttribLocation(this.program,"texCoord");this.blurParams.resolutionLocation=oe.getUniformLocation(this.program,"resolution"),this.blurParams.imageLocation0=oe.getUniformLocation(this.program,"u_image0"),this.blurParams.imageLocation1=oe.getUniformLocation(this.program,"u_image1"),oe.bindVertexArray(this.vao),oe.bindBuffer(oe.ARRAY_BUFFER,this.positionBuffer),oe.enableVertexAttribArray(re),oe.vertexAttribPointer(re,2,oe.FLOAT,!1,0,0),oe.bindBuffer(oe.ARRAY_BUFFER,oe.createBuffer()),oe.bufferData(oe.ARRAY_BUFFER,new Float32Array([0,0,1,0,0,1,0,1,1,0,1,1]),oe.STATIC_DRAW),oe.enableVertexAttribArray(be),oe.vertexAttribPointer(be,2,oe.FLOAT,!1,0,0)}},{key:"onBlurResult",value:function(oe){for(var X=oe.segmentationMask,se=oe.image,z=this.gl,re=[],be=[X,se],ue=0;ue<2;++ue){var _e=z.createTexture();z.bindTexture(z.TEXTURE_2D,_e),z.texParameteri(z.TEXTURE_2D,z.TEXTURE_WRAP_S,z.CLAMP_TO_EDGE),z.texParameteri(z.TEXTURE_2D,z.TEXTURE_WRAP_T,z.CLAMP_TO_EDGE),z.texParameteri(z.TEXTURE_2D,z.TEXTURE_MIN_FILTER,z.NEAREST),z.texParameteri(z.TEXTURE_2D,z.TEXTURE_MAG_FILTER,z.NEAREST),z.texImage2D(z.TEXTURE_2D,0,z.RGBA,z.RGBA,z.UNSIGNED_BYTE,be[ue]),re.push(_e)}z.bindBuffer(z.ARRAY_BUFFER,this.positionBuffer),this.setRectangle(z,0,0,this.width,this.height),z.viewport(0,0,this.width,this.height),z.clearColor(0,0,0,0),z.clear(z.COLOR_BUFFER_BIT|z.DEPTH_BUFFER_BIT),z.useProgram(this.program),z.bindVertexArray(this.vao);var Oe=this.blurParams,Wt=Oe.resolutionLocation,$t=Oe.imageLocation0,Xe=Oe.imageLocation1;z.uniform2f(Wt,this.width,this.height),z.uniform1i($t,0),z.uniform1i(Xe,1),z.activeTexture(z.TEXTURE0),z.bindTexture(z.TEXTURE_2D,re[0]),z.activeTexture(z.TEXTURE1),z.bindTexture(z.TEXTURE_2D,re[1]),z.drawArrays(z.TRIANGLES,0,6)}},{key:"initVirtualBackgroundProgram",value:function(){var oe=this.gl,X={vertexShaderSource:`#version 300 es
288
252
 
289
253
  // an attribute is an input (in) to a vertex shader.
290
254
  // It will receive data from a buffer
@@ -564,22 +528,22 @@ b=`+P+":"+k+`\r
564
528
  outColor.rgb = (maskValue * color1 + (1.0 - maskValue) * color2).rgb;
565
529
  outColor.a = 1.0;
566
530
  }
567
- `},ae=W.vertexShaderSource,B=W.fragmentShaderSource;this.program=$e(ie,[ae,B]);var te=ie.getAttribLocation(this.program,"position"),Se=ie.getAttribLocation(this.program,"texCoord"),oe=this.program;this.virtualParams={resolutionLocation:ie.getUniformLocation(oe,"resolution"),imageLocation0:ie.getUniformLocation(oe,"u_image0"),imageLocation1:ie.getUniformLocation(oe,"u_image1"),imageLocation2:ie.getUniformLocation(oe,"u_image2"),imageOldLocation0:ie.getUniformLocation(oe,"u_image_old0"),imageOldLocation1:ie.getUniformLocation(oe,"u_image_old1"),imageOldLocation2:ie.getUniformLocation(oe,"u_image_old2"),imageOldLocation3:ie.getUniformLocation(oe,"u_image_old3"),imageOldLocation4:ie.getUniformLocation(oe,"u_image_old4"),imageOldLocation5:ie.getUniformLocation(oe,"u_image_old5")},this.virtualLocation={postProcessTypeLocation:ie.getUniformLocation(oe,"PostProcessType"),sigmaLocation:ie.getUniformLocation(oe,"SIGMA"),bSigmaLocation:ie.getUniformLocation(oe,"BSIGMA"),mSizeLocation:ie.getUniformLocation(oe,"MSIZE"),overlayTypeLocation:ie.getUniformLocation(oe,"overlayType"),hardThresholdLocation:ie.getUniformLocation(oe,"hardThreshold"),sigmoidClipLocation:ie.getUniformLocation(oe,"sigmoidClip")},ie.bindVertexArray(this.vao),ie.bindBuffer(ie.ARRAY_BUFFER,this.positionBuffer),ie.enableVertexAttribArray(te),ie.vertexAttribPointer(te,2,ie.FLOAT,!1,0,0),ie.bindBuffer(ie.ARRAY_BUFFER,ie.createBuffer()),ie.bufferData(ie.ARRAY_BUFFER,new Float32Array([0,0,1,0,0,1,0,1,1,0,1,1]),ie.STATIC_DRAW),ie.enableVertexAttribArray(Se),ie.vertexAttribPointer(Se,2,ie.FLOAT,!1,0,0)}},{key:"onVirtualResults",value:function(ie){var W=ie.segmentationMask,ae=ie.image,B=this.gl;this.maskBuffer.length<3&&this.maskBuffer.push(W,W,W),this.frameBuffer.length<3&&this.frameBuffer.push(ae,ae,ae);for(var te=[],Se=[W,ae,this.img,this.maskBuffer[0],this.maskBuffer[1],this.maskBuffer[2],this.frameBuffer[0],this.frameBuffer[1],this.frameBuffer[2]],oe=0;oe<Se.length;++oe)this.sourceTexture=B.createTexture(),B.bindTexture(B.TEXTURE_2D,this.sourceTexture),B.texParameteri(B.TEXTURE_2D,B.TEXTURE_WRAP_S,B.CLAMP_TO_EDGE),B.texParameteri(B.TEXTURE_2D,B.TEXTURE_WRAP_T,B.CLAMP_TO_EDGE),B.texParameteri(B.TEXTURE_2D,B.TEXTURE_MIN_FILTER,B.NEAREST),B.texParameteri(B.TEXTURE_2D,B.TEXTURE_MAG_FILTER,B.NEAREST),B.texImage2D(B.TEXTURE_2D,0,B.RGBA,B.RGBA,B.UNSIGNED_BYTE,Se[oe]),te.push(this.sourceTexture);B.bindBuffer(B.ARRAY_BUFFER,this.positionBuffer),this.setRectangle(B,0,0,this.width,this.height),B.viewport(0,0,this.width,this.height),B.clearColor(0,0,0,0),B.clear(B.COLOR_BUFFER_BIT|B.DEPTH_BUFFER_BIT),B.useProgram(this.program),B.bindVertexArray(this.vao);var _e=this.virtualParams,Oe=_e.resolutionLocation,Jt=_e.imageLocation0,Zt=_e.imageLocation1,Qe=_e.imageLocation2,Kt=_e.imageOldLocation0,ht=_e.imageOldLocation1,Jn=_e.imageOldLocation2,ur=_e.imageOldLocation3,Ht=_e.imageOldLocation4,An=_e.imageOldLocation5;B.uniform2f(Oe,this.width,this.height);var et=this.virtualOption,zt=et.postProcess,Kn=et.kSize,de=et.sigma,le=et.bSigma,Ne=et.overlayType,Je=et.hardThreshold,De=et.sigmoidClip,lt=this.virtualLocation,it=lt.postProcessTypeLocation,Vt=lt.mSizeLocation,en=lt.sigmaLocation,pe=lt.bSigmaLocation,Lt=lt.overlayTypeLocation,qt=lt.hardThresholdLocation,lr=lt.sigmoidClipLocation;B.uniform1i(it,zt),B.uniform1i(Vt,Kn),B.uniform1f(en,de),B.uniform1f(pe,le),B.uniform1i(Lt,Ne),B.uniform1f(qt,Je),B.uniform1i(lr,De),B.uniform1i(Jt,0),B.uniform1i(Zt,1),B.uniform1i(Qe,2),B.uniform1i(Kt,3),B.uniform1i(ht,4),B.uniform1i(Jn,5),B.uniform1i(ur,6),B.uniform1i(Ht,7),B.uniform1i(An,8),B.activeTexture(B.TEXTURE0),B.bindTexture(B.TEXTURE_2D,te[0]),B.activeTexture(B.TEXTURE1),B.bindTexture(B.TEXTURE_2D,te[1]),B.activeTexture(B.TEXTURE2),B.bindTexture(B.TEXTURE_2D,te[2]),B.activeTexture(B.TEXTURE3),B.bindTexture(B.TEXTURE_2D,te[3]),B.activeTexture(B.TEXTURE4),B.bindTexture(B.TEXTURE_2D,te[4]),B.activeTexture(B.TEXTURE5),B.bindTexture(B.TEXTURE_2D,te[5]),B.activeTexture(B.TEXTURE6),B.bindTexture(B.TEXTURE_2D,te[6]),B.activeTexture(B.TEXTURE7),B.bindTexture(B.TEXTURE_2D,te[7]),B.activeTexture(B.TEXTURE8),B.bindTexture(B.TEXTURE_2D,te[8]),B.drawArrays(B.TRIANGLES,0,6),this.maskBuffer[0]=this.maskBuffer[1],this.maskBuffer[1]=this.maskBuffer[2],this.maskBuffer[2]=W,this.frameBuffer[0]=this.frameBuffer[1],this.frameBuffer[1]=this.frameBuffer[2],this.frameBuffer[2]=ae}}]),se}(),zo=typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:typeof global!="undefined"?global:typeof self!="undefined"?self:{};(function(){var se;function Te(l){var m=0;return function(){return m<l.length?{done:!1,value:l[m++]}:{done:!0}}}var be=typeof Object.defineProperties=="function"?Object.defineProperty:function(l,m,S){return l==Array.prototype||l==Object.prototype||(l[m]=S.value),l},Be=function(l){l=[(typeof globalThis=="undefined"?"undefined":X(globalThis))=="object"&&globalThis,l,(typeof window=="undefined"?"undefined":X(window))=="object"&&window,(typeof self=="undefined"?"undefined":X(self))=="object"&&self,X(zo)=="object"&&zo];for(var m=0;m<l.length;++m){var S=l[m];if(S&&S.Math==Math)return S}throw Error("Cannot find global object")}(this);function ze(l,m){if(m)e:{var S=Be;l=l.split(".");for(var x=0;x<l.length-1;x++){var D=l[x];if(!(D in S))break e;S=S[D]}(m=m(x=S[l=l[l.length-1]]))!=x&&m!=null&&be(S,l,{configurable:!0,writable:!0,value:m})}}function ie(l){return(l={next:l})[Symbol.iterator]=function(){return this},l}function W(l){var m=typeof Symbol!="undefined"&&Symbol.iterator&&l[Symbol.iterator];return m?m.call(l):{next:Te(l)}}function ae(l){if(!(l instanceof Array)){l=W(l);for(var m,S=[];!(m=l.next()).done;)S.push(m.value);l=S}return l}ze("Symbol",function(l){function m(D,R){this.h=D,be(this,"description",{configurable:!0,writable:!0,value:R})}if(l)return l;m.prototype.toString=function(){return this.h};var S="jscomp_symbol_"+(1e9*Math.random()>>>0)+"_",x=0;return function D(R){if(this instanceof D)throw new TypeError("Symbol is not a constructor");return new m(S+(R||"")+"_"+x++,R)}}),ze("Symbol.iterator",function(l){if(l)return l;l=Symbol("Symbol.iterator");for(var m="Array Int8Array Uint8Array Uint8ClampedArray Int16Array Uint16Array Int32Array Uint32Array Float32Array Float64Array".split(" "),S=0;S<m.length;S++){var x=Be[m[S]];typeof x=="function"&&typeof x.prototype[l]!="function"&&be(x.prototype,l,{configurable:!0,writable:!0,value:function(){return ie(Te(this))}})}return l});var B=typeof Object.assign=="function"?Object.assign:function(l,m){for(var S=1;S<arguments.length;S++){var x=arguments[S];if(x)for(var D in x)Object.prototype.hasOwnProperty.call(x,D)&&(l[D]=x[D])}return l};ze("Object.assign",function(l){return l||B});var te,Se=typeof Object.create=="function"?Object.create:function(l){function m(){}return m.prototype=l,new m};if(typeof Object.setPrototypeOf=="function")te=Object.setPrototypeOf;else{var oe;e:{var _e={};try{_e.__proto__={a:!0},oe=_e.a;break e}catch(l){}oe=!1}te=oe?function(l,m){if(l.__proto__=m,l.__proto__!==m)throw new TypeError(l+" is not extensible");return l}:null}var Oe=te;function Jt(l,m){if(l.prototype=Se(m.prototype),l.prototype.constructor=l,Oe)Oe(l,m);else for(var S in m)if(S!="prototype")if(Object.defineProperties){var x=Object.getOwnPropertyDescriptor(m,S);x&&Object.defineProperty(l,S,x)}else l[S]=m[S];l.za=m.prototype}function Zt(){this.m=!1,this.j=null,this.i=void 0,this.h=1,this.v=this.s=0,this.l=null}function Qe(l){if(l.m)throw new TypeError("Generator is already running");l.m=!0}function Kt(l,m){l.l={ma:m,na:!0},l.h=l.s||l.v}function ht(l,m,S){return l.h=S,{value:m}}function Jn(l){this.h=new Zt,this.i=l}function ur(l,m,S,x){try{var D=m.call(l.h.j,S);if(!(D instanceof Object))throw new TypeError("Iterator result "+D+" is not an object");if(!D.done)return l.h.m=!1,D;var R=D.value}catch(M){return l.h.j=null,Kt(l.h,M),Ht(l)}return l.h.j=null,x.call(l.h,R),Ht(l)}function Ht(l){for(;l.h.h;)try{var m=l.i(l.h);if(m)return l.h.m=!1,{value:m.value,done:!1}}catch(S){l.h.i=void 0,Kt(l.h,S)}if(l.h.m=!1,l.h.l){if(m=l.h.l,l.h.l=null,m.na)throw m.ma;return{value:m.return,done:!0}}return{value:void 0,done:!0}}function An(l){this.next=function(m){return Qe(l.h),l.h.j?m=ur(l,l.h.j.next,m,l.h.u):(l.h.u(m),m=Ht(l)),m},this.throw=function(m){return Qe(l.h),l.h.j?m=ur(l,l.h.j.throw,m,l.h.u):(Kt(l.h,m),m=Ht(l)),m},this.return=function(m){return function(S,x){Qe(S.h);var D=S.h.j;return D?ur(S,"return"in D?D.return:function(R){return{value:R,done:!0}},x,S.h.return):(S.h.return(x),Ht(S))}(l,m)},this[Symbol.iterator]=function(){return this}}function et(l){return function(m){function S(D){return m.next(D)}function x(D){return m.throw(D)}return new Promise(function(D,R){(function M(G){G.done?D(G.value):Promise.resolve(G.value).then(S,x).then(M,R)})(m.next())})}(new An(new Jn(l)))}function zt(l){return l||Array.prototype.fill}Zt.prototype.u=function(l){this.i=l},Zt.prototype.return=function(l){this.l={return:l},this.h=this.v},ze("Promise",function(l){function m(M){this.i=0,this.j=void 0,this.h=[],this.u=!1;var G=this.l();try{M(G.resolve,G.reject)}catch(Q){G.reject(Q)}}function S(){this.h=null}function x(M){return M instanceof m?M:new m(function(G){G(M)})}if(l)return l;S.prototype.i=function(M){if(this.h==null){this.h=[];var G=this;this.j(function(){G.m()})}this.h.push(M)};var D=Be.setTimeout;S.prototype.j=function(M){D(M,0)},S.prototype.m=function(){for(;this.h&&this.h.length;){var M=this.h;this.h=[];for(var G=0;G<M.length;++G){var Q=M[G];M[G]=null;try{Q()}catch(he){this.l(he)}}}this.h=null},S.prototype.l=function(M){this.j(function(){throw M})},m.prototype.l=function(){function M(he){return function(fe){Q||(Q=!0,he.call(G,fe))}}var G=this,Q=!1;return{resolve:M(this.I),reject:M(this.m)}},m.prototype.I=function(M){if(M===this)this.m(new TypeError("A Promise cannot resolve to itself"));else if(M instanceof m)this.L(M);else{e:switch(X(M)){case"object":var G=M!=null;break e;case"function":G=!0;break e;default:G=!1}G?this.F(M):this.s(M)}},m.prototype.F=function(M){var G=void 0;try{G=M.then}catch(Q){return void this.m(Q)}typeof G=="function"?this.M(G,M):this.s(M)},m.prototype.m=function(M){this.v(2,M)},m.prototype.s=function(M){this.v(1,M)},m.prototype.v=function(M,G){if(this.i!=0)throw Error("Cannot settle("+M+", "+G+"): Promise already settled in state"+this.i);this.i=M,this.j=G,this.i===2&&this.K(),this.H()},m.prototype.K=function(){var M=this;D(function(){if(M.D()){var G=Be.console;G!==void 0&&G.error(M.j)}},1)},m.prototype.D=function(){if(this.u)return!1;var M=Be.CustomEvent,G=Be.Event,Q=Be.dispatchEvent;return Q===void 0||(typeof M=="function"?M=new M("unhandledrejection",{cancelable:!0}):typeof G=="function"?M=new G("unhandledrejection",{cancelable:!0}):(M=Be.document.createEvent("CustomEvent")).initCustomEvent("unhandledrejection",!1,!0,M),M.promise=this,M.reason=this.j,Q(M))},m.prototype.H=function(){if(this.h!=null){for(var M=0;M<this.h.length;++M)R.i(this.h[M]);this.h=null}};var R=new S;return m.prototype.L=function(M){var G=this.l();M.T(G.resolve,G.reject)},m.prototype.M=function(M,G){var Q=this.l();try{M.call(G,Q.resolve,Q.reject)}catch(he){Q.reject(he)}},m.prototype.then=function(M,G){function Q(Re,me){return typeof Re=="function"?function(Le){try{he(Re(Le))}catch(je){fe(je)}}:me}var he,fe,we=new m(function(Re,me){he=Re,fe=me});return this.T(Q(M,he),Q(G,fe)),we},m.prototype.catch=function(M){return this.then(void 0,M)},m.prototype.T=function(M,G){function Q(){switch(he.i){case 1:M(he.j);break;case 2:G(he.j);break;default:throw Error("Unexpected state: "+he.i)}}var he=this;this.h==null?R.i(Q):this.h.push(Q),this.u=!0},m.resolve=x,m.reject=function(M){return new m(function(G,Q){Q(M)})},m.race=function(M){return new m(function(G,Q){for(var he=W(M),fe=he.next();!fe.done;fe=he.next())x(fe.value).T(G,Q)})},m.all=function(M){var G=W(M),Q=G.next();return Q.done?x([]):new m(function(he,fe){function we(Le){return function(je){Re[Le]=je,--me==0&&he(Re)}}var Re=[],me=0;do Re.push(void 0),me++,x(Q.value).T(we(Re.length-1),fe),Q=G.next();while(!Q.done)})},m}),ze("Array.prototype.keys",function(l){return l||function(){return function(m,S){m instanceof String&&(m+="");var x=0,D=!1,R={next:function(){if(!D&&x<m.length){var M=x++;return{value:S(M,m[M]),done:!1}}return D=!0,{done:!0,value:void 0}}};return R[Symbol.iterator]=function(){return R},R}(this,function(m){return m})}}),ze("Array.prototype.fill",function(l){return l||function(m,S,x){var D=this.length||0;for(0>S&&(S=Math.max(0,D+S)),(x==null||x>D)&&(x=D),0>(x=Number(x))&&(x=Math.max(0,D+x)),S=Number(S||0);S<x;S++)this[S]=m;return this}}),ze("Int8Array.prototype.fill",zt),ze("Uint8Array.prototype.fill",zt),ze("Uint8ClampedArray.prototype.fill",zt),ze("Int16Array.prototype.fill",zt),ze("Uint16Array.prototype.fill",zt),ze("Int32Array.prototype.fill",zt),ze("Uint32Array.prototype.fill",zt),ze("Float32Array.prototype.fill",zt),ze("Float64Array.prototype.fill",zt),ze("Object.is",function(l){return l||function(m,S){return m===S?m!==0||1/m==1/S:m!=m&&S!=S}}),ze("Array.prototype.includes",function(l){return l||function(m,S){var x=this;x instanceof String&&(x=String(x));var D=x.length;for(0>(S=S||0)&&(S=Math.max(S+D,0));S<D;S++){var R=x[S];if(R===m||Object.is(R,m))return!0}return!1}}),ze("String.prototype.includes",function(l){return l||function(m,S){if(this==null)throw new TypeError("The 'this' value for String.prototype.includes must not be null or undefined");if(m instanceof RegExp)throw new TypeError("First argument to String.prototype.includes must not be a regular expression");return this.indexOf(m,S||0)!==-1}});var Kn=this||self;function de(l,m){l=l.split(".");var S,x=Kn;for((l[0]in x)||x.execScript===void 0||x.execScript("var "+l[0]);l.length&&(S=l.shift());)l.length||m===void 0?x=x[S]&&x[S]!==Object.prototype[S]?x[S]:x[S]={}:x[S]=m}function le(l){var m;return(m=Kn.navigator)&&(m=m.userAgent)||(m=""),m.indexOf(l)!=-1}var Ne=Array.prototype.map?function(l,m){return Array.prototype.map.call(l,m,void 0)}:function(l,m){for(var S=l.length,x=Array(S),D=typeof l=="string"?l.split(""):l,R=0;R<S;R++)R in D&&(x[R]=m.call(void 0,D[R],R,l));return x},Je={},De=null;function lt(l){var m=l.length,S=3*m/4;S%3?S=Math.floor(S):"=.".indexOf(l[m-1])!=-1&&(S="=.".indexOf(l[m-2])!=-1?S-2:S-1);var x=new Uint8Array(S),D=0;return function(R,M){function G(me){for(;Q<R.length;){var Le=R.charAt(Q++),je=De[Le];if(je!=null)return je;if(!/^[\s\xa0]*$/.test(Le))throw Error("Unknown base64 encoding at char: "+Le)}return me}it();for(var Q=0;;){var he=G(-1),fe=G(0),we=G(64),Re=G(64);if(Re===64&&he===-1)break;M(he<<2|fe>>4),we!=64&&(M(fe<<4&240|we>>2),Re!=64&&M(we<<6&192|Re))}}(l,function(R){x[D++]=R}),D!==S?x.subarray(0,D):x}function it(){if(!De){De={};for(var l="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789".split(""),m=["+/=","+/","-_=","-_.","-_"],S=0;5>S;S++){var x=l.concat(m[S].split(""));Je[S]=x;for(var D=0;D<x.length;D++){var R=x[D];De[R]===void 0&&(De[R]=D)}}}}var Vt=typeof Uint8Array!="undefined",en=!(le("Trident")||le("MSIE"))&&typeof Kn.btoa=="function";function pe(l){if(!en){var m;m===void 0&&(m=0),it(),m=Je[m];for(var S=Array(Math.floor(l.length/3)),x=m[64]||"",D=0,R=0;D<l.length-2;D+=3){var M=l[D],G=l[D+1],Q=l[D+2],he=m[M>>2];M=m[(3&M)<<4|G>>4],G=m[(15&G)<<2|Q>>6],Q=m[63&Q],S[R++]=he+M+G+Q}switch(he=0,Q=x,l.length-D){case 2:Q=m[(15&(he=l[D+1]))<<2]||x;case 1:l=l[D],S[R]=m[l>>2]+m[(3&l)<<4|he>>4]+Q+x}return S.join("")}for(m="";10240<l.length;)m+=String.fromCharCode.apply(null,l.subarray(0,10240)),l=l.subarray(10240);return m+=String.fromCharCode.apply(null,l),btoa(m)}var Lt,qt=RegExp("[-_.]","g");function lr(l){switch(l){case"-":return"+";case"_":return"/";case".":return"=";default:return""}}function wi(l){if(!en)return lt(l);qt.test(l)&&(l=l.replace(qt,lr)),l=atob(l);for(var m=new Uint8Array(l.length),S=0;S<l.length;S++)m[S]=l.charCodeAt(S);return m}function yn(){return Lt||(Lt=new Uint8Array(0))}var Ct={},Dd=typeof Uint8Array.prototype.slice=="function",Ot=0,pt=0;function Oc(l){var m=0>l,S=(l=Math.abs(l))>>>0;l=Math.floor((l-S)/4294967296),m&&(m=(S=W(va(S,l))).next().value,l=S.next().value,S=m),Ot=S>>>0,pt=l>>>0}var Mc,Sn=typeof BigInt=="function";function va(l,m){return m=~m,l?l=1+~l:m+=1,[l,m]}function Ei(l,m){this.i=l>>>0,this.h=m>>>0}function Nc(l){if(!l)return Mc||(Mc=new Ei(0,0));if(!/^-?\d+$/.test(l))return null;if(16>l.length)Oc(Number(l));else if(Sn)l=BigInt(l),Ot=Number(l&BigInt(4294967295))>>>0,pt=Number(l>>BigInt(32)&BigInt(4294967295));else{var m=+(l[0]==="-");pt=Ot=0;for(var S=l.length,x=m,D=(S-m)%6+m;D<=S;x=D,D+=6)x=Number(l.slice(x,D)),pt*=1e6,4294967296<=(Ot=1e6*Ot+x)&&(pt+=Ot/4294967296|0,Ot%=4294967296);m&&(l=(m=W(va(Ot,pt))).next().value,m=m.next().value,Ot=l,pt=m)}return new Ei(Ot,pt)}function at(l,m){return Error("Invalid wire type: "+l+" (at position "+m+")")}function ga(){return Error("Failed to read varint, encoding is invalid.")}function Vc(l,m){return Error("Tried to read past the end of the data "+m+" > "+l)}function ot(){throw Error("Invalid UTF8")}function _a(l,m){return m=String.fromCharCode.apply(null,m),l==null?m:l+m}var Wo,Uc,Pn,bn=void 0,qn=typeof TextDecoder!="undefined",Bc=typeof TextEncoder!="undefined";function ya(l){if(l!==Ct)throw Error("illegal external caller")}function Xr(l,m){if(ya(m),this.V=l,l!=null&&l.length===0)throw Error("ByteString should be constructed with non-empty values")}function Sa(){return Pn||(Pn=new Xr(null,Ct))}function Jo(l){ya(Ct);var m=l.V;return(m=m==null||Vt&&m!=null&&m instanceof Uint8Array?m:typeof m=="string"?wi(m):null)==null?m:l.V=m}function Ko(l,m){this.i=null,this.m=!1,this.h=this.j=this.l=0,dr(this,l,m)}function dr(l,m,S){S=S===void 0?{}:S,l.S=S.S!==void 0&&S.S,m&&(m=function(x){if(typeof x=="string")return{buffer:wi(x),C:!1};if(Array.isArray(x))return{buffer:new Uint8Array(x),C:!1};if(x.constructor===Uint8Array)return{buffer:x,C:!1};if(x.constructor===ArrayBuffer)return{buffer:new Uint8Array(x),C:!1};if(x.constructor===Xr)return{buffer:Jo(x)||yn(),C:!0};if(x instanceof Uint8Array)return{buffer:new Uint8Array(x.buffer,x.byteOffset,x.byteLength),C:!1};throw Error("Type not convertible to a Uint8Array, expected a Uint8Array, an ArrayBuffer, a base64 encoded string, a ByteString or an Array of numbers")}(m),l.i=m.buffer,l.m=m.C,l.l=0,l.j=l.i.length,l.h=l.l)}function hr(l,m){if(l.h=m,m>l.j)throw Vc(l.j,m)}function Ci(l){var m=l.i,S=l.h,x=m[S++],D=127&x;if(128&x&&(D|=(127&(x=m[S++]))<<7,128&x&&(D|=(127&(x=m[S++]))<<14,128&x&&(D|=(127&(x=m[S++]))<<21,128&x&&(D|=(x=m[S++])<<28,128&x&&128&m[S++]&&128&m[S++]&&128&m[S++]&&128&m[S++]&&128&m[S++])))))throw ga();return hr(l,S),D}function qo(l,m){if(0>m)throw Error("Tried to read a negative byte length: "+m);var S=l.h,x=S+m;if(x>l.j)throw Vc(m,l.j-S);return l.h=x,S}Ko.prototype.reset=function(){this.h=this.l};var Xo=[];function Qo(){this.h=[]}function jc(l,m,S){for(;0<S||127<m;)l.h.push(127&m|128),m=(m>>>7|S<<25)>>>0,S>>>=7;l.h.push(m)}function Pr(l,m){for(;127<m;)l.h.push(127&m|128),m>>>=7;l.h.push(m)}function Yo(l,m){if(Xo.length){var S=Xo.pop();dr(S,l,m),l=S}else l=new Ko(l,m);this.h=l,this.j=this.h.h,this.i=this.l=-1,this.setOptions(m)}function Ri(l){var m=l.h;if(m.h==m.j)return!1;l.j=l.h.h;var S=Ci(l.h)>>>0;if(m=S>>>3,!(0<=(S&=7)&&5>=S))throw at(S,l.j);if(1>m)throw Error("Invalid field number: "+m+" (at position "+l.j+")");return l.l=m,l.i=S,!0}function ba(l){switch(l.i){case 0:if(l.i!=0)ba(l);else e:{for(var m=(l=l.h).h,S=m+10,x=l.i;m<S;)if((128&x[m++])==0){hr(l,m);break e}throw ga()}break;case 1:hr(l=l.h,l.h+8);break;case 2:l.i!=2?ba(l):(m=Ci(l.h)>>>0,hr(l=l.h,l.h+m));break;case 5:hr(l=l.h,l.h+4);break;case 3:for(m=l.l;;){if(!Ri(l))throw Error("Unmatched start-group tag: stream EOF");if(l.i==4){if(l.l!=m)throw Error("Unmatched end-group tag");break}ba(l)}break;default:throw at(l.i,l.j)}}Qo.prototype.length=function(){return this.h.length},Qo.prototype.end=function(){var l=this.h;return this.h=[],l},Yo.prototype.setOptions=function(l){l=l===void 0?{}:l,this.ca=l.ca!==void 0&&l.ca},Yo.prototype.reset=function(){this.h.reset(),this.j=this.h.h,this.i=this.l=-1};var Xn=[];function Ld(){this.j=[],this.i=0,this.h=new Qo}function Qr(l,m){m.length!==0&&(l.j.push(m),l.i+=m.length)}var Qn=typeof Symbol=="function"&&X(Symbol())==="symbol"?Symbol():void 0;function Ut(l,m){return Qn?l[Qn]|=m:l.A!==void 0?l.A|=m:(Object.defineProperties(l,{A:{value:m,configurable:!0,writable:!0,enumerable:!1}}),m)}function Fc(l,m){Qn?l[Qn]&&(l[Qn]&=~m):l.A!==void 0&&(l.A&=~m)}function wt(l){var m;return(m=Qn?l[Qn]:l.A)==null?0:m}function Xt(l,m){Qn?l[Qn]=m:l.A!==void 0?l.A=m:Object.defineProperties(l,{A:{value:m,configurable:!0,writable:!0,enumerable:!1}})}function Ai(l){return Ut(l,1),l}function $o(l,m){Xt(m,-51&(0|l))}function Yr(l,m){Xt(m,-41&(18|l))}var Zo={};function Dr(l){return l!==null&&X(l)==="object"&&!Array.isArray(l)&&l.constructor===Object}var $r,ka,Ta=[];function es(l){if(2&wt(l.o))throw Error("Cannot mutate an immutable Message")}function xa(l){var m=l.length;(m=m?l[m-1]:void 0)&&Dr(m)?m.g=1:(m={},l.push((m.g=1,m)))}function Ia(l){var m=l.i+l.G;return l.B||(l.B=l.o[m]={})}function pn(l,m){return m===-1?null:m>=l.i?l.B?l.B[m]:void 0:l.o[m+l.G]}function Dn(l,m,S,x){es(l),Pi(l,m,S,x)}function Pi(l,m,S,x){l.j&&(l.j=void 0),m>=l.i||x?Ia(l)[m]=S:(l.o[m+l.G]=S,(l=l.B)&&m in l&&delete l[m])}function Bt(l,m,S,x){var D=pn(l,m);Array.isArray(D)||(D=$r);var R=wt(D);if(1&R||Ai(D),x)2&R||Ut(D,2),1&S||Object.freeze(D);else{x=!(2&S);var M=2&R;1&S||!M?x&&16&R&&!M&&Fc(D,16):Pi(l,m,D=Ai(Array.prototype.slice.call(D)))}return D}function ts(l,m){var S=pn(l,m),x=S==null?S:typeof S=="number"||S==="NaN"||S==="Infinity"||S==="-Infinity"?Number(S):void 0;return x!=null&&x!==S&&Pi(l,m,x),x}function Gc(l,m,S,x,D){l.h||(l.h={});var R=l.h[S],M=Bt(l,S,3,D);if(!R){var G=M;R=[];var Q=!!(16&wt(l.o));M=!!(2&wt(G));var he=G;!D&&M&&(G=Array.prototype.slice.call(G));for(var fe=M,we=0;we<G.length;we++){var Re=G[we],me=m,Le=!1;if(Le=Le!==void 0&&Le,(Re=Array.isArray(Re)?new me(Re):Le?new me:void 0)!==void 0){var je=Le=wt(me=Re.o);M&&(je|=2),Q&&(je|=16),je!=Le&&Xt(me,je),me=je,fe=fe||!!(2&me),R.push(Re)}}return l.h[S]=R,m=33|(Q=wt(G)),Q!=(m=fe?-9&m:8|m)&&(fe=G,Object.isFrozen(fe)&&(fe=Array.prototype.slice.call(fe)),Xt(fe,m),G=fe),he!==G&&Pi(l,S,G),(D||x&&M)&&Ut(R,2),x&&Object.freeze(R),R}return D||(D=Object.isFrozen(R),x&&!D?Object.freeze(R):!x&&D&&(R=Array.prototype.slice.call(R),l.h[S]=R)),R}function xt(l,m,S){var x=!!(2&wt(l.o));if(m=Gc(l,m,S,x,x),l=Bt(l,S,3,x),!(x||8&wt(l))){for(x=0;x<m.length;x++){if(2&wt((S=m[x]).o)){var D=Zr(S,!1);D.j=S}else D=S;S!==D&&(m[x]=D,l[x]=D.o)}Ut(l,8)}return m}function Ln(l,m,S){if(S!=null&&typeof S!="number")throw Error("Value of float/double field must be a number|null|undefined, found "+X(S)+": "+S);Dn(l,m,S)}function Hc(l,m,S,x,D){es(l);var R=Gc(l,S,m,!1,!1);return S=x!=null?x:new S,l=Bt(l,m,2,!1),D!=null?(R.splice(D,0,S),l.splice(D,0,S.o)):(R.push(S),l.push(S.o)),S.C()&&Fc(l,8),S}function wa(l,m){return l==null?m:l}function On(l,m,S){return S=S===void 0?0:S,wa(ts(l,m),S)}function Di(l,m,S,x){if(l!=null){if(Array.isArray(l))l=ns(l,m,S,x!==void 0);else if(Dr(l)){var D,R={};for(D in l)R[D]=Di(l[D],m,S,x);l=R}else l=m(l,x);return l}}function ns(l,m,S,x){var D=wt(l);x=x?!!(16&D):void 0,l=Array.prototype.slice.call(l);for(var R=0;R<l.length;R++)l[R]=Di(l[R],m,S,x);return S(D,l),l}function Od(l){return l.ja===Zo?l.toJSON():function(m){switch(X(m)){case"number":return isFinite(m)?m:String(m);case"object":if(m)if(Array.isArray(m)){if((128&wt(m))!=0)return xa(m=Array.prototype.slice.call(m)),m}else{if(Vt&&m!=null&&m instanceof Uint8Array)return pe(m);if(m instanceof Xr){var S=m.V;return S==null?"":typeof S=="string"?S:m.V=pe(S)}}}return m}(l)}function zc(l,m){128&l&&xa(m)}function Wc(l,m,S){if(S=S===void 0?Yr:S,l!=null){if(Vt&&l instanceof Uint8Array)return l.length?new Xr(new Uint8Array(l),Ct):Sa();if(Array.isArray(l)){var x=wt(l);return 2&x?l:!m||32&x||!(16&x||x===0)?(4&(m=wt(l=ns(l,Wc,4&x?Yr:S,!0)))&&2&m&&Object.freeze(l),l):(Xt(l,2|x),l)}return l.ja===Zo?is(l):l}}function rs(l,m,S,x,D,R,M){if(l=l.h&&l.h[S]){if(2&(x=wt(l))?x=l:(Yr(x,R=Ne(l,is)),Object.freeze(R),x=R),es(m),M=x==null?$r:Ai([]),x!=null){for(R=!!x.length,l=0;l<x.length;l++){var G=x[l];R=R&&!(2&wt(G.o)),M[l]=G.o}R=1|(R?8:0),((l=wt(M))&R)!==R&&(Object.isFrozen(M)&&(M=Array.prototype.slice.call(M)),Xt(M,l|R)),m.h||(m.h={}),m.h[S]=x}else m.h&&(m.h[S]=void 0);Pi(m,S,M,D)}else Dn(m,S,Wc(x,R,M),D)}function is(l){return 2&wt(l.o)||Ut((l=Zr(l,!0)).o,2),l}function Zr(l,m){var S=l.o,x=[];Ut(x,16);var D=l.constructor.h;if(D&&x.push(D),D=l.B){x.length=S.length,x.fill(void 0,x.length,S.length);var R={};x[x.length-1]=R}(128&wt(S))!=0&&xa(x),m=m||l.C()?Yr:$o,R=l.constructor,ka=x,x=new R(x),ka=void 0,l.R&&(x.R=l.R.slice()),R=!!(16&wt(S));for(var M=D?S.length-1:S.length,G=0;G<M;G++)rs(l,x,G-l.G,S[G],!1,R,m);if(D)for(var Q in D)rs(l,x,+Q,D[Q],!0,R,m);return x}function Rt(l,m,S){l==null&&(l=ka),ka=void 0;var x,D=this.constructor.i||0,R=0<D,M=this.constructor.h,G=!1;if(l==null){var Q=48,he=!0;R&&(D=0,Q|=128),Xt(l=M?[M]:[],Q)}else{if(!Array.isArray(l)||M&&M!==l[0])throw Error();var fe=Q=Ut(l,0);if((he=(16&fe)!=0)&&((G=(32&fe)!=0)||(fe|=32)),R){if(128&fe)D=0;else if(0<l.length){var we=l[l.length-1];if(Dr(we)&&"g"in we){D=0,fe|=128,delete we.g;var Re,me=!0;for(Re in we){me=!1;break}me&&l.pop()}}}else if(128&fe)throw Error();Q!==fe&&Xt(l,fe)}if(this.G=(M?0:-1)-D,this.h=void 0,this.o=l,D=(M=this.o.length)-1,M&&Dr(M=this.o[D])?(this.B=M,this.i=D-this.G):m!==void 0&&-1<m?(this.i=Math.max(m,D+1-this.G),this.B=void 0):this.i=Number.MAX_VALUE,!R&&this.B&&"g"in this.B)throw Error('Unexpected "g" flag in sparse object of message that is not a group type.');if(S)for(m=he&&!G&&!0,R=this.i,he=0;he<S.length;he++)(G=S[he])<R?(D=l[G+=this.G])?as(D,m):l[G]=$r:(x||(x=Ia(this)),(D=x[G])?as(D,m):x[G]=$r)}function as(l,m){if(Array.isArray(l)){var S=wt(l),x=1;!m||2&S||(x|=16),(S&x)!==x&&Xt(l,S|x)}}function Jc(l,m,S){if(S){var x,D={};for(x in S){var R=S[x],M=R.ra;M||(D.J=R.xa||R.oa.W,R.ia?(D.aa=Yc(R.ia),M=function(G){return function(Q,he,fe){return G.J(Q,he,fe,G.aa)}}(D)):R.ka?(D.Z=Ca(R.da.P,R.ka),M=function(G){return function(Q,he,fe){return G.J(Q,he,fe,G.Z)}}(D)):M=D.J,R.ra=M),M(m,l,R.da),D={J:D.J,aa:D.aa,Z:D.Z}}}(function(G,Q){if(Q=Q.R){Qr(G,G.h.end());for(var he=0;he<Q.length;he++)Qr(G,Jo(Q[he])||yn())}})(m,l)}Xt(Ta,23),$r=Object.freeze(Ta),Rt.prototype.toJSON=function(){return ns(this.o,Od,zc)},Rt.prototype.C=function(){return!!(2&wt(this.o))},Rt.prototype.ja=Zo,Rt.prototype.toString=function(){return this.o.toString()};var nt=Symbol();function Kc(l,m,S){return l[nt]||(l[nt]=function(x,D){return m(x,D,S)})}function os(l){var m=l[nt];if(!m){var S=us(l);m=function(x,D){return eu(x,D,S)},l[nt]=m}return m}function qc(l){var m=function(D){var R=D.ia;return R?os(R):(R=D.wa)?Kc(D.da.P,R,D.ka):void 0}(l),S=l.da,x=l.oa.U;return m?function(D,R){return x(D,R,S,m)}:function(D,R){return x(D,R,S)}}function Xc(l,m){var S=l[m];return typeof S=="function"&&S.length===0&&(S=S(),l[m]=S),Array.isArray(S)&&(pr in S||Li in S||0<S.length&&typeof S[0]=="function")?S:void 0}function Qc(l,m,S,x,D,R){m.P=l[0];var M=1;if(l.length>M&&typeof l[M]!="number"){var G=l[M++];S(m,G)}for(;M<l.length;){S=l[M++];for(var Q=M+1;Q<l.length&&typeof l[Q]!="number";)Q++;switch(G=l[M++],Q-=M){case 0:x(m,S,G);break;case 1:(Q=Xc(l,M))?(M++,D(m,S,G,Q)):x(m,S,G,l[M++]);break;case 2:D(m,S,G,Q=Xc(l,Q=M++),l[M++]);break;case 3:R(m,S,G,l[M++],l[M++],l[M++]);break;case 4:R(m,S,G,l[M++],l[M++],l[M++],l[M++]);break;default:throw Error("unexpected number of binary field arguments: "+Q)}}return m}var Ea=Symbol();function Yc(l){var m=l[Ea];if(!m){var S=cs(l);m=function(x,D){return tu(x,D,S)},l[Ea]=m}return m}function Ca(l,m){var S=l[Ea];return S||(S=function(x,D){return Jc(x,D,m)},l[Ea]=S),S}var Li=Symbol();function Md(l,m){l.push(m)}function Ra(l,m,S){l.push(m,S.W)}function $c(l,m,S,x){var D=Yc(x),R=cs(x).P,M=S.W;l.push(m,function(G,Q,he){return M(G,Q,he,R,D)})}function ss(l,m,S,x,D,R){var M=Ca(x,R),G=S.W;l.push(m,function(Q,he,fe){return G(Q,he,fe,x,M)})}function cs(l){var m=l[Li];return m||(m=Qc(l,l[Li]=[],Md,Ra,$c,ss),pr in l&&Li in l&&(l.length=0),m)}var pr=Symbol();function Nd(l,m){l[0]=m}function Zc(l,m,S,x){var D=S.U;l[m]=x?function(R,M,G){return D(R,M,G,x)}:D}function Vd(l,m,S,x,D){var R=S.U,M=os(x),G=us(x).P;l[m]=function(Q,he,fe){return R(Q,he,fe,G,M,D)}}function Ud(l,m,S,x,D,R,M){var G=S.U,Q=Kc(x,D,R);l[m]=function(he,fe,we){return G(he,fe,we,x,Q,M)}}function us(l){var m=l[pr];return m||(m=Qc(l,l[pr]={},Nd,Zc,Vd,Ud),pr in l&&Li in l&&(l.length=0),m)}function eu(l,m,S){for(;Ri(m)&&m.i!=4;){var x=m.l,D=S[x];if(!D){var R=S[0];R&&(R=R[x])&&(D=S[x]=qc(R))}if(!D||!D(m,l,x)){x=l,R=(D=m).j,ba(D);var M=D;if(!M.ca){if(D=M.h.h-R,M.h.h=R,M=M.h,D==0)D=Sa();else{if(R=qo(M,D),M.S&&M.m)D=M.i.subarray(R,R+D);else{M=M.i;var G=R;D=G===(D=R+D)?yn():Dd?M.slice(G,D):new Uint8Array(M.subarray(G,D))}D=D.length==0?Sa():new Xr(D,Ct)}(R=x.R)?R.push(D):x.R=[D]}}}return l}function tu(l,m,S){for(var x=S.length,D=x%2==1,R=D?1:0;R<x;R+=2)(0,S[R+1])(m,l,S[R]);Jc(l,m,D?S[0]:void 0)}function Oi(l,m){return{U:l,W:m}}var kn=Oi(function(l,m,S){if(l.i!==5)return!1;var x=(l=l.h).i,D=l.h,R=x[D],M=x[D+1],G=x[D+2];return x=x[D+3],hr(l,l.h+4),l=2*((M=(R<<0|M<<8|G<<16|x<<24)>>>0)>>31)+1,R=M>>>23&255,M&=8388607,Dn(m,S,R==255?M?NaN:1/0*l:R==0?l*Math.pow(2,-149)*M:l*Math.pow(2,R-150)*(M+Math.pow(2,23))),!0},function(l,m,S){if((m=ts(m,S))!=null){Pr(l.h,8*S+5),l=l.h;var x=+m;x===0?0<1/x?Ot=pt=0:(pt=0,Ot=2147483648):isNaN(x)?(pt=0,Ot=2147483647):34028234663852886e22<(x=(S=0>x?-2147483648:0)?-x:x)?(pt=0,Ot=(2139095040|S)>>>0):11754943508222875e-54>x?(x=Math.round(x/Math.pow(2,-149)),pt=0,Ot=(S|x)>>>0):(m=Math.floor(Math.log(x)/Math.LN2),x*=Math.pow(2,-m),16777216<=(x=Math.round(8388608*x))&&++m,pt=0,Ot=(S|m+127<<23|8388607&x)>>>0),S=Ot,l.h.push(S>>>0&255),l.h.push(S>>>8&255),l.h.push(S>>>16&255),l.h.push(S>>>24&255)}}),Bd=Oi(function(l,m,S){if(l.i!==0)return!1;var x=l.h,D=0,R=l=0,M=x.i,G=x.h;do{var Q=M[G++];D|=(127&Q)<<R,R+=7}while(32>R&&128&Q);for(32<R&&(l|=(127&Q)>>4),R=3;32>R&&128&Q;R+=7)l|=(127&(Q=M[G++]))<<R;if(hr(x,G),!(128>Q))throw ga();return x=D>>>0,(l=2147483648&(Q=l>>>0))&&(Q=~Q>>>0,(x=1+~x>>>0)==0&&(Q=Q+1>>>0)),x=4294967296*Q+(x>>>0),Dn(m,S,l?-x:x),!0},function(l,m,S){(m=pn(m,S))!=null&&(typeof m=="string"&&Nc(m),m!=null&&(Pr(l.h,8*S),typeof m=="number"?(l=l.h,Oc(m),jc(l,Ot,pt)):(S=Nc(m),jc(l.h,S.i,S.h))))}),nu=Oi(function(l,m,S){return l.i===0&&(Dn(m,S,Ci(l.h)),!0)},function(l,m,S){if((m=pn(m,S))!=null&&m!=null)if(Pr(l.h,8*S),l=l.h,0<=(S=m))Pr(l,S);else{for(m=0;9>m;m++)l.h.push(127&S|128),S>>=7;l.h.push(1)}}),At=Oi(function(l,m,S){if(l.i!==2)return!1;var x=Ci(l.h)>>>0,D=qo(l=l.h,x);if(l=l.i,qn){var R,M=l;(R=Wo)||(R=Wo=new TextDecoder("utf-8",{fatal:!0})),l=D+x,M=D===0&&l===M.length?M:M.subarray(D,l);try{var G=R.decode(M)}catch(we){if(bn===void 0){try{R.decode(new Uint8Array([128]))}catch(Re){}try{R.decode(new Uint8Array([97])),bn=!0}catch(Re){bn=!1}}throw!bn&&(Wo=void 0),we}}else{x=(G=D)+x,D=[];for(var Q,he,fe=null;G<x;)128>(Q=l[G++])?D.push(Q):224>Q?G>=x?ot():(he=l[G++],194>Q||(192&he)!=128?(G--,ot()):D.push((31&Q)<<6|63&he)):240>Q?G>=x-1?ot():(192&(he=l[G++]))!=128||Q===224&&160>he||Q===237&&160<=he||(192&(M=l[G++]))!=128?(G--,ot()):D.push((15&Q)<<12|(63&he)<<6|63&M):244>=Q?G>=x-2?ot():(192&(he=l[G++]))!=128||he-144+(Q<<28)>>30!=0||(192&(M=l[G++]))!=128||(192&(R=l[G++]))!=128?(G--,ot()):(Q=(7&Q)<<18|(63&he)<<12|(63&M)<<6|63&R,Q-=65536,D.push(55296+(Q>>10&1023),56320+(1023&Q))):ot(),8192<=D.length&&(fe=_a(fe,D),D.length=0);G=_a(fe,D)}return Dn(m,S,G),!0},function(l,m,S){if((m=pn(m,S))!=null){var x=!1;if(x=x!==void 0&&x,Bc){if(x&&/(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])/.test(m))throw Error("Found an unpaired surrogate");m=(Uc||(Uc=new TextEncoder)).encode(m)}else{for(var D=0,R=new Uint8Array(3*m.length),M=0;M<m.length;M++){var G=m.charCodeAt(M);if(128>G)R[D++]=G;else{if(2048>G)R[D++]=G>>6|192;else{if(55296<=G&&57343>=G){if(56319>=G&&M<m.length){var Q=m.charCodeAt(++M);if(56320<=Q&&57343>=Q){G=1024*(G-55296)+Q-56320+65536,R[D++]=G>>18|240,R[D++]=G>>12&63|128,R[D++]=G>>6&63|128,R[D++]=63&G|128;continue}M--}if(x)throw Error("Found an unpaired surrogate");G=65533}R[D++]=G>>12|224,R[D++]=G>>6&63|128}R[D++]=63&G|128}}m=D===R.length?R:R.subarray(0,D)}Pr(l.h,8*S+2),Pr(l.h,m.length),Qr(l,l.h.end()),Qr(l,m)}}),ls=Oi(function(l,m,S,x,D){if(l.i!==2)return!1;m=Hc(m,S,x),S=l.h.j,x=Ci(l.h)>>>0;var R=l.h.h+x,M=R-S;if(0>=M&&(l.h.j=R,D(m,l,void 0,void 0,void 0),M=R-l.h.h),M)throw Error("Message parsing ended unexpectedly. Expected to read "+x+" bytes, instead read "+(x-M)+" bytes, either the data ended unexpectedly or the message misreported its own length");return l.h.h=R,l.h.j=S,!0},function(l,m,S,x,D){if((m=xt(m,x,S))!=null)for(x=0;x<m.length;x++){var R=l;Pr(R.h,8*S+2);var M=R.h.end();Qr(R,M),M.push(R.i),R=M,D(m[x],l),M=l;var G=R.pop();for(G=M.i+M.h.length()-G;127<G;)R.push(127&G|128),G>>>=7,M.i++;R.push(G),M.i++}});function ds(l){return function(m,S){e:{if(Xn.length){var x=Xn.pop();x.setOptions(S),dr(x.h,m,S),m=x}else m=new Yo(m,S);try{var D=us(l),R=eu(new D.P,m,D);break e}finally{(D=m.h).i=null,D.m=!1,D.l=0,D.j=0,D.h=0,D.S=!1,m.l=-1,m.i=-1,100>Xn.length&&Xn.push(m)}R=void 0}return R}}function hs(l){return function(){var m=new Ld;tu(this,m,cs(l)),Qr(m,m.h.end());for(var S=new Uint8Array(m.i),x=m.j,D=x.length,R=0,M=0;M<D;M++){var G=x[M];S.set(G,R),R+=G.length}return m.j=[S],S}}function ei(l){Rt.call(this,l)}Jt(ei,Rt);var It=[ei,1,nu,2,kn,3,At,4,At];function ps(l){Rt.call(this,l,-1,jd)}ei.prototype.l=hs(It),Jt(ps,Rt),ps.prototype.addClassification=function(l,m){return Hc(this,1,ei,l,m),this};var jd=[1],Fd=ds([ps,1,ls,It]);function fr(l){Rt.call(this,l)}Jt(fr,Rt);var fs=[fr,1,kn,2,kn,3,kn,4,kn,5,kn];function ru(l){Rt.call(this,l,-1,ms)}fr.prototype.l=hs(fs),Jt(ru,Rt);var ms=[1],Gd=ds([ru,1,ls,fs]);function Aa(l){Rt.call(this,l)}Jt(Aa,Rt);var iu=[Aa,1,kn,2,kn,3,kn,4,kn,5,kn,6,Bd],Hd=ds(iu);function au(l,m,S){if(S=l.createShader(S===0?l.VERTEX_SHADER:l.FRAGMENT_SHADER),l.shaderSource(S,m),l.compileShader(S),!l.getShaderParameter(S,l.COMPILE_STATUS))throw Error(`Could not compile WebGL shader.
531
+ `},se=X.vertexShaderSource,z=X.fragmentShaderSource;this.program=Qe(oe,[se,z]);var re=oe.getAttribLocation(this.program,"position"),be=oe.getAttribLocation(this.program,"texCoord"),ue=this.program;this.virtualParams={resolutionLocation:oe.getUniformLocation(ue,"resolution"),imageLocation0:oe.getUniformLocation(ue,"u_image0"),imageLocation1:oe.getUniformLocation(ue,"u_image1"),imageLocation2:oe.getUniformLocation(ue,"u_image2"),imageOldLocation0:oe.getUniformLocation(ue,"u_image_old0"),imageOldLocation1:oe.getUniformLocation(ue,"u_image_old1"),imageOldLocation2:oe.getUniformLocation(ue,"u_image_old2"),imageOldLocation3:oe.getUniformLocation(ue,"u_image_old3"),imageOldLocation4:oe.getUniformLocation(ue,"u_image_old4"),imageOldLocation5:oe.getUniformLocation(ue,"u_image_old5")},this.virtualLocation={postProcessTypeLocation:oe.getUniformLocation(ue,"PostProcessType"),sigmaLocation:oe.getUniformLocation(ue,"SIGMA"),bSigmaLocation:oe.getUniformLocation(ue,"BSIGMA"),mSizeLocation:oe.getUniformLocation(ue,"MSIZE"),overlayTypeLocation:oe.getUniformLocation(ue,"overlayType"),hardThresholdLocation:oe.getUniformLocation(ue,"hardThreshold"),sigmoidClipLocation:oe.getUniformLocation(ue,"sigmoidClip")},oe.bindVertexArray(this.vao),oe.bindBuffer(oe.ARRAY_BUFFER,this.positionBuffer),oe.enableVertexAttribArray(re),oe.vertexAttribPointer(re,2,oe.FLOAT,!1,0,0),oe.bindBuffer(oe.ARRAY_BUFFER,oe.createBuffer()),oe.bufferData(oe.ARRAY_BUFFER,new Float32Array([0,0,1,0,0,1,0,1,1,0,1,1]),oe.STATIC_DRAW),oe.enableVertexAttribArray(be),oe.vertexAttribPointer(be,2,oe.FLOAT,!1,0,0)}},{key:"onVirtualResults",value:function(oe){var X=oe.segmentationMask,se=oe.image,z=this.gl;this.maskBuffer.length<3&&this.maskBuffer.push(X,X,X),this.frameBuffer.length<3&&this.frameBuffer.push(se,se,se);for(var re=[],be=[X,se,this.img,this.maskBuffer[0],this.maskBuffer[1],this.maskBuffer[2],this.frameBuffer[0],this.frameBuffer[1],this.frameBuffer[2]],ue=0;ue<be.length;++ue)this.sourceTexture=z.createTexture(),z.bindTexture(z.TEXTURE_2D,this.sourceTexture),z.texParameteri(z.TEXTURE_2D,z.TEXTURE_WRAP_S,z.CLAMP_TO_EDGE),z.texParameteri(z.TEXTURE_2D,z.TEXTURE_WRAP_T,z.CLAMP_TO_EDGE),z.texParameteri(z.TEXTURE_2D,z.TEXTURE_MIN_FILTER,z.NEAREST),z.texParameteri(z.TEXTURE_2D,z.TEXTURE_MAG_FILTER,z.NEAREST),z.texImage2D(z.TEXTURE_2D,0,z.RGBA,z.RGBA,z.UNSIGNED_BYTE,be[ue]),re.push(this.sourceTexture);z.bindBuffer(z.ARRAY_BUFFER,this.positionBuffer),this.setRectangle(z,0,0,this.width,this.height),z.viewport(0,0,this.width,this.height),z.clearColor(0,0,0,0),z.clear(z.COLOR_BUFFER_BIT|z.DEPTH_BUFFER_BIT),z.useProgram(this.program),z.bindVertexArray(this.vao);var _e=this.virtualParams,Oe=_e.resolutionLocation,Wt=_e.imageLocation0,$t=_e.imageLocation1,Xe=_e.imageLocation2,qt=_e.imageOldLocation0,dt=_e.imageOldLocation1,zn=_e.imageOldLocation2,ur=_e.imageOldLocation3,Ht=_e.imageOldLocation4,En=_e.imageOldLocation5;z.uniform2f(Oe,this.width,this.height);var Ze=this.virtualOption,Gt=Ze.postProcess,Wn=Ze.kSize,he=Ze.sigma,de=Ze.bSigma,Ne=Ze.overlayType,We=Ze.hardThreshold,De=Ze.sigmoidClip,ct=this.virtualLocation,rt=ct.postProcessTypeLocation,Nt=ct.mSizeLocation,Zt=ct.sigmaLocation,pe=ct.bSigmaLocation,Lt=ct.overlayTypeLocation,Jt=ct.hardThresholdLocation,lr=ct.sigmoidClipLocation;z.uniform1i(rt,Gt),z.uniform1i(Nt,Wn),z.uniform1f(Zt,he),z.uniform1f(pe,de),z.uniform1i(Lt,Ne),z.uniform1f(Jt,We),z.uniform1i(lr,De),z.uniform1i(Wt,0),z.uniform1i($t,1),z.uniform1i(Xe,2),z.uniform1i(qt,3),z.uniform1i(dt,4),z.uniform1i(zn,5),z.uniform1i(ur,6),z.uniform1i(Ht,7),z.uniform1i(En,8),z.activeTexture(z.TEXTURE0),z.bindTexture(z.TEXTURE_2D,re[0]),z.activeTexture(z.TEXTURE1),z.bindTexture(z.TEXTURE_2D,re[1]),z.activeTexture(z.TEXTURE2),z.bindTexture(z.TEXTURE_2D,re[2]),z.activeTexture(z.TEXTURE3),z.bindTexture(z.TEXTURE_2D,re[3]),z.activeTexture(z.TEXTURE4),z.bindTexture(z.TEXTURE_2D,re[4]),z.activeTexture(z.TEXTURE5),z.bindTexture(z.TEXTURE_2D,re[5]),z.activeTexture(z.TEXTURE6),z.bindTexture(z.TEXTURE_2D,re[6]),z.activeTexture(z.TEXTURE7),z.bindTexture(z.TEXTURE_2D,re[7]),z.activeTexture(z.TEXTURE8),z.bindTexture(z.TEXTURE_2D,re[8]),z.drawArrays(z.TRIANGLES,0,6),this.maskBuffer[0]=this.maskBuffer[1],this.maskBuffer[1]=this.maskBuffer[2],this.maskBuffer[2]=X,this.frameBuffer[0]=this.frameBuffer[1],this.frameBuffer[1]=this.frameBuffer[2],this.frameBuffer[2]=se}}]),le}(),Wo=typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:typeof global!="undefined"?global:typeof self!="undefined"?self:{};(function(){var le;function ke(d){var g=0;return function(){return g<d.length?{done:!1,value:d[g++]}:{done:!0}}}var Se=typeof Object.defineProperties=="function"?Object.defineProperty:function(d,g,w){return d==Array.prototype||d==Object.prototype||(d[g]=w.value),d},je=function(d){d=[(typeof globalThis=="undefined"?"undefined":$(globalThis))=="object"&&globalThis,d,(typeof window=="undefined"?"undefined":$(window))=="object"&&window,(typeof self=="undefined"?"undefined":$(self))=="object"&&self,$(Wo)=="object"&&Wo];for(var g=0;g<d.length;++g){var w=d[g];if(w&&w.Math==Math)return w}throw Error("Cannot find global object")}(this);function He(d,g){if(g)e:{var w=je;d=d.split(".");for(var L=0;L<d.length-1;L++){var B=d[L];if(!(B in w))break e;w=w[B]}(g=g(L=w[d=d[d.length-1]]))!=L&&g!=null&&Se(w,d,{configurable:!0,writable:!0,value:g})}}function oe(d){return(d={next:d})[Symbol.iterator]=function(){return this},d}function X(d){var g=typeof Symbol!="undefined"&&Symbol.iterator&&d[Symbol.iterator];return g?g.call(d):{next:ke(d)}}function se(d){if(!(d instanceof Array)){d=X(d);for(var g,w=[];!(g=d.next()).done;)w.push(g.value);d=w}return d}He("Symbol",function(d){function g(B,M){this.h=B,Se(this,"description",{configurable:!0,writable:!0,value:M})}if(d)return d;g.prototype.toString=function(){return this.h};var w="jscomp_symbol_"+(1e9*Math.random()>>>0)+"_",L=0;return function B(M){if(this instanceof B)throw new TypeError("Symbol is not a constructor");return new g(w+(M||"")+"_"+L++,M)}}),He("Symbol.iterator",function(d){if(d)return d;d=Symbol("Symbol.iterator");for(var g="Array Int8Array Uint8Array Uint8ClampedArray Int16Array Uint16Array Int32Array Uint32Array Float32Array Float64Array".split(" "),w=0;w<g.length;w++){var L=je[g[w]];typeof L=="function"&&typeof L.prototype[d]!="function"&&Se(L.prototype,d,{configurable:!0,writable:!0,value:function(){return oe(ke(this))}})}return d});var z=typeof Object.assign=="function"?Object.assign:function(d,g){for(var w=1;w<arguments.length;w++){var L=arguments[w];if(L)for(var B in L)Object.prototype.hasOwnProperty.call(L,B)&&(d[B]=L[B])}return d};He("Object.assign",function(d){return d||z});var re,be=typeof Object.create=="function"?Object.create:function(d){function g(){}return g.prototype=d,new g};if(typeof Object.setPrototypeOf=="function")re=Object.setPrototypeOf;else{var ue;e:{var _e={};try{_e.__proto__={a:!0},ue=_e.a;break e}catch(d){}ue=!1}re=ue?function(d,g){if(d.__proto__=g,d.__proto__!==g)throw new TypeError(d+" is not extensible");return d}:null}var Oe=re;function Wt(d,g){if(d.prototype=be(g.prototype),d.prototype.constructor=d,Oe)Oe(d,g);else for(var w in g)if(w!="prototype")if(Object.defineProperties){var L=Object.getOwnPropertyDescriptor(g,w);L&&Object.defineProperty(d,w,L)}else d[w]=g[w];d.za=g.prototype}function $t(){this.m=!1,this.j=null,this.i=void 0,this.h=1,this.v=this.s=0,this.l=null}function Xe(d){if(d.m)throw new TypeError("Generator is already running");d.m=!0}function qt(d,g){d.l={ma:g,na:!0},d.h=d.s||d.v}function dt(d,g,w){return d.h=w,{value:g}}function zn(d){this.h=new $t,this.i=d}function ur(d,g,w,L){try{var B=g.call(d.h.j,w);if(!(B instanceof Object))throw new TypeError("Iterator result "+B+" is not an object");if(!B.done)return d.h.m=!1,B;var M=B.value}catch(F){return d.h.j=null,qt(d.h,F),Ht(d)}return d.h.j=null,L.call(d.h,M),Ht(d)}function Ht(d){for(;d.h.h;)try{var g=d.i(d.h);if(g)return d.h.m=!1,{value:g.value,done:!1}}catch(w){d.h.i=void 0,qt(d.h,w)}if(d.h.m=!1,d.h.l){if(g=d.h.l,d.h.l=null,g.na)throw g.ma;return{value:g.return,done:!0}}return{value:void 0,done:!0}}function En(d){this.next=function(g){return Xe(d.h),d.h.j?g=ur(d,d.h.j.next,g,d.h.u):(d.h.u(g),g=Ht(d)),g},this.throw=function(g){return Xe(d.h),d.h.j?g=ur(d,d.h.j.throw,g,d.h.u):(qt(d.h,g),g=Ht(d)),g},this.return=function(g){return function(w,L){Xe(w.h);var B=w.h.j;return B?ur(w,"return"in B?B.return:function(M){return{value:M,done:!0}},L,w.h.return):(w.h.return(L),Ht(w))}(d,g)},this[Symbol.iterator]=function(){return this}}function Ze(d){return function(g){function w(B){return g.next(B)}function L(B){return g.throw(B)}return new Promise(function(B,M){(function F(W){W.done?B(W.value):Promise.resolve(W.value).then(w,L).then(F,M)})(g.next())})}(new En(new zn(d)))}function Gt(d){return d||Array.prototype.fill}$t.prototype.u=function(d){this.i=d},$t.prototype.return=function(d){this.l={return:d},this.h=this.v},He("Promise",function(d){function g(F){this.i=0,this.j=void 0,this.h=[],this.u=!1;var W=this.l();try{F(W.resolve,W.reject)}catch(Z){W.reject(Z)}}function w(){this.h=null}function L(F){return F instanceof g?F:new g(function(W){W(F)})}if(d)return d;w.prototype.i=function(F){if(this.h==null){this.h=[];var W=this;this.j(function(){W.m()})}this.h.push(F)};var B=je.setTimeout;w.prototype.j=function(F){B(F,0)},w.prototype.m=function(){for(;this.h&&this.h.length;){var F=this.h;this.h=[];for(var W=0;W<F.length;++W){var Z=F[W];F[W]=null;try{Z()}catch(fe){this.l(fe)}}}this.h=null},w.prototype.l=function(F){this.j(function(){throw F})},g.prototype.l=function(){function F(fe){return function(me){Z||(Z=!0,fe.call(W,me))}}var W=this,Z=!1;return{resolve:F(this.I),reject:F(this.m)}},g.prototype.I=function(F){if(F===this)this.m(new TypeError("A Promise cannot resolve to itself"));else if(F instanceof g)this.L(F);else{e:switch($(F)){case"object":var W=F!=null;break e;case"function":W=!0;break e;default:W=!1}W?this.F(F):this.s(F)}},g.prototype.F=function(F){var W=void 0;try{W=F.then}catch(Z){return void this.m(Z)}typeof W=="function"?this.M(W,F):this.s(F)},g.prototype.m=function(F){this.v(2,F)},g.prototype.s=function(F){this.v(1,F)},g.prototype.v=function(F,W){if(this.i!=0)throw Error("Cannot settle("+F+", "+W+"): Promise already settled in state"+this.i);this.i=F,this.j=W,this.i===2&&this.K(),this.H()},g.prototype.K=function(){var F=this;B(function(){if(F.D()){var W=je.console;W!==void 0&&W.error(F.j)}},1)},g.prototype.D=function(){if(this.u)return!1;var F=je.CustomEvent,W=je.Event,Z=je.dispatchEvent;return Z===void 0||(typeof F=="function"?F=new F("unhandledrejection",{cancelable:!0}):typeof W=="function"?F=new W("unhandledrejection",{cancelable:!0}):(F=je.document.createEvent("CustomEvent")).initCustomEvent("unhandledrejection",!1,!0,F),F.promise=this,F.reason=this.j,Z(F))},g.prototype.H=function(){if(this.h!=null){for(var F=0;F<this.h.length;++F)M.i(this.h[F]);this.h=null}};var M=new w;return g.prototype.L=function(F){var W=this.l();F.T(W.resolve,W.reject)},g.prototype.M=function(F,W){var Z=this.l();try{F.call(W,Z.resolve,Z.reject)}catch(fe){Z.reject(fe)}},g.prototype.then=function(F,W){function Z(Ae,ve){return typeof Ae=="function"?function(Le){try{fe(Ae(Le))}catch(Be){me(Be)}}:ve}var fe,me,we=new g(function(Ae,ve){fe=Ae,me=ve});return this.T(Z(F,fe),Z(W,me)),we},g.prototype.catch=function(F){return this.then(void 0,F)},g.prototype.T=function(F,W){function Z(){switch(fe.i){case 1:F(fe.j);break;case 2:W(fe.j);break;default:throw Error("Unexpected state: "+fe.i)}}var fe=this;this.h==null?M.i(Z):this.h.push(Z),this.u=!0},g.resolve=L,g.reject=function(F){return new g(function(W,Z){Z(F)})},g.race=function(F){return new g(function(W,Z){for(var fe=X(F),me=fe.next();!me.done;me=fe.next())L(me.value).T(W,Z)})},g.all=function(F){var W=X(F),Z=W.next();return Z.done?L([]):new g(function(fe,me){function we(Le){return function(Be){Ae[Le]=Be,--ve==0&&fe(Ae)}}var Ae=[],ve=0;do Ae.push(void 0),ve++,L(Z.value).T(we(Ae.length-1),me),Z=W.next();while(!Z.done)})},g}),He("Array.prototype.keys",function(d){return d||function(){return function(g,w){g instanceof String&&(g+="");var L=0,B=!1,M={next:function(){if(!B&&L<g.length){var F=L++;return{value:w(F,g[F]),done:!1}}return B=!0,{done:!0,value:void 0}}};return M[Symbol.iterator]=function(){return M},M}(this,function(g){return g})}}),He("Array.prototype.fill",function(d){return d||function(g,w,L){var B=this.length||0;for(0>w&&(w=Math.max(0,B+w)),(L==null||L>B)&&(L=B),0>(L=Number(L))&&(L=Math.max(0,B+L)),w=Number(w||0);w<L;w++)this[w]=g;return this}}),He("Int8Array.prototype.fill",Gt),He("Uint8Array.prototype.fill",Gt),He("Uint8ClampedArray.prototype.fill",Gt),He("Int16Array.prototype.fill",Gt),He("Uint16Array.prototype.fill",Gt),He("Int32Array.prototype.fill",Gt),He("Uint32Array.prototype.fill",Gt),He("Float32Array.prototype.fill",Gt),He("Float64Array.prototype.fill",Gt),He("Object.is",function(d){return d||function(g,w){return g===w?g!==0||1/g==1/w:g!=g&&w!=w}}),He("Array.prototype.includes",function(d){return d||function(g,w){var L=this;L instanceof String&&(L=String(L));var B=L.length;for(0>(w=w||0)&&(w=Math.max(w+B,0));w<B;w++){var M=L[w];if(M===g||Object.is(M,g))return!0}return!1}}),He("String.prototype.includes",function(d){return d||function(g,w){if(this==null)throw new TypeError("The 'this' value for String.prototype.includes must not be null or undefined");if(g instanceof RegExp)throw new TypeError("First argument to String.prototype.includes must not be a regular expression");return this.indexOf(g,w||0)!==-1}});var Wn=this||self;function he(d,g){d=d.split(".");var w,L=Wn;for((d[0]in L)||L.execScript===void 0||L.execScript("var "+d[0]);d.length&&(w=d.shift());)d.length||g===void 0?L=L[w]&&L[w]!==Object.prototype[w]?L[w]:L[w]={}:L[w]=g}function de(d){var g;return(g=Wn.navigator)&&(g=g.userAgent)||(g=""),g.indexOf(d)!=-1}var Ne=Array.prototype.map?function(d,g){return Array.prototype.map.call(d,g,void 0)}:function(d,g){for(var w=d.length,L=Array(w),B=typeof d=="string"?d.split(""):d,M=0;M<w;M++)M in B&&(L[M]=g.call(void 0,B[M],M,d));return L},We={},De=null;function ct(d){var g=d.length,w=3*g/4;w%3?w=Math.floor(w):"=.".indexOf(d[g-1])!=-1&&(w="=.".indexOf(d[g-2])!=-1?w-2:w-1);var L=new Uint8Array(w),B=0;return function(M,F){function W(ve){for(;Z<M.length;){var Le=M.charAt(Z++),Be=De[Le];if(Be!=null)return Be;if(!/^[\s\xa0]*$/.test(Le))throw Error("Unknown base64 encoding at char: "+Le)}return ve}rt();for(var Z=0;;){var fe=W(-1),me=W(0),we=W(64),Ae=W(64);if(Ae===64&&fe===-1)break;F(fe<<2|me>>4),we!=64&&(F(me<<4&240|we>>2),Ae!=64&&F(we<<6&192|Ae))}}(d,function(M){L[B++]=M}),B!==w?L.subarray(0,B):L}function rt(){if(!De){De={};for(var d="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789".split(""),g=["+/=","+/","-_=","-_.","-_"],w=0;5>w;w++){var L=d.concat(g[w].split(""));We[w]=L;for(var B=0;B<L.length;B++){var M=L[B];De[M]===void 0&&(De[M]=B)}}}}var Nt=typeof Uint8Array!="undefined",Zt=!(de("Trident")||de("MSIE"))&&typeof Wn.btoa=="function";function pe(d){if(!Zt){var g;g===void 0&&(g=0),rt(),g=We[g];for(var w=Array(Math.floor(d.length/3)),L=g[64]||"",B=0,M=0;B<d.length-2;B+=3){var F=d[B],W=d[B+1],Z=d[B+2],fe=g[F>>2];F=g[(3&F)<<4|W>>4],W=g[(15&W)<<2|Z>>6],Z=g[63&Z],w[M++]=fe+F+W+Z}switch(fe=0,Z=L,d.length-B){case 2:Z=g[(15&(fe=d[B+1]))<<2]||L;case 1:d=d[B],w[M]=g[d>>2]+g[(3&d)<<4|fe>>4]+Z+L}return w.join("")}for(g="";10240<d.length;)g+=String.fromCharCode.apply(null,d.subarray(0,10240)),d=d.subarray(10240);return g+=String.fromCharCode.apply(null,d),btoa(g)}var Lt,Jt=RegExp("[-_.]","g");function lr(d){switch(d){case"-":return"+";case"_":return"/";case".":return"=";default:return""}}function Ri(d){if(!Zt)return ct(d);Jt.test(d)&&(d=d.replace(Jt,lr)),d=atob(d);for(var g=new Uint8Array(d.length),w=0;w<d.length;w++)g[w]=d.charCodeAt(w);return g}function _n(){return Lt||(Lt=new Uint8Array(0))}var Et={},xd=typeof Uint8Array.prototype.slice=="function",Ot=0,ht=0;function Pc(d){var g=0>d,w=(d=Math.abs(d))>>>0;d=Math.floor((d-w)/4294967296),g&&(g=(w=X(ga(w,d))).next().value,d=w.next().value,w=g),Ot=w>>>0,ht=d>>>0}var Dc,yn=typeof BigInt=="function";function ga(d,g){return g=~g,d?d=1+~d:g+=1,[d,g]}function Ai(d,g){this.i=d>>>0,this.h=g>>>0}function Lc(d){if(!d)return Dc||(Dc=new Ai(0,0));if(!/^-?\d+$/.test(d))return null;if(16>d.length)Pc(Number(d));else if(yn)d=BigInt(d),Ot=Number(d&BigInt(4294967295))>>>0,ht=Number(d>>BigInt(32)&BigInt(4294967295));else{var g=+(d[0]==="-");ht=Ot=0;for(var w=d.length,L=g,B=(w-g)%6+g;B<=w;L=B,B+=6)L=Number(d.slice(L,B)),ht*=1e6,4294967296<=(Ot=1e6*Ot+L)&&(ht+=Ot/4294967296|0,Ot%=4294967296);g&&(d=(g=X(ga(Ot,ht))).next().value,g=g.next().value,Ot=d,ht=g)}return new Ai(Ot,ht)}function it(d,g){return Error("Invalid wire type: "+d+" (at position "+g+")")}function _a(){return Error("Failed to read varint, encoding is invalid.")}function Oc(d,g){return Error("Tried to read past the end of the data "+g+" > "+d)}function at(){throw Error("Invalid UTF8")}function ya(d,g){return g=String.fromCharCode.apply(null,g),d==null?g:d+g}var qo,Mc,Rn,bn=void 0,qn=typeof TextDecoder!="undefined",Nc=typeof TextEncoder!="undefined";function ba(d){if(d!==Et)throw Error("illegal external caller")}function Kr(d,g){if(ba(g),this.V=d,d!=null&&d.length===0)throw Error("ByteString should be constructed with non-empty values")}function Sa(){return Rn||(Rn=new Kr(null,Et))}function Jo(d){ba(Et);var g=d.V;return(g=g==null||Nt&&g!=null&&g instanceof Uint8Array?g:typeof g=="string"?Ri(g):null)==null?g:d.V=g}function Ko(d,g){this.i=null,this.m=!1,this.h=this.j=this.l=0,dr(this,d,g)}function dr(d,g,w){w=w===void 0?{}:w,d.S=w.S!==void 0&&w.S,g&&(g=function(L){if(typeof L=="string")return{buffer:Ri(L),C:!1};if(Array.isArray(L))return{buffer:new Uint8Array(L),C:!1};if(L.constructor===Uint8Array)return{buffer:L,C:!1};if(L.constructor===ArrayBuffer)return{buffer:new Uint8Array(L),C:!1};if(L.constructor===Kr)return{buffer:Jo(L)||_n(),C:!0};if(L instanceof Uint8Array)return{buffer:new Uint8Array(L.buffer,L.byteOffset,L.byteLength),C:!1};throw Error("Type not convertible to a Uint8Array, expected a Uint8Array, an ArrayBuffer, a base64 encoded string, a ByteString or an Array of numbers")}(g),d.i=g.buffer,d.m=g.C,d.l=0,d.j=d.i.length,d.h=d.l)}function hr(d,g){if(d.h=g,g>d.j)throw Oc(d.j,g)}function Pi(d){var g=d.i,w=d.h,L=g[w++],B=127&L;if(128&L&&(B|=(127&(L=g[w++]))<<7,128&L&&(B|=(127&(L=g[w++]))<<14,128&L&&(B|=(127&(L=g[w++]))<<21,128&L&&(B|=(L=g[w++])<<28,128&L&&128&g[w++]&&128&g[w++]&&128&g[w++]&&128&g[w++]&&128&g[w++])))))throw _a();return hr(d,w),B}function Xo(d,g){if(0>g)throw Error("Tried to read a negative byte length: "+g);var w=d.h,L=w+g;if(L>d.j)throw Oc(g,d.j-w);return d.h=L,w}Ko.prototype.reset=function(){this.h=this.l};var Qo=[];function Yo(){this.h=[]}function Uc(d,g,w){for(;0<w||127<g;)d.h.push(127&g|128),g=(g>>>7|w<<25)>>>0,w>>>=7;d.h.push(g)}function Rr(d,g){for(;127<g;)d.h.push(127&g|128),g>>>=7;d.h.push(g)}function $o(d,g){if(Qo.length){var w=Qo.pop();dr(w,d,g),d=w}else d=new Ko(d,g);this.h=d,this.j=this.h.h,this.i=this.l=-1,this.setOptions(g)}function Di(d){var g=d.h;if(g.h==g.j)return!1;d.j=d.h.h;var w=Pi(d.h)>>>0;if(g=w>>>3,!(0<=(w&=7)&&5>=w))throw it(w,d.j);if(1>g)throw Error("Invalid field number: "+g+" (at position "+d.j+")");return d.l=g,d.i=w,!0}function ka(d){switch(d.i){case 0:if(d.i!=0)ka(d);else e:{for(var g=(d=d.h).h,w=g+10,L=d.i;g<w;)if((128&L[g++])==0){hr(d,g);break e}throw _a()}break;case 1:hr(d=d.h,d.h+8);break;case 2:d.i!=2?ka(d):(g=Pi(d.h)>>>0,hr(d=d.h,d.h+g));break;case 5:hr(d=d.h,d.h+4);break;case 3:for(g=d.l;;){if(!Di(d))throw Error("Unmatched start-group tag: stream EOF");if(d.i==4){if(d.l!=g)throw Error("Unmatched end-group tag");break}ka(d)}break;default:throw it(d.i,d.j)}}Yo.prototype.length=function(){return this.h.length},Yo.prototype.end=function(){var d=this.h;return this.h=[],d},$o.prototype.setOptions=function(d){d=d===void 0?{}:d,this.ca=d.ca!==void 0&&d.ca},$o.prototype.reset=function(){this.h.reset(),this.j=this.h.h,this.i=this.l=-1};var Jn=[];function Id(){this.j=[],this.i=0,this.h=new Yo}function Xr(d,g){g.length!==0&&(d.j.push(g),d.i+=g.length)}var Kn=typeof Symbol=="function"&&$(Symbol())==="symbol"?Symbol():void 0;function Ut(d,g){return Kn?d[Kn]|=g:d.A!==void 0?d.A|=g:(Object.defineProperties(d,{A:{value:g,configurable:!0,writable:!0,enumerable:!1}}),g)}function Vc(d,g){Kn?d[Kn]&&(d[Kn]&=~g):d.A!==void 0&&(d.A&=~g)}function It(d){var g;return(g=Kn?d[Kn]:d.A)==null?0:g}function Kt(d,g){Kn?d[Kn]=g:d.A!==void 0?d.A=g:Object.defineProperties(d,{A:{value:g,configurable:!0,writable:!0,enumerable:!1}})}function Li(d){return Ut(d,1),d}function Zo(d,g){Kt(g,-51&(0|d))}function Qr(d,g){Kt(g,-41&(18|d))}var es={};function Ar(d){return d!==null&&$(d)==="object"&&!Array.isArray(d)&&d.constructor===Object}var Yr,Ta,xa=[];function ts(d){if(2&It(d.o))throw Error("Cannot mutate an immutable Message")}function Ia(d){var g=d.length;(g=g?d[g-1]:void 0)&&Ar(g)?g.g=1:(g={},d.push((g.g=1,g)))}function wa(d){var g=d.i+d.G;return d.B||(d.B=d.o[g]={})}function dn(d,g){return g===-1?null:g>=d.i?d.B?d.B[g]:void 0:d.o[g+d.G]}function An(d,g,w,L){ts(d),Oi(d,g,w,L)}function Oi(d,g,w,L){d.j&&(d.j=void 0),g>=d.i||L?wa(d)[g]=w:(d.o[g+d.G]=w,(d=d.B)&&g in d&&delete d[g])}function Vt(d,g,w,L){var B=dn(d,g);Array.isArray(B)||(B=Yr);var M=It(B);if(1&M||Li(B),L)2&M||Ut(B,2),1&w||Object.freeze(B);else{L=!(2&w);var F=2&M;1&w||!F?L&&16&M&&!F&&Vc(B,16):Oi(d,g,B=Li(Array.prototype.slice.call(B)))}return B}function ns(d,g){var w=dn(d,g),L=w==null?w:typeof w=="number"||w==="NaN"||w==="Infinity"||w==="-Infinity"?Number(w):void 0;return L!=null&&L!==w&&Oi(d,g,L),L}function jc(d,g,w,L,B){d.h||(d.h={});var M=d.h[w],F=Vt(d,w,3,B);if(!M){var W=F;M=[];var Z=!!(16&It(d.o));F=!!(2&It(W));var fe=W;!B&&F&&(W=Array.prototype.slice.call(W));for(var me=F,we=0;we<W.length;we++){var Ae=W[we],ve=g,Le=!1;if(Le=Le!==void 0&&Le,(Ae=Array.isArray(Ae)?new ve(Ae):Le?new ve:void 0)!==void 0){var Be=Le=It(ve=Ae.o);F&&(Be|=2),Z&&(Be|=16),Be!=Le&&Kt(ve,Be),ve=Be,me=me||!!(2&ve),M.push(Ae)}}return d.h[w]=M,g=33|(Z=It(W)),Z!=(g=me?-9&g:8|g)&&(me=W,Object.isFrozen(me)&&(me=Array.prototype.slice.call(me)),Kt(me,g),W=me),fe!==W&&Oi(d,w,W),(B||L&&F)&&Ut(M,2),L&&Object.freeze(M),M}return B||(B=Object.isFrozen(M),L&&!B?Object.freeze(M):!L&&B&&(M=Array.prototype.slice.call(M),d.h[w]=M)),M}function kt(d,g,w){var L=!!(2&It(d.o));if(g=jc(d,g,w,L,L),d=Vt(d,w,3,L),!(L||8&It(d))){for(L=0;L<g.length;L++){if(2&It((w=g[L]).o)){var B=$r(w,!1);B.j=w}else B=w;w!==B&&(g[L]=B,d[L]=B.o)}Ut(d,8)}return g}function Pn(d,g,w){if(w!=null&&typeof w!="number")throw Error("Value of float/double field must be a number|null|undefined, found "+$(w)+": "+w);An(d,g,w)}function Bc(d,g,w,L,B){ts(d);var M=jc(d,w,g,!1,!1);return w=L!=null?L:new w,d=Vt(d,g,2,!1),B!=null?(M.splice(B,0,w),d.splice(B,0,w.o)):(M.push(w),d.push(w.o)),w.C()&&Vc(d,8),w}function Ca(d,g){return d==null?g:d}function Dn(d,g,w){return w=w===void 0?0:w,Ca(ns(d,g),w)}function Mi(d,g,w,L){if(d!=null){if(Array.isArray(d))d=rs(d,g,w,L!==void 0);else if(Ar(d)){var B,M={};for(B in d)M[B]=Mi(d[B],g,w,L);d=M}else d=g(d,L);return d}}function rs(d,g,w,L){var B=It(d);L=L?!!(16&B):void 0,d=Array.prototype.slice.call(d);for(var M=0;M<d.length;M++)d[M]=Mi(d[M],g,w,L);return w(B,d),d}function wd(d){return d.ja===es?d.toJSON():function(g){switch($(g)){case"number":return isFinite(g)?g:String(g);case"object":if(g)if(Array.isArray(g)){if((128&It(g))!=0)return Ia(g=Array.prototype.slice.call(g)),g}else{if(Nt&&g!=null&&g instanceof Uint8Array)return pe(g);if(g instanceof Kr){var w=g.V;return w==null?"":typeof w=="string"?w:g.V=pe(w)}}}return g}(d)}function Fc(d,g){128&d&&Ia(g)}function Hc(d,g,w){if(w=w===void 0?Qr:w,d!=null){if(Nt&&d instanceof Uint8Array)return d.length?new Kr(new Uint8Array(d),Et):Sa();if(Array.isArray(d)){var L=It(d);return 2&L?d:!g||32&L||!(16&L||L===0)?(4&(g=It(d=rs(d,Hc,4&L?Qr:w,!0)))&&2&g&&Object.freeze(d),d):(Kt(d,2|L),d)}return d.ja===es?as(d):d}}function is(d,g,w,L,B,M,F){if(d=d.h&&d.h[w]){if(2&(L=It(d))?L=d:(Qr(L,M=Ne(d,as)),Object.freeze(M),L=M),ts(g),F=L==null?Yr:Li([]),L!=null){for(M=!!L.length,d=0;d<L.length;d++){var W=L[d];M=M&&!(2&It(W.o)),F[d]=W.o}M=1|(M?8:0),((d=It(F))&M)!==M&&(Object.isFrozen(F)&&(F=Array.prototype.slice.call(F)),Kt(F,d|M)),g.h||(g.h={}),g.h[w]=L}else g.h&&(g.h[w]=void 0);Oi(g,w,F,B)}else An(g,w,Hc(L,M,F),B)}function as(d){return 2&It(d.o)||Ut((d=$r(d,!0)).o,2),d}function $r(d,g){var w=d.o,L=[];Ut(L,16);var B=d.constructor.h;if(B&&L.push(B),B=d.B){L.length=w.length,L.fill(void 0,L.length,w.length);var M={};L[L.length-1]=M}(128&It(w))!=0&&Ia(L),g=g||d.C()?Qr:Zo,M=d.constructor,Ta=L,L=new M(L),Ta=void 0,d.R&&(L.R=d.R.slice()),M=!!(16&It(w));for(var F=B?w.length-1:w.length,W=0;W<F;W++)is(d,L,W-d.G,w[W],!1,M,g);if(B)for(var Z in B)is(d,L,+Z,B[Z],!0,M,g);return L}function Rt(d,g,w){d==null&&(d=Ta),Ta=void 0;var L,B=this.constructor.i||0,M=0<B,F=this.constructor.h,W=!1;if(d==null){var Z=48,fe=!0;M&&(B=0,Z|=128),Kt(d=F?[F]:[],Z)}else{if(!Array.isArray(d)||F&&F!==d[0])throw Error();var me=Z=Ut(d,0);if((fe=(16&me)!=0)&&((W=(32&me)!=0)||(me|=32)),M){if(128&me)B=0;else if(0<d.length){var we=d[d.length-1];if(Ar(we)&&"g"in we){B=0,me|=128,delete we.g;var Ae,ve=!0;for(Ae in we){ve=!1;break}ve&&d.pop()}}}else if(128&me)throw Error();Z!==me&&Kt(d,me)}if(this.G=(F?0:-1)-B,this.h=void 0,this.o=d,B=(F=this.o.length)-1,F&&Ar(F=this.o[B])?(this.B=F,this.i=B-this.G):g!==void 0&&-1<g?(this.i=Math.max(g,B+1-this.G),this.B=void 0):this.i=Number.MAX_VALUE,!M&&this.B&&"g"in this.B)throw Error('Unexpected "g" flag in sparse object of message that is not a group type.');if(w)for(g=fe&&!W&&!0,M=this.i,fe=0;fe<w.length;fe++)(W=w[fe])<M?(B=d[W+=this.G])?os(B,g):d[W]=Yr:(L||(L=wa(this)),(B=L[W])?os(B,g):L[W]=Yr)}function os(d,g){if(Array.isArray(d)){var w=It(d),L=1;!g||2&w||(L|=16),(w&L)!==L&&Kt(d,w|L)}}function Gc(d,g,w){if(w){var L,B={};for(L in w){var M=w[L],F=M.ra;F||(B.J=M.xa||M.oa.W,M.ia?(B.aa=Kc(M.ia),F=function(W){return function(Z,fe,me){return W.J(Z,fe,me,W.aa)}}(B)):M.ka?(B.Z=Ra(M.da.P,M.ka),F=function(W){return function(Z,fe,me){return W.J(Z,fe,me,W.Z)}}(B)):F=B.J,M.ra=F),F(g,d,M.da),B={J:B.J,aa:B.aa,Z:B.Z}}}(function(W,Z){if(Z=Z.R){Xr(W,W.h.end());for(var fe=0;fe<Z.length;fe++)Xr(W,Jo(Z[fe])||_n())}})(g,d)}Kt(xa,23),Yr=Object.freeze(xa),Rt.prototype.toJSON=function(){return rs(this.o,wd,Fc)},Rt.prototype.C=function(){return!!(2&It(this.o))},Rt.prototype.ja=es,Rt.prototype.toString=function(){return this.o.toString()};var tt=Symbol();function zc(d,g,w){return d[tt]||(d[tt]=function(L,B){return g(L,B,w)})}function ss(d){var g=d[tt];if(!g){var w=ls(d);g=function(L,B){return Yc(L,B,w)},d[tt]=g}return g}function Wc(d){var g=function(B){var M=B.ia;return M?ss(M):(M=B.wa)?zc(B.da.P,M,B.ka):void 0}(d),w=d.da,L=d.oa.U;return g?function(B,M){return L(B,M,w,g)}:function(B,M){return L(B,M,w)}}function qc(d,g){var w=d[g];return typeof w=="function"&&w.length===0&&(w=w(),d[g]=w),Array.isArray(w)&&(fr in w||Ni in w||0<w.length&&typeof w[0]=="function")?w:void 0}function Jc(d,g,w,L,B,M){g.P=d[0];var F=1;if(d.length>F&&typeof d[F]!="number"){var W=d[F++];w(g,W)}for(;F<d.length;){w=d[F++];for(var Z=F+1;Z<d.length&&typeof d[Z]!="number";)Z++;switch(W=d[F++],Z-=F){case 0:L(g,w,W);break;case 1:(Z=qc(d,F))?(F++,B(g,w,W,Z)):L(g,w,W,d[F++]);break;case 2:B(g,w,W,Z=qc(d,Z=F++),d[F++]);break;case 3:M(g,w,W,d[F++],d[F++],d[F++]);break;case 4:M(g,w,W,d[F++],d[F++],d[F++],d[F++]);break;default:throw Error("unexpected number of binary field arguments: "+Z)}}return g}var Ea=Symbol();function Kc(d){var g=d[Ea];if(!g){var w=us(d);g=function(L,B){return $c(L,B,w)},d[Ea]=g}return g}function Ra(d,g){var w=d[Ea];return w||(w=function(L,B){return Gc(L,B,g)},d[Ea]=w),w}var Ni=Symbol();function Cd(d,g){d.push(g)}function Aa(d,g,w){d.push(g,w.W)}function Xc(d,g,w,L){var B=Kc(L),M=us(L).P,F=w.W;d.push(g,function(W,Z,fe){return F(W,Z,fe,M,B)})}function cs(d,g,w,L,B,M){var F=Ra(L,M),W=w.W;d.push(g,function(Z,fe,me){return W(Z,fe,me,L,F)})}function us(d){var g=d[Ni];return g||(g=Jc(d,d[Ni]=[],Cd,Aa,Xc,cs),fr in d&&Ni in d&&(d.length=0),g)}var fr=Symbol();function Ed(d,g){d[0]=g}function Qc(d,g,w,L){var B=w.U;d[g]=L?function(M,F,W){return B(M,F,W,L)}:B}function Rd(d,g,w,L,B){var M=w.U,F=ss(L),W=ls(L).P;d[g]=function(Z,fe,me){return M(Z,fe,me,W,F,B)}}function Ad(d,g,w,L,B,M,F){var W=w.U,Z=zc(L,B,M);d[g]=function(fe,me,we){return W(fe,me,we,L,Z,F)}}function ls(d){var g=d[fr];return g||(g=Jc(d,d[fr]={},Ed,Qc,Rd,Ad),fr in d&&Ni in d&&(d.length=0),g)}function Yc(d,g,w){for(;Di(g)&&g.i!=4;){var L=g.l,B=w[L];if(!B){var M=w[0];M&&(M=M[L])&&(B=w[L]=Wc(M))}if(!B||!B(g,d,L)){L=d,M=(B=g).j,ka(B);var F=B;if(!F.ca){if(B=F.h.h-M,F.h.h=M,F=F.h,B==0)B=Sa();else{if(M=Xo(F,B),F.S&&F.m)B=F.i.subarray(M,M+B);else{F=F.i;var W=M;B=W===(B=M+B)?_n():xd?F.slice(W,B):new Uint8Array(F.subarray(W,B))}B=B.length==0?Sa():new Kr(B,Et)}(M=L.R)?M.push(B):L.R=[B]}}}return d}function $c(d,g,w){for(var L=w.length,B=L%2==1,M=B?1:0;M<L;M+=2)(0,w[M+1])(g,d,w[M]);Gc(d,g,B?w[0]:void 0)}function Ui(d,g){return{U:d,W:g}}var Sn=Ui(function(d,g,w){if(d.i!==5)return!1;var L=(d=d.h).i,B=d.h,M=L[B],F=L[B+1],W=L[B+2];return L=L[B+3],hr(d,d.h+4),d=2*((F=(M<<0|F<<8|W<<16|L<<24)>>>0)>>31)+1,M=F>>>23&255,F&=8388607,An(g,w,M==255?F?NaN:1/0*d:M==0?d*Math.pow(2,-149)*F:d*Math.pow(2,M-150)*(F+Math.pow(2,23))),!0},function(d,g,w){if((g=ns(g,w))!=null){Rr(d.h,8*w+5),d=d.h;var L=+g;L===0?0<1/L?Ot=ht=0:(ht=0,Ot=2147483648):isNaN(L)?(ht=0,Ot=2147483647):34028234663852886e22<(L=(w=0>L?-2147483648:0)?-L:L)?(ht=0,Ot=(2139095040|w)>>>0):11754943508222875e-54>L?(L=Math.round(L/Math.pow(2,-149)),ht=0,Ot=(w|L)>>>0):(g=Math.floor(Math.log(L)/Math.LN2),L*=Math.pow(2,-g),16777216<=(L=Math.round(8388608*L))&&++g,ht=0,Ot=(w|g+127<<23|8388607&L)>>>0),w=Ot,d.h.push(w>>>0&255),d.h.push(w>>>8&255),d.h.push(w>>>16&255),d.h.push(w>>>24&255)}}),Pd=Ui(function(d,g,w){if(d.i!==0)return!1;var L=d.h,B=0,M=d=0,F=L.i,W=L.h;do{var Z=F[W++];B|=(127&Z)<<M,M+=7}while(32>M&&128&Z);for(32<M&&(d|=(127&Z)>>4),M=3;32>M&&128&Z;M+=7)d|=(127&(Z=F[W++]))<<M;if(hr(L,W),!(128>Z))throw _a();return L=B>>>0,(d=2147483648&(Z=d>>>0))&&(Z=~Z>>>0,(L=1+~L>>>0)==0&&(Z=Z+1>>>0)),L=4294967296*Z+(L>>>0),An(g,w,d?-L:L),!0},function(d,g,w){(g=dn(g,w))!=null&&(typeof g=="string"&&Lc(g),g!=null&&(Rr(d.h,8*w),typeof g=="number"?(d=d.h,Pc(g),Uc(d,Ot,ht)):(w=Lc(g),Uc(d.h,w.i,w.h))))}),Zc=Ui(function(d,g,w){return d.i===0&&(An(g,w,Pi(d.h)),!0)},function(d,g,w){if((g=dn(g,w))!=null&&g!=null)if(Rr(d.h,8*w),d=d.h,0<=(w=g))Rr(d,w);else{for(g=0;9>g;g++)d.h.push(127&w|128),w>>=7;d.h.push(1)}}),At=Ui(function(d,g,w){if(d.i!==2)return!1;var L=Pi(d.h)>>>0,B=Xo(d=d.h,L);if(d=d.i,qn){var M,F=d;(M=qo)||(M=qo=new TextDecoder("utf-8",{fatal:!0})),d=B+L,F=B===0&&d===F.length?F:F.subarray(B,d);try{var W=M.decode(F)}catch(we){if(bn===void 0){try{M.decode(new Uint8Array([128]))}catch(Ae){}try{M.decode(new Uint8Array([97])),bn=!0}catch(Ae){bn=!1}}throw!bn&&(qo=void 0),we}}else{L=(W=B)+L,B=[];for(var Z,fe,me=null;W<L;)128>(Z=d[W++])?B.push(Z):224>Z?W>=L?at():(fe=d[W++],194>Z||(192&fe)!=128?(W--,at()):B.push((31&Z)<<6|63&fe)):240>Z?W>=L-1?at():(192&(fe=d[W++]))!=128||Z===224&&160>fe||Z===237&&160<=fe||(192&(F=d[W++]))!=128?(W--,at()):B.push((15&Z)<<12|(63&fe)<<6|63&F):244>=Z?W>=L-2?at():(192&(fe=d[W++]))!=128||fe-144+(Z<<28)>>30!=0||(192&(F=d[W++]))!=128||(192&(M=d[W++]))!=128?(W--,at()):(Z=(7&Z)<<18|(63&fe)<<12|(63&F)<<6|63&M,Z-=65536,B.push(55296+(Z>>10&1023),56320+(1023&Z))):at(),8192<=B.length&&(me=ya(me,B),B.length=0);W=ya(me,B)}return An(g,w,W),!0},function(d,g,w){if((g=dn(g,w))!=null){var L=!1;if(L=L!==void 0&&L,Nc){if(L&&/(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])/.test(g))throw Error("Found an unpaired surrogate");g=(Mc||(Mc=new TextEncoder)).encode(g)}else{for(var B=0,M=new Uint8Array(3*g.length),F=0;F<g.length;F++){var W=g.charCodeAt(F);if(128>W)M[B++]=W;else{if(2048>W)M[B++]=W>>6|192;else{if(55296<=W&&57343>=W){if(56319>=W&&F<g.length){var Z=g.charCodeAt(++F);if(56320<=Z&&57343>=Z){W=1024*(W-55296)+Z-56320+65536,M[B++]=W>>18|240,M[B++]=W>>12&63|128,M[B++]=W>>6&63|128,M[B++]=63&W|128;continue}F--}if(L)throw Error("Found an unpaired surrogate");W=65533}M[B++]=W>>12|224,M[B++]=W>>6&63|128}M[B++]=63&W|128}}g=B===M.length?M:M.subarray(0,B)}Rr(d.h,8*w+2),Rr(d.h,g.length),Xr(d,d.h.end()),Xr(d,g)}}),ds=Ui(function(d,g,w,L,B){if(d.i!==2)return!1;g=Bc(g,w,L),w=d.h.j,L=Pi(d.h)>>>0;var M=d.h.h+L,F=M-w;if(0>=F&&(d.h.j=M,B(g,d,void 0,void 0,void 0),F=M-d.h.h),F)throw Error("Message parsing ended unexpectedly. Expected to read "+L+" bytes, instead read "+(L-F)+" bytes, either the data ended unexpectedly or the message misreported its own length");return d.h.h=M,d.h.j=w,!0},function(d,g,w,L,B){if((g=kt(g,L,w))!=null)for(L=0;L<g.length;L++){var M=d;Rr(M.h,8*w+2);var F=M.h.end();Xr(M,F),F.push(M.i),M=F,B(g[L],d),F=d;var W=M.pop();for(W=F.i+F.h.length()-W;127<W;)M.push(127&W|128),W>>>=7,F.i++;M.push(W),F.i++}});function hs(d){return function(g,w){e:{if(Jn.length){var L=Jn.pop();L.setOptions(w),dr(L.h,g,w),g=L}else g=new $o(g,w);try{var B=ls(d),M=Yc(new B.P,g,B);break e}finally{(B=g.h).i=null,B.m=!1,B.l=0,B.j=0,B.h=0,B.S=!1,g.l=-1,g.i=-1,100>Jn.length&&Jn.push(g)}M=void 0}return M}}function fs(d){return function(){var g=new Id;$c(this,g,us(d)),Xr(g,g.h.end());for(var w=new Uint8Array(g.i),L=g.j,B=L.length,M=0,F=0;F<B;F++){var W=L[F];w.set(W,M),M+=W.length}return g.j=[w],w}}function Zr(d){Rt.call(this,d)}Wt(Zr,Rt);var Tt=[Zr,1,Zc,2,Sn,3,At,4,At];function ps(d){Rt.call(this,d,-1,Dd)}Zr.prototype.l=fs(Tt),Wt(ps,Rt),ps.prototype.addClassification=function(d,g){return Bc(this,1,Zr,d,g),this};var Dd=[1],Ld=hs([ps,1,ds,Tt]);function pr(d){Rt.call(this,d)}Wt(pr,Rt);var ms=[pr,1,Sn,2,Sn,3,Sn,4,Sn,5,Sn];function eu(d){Rt.call(this,d,-1,vs)}pr.prototype.l=fs(ms),Wt(eu,Rt);var vs=[1],Od=hs([eu,1,ds,ms]);function Pa(d){Rt.call(this,d)}Wt(Pa,Rt);var tu=[Pa,1,Sn,2,Sn,3,Sn,4,Sn,5,Sn,6,Pd],Md=hs(tu);function nu(d,g,w){if(w=d.createShader(w===0?d.VERTEX_SHADER:d.FRAGMENT_SHADER),d.shaderSource(w,g),d.compileShader(w),!d.getShaderParameter(w,d.COMPILE_STATUS))throw Error(`Could not compile WebGL shader.
568
532
 
569
- `+l.getShaderInfoLog(S));return S}function zd(l){return xt(l,ei,1).map(function(m){var S=pn(m,1);return{index:S==null?0:S,qa:On(m,2),label:pn(m,3)!=null?wa(pn(m,3),""):void 0,displayName:pn(m,4)!=null?wa(pn(m,4),""):void 0}})}function Mn(l){return{x:On(l,1),y:On(l,2),z:On(l,3),visibility:ts(l,4)!=null?On(l,4):void 0}}function Mi(l,m){this.i=l,this.h=m,this.m=0}function Pa(l,m,S){return function(x,D){var R=x.h;if(x.s===void 0){var M=au(R,`
533
+ `+d.getShaderInfoLog(w));return w}function Nd(d){return kt(d,Zr,1).map(function(g){var w=dn(g,1);return{index:w==null?0:w,qa:Dn(g,2),label:dn(g,3)!=null?Ca(dn(g,3),""):void 0,displayName:dn(g,4)!=null?Ca(dn(g,4),""):void 0}})}function Ln(d){return{x:Dn(d,1),y:Dn(d,2),z:Dn(d,3),visibility:ns(d,4)!=null?Dn(d,4):void 0}}function Vi(d,g){this.i=d,this.h=g,this.m=0}function Da(d,g,w){return function(L,B){var M=L.h;if(L.s===void 0){var F=nu(M,`
570
534
  attribute vec2 aVertex;
571
535
  attribute vec2 aTex;
572
536
  varying vec2 vTex;
573
537
  void main(void) {
574
538
  gl_Position = vec4(aVertex, 0.0, 1.0);
575
539
  vTex = aTex;
576
- }`,0),G=au(R,`
540
+ }`,0),W=nu(M,`
577
541
  precision mediump float;
578
542
  varying vec2 vTex;
579
543
  uniform sampler2D sampler0;
580
544
  void main(){
581
545
  gl_FragColor = texture2D(sampler0, vTex);
582
- }`,1),Q=R.createProgram();if(R.attachShader(Q,M),R.attachShader(Q,G),R.linkProgram(Q),!R.getProgramParameter(Q,R.LINK_STATUS))throw Error(`Could not compile WebGL program.
546
+ }`,1),Z=M.createProgram();if(M.attachShader(Z,F),M.attachShader(Z,W),M.linkProgram(Z),!M.getProgramParameter(Z,M.LINK_STATUS))throw Error(`Could not compile WebGL program.
583
547
 
584
- `+R.getProgramInfoLog(Q));M=x.s=Q,R.useProgram(M),G=R.getUniformLocation(M,"sampler0"),x.l={O:R.getAttribLocation(M,"aVertex"),N:R.getAttribLocation(M,"aTex"),ya:G},x.v=R.createBuffer(),R.bindBuffer(R.ARRAY_BUFFER,x.v),R.enableVertexAttribArray(x.l.O),R.vertexAttribPointer(x.l.O,2,R.FLOAT,!1,0,0),R.bufferData(R.ARRAY_BUFFER,new Float32Array([-1,-1,-1,1,1,1,1,-1]),R.STATIC_DRAW),R.bindBuffer(R.ARRAY_BUFFER,null),x.u=R.createBuffer(),R.bindBuffer(R.ARRAY_BUFFER,x.u),R.enableVertexAttribArray(x.l.N),R.vertexAttribPointer(x.l.N,2,R.FLOAT,!1,0,0),R.bufferData(R.ARRAY_BUFFER,new Float32Array([0,1,0,0,1,0,1,1]),R.STATIC_DRAW),R.bindBuffer(R.ARRAY_BUFFER,null),R.uniform1i(G,0)}M=x.l,R.useProgram(x.s),R.canvas.width=D.width,R.canvas.height=D.height,R.viewport(0,0,D.width,D.height),R.activeTexture(R.TEXTURE0),x.i.bindTexture2d(D.glName),R.enableVertexAttribArray(M.O),R.bindBuffer(R.ARRAY_BUFFER,x.v),R.vertexAttribPointer(M.O,2,R.FLOAT,!1,0,0),R.enableVertexAttribArray(M.N),R.bindBuffer(R.ARRAY_BUFFER,x.u),R.vertexAttribPointer(M.N,2,R.FLOAT,!1,0,0),R.bindFramebuffer(R.DRAW_FRAMEBUFFER?R.DRAW_FRAMEBUFFER:R.FRAMEBUFFER,null),R.clearColor(0,0,0,0),R.clear(R.COLOR_BUFFER_BIT),R.colorMask(!0,!0,!0,!0),R.drawArrays(R.TRIANGLE_FAN,0,4),R.disableVertexAttribArray(M.O),R.disableVertexAttribArray(M.N),R.bindBuffer(R.ARRAY_BUFFER,null),x.i.bindTexture2d(0)}(l,m),typeof l.h.canvas.transferToImageBitmap=="function"?Promise.resolve(l.h.canvas.transferToImageBitmap()):S?Promise.resolve(l.h.canvas):typeof createImageBitmap=="function"?createImageBitmap(l.h.canvas):(l.j===void 0&&(l.j=document.createElement("canvas")),new Promise(function(x){l.j.height=l.h.canvas.height,l.j.width=l.h.canvas.width,l.j.getContext("2d",{}).drawImage(l.h.canvas,0,0,l.h.canvas.width,l.h.canvas.height),x(l.j)}))}function Wd(l){this.h=l}Aa.prototype.l=hs(iu);var ou=new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,2,1,0,10,9,1,7,0,65,0,253,15,26,11]);function Jd(l,m){return m+l}function Da(l,m){window[l]=m}function Yn(l){if(this.h=l,this.listeners={},this.l={},this.L={},this.s={},this.v={},this.M=this.u=this.ga=!0,this.I=Promise.resolve(),this.fa="",this.D={},this.locateFile=l&&l.locateFile||Jd,(typeof window=="undefined"?"undefined":X(window))==="object")var m=window.location.pathname.toString().substring(0,window.location.pathname.toString().lastIndexOf("/"))+"/";else{if(typeof location=="undefined")throw Error("solutions can only be loaded on a web page or in a web worker");m=location.pathname.toString().substring(0,location.pathname.toString().lastIndexOf("/"))+"/"}if(this.ha=m,l.options)for(var S=(m=W(Object.keys(l.options))).next();!S.done;S=m.next()){S=S.value;var x=l.options[S].default;x!==void 0&&(this.l[S]=typeof x=="function"?x():x)}}function Kd(l){var m,S,x,D,R,M,G,Q,he,fe,we;return et(function(Re){switch(Re.h){case 1:return l.ga?(m=l.h.files===void 0?[]:typeof l.h.files=="function"?l.h.files(l.l):l.h.files,ht(Re,et(function(me){switch(me.h){case 1:return me.s=2,ht(me,WebAssembly.instantiate(ou),4);case 4:me.h=3,me.s=0;break;case 2:return me.s=0,me.l=null,me.return(!1);case 3:return me.return(!0)}}),2)):Re.return();case 2:if(S=Re.i,(typeof window=="undefined"?"undefined":X(window))==="object")return Da("createMediapipeSolutionsWasm",{locateFile:l.locateFile}),Da("createMediapipeSolutionsPackedAssets",{locateFile:l.locateFile}),M=m.filter(function(me){return me.data!==void 0}),G=m.filter(function(me){return me.data===void 0}),Q=Promise.all(M.map(function(me){var Le=ti(l,me.url);if(me.path!==void 0){var je=me.path;Le=Le.then(function(st){return l.overrideFile(je,st),Promise.resolve(st)})}return Le})),he=Promise.all(G.map(function(me){return me.simd===void 0||me.simd&&S||!me.simd&&!S?function(Le){var je=document.createElement("script");return je.setAttribute("src",Le),je.setAttribute("crossorigin","anonymous"),new Promise(function(st){je.addEventListener("load",function(){st()},!1),je.addEventListener("error",function(){st()},!1),document.body.appendChild(je)})}(l.locateFile(me.url,l.ha)):Promise.resolve()})).then(function(){var me,Le,je;return et(function(st){if(st.h==1)return me=window.createMediapipeSolutionsWasm,Le=window.createMediapipeSolutionsPackedAssets,je=l,ht(st,me(Le),2);je.i=st.i,st.h=0})}),fe=et(function(me){return l.h.graph&&l.h.graph.url?me=ht(me,ti(l,l.h.graph.url),0):(me.h=0,me=void 0),me}),ht(Re,Promise.all([he,Q,fe]),7);if(typeof importScripts!="function")throw Error("solutions can only be loaded on a web page or in a web worker");return x=m.filter(function(me){return me.simd===void 0||me.simd&&S||!me.simd&&!S}).map(function(me){return l.locateFile(me.url,l.ha)}),importScripts.apply(null,ae(x)),D=l,ht(Re,createMediapipeSolutionsWasm(Module),6);case 6:D.i=Re.i,l.m=new OffscreenCanvas(1,1),l.i.canvas=l.m,R=l.i.GL.createContext(l.m,{antialias:!1,alpha:!1,va:typeof WebGL2RenderingContext!="undefined"?2:1}),l.i.GL.makeContextCurrent(R),Re.h=4;break;case 7:if(l.m=document.createElement("canvas"),!(we=l.m.getContext("webgl2",{}))&&!(we=l.m.getContext("webgl",{})))return alert("Failed to create WebGL canvas context when passing video frame."),Re.return();l.K=we,l.i.canvas=l.m,l.i.createContext(l.m,!0,!0,{});case 4:l.j=new l.i.SolutionWasm,l.ga=!1,Re.h=0}})}function ti(l,m){var S,x;return et(function(D){return m in l.L?D.return(l.L[m]):(S=l.locateFile(m,""),x=fetch(S).then(function(R){return R.arrayBuffer()}),l.L[m]=x,D.return(x))})}function qd(l,m,S){var x,D,R,M,G,Q,he,fe,we,Re,me,Le,je,st;return et(function(dt){switch(dt.h){case 1:if(!S)return dt.return(m);for(x={},D=0,R=W(Object.keys(S)),M=R.next();!M.done;M=R.next())G=M.value,typeof(Q=S[G])!="string"&&Q.type==="texture"&&m[Q.stream]!==void 0&&++D;1<D&&(l.M=!1),he=W(Object.keys(S)),M=he.next();case 2:if(M.done){dt.h=4;break}if(fe=M.value,typeof(we=S[fe])=="string")return je=x,st=fe,ht(dt,function(Nn,Ma,ri){var Na;return et(function(vs){return typeof ri=="number"||ri instanceof Uint8Array||ri instanceof Nn.i.Uint8BlobList?vs.return(ri):ri instanceof Nn.i.Texture2dDataOut?((Na=Nn.v[Ma])||(Na=new Mi(Nn.i,Nn.K),Nn.v[Ma]=Na),vs.return(Pa(Na,ri,Nn.M))):vs.return(void 0)})}(l,fe,m[we]),14);if(Re=m[we.stream],we.type==="detection_list"){if(Re){for(var jt=Re.getRectList(),fn=Re.getLandmarksList(),St=Re.getClassificationsList(),qe=[],Xe=0;Xe<jt.size();++Xe){var mr=Hd(jt.get(Xe)),Oa=void 0;Oa=Oa===void 0?0:Oa,mr={la:{sa:On(mr,1),ta:On(mr,2),height:On(mr,3),width:On(mr,4),rotation:On(mr,5,0),pa:wa(pn(mr,6),Oa)},ea:xt(Gd(fn.get(Xe)),fr,1).map(Mn),ba:zd(Fd(St.get(Xe)))},qe.push(mr)}jt=qe}else jt=[];x[fe]=jt,dt.h=7;break}if(we.type==="proto_list"){if(Re){for(jt=Array(Re.size()),fn=0;fn<Re.size();fn++)jt[fn]=Re.get(fn);Re.delete()}else jt=[];x[fe]=jt,dt.h=7;break}if(Re===void 0){dt.h=3;break}if(we.type==="float_list"){x[fe]=Re,dt.h=7;break}if(we.type==="proto"){x[fe]=Re,dt.h=7;break}if(we.type!=="texture")throw Error("Unknown output config type: '"+we.type+"'");return(me=l.v[fe])||(me=new Mi(l.i,l.K),l.v[fe]=me),ht(dt,Pa(me,Re,l.M),13);case 13:Le=dt.i,x[fe]=Le;case 7:we.transform&&x[fe]&&(x[fe]=we.transform(x[fe])),dt.h=3;break;case 14:je[st]=dt.i;case 3:M=he.next(),dt.h=2;break;case 4:return dt.return(x)}})}function La(l,m){for(var S=m.name||"$",x=[].concat(ae(m.wants)),D=new l.i.StringList,R=W(m.wants),M=R.next();!M.done;M=R.next())D.push_back(M.value);R=l.i.PacketListener.implement({onResults:function(G){for(var Q={},he=0;he<m.wants.length;++he)Q[x[he]]=G.get(he);var fe=l.listeners[S];fe&&(l.I=qd(l,Q,m.outs).then(function(we){we=fe(we);for(var Re=0;Re<m.wants.length;++Re){var me=Q[x[Re]];X(me)==="object"&&me.hasOwnProperty&&me.hasOwnProperty("delete")&&me.delete()}we&&(l.I=we)}))}}),l.j.attachMultiListener(D,R),D.delete()}function ni(l){return l===void 0&&(l=0),l===1?"selfie_segmentation_landscape.tflite":"selfie_segmentation.tflite"}function Ni(l){var m=this;l=l||{},this.h=new Yn({locateFile:l.locateFile,files:function(S){return[{simd:!0,url:"selfie_segmentation_solution_simd_wasm_bin.js"},{simd:!1,url:"selfie_segmentation_solution_wasm_bin.js"},{data:!0,url:ni(S.modelSelection)}]},graph:{url:"selfie_segmentation.binarypb"},listeners:[{wants:["segmentation_mask","image_transformed"],outs:{image:{type:"texture",stream:"image_transformed"},segmentationMask:{type:"texture",stream:"segmentation_mask"}}}],inputs:{image:{type:"video",stream:"input_frames_gpu"}},options:{useCpuInference:{type:0,graphOptionXref:{calculatorType:"InferenceCalculator",fieldName:"use_cpu_inference"},default:(typeof window=="undefined"?"undefined":X(window))==="object"&&window.navigator!==void 0&&("iPad Simulator;iPhone Simulator;iPod Simulator;iPad;iPhone;iPod".split(";").includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document)},selfieMode:{type:0,graphOptionXref:{calculatorType:"GlScalerCalculator",calculatorIndex:1,fieldName:"flip_horizontal"}},modelSelection:{type:1,graphOptionXref:{calculatorType:"ConstantSidePacketCalculator",calculatorName:"ConstantSidePacketCalculatorModelSelection",fieldName:"int_value"},onChange:function(S){var x,D,R;return et(function(M){return M.h==1?(x=ni(S),D="third_party/mediapipe/modules/selfie_segmentation/"+x,ht(M,ti(m.h,x),2)):(R=M.i,m.h.overrideFile(D,R),M.return(!0))})}}}})}(se=Yn.prototype).close=function(){return this.j&&this.j.delete(),Promise.resolve()},se.reset=function(){var l=this;return et(function(m){l.j&&(l.j.reset(),l.s={},l.v={}),m.h=0})},se.setOptions=function(l,m){var S=this;if(m=m||this.h.options){for(var x=[],D=[],R={},M=W(Object.keys(l)),G=M.next();!G.done;R={X:R.X,Y:R.Y},G=M.next())if(!((G=G.value)in this.l)||this.l[G]!==l[G]){this.l[G]=l[G];var Q=m[G];Q!==void 0&&(Q.onChange&&(R.X=Q.onChange,R.Y=l[G],x.push(function(he){return function(){return et(function(fe){if(fe.h==1)return ht(fe,he.X(he.Y),2);fe.i===!0&&(S.u=!0),fe.h=0})}}(R))),Q.graphOptionXref&&(G=Object.assign({},{calculatorName:"",calculatorIndex:0},Q.graphOptionXref,{valueNumber:Q.type===1?l[G]:0,valueBoolean:Q.type===0&&l[G],valueString:Q.type===2?l[G]:""}),D.push(G)))}x.length===0&&D.length===0||(this.u=!0,this.H=(this.H===void 0?[]:this.H).concat(D),this.F=(this.F===void 0?[]:this.F).concat(x))}},se.initialize=function(){var l=this;return et(function(m){return m.h==1?ht(m,Kd(l),2):m.h!=3?ht(m,function(S){var x,D,R,M,G,Q,he,fe;return et(function(we){if(we.h==1)return S.h.graph&&S.h.graph.url&&S.fa===S.h.graph.url?we.return():(S.u=!0,S.h.graph&&S.h.graph.url?(S.fa=S.h.graph.url,ht(we,ti(S,S.h.graph.url),3)):void(we.h=2));for(we.h!=2&&(x=we.i,S.j.loadGraph(x)),D=W(Object.keys(S.D)),R=D.next();!R.done;R=D.next())M=R.value,S.j.overrideFile(M,S.D[M]);if(S.D={},S.h.listeners)for(G=W(S.h.listeners),Q=G.next();!Q.done;Q=G.next())he=Q.value,La(S,he);fe=S.l,S.l={},S.setOptions(fe),we.h=0})}(l),3):ht(m,function(S){var x,D,R,M,G,Q;return et(function(he){switch(he.h){case 1:if(!S.u)return he.return();if(!S.F){he.h=2;break}x=W(S.F),D=x.next();case 3:if(D.done){he.h=5;break}return ht(he,(0,D.value)(),4);case 4:D=x.next(),he.h=3;break;case 5:S.F=void 0;case 2:if(S.H){for(R=new S.i.GraphOptionChangeRequestList,M=W(S.H),G=M.next();!G.done;G=M.next())Q=G.value,R.push_back(Q);S.j.changeOptions(R),R.delete(),S.H=void 0}S.u=!1,he.h=0}})}(l),0)})},se.overrideFile=function(l,m){this.j?this.j.overrideFile(l,m):this.D[l]=m},se.clearOverriddenFiles=function(){this.D={},this.j&&this.j.clearOverriddenFiles()},se.send=function(l,m){var S,x,D,R,M,G,Q,he,fe,we=this;return et(function(Re){switch(Re.h){case 1:return we.h.inputs?(S=1e3*(m==null?performance.now():m),ht(Re,we.I,2)):Re.return();case 2:return ht(Re,we.initialize(),3);case 3:for(x=new we.i.PacketDataList,D=W(Object.keys(l)),R=D.next();!R.done;R=D.next())if(M=R.value,G=we.h.inputs[M]){e:{var me=l[M];switch(G.type){case"video":var Le=we.s[G.stream];if(Le||(Le=new Mi(we.i,we.K),we.s[G.stream]=Le),Le.m===0&&(Le.m=Le.i.createTexture()),typeof HTMLVideoElement!="undefined"&&me instanceof HTMLVideoElement)var je=me.videoWidth,st=me.videoHeight;else typeof HTMLImageElement!="undefined"&&me instanceof HTMLImageElement?(je=me.naturalWidth,st=me.naturalHeight):(je=me.width,st=me.height);st={glName:Le.m,width:je,height:st},(je=Le.h).canvas.width=st.width,je.canvas.height=st.height,je.activeTexture(je.TEXTURE0),Le.i.bindTexture2d(Le.m),je.texImage2D(je.TEXTURE_2D,0,je.RGBA,je.RGBA,je.UNSIGNED_BYTE,me),Le.i.bindTexture2d(0),Le=st;break e;case"detections":for((Le=we.s[G.stream])||(Le=new Wd(we.i),we.s[G.stream]=Le),Le.data||(Le.data=new Le.h.DetectionListData),Le.data.reset(me.length),st=0;st<me.length;++st){je=me[st];var dt=Le.data,jt=dt.setBoundingBox,fn=st,St=je.la,qe=new Aa;if(Ln(qe,1,St.sa),Ln(qe,2,St.ta),Ln(qe,3,St.height),Ln(qe,4,St.width),Ln(qe,5,St.rotation),Dn(qe,6,St.pa),St=qe.l(),jt.call(dt,fn,St),je.ea)for(dt=0;dt<je.ea.length;++dt){qe=je.ea[dt],fn=(jt=Le.data).addNormalizedLandmark,St=st,qe=Object.assign({},qe,{visibility:qe.visibility?qe.visibility:0});var Xe=new fr;Ln(Xe,1,qe.x),Ln(Xe,2,qe.y),Ln(Xe,3,qe.z),qe.visibility&&Ln(Xe,4,qe.visibility),qe=Xe.l(),fn.call(jt,St,qe)}if(je.ba)for(dt=0;dt<je.ba.length;++dt)fn=(jt=Le.data).addClassification,St=st,qe=je.ba[dt],Ln(Xe=new ei,2,qe.qa),qe.index&&Dn(Xe,1,qe.index),qe.label&&Dn(Xe,3,qe.label),qe.displayName&&Dn(Xe,4,qe.displayName),qe=Xe.l(),fn.call(jt,St,qe)}Le=Le.data;break e;default:Le={}}}switch(Q=Le,he=G.stream,G.type){case"video":x.pushTexture2d(Object.assign({},Q,{stream:he,timestamp:S}));break;case"detections":(fe=Q).stream=he,fe.timestamp=S,x.pushDetectionList(fe);break;default:throw Error("Unknown input config type: '"+G.type+"'")}}return we.j.send(x),ht(Re,we.I,4);case 4:x.delete(),Re.h=0}})},se.onResults=function(l,m){this.listeners[m||"$"]=l},de("Solution",Yn),de("OptionType",{BOOL:0,NUMBER:1,ua:2,0:"BOOL",1:"NUMBER",2:"STRING"}),(se=Ni.prototype).close=function(){return this.h.close(),Promise.resolve()},se.onResults=function(l){this.h.onResults(l)},se.initialize=function(){var l=this;return et(function(m){return ht(m,l.h.initialize(),0)})},se.reset=function(){this.h.reset()},se.send=function(l){var m=this;return et(function(S){return ht(S,m.h.send(l),0)})},se.setOptions=function(l){this.h.setOptions(l)},de("SelfieSegmentation",Ni),de("VERSION","0.1.1675465747")}).call(zo);var Ar=function(se){return typeof se=="number"},Lc=function(){function se(){Pe(this,se),this.userId="",this.videoBeauty=document.createElement("video"),this.videoBeauty.loop=!0,this.videoBeauty.autoplay=!0,this.videoVirtual=document.createElement("video"),this.videoVirtual.loop=!0,this.videoVirtual.autoplay=!0,this.onoverload=null,this.canvasBeauty=document.createElement("canvas"),this.filter=new Go({canvas:this.canvasBeauty,video:this.videoBeauty}),this.canvasVirtual=document.createElement("canvas"),this.virtual=new Ho({canvas:this.canvasVirtual,video:this.videoVirtual,onoverload:this.onoverload}),this.beautyParams={beauty:.5,brightness:.5,ruddy:.5},this.timeoutId=null,this.rafId=null,this.startTime=null,this.originTrack=null,this.beautyTrack=null,this.resultTrack=null,this.localStream=null,this.frameRate=null,this.disableStatus=!1,this.isVirualEnable=!1}var Te,be,Be,ze,ie;return ut(se,[{key:"generateBeautyStream",value:function(W){this.userId=W==null?void 0:W.getUserId();var ae=W.getVideoTrack();if(!ae)throw new Error("Your localStream does not contain video track.");var B=this.generateBeautyTrack(ae);return W.replaceTrack(B),this.localStream=W,W.setBeautyStatus&&W.setBeautyStatus(!0),console.log("RTCBeautyPlugin: generateBeautyStream ".concat(this.userId?"userId: ".concat(this.userId):"")),W}},{key:"generateBeautyTrack",value:function(W){var ae=this;this.reset();var B=W.getSettings();this.frameRate=B.frameRate,this.filter.setRect(B.width,B.height),this.setRect(B.width,B.height);var te=new MediaStream;te.addTrack(W),this.videoBeauty.srcObject=te,this.videoBeauty.play();var Se=this.canvasBeauty.captureStream(this.frameRate||15).getVideoTracks()[0];return this.rafId&&cancelAnimationFrame(this.rafId),this.rafId=requestAnimationFrame(function(){ae.startTime=new Date().getTime(),ae.render()}),this.installEvents(),this.originTrack=W,this.beautyTrack=Se,this.setTrackParam({type:"beauty",originTrack:W,resultTrack:Se,param:this.beautyParams}),Se}},{key:"setBackground",value:(ie=J(V().mark(function W(ae){return V().wrap(function(B){for(;;)switch(B.prev=B.next){case 0:return B.next=2,this.virtual.setBackground(ae);case 2:console.log("RTCBeautyPlugin: setBackground img:".concat(ae));case 3:case"end":return B.stop()}},W,this)})),function(W){return ie.apply(this,arguments)})},{key:"generateStream",value:(ze=J(V().mark(function W(ae){var B,te,Se,oe,_e;return V().wrap(function(Oe){for(;;)switch(Oe.prev=Oe.next){case 0:if(B=ae.localStream,te=ae.type,Se=ae.img,oe=B.getVideoTrack()){Oe.next=4;break}throw new Error("Your localStream does not contain video track.");case 4:return this.localStream=B,Oe.next=7,this.generateMixedTrack({videoTrack:oe,type:te,img:Se});case 7:return _e=Oe.sent,B.replaceTrack(_e),B.setBeautyStatus&&B.setBeautyStatus(!0),Oe.abrupt("return",B);case 11:case"end":return Oe.stop()}},W,this)})),function(W){return ze.apply(this,arguments)})},{key:"generateMixedTrack",value:(Be=J(V().mark(function W(ae){var B,te,Se,oe,_e;return V().wrap(function(Oe){for(;;)switch(Oe.prev=Oe.next){case 0:if(B=ae.videoTrack,te=ae.type,Se=ae.img,this.virtual.selfieSegmentation){Oe.next=3;break}throw new Error("you should call loadResources() first");case 3:return this.virtual.initVirtualParams({type:te,img:Se}),Oe.next=6,this.generateBeautyTrack(B);case 6:return oe=Oe.sent,Oe.next=9,this.generateVirtualTrack({videoTrack:oe,type:te,img:Se});case 9:return _e=Oe.sent,this.beautyTrack=oe,this.resultTrack=_e,this.setTrackParam({type:"mixed",originTrack:this.originTrack,resultTrack:this.resultTrack,param:{type:te,img:Se}}),Oe.abrupt("return",this.resultTrack);case 14:case"end":return Oe.stop()}},W,this)})),function(W){return Be.apply(this,arguments)})},{key:"generateVirtualStream",value:(be=J(V().mark(function W(ae){var B,te,Se,oe,_e;return V().wrap(function(Oe){for(;;)switch(Oe.prev=Oe.next){case 0:if(B=ae.localStream,te=ae.type,Se=ae.img,oe=B.getVideoTrack()){Oe.next=4;break}throw new Error("Your localStream does not contain video track.");case 4:return this.localStream=B,Oe.next=7,this.generateVirtualTrack({videoTrack:oe,type:te,img:Se});case 7:return _e=Oe.sent,Oe.next=10,B.replaceTrack(_e);case 10:return B.setBeautyStatus&&B.setBeautyStatus(!0),console.log("".concat(this.userId?"[userId: ".concat(this.userId,"]"):""," RTCBeautyPlugin generate ").concat(te," Stream.")),Oe.abrupt("return",B);case 13:case"end":return Oe.stop()}},W,this)})),function(W){return be.apply(this,arguments)})},{key:"generateVirtualTrack",value:(Te=J(V().mark(function W(ae){var B,te,Se,oe;return V().wrap(function(_e){for(;;)switch(_e.prev=_e.next){case 0:if(B=ae.videoTrack,te=ae.type,Se=ae.img,this.virtual.selfieSegmentation){_e.next=3;break}throw new Error("you should call loadResources() first");case 3:return oe=B.getSettings(),this.frameRate=oe.frameRate,this.virtual.setRect(oe.width,oe.height),_e.next=8,this.virtual.initVirtualParams({type:te,img:Se});case 8:return this.setRect(oe.width,oe.height),this.mediaStream=new MediaStream,this.mediaStream.addTrack(B),this.videoVirtual.srcObject=this.mediaStream,_e.next=14,this.videoVirtual.play();case 14:return this.virtual.startVirtual(this.frameRate),_e.next=17,this.virtual.render();case 17:return this.originTrack=B,this.resultTrack=this.canvasVirtual.captureStream(this.frameRate||15).getVideoTracks()[0],this.setTrackParam({type:"virtual",originTrack:this.originTrack,resultTrack:this.resultTrack,param:{type:te,img:Se}}),this.isVirualEnable=!0,_e.abrupt("return",this.resultTrack);case 22:case"end":return _e.stop()}},W,this)})),function(W){return Te.apply(this,arguments)})},{key:"replaceVirtualTrack",value:function(W){this.isVirualEnable&&(this.mediaStream.removeTrack(this.mediaStream.getVideoTracks()[0]),this.mediaStream.addTrack(W),this.originTrack=W)}},{key:"deleteSource",value:function(W){if(p.default){var ae=p.default.beautyTrackMap.get(W);ae&&(ae.type==="mixed"&&this.deleteSource(ae.originTrack.id),ae.originTrack&&(ae.originTrack.stop(),ae.originTrack=null),ae.beautyTrack&&(ae.beautyTrack.stop(),ae.beautyTrack=null),ae.resultTrack&&(ae.resultTrack.stop(),ae.resultTrack=null),p.default.beautyTrackMap.delete(W))}}},{key:"draw",value:function(){this.videoBeauty&&this.videoBeauty.readyState===this.videoBeauty.HAVE_ENOUGH_DATA&&this.filter.apply(this.videoBeauty)}},{key:"enableVirtualBg",value:function(){var W;if(this.virtual&&!this.isVirualEnable)return this.virtual.setEnable(!0),this.virtual.render(),this.isVirualEnable=!0,(W=this.localStream)===null||W===void 0||W.replaceTrack(this.resultTrack),console.log("".concat(this.userId?"[userId: ".concat(this.userId,"]"):""," RTCBeautyPlugin enable.")),this.resultTrack}},{key:"disableVirtualBg",value:function(){var W;if(this.virtual&&this.isVirualEnable)return this.virtual.setEnable(!1),this.isVirualEnable=!1,(W=this.localStream)===null||W===void 0||W.replaceTrack(this.originTrack),console.log("".concat(this.userId?"[userId: ".concat(this.userId,"]"):""," RTCBeautyPlugin disable.")),this.originTrack}},{key:"changeType",value:function(W){var ae=W.type,B=W.img;console.log("".concat(this.userId?"[userId: ".concat(this.userId,"]"):""," RTCBeautyPlugin changeType\uFF1A").concat(ae,". img: ").concat(B,".")),ae==="blur"&&(this.virtual.reset(),this.virtual.initVirtualParams({type:"blur"}),this.virtual.startVirtual(this.frameRate),this.virtual.render()),ae==="virtual"&&(this.virtual.reset(),this.virtual.initVirtualParams({type:"virtual",img:B}),this.virtual.startVirtual(this.frameRate),this.virtual.render()),this.setTrackParam({type:ae,originTrack:this.originTrack,resultTrack:this.resultTrack,param:{type:ae,img:B}})}},{key:"render",value:function(){var W=this,ae=new Date().getTime();ae-this.startTime>1e3/this.frameRate&&(this.draw(),this.startTime=ae),document.hidden?(clearTimeout(this.timeoutId),this.timeoutId=setTimeout(function(){W.render()},1e3/this.frameRate)):(this.timeoutId&&clearTimeout(this.timeoutId),this.rafId&&cancelAnimationFrame(this.rafId),this.rafId=requestAnimationFrame(this.render.bind(this)))}},{key:"setBeautyParam",value:function(W){var ae=W.beauty,B=W.brightness,te=W.ruddy;Ar(ae)&&(this.beautyParams.beauty=ae),Ar(B)&&(this.beautyParams.brightness=B),Ar(te)&&(this.beautyParams.ruddy=te),this.filter.setBeautyParams(this.beautyParams),this.getClose()&&!this.disableStatus&&this.disable(),!this.getClose()&&this.disableStatus&&this.enable()}},{key:"setRect",value:function(W,ae){var B=W||640,te=ae||480;this.videoBeauty.height=te,this.videoBeauty.width=B,this.canvasBeauty.height=te,this.canvasBeauty.width=B,this.videoVirtual.height=te,this.videoVirtual.width=B,this.canvasVirtual.height=te,this.canvasVirtual.width=B}},{key:"reset",value:function(){cancelAnimationFrame(this.rafId),clearTimeout(this.timeoutId),this.videoBeauty.pause(),this.filter.reset(),this.beautyTrack&&this.beautyTrack.stop(),this.videoVirtual.pause(),this.resultTrack&&this.resultTrack.stop(),this.originTrack&&this.originTrack.stop()}},{key:"destroy",value:function(){cancelAnimationFrame(this.rafId),clearTimeout(this.timeoutId),this.canvasBeauty&&(this.canvasBeauty.width=0,this.canvasBeauty.height=0,this.canvasBeauty.remove(),this.canvasBeauty=null),this.videoBeauty&&(this.videoBeauty.pause(),this.videoBeauty.removeAttribute("srcObject"),this.videoBeauty.removeAttribute("src"),this.videoBeauty.load(),this.videoBeauty.width=0,this.videoBeauty.height=0,this.videoBeauty.remove(),this.videoBeauty=null),this.beautyTrack&&(this.deleteSource(this.beautyTrack.id),this.beautyTrack.stop(),this.beautyTrack=null),this.originTrack&&(this.originTrack.stop(),this.originTrack=null),this.resultTrack&&(this.deleteSource(this.resultTrack.id),this.resultTrack.stop(),this.resultTrack=null),this.canvasVirtual&&(this.canvasVirtual.width=0,this.canvasVirtual.height=0,this.canvasVirtual.remove(),this.canvasVirtual=null),this.videoVirtual&&(this.videoVirtual.pause(),this.videoVirtual.removeAttribute("srcObject"),this.videoVirtual.removeAttribute("src"),this.videoVirtual.load(),this.videoVirtual.width=0,this.videoVirtual.height=0,this.videoVirtual.remove(),this.videoVirtual=null),this.virtual.destroy(),this.uninstallEvents()}},{key:"generateVideoTrackFromCanvasCapture",value:function(W){return this.canvasVirtual.captureStream(W).getVideoTracks()[0]}},{key:"setTrackParam",value:function(W){var ae=W.type,B=W.originTrack,te=W.resultTrack,Se=W.param;p.default&&(p.default.beautyTrackMap||(p.default.beautyTrackMap=new Map),p.default.beautyTrackMap.set(te.id,{type:ae,originTrack:B,resultTrack:te,param:Se,pluginInstance:this}))}},{key:"disable",value:function(){this.localStream&&this.originTrack&&(this.localStream.replaceTrack(this.originTrack),cancelAnimationFrame(this.rafId),clearTimeout(this.timeoutId),this.disableStatus=!0)}},{key:"enable",value:function(){this.localStream&&this.beautyTrack&&(this.localStream.replaceTrack(this.beautyTrack),this.render(),this.disableStatus=!1)}},{key:"installEvents",value:function(){document.addEventListener("visibilitychange",this.render.bind(this))}},{key:"uninstallEvents",value:function(){document.removeEventListener("visibilitychange",this.render.bind(this))}},{key:"overload",value:function(){this.onoverload&&this.onoverload()}},{key:"getClose",value:function(){return this.beautyParams.beauty===0&&this.beautyParams.brightness===0&&this.beautyParams.ruddy===0}}]),se}();return p.default&&(p.default.getRTCBeautyPlugin=function(){return new Lc}),Lc})});var Kw="0.0.12";var Td=sr(Rr());var kd=sr(Rr());var iE=sr(mg());var Mo=class extends iE.default{constructor({mediaType:p}){super();Ue(this,"trackMediaType");Ue(this,"_stream");Ue(this,"_playerState");this.trackMediaType=p}get isPlaying(){return this._playerState==="PLAYING"}async stop(){this._playerState="STOPPED",await this._stream.stop()}};var h9=1,No=class extends Mo{constructor(p){super(p);Ue(this,"TRTC",kd.default);Ue(this,"muted");Ue(this,"_publishedStream",null);Ue(this,"_log");this._log=Gt.createLogger({id:p.id+h9++})}get closed(){let p=this.getMediaStreamTrack();return p?p.readyState==="ended":!0}async init(){this._stream.on("device-auto-recovered",async({isMicrophone:p,isCamera:V,microphoneId:X,cameraId:N})=>{if(this._publishedStream&&this._stream!==this._publishedStream){let J=this.getMediaStreamTrack(),Pe=this.trackMediaType==="audio"?this._publishedStream.getAudioTrack():this._publishedStream.getVideoTrack();J&&Pe&&J!==Pe&&this._publishedStream.replaceTrack(J)}if(p){let J=(await kd.default.getMicrophones()).find(Pe=>Pe.deviceId===X);J&&this.emit("device-switched",J)}if(V){let J=(await kd.default.getCameras()).find(Pe=>Pe.deviceId===N);J&&this.emit("device-switched",J)}}),this._stream.on("player-state-changed",({state:p})=>{this._playerState=p}),this._stream.on("error",p=>{p.getCode()===16452&&this.emit("track-ended",this.trackMediaType)}),await this._stream.initialize()}setPublishedStream(p){this._publishedStream=p}on(p,V){return super.on(p,V),this}async setMuted(p){let V=this._publishedStream||this._stream;this.trackMediaType==="audio"?p?V.muteAudio():V.unmuteAudio():p?V.muteVideo():V.unmuteVideo()}getMediaStreamTrack(){return this.trackMediaType==="audio"?this._stream.getAudioTrack():this._stream.getVideoTrack()}close(){this._stream.close()}getTrackLabel(){var p;return((p=this.getMediaStreamTrack())==null?void 0:p.label)||""}getDeviceId(){var p,V;return((V=(p=this.getMediaStreamTrack())==null?void 0:p.getSettings())==null?void 0:V.deviceId)||""}};var oE=sr(aE()),sE=sr(Rr());var Vo=class extends No{constructor(p){super(p);Ue(this,"mirrored",!1);Ue(this,"lastPlayContainer");Ue(this,"_beautyPlugin");Ue(this,"_virtualTrack");Ue(this,"_isVirtualEnable",!1);Ue(this,"_imageUrl",null);this.onOriginTrackEnded=this.onOriginTrackEnded.bind(this)}get _originTrack(){var p;return((p=this._beautyPlugin)==null?void 0:p.originTrack)||null}get videoElement(){var p;return((p=this.lastPlayContainer)==null?void 0:p.querySelector(`#video_${this._stream.getId()}`))||null}mirrorVideo(p){this.lastPlayContainer&&this._stream.play(this.lastPlayContainer,{mirror:p}),this.mirrored=p}async applyVirtualBackground(p){var V;if(this._log.info(`applyVirtualBackground ${p} ${this._imageUrl}`),!p)return this.stopVirtualBackground(),!0;if(p===this._imageUrl)return!0;if(this._beautyPlugin||(this._beautyPlugin=new oE.default,await this._beautyPlugin.virtual.loadResources(),this._beautyPlugin.virtual.onoverload=()=>{this._log.info("virtualBackground is onoverload"),this.emit("VirtualBackgroundOverload")}),this._imageUrl)p==="blur"&&this._imageUrl!=="blur"&&this._beautyPlugin.changeType({type:"blur"}),p!=="blur"&&this._imageUrl==="blur"&&this._beautyPlugin.changeType({type:"virtual",img:p}),p!=="blur"&&this._imageUrl!=="blur"&&this._imageUrl!==p&&await this._beautyPlugin.setBackground(p);else{let X=await this._beautyPlugin.generateVirtualStream({localStream:this._stream,type:p==="blur"?"blur":"virtual",img:p==="blur"?void 0:p});this._virtualTrack=X.getVideoTrack(),this._publishedStream&&this._publishedStream.replaceTrack(this._virtualTrack),this._isVirtualEnable=!0}return(V=this._originTrack)==null||V.addEventListener("ended",this.onOriginTrackEnded),this._imageUrl=p,!this._isVirtualEnable&&this._beautyPlugin&&(this._isVirtualEnable=!0,this._beautyPlugin.enableVirtualBg()),!0}async onOriginTrackEnded(){let p=(await sE.default.getCameras())[0];p?this.setDevice(p.deviceId):this.emit("track-ended",this.trackMediaType)}async stopVirtualBackground(){var p;return this._log.info("stopVirtualBackground is called"),this._beautyPlugin&&this._isVirtualEnable&&(this._log.info("RTCBeautyPlugin: call disableVirtualBackground"),this._beautyPlugin.disableVirtualBg(),this._isVirtualEnable=!1,(p=this._originTrack)==null||p.removeEventListener("ended",this.onOriginTrackEnded)),!0}getDeviceId(){var p,V;return this._isVirtualEnable||this._beautyPlugin?((V=(p=this._beautyPlugin.originTrack)==null?void 0:p.getSettings())==null?void 0:V.deviceId)||"":super.getDeviceId()}getMediaStreamTrack(){return this._originTrack&&(this._isVirtualEnable||this._beautyPlugin)?this._originTrack:super.getMediaStreamTrack()}close(){var p;(p=this._beautyPlugin)==null||p.destroy()}};var Ac=class extends Vo{constructor(p){super(yd(qr({},p),{mediaType:"video"}));Ue(this,"_videoProfile",{width:320,height:240,frameRate:15,bitrate:300});let{width:V,height:X,frameRate:N,bitrate:J}=p;Gt.info("new LingoCameraVideoTrack"),this._stream=Td.default.createStream({audio:!1,video:!0,cameraId:p.cameraId}),V&&(this._videoProfile.width=V),X&&(this._videoProfile.height=X),N&&(this._videoProfile.frameRate=N),J&&(this._videoProfile.bitrate=J),this._stream.setVideoProfile(this._videoProfile)}async play(p){await this._stream.play(p.container,{mirror:this.mirrored}),this.lastPlayContainer=p.container}async stop(){await super.stop(),this.lastPlayContainer=null}async setDevice(p){var N,J,Pe;let V=this._beautyPlugin&&this._isVirtualEnable;if(this._log.info(`setDevice ${p} visual: ${V}`),V){let ye=Td.default.createStream({audio:!1,video:!0,cameraId:p});ye.setVideoProfile(this._videoProfile),await ye.initialize();let ut=ye.getVideoTrack();ut&&((N=this._originTrack)==null||N.removeEventListener("ended",this.onOriginTrackEnded),await((J=this._beautyPlugin)==null?void 0:J.replaceVirtualTrack(ut)),(Pe=this._originTrack)==null||Pe.addEventListener("ended",this.onOriginTrackEnded))}else if(await this._stream.switchDevice(this.trackMediaType,p),this._publishedStream&&this._publishedStream!==this._stream){let ye=this.getMediaStreamTrack();ye&&await this._publishedStream.replaceTrack(ye)}let X=(await Td.default.getCameras()).find(ye=>ye.deviceId===p);X&&this.emit("device-switched",X),!this._isVirtualEnable&&this._beautyPlugin&&(this._beautyPlugin.destroy(),this._beautyPlugin=null,this._isVirtualEnable=!1,this._imageUrl=null)}close(){var p;(p=this.getMediaStreamTrack())==null||p.stop(),this._stream.hasAudio()||this._stream.close(),super.close()}};var cE=sr(Rr());var p9=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(Z){let H=Math.random()*16|0;return(Z=="x"?H:H&3|8).toString(16)})};function xd(){return!performance||!performance.now?Date.now():Math.floor(performance.now())}var _g=class{constructor(){this.intervalMap_=new Map}setInterval(H,p,V=!0){if(!window||!window.requestAnimationFrame)return setInterval(H,p);let X=p9(),N=xd(),J=N;this.intervalMap_.set(X,{rafId:null,timeoutId:null,onVisibilityChange:null});let Pe=()=>{if(V&&document.hidden){if(H(),!this.intervalMap_.has(X))return;let ut=setTimeout(Pe,p);this.setTimeoutId(X,ut),N=xd(),J=N}else{if(J=xd(),J-N>=p&&(N=J,H(),!this.intervalMap_.has(X)))return;let ut=requestAnimationFrame(Pe);this.setRafId(X,ut)}},ye=requestAnimationFrame(Pe);if(this.setRafId(X,ye),V){let ut=()=>{if(document.hidden){let Nt=xd()-N;if(Nt>=p)Pe();else{let $e=setTimeout(Pe,p-Nt);this.setTimeoutId(X,$e)}}};document.addEventListener("visibilitychange",ut),this.setOnVisibilityChange(X,ut),document.hidden&&ut()}return X}clearInterval(H){if(this.intervalMap_.has(H)){let{rafId:p,timeoutId:V,onVisibilityChange:X}=this.intervalMap_.get(H);cancelAnimationFrame(p),clearTimeout(V),document.removeEventListener("visibilitychange",X),this.intervalMap_.delete(H)}}setTimeoutId(H,p){if(this.intervalMap_.has(H)){let V=this.intervalMap_.get(H);V.timeoutId&&clearTimeout(V.timeoutId),V.timeoutId=p}}setRafId(H,p){if(this.intervalMap_.has(H)){let V=this.intervalMap_.get(H);V.rafId&&cancelAnimationFrame(V.rafId),V.rafId=p}}setOnVisibilityChange(H,p){if(this.intervalMap_.has(H)){let V=this.intervalMap_.get(H);V.onVisibilityChange=p}}},f9=new _g,yg=f9;var Id=class extends Vo{constructor(p){super({mediaType:"video",id:"cus"});Ue(this,"frameRate",0);Ue(this,"canvas",document.createElement("canvas"));Ue(this,"canvasCtx");Ue(this,"onDraw",null);Ue(this,"_cameraVideoTrack",null);Ue(this,"_timerId");this._cameraVideoTrack=p}timerStop(){yg.clearInterval(this._timerId)}async init(){var X;if(this.canvasCtx)return;this.canvasCtx=this.canvas.getContext("2d");let p=(X=this._cameraVideoTrack)==null?void 0:X.getMediaStreamTrack();if(p){let{width:N,height:J,frameRate:Pe}=p.getSettings();N&&(this.canvas.width=N),J&&(this.canvas.height=J),Pe&&(this.frameRate=Pe)}this._timerId=yg.setInterval(()=>{var Pe,ye,ut;let N=(Pe=this._cameraVideoTrack)==null?void 0:Pe.getMediaStreamTrack();if(N){let{width:Nt,height:$e,frameRate:cr}=N.getSettings();Nt&&(this.canvas.width=Nt),$e&&(this.canvas.height=$e),cr&&(this.frameRate=cr)}let J=(ye=this._cameraVideoTrack)==null?void 0:ye.videoElement;J&&((ut=this.canvasCtx)==null||ut.drawImage(J,0,0,this.canvas.width,this.canvas.height),this.onDraw&&this.onDraw(this.canvas,this.mirrored))},1e3/this.frameRate,!0);let V=this.canvas.captureStream(this.frameRate).getVideoTracks()[0];this._stream=cE.default.createStream({videoSource:V}),await super.init()}async play(p){var V,X,N,J;if(p.container){this.lastPlayContainer=p.container,(V=this._cameraVideoTrack)!=null&&V.isPlaying||await((X=this._cameraVideoTrack)==null?void 0:X.play({container:p.container}));let Pe=(N=this._cameraVideoTrack)==null?void 0:N.videoElement;Pe&&Pe.parentElement&&(Pe.parentElement.style.display="none"),await this._stream.play(p.container),this.mirrorVideo(this.mirrored)}(J=p.custom)!=null&&J.onDraw&&(this.onDraw=p.custom.onDraw)}async stop(){var V;this.onDraw=null;let p=(V=this._cameraVideoTrack)==null?void 0:V.videoElement;p&&p.parentElement&&(p.parentElement.style.display="block"),await this._stream.stop(),this.lastPlayContainer=null}setDevice(p){return Promise.resolve()}};var Sg=sr(Rr());function wd(Z){return Z*1.5>100?100:Z*1.5}var Ed=class extends No{constructor({microphoneId:p}){super({mediaType:"audio"});Ue(this,"_captureVolume",100);Ue(this,"_div",document.createElement("div"));Ue(this,"_isPlayCalled",!1);Gt.info("new LingoMicrophoneAudioTrack"),this._stream=Sg.default.createStream({audio:!0,video:!1,microphoneId:p})}async play(){return this._isPlayCalled=!0,await this._stream.play(this._div,{muted:!1})}stop(){return this._isPlayCalled=!1,super.stop()}setPublishedStream(p){var V;p===null?(V=this._publishedStream)==null||V.setAudioCaptureVolume(100):p.setAudioCaptureVolume(this._captureVolume),super.setPublishedStream(p)}async setDevice(p){if(Gt.warn(`switch mic ${p}`),p==="default"&&this._stream.isAudioRecovering_)return;if(await this._stream.switchDevice(this.trackMediaType,p),this._publishedStream&&this._publishedStream!==this._stream){let X=this.getMediaStreamTrack();X&&await this._publishedStream.replaceTrack(X)}let V=(await Sg.default.getMicrophones()).find(X=>X.deviceId===p);V&&this.emit("device-switched",V)}setVolume(p){var V;(V=this._publishedStream)==null||V.setAudioCaptureVolume(p),this._captureVolume=p}getVolume(){return this._isPlayCalled||(this._isPlayCalled=!0,this._stream.play(this._div)),wd(this._stream.getAudioLevel()*100)}setSpeakerDevice(p){return this._stream.setAudioOutput(p)}close(){var p;(p=this.getMediaStreamTrack())==null||p.stop(),this._stream.hasAudio()||this._stream.close()}};var Uo=class extends Mo{constructor({uid:p,mediaType:V,stream:X}){super({mediaType:V});Ue(this,"uid");Ue(this,"isSubscribed",!1);this.uid=p,this._stream=X,this._stream.on("player-state-changed",({state:N})=>{this._playerState=N})}subscribe(){this.isSubscribed=!0}unsubscribe(){this.isSubscribed=!1}};var Cd=class extends Uo{constructor({uid:H,stream:p}){super({uid:H,mediaType:"audio",stream:p})}setVolume(H){this._stream.setAudioVolume(H/100)}getVolume(){return wd(this._stream.getAudioLevel()*100)}setSpeakerDevice(H){return this._stream.setAudioOutput(H)}async play(){return this._stream.isPlaying()?Promise.resolve():this._stream.play(document.createElement("div"))}};var Rd=class extends Uo{constructor({uid:p,stream:V}){super({uid:p,mediaType:"video",stream:V});Ue(this,"mirrored",!1);Ue(this,"lastPlayContainer")}async play(p){await this._stream.play(p.container),this.lastPlayContainer=p.container}async stop(){await super.stop(),this.lastPlayContainer=null}mirrorVideo(p){this.lastPlayContainer&&(this._stream.play(this.lastPlayContainer,{mirror:p}),this.mirrored=p)}};import{LingoBaseRTC as v9,LingoRTCError as xg}from"@lingoace/lingo-base-rtc";var bg=sr(Rr());import{LingoBaseRTCClient as m9,LingoRTCError as Bo,config as Pc}from"@lingoace/lingo-base-rtc";var Ad=new WeakMap;function Pd(){return function(Z,H,p){let V=p.value,X=({fn:N,args:J,context:Pe,resolve:ye,reject:ut})=>{N.apply(Pe,J).then(ye,ut).finally(()=>{let Nt=Ad.get(Pe);Nt.shift(),Nt[0]&&X(qr({},Nt[0]))})};return p.value=function(...N){return new Promise((J,Pe)=>{if(Ad.has(this)){let ye=Ad.get(this),{length:ut}=ye;ye.push({fn:V,args:N,context:this,resolve:J,reject:Pe}),ut===0&&X({fn:V,args:N,context:this,resolve:J,reject:Pe})}else Ad.set(this,[{fn:V,args:N,context:this,resolve:J,reject:Pe}]),X({fn:V,args:N,context:this,resolve:J,reject:Pe})})},p}}import{LingoRTCError as uE}from"@lingoace/lingo-base-rtc";function Cn(Z){return function(H,p,V){let X=V.value;return V.value=async function(...N){try{return await X.apply(this,N)}catch(J){throw Z?Z(J):J instanceof uE?J:uE.createOtherError(J.message)}},V}}var Rn=class extends m9{constructor(){super(...arguments);Ue(this,"_client",null);Ue(this,"_localStream",null);Ue(this,"_screenStream",null);Ue(this,"_remoteAuxiliaryStream",null);Ue(this,"_remoteMainStreamMap",new Map);Ue(this,"_remoteUserIdSet",new Set);Ue(this,"_quality",{res:"0x0",vfps:0,vra:0,ara:0,rtt:0,pktLostRate:0,upQuality:0,downQuality:0});Ue(this,"_prevLocalVideoStat",null);Ue(this,"_prevLocalAudioStat",null)}getRemoteUsers(){let p=new Map;return this._remoteUserIdSet.forEach(V=>{p.set(V,{uid:V,hasAudio:!1,hasVideo:!1})}),this.remoteAudioTrackMap.forEach(V=>{if(p.has(V.uid)){let X=p.get(V.uid);X.hasAudio=!0,X.audioTrack=V.isSubscribed?V:void 0}else p.set(V.uid,{uid:V.uid,hasAudio:!0,hasVideo:!1,audioTrack:V.isSubscribed?V:void 0,videoTrack:void 0})}),this.remoteVideoTrackMap.forEach(V=>{let{uid:X}=V;if(p.has(V.uid)){let N=p.get(V.uid);N.hasVideo=!0,N.videoTrack=V.isSubscribed?V:void 0}else p.set(X,{uid:X,hasAudio:!1,hasVideo:!0,audioTrack:void 0,videoTrack:V.isSubscribed?V:void 0})}),[...p.values()]}async join(p){return this._client=bg.default.createClient({sdkAppId:Number(p.appId),userId:p.uid,userSig:p.token,mode:"rtc",useStringRoomId:!0,autoSubscribe:!1,enableAutoPlayDialog:!1}),this.handleEvents(),await this._client.join({roomId:p.roomId}),this.joinParam=p,this.uid=p.uid,p.uid}async leave(){!this._client||(await this._client.leave(),this.joinParam=void 0,this._client=null)}start(){return Promise.resolve()}async publish(p){return this._localStream?await this._localStream.addTrack(p.getMediaStreamTrack()):(await this._client.publish(p._stream),this._localStream=p._stream),p.setPublishedStream(this._localStream),this.localTracks.push(p),!0}async unpublish(p){var X;let V=p.getMediaStreamTrack();return!V||!this._localStream||this.localTracks.length===0||(this.localTracks.length===1?(await((X=this._client)==null?void 0:X.unpublish(this._localStream)),p.setPublishedStream(null),this._localStream=null,this.localTracks=[]):this.localTracks.find(N=>N===p)&&(await this._localStream.removeTrack(V),p.setPublishedStream(null),this.localTracks=this.localTracks.filter(N=>N!==p))),!0}async subscribe(p,V){var X,N;if(!this._client)throw Bo.createOtherError("\u7528\u6237\u672A\u8FDB\u623F\uFF0C\u65E0\u6CD5\u8BA2\u9605");if(V==="audio"&&!this.remoteAudioTrackMap.has(p))throw Bo.createOtherError(`\u8FDC\u7AEF\u7528\u6237: ${p} \u672A\u63A8\u97F3\u9891\uFF0C\u65E0\u6CD5\u8BA2\u9605`);if(V==="video"&&p!==Pc.screenSharingUid&&!this.remoteVideoTrackMap.has(p))throw Bo.createOtherError(`\u8FDC\u7AEF\u7528\u6237: ${p} \u672A\u63A8\u89C6\u9891\uFF0C\u65E0\u6CD5\u8BA2\u9605`);if(Gt.info(`subscribe ${p} ${V}`),p===Pc.screenSharingUid&&this._remoteAuxiliaryStream&&this._client)return await this._client.subscribe(this._remoteAuxiliaryStream),!0;if(V==="audio"){let J=this.remoteAudioTrackMap.get(p);J.subscribe();try{await this._client.subscribe(J._stream,{audio:!0,video:!!((X=this.remoteVideoTrackMap.get(p))!=null&&X.isSubscribed)})}catch(Pe){throw J.unsubscribe(),Pe}}else{let J=this.remoteVideoTrackMap.get(p);J.subscribe();try{await this._client.subscribe(J._stream,{video:!0,audio:!!((N=this.remoteAudioTrackMap.get(p))!=null&&N.isSubscribed)})}catch(Pe){throw J.unsubscribe(),Pe}}return!0}async unsubscribe(p,V){var N,J;if(!this._client)throw Bo.createOtherError("\u7528\u6237\u672A\u8FDB\u623F\uFF0C\u65E0\u6CD5\u8BA2\u9605");Gt.info(`unsubscribe ${p} ${V}`);let X=null;if(V==="audio"&&this.remoteAudioTrackMap.has(p)?X=this.remoteAudioTrackMap.get(p):V==="video"&&this.remoteVideoTrackMap.has(p)&&(X=this.remoteVideoTrackMap.get(p)),!X)throw Bo.createOtherError(`\u8FDC\u7AEF\u7528\u6237: ${p} \u672A\u63A8 ${V}\uFF0C\u65E0\u6CD5\u8BA2\u9605`);return p===Pc.screenSharingUid&&this._remoteAuxiliaryStream?(await this._client.unsubscribe(this._remoteAuxiliaryStream),!0):(V==="audio"?(N=this.remoteVideoTrackMap.get(p))!=null&&N.isSubscribed?await this._client.subscribe(X._stream,{video:!0,audio:!1}):await this._client.unsubscribe(X._stream):(J=this.remoteAudioTrackMap.get(p))!=null&&J.isSubscribed?await this._client.subscribe(X._stream,{video:!1,audio:!0}):await this._client.unsubscribe(X._stream),X.unsubscribe(),!0)}getQOEStats(){return this._quality}async startScreenShare(p){if(!this.joinParam||!this._client)throw Bo.createOtherError("\u7528\u6237\u672A\u8FDB\u623F\uFF0C\u65E0\u6CD5\u5F00\u542F\u5C4F\u5E55\u5206\u4EAB");this._screenStream=bg.default.createStream({screen:!0,screenAudio:!0});let V={width:1280,height:720,frameRate:15,bitrate:2e3};this._screenStream.setScreenProfile(qr(qr({},V),p)),this._screenStream.on("screen-sharing-stopped",async()=>{await this.stopScreenShare(),this.emit("ScreenSharingEnded")}),await this._screenStream.initialize(),await this._client.publish(this._screenStream,{isAuxiliary:!0})}async stopScreenShare(){!this._client||!this._screenStream||(await this._client.unpublish(this._screenStream),this._screenStream.stop(),this._screenStream.close(),this._screenStream=null)}async playScreenShareView(p){var V;this._remoteAuxiliaryStream&&this._client?(await this._client.subscribe(this._remoteAuxiliaryStream),await this._remoteAuxiliaryStream.play(p)):await((V=this._screenStream)==null?void 0:V.play(p))}async stopScreenShareView(){var p;this._remoteAuxiliaryStream&&this._client?(await this._client.unsubscribe(this._remoteAuxiliaryStream),await this._remoteAuxiliaryStream.stop()):await((p=this._screenStream)==null?void 0:p.stop())}handleEvents(){!this._client||(this._client.on("connection-state-changed",({prevState:p,state:V})=>{this.connectionState=V,this.emit("ConnectionStateChange",V,p,"")}),this._client.on("peer-join",p=>{this._remoteUserIdSet.add(p.userId),this.emit("UserJoined",p.userId)}),this._client.on("peer-leave",p=>{this._remoteUserIdSet.delete(p.userId),this.emit("UserLeft",p.userId)}),this._client.on("stream-added",p=>{let V=p.stream,X=V.getUserId();if(V.getType()==="auxiliary"){this._remoteAuxiliaryStream=V,this.emit("RemoteScreenSharing",Pc.screenSharingUid,!0,"video");return}this._remoteMainStreamMap.set(X,V),V.on("error",N=>{if(N.getCode()===16451){let J=()=>{V.resume().then(()=>{document.body.removeEventListener("click",J),document.body.removeEventListener("touchstart",J)})};document.body.addEventListener("click",J,!0),document.body.addEventListener("touchstart",J,!0),this.emit("AutoplayFailed")}}),V.hasAudio()&&this.handleUserPublished(X,"audio"),V.hasVideo()&&this.handleUserPublished(X,"video")}),this._client.on("stream-updated",p=>{let V=p.stream,X=V.getUserId();!this.remoteAudioTrackMap.has(X)&&V.hasAudio()&&this.handleUserPublished(X,"audio"),this.remoteAudioTrackMap.has(X)&&!V.hasAudio()&&this.handleUserUnpublished(X,"audio"),!this.remoteVideoTrackMap.has(X)&&V.hasVideo()&&this.handleUserPublished(X,"video"),this.remoteVideoTrackMap.has(X)&&!V.hasVideo()&&this.handleUserUnpublished(X,"video")}),this._client.on("stream-removed",p=>{let V=p.stream.getUserId();if(p.stream.getType()==="auxiliary"){this._remoteAuxiliaryStream=null,this.emit("RemoteScreenSharing",Pc.screenSharingUid,!1,"video");return}this._remoteMainStreamMap.delete(V),this.handleUserUnpublished(V,"audio"),this.handleUserUnpublished(V,"video")}),this._client.on("network-quality",p=>{var V,X;this._quality.upQuality=p.uplinkNetworkQuality,this._quality.downQuality=p.downlinkNetworkQuality,this._quality.rtt=p.uplinkRTT,this._quality.pktLostRate=p.uplinkLoss,(V=this._client)==null||V.getLocalVideoStats().then(N=>{let J=N[this.uid];J&&(this._quality.res=`${J.frameWidth}x${J.frameHeight}`,this._prevLocalVideoStat&&(this._quality.vfps=Math.floor((J.framesSent-this._prevLocalVideoStat.framesSent)/2)||0,this._quality.vra=Math.floor((J.bytesSent-this._prevLocalVideoStat.bytesSent)*8/2)||0),this._prevLocalVideoStat=J)}),(X=this._client)==null||X.getLocalAudioStats().then(N=>{let J=N[this.uid];J&&(this._prevLocalAudioStat&&(this._quality.ara=Math.floor((J.bytesSent-this._prevLocalAudioStat.bytesSent)*8/2)||0),this._prevLocalAudioStat=J)}),this.emit("NetworkQuality",p)}),this._client.on("mute-audio",p=>{this.handleUserUnpublished(p.userId,"audio")}),this._client.on("unmute-audio",p=>{this.handleUserPublished(p.userId,"audio",!0)}))}handleUserUnpublished(p,V){Gt.info(`UserUnpublished ${p} ${V}`),V==="audio"?this.remoteAudioTrackMap.has(p)&&(this.remoteAudioTrackMap.delete(p),this.emit("UserUnpublished",p,V)):this.remoteVideoTrackMap.has(p)&&(this.remoteVideoTrackMap.delete(p),this.emit("UserUnpublished",p,V))}handleUserPublished(p,V,X=!1){var Pe;Gt.info(`UserPublished ${p} ${V} firedByUnmute: ${X}`);let N=this._remoteMainStreamMap.get(p),J=(Pe=this._client)==null?void 0:Pe.getRemoteMutedState().find(ye=>ye.userId===p);if(N){if(V==="audio"&&!this.remoteAudioTrackMap.has(p)&&N.hasAudio()){if(!X&&J&&J.audioMuted)return;let ye=new Cd({uid:p,stream:N});this.remoteAudioTrackMap.set(p,ye)}else if(V==="video"&&!this.remoteVideoTrackMap.has(p)&&N.hasVideo()){let ye=new Rd({uid:p,stream:N});this.remoteVideoTrackMap.set(p,ye)}this.emit("UserPublished",p,V)}}};En([Cn(),Pd()],Rn.prototype,"publish",1),En([Cn()],Rn.prototype,"unpublish",1),En([Cn()],Rn.prototype,"subscribe",1),En([Cn()],Rn.prototype,"unsubscribe",1),En([Cn()],Rn.prototype,"startScreenShare",1),En([Cn()],Rn.prototype,"stopScreenShare",1),En([Cn()],Rn.prototype,"playScreenShareView",1),En([Cn()],Rn.prototype,"stopScreenShareView",1);var Fo=sr(Rr());var lE=sr(mg()),kg=sr(Rr());var Tg=class extends lE.default{constructor(){super();Ue(this,"prevDevices_",[]);navigator.mediaDevices&&(this.onDeviceChange=this.onDeviceChange.bind(this),navigator.mediaDevices.addEventListener("devicechange",this.onDeviceChange))}async init(){this.prevDevices_=await kg.default.getDevices()}async onDeviceChange(){let p=await kg.default.getDevices(),V=p.filter(N=>this.prevDevices_.findIndex(({deviceId:J})=>N.deviceId===J)<0),X=this.prevDevices_.filter(N=>p.findIndex(({deviceId:J})=>N.deviceId===J)<0);V.length>0&&V.forEach(N=>{this.emit("device-added",N)}),X.length>0&&X.forEach(N=>{this.emit("device-removed",N)}),this.prevDevices_=p}destroy(){navigator.mediaDevices.removeEventListener("devicechange",this.onDeviceChange)}},dE=Tg;var Gt=Fo.default.Logger.loggerManager,jo=class extends v9{constructor(){super(...arguments);Ue(this,"version",Kw);Ue(this,"_deviceDetector",new dE);Ue(this,"_virtualOverloadCount",0);Ue(this,"_isVirtualOverloadStart",0)}init(p){return Gt.info(`lingo-trtc version: ${this.version}`),Promise.resolve()}release(){this._deviceDetector.destroy(),super.release()}async checkSystemRequirements(){let{result:p}=await Fo.default.checkSystemRequirements();return p&&Fo.default.isScreenShareSupported()}async createClient(){return this.client=new Rn,await this._deviceDetector.init(),this._deviceDetector.on("device-added",p=>{p.kind==="videoinput"?this.client.emit("CameraChanged",!0,p):p.kind==="audioinput"?this.client.emit("MicrophoneChanged",!0,p):p.kind==="audiooutput"&&this.client.emit("SpeakerDeviceChanged",!0,p)}),this._deviceDetector.on("device-removed",async p=>{var V,X;if(p.kind==="videoinput"){let N=this.cameraVideoTrack||this.previewVideoTrack;if(p.deviceId===(N==null?void 0:N.getDeviceId())){if((await Fo.default.getCameras()).length===0){this.client.emit("CameraChanged",!1,p);return}N.once("device-switched",()=>{this.client.emit("CameraChanged",!1,p)}),N.once("track-ended",()=>{this.client.emit("CameraChanged",!1,p)})}else this.client.emit("CameraChanged",!1,p)}else if(p.kind==="audioinput")if(p.deviceId===((V=this.microphoneAudioTrack)==null?void 0:V.getDeviceId())){if((await Fo.default.getMicrophones()).length===0){this.client.emit("CameraChanged",!1,p);return}this.microphoneAudioTrack.once("device-switched",()=>{this.client.emit("CameraChanged",!1,p)}),(X=this.microphoneAudioTrack)==null||X.once("track-ended",()=>{this.client.emit("CameraChanged",!1,p)})}else this.client.emit("MicrophoneChanged",!1,p);else p.kind==="audiooutput"&&this.client.emit("SpeakerDeviceChanged",!1,p)}),this.client}async createCustomVideoTrack(p){if(this.customVideoTrack&&!this.customVideoTrack.closed)return this.customVideoTrack;Gt.info("createCustomVideoTrack");let V=new Id(p);return await V.init(),this.customVideoTrack=V,V}async detectCamera(p){var V,X;if(this.previewVideoTrack&&!this.previewVideoTrack.closed)return{checkIsActive:()=>{var N,J;return Promise.resolve(((J=(N=this.previewVideoTrack)==null?void 0:N.getMediaStreamTrack())==null?void 0:J.readyState)==="live")},cleanup:()=>{var N,J;(N=this.previewVideoTrack)==null||N.stop(),(J=this.previewVideoTrack)==null||J.close(),this.previewVideoTrack=void 0}};Gt.info("detectCamera");try{let N=new Ac({cameraId:p.cameraId,id:"pv"});return N.on("device-switched",J=>this.client.emit("DeviceSwitched",J)),this.previewVideoTrack=N,await N.init(),p.mirror&&N.mirrorVideo(p.mirror),p.container&&await N.play({container:p.container}),{checkIsActive:()=>{var J;return Promise.resolve(((J=N.getMediaStreamTrack())==null?void 0:J.readyState)==="live")},cleanup:()=>{N.stop(),N.close(),this.previewVideoTrack=void 0}}}catch(N){throw(V=this.previewVideoTrack)==null||V.stop(),(X=this.previewVideoTrack)==null||X.close(),this.previewVideoTrack=void 0,N}}processExternalMediaAEC(p){}async createMicrophoneAudioTrack(p){if(this.microphoneAudioTrack&&!this.microphoneAudioTrack.closed)return this.microphoneAudioTrack;Gt.info("createMicrophoneAudioTrack");let V=new Ed({microphoneId:p});return V.on("device-switched",X=>this.client.emit("DeviceSwitched",X)),await V.init(),this.microphoneAudioTrack=V,this.client.emit("LocalTrackCreated",V),V}async createCameraVideoTrack(p){if(this.cameraVideoTrack&&!this.cameraVideoTrack.closed)return this.cameraVideoTrack;Gt.info(`createCameraVideoTrack ${JSON.stringify(p)}`);let V=new Ac(yd(qr({},p),{id:"ct"}));return V.on("device-switched",X=>this.client.emit("DeviceSwitched",X)),await V.init(),this.cameraVideoTrack=V,this.client.emit("LocalTrackCreated",V),this.cameraVideoTrack.on("VirtualBackgroundOverload",()=>{this._virtualOverloadCount++,Gt.warn(`VirtualBackground overload count is: ${this._virtualOverloadCount}`),new Date().getTime()-this._isVirtualOverloadStart>5e3&&(this._virtualOverloadCount>10&&(Gt.warn("VirtualBackgroundOverload"),this.client.emit("VirtualBackgroundOverload")),this._virtualOverloadCount=0,this._isVirtualOverloadStart=new Date().getTime())}),V}};En([Pd(),Cn(Z=>xg.createRTCError(Z))],jo.prototype,"detectCamera",1),En([Cn(Z=>xg.createRTCError(Z))],jo.prototype,"createMicrophoneAudioTrack",1),En([Cn(Z=>xg.createRTCError(Z))],jo.prototype,"createCameraVideoTrack",1);var BG=jo;export{BG as default,Gt as loggerManager};
548
+ `+M.getProgramInfoLog(Z));F=L.s=Z,M.useProgram(F),W=M.getUniformLocation(F,"sampler0"),L.l={O:M.getAttribLocation(F,"aVertex"),N:M.getAttribLocation(F,"aTex"),ya:W},L.v=M.createBuffer(),M.bindBuffer(M.ARRAY_BUFFER,L.v),M.enableVertexAttribArray(L.l.O),M.vertexAttribPointer(L.l.O,2,M.FLOAT,!1,0,0),M.bufferData(M.ARRAY_BUFFER,new Float32Array([-1,-1,-1,1,1,1,1,-1]),M.STATIC_DRAW),M.bindBuffer(M.ARRAY_BUFFER,null),L.u=M.createBuffer(),M.bindBuffer(M.ARRAY_BUFFER,L.u),M.enableVertexAttribArray(L.l.N),M.vertexAttribPointer(L.l.N,2,M.FLOAT,!1,0,0),M.bufferData(M.ARRAY_BUFFER,new Float32Array([0,1,0,0,1,0,1,1]),M.STATIC_DRAW),M.bindBuffer(M.ARRAY_BUFFER,null),M.uniform1i(W,0)}F=L.l,M.useProgram(L.s),M.canvas.width=B.width,M.canvas.height=B.height,M.viewport(0,0,B.width,B.height),M.activeTexture(M.TEXTURE0),L.i.bindTexture2d(B.glName),M.enableVertexAttribArray(F.O),M.bindBuffer(M.ARRAY_BUFFER,L.v),M.vertexAttribPointer(F.O,2,M.FLOAT,!1,0,0),M.enableVertexAttribArray(F.N),M.bindBuffer(M.ARRAY_BUFFER,L.u),M.vertexAttribPointer(F.N,2,M.FLOAT,!1,0,0),M.bindFramebuffer(M.DRAW_FRAMEBUFFER?M.DRAW_FRAMEBUFFER:M.FRAMEBUFFER,null),M.clearColor(0,0,0,0),M.clear(M.COLOR_BUFFER_BIT),M.colorMask(!0,!0,!0,!0),M.drawArrays(M.TRIANGLE_FAN,0,4),M.disableVertexAttribArray(F.O),M.disableVertexAttribArray(F.N),M.bindBuffer(M.ARRAY_BUFFER,null),L.i.bindTexture2d(0)}(d,g),typeof d.h.canvas.transferToImageBitmap=="function"?Promise.resolve(d.h.canvas.transferToImageBitmap()):w?Promise.resolve(d.h.canvas):typeof createImageBitmap=="function"?createImageBitmap(d.h.canvas):(d.j===void 0&&(d.j=document.createElement("canvas")),new Promise(function(L){d.j.height=d.h.canvas.height,d.j.width=d.h.canvas.width,d.j.getContext("2d",{}).drawImage(d.h.canvas,0,0,d.h.canvas.width,d.h.canvas.height),L(d.j)}))}function Ud(d){this.h=d}Pa.prototype.l=fs(tu);var ru=new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,2,1,0,10,9,1,7,0,65,0,253,15,26,11]);function Vd(d,g){return g+d}function La(d,g){window[d]=g}function Xn(d){if(this.h=d,this.listeners={},this.l={},this.L={},this.s={},this.v={},this.M=this.u=this.ga=!0,this.I=Promise.resolve(),this.fa="",this.D={},this.locateFile=d&&d.locateFile||Vd,(typeof window=="undefined"?"undefined":$(window))==="object")var g=window.location.pathname.toString().substring(0,window.location.pathname.toString().lastIndexOf("/"))+"/";else{if(typeof location=="undefined")throw Error("solutions can only be loaded on a web page or in a web worker");g=location.pathname.toString().substring(0,location.pathname.toString().lastIndexOf("/"))+"/"}if(this.ha=g,d.options)for(var w=(g=X(Object.keys(d.options))).next();!w.done;w=g.next()){w=w.value;var L=d.options[w].default;L!==void 0&&(this.l[w]=typeof L=="function"?L():L)}}function jd(d){var g,w,L,B,M,F,W,Z,fe,me,we;return Ze(function(Ae){switch(Ae.h){case 1:return d.ga?(g=d.h.files===void 0?[]:typeof d.h.files=="function"?d.h.files(d.l):d.h.files,dt(Ae,Ze(function(ve){switch(ve.h){case 1:return ve.s=2,dt(ve,WebAssembly.instantiate(ru),4);case 4:ve.h=3,ve.s=0;break;case 2:return ve.s=0,ve.l=null,ve.return(!1);case 3:return ve.return(!0)}}),2)):Ae.return();case 2:if(w=Ae.i,(typeof window=="undefined"?"undefined":$(window))==="object")return La("createMediapipeSolutionsWasm",{locateFile:d.locateFile}),La("createMediapipeSolutionsPackedAssets",{locateFile:d.locateFile}),F=g.filter(function(ve){return ve.data!==void 0}),W=g.filter(function(ve){return ve.data===void 0}),Z=Promise.all(F.map(function(ve){var Le=ei(d,ve.url);if(ve.path!==void 0){var Be=ve.path;Le=Le.then(function(ot){return d.overrideFile(Be,ot),Promise.resolve(ot)})}return Le})),fe=Promise.all(W.map(function(ve){return ve.simd===void 0||ve.simd&&w||!ve.simd&&!w?function(Le){var Be=document.createElement("script");return Be.setAttribute("src",Le),Be.setAttribute("crossorigin","anonymous"),new Promise(function(ot){Be.addEventListener("load",function(){ot()},!1),Be.addEventListener("error",function(){ot()},!1),document.body.appendChild(Be)})}(d.locateFile(ve.url,d.ha)):Promise.resolve()})).then(function(){var ve,Le,Be;return Ze(function(ot){if(ot.h==1)return ve=window.createMediapipeSolutionsWasm,Le=window.createMediapipeSolutionsPackedAssets,Be=d,dt(ot,ve(Le),2);Be.i=ot.i,ot.h=0})}),me=Ze(function(ve){return d.h.graph&&d.h.graph.url?ve=dt(ve,ei(d,d.h.graph.url),0):(ve.h=0,ve=void 0),ve}),dt(Ae,Promise.all([fe,Z,me]),7);if(typeof importScripts!="function")throw Error("solutions can only be loaded on a web page or in a web worker");return L=g.filter(function(ve){return ve.simd===void 0||ve.simd&&w||!ve.simd&&!w}).map(function(ve){return d.locateFile(ve.url,d.ha)}),importScripts.apply(null,se(L)),B=d,dt(Ae,createMediapipeSolutionsWasm(Module),6);case 6:B.i=Ae.i,d.m=new OffscreenCanvas(1,1),d.i.canvas=d.m,M=d.i.GL.createContext(d.m,{antialias:!1,alpha:!1,va:typeof WebGL2RenderingContext!="undefined"?2:1}),d.i.GL.makeContextCurrent(M),Ae.h=4;break;case 7:if(d.m=document.createElement("canvas"),!(we=d.m.getContext("webgl2",{}))&&!(we=d.m.getContext("webgl",{})))return alert("Failed to create WebGL canvas context when passing video frame."),Ae.return();d.K=we,d.i.canvas=d.m,d.i.createContext(d.m,!0,!0,{});case 4:d.j=new d.i.SolutionWasm,d.ga=!1,Ae.h=0}})}function ei(d,g){var w,L;return Ze(function(B){return g in d.L?B.return(d.L[g]):(w=d.locateFile(g,""),L=fetch(w).then(function(M){return M.arrayBuffer()}),d.L[g]=L,B.return(L))})}function Bd(d,g,w){var L,B,M,F,W,Z,fe,me,we,Ae,ve,Le,Be,ot;return Ze(function(ut){switch(ut.h){case 1:if(!w)return ut.return(g);for(L={},B=0,M=X(Object.keys(w)),F=M.next();!F.done;F=M.next())W=F.value,typeof(Z=w[W])!="string"&&Z.type==="texture"&&g[Z.stream]!==void 0&&++B;1<B&&(d.M=!1),fe=X(Object.keys(w)),F=fe.next();case 2:if(F.done){ut.h=4;break}if(me=F.value,typeof(we=w[me])=="string")return Be=L,ot=me,dt(ut,function(On,Na,ni){var Ua;return Ze(function(gs){return typeof ni=="number"||ni instanceof Uint8Array||ni instanceof On.i.Uint8BlobList?gs.return(ni):ni instanceof On.i.Texture2dDataOut?((Ua=On.v[Na])||(Ua=new Vi(On.i,On.K),On.v[Na]=Ua),gs.return(Da(Ua,ni,On.M))):gs.return(void 0)})}(d,me,g[we]),14);if(Ae=g[we.stream],we.type==="detection_list"){if(Ae){for(var jt=Ae.getRectList(),hn=Ae.getLandmarksList(),yt=Ae.getClassificationsList(),Je=[],Ke=0;Ke<jt.size();++Ke){var mr=Md(jt.get(Ke)),Ma=void 0;Ma=Ma===void 0?0:Ma,mr={la:{sa:Dn(mr,1),ta:Dn(mr,2),height:Dn(mr,3),width:Dn(mr,4),rotation:Dn(mr,5,0),pa:Ca(dn(mr,6),Ma)},ea:kt(Od(hn.get(Ke)),pr,1).map(Ln),ba:Nd(Ld(yt.get(Ke)))},Je.push(mr)}jt=Je}else jt=[];L[me]=jt,ut.h=7;break}if(we.type==="proto_list"){if(Ae){for(jt=Array(Ae.size()),hn=0;hn<Ae.size();hn++)jt[hn]=Ae.get(hn);Ae.delete()}else jt=[];L[me]=jt,ut.h=7;break}if(Ae===void 0){ut.h=3;break}if(we.type==="float_list"){L[me]=Ae,ut.h=7;break}if(we.type==="proto"){L[me]=Ae,ut.h=7;break}if(we.type!=="texture")throw Error("Unknown output config type: '"+we.type+"'");return(ve=d.v[me])||(ve=new Vi(d.i,d.K),d.v[me]=ve),dt(ut,Da(ve,Ae,d.M),13);case 13:Le=ut.i,L[me]=Le;case 7:we.transform&&L[me]&&(L[me]=we.transform(L[me])),ut.h=3;break;case 14:Be[ot]=ut.i;case 3:F=fe.next(),ut.h=2;break;case 4:return ut.return(L)}})}function Oa(d,g){for(var w=g.name||"$",L=[].concat(se(g.wants)),B=new d.i.StringList,M=X(g.wants),F=M.next();!F.done;F=M.next())B.push_back(F.value);M=d.i.PacketListener.implement({onResults:function(W){for(var Z={},fe=0;fe<g.wants.length;++fe)Z[L[fe]]=W.get(fe);var me=d.listeners[w];me&&(d.I=Bd(d,Z,g.outs).then(function(we){we=me(we);for(var Ae=0;Ae<g.wants.length;++Ae){var ve=Z[L[Ae]];$(ve)==="object"&&ve.hasOwnProperty&&ve.hasOwnProperty("delete")&&ve.delete()}we&&(d.I=we)}))}}),d.j.attachMultiListener(B,M),B.delete()}function ti(d){return d===void 0&&(d=0),d===1?"selfie_segmentation_landscape.tflite":"selfie_segmentation.tflite"}function ji(d){var g=this;d=d||{},this.h=new Xn({locateFile:d.locateFile,files:function(w){return[{simd:!0,url:"selfie_segmentation_solution_simd_wasm_bin.js"},{simd:!1,url:"selfie_segmentation_solution_wasm_bin.js"},{data:!0,url:ti(w.modelSelection)}]},graph:{url:"selfie_segmentation.binarypb"},listeners:[{wants:["segmentation_mask","image_transformed"],outs:{image:{type:"texture",stream:"image_transformed"},segmentationMask:{type:"texture",stream:"segmentation_mask"}}}],inputs:{image:{type:"video",stream:"input_frames_gpu"}},options:{useCpuInference:{type:0,graphOptionXref:{calculatorType:"InferenceCalculator",fieldName:"use_cpu_inference"},default:(typeof window=="undefined"?"undefined":$(window))==="object"&&window.navigator!==void 0&&("iPad Simulator;iPhone Simulator;iPod Simulator;iPad;iPhone;iPod".split(";").includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document)},selfieMode:{type:0,graphOptionXref:{calculatorType:"GlScalerCalculator",calculatorIndex:1,fieldName:"flip_horizontal"}},modelSelection:{type:1,graphOptionXref:{calculatorType:"ConstantSidePacketCalculator",calculatorName:"ConstantSidePacketCalculatorModelSelection",fieldName:"int_value"},onChange:function(w){var L,B,M;return Ze(function(F){return F.h==1?(L=ti(w),B="third_party/mediapipe/modules/selfie_segmentation/"+L,dt(F,ei(g.h,L),2)):(M=F.i,g.h.overrideFile(B,M),F.return(!0))})}}}})}(le=Xn.prototype).close=function(){return this.j&&this.j.delete(),Promise.resolve()},le.reset=function(){var d=this;return Ze(function(g){d.j&&(d.j.reset(),d.s={},d.v={}),g.h=0})},le.setOptions=function(d,g){var w=this;if(g=g||this.h.options){for(var L=[],B=[],M={},F=X(Object.keys(d)),W=F.next();!W.done;M={X:M.X,Y:M.Y},W=F.next())if(!((W=W.value)in this.l)||this.l[W]!==d[W]){this.l[W]=d[W];var Z=g[W];Z!==void 0&&(Z.onChange&&(M.X=Z.onChange,M.Y=d[W],L.push(function(fe){return function(){return Ze(function(me){if(me.h==1)return dt(me,fe.X(fe.Y),2);me.i===!0&&(w.u=!0),me.h=0})}}(M))),Z.graphOptionXref&&(W=Object.assign({},{calculatorName:"",calculatorIndex:0},Z.graphOptionXref,{valueNumber:Z.type===1?d[W]:0,valueBoolean:Z.type===0&&d[W],valueString:Z.type===2?d[W]:""}),B.push(W)))}L.length===0&&B.length===0||(this.u=!0,this.H=(this.H===void 0?[]:this.H).concat(B),this.F=(this.F===void 0?[]:this.F).concat(L))}},le.initialize=function(){var d=this;return Ze(function(g){return g.h==1?dt(g,jd(d),2):g.h!=3?dt(g,function(w){var L,B,M,F,W,Z,fe,me;return Ze(function(we){if(we.h==1)return w.h.graph&&w.h.graph.url&&w.fa===w.h.graph.url?we.return():(w.u=!0,w.h.graph&&w.h.graph.url?(w.fa=w.h.graph.url,dt(we,ei(w,w.h.graph.url),3)):void(we.h=2));for(we.h!=2&&(L=we.i,w.j.loadGraph(L)),B=X(Object.keys(w.D)),M=B.next();!M.done;M=B.next())F=M.value,w.j.overrideFile(F,w.D[F]);if(w.D={},w.h.listeners)for(W=X(w.h.listeners),Z=W.next();!Z.done;Z=W.next())fe=Z.value,Oa(w,fe);me=w.l,w.l={},w.setOptions(me),we.h=0})}(d),3):dt(g,function(w){var L,B,M,F,W,Z;return Ze(function(fe){switch(fe.h){case 1:if(!w.u)return fe.return();if(!w.F){fe.h=2;break}L=X(w.F),B=L.next();case 3:if(B.done){fe.h=5;break}return dt(fe,(0,B.value)(),4);case 4:B=L.next(),fe.h=3;break;case 5:w.F=void 0;case 2:if(w.H){for(M=new w.i.GraphOptionChangeRequestList,F=X(w.H),W=F.next();!W.done;W=F.next())Z=W.value,M.push_back(Z);w.j.changeOptions(M),M.delete(),w.H=void 0}w.u=!1,fe.h=0}})}(d),0)})},le.overrideFile=function(d,g){this.j?this.j.overrideFile(d,g):this.D[d]=g},le.clearOverriddenFiles=function(){this.D={},this.j&&this.j.clearOverriddenFiles()},le.send=function(d,g){var w,L,B,M,F,W,Z,fe,me,we=this;return Ze(function(Ae){switch(Ae.h){case 1:return we.h.inputs?(w=1e3*(g==null?performance.now():g),dt(Ae,we.I,2)):Ae.return();case 2:return dt(Ae,we.initialize(),3);case 3:for(L=new we.i.PacketDataList,B=X(Object.keys(d)),M=B.next();!M.done;M=B.next())if(F=M.value,W=we.h.inputs[F]){e:{var ve=d[F];switch(W.type){case"video":var Le=we.s[W.stream];if(Le||(Le=new Vi(we.i,we.K),we.s[W.stream]=Le),Le.m===0&&(Le.m=Le.i.createTexture()),typeof HTMLVideoElement!="undefined"&&ve instanceof HTMLVideoElement)var Be=ve.videoWidth,ot=ve.videoHeight;else typeof HTMLImageElement!="undefined"&&ve instanceof HTMLImageElement?(Be=ve.naturalWidth,ot=ve.naturalHeight):(Be=ve.width,ot=ve.height);ot={glName:Le.m,width:Be,height:ot},(Be=Le.h).canvas.width=ot.width,Be.canvas.height=ot.height,Be.activeTexture(Be.TEXTURE0),Le.i.bindTexture2d(Le.m),Be.texImage2D(Be.TEXTURE_2D,0,Be.RGBA,Be.RGBA,Be.UNSIGNED_BYTE,ve),Le.i.bindTexture2d(0),Le=ot;break e;case"detections":for((Le=we.s[W.stream])||(Le=new Ud(we.i),we.s[W.stream]=Le),Le.data||(Le.data=new Le.h.DetectionListData),Le.data.reset(ve.length),ot=0;ot<ve.length;++ot){Be=ve[ot];var ut=Le.data,jt=ut.setBoundingBox,hn=ot,yt=Be.la,Je=new Pa;if(Pn(Je,1,yt.sa),Pn(Je,2,yt.ta),Pn(Je,3,yt.height),Pn(Je,4,yt.width),Pn(Je,5,yt.rotation),An(Je,6,yt.pa),yt=Je.l(),jt.call(ut,hn,yt),Be.ea)for(ut=0;ut<Be.ea.length;++ut){Je=Be.ea[ut],hn=(jt=Le.data).addNormalizedLandmark,yt=ot,Je=Object.assign({},Je,{visibility:Je.visibility?Je.visibility:0});var Ke=new pr;Pn(Ke,1,Je.x),Pn(Ke,2,Je.y),Pn(Ke,3,Je.z),Je.visibility&&Pn(Ke,4,Je.visibility),Je=Ke.l(),hn.call(jt,yt,Je)}if(Be.ba)for(ut=0;ut<Be.ba.length;++ut)hn=(jt=Le.data).addClassification,yt=ot,Je=Be.ba[ut],Pn(Ke=new Zr,2,Je.qa),Je.index&&An(Ke,1,Je.index),Je.label&&An(Ke,3,Je.label),Je.displayName&&An(Ke,4,Je.displayName),Je=Ke.l(),hn.call(jt,yt,Je)}Le=Le.data;break e;default:Le={}}}switch(Z=Le,fe=W.stream,W.type){case"video":L.pushTexture2d(Object.assign({},Z,{stream:fe,timestamp:w}));break;case"detections":(me=Z).stream=fe,me.timestamp=w,L.pushDetectionList(me);break;default:throw Error("Unknown input config type: '"+W.type+"'")}}return we.j.send(L),dt(Ae,we.I,4);case 4:L.delete(),Ae.h=0}})},le.onResults=function(d,g){this.listeners[g||"$"]=d},he("Solution",Xn),he("OptionType",{BOOL:0,NUMBER:1,ua:2,0:"BOOL",1:"NUMBER",2:"STRING"}),(le=ji.prototype).close=function(){return this.h.close(),Promise.resolve()},le.onResults=function(d){this.h.onResults(d)},le.initialize=function(){var d=this;return Ze(function(g){return dt(g,d.h.initialize(),0)})},le.reset=function(){this.h.reset()},le.send=function(d){var g=this;return Ze(function(w){return dt(w,g.h.send(d),0)})},le.setOptions=function(d){this.h.setOptions(d)},he("SelfieSegmentation",ji),he("VERSION","0.1.1675465747")}).call(Wo);var Er=function(le){return typeof le=="number"},Ac=function(){function le(){Re(this,le),this.userId="",this.videoBeauty=document.createElement("video"),this.videoBeauty.loop=!0,this.videoBeauty.autoplay=!0,this.videoVirtual=document.createElement("video"),this.videoVirtual.loop=!0,this.videoVirtual.autoplay=!0,this.onoverload=null,this.canvasBeauty=document.createElement("canvas"),this.filter=new Go({canvas:this.canvasBeauty,video:this.videoBeauty}),this.canvasVirtual=document.createElement("canvas"),this.virtual=new zo({canvas:this.canvasVirtual,video:this.videoVirtual,onoverload:this.onoverload}),this.beautyParams={beauty:.5,brightness:.5,ruddy:.5},this.timeoutId=null,this.rafId=null,this.startTime=null,this.originTrack=null,this.beautyTrack=null,this.resultTrack=null,this.localStream=null,this.frameRate=null,this.disableStatus=!1,this.isVirualEnable=!1}var ke,Se,je,He,oe;return $e(le,[{key:"generateBeautyStream",value:function(X){this.userId=X==null?void 0:X.getUserId();var se=X.getVideoTrack();if(!se)throw new Error("Your localStream does not contain video track.");var z=this.generateBeautyTrack(se);return X.replaceTrack(z),this.localStream=X,X.setBeautyStatus&&X.setBeautyStatus(!0),console.log("RTCBeautyPlugin: generateBeautyStream ".concat(this.userId?"userId: ".concat(this.userId):"")),X}},{key:"generateBeautyTrack",value:function(X){var se=this;this.reset();var z=X.getSettings();this.frameRate=z.frameRate,this.filter.setRect(z.width,z.height),this.setRect(z.width,z.height);var re=new MediaStream;re.addTrack(X),this.videoBeauty.srcObject=re,this.videoBeauty.play();var be=this.canvasBeauty.captureStream(this.frameRate||15).getVideoTracks()[0];return this.rafId&&cancelAnimationFrame(this.rafId),this.rafId=requestAnimationFrame(function(){se.startTime=new Date().getTime(),se.render()}),this.installEvents(),this.originTrack=X,this.beautyTrack=be,this.setTrackParam({type:"beauty",originTrack:X,resultTrack:be,param:this.beautyParams}),be}},{key:"setBackground",value:(oe=Q(G().mark(function X(se){return G().wrap(function(z){for(;;)switch(z.prev=z.next){case 0:return z.next=2,this.virtual.setBackground(se);case 2:console.log("RTCBeautyPlugin: setBackground img:".concat(se));case 3:case"end":return z.stop()}},X,this)})),function(X){return oe.apply(this,arguments)})},{key:"generateStream",value:(He=Q(G().mark(function X(se){var z,re,be,ue,_e;return G().wrap(function(Oe){for(;;)switch(Oe.prev=Oe.next){case 0:if(z=se.localStream,re=se.type,be=se.img,ue=z.getVideoTrack()){Oe.next=4;break}throw new Error("Your localStream does not contain video track.");case 4:return this.localStream=z,Oe.next=7,this.generateMixedTrack({videoTrack:ue,type:re,img:be});case 7:return _e=Oe.sent,z.replaceTrack(_e),z.setBeautyStatus&&z.setBeautyStatus(!0),Oe.abrupt("return",z);case 11:case"end":return Oe.stop()}},X,this)})),function(X){return He.apply(this,arguments)})},{key:"generateMixedTrack",value:(je=Q(G().mark(function X(se){var z,re,be,ue,_e;return G().wrap(function(Oe){for(;;)switch(Oe.prev=Oe.next){case 0:if(z=se.videoTrack,re=se.type,be=se.img,this.virtual.selfieSegmentation){Oe.next=3;break}throw new Error("you should call loadResources() first");case 3:return this.virtual.initVirtualParams({type:re,img:be}),Oe.next=6,this.generateBeautyTrack(z);case 6:return ue=Oe.sent,Oe.next=9,this.generateVirtualTrack({videoTrack:ue,type:re,img:be});case 9:return _e=Oe.sent,this.beautyTrack=ue,this.resultTrack=_e,this.setTrackParam({type:"mixed",originTrack:this.originTrack,resultTrack:this.resultTrack,param:{type:re,img:be}}),Oe.abrupt("return",this.resultTrack);case 14:case"end":return Oe.stop()}},X,this)})),function(X){return je.apply(this,arguments)})},{key:"generateVirtualStream",value:(Se=Q(G().mark(function X(se){var z,re,be,ue,_e;return G().wrap(function(Oe){for(;;)switch(Oe.prev=Oe.next){case 0:if(z=se.localStream,re=se.type,be=se.img,ue=z.getVideoTrack()){Oe.next=4;break}throw new Error("Your localStream does not contain video track.");case 4:return this.localStream=z,Oe.next=7,this.generateVirtualTrack({videoTrack:ue,type:re,img:be});case 7:return _e=Oe.sent,Oe.next=10,z.replaceTrack(_e);case 10:return z.setBeautyStatus&&z.setBeautyStatus(!0),console.log("".concat(this.userId?"[userId: ".concat(this.userId,"]"):""," RTCBeautyPlugin generate ").concat(re," Stream.")),Oe.abrupt("return",z);case 13:case"end":return Oe.stop()}},X,this)})),function(X){return Se.apply(this,arguments)})},{key:"generateVirtualTrack",value:(ke=Q(G().mark(function X(se){var z,re,be,ue;return G().wrap(function(_e){for(;;)switch(_e.prev=_e.next){case 0:if(z=se.videoTrack,re=se.type,be=se.img,this.virtual.selfieSegmentation){_e.next=3;break}throw new Error("you should call loadResources() first");case 3:return ue=z.getSettings(),this.frameRate=ue.frameRate,this.virtual.setRect(ue.width,ue.height),_e.next=8,this.virtual.initVirtualParams({type:re,img:be});case 8:return this.setRect(ue.width,ue.height),this.mediaStream=new MediaStream,this.mediaStream.addTrack(z),this.videoVirtual.srcObject=this.mediaStream,_e.next=14,this.videoVirtual.play();case 14:return this.virtual.startVirtual(this.frameRate),_e.next=17,this.virtual.render();case 17:return this.originTrack=z,this.resultTrack=this.canvasVirtual.captureStream(this.frameRate||15).getVideoTracks()[0],this.setTrackParam({type:"virtual",originTrack:this.originTrack,resultTrack:this.resultTrack,param:{type:re,img:be}}),this.isVirualEnable=!0,_e.abrupt("return",this.resultTrack);case 22:case"end":return _e.stop()}},X,this)})),function(X){return ke.apply(this,arguments)})},{key:"replaceVirtualTrack",value:function(X){this.isVirualEnable&&(this.mediaStream.removeTrack(this.mediaStream.getVideoTracks()[0]),this.mediaStream.addTrack(X),this.originTrack=X)}},{key:"deleteSource",value:function(X){if(f.default){var se=f.default.beautyTrackMap.get(X);se&&(se.type==="mixed"&&this.deleteSource(se.originTrack.id),se.originTrack&&(se.originTrack.stop(),se.originTrack=null),se.beautyTrack&&(se.beautyTrack.stop(),se.beautyTrack=null),se.resultTrack&&(se.resultTrack.stop(),se.resultTrack=null),f.default.beautyTrackMap.delete(X))}}},{key:"draw",value:function(){this.videoBeauty&&this.videoBeauty.readyState===this.videoBeauty.HAVE_ENOUGH_DATA&&this.filter.apply(this.videoBeauty)}},{key:"enableVirtualBg",value:function(){var X;if(this.virtual&&!this.isVirualEnable)return this.virtual.setEnable(!0),this.virtual.render(),this.isVirualEnable=!0,(X=this.localStream)===null||X===void 0||X.replaceTrack(this.resultTrack),console.log("".concat(this.userId?"[userId: ".concat(this.userId,"]"):""," RTCBeautyPlugin enable.")),this.resultTrack}},{key:"disableVirtualBg",value:function(){var X;if(this.virtual&&this.isVirualEnable)return this.virtual.setEnable(!1),this.isVirualEnable=!1,(X=this.localStream)===null||X===void 0||X.replaceTrack(this.originTrack),console.log("".concat(this.userId?"[userId: ".concat(this.userId,"]"):""," RTCBeautyPlugin disable.")),this.originTrack}},{key:"changeType",value:function(X){var se=X.type,z=X.img;console.log("".concat(this.userId?"[userId: ".concat(this.userId,"]"):""," RTCBeautyPlugin changeType\uFF1A").concat(se,". img: ").concat(z,".")),se==="blur"&&(this.virtual.reset(),this.virtual.initVirtualParams({type:"blur"}),this.virtual.startVirtual(this.frameRate),this.virtual.render()),se==="virtual"&&(this.virtual.reset(),this.virtual.initVirtualParams({type:"virtual",img:z}),this.virtual.startVirtual(this.frameRate),this.virtual.render()),this.setTrackParam({type:se,originTrack:this.originTrack,resultTrack:this.resultTrack,param:{type:se,img:z}})}},{key:"render",value:function(){var X=this,se=new Date().getTime();se-this.startTime>1e3/this.frameRate&&(this.draw(),this.startTime=se),document.hidden?(clearTimeout(this.timeoutId),this.timeoutId=setTimeout(function(){X.render()},1e3/this.frameRate)):(this.timeoutId&&clearTimeout(this.timeoutId),this.rafId&&cancelAnimationFrame(this.rafId),this.rafId=requestAnimationFrame(this.render.bind(this)))}},{key:"setBeautyParam",value:function(X){var se=X.beauty,z=X.brightness,re=X.ruddy;Er(se)&&(this.beautyParams.beauty=se),Er(z)&&(this.beautyParams.brightness=z),Er(re)&&(this.beautyParams.ruddy=re),this.filter.setBeautyParams(this.beautyParams),this.getClose()&&!this.disableStatus&&this.disable(),!this.getClose()&&this.disableStatus&&this.enable()}},{key:"setRect",value:function(X,se){var z=X||640,re=se||480;this.videoBeauty.height=re,this.videoBeauty.width=z,this.canvasBeauty.height=re,this.canvasBeauty.width=z,this.videoVirtual.height=re,this.videoVirtual.width=z,this.canvasVirtual.height=re,this.canvasVirtual.width=z}},{key:"reset",value:function(){cancelAnimationFrame(this.rafId),clearTimeout(this.timeoutId),this.videoBeauty.pause(),this.filter.reset(),this.beautyTrack&&this.beautyTrack.stop(),this.videoVirtual.pause(),this.resultTrack&&this.resultTrack.stop(),this.originTrack&&this.originTrack.stop()}},{key:"destroy",value:function(){cancelAnimationFrame(this.rafId),clearTimeout(this.timeoutId),this.canvasBeauty&&(this.canvasBeauty.width=0,this.canvasBeauty.height=0,this.canvasBeauty.remove(),this.canvasBeauty=null),this.videoBeauty&&(this.videoBeauty.pause(),this.videoBeauty.removeAttribute("srcObject"),this.videoBeauty.removeAttribute("src"),this.videoBeauty.load(),this.videoBeauty.width=0,this.videoBeauty.height=0,this.videoBeauty.remove(),this.videoBeauty=null),this.beautyTrack&&(this.deleteSource(this.beautyTrack.id),this.beautyTrack.stop(),this.beautyTrack=null),this.originTrack&&(this.originTrack.stop(),this.originTrack=null),this.resultTrack&&(this.deleteSource(this.resultTrack.id),this.resultTrack.stop(),this.resultTrack=null),this.canvasVirtual&&(this.canvasVirtual.width=0,this.canvasVirtual.height=0,this.canvasVirtual.remove(),this.canvasVirtual=null),this.videoVirtual&&(this.videoVirtual.pause(),this.videoVirtual.removeAttribute("srcObject"),this.videoVirtual.removeAttribute("src"),this.videoVirtual.load(),this.videoVirtual.width=0,this.videoVirtual.height=0,this.videoVirtual.remove(),this.videoVirtual=null),this.virtual.destroy(),this.uninstallEvents()}},{key:"generateVideoTrackFromCanvasCapture",value:function(X){return this.canvasVirtual.captureStream(X).getVideoTracks()[0]}},{key:"setTrackParam",value:function(X){var se=X.type,z=X.originTrack,re=X.resultTrack,be=X.param;f.default&&(f.default.beautyTrackMap||(f.default.beautyTrackMap=new Map),f.default.beautyTrackMap.set(re.id,{type:se,originTrack:z,resultTrack:re,param:be,pluginInstance:this}))}},{key:"disable",value:function(){this.localStream&&this.originTrack&&(this.localStream.replaceTrack(this.originTrack),cancelAnimationFrame(this.rafId),clearTimeout(this.timeoutId),this.disableStatus=!0)}},{key:"enable",value:function(){this.localStream&&this.beautyTrack&&(this.localStream.replaceTrack(this.beautyTrack),this.render(),this.disableStatus=!1)}},{key:"installEvents",value:function(){document.addEventListener("visibilitychange",this.render.bind(this))}},{key:"uninstallEvents",value:function(){document.removeEventListener("visibilitychange",this.render.bind(this))}},{key:"overload",value:function(){this.onoverload&&this.onoverload()}},{key:"getClose",value:function(){return this.beautyParams.beauty===0&&this.beautyParams.brightness===0&&this.beautyParams.ruddy===0}}]),le}();return f.default&&(f.default.getRTCBeautyPlugin=function(){return new Ac}),Ac})});var KI="0.0.14";var md=sr(Cr());var pd=sr(Cr());var aw=sr(ng());var No=class extends aw.default{constructor({mediaType:f}){super();Ve(this,"trackMediaType");Ve(this,"_stream");Ve(this,"_playerState");this.trackMediaType=f}get isPlaying(){return this._playerState==="PLAYING"}async stop(){this._playerState="STOPPED",await this._stream.stop()}};var v7=1,Uo=class extends No{constructor(f){super(f);Ve(this,"TRTC",pd.default);Ve(this,"muted");Ve(this,"_publishedStream",null);Ve(this,"_log");this._log=Ft.createLogger({id:f.id+v7++})}get closed(){let f=this.getMediaStreamTrack();return f?f.readyState==="ended":!0}async init(){this._stream.on("device-auto-recovered",async({isMicrophone:f,isCamera:G,microphoneId:$,cameraId:H})=>{if(this._publishedStream&&this._stream!==this._publishedStream){let Q=this.getMediaStreamTrack(),Re=this.trackMediaType==="audio"?this._publishedStream.getAudioTrack():this._publishedStream.getVideoTrack();Q&&Re&&Q!==Re&&this._publishedStream.replaceTrack(Q)}if(f){let Q=(await pd.default.getMicrophones()).find(Re=>Re.deviceId===$);Q&&this.emit("device-switched",Q)}if(G){let Q=(await pd.default.getCameras()).find(Re=>Re.deviceId===H);Q&&this.emit("device-switched",Q)}}),this._stream.on("player-state-changed",({state:f})=>{this._playerState=f}),this._stream.on("error",f=>{f.getCode()===16452&&this.emit("track-ended",this.trackMediaType)}),await this._stream.initialize()}setPublishedStream(f){this._publishedStream=f}on(f,G){return super.on(f,G),this}async setMuted(f){let G=this._publishedStream||this._stream;this.trackMediaType==="audio"?f?G.muteAudio():G.unmuteAudio():f?G.muteVideo():G.unmuteVideo()}getMediaStreamTrack(){return this.trackMediaType==="audio"?this._stream.getAudioTrack():this._stream.getVideoTrack()}close(){this._stream.close()}getTrackLabel(){var f;return((f=this.getMediaStreamTrack())==null?void 0:f.label)||""}getDeviceId(){var f,G;return((G=(f=this.getMediaStreamTrack())==null?void 0:f.getSettings())==null?void 0:G.deviceId)||""}};var sw=sr(ow()),cw=sr(Cr());var Vo=class extends Uo{constructor(f){super(f);Ve(this,"mirrored",!1);Ve(this,"lastPlayContainer");Ve(this,"_beautyPlugin");Ve(this,"_virtualTrack");Ve(this,"_isVirtualEnable",!1);Ve(this,"_imageUrl",null);this.onOriginTrackEnded=this.onOriginTrackEnded.bind(this)}get _originTrack(){var f;return((f=this._beautyPlugin)==null?void 0:f.originTrack)||null}get videoElement(){var f;return((f=this.lastPlayContainer)==null?void 0:f.querySelector(`#video_${this._stream.getId()}`))||null}mirrorVideo(f){this.lastPlayContainer&&this._stream.play(this.lastPlayContainer,{mirror:f}),this.mirrored=f}async applyVirtualBackground(f){var G;if(this._log.info(`applyVirtualBackground ${f} ${this._imageUrl}`),!f)return this.stopVirtualBackground(),!0;if(f===this._imageUrl)return!0;if(this._beautyPlugin||(this._beautyPlugin=new sw.default,await this._beautyPlugin.virtual.loadResources(),this._beautyPlugin.virtual.onoverload=()=>{this._log.info("virtualBackground is onoverload"),this.emit("VirtualBackgroundOverload")}),this._imageUrl)f==="blur"&&this._imageUrl!=="blur"&&this._beautyPlugin.changeType({type:"blur"}),f!=="blur"&&this._imageUrl==="blur"&&this._beautyPlugin.changeType({type:"virtual",img:f}),f!=="blur"&&this._imageUrl!=="blur"&&this._imageUrl!==f&&await this._beautyPlugin.setBackground(f);else{let $=await this._beautyPlugin.generateVirtualStream({localStream:this._stream,type:f==="blur"?"blur":"virtual",img:f==="blur"?void 0:f});this._virtualTrack=$.getVideoTrack(),this._publishedStream&&this._publishedStream.replaceTrack(this._virtualTrack),this._isVirtualEnable=!0}return(G=this._originTrack)==null||G.addEventListener("ended",this.onOriginTrackEnded),this._imageUrl=f,!this._isVirtualEnable&&this._beautyPlugin&&(this._isVirtualEnable=!0,this._beautyPlugin.enableVirtualBg()),!0}async onOriginTrackEnded(){let f=(await cw.default.getCameras())[0];f?this.setDevice(f.deviceId):this.emit("track-ended",this.trackMediaType)}async stopVirtualBackground(){var f;return this._log.info("stopVirtualBackground is called"),this._beautyPlugin&&this._isVirtualEnable&&(this._log.info("RTCBeautyPlugin: call disableVirtualBackground"),this._beautyPlugin.disableVirtualBg(),this._isVirtualEnable=!1,(f=this._originTrack)==null||f.removeEventListener("ended",this.onOriginTrackEnded)),!0}getDeviceId(){var f,G;return this._isVirtualEnable||this._beautyPlugin?((G=(f=this._beautyPlugin.originTrack)==null?void 0:f.getSettings())==null?void 0:G.deviceId)||"":super.getDeviceId()}getMediaStreamTrack(){return this._originTrack&&(this._isVirtualEnable||this._beautyPlugin)?this._originTrack:super.getMediaStreamTrack()}close(){var f;(f=this._beautyPlugin)==null||f.destroy()}};var va=class extends Vo{constructor(f){var Re;super(dd(Jr({},f),{mediaType:"video"}));Ve(this,"_videoProfile",{width:320,height:240,frameRate:15,bitrate:300});let{width:G,height:$,frameRate:H,bitrate:Q}=f;Ft.info("new LingoCameraVideoTrack"),this._stream=md.default.createStream({audio:!1,video:!0,cameraId:f.cameraId}),G&&(this._videoProfile.width=G),$&&(this._videoProfile.height=$),H&&(this._videoProfile.frameRate=H),Q&&(this._videoProfile.bitrate=Q),this._stream.setVideoProfile(this._videoProfile),(Re=this._publishedStream)==null||Re.setVideoProfile(this._videoProfile)}getVideoProfile(){return this._videoProfile}async play(f){await this._stream.play(f.container,{mirror:this.mirrored}),this.lastPlayContainer=f.container}async stop(){await super.stop(),this.lastPlayContainer=null}async setDevice(f){var H,Q,Re,Ie;let G=this._beautyPlugin&&this._isVirtualEnable;if(this._log.info(`setDevice ${f} visual: ${G}`),G){let $e=md.default.createStream({audio:!1,video:!0,cameraId:f});$e.setVideoProfile(this._videoProfile),(H=this._publishedStream)==null||H.setVideoProfile(this._videoProfile),await $e.initialize();let Ct=$e.getVideoTrack();Ct&&((Q=this._originTrack)==null||Q.removeEventListener("ended",this.onOriginTrackEnded),await((Re=this._beautyPlugin)==null?void 0:Re.replaceVirtualTrack(Ct)),(Ie=this._originTrack)==null||Ie.addEventListener("ended",this.onOriginTrackEnded))}else if(await this._stream.switchDevice(this.trackMediaType,f),this._publishedStream&&this._publishedStream!==this._stream){let $e=this.getMediaStreamTrack();$e&&await this._publishedStream.replaceTrack($e)}let $=(await md.default.getCameras()).find($e=>$e.deviceId===f);$&&this.emit("device-switched",$),!this._isVirtualEnable&&this._beautyPlugin&&(this._beautyPlugin.destroy(),this._beautyPlugin=null,this._isVirtualEnable=!1,this._imageUrl=null)}close(){var f;(f=this.getMediaStreamTrack())==null||f.stop(),this._stream.hasAudio()||this._stream.close(),super.close()}};var uw=sr(Cr());var g7=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(te){let q=Math.random()*16|0;return(te=="x"?q:q&3|8).toString(16)})};function vd(){return!performance||!performance.now?Date.now():Math.floor(performance.now())}var ag=class{constructor(){this.intervalMap_=new Map}setInterval(q,f,G=!0){if(!window||!window.requestAnimationFrame)return setInterval(q,f);let $=g7(),H=vd(),Q=H;this.intervalMap_.set($,{rafId:null,timeoutId:null,onVisibilityChange:null});let Re=()=>{if(G&&document.hidden){if(q(),!this.intervalMap_.has($))return;let $e=setTimeout(Re,f);this.setTimeoutId($,$e),H=vd(),Q=H}else{if(Q=vd(),Q-H>=f&&(H=Q,q(),!this.intervalMap_.has($)))return;let $e=requestAnimationFrame(Re);this.setRafId($,$e)}},Ie=requestAnimationFrame(Re);if(this.setRafId($,Ie),G){let $e=()=>{if(document.hidden){let Ct=vd()-H;if(Ct>=f)Re();else{let Qe=setTimeout(Re,f-Ct);this.setTimeoutId($,Qe)}}};document.addEventListener("visibilitychange",$e),this.setOnVisibilityChange($,$e),document.hidden&&$e()}return $}clearInterval(q){if(this.intervalMap_.has(q)){let{rafId:f,timeoutId:G,onVisibilityChange:$}=this.intervalMap_.get(q);cancelAnimationFrame(f),clearTimeout(G),document.removeEventListener("visibilitychange",$),this.intervalMap_.delete(q)}}setTimeoutId(q,f){if(this.intervalMap_.has(q)){let G=this.intervalMap_.get(q);G.timeoutId&&clearTimeout(G.timeoutId),G.timeoutId=f}}setRafId(q,f){if(this.intervalMap_.has(q)){let G=this.intervalMap_.get(q);G.rafId&&cancelAnimationFrame(G.rafId),G.rafId=f}}setOnVisibilityChange(q,f){if(this.intervalMap_.has(q)){let G=this.intervalMap_.get(q);G.onVisibilityChange=f}}},_7=new ag,og=_7;var gd=class extends Vo{constructor(f){super({mediaType:"video",id:"cus"});Ve(this,"frameRate",0);Ve(this,"canvas",document.createElement("canvas"));Ve(this,"canvasCtx");Ve(this,"onDraw",null);Ve(this,"_cameraVideoTrack",null);Ve(this,"_timerId");this._cameraVideoTrack=f}timerStop(){og.clearInterval(this._timerId)}async init(){var $;if(this.canvasCtx)return;this.canvasCtx=this.canvas.getContext("2d");let f=($=this._cameraVideoTrack)==null?void 0:$.getMediaStreamTrack();if(f){let{width:H,height:Q,frameRate:Re}=f.getSettings();H&&(this.canvas.width=H),Q&&(this.canvas.height=Q),Re&&(this.frameRate=Re)}this._timerId=og.setInterval(()=>{var Re,Ie,$e;let H=(Re=this._cameraVideoTrack)==null?void 0:Re.getMediaStreamTrack();if(H){let{width:Ct,height:Qe,frameRate:cr}=H.getSettings();Ct&&(this.canvas.width=Ct),Qe&&(this.canvas.height=Qe),cr&&(this.frameRate=cr)}let Q=(Ie=this._cameraVideoTrack)==null?void 0:Ie.videoElement;Q&&(($e=this.canvasCtx)==null||$e.drawImage(Q,0,0,this.canvas.width,this.canvas.height),this.onDraw&&this.onDraw(this.canvas,this.mirrored))},1e3/this.frameRate,!0);let G=this.canvas.captureStream(this.frameRate).getVideoTracks()[0];this._stream=uw.default.createStream({videoSource:G}),await super.init()}async play(f){var G,$,H,Q;if(f.container){this.lastPlayContainer=f.container,(G=this._cameraVideoTrack)!=null&&G.isPlaying||await(($=this._cameraVideoTrack)==null?void 0:$.play({container:f.container}));let Re=(H=this._cameraVideoTrack)==null?void 0:H.videoElement;Re&&Re.parentElement&&(Re.parentElement.style.display="none"),await this._stream.play(f.container),this.mirrorVideo(this.mirrored)}(Q=f.custom)!=null&&Q.onDraw&&(this.onDraw=f.custom.onDraw)}async stop(){var G;this.onDraw=null;let f=(G=this._cameraVideoTrack)==null?void 0:G.videoElement;f&&f.parentElement&&(f.parentElement.style.display="block"),await this._stream.stop(),this.lastPlayContainer=null}setDevice(f){return Promise.resolve()}};var sg=sr(Cr());function _d(te){return te*1.5>100?100:te*1.5}var yd=class extends Uo{constructor({microphoneId:f}){super({mediaType:"audio"});Ve(this,"_captureVolume",100);Ve(this,"_div",document.createElement("div"));Ve(this,"_isPlayCalled",!1);Ft.info("new LingoMicrophoneAudioTrack"),this._stream=sg.default.createStream({audio:!0,video:!1,microphoneId:f})}async play(){return this._isPlayCalled=!0,await this._stream.play(this._div,{muted:!1})}stop(){return this._isPlayCalled=!1,super.stop()}setPublishedStream(f){var G;f===null?(G=this._publishedStream)==null||G.setAudioCaptureVolume(100):f.setAudioCaptureVolume(this._captureVolume),super.setPublishedStream(f)}async setDevice(f){if(Ft.warn(`switch mic ${f}`),f==="default"&&this._stream.isAudioRecovering_)return;if(await this._stream.switchDevice(this.trackMediaType,f),this._publishedStream&&this._publishedStream!==this._stream){let $=this.getMediaStreamTrack();$&&await this._publishedStream.replaceTrack($)}let G=(await sg.default.getMicrophones()).find($=>$.deviceId===f);G&&this.emit("device-switched",G)}setVolume(f){var G;(G=this._publishedStream)==null||G.setAudioCaptureVolume(f),this._captureVolume=f}getVolume(){return this._isPlayCalled||(this._isPlayCalled=!0,this._stream.play(this._div)),_d(this._stream.getAudioLevel()*100)}setSpeakerDevice(f){return this._stream.setAudioOutput(f)}close(){var f;(f=this.getMediaStreamTrack())==null||f.stop(),this._stream.hasAudio()||this._stream.close()}};var jo=class extends No{constructor({uid:f,mediaType:G,stream:$}){super({mediaType:G});Ve(this,"uid");Ve(this,"isSubscribed",!1);this.uid=f,this._stream=$,this._stream.on("player-state-changed",({state:H})=>{this._playerState=H})}subscribe(){this.isSubscribed=!0}unsubscribe(){this.isSubscribed=!1}};var bd=class extends jo{constructor({uid:q,stream:f}){super({uid:q,mediaType:"audio",stream:f})}setVolume(q){this._stream.setAudioVolume(q/100)}getVolume(){return _d(this._stream.getAudioLevel()*100)}setSpeakerDevice(q){return this._stream.setAudioOutput(q)}async play(){return this._stream.isPlaying()?Promise.resolve():this._stream.play(document.createElement("div"))}};var Sd=class extends jo{constructor({uid:f,stream:G}){super({uid:f,mediaType:"video",stream:G});Ve(this,"mirrored",!1);Ve(this,"lastPlayContainer")}async play(f){await this._stream.play(f.container),this.lastPlayContainer=f.container}async stop(){await super.stop(),this.lastPlayContainer=null}mirrorVideo(f){this.lastPlayContainer&&(this._stream.play(this.lastPlayContainer,{mirror:f}),this.mirrored=f)}};import{LingoBaseRTC as b7,LingoRTCError as dg}from"@lingoace/lingo-base-rtc";var cg=sr(Cr());import{LingoBaseRTCClient as y7,LingoRTCError as Bo,config as Ec}from"@lingoace/lingo-base-rtc";var kd=new WeakMap;function Td(){return function(te,q,f){let G=f.value,$=({fn:H,args:Q,context:Re,resolve:Ie,reject:$e})=>{H.apply(Re,Q).then(Ie,$e).finally(()=>{let Ct=kd.get(Re);Ct.shift(),Ct[0]&&$(Jr({},Ct[0]))})};return f.value=function(...H){return new Promise((Q,Re)=>{if(kd.has(this)){let Ie=kd.get(this),{length:$e}=Ie;Ie.push({fn:G,args:H,context:this,resolve:Q,reject:Re}),$e===0&&$({fn:G,args:H,context:this,resolve:Q,reject:Re})}else kd.set(this,[{fn:G,args:H,context:this,resolve:Q,reject:Re}]),$({fn:G,args:H,context:this,resolve:Q,reject:Re})})},f}}import{LingoRTCError as lw}from"@lingoace/lingo-base-rtc";function wn(te){return function(q,f,G){let $=G.value;return G.value=async function(...H){try{return await $.apply(this,H)}catch(Q){throw te?te(Q):Q instanceof lw?Q:lw.createOtherError(Q.message)}},G}}var Cn=class extends y7{constructor(){super(...arguments);Ve(this,"_client",null);Ve(this,"_localStream",null);Ve(this,"_screenStream",null);Ve(this,"_remoteAuxiliaryStream",null);Ve(this,"_remoteMainStreamMap",new Map);Ve(this,"_remoteUserIdSet",new Set);Ve(this,"_quality",{res:"0x0",vfps:0,vra:0,ara:0,rtt:0,pktLostRate:0,upQuality:0,downQuality:0});Ve(this,"_prevLocalVideoStat",null);Ve(this,"_prevLocalAudioStat",null)}getRemoteUsers(){let f=new Map;return this._remoteUserIdSet.forEach(G=>{f.set(G,{uid:G,hasAudio:!1,hasVideo:!1})}),this.remoteAudioTrackMap.forEach(G=>{if(f.has(G.uid)){let $=f.get(G.uid);$.hasAudio=!0,$.audioTrack=G.isSubscribed?G:void 0}else f.set(G.uid,{uid:G.uid,hasAudio:!0,hasVideo:!1,audioTrack:G.isSubscribed?G:void 0,videoTrack:void 0})}),this.remoteVideoTrackMap.forEach(G=>{let{uid:$}=G;if(f.has(G.uid)){let H=f.get(G.uid);H.hasVideo=!0,H.videoTrack=G.isSubscribed?G:void 0}else f.set($,{uid:$,hasAudio:!1,hasVideo:!0,audioTrack:void 0,videoTrack:G.isSubscribed?G:void 0})}),[...f.values()]}async join(f){return this._client=cg.default.createClient({sdkAppId:Number(f.appId),userId:f.uid,userSig:f.token,mode:"rtc",useStringRoomId:!0,autoSubscribe:!1,enableAutoPlayDialog:!1}),this.handleEvents(),await this._client.join({roomId:f.roomId}),this.joinParam=f,this.uid=f.uid,f.uid}async leave(){!this._client||(await this._client.leave(),this.joinParam=void 0,this._client=null)}start(){return Promise.resolve()}async publish(f){return this._localStream?(f instanceof va&&await this._localStream.setVideoProfile(f.getVideoProfile()),await this._localStream.addTrack(f.getMediaStreamTrack())):(await this._client.publish(f._stream),this._localStream=f._stream),f.setPublishedStream(this._localStream),this.localTracks.push(f),!0}async unpublish(f){var $;let G=f.getMediaStreamTrack();return!G||!this._localStream||this.localTracks.length===0||(this.localTracks.length===1?(await(($=this._client)==null?void 0:$.unpublish(this._localStream)),f.setPublishedStream(null),this._localStream=null,this.localTracks=[]):this.localTracks.find(H=>H===f)&&(await this._localStream.removeTrack(G),f.setPublishedStream(null),this.localTracks=this.localTracks.filter(H=>H!==f))),!0}async subscribe(f,G){var $,H;if(!this._client)throw Bo.createOtherError("\u7528\u6237\u672A\u8FDB\u623F\uFF0C\u65E0\u6CD5\u8BA2\u9605");if(G==="audio"&&!this.remoteAudioTrackMap.has(f))throw Bo.createOtherError(`\u8FDC\u7AEF\u7528\u6237: ${f} \u672A\u63A8\u97F3\u9891\uFF0C\u65E0\u6CD5\u8BA2\u9605`);if(G==="video"&&f!==Ec.screenSharingUid&&!this.remoteVideoTrackMap.has(f))throw Bo.createOtherError(`\u8FDC\u7AEF\u7528\u6237: ${f} \u672A\u63A8\u89C6\u9891\uFF0C\u65E0\u6CD5\u8BA2\u9605`);if(Ft.info(`subscribe ${f} ${G}`),f===Ec.screenSharingUid&&this._remoteAuxiliaryStream&&this._client)return await this._client.subscribe(this._remoteAuxiliaryStream),!0;if(G==="audio"){let Q=this.remoteAudioTrackMap.get(f);Q.subscribe();try{await this._client.subscribe(Q._stream,{audio:!0,video:!!(($=this.remoteVideoTrackMap.get(f))!=null&&$.isSubscribed)})}catch(Re){throw Q.unsubscribe(),Re}}else{let Q=this.remoteVideoTrackMap.get(f);Q.subscribe();try{await this._client.subscribe(Q._stream,{video:!0,audio:!!((H=this.remoteAudioTrackMap.get(f))!=null&&H.isSubscribed)})}catch(Re){throw Q.unsubscribe(),Re}}return!0}async unsubscribe(f,G){var H,Q;if(!this._client)throw Bo.createOtherError("\u7528\u6237\u672A\u8FDB\u623F\uFF0C\u65E0\u6CD5\u8BA2\u9605");Ft.info(`unsubscribe ${f} ${G}`);let $=null;if(G==="audio"&&this.remoteAudioTrackMap.has(f)?$=this.remoteAudioTrackMap.get(f):G==="video"&&this.remoteVideoTrackMap.has(f)&&($=this.remoteVideoTrackMap.get(f)),!$)throw Bo.createOtherError(`\u8FDC\u7AEF\u7528\u6237: ${f} \u672A\u63A8 ${G}\uFF0C\u65E0\u6CD5\u8BA2\u9605`);return f===Ec.screenSharingUid&&this._remoteAuxiliaryStream?(await this._client.unsubscribe(this._remoteAuxiliaryStream),!0):(G==="audio"?(H=this.remoteVideoTrackMap.get(f))!=null&&H.isSubscribed?await this._client.subscribe($._stream,{video:!0,audio:!1}):await this._client.unsubscribe($._stream):(Q=this.remoteAudioTrackMap.get(f))!=null&&Q.isSubscribed?await this._client.subscribe($._stream,{video:!1,audio:!0}):await this._client.unsubscribe($._stream),$.unsubscribe(),!0)}getQOEStats(){return this._quality}async startScreenShare(f){if(!this.joinParam||!this._client)throw Bo.createOtherError("\u7528\u6237\u672A\u8FDB\u623F\uFF0C\u65E0\u6CD5\u5F00\u542F\u5C4F\u5E55\u5206\u4EAB");this._screenStream=cg.default.createStream({screen:!0,screenAudio:!0});let G={width:1280,height:720,frameRate:15,bitrate:2e3};this._screenStream.setScreenProfile(Jr(Jr({},G),f)),this._screenStream.on("screen-sharing-stopped",async()=>{await this.stopScreenShare(),this.emit("ScreenSharingEnded")}),await this._screenStream.initialize(),await this._client.publish(this._screenStream,{isAuxiliary:!0})}async stopScreenShare(){!this._client||!this._screenStream||(await this._client.unpublish(this._screenStream),this._screenStream.stop(),this._screenStream.close(),this._screenStream=null)}async playScreenShareView(f){var G;this._remoteAuxiliaryStream&&this._client?(await this._client.subscribe(this._remoteAuxiliaryStream),await this._remoteAuxiliaryStream.play(f)):await((G=this._screenStream)==null?void 0:G.play(f))}async stopScreenShareView(){var f;this._remoteAuxiliaryStream&&this._client?(await this._client.unsubscribe(this._remoteAuxiliaryStream),await this._remoteAuxiliaryStream.stop()):await((f=this._screenStream)==null?void 0:f.stop())}handleEvents(){!this._client||(this._client.on("connection-state-changed",({prevState:f,state:G})=>{this.connectionState=G,this.emit("ConnectionStateChange",G,f,"")}),this._client.on("peer-join",f=>{this._remoteUserIdSet.add(f.userId),this.emit("UserJoined",f.userId)}),this._client.on("peer-leave",f=>{this._remoteUserIdSet.delete(f.userId),this.emit("UserLeft",f.userId)}),this._client.on("stream-added",f=>{let G=f.stream,$=G.getUserId();if(G.getType()==="auxiliary"){this._remoteAuxiliaryStream=G,this.emit("RemoteScreenSharing",Ec.screenSharingUid,!0,"video");return}this._remoteMainStreamMap.set($,G),G.on("error",H=>{if(H.getCode()===16451){let Q=()=>{G.resume().then(()=>{document.body.removeEventListener("click",Q),document.body.removeEventListener("touchstart",Q)})};document.body.addEventListener("click",Q,!0),document.body.addEventListener("touchstart",Q,!0),this.emit("AutoplayFailed")}}),G.hasAudio()&&this.handleUserPublished($,"audio"),G.hasVideo()&&this.handleUserPublished($,"video")}),this._client.on("stream-updated",f=>{let G=f.stream,$=G.getUserId();!this.remoteAudioTrackMap.has($)&&G.hasAudio()&&this.handleUserPublished($,"audio"),this.remoteAudioTrackMap.has($)&&!G.hasAudio()&&this.handleUserUnpublished($,"audio"),!this.remoteVideoTrackMap.has($)&&G.hasVideo()&&this.handleUserPublished($,"video"),this.remoteVideoTrackMap.has($)&&!G.hasVideo()&&this.handleUserUnpublished($,"video")}),this._client.on("stream-removed",f=>{let G=f.stream.getUserId();if(f.stream.getType()==="auxiliary"){this._remoteAuxiliaryStream=null,this.emit("RemoteScreenSharing",Ec.screenSharingUid,!1,"video");return}this._remoteMainStreamMap.delete(G),this.handleUserUnpublished(G,"audio"),this.handleUserUnpublished(G,"video")}),this._client.on("network-quality",f=>{var G,$;this._quality.upQuality=f.uplinkNetworkQuality,this._quality.downQuality=f.downlinkNetworkQuality,this._quality.rtt=f.uplinkRTT,this._quality.pktLostRate=f.uplinkLoss,(G=this._client)==null||G.getLocalVideoStats().then(H=>{let Q=H[this.uid];Q&&(this._quality.res=`${Q.frameWidth}x${Q.frameHeight}`,this._prevLocalVideoStat&&(this._quality.vfps=Math.floor((Q.framesSent-this._prevLocalVideoStat.framesSent)/2)||0,this._quality.vra=Math.floor((Q.bytesSent-this._prevLocalVideoStat.bytesSent)*8/2)||0),this._prevLocalVideoStat=Q)}),($=this._client)==null||$.getLocalAudioStats().then(H=>{let Q=H[this.uid];Q&&(this._prevLocalAudioStat&&(this._quality.ara=Math.floor((Q.bytesSent-this._prevLocalAudioStat.bytesSent)*8/2)||0),this._prevLocalAudioStat=Q)}),this.emit("NetworkQuality",f)}),this._client.on("mute-audio",f=>{this.handleUserUnpublished(f.userId,"audio")}),this._client.on("unmute-audio",f=>{this.handleUserPublished(f.userId,"audio",!0)}))}handleUserUnpublished(f,G){Ft.info(`UserUnpublished ${f} ${G}`),G==="audio"?this.remoteAudioTrackMap.has(f)&&(this.remoteAudioTrackMap.delete(f),this.emit("UserUnpublished",f,G)):this.remoteVideoTrackMap.has(f)&&(this.remoteVideoTrackMap.delete(f),this.emit("UserUnpublished",f,G))}handleUserPublished(f,G,$=!1){var Re;Ft.info(`UserPublished ${f} ${G} firedByUnmute: ${$}`);let H=this._remoteMainStreamMap.get(f),Q=(Re=this._client)==null?void 0:Re.getRemoteMutedState().find(Ie=>Ie.userId===f);if(H){if(G==="audio"&&!this.remoteAudioTrackMap.has(f)&&H.hasAudio()){if(!$&&Q&&Q.audioMuted)return;let Ie=new bd({uid:f,stream:H});this.remoteAudioTrackMap.set(f,Ie)}else if(G==="video"&&!this.remoteVideoTrackMap.has(f)&&H.hasVideo()){let Ie=new Sd({uid:f,stream:H});this.remoteVideoTrackMap.set(f,Ie)}this.emit("UserPublished",f,G)}}};In([wn(),Td()],Cn.prototype,"publish",1),In([wn()],Cn.prototype,"unpublish",1),In([wn()],Cn.prototype,"subscribe",1),In([wn()],Cn.prototype,"unsubscribe",1),In([wn()],Cn.prototype,"startScreenShare",1),In([wn()],Cn.prototype,"stopScreenShare",1),In([wn()],Cn.prototype,"playScreenShareView",1),In([wn()],Cn.prototype,"stopScreenShareView",1);var Ho=sr(Cr());var dw=sr(ng()),ug=sr(Cr());var lg=class extends dw.default{constructor(){super();Ve(this,"prevDevices_",[]);navigator.mediaDevices&&(this.onDeviceChange=this.onDeviceChange.bind(this),navigator.mediaDevices.addEventListener("devicechange",this.onDeviceChange))}async init(){this.prevDevices_=await ug.default.getDevices()}async onDeviceChange(){let f=await ug.default.getDevices(),G=f.filter(H=>this.prevDevices_.findIndex(({deviceId:Q})=>H.deviceId===Q)<0),$=this.prevDevices_.filter(H=>f.findIndex(({deviceId:Q})=>H.deviceId===Q)<0);G.length>0&&G.forEach(H=>{this.emit("device-added",H)}),$.length>0&&$.forEach(H=>{this.emit("device-removed",H)}),this.prevDevices_=f}destroy(){navigator.mediaDevices.removeEventListener("devicechange",this.onDeviceChange)}},hw=lg;var Ft=Ho.default.Logger.loggerManager,Fo=class extends b7{constructor(){super(...arguments);Ve(this,"version",KI);Ve(this,"_deviceDetector",new hw);Ve(this,"_virtualOverloadCount",0);Ve(this,"_isVirtualOverloadStart",0)}init(f){return Ft.info(`lingo-trtc version: ${this.version}`),Promise.resolve()}release(){this._deviceDetector.destroy(),super.release()}async checkSystemRequirements(){let{result:f}=await Ho.default.checkSystemRequirements();return f&&Ho.default.isScreenShareSupported()}async createClient(){return this.client=new Cn,await this._deviceDetector.init(),this._deviceDetector.on("device-added",f=>{f.kind==="videoinput"?this.client.emit("CameraChanged",!0,f):f.kind==="audioinput"?this.client.emit("MicrophoneChanged",!0,f):f.kind==="audiooutput"&&this.client.emit("SpeakerDeviceChanged",!0,f)}),this._deviceDetector.on("device-removed",async f=>{var G,$;if(f.kind==="videoinput"){let H=this.cameraVideoTrack||this.previewVideoTrack;if(f.deviceId===(H==null?void 0:H.getDeviceId())){if((await Ho.default.getCameras()).length===0){this.client.emit("CameraChanged",!1,f);return}H.once("device-switched",()=>{this.client.emit("CameraChanged",!1,f)}),H.once("track-ended",()=>{this.client.emit("CameraChanged",!1,f)})}else this.client.emit("CameraChanged",!1,f)}else if(f.kind==="audioinput")if(f.deviceId===((G=this.microphoneAudioTrack)==null?void 0:G.getDeviceId())){if((await Ho.default.getMicrophones()).length===0){this.client.emit("CameraChanged",!1,f);return}this.microphoneAudioTrack.once("device-switched",()=>{this.client.emit("CameraChanged",!1,f)}),($=this.microphoneAudioTrack)==null||$.once("track-ended",()=>{this.client.emit("CameraChanged",!1,f)})}else this.client.emit("MicrophoneChanged",!1,f);else f.kind==="audiooutput"&&this.client.emit("SpeakerDeviceChanged",!1,f)}),this.client}async createCustomVideoTrack(f){if(this.customVideoTrack&&!this.customVideoTrack.closed)return this.customVideoTrack;Ft.info("createCustomVideoTrack");let G=new gd(f);return await G.init(),this.customVideoTrack=G,G}async detectCamera(f){var G,$;if(this.previewVideoTrack&&!this.previewVideoTrack.closed)return{checkIsActive:()=>{var H,Q;return Promise.resolve(((Q=(H=this.previewVideoTrack)==null?void 0:H.getMediaStreamTrack())==null?void 0:Q.readyState)==="live")},cleanup:()=>{var H,Q;(H=this.previewVideoTrack)==null||H.stop(),(Q=this.previewVideoTrack)==null||Q.close(),this.previewVideoTrack=void 0}};Ft.info("detectCamera");try{let H=new va({cameraId:f.cameraId,id:"pv"});return H.on("device-switched",Q=>this.client.emit("DeviceSwitched",Q)),this.previewVideoTrack=H,await H.init(),f.mirror&&H.mirrorVideo(f.mirror),f.container&&await H.play({container:f.container}),{checkIsActive:()=>{var Q;return Promise.resolve(((Q=H.getMediaStreamTrack())==null?void 0:Q.readyState)==="live")},cleanup:()=>{H.stop(),H.close(),this.previewVideoTrack=void 0}}}catch(H){throw(G=this.previewVideoTrack)==null||G.stop(),($=this.previewVideoTrack)==null||$.close(),this.previewVideoTrack=void 0,H}}processExternalMediaAEC(f){}async createMicrophoneAudioTrack(f){if(this.microphoneAudioTrack&&!this.microphoneAudioTrack.closed)return this.microphoneAudioTrack;Ft.info("createMicrophoneAudioTrack");let G=new yd({microphoneId:f});return G.on("device-switched",$=>this.client.emit("DeviceSwitched",$)),await G.init(),this.microphoneAudioTrack=G,this.client.emit("LocalTrackCreated",G),G}async createCameraVideoTrack(f){if(this.cameraVideoTrack&&!this.cameraVideoTrack.closed)return this.cameraVideoTrack;Ft.info(`createCameraVideoTrack ${JSON.stringify(f)}`);let G=new va(dd(Jr({},f),{id:"ct"}));return G.on("device-switched",$=>this.client.emit("DeviceSwitched",$)),await G.init(),this.cameraVideoTrack=G,this.client.emit("LocalTrackCreated",G),this.cameraVideoTrack.on("VirtualBackgroundOverload",()=>{this._virtualOverloadCount++,Ft.warn(`VirtualBackground overload count is: ${this._virtualOverloadCount}`),new Date().getTime()-this._isVirtualOverloadStart>5e3&&(this._virtualOverloadCount>10&&(Ft.warn("VirtualBackgroundOverload"),this.client.emit("VirtualBackgroundOverload")),this._virtualOverloadCount=0,this._isVirtualOverloadStart=new Date().getTime())}),G}};In([Td(),wn(te=>dg.createRTCError(te))],Fo.prototype,"detectCamera",1),In([wn(te=>dg.createRTCError(te))],Fo.prototype,"createMicrophoneAudioTrack",1),In([wn(te=>dg.createRTCError(te))],Fo.prototype,"createCameraVideoTrack",1);var G9=Fo;export{G9 as default,Ft as loggerManager};
585
549
  /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */