trtc-sdk-v5 5.10.1-beta.8 → 5.10.1-beta.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/plugins/cdn-streaming/package.json +1 -1
- package/plugins/cross-room/package.json +1 -1
- package/plugins/custom-encryption/package.json +1 -1
- package/plugins/device-detector/package.json +1 -1
- package/plugins/video-decoder/package.json +1 -1
- package/plugins/video-effect/basic-beauty/package.json +1 -1
- package/plugins/video-effect/beauty/package.json +1 -1
- package/plugins/video-effect/virtual-background/package.json +1 -1
- package/plugins/video-effect/watermark/package.json +1 -1
- package/plugins/voice-changer/package.json +1 -1
- package/trtc.es5.js +1 -1
- package/trtc.esm.js +2 -2
- package/trtc.js +1 -1
package/trtc.es5.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).TRTC=t()}(this,(function(){function e(e,t){return t.forEach((function(t){t&&"string"!=typeof t&&!Array.isArray(t)&&Object.keys(t).forEach((function(n){if("default"!==n&&!(n in e)){var r=Object.getOwnPropertyDescriptor(t,n);Object.defineProperty(e,n,r.get?r:{enumerable:!0,get:function(){return t[n]}})}}))})),Object.freeze(e)}function t(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function n(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function r(e,t,n){return t=l(t),f(e,h()?Reflect.construct(t,n||[],l(e).constructor):t.apply(e,n))}function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e,t,n){if(h())return Reflect.construct.apply(null,arguments);var r=[null];r.push.apply(r,t);var i=new(e.bind.apply(e,r));return n&&v(i,n.prototype),i}function a(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,k(r.key),r)}}function s(e,t,n){return t&&a(e.prototype,t),n&&a(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}function c(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=I(e))||t&&e&&"number"==typeof e.length){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(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,a=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return a=e.done,e},e:function(e){s=!0,o=e},f:function(){try{a||null==n.return||n.return()}finally{if(s)throw o}}}}function u(){return u="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(e,t,n){var r=g(e,t);if(r){var i=Object.getOwnPropertyDescriptor(r,t);return i.get?i.get.call(arguments.length<3?e:n):i.value}},u.apply(null,arguments)}function l(e){return l=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},l(e)}function d(e,t){if("function"!=typeof t&&null!==t)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&&v(e,t)}function h(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return(h=function(){return!!e})()}function f(e,t){if(t&&("object"==typeof t||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return n(e)}function p(){p=function(){return t};var e,t={},n=Object.prototype,r=n.hasOwnProperty,i=Object.defineProperty||function(e,t,n){e[t]=n.value},o="function"==typeof Symbol?Symbol:{},a=o.iterator||"@@iterator",s=o.asyncIterator||"@@asyncIterator",c=o.toStringTag||"@@toStringTag";function u(e,t,n){return Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{u({},"")}catch(e){u=function(e,t,n){return e[t]=n}}function l(e,t,n,r){var o=t&&t.prototype instanceof g?t:g,a=Object.create(o.prototype),s=new N(r||[]);return i(a,"_invoke",{value:R(e,n,s)}),a}function d(e,t,n){try{return{type:"normal",arg:e.call(t,n)}}catch(e){return{type:"throw",arg:e}}}t.wrap=l;var h="suspendedStart",f="suspendedYield",m="executing",v="completed",_={};function g(){}function y(){}function E(){}var T={};u(T,a,(function(){return this}));var k=Object.getPrototypeOf,S=k&&k(k(x([])));S&&S!==n&&r.call(S,a)&&(T=S);var I=E.prototype=g.prototype=Object.create(T);function b(e){["next","throw","return"].forEach((function(t){u(e,t,(function(e){return this._invoke(t,e)}))}))}function A(e,t){function n(i,o,a,s){var c=d(e[i],e,o);if("throw"!==c.type){var u=c.arg,l=u.value;return l&&"object"==typeof l&&r.call(l,"__await")?t.resolve(l.__await).then((function(e){n("next",e,a,s)}),(function(e){n("throw",e,a,s)})):t.resolve(l).then((function(e){u.value=e,a(u)}),(function(e){return n("throw",e,a,s)}))}s(c.arg)}var o;i(this,"_invoke",{value:function(e,r){function i(){return new t((function(t,i){n(e,r,t,i)}))}return o=o?o.then(i,i):i()}})}function R(t,n,r){var i=h;return function(o,a){if(i===m)throw Error("Generator is already running");if(i===v){if("throw"===o)throw a;return{value:e,done:!0}}for(r.method=o,r.arg=a;;){var s=r.delegate;if(s){var c=C(s,r);if(c){if(c===_)continue;return c}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if(i===h)throw i=v,r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);i=m;var u=d(t,n,r);if("normal"===u.type){if(i=r.done?v:f,u.arg===_)continue;return{value:u.arg,done:r.done}}"throw"===u.type&&(i=v,r.method="throw",r.arg=u.arg)}}}function C(t,n){var r=n.method,i=t.iterator[r];if(i===e)return n.delegate=null,"throw"===r&&t.iterator.return&&(n.method="return",n.arg=e,C(t,n),"throw"===n.method)||"return"!==r&&(n.method="throw",n.arg=new TypeError("The iterator does not provide a '"+r+"' method")),_;var o=d(i,t.iterator,n.arg);if("throw"===o.type)return n.method="throw",n.arg=o.arg,n.delegate=null,_;var a=o.arg;return a?a.done?(n[t.resultName]=a.value,n.next=t.nextLoc,"return"!==n.method&&(n.method="next",n.arg=e),n.delegate=null,_):a:(n.method="throw",n.arg=new TypeError("iterator result is not an object"),n.delegate=null,_)}function w(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function D(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function N(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(w,this),this.reset(!0)}function x(t){if(t||""===t){var n=t[a];if(n)return n.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var i=-1,o=function n(){for(;++i<t.length;)if(r.call(t,i))return n.value=t[i],n.done=!1,n;return n.value=e,n.done=!0,n};return o.next=o}}throw new TypeError(typeof t+" is not iterable")}return y.prototype=E,i(I,"constructor",{value:E,configurable:!0}),i(E,"constructor",{value:y,configurable:!0}),y.displayName=u(E,c,"GeneratorFunction"),t.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===y||"GeneratorFunction"===(t.displayName||t.name))},t.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,E):(e.__proto__=E,u(e,c,"GeneratorFunction")),e.prototype=Object.create(I),e},t.awrap=function(e){return{__await:e}},b(A.prototype),u(A.prototype,s,(function(){return this})),t.AsyncIterator=A,t.async=function(e,n,r,i,o){void 0===o&&(o=Promise);var a=new A(l(e,n,r,i),o);return t.isGeneratorFunction(n)?a:a.next().then((function(e){return e.done?e.value:a.next()}))},b(I),u(I,c,"Generator"),u(I,a,(function(){return this})),u(I,"toString",(function(){return"[object Generator]"})),t.keys=function(e){var t=Object(e),n=[];for(var r in t)n.push(r);return n.reverse(),function e(){for(;n.length;){var r=n.pop();if(r in t)return e.value=r,e.done=!1,e}return e.done=!0,e}},t.values=x,N.prototype={constructor:N,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=e,this.done=!1,this.delegate=null,this.method="next",this.arg=e,this.tryEntries.forEach(D),!t)for(var n in this)"t"===n.charAt(0)&&r.call(this,n)&&!isNaN(+n.slice(1))&&(this[n]=e)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var n=this;function i(r,i){return s.type="throw",s.arg=t,n.next=r,i&&(n.method="next",n.arg=e),!!i}for(var o=this.tryEntries.length-1;o>=0;--o){var a=this.tryEntries[o],s=a.completion;if("root"===a.tryLoc)return i("end");if(a.tryLoc<=this.prev){var c=r.call(a,"catchLoc"),u=r.call(a,"finallyLoc");if(c&&u){if(this.prev<a.catchLoc)return i(a.catchLoc,!0);if(this.prev<a.finallyLoc)return i(a.finallyLoc)}else if(c){if(this.prev<a.catchLoc)return i(a.catchLoc,!0)}else{if(!u)throw Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return i(a.finallyLoc)}}}},abrupt:function(e,t){for(var n=this.tryEntries.length-1;n>=0;--n){var i=this.tryEntries[n];if(i.tryLoc<=this.prev&&r.call(i,"finallyLoc")&&this.prev<i.finallyLoc){var o=i;break}}o&&("break"===e||"continue"===e)&&o.tryLoc<=t&&t<=o.finallyLoc&&(o=null);var a=o?o.completion:{};return a.type=e,a.arg=t,o?(this.method="next",this.next=o.finallyLoc,_):this.complete(a)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),_},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.finallyLoc===e)return this.complete(n.completion,n.afterLoc),D(n),_}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc===e){var r=n.completion;if("throw"===r.type){var i=r.arg;D(n)}return i}}throw Error("illegal catch attempt")},delegateYield:function(t,n,r){return this.delegate={iterator:x(t),resultName:n,nextLoc:r},"next"===this.method&&(this.arg=e),_}},t}function m(e,t,n,r){return m="undefined"!=typeof Reflect&&Reflect.set?Reflect.set:function(e,t,n,r){var i,o=g(e,t);if(o){if((i=Object.getOwnPropertyDescriptor(o,t)).set)return i.set.call(r,n),!0;if(!i.writable)return!1}if(i=Object.getOwnPropertyDescriptor(r,t)){if(!i.writable)return!1;i.value=n,Object.defineProperty(r,t,i)}else!function(e,t,n){(t=k(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n}(r,t,n);return!0},m(e,t,n,r)}function v(e,t){return v=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},v(e,t)}function _(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,i,o,a,s=[],c=!0,u=!1;try{if(o=(n=n.call(e)).next,0===t){if(Object(n)!==n)return;c=!1}else for(;!(c=(r=o.call(n)).done)&&(s.push(r.value),s.length!==t);c=!0);}catch(e){u=!0,i=e}finally{try{if(!c&&null!=n.return&&(a=n.return(),Object(a)!==a))return}finally{if(u)throw i}}return s}}(e,t)||I(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function g(e,t){for(;!{}.hasOwnProperty.call(e,t)&&null!==(e=l(e)););return e}function y(e,t,n,r){var i=u(l(1&r?e.prototype:e),t,n);return 2&r&&"function"==typeof i?function(e){return i.apply(n,e)}:i}function E(e,t,n,r,i,o){return function(e,t,n,r,i){if(!m(e,t,n,r||e)&&i)throw new TypeError("failed to set property");return n}(l(o?e.prototype:e),t,n,r,i)}function T(e){return function(e){if(Array.isArray(e))return t(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||I(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function k(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t||"default");if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}function S(e){return S="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},S(e)}function I(e,n){if(e){if("string"==typeof e)return t(e,n);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?t(e,n):void 0}}function b(e){var t="function"==typeof Map?new Map:void 0;return b=function(e){if(null===e||!function(e){try{return-1!==Function.toString.call(e).indexOf("[native code]")}catch(hB){return"function"==typeof e}}(e))return e;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,n)}function n(){return o(e,arguments,l(this).constructor)}return n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),v(n,e)},b(e)}var A="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},R=function(e){return e&&e.Math===Math&&e},C=R("object"==typeof globalThis&&globalThis)||R("object"==typeof window&&window)||R("object"==typeof self&&self)||R("object"==typeof A&&A)||R("object"==typeof A&&A)||function(){return this}()||Function("return this")(),w={},D=function(e){try{return!!e()}catch(t){return!0}},N=!D((function(){return 7!==Object.defineProperty({},1,{get:function(){return 7}})[1]})),x=!D((function(){var e=function(){}.bind();return"function"!=typeof e||e.hasOwnProperty("prototype")})),O=x,P=Function.prototype.call,M=O?P.bind(P):function(){return P.apply(P,arguments)},L={},V={}.propertyIsEnumerable,U=Object.getOwnPropertyDescriptor,F=U&&!V.call({1:2},1);L.f=F?function(e){var t=U(this,e);return!!t&&t.enumerable}:V;var B,H,j=function(e,t){return{enumerable:!(1&e),configurable:!(2&e),writable:!(4&e),value:t}},G=x,W=Function.prototype,J=W.call,K=G&&W.bind.bind(J,J),z=G?K:function(e){return function(){return J.apply(e,arguments)}},q=z,Y=q({}.toString),X=q("".slice),Q=function(e){return X(Y(e),8,-1)},$=D,Z=Q,ee=Object,te=z("".split),ne=$((function(){return!ee("z").propertyIsEnumerable(0)}))?function(e){return"String"===Z(e)?te(e,""):ee(e)}:ee,re=function(e){return null==e},ie=re,oe=TypeError,ae=function(e){if(ie(e))throw new oe("Can't call method on "+e);return e},se=ne,ce=ae,ue=function(e){return se(ce(e))},le="object"==typeof document&&document.all,de=void 0===le&&void 0!==le?function(e){return"function"==typeof e||e===le}:function(e){return"function"==typeof e},he=de,fe=function(e){return"object"==typeof e?null!==e:he(e)},pe=C,me=de,ve=function(e,t){return arguments.length<2?(n=pe[e],me(n)?n:void 0):pe[e]&&pe[e][t];var n},_e=z({}.isPrototypeOf),ge=C.navigator,ye=ge&&ge.userAgent,Ee=ye?String(ye):"",Te=C,ke=Ee,Se=Te.process,Ie=Te.Deno,be=Se&&Se.versions||Ie&&Ie.version,Ae=be&&be.v8;Ae&&(H=(B=Ae.split("."))[0]>0&&B[0]<4?1:+(B[0]+B[1])),!H&&ke&&(!(B=ke.match(/Edge\/(\d+)/))||B[1]>=74)&&(B=ke.match(/Chrome\/(\d+)/))&&(H=+B[1]);var Re=H,Ce=Re,we=D,De=C.String,Ne=!!Object.getOwnPropertySymbols&&!we((function(){var e=Symbol("symbol detection");return!De(e)||!(Object(e)instanceof Symbol)||!Symbol.sham&&Ce&&Ce<41})),xe=Ne&&!Symbol.sham&&"symbol"==typeof Symbol.iterator,Oe=ve,Pe=de,Me=_e,Le=Object,Ve=xe?function(e){return"symbol"==typeof e}:function(e){var t=Oe("Symbol");return Pe(t)&&Me(t.prototype,Le(e))},Ue=String,Fe=function(e){try{return Ue(e)}catch(t){return"Object"}},Be=de,He=Fe,je=TypeError,Ge=function(e){if(Be(e))return e;throw new je(He(e)+" is not a function")},We=Ge,Je=re,Ke=function(e,t){var n=e[t];return Je(n)?void 0:We(n)},ze=M,qe=de,Ye=fe,Xe=TypeError,Qe={},$e={get exports(){return Qe},set exports(e){Qe=e}},Ze=C,et=Object.defineProperty,tt=function(e,t){try{et(Ze,e,{value:t,configurable:!0,writable:!0})}catch(n){Ze[e]=t}return t},nt=C,rt=tt,it="__core-js_shared__",ot=$e.exports=nt[it]||rt(it,{});(ot.versions||(ot.versions=[])).push({version:"3.38.1",mode:"global",copyright:"© 2014-2024 Denis Pushkarev (zloirock.ru)",license:"https://github.com/zloirock/core-js/blob/v3.38.1/LICENSE",source:"https://github.com/zloirock/core-js"});var at=Qe,st=function(e,t){return at[e]||(at[e]=t||{})},ct=ae,ut=Object,lt=function(e){return ut(ct(e))},dt=lt,ht=z({}.hasOwnProperty),ft=Object.hasOwn||function(e,t){return ht(dt(e),t)},pt=z,mt=0,vt=Math.random(),_t=pt(1..toString),gt=function(e){return"Symbol("+(void 0===e?"":e)+")_"+_t(++mt+vt,36)},yt=st,Et=ft,Tt=gt,kt=Ne,St=xe,It=C.Symbol,bt=yt("wks"),At=St?It.for||It:It&&It.withoutSetter||Tt,Rt=function(e){return Et(bt,e)||(bt[e]=kt&&Et(It,e)?It[e]:At("Symbol."+e)),bt[e]},Ct=M,wt=fe,Dt=Ve,Nt=Ke,xt=function(e,t){var n,r;if("string"===t&&qe(n=e.toString)&&!Ye(r=ze(n,e)))return r;if(qe(n=e.valueOf)&&!Ye(r=ze(n,e)))return r;if("string"!==t&&qe(n=e.toString)&&!Ye(r=ze(n,e)))return r;throw new Xe("Can't convert object to primitive value")},Ot=TypeError,Pt=Rt("toPrimitive"),Mt=function(e,t){if(!wt(e)||Dt(e))return e;var n,r=Nt(e,Pt);if(r){if(void 0===t&&(t="default"),n=Ct(r,e,t),!wt(n)||Dt(n))return n;throw new Ot("Can't convert object to primitive value")}return void 0===t&&(t="number"),xt(e,t)},Lt=Mt,Vt=Ve,Ut=function(e){var t=Lt(e,"string");return Vt(t)?t:t+""},Ft=fe,Bt=C.document,Ht=Ft(Bt)&&Ft(Bt.createElement),jt=function(e){return Ht?Bt.createElement(e):{}},Gt=jt,Wt=!N&&!D((function(){return 7!==Object.defineProperty(Gt("div"),"a",{get:function(){return 7}}).a})),Jt=N,Kt=M,zt=L,qt=j,Yt=ue,Xt=Ut,Qt=ft,$t=Wt,Zt=Object.getOwnPropertyDescriptor;w.f=Jt?Zt:function(e,t){if(e=Yt(e),t=Xt(t),$t)try{return Zt(e,t)}catch(n){}if(Qt(e,t))return qt(!Kt(zt.f,e,t),e[t])};var en={},tn=N&&D((function(){return 42!==Object.defineProperty((function(){}),"prototype",{value:42,writable:!1}).prototype})),nn=fe,rn=String,on=TypeError,an=function(e){if(nn(e))return e;throw new on(rn(e)+" is not an object")},sn=N,cn=Wt,un=tn,ln=an,dn=Ut,hn=TypeError,fn=Object.defineProperty,pn=Object.getOwnPropertyDescriptor,mn="enumerable",vn="configurable",_n="writable";en.f=sn?un?function(e,t,n){if(ln(e),t=dn(t),ln(n),"function"==typeof e&&"prototype"===t&&"value"in n&&_n in n&&!n[_n]){var r=pn(e,t);r&&r[_n]&&(e[t]=n.value,n={configurable:vn in n?n[vn]:r[vn],enumerable:mn in n?n[mn]:r[mn],writable:!1})}return fn(e,t,n)}:fn:function(e,t,n){if(ln(e),t=dn(t),ln(n),cn)try{return fn(e,t,n)}catch(r){}if("get"in n||"set"in n)throw new hn("Accessors not supported");return"value"in n&&(e[t]=n.value),e};var gn=en,yn=j,En=N?function(e,t,n){return gn.f(e,t,yn(1,n))}:function(e,t,n){return e[t]=n,e},Tn={},kn={get exports(){return Tn},set exports(e){Tn=e}},Sn=N,In=ft,bn=Function.prototype,An=Sn&&Object.getOwnPropertyDescriptor,Rn=In(bn,"name"),Cn={EXISTS:Rn,PROPER:Rn&&"something"===function(){}.name,CONFIGURABLE:Rn&&(!Sn||Sn&&An(bn,"name").configurable)},wn=de,Dn=Qe,Nn=z(Function.toString);wn(Dn.inspectSource)||(Dn.inspectSource=function(e){return Nn(e)});var xn,On,Pn,Mn=Dn.inspectSource,Ln=de,Vn=C.WeakMap,Un=Ln(Vn)&&/native code/.test(String(Vn)),Fn=gt,Bn=st("keys"),Hn=function(e){return Bn[e]||(Bn[e]=Fn(e))},jn={},Gn=Un,Wn=C,Jn=fe,Kn=En,zn=ft,qn=Qe,Yn=Hn,Xn=jn,Qn="Object already initialized",$n=Wn.TypeError,Zn=Wn.WeakMap;if(Gn||qn.state){var er=qn.state||(qn.state=new Zn);er.get=er.get,er.has=er.has,er.set=er.set,xn=function(e,t){if(er.has(e))throw new $n(Qn);return t.facade=e,er.set(e,t),t},On=function(e){return er.get(e)||{}},Pn=function(e){return er.has(e)}}else{var tr=Yn("state");Xn[tr]=!0,xn=function(e,t){if(zn(e,tr))throw new $n(Qn);return t.facade=e,Kn(e,tr,t),t},On=function(e){return zn(e,tr)?e[tr]:{}},Pn=function(e){return zn(e,tr)}}var nr={set:xn,get:On,has:Pn,enforce:function(e){return Pn(e)?On(e):xn(e,{})},getterFor:function(e){return function(t){var n;if(!Jn(t)||(n=On(t)).type!==e)throw new $n("Incompatible receiver, "+e+" required");return n}}},rr=z,ir=D,or=de,ar=ft,sr=N,cr=Cn.CONFIGURABLE,ur=Mn,lr=nr.enforce,dr=nr.get,hr=String,fr=Object.defineProperty,pr=rr("".slice),mr=rr("".replace),vr=rr([].join),_r=sr&&!ir((function(){return 8!==fr((function(){}),"length",{value:8}).length})),gr=String(String).split("String"),yr=kn.exports=function(e,t,n){"Symbol("===pr(hr(t),0,7)&&(t="["+mr(hr(t),/^Symbol\(([^)]*)\).*$/,"$1")+"]"),n&&n.getter&&(t="get "+t),n&&n.setter&&(t="set "+t),(!ar(e,"name")||cr&&e.name!==t)&&(sr?fr(e,"name",{value:t,configurable:!0}):e.name=t),_r&&n&&ar(n,"arity")&&e.length!==n.arity&&fr(e,"length",{value:n.arity});try{n&&ar(n,"constructor")&&n.constructor?sr&&fr(e,"prototype",{writable:!1}):e.prototype&&(e.prototype=void 0)}catch(i){}var r=lr(e);return ar(r,"source")||(r.source=vr(gr,"string"==typeof t?t:"")),e};Function.prototype.toString=yr((function(){return or(this)&&dr(this).source||ur(this)}),"toString");var Er=de,Tr=en,kr=Tn,Sr=tt,Ir=function(e,t,n,r){r||(r={});var i=r.enumerable,o=void 0!==r.name?r.name:t;if(Er(n)&&kr(n,o,r),r.global)i?e[t]=n:Sr(t,n);else{try{r.unsafe?e[t]&&(i=!0):delete e[t]}catch(a){}i?e[t]=n:Tr.f(e,t,{value:n,enumerable:!1,configurable:!r.nonConfigurable,writable:!r.nonWritable})}return e},br={},Ar=Math.ceil,Rr=Math.floor,Cr=Math.trunc||function(e){var t=+e;return(t>0?Rr:Ar)(t)},wr=Cr,Dr=function(e){var t=+e;return t!=t||0===t?0:wr(t)},Nr=Dr,xr=Math.max,Or=Math.min,Pr=function(e,t){var n=Nr(e);return n<0?xr(n+t,0):Or(n,t)},Mr=Dr,Lr=Math.min,Vr=function(e){var t=Mr(e);return t>0?Lr(t,9007199254740991):0},Ur=Vr,Fr=function(e){return Ur(e.length)},Br=ue,Hr=Pr,jr=Fr,Gr=function(e){return function(t,n,r){var i=Br(t),o=jr(i);if(0===o)return!e&&-1;var a,s=Hr(r,o);if(e&&n!=n){for(;o>s;)if((a=i[s++])!=a)return!0}else for(;o>s;s++)if((e||s in i)&&i[s]===n)return e||s||0;return!e&&-1}},Wr={includes:Gr(!0),indexOf:Gr(!1)},Jr=ft,Kr=ue,zr=Wr.indexOf,qr=jn,Yr=z([].push),Xr=function(e,t){var n,r=Kr(e),i=0,o=[];for(n in r)!Jr(qr,n)&&Jr(r,n)&&Yr(o,n);for(;t.length>i;)Jr(r,n=t[i++])&&(~zr(o,n)||Yr(o,n));return o},Qr=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"],$r=Xr,Zr=Qr.concat("length","prototype");br.f=Object.getOwnPropertyNames||function(e){return $r(e,Zr)};var ei={};ei.f=Object.getOwnPropertySymbols;var ti=ve,ni=br,ri=ei,ii=an,oi=z([].concat),ai=ti("Reflect","ownKeys")||function(e){var t=ni.f(ii(e)),n=ri.f;return n?oi(t,n(e)):t},si=ft,ci=ai,ui=w,li=en,di=function(e,t,n){for(var r=ci(t),i=li.f,o=ui.f,a=0;a<r.length;a++){var s=r[a];si(e,s)||n&&si(n,s)||i(e,s,o(t,s))}},hi=D,fi=de,pi=/#|\.prototype\./,mi=function(e,t){var n=_i[vi(e)];return n===yi||n!==gi&&(fi(t)?hi(t):!!t)},vi=mi.normalize=function(e){return String(e).replace(pi,".").toLowerCase()},_i=mi.data={},gi=mi.NATIVE="N",yi=mi.POLYFILL="P",Ei=mi,Ti=C,ki=w.f,Si=En,Ii=Ir,bi=tt,Ai=di,Ri=Ei,Ci=function(e,t){var n,r,i,o,a,s=e.target,c=e.global,u=e.stat;if(n=c?Ti:u?Ti[s]||bi(s,{}):Ti[s]&&Ti[s].prototype)for(r in t){if(o=t[r],i=e.dontCallGetSet?(a=ki(n,r))&&a.value:n[r],!Ri(c?r:s+(u?".":"#")+r,e.forced)&&void 0!==i){if(typeof o==typeof i)continue;Ai(o,i)}(e.sham||i&&i.sham)&&Si(o,"sham",!0),Ii(n,r,o,e)}},wi={};wi[Rt("toStringTag")]="z";var Di="[object z]"===String(wi),Ni=Di,xi=de,Oi=Q,Pi=Rt("toStringTag"),Mi=Object,Li="Arguments"===Oi(function(){return arguments}()),Vi=Ni?Oi:function(e){var t,n,r;return void 0===e?"Undefined":null===e?"Null":"string"==typeof(n=function(e,t){try{return e[t]}catch(n){}}(t=Mi(e),Pi))?n:Li?Oi(t):"Object"===(r=Oi(t))&&xi(t.callee)?"Arguments":r},Ui=Vi,Fi=String,Bi=function(e){if("Symbol"===Ui(e))throw new TypeError("Cannot convert a Symbol value to a string");return Fi(e)},Hi={},ji=Xr,Gi=Qr,Wi=Object.keys||function(e){return ji(e,Gi)},Ji=N,Ki=tn,zi=en,qi=an,Yi=ue,Xi=Wi;Hi.f=Ji&&!Ki?Object.defineProperties:function(e,t){qi(e);for(var n,r=Yi(t),i=Xi(t),o=i.length,a=0;o>a;)zi.f(e,n=i[a++],r[n]);return e};var Qi,$i=ve("document","documentElement"),Zi=an,eo=Hi,to=Qr,no=jn,ro=$i,io=jt,oo="prototype",ao="script",so=Hn("IE_PROTO"),co=function(){},uo=function(e){return"<"+ao+">"+e+"</"+ao+">"},lo=function(e){e.write(uo("")),e.close();var t=e.parentWindow.Object;return e=null,t},ho=function(){try{Qi=new ActiveXObject("htmlfile")}catch(i){}var e,t,n;ho="undefined"!=typeof document?document.domain&&Qi?lo(Qi):(t=io("iframe"),n="java"+ao+":",t.style.display="none",ro.appendChild(t),t.src=String(n),(e=t.contentWindow.document).open(),e.write(uo("document.F=Object")),e.close(),e.F):lo(Qi);for(var r=to.length;r--;)delete ho[oo][to[r]];return ho()};no[so]=!0;var fo=Object.create||function(e,t){var n;return null!==e?(co[oo]=Zi(e),n=new co,co[oo]=null,n[so]=e):n=ho(),void 0===t?n:eo.f(n,t)},po={},mo=z([].slice),vo=Q,_o=ue,go=br.f,yo=mo,Eo="object"==typeof window&&window&&Object.getOwnPropertyNames?Object.getOwnPropertyNames(window):[];po.f=function(e){return Eo&&"Window"===vo(e)?function(e){try{return go(e)}catch(t){return yo(Eo)}}(e):go(_o(e))};var To=Tn,ko=en,So=function(e,t,n){return n.get&&To(n.get,t,{getter:!0}),n.set&&To(n.set,t,{setter:!0}),ko.f(e,t,n)},Io={},bo=Rt;Io.f=bo;var Ao=C,Ro=Ao,Co=ft,wo=Io,Do=en.f,No=M,xo=ve,Oo=Rt,Po=Ir,Mo=en.f,Lo=ft,Vo=Rt("toStringTag"),Uo=function(e,t,n){e&&!n&&(e=e.prototype),e&&!Lo(e,Vo)&&Mo(e,Vo,{configurable:!0,value:t})},Fo=Q,Bo=z,Ho=function(e){if("Function"===Fo(e))return Bo(e)},jo=Ge,Go=x,Wo=Ho(Ho.bind),Jo=function(e,t){return jo(e),void 0===t?e:Go?Wo(e,t):function(){return e.apply(t,arguments)}},Ko=Q,zo=Array.isArray||function(e){return"Array"===Ko(e)},qo=z,Yo=D,Xo=de,Qo=Vi,$o=Mn,Zo=function(){},ea=ve("Reflect","construct"),ta=/^\s*(?:class|function)\b/,na=qo(ta.exec),ra=!ta.test(Zo),ia=function(e){if(!Xo(e))return!1;try{return ea(Zo,[],e),!0}catch(t){return!1}},oa=function(e){if(!Xo(e))return!1;switch(Qo(e)){case"AsyncFunction":case"GeneratorFunction":case"AsyncGeneratorFunction":return!1}try{return ra||!!na(ta,$o(e))}catch(t){return!0}};oa.sham=!0;var aa=!ea||Yo((function(){var e;return ia(ia.call)||!ia(Object)||!ia((function(){e=!0}))||e}))?oa:ia,sa=zo,ca=aa,ua=fe,la=Rt("species"),da=Array,ha=function(e){var t;return sa(e)&&(t=e.constructor,(ca(t)&&(t===da||sa(t.prototype))||ua(t)&&null===(t=t[la]))&&(t=void 0)),void 0===t?da:t},fa=function(e,t){return new(ha(e))(0===t?0:t)},pa=Jo,ma=ne,va=lt,_a=Fr,ga=fa,ya=z([].push),Ea=function(e){var t=1===e,n=2===e,r=3===e,i=4===e,o=6===e,a=7===e,s=5===e||o;return function(c,u,l,d){for(var h,f,p=va(c),m=ma(p),v=_a(m),_=pa(u,l),g=0,y=d||ga,E=t?y(c,v):n||a?y(c,0):void 0;v>g;g++)if((s||g in m)&&(f=_(h=m[g],g,p),e))if(t)E[g]=f;else if(f)switch(e){case 3:return!0;case 5:return h;case 6:return g;case 2:ya(E,h)}else switch(e){case 4:return!1;case 7:ya(E,h)}return o?-1:r||i?i:E}},Ta={forEach:Ea(0),map:Ea(1),filter:Ea(2),some:Ea(3),every:Ea(4),find:Ea(5),findIndex:Ea(6),filterReject:Ea(7)},ka=Ci,Sa=C,Ia=M,ba=z,Aa=N,Ra=Ne,Ca=D,wa=ft,Da=_e,Na=an,xa=ue,Oa=Ut,Pa=Bi,Ma=j,La=fo,Va=Wi,Ua=br,Fa=po,Ba=ei,Ha=w,ja=en,Ga=Hi,Wa=L,Ja=Ir,Ka=So,za=st,qa=jn,Ya=gt,Xa=Rt,Qa=Io,$a=function(e){var t=Ro.Symbol||(Ro.Symbol={});Co(t,e)||Do(t,e,{value:wo.f(e)})},Za=function(){var e=xo("Symbol"),t=e&&e.prototype,n=t&&t.valueOf,r=Oo("toPrimitive");t&&!t[r]&&Po(t,r,(function(e){return No(n,this)}),{arity:1})},es=Uo,ts=nr,ns=Ta.forEach,rs=Hn("hidden"),is="Symbol",os="prototype",as=ts.set,ss=ts.getterFor(is),cs=Object[os],us=Sa.Symbol,ls=us&&us[os],ds=Sa.RangeError,hs=Sa.TypeError,fs=Sa.QObject,ps=Ha.f,ms=ja.f,vs=Fa.f,_s=Wa.f,gs=ba([].push),ys=za("symbols"),Es=za("op-symbols"),Ts=za("wks"),ks=!fs||!fs[os]||!fs[os].findChild,Ss=function(e,t,n){var r=ps(cs,t);r&&delete cs[t],ms(e,t,n),r&&e!==cs&&ms(cs,t,r)},Is=Aa&&Ca((function(){return 7!==La(ms({},"a",{get:function(){return ms(this,"a",{value:7}).a}})).a}))?Ss:ms,bs=function(e,t){var n=ys[e]=La(ls);return as(n,{type:is,tag:e,description:t}),Aa||(n.description=t),n},As=function(e,t,n){e===cs&&As(Es,t,n),Na(e);var r=Oa(t);return Na(n),wa(ys,r)?(n.enumerable?(wa(e,rs)&&e[rs][r]&&(e[rs][r]=!1),n=La(n,{enumerable:Ma(0,!1)})):(wa(e,rs)||ms(e,rs,Ma(1,La(null))),e[rs][r]=!0),Is(e,r,n)):ms(e,r,n)},Rs=function(e,t){Na(e);var n=xa(t),r=Va(n).concat(Ns(n));return ns(r,(function(t){Aa&&!Ia(Cs,n,t)||As(e,t,n[t])})),e},Cs=function(e){var t=Oa(e),n=Ia(_s,this,t);return!(this===cs&&wa(ys,t)&&!wa(Es,t))&&(!(n||!wa(this,t)||!wa(ys,t)||wa(this,rs)&&this[rs][t])||n)},ws=function(e,t){var n=xa(e),r=Oa(t);if(n!==cs||!wa(ys,r)||wa(Es,r)){var i=ps(n,r);return!i||!wa(ys,r)||wa(n,rs)&&n[rs][r]||(i.enumerable=!0),i}},Ds=function(e){var t=vs(xa(e)),n=[];return ns(t,(function(e){wa(ys,e)||wa(qa,e)||gs(n,e)})),n},Ns=function(e){var t=e===cs,n=vs(t?Es:xa(e)),r=[];return ns(n,(function(e){!wa(ys,e)||t&&!wa(cs,e)||gs(r,ys[e])})),r};Ra||(us=function(){if(Da(ls,this))throw new hs("Symbol is not a constructor");var e=arguments.length&&void 0!==arguments[0]?Pa(arguments[0]):void 0,t=Ya(e),n=function(e){var r=void 0===this?Sa:this;r===cs&&Ia(n,Es,e),wa(r,rs)&&wa(r[rs],t)&&(r[rs][t]=!1);var i=Ma(1,e);try{Is(r,t,i)}catch(o){if(!(o instanceof ds))throw o;Ss(r,t,i)}};return Aa&&ks&&Is(cs,t,{configurable:!0,set:n}),bs(t,e)},Ja(ls=us[os],"toString",(function(){return ss(this).tag})),Ja(us,"withoutSetter",(function(e){return bs(Ya(e),e)})),Wa.f=Cs,ja.f=As,Ga.f=Rs,Ha.f=ws,Ua.f=Fa.f=Ds,Ba.f=Ns,Qa.f=function(e){return bs(Xa(e),e)},Aa&&(Ka(ls,"description",{configurable:!0,get:function(){return ss(this).description}}),Ja(cs,"propertyIsEnumerable",Cs,{unsafe:!0}))),ka({global:!0,constructor:!0,wrap:!0,forced:!Ra,sham:!Ra},{Symbol:us}),ns(Va(Ts),(function(e){$a(e)})),ka({target:is,stat:!0,forced:!Ra},{useSetter:function(){ks=!0},useSimple:function(){ks=!1}}),ka({target:"Object",stat:!0,forced:!Ra,sham:!Aa},{create:function(e,t){return void 0===t?La(e):Rs(La(e),t)},defineProperty:As,defineProperties:Rs,getOwnPropertyDescriptor:ws}),ka({target:"Object",stat:!0,forced:!Ra},{getOwnPropertyNames:Ds}),Za(),es(us,is),qa[rs]=!0;var xs=Ne&&!!Symbol.for&&!!Symbol.keyFor,Os=Ci,Ps=ve,Ms=ft,Ls=Bi,Vs=st,Us=xs,Fs=Vs("string-to-symbol-registry"),Bs=Vs("symbol-to-string-registry");Os({target:"Symbol",stat:!0,forced:!Us},{for:function(e){var t=Ls(e);if(Ms(Fs,t))return Fs[t];var n=Ps("Symbol")(t);return Fs[t]=n,Bs[n]=t,n}});var Hs=Ci,js=ft,Gs=Ve,Ws=Fe,Js=xs,Ks=st("symbol-to-string-registry");Hs({target:"Symbol",stat:!0,forced:!Js},{keyFor:function(e){if(!Gs(e))throw new TypeError(Ws(e)+" is not a symbol");if(js(Ks,e))return Ks[e]}});var zs=x,qs=Function.prototype,Ys=qs.apply,Xs=qs.call,Qs="object"==typeof Reflect&&Reflect.apply||(zs?Xs.bind(Ys):function(){return Xs.apply(Ys,arguments)}),$s=zo,Zs=de,ec=Q,tc=Bi,nc=z([].push),rc=Ci,ic=ve,oc=Qs,ac=M,sc=z,cc=D,uc=de,lc=Ve,dc=mo,hc=function(e){if(Zs(e))return e;if($s(e)){for(var t=e.length,n=[],r=0;r<t;r++){var i=e[r];"string"==typeof i?nc(n,i):"number"!=typeof i&&"Number"!==ec(i)&&"String"!==ec(i)||nc(n,tc(i))}var o=n.length,a=!0;return function(e,t){if(a)return a=!1,t;if($s(this))return t;for(var r=0;r<o;r++)if(n[r]===e)return t}}},fc=Ne,pc=String,mc=ic("JSON","stringify"),vc=sc(/./.exec),_c=sc("".charAt),gc=sc("".charCodeAt),yc=sc("".replace),Ec=sc(1..toString),Tc=/[\uD800-\uDFFF]/g,kc=/^[\uD800-\uDBFF]$/,Sc=/^[\uDC00-\uDFFF]$/,Ic=!fc||cc((function(){var e=ic("Symbol")("stringify detection");return"[null]"!==mc([e])||"{}"!==mc({a:e})||"{}"!==mc(Object(e))})),bc=cc((function(){return'"\\udf06\\ud834"'!==mc("\udf06\ud834")||'"\\udead"'!==mc("\udead")})),Ac=function(e,t){var n=dc(arguments),r=hc(t);if(uc(r)||void 0!==e&&!lc(e))return n[1]=function(e,t){if(uc(r)&&(t=ac(r,this,pc(e),t)),!lc(t))return t},oc(mc,null,n)},Rc=function(e,t,n){var r=_c(n,t-1),i=_c(n,t+1);return vc(kc,e)&&!vc(Sc,i)||vc(Sc,e)&&!vc(kc,r)?"\\u"+Ec(gc(e,0),16):e};mc&&rc({target:"JSON",stat:!0,arity:3,forced:Ic||bc},{stringify:function(e,t,n){var r=dc(arguments),i=oc(Ic?Ac:mc,null,r);return bc&&"string"==typeof i?yc(i,Tc,Rc):i}});var Cc=ei,wc=lt;Ci({target:"Object",stat:!0,forced:!Ne||D((function(){Cc.f(1)}))},{getOwnPropertySymbols:function(e){var t=Cc.f;return t?t(wc(e)):[]}});var Dc=Ci,Nc=N,xc=z,Oc=ft,Pc=de,Mc=_e,Lc=Bi,Vc=So,Uc=di,Fc=C.Symbol,Bc=Fc&&Fc.prototype;if(Nc&&Pc(Fc)&&(!("description"in Bc)||void 0!==Fc().description)){var Hc={},jc=function(){var e=arguments.length<1||void 0===arguments[0]?void 0:Lc(arguments[0]),t=Mc(Bc,this)?new Fc(e):void 0===e?Fc():Fc(e);return""===e&&(Hc[t]=!0),t};Uc(jc,Fc),jc.prototype=Bc,Bc.constructor=jc;var Gc="Symbol(description detection)"===String(Fc("description detection")),Wc=xc(Bc.valueOf),Jc=xc(Bc.toString),Kc=/^Symbol\((.*)\)[^)]+$/,zc=xc("".replace),qc=xc("".slice);Vc(Bc,"description",{configurable:!0,get:function(){var e=Wc(this);if(Oc(Hc,e))return"";var t=Jc(e),n=Gc?qc(t,7,-1):zc(t,Kc,"$1");return""===n?void 0:n}}),Dc({global:!0,constructor:!0,forced:!0},{Symbol:jc})}var Yc=TypeError,Xc=function(e){if(e>9007199254740991)throw Yc("Maximum allowed index exceeded");return e},Qc=N,$c=en,Zc=j,eu=function(e,t,n){Qc?$c.f(e,t,Zc(0,n)):e[t]=n},tu=D,nu=Re,ru=Rt("species"),iu=function(e){return nu>=51||!tu((function(){var t=[];return(t.constructor={})[ru]=function(){return{foo:1}},1!==t[e](Boolean).foo}))},ou=Ci,au=D,su=zo,cu=fe,uu=lt,lu=Fr,du=Xc,hu=eu,fu=fa,pu=iu,mu=Re,vu=Rt("isConcatSpreadable"),_u=mu>=51||!au((function(){var e=[];return e[vu]=!1,e.concat()[0]!==e})),gu=function(e){if(!cu(e))return!1;var t=e[vu];return void 0!==t?!!t:su(e)};ou({target:"Array",proto:!0,arity:1,forced:!_u||!pu("concat")},{concat:function(e){var t,n,r,i,o,a=uu(this),s=fu(a,0),c=0;for(t=-1,r=arguments.length;t<r;t++)if(gu(o=-1===t?a:arguments[t]))for(i=lu(o),du(c+i),n=0;n<i;n++,c++)n in o&&hu(s,c,o[n]);else du(c+1),hu(s,c++,o);return s.length=c,s}});var yu=D,Eu=function(e,t){var n=[][e];return!!n&&yu((function(){n.call(null,t||function(){return 1},1)}))},Tu=Ta.every;Ci({target:"Array",proto:!0,forced:!Eu("every")},{every:function(e){return Tu(this,e,arguments.length>1?arguments[1]:void 0)}});var ku=Ta.filter;Ci({target:"Array",proto:!0,forced:!iu("filter")},{filter:function(e){return ku(this,e,arguments.length>1?arguments[1]:void 0)}});var Su=Rt,Iu=fo,bu=en.f,Au=Su("unscopables"),Ru=Array.prototype;void 0===Ru[Au]&&bu(Ru,Au,{configurable:!0,value:Iu(null)});var Cu=function(e){Ru[Au][e]=!0},wu=Ci,Du=Ta.find,Nu=Cu,xu="find",Ou=!0;xu in[]&&Array(1)[xu]((function(){Ou=!1})),wu({target:"Array",proto:!0,forced:Ou},{find:function(e){return Du(this,e,arguments.length>1?arguments[1]:void 0)}}),Nu(xu);var Pu=Ci,Mu=Ta.findIndex,Lu=Cu,Vu="findIndex",Uu=!0;Vu in[]&&Array(1)[Vu]((function(){Uu=!1})),Pu({target:"Array",proto:!0,forced:Uu},{findIndex:function(e){return Mu(this,e,arguments.length>1?arguments[1]:void 0)}}),Lu(Vu);var Fu=Ta.forEach,Bu=Eu("forEach")?[].forEach:function(e){return Fu(this,e,arguments.length>1?arguments[1]:void 0)};Ci({target:"Array",proto:!0,forced:[].forEach!==Bu},{forEach:Bu});var Hu=Wr.includes,ju=Cu;Ci({target:"Array",proto:!0,forced:D((function(){return!Array(1).includes()}))},{includes:function(e){return Hu(this,e,arguments.length>1?arguments[1]:void 0)}}),ju("includes");var Gu=Ci,Wu=Wr.indexOf,Ju=Eu,Ku=Ho([].indexOf),zu=!!Ku&&1/Ku([1],1,-0)<0;Gu({target:"Array",proto:!0,forced:zu||!Ju("indexOf")},{indexOf:function(e){var t=arguments.length>1?arguments[1]:void 0;return zu?Ku(this,e,t)||0:Wu(this,e,t)}}),Ci({target:"Array",stat:!0},{isArray:zo});var qu,Yu,Xu,Qu={},$u=!D((function(){function e(){}return e.prototype.constructor=null,Object.getPrototypeOf(new e)!==e.prototype})),Zu=ft,el=de,tl=lt,nl=$u,rl=Hn("IE_PROTO"),il=Object,ol=il.prototype,al=nl?il.getPrototypeOf:function(e){var t=tl(e);if(Zu(t,rl))return t[rl];var n=t.constructor;return el(n)&&t instanceof n?n.prototype:t instanceof il?ol:null},sl=D,cl=de,ul=fe,ll=al,dl=Ir,hl=Rt("iterator"),fl=!1;[].keys&&("next"in(Xu=[].keys())?(Yu=ll(ll(Xu)))!==Object.prototype&&(qu=Yu):fl=!0);var pl=!ul(qu)||sl((function(){var e={};return qu[hl].call(e)!==e}));pl&&(qu={}),cl(qu[hl])||dl(qu,hl,(function(){return this}));var ml={IteratorPrototype:qu,BUGGY_SAFARI_ITERATORS:fl},vl=ml.IteratorPrototype,_l=fo,gl=j,yl=Uo,El=Qu,Tl=function(){return this},kl=function(e,t,n,r){var i=t+" Iterator";return e.prototype=_l(vl,{next:gl(+!r,n)}),yl(e,i,!1),El[i]=Tl,e},Sl=z,Il=Ge,bl=fe,Al=function(e){return bl(e)||null===e},Rl=String,Cl=TypeError,wl=function(e,t,n){try{return Sl(Il(Object.getOwnPropertyDescriptor(e,t)[n]))}catch(r){}},Dl=fe,Nl=ae,xl=function(e){if(Al(e))return e;throw new Cl("Can't set "+Rl(e)+" as a prototype")},Ol=Object.setPrototypeOf||("__proto__"in{}?function(){var e,t=!1,n={};try{(e=wl(Object.prototype,"__proto__","set"))(n,[]),t=n instanceof Array}catch(r){}return function(n,r){return Nl(n),xl(r),Dl(n)?(t?e(n,r):n.__proto__=r,n):n}}():void 0),Pl=Ci,Ml=M,Ll=de,Vl=kl,Ul=al,Fl=Ol,Bl=Uo,Hl=En,jl=Ir,Gl=Qu,Wl=Cn.PROPER,Jl=Cn.CONFIGURABLE,Kl=ml.IteratorPrototype,zl=ml.BUGGY_SAFARI_ITERATORS,ql=Rt("iterator"),Yl="keys",Xl="values",Ql="entries",$l=function(){return this},Zl=function(e,t,n,r,i,o,a){Vl(n,t,r);var s,c,u,l=function(e){if(e===i&&m)return m;if(!zl&&e&&e in f)return f[e];switch(e){case Yl:case Xl:case Ql:return function(){return new n(this,e)}}return function(){return new n(this)}},d=t+" Iterator",h=!1,f=e.prototype,p=f[ql]||f["@@iterator"]||i&&f[i],m=!zl&&p||l(i),v="Array"===t&&f.entries||p;if(v&&(s=Ul(v.call(new e)))!==Object.prototype&&s.next&&(Ul(s)!==Kl&&(Fl?Fl(s,Kl):Ll(s[ql])||jl(s,ql,$l)),Bl(s,d,!0)),Wl&&i===Xl&&p&&p.name!==Xl&&(Jl?Hl(f,"name",Xl):(h=!0,m=function(){return Ml(p,this)})),i)if(c={values:l(Xl),keys:o?m:l(Yl),entries:l(Ql)},a)for(u in c)(zl||h||!(u in f))&&jl(f,u,c[u]);else Pl({target:t,proto:!0,forced:zl||h},c);return f[ql]!==m&&jl(f,ql,m,{name:i}),Gl[t]=m,c},ed=function(e,t){return{value:e,done:t}},td=ue,nd=Cu,rd=Qu,id=nr,od=en.f,ad=Zl,sd=ed,cd=N,ud="Array Iterator",ld=id.set,dd=id.getterFor(ud),hd=ad(Array,"Array",(function(e,t){ld(this,{type:ud,target:td(e),index:0,kind:t})}),(function(){var e=dd(this),t=e.target,n=e.index++;if(!t||n>=t.length)return e.target=null,sd(void 0,!0);switch(e.kind){case"keys":return sd(n,!1);case"values":return sd(t[n],!1)}return sd([n,t[n]],!1)}),"values"),fd=rd.Arguments=rd.Array;if(nd("keys"),nd("values"),nd("entries"),cd&&"values"!==fd.name)try{od(fd,"name",{value:"values"})}catch(t3){}var pd=Ci,md=ne,vd=ue,_d=Eu,gd=z([].join);pd({target:"Array",proto:!0,forced:md!==Object||!_d("join",",")},{join:function(e){return gd(vd(this),void 0===e?",":e)}});var yd=Qs,Ed=ue,Td=Dr,kd=Fr,Sd=Eu,Id=Math.min,bd=[].lastIndexOf,Ad=!!bd&&1/[1].lastIndexOf(1,-0)<0,Rd=Sd("lastIndexOf"),Cd=Ad||!Rd?function(e){if(Ad)return yd(bd,this,arguments)||0;var t=Ed(this),n=kd(t);if(0===n)return-1;var r=n-1;for(arguments.length>1&&(r=Id(r,Td(arguments[1]))),r<0&&(r=n+r);r>=0;r--)if(r in t&&t[r]===e)return r||0;return-1}:bd;Ci({target:"Array",proto:!0,forced:Cd!==[].lastIndexOf},{lastIndexOf:Cd});var wd=Ta.map;Ci({target:"Array",proto:!0,forced:!iu("map")},{map:function(e){return wd(this,e,arguments.length>1?arguments[1]:void 0)}});var Dd=Ge,Nd=lt,xd=ne,Od=Fr,Pd=TypeError,Md="Reduce of empty array with no initial value",Ld=function(e){return function(t,n,r,i){var o=Nd(t),a=xd(o),s=Od(o);if(Dd(n),0===s&&r<2)throw new Pd(Md);var 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 new Pd(Md)}for(;e?c>=0:s>c;c+=u)c in a&&(i=n(i,a[c],c,o));return i}},Vd={left:Ld(!1),right:Ld(!0)},Ud=C,Fd=Ee,Bd=Q,Hd=function(e){return Fd.slice(0,e.length)===e},jd=Hd("Bun/")?"BUN":Hd("Cloudflare-Workers")?"CLOUDFLARE":Hd("Deno/")?"DENO":Hd("Node.js/")?"NODE":Ud.Bun&&"string"==typeof Bun.version?"BUN":Ud.Deno&&"object"==typeof Deno.version?"DENO":"process"===Bd(Ud.process)?"NODE":Ud.window&&Ud.document?"BROWSER":"REST",Gd="NODE"===jd,Wd=Vd.left;Ci({target:"Array",proto:!0,forced:!Gd&&Re>79&&Re<83||!Eu("reduce")},{reduce:function(e){var t=arguments.length;return Wd(this,e,t,t>1?arguments[1]:void 0)}});var Jd=Vd.right;Ci({target:"Array",proto:!0,forced:!Gd&&Re>79&&Re<83||!Eu("reduceRight")},{reduceRight:function(e){return Jd(this,e,arguments.length,arguments.length>1?arguments[1]:void 0)}});var Kd=Ci,zd=zo,qd=z([].reverse),Yd=[1,2];Kd({target:"Array",proto:!0,forced:String(Yd)===String(Yd.reverse())},{reverse:function(){return zd(this)&&(this.length=this.length),qd(this)}});var Xd=Ci,Qd=zo,$d=aa,Zd=fe,eh=Pr,th=Fr,nh=ue,rh=eu,ih=Rt,oh=mo,ah=iu("slice"),sh=ih("species"),ch=Array,uh=Math.max;Xd({target:"Array",proto:!0,forced:!ah},{slice:function(e,t){var n,r,i,o=nh(this),a=th(o),s=eh(e,a),c=eh(void 0===t?a:t,a);if(Qd(o)&&(n=o.constructor,($d(n)&&(n===ch||Qd(n.prototype))||Zd(n)&&null===(n=n[sh]))&&(n=void 0),n===ch||void 0===n))return oh(o,s,c);for(r=new(void 0===n?ch:n)(uh(c-s,0)),i=0;s<c;s++,i++)s in o&&rh(r,i,o[s]);return r.length=i,r}});var lh=Ta.some;Ci({target:"Array",proto:!0,forced:!Eu("some")},{some:function(e){return lh(this,e,arguments.length>1?arguments[1]:void 0)}});var dh=Fe,hh=TypeError,fh=function(e,t){if(!delete e[t])throw new hh("Cannot delete property "+dh(t)+" of "+dh(e))},ph=mo,mh=Math.floor,vh=function(e,t){var n=e.length;if(n<8)for(var r,i,o=1;o<n;){for(i=o,r=e[o];i&&t(e[i-1],r)>0;)e[i]=e[--i];i!==o++&&(e[i]=r)}else for(var a=mh(n/2),s=vh(ph(e,0,a),t),c=vh(ph(e,a),t),u=s.length,l=c.length,d=0,h=0;d<u||h<l;)e[d+h]=d<u&&h<l?t(s[d],c[h])<=0?s[d++]:c[h++]:d<u?s[d++]:c[h++];return e},_h=vh,gh=Ee.match(/firefox\/(\d+)/i),yh=!!gh&&+gh[1],Eh=/MSIE|Trident/.test(Ee),Th=Ee.match(/AppleWebKit\/(\d+)\./),kh=!!Th&&+Th[1],Sh=Ci,Ih=z,bh=Ge,Ah=lt,Rh=Fr,Ch=fh,wh=Bi,Dh=D,Nh=_h,xh=Eu,Oh=yh,Ph=Eh,Mh=Re,Lh=kh,Vh=[],Uh=Ih(Vh.sort),Fh=Ih(Vh.push),Bh=Dh((function(){Vh.sort(void 0)})),Hh=Dh((function(){Vh.sort(null)})),jh=xh("sort"),Gh=!Dh((function(){if(Mh)return Mh<70;if(!(Oh&&Oh>3)){if(Ph)return!0;if(Lh)return Lh<603;var e,t,n,r,i="";for(e=65;e<76;e++){switch(t=String.fromCharCode(e),e){case 66:case 69:case 70:case 72:n=3;break;case 68:case 71:n=4;break;default:n=2}for(r=0;r<47;r++)Vh.push({k:t+r,v:n})}for(Vh.sort((function(e,t){return t.v-e.v})),r=0;r<Vh.length;r++)t=Vh[r].k.charAt(0),i.charAt(i.length-1)!==t&&(i+=t);return"DGBEFHACIJK"!==i}}));Sh({target:"Array",proto:!0,forced:Bh||!Hh||!jh||!Gh},{sort:function(e){void 0!==e&&bh(e);var t=Ah(this);if(Gh)return void 0===e?Uh(t):Uh(t,e);var n,r,i=[],o=Rh(t);for(r=0;r<o;r++)r in t&&Fh(i,t[r]);for(Nh(i,function(e){return function(t,n){return void 0===n?-1:void 0===t?1:void 0!==e?+e(t,n)||0:wh(t)>wh(n)?1:-1}}(e)),n=Rh(i),r=0;r<n;)t[r]=i[r++];for(;r<o;)Ch(t,r++);return t}});var Wh=N,Jh=zo,Kh=TypeError,zh=Object.getOwnPropertyDescriptor,qh=Wh&&!function(){if(void 0!==this)return!0;try{Object.defineProperty([],"length",{writable:!1}).length=1}catch(t3){return t3 instanceof TypeError}}()?function(e,t){if(Jh(e)&&!zh(e,"length").writable)throw new Kh("Cannot set read only .length");return e.length=t}:function(e,t){return e.length=t},Yh=Ci,Xh=lt,Qh=Pr,$h=Dr,Zh=Fr,ef=qh,tf=Xc,nf=fa,rf=eu,of=fh,af=iu("splice"),sf=Math.max,cf=Math.min;Yh({target:"Array",proto:!0,forced:!af},{splice:function(e,t){var n,r,i,o,a,s,c=Xh(this),u=Zh(c),l=Qh(e,u),d=arguments.length;for(0===d?n=r=0:1===d?(n=0,r=u-l):(n=d-2,r=cf(sf($h(t),0),u-l)),tf(u+n-r),i=nf(c,r),o=0;o<r;o++)(a=l+o)in c&&rf(i,o,c[a]);if(i.length=r,n<r){for(o=l;o<u-r;o++)s=o+n,(a=o+r)in c?c[s]=c[a]:of(c,s);for(o=u;o>u-r+n;o--)of(c,o-1)}else if(n>r)for(o=u-r;o>l;o--)s=o+n-1,(a=o+r-1)in c?c[s]=c[a]:of(c,s);for(o=0;o<n;o++)c[o+l]=arguments[o+2];return ef(c,u-r+n),i}});var uf="undefined"!=typeof ArrayBuffer&&"undefined"!=typeof DataView,lf=Ir,df=function(e,t,n){for(var r in t)lf(e,r,t[r],n);return e},hf=_e,ff=TypeError,pf=function(e,t){if(hf(t,e))return e;throw new ff("Incorrect invocation")},mf=Dr,vf=Vr,_f=RangeError,gf=function(e){if(void 0===e)return 0;var t=mf(e),n=vf(t);if(t!==n)throw new _f("Wrong length or index");return n},yf=Math.sign||function(e){var t=+e;return 0===t||t!=t?t:t<0?-1:1},Ef=yf,Tf=Math.abs,kf=2220446049250313e-31,Sf=1/kf,If=function(e,t,n,r){var i=+e,o=Tf(i),a=Ef(i);if(o<r)return a*function(e){return e+Sf-Sf}(o/r/t)*r*t;var s=(1+t/kf)*o,c=s-(s-o);return c>n||c!=c?Infinity*a:a*c},bf=Math.fround||function(e){return If(e,1.1920928955078125e-7,34028234663852886e22,11754943508222875e-54)},Af=Array,Rf=Math.abs,Cf=Math.pow,wf=Math.floor,Df=Math.log,Nf=Math.LN2,xf={pack:function(e,t,n){var r,i,o,a=Af(n),s=8*n-t-1,c=(1<<s)-1,u=c>>1,l=23===t?Cf(2,-24)-Cf(2,-77):0,d=e<0||0===e&&1/e<0?1:0,h=0;for((e=Rf(e))!=e||Infinity===e?(i=e!=e?1:0,r=c):(r=wf(Df(e)/Nf),e*(o=Cf(2,-r))<1&&(r--,o*=2),(e+=r+u>=1?l/o:l*Cf(2,1-u))*o>=2&&(r++,o/=2),r+u>=c?(i=0,r=c):r+u>=1?(i=(e*o-1)*Cf(2,t),r+=u):(i=e*Cf(2,u-1)*Cf(2,t),r=0));t>=8;)a[h++]=255&i,i/=256,t-=8;for(r=r<<t|i,s+=t;s>0;)a[h++]=255&r,r/=256,s-=8;return a[h-1]|=128*d,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--],l=127&u;for(u>>=7;s>0;)l=256*l+e[c--],s-=8;for(n=l&(1<<-s)-1,l>>=-s,s+=t;s>0;)n=256*n+e[c--],s-=8;if(0===l)l=1-a;else{if(l===o)return n?NaN:u?-Infinity:Infinity;n+=Cf(2,t),l-=a}return(u?-1:1)*n*Cf(2,l-t)}},Of=lt,Pf=Pr,Mf=Fr,Lf=function(e){for(var t=Of(this),n=Mf(t),r=arguments.length,i=Pf(r>1?arguments[1]:void 0,n),o=r>2?arguments[2]:void 0,a=void 0===o?n:Pf(o,n);a>i;)t[i++]=e;return t},Vf=de,Uf=fe,Ff=Ol,Bf=function(e,t,n){var r,i;return Ff&&Vf(r=t.constructor)&&r!==n&&Uf(i=r.prototype)&&i!==n.prototype&&Ff(e,i),e},Hf=C,jf=z,Gf=N,Wf=uf,Jf=En,Kf=So,zf=df,qf=D,Yf=pf,Xf=Dr,Qf=Vr,$f=gf,Zf=bf,ep=xf,tp=al,np=Ol,rp=Lf,ip=mo,op=Bf,ap=di,sp=Uo,cp=nr,up=Cn.PROPER,lp=Cn.CONFIGURABLE,dp="ArrayBuffer",hp="DataView",fp="prototype",pp="Wrong index",mp=cp.getterFor(dp),vp=cp.getterFor(hp),_p=cp.set,gp=Hf[dp],yp=gp,Ep=yp&&yp[fp],Tp=Hf[hp],kp=Tp&&Tp[fp],Sp=Object.prototype,Ip=Hf.Array,bp=Hf.RangeError,Ap=jf(rp),Rp=jf([].reverse),Cp=ep.pack,wp=ep.unpack,Dp=function(e){return[255&e]},Np=function(e){return[255&e,e>>8&255]},xp=function(e){return[255&e,e>>8&255,e>>16&255,e>>24&255]},Op=function(e){return e[3]<<24|e[2]<<16|e[1]<<8|e[0]},Pp=function(e){return Cp(Zf(e),23,4)},Mp=function(e){return Cp(e,52,8)},Lp=function(e,t,n){Kf(e[fp],t,{configurable:!0,get:function(){return n(this)[t]}})},Vp=function(e,t,n,r){var i=vp(e),o=$f(n),a=!!r;if(o+t>i.byteLength)throw new bp(pp);var s=i.bytes,c=o+i.byteOffset,u=ip(s,c,c+t);return a?u:Rp(u)},Up=function(e,t,n,r,i,o){var a=vp(e),s=$f(n),c=r(+i),u=!!o;if(s+t>a.byteLength)throw new bp(pp);for(var l=a.bytes,d=s+a.byteOffset,h=0;h<t;h++)l[d+h]=c[u?h:t-h-1]};if(Wf){var Fp=up&&gp.name!==dp;qf((function(){gp(1)}))&&qf((function(){new gp(-1)}))&&!qf((function(){return new gp,new gp(1.5),new gp(NaN),1!==gp.length||Fp&&!lp}))?Fp&&lp&&Jf(gp,"name",dp):((yp=function(e){return Yf(this,Ep),op(new gp($f(e)),this,yp)})[fp]=Ep,Ep.constructor=yp,ap(yp,gp)),np&&tp(kp)!==Sp&&np(kp,Sp);var Bp=new Tp(new yp(2)),Hp=jf(kp.setInt8);Bp.setInt8(0,2147483648),Bp.setInt8(1,2147483649),!Bp.getInt8(0)&&Bp.getInt8(1)||zf(kp,{setInt8:function(e,t){Hp(this,e,t<<24>>24)},setUint8:function(e,t){Hp(this,e,t<<24>>24)}},{unsafe:!0})}else Ep=(yp=function(e){Yf(this,Ep);var t=$f(e);_p(this,{type:dp,bytes:Ap(Ip(t),0),byteLength:t}),Gf||(this.byteLength=t,this.detached=!1)})[fp],kp=(Tp=function(e,t,n){Yf(this,kp),Yf(e,Ep);var r=mp(e),i=r.byteLength,o=Xf(t);if(o<0||o>i)throw new bp("Wrong offset");if(o+(n=void 0===n?i-o:Qf(n))>i)throw new bp("Wrong length");_p(this,{type:hp,buffer:e,byteLength:n,byteOffset:o,bytes:r.bytes}),Gf||(this.buffer=e,this.byteLength=n,this.byteOffset=o)})[fp],Gf&&(Lp(yp,"byteLength",mp),Lp(Tp,"buffer",vp),Lp(Tp,"byteLength",vp),Lp(Tp,"byteOffset",vp)),zf(kp,{getInt8:function(e){return Vp(this,1,e)[0]<<24>>24},getUint8:function(e){return Vp(this,1,e)[0]},getInt16:function(e){var t=Vp(this,2,e,arguments.length>1&&arguments[1]);return(t[1]<<8|t[0])<<16>>16},getUint16:function(e){var t=Vp(this,2,e,arguments.length>1&&arguments[1]);return t[1]<<8|t[0]},getInt32:function(e){return Op(Vp(this,4,e,arguments.length>1&&arguments[1]))},getUint32:function(e){return Op(Vp(this,4,e,arguments.length>1&&arguments[1]))>>>0},getFloat32:function(e){return wp(Vp(this,4,e,arguments.length>1&&arguments[1]),23)},getFloat64:function(e){return wp(Vp(this,8,e,arguments.length>1&&arguments[1]),52)},setInt8:function(e,t){Up(this,1,e,Dp,t)},setUint8:function(e,t){Up(this,1,e,Dp,t)},setInt16:function(e,t){Up(this,2,e,Np,t,arguments.length>2&&arguments[2])},setUint16:function(e,t){Up(this,2,e,Np,t,arguments.length>2&&arguments[2])},setInt32:function(e,t){Up(this,4,e,xp,t,arguments.length>2&&arguments[2])},setUint32:function(e,t){Up(this,4,e,xp,t,arguments.length>2&&arguments[2])},setFloat32:function(e,t){Up(this,4,e,Pp,t,arguments.length>2&&arguments[2])},setFloat64:function(e,t){Up(this,8,e,Mp,t,arguments.length>2&&arguments[2])}});sp(yp,dp),sp(Tp,hp);var jp={ArrayBuffer:yp,DataView:Tp},Gp=ve,Wp=So,Jp=N,Kp=Rt("species"),zp=function(e){var t=Gp(e);Jp&&t&&!t[Kp]&&Wp(t,Kp,{configurable:!0,get:function(){return this}})},qp=zp,Yp="ArrayBuffer",Xp=jp[Yp];Ci({global:!0,constructor:!0,forced:C[Yp]!==Xp},{ArrayBuffer:Xp}),qp(Yp);var Qp=aa,$p=Fe,Zp=TypeError,em=function(e){if(Qp(e))return e;throw new Zp($p(e)+" is not a constructor")},tm=an,nm=em,rm=re,im=Rt("species"),om=function(e,t){var n,r=tm(e).constructor;return void 0===r||rm(n=tm(r)[im])?t:nm(n)},am=Ci,sm=Ho,cm=D,um=an,lm=Pr,dm=Vr,hm=om,fm=jp.ArrayBuffer,pm=jp.DataView,mm=pm.prototype,vm=sm(fm.prototype.slice),_m=sm(mm.getUint8),gm=sm(mm.setUint8);am({target:"ArrayBuffer",proto:!0,unsafe:!0,forced:cm((function(){return!new fm(2).slice(1,void 0).byteLength}))},{slice:function(e,t){if(vm&&void 0===t)return vm(um(this),e);for(var n=um(this).byteLength,r=lm(e,n),i=lm(void 0===t?n:t,n),o=new(hm(this,fm))(dm(i-r)),a=new pm(this),s=new pm(o),c=0;r<i;)gm(s,c++,_m(a,r++));return o}}),Ci({global:!0,constructor:!0,forced:!uf},{DataView:jp.DataView});var ym=Ci,Em=Date,Tm=z(Em.prototype.getTime);ym({target:"Date",stat:!0},{now:function(){return Tm(new Em)}});var km=lt,Sm=Mt;Ci({target:"Date",proto:!0,arity:1,forced:D((function(){return null!==new Date(NaN).toJSON()||1!==Date.prototype.toJSON.call({toISOString:function(){return 1}})}))},{toJSON:function(e){var t=km(this),n=Sm(t,"number");return"number"!=typeof n||isFinite(n)?t.toISOString():null}});var Im=z,bm=Ir,Am=Date.prototype,Rm="Invalid Date",Cm="toString",wm=Im(Am[Cm]),Dm=Im(Am.getTime);String(new Date(NaN))!==Rm&&bm(Am,Cm,(function(){var e=Dm(this);return e==e?wm(this):Rm}));var Nm=z,xm=Ge,Om=fe,Pm=ft,Mm=mo,Lm=x,Vm=Function,Um=Nm([].concat),Fm=Nm([].join),Bm={},Hm=Lm?Vm.bind:function(e){var t=xm(this),n=t.prototype,r=Mm(arguments,1),i=function(){var n=Um(r,Mm(arguments));return this instanceof i?function(e,t,n){if(!Pm(Bm,t)){for(var r=[],i=0;i<t;i++)r[i]="a["+i+"]";Bm[t]=Vm("C,a","return new C("+Fm(r,",")+")")}return Bm[t](e,n)}(t,n.length,n):t.apply(e,n)};return Om(n)&&(i.prototype=n),i},jm=Hm;Ci({target:"Function",proto:!0,forced:Function.bind!==jm},{bind:jm});var Gm=N,Wm=Cn.EXISTS,Jm=z,Km=So,zm=Function.prototype,qm=Jm(zm.toString),Ym=/function\b(?:\s|\/\*[\S\s]*?\*\/|\/\/[^\n\r]*[\n\r]+)*([^\s(/]*)/,Xm=Jm(Ym.exec);Gm&&!Wm&&Km(zm,"name",{configurable:!0,get:function(){try{return Xm(Ym,qm(this))[1]}catch(t3){return""}}});var Qm={},$m={get exports(){return Qm},set exports(e){Qm=e}},Zm=D((function(){if("function"==typeof ArrayBuffer){var e=new ArrayBuffer(8);Object.isExtensible(e)&&Object.defineProperty(e,"a",{value:8})}})),ev=D,tv=fe,nv=Q,rv=Zm,iv=Object.isExtensible,ov=ev((function(){iv(1)}))||rv?function(e){return!!tv(e)&&((!rv||"ArrayBuffer"!==nv(e))&&(!iv||iv(e)))}:iv,av=!D((function(){return Object.isExtensible(Object.preventExtensions({}))})),sv=Ci,cv=z,uv=jn,lv=fe,dv=ft,hv=en.f,fv=br,pv=po,mv=ov,vv=av,_v=!1,gv=gt("meta"),yv=0,Ev=function(e){hv(e,gv,{value:{objectID:"O"+yv++,weakData:{}}})},Tv=$m.exports={enable:function(){Tv.enable=function(){},_v=!0;var e=fv.f,t=cv([].splice),n={};n[gv]=1,e(n).length&&(fv.f=function(n){for(var r=e(n),i=0,o=r.length;i<o;i++)if(r[i]===gv){t(r,i,1);break}return r},sv({target:"Object",stat:!0,forced:!0},{getOwnPropertyNames:pv.f}))},fastKey:function(e,t){if(!lv(e))return"symbol"==typeof e?e:("string"==typeof e?"S":"P")+e;if(!dv(e,gv)){if(!mv(e))return"F";if(!t)return"E";Ev(e)}return e[gv].objectID},getWeakData:function(e,t){if(!dv(e,gv)){if(!mv(e))return!0;if(!t)return!1;Ev(e)}return e[gv].weakData},onFreeze:function(e){return vv&&_v&&mv(e)&&!dv(e,gv)&&Ev(e),e}};uv[gv]=!0;var kv=Qu,Sv=Rt("iterator"),Iv=Array.prototype,bv=function(e){return void 0!==e&&(kv.Array===e||Iv[Sv]===e)},Av=Vi,Rv=Ke,Cv=re,wv=Qu,Dv=Rt("iterator"),Nv=function(e){if(!Cv(e))return Rv(e,Dv)||Rv(e,"@@iterator")||wv[Av(e)]},xv=M,Ov=Ge,Pv=an,Mv=Fe,Lv=Nv,Vv=TypeError,Uv=function(e,t){var n=arguments.length<2?Lv(e):t;if(Ov(n))return Pv(xv(n,e));throw new Vv(Mv(e)+" is not iterable")},Fv=M,Bv=an,Hv=Ke,jv=function(e,t,n){var r,i;Bv(e);try{if(!(r=Hv(e,"return"))){if("throw"===t)throw n;return n}r=Fv(r,e)}catch(t3){i=!0,r=t3}if("throw"===t)throw n;if(i)throw r;return Bv(r),n},Gv=Jo,Wv=M,Jv=an,Kv=Fe,zv=bv,qv=Fr,Yv=_e,Xv=Uv,Qv=Nv,$v=jv,Zv=TypeError,e_=function(e,t){this.stopped=e,this.result=t},t_=e_.prototype,n_=function(e,t,n){var r,i,o,a,s,c,u,l=n&&n.that,d=!(!n||!n.AS_ENTRIES),h=!(!n||!n.IS_RECORD),f=!(!n||!n.IS_ITERATOR),p=!(!n||!n.INTERRUPTED),m=Gv(t,l),v=function(e){return r&&$v(r,"normal",e),new e_(!0,e)},_=function(e){return d?(Jv(e),p?m(e[0],e[1],v):m(e[0],e[1])):p?m(e,v):m(e)};if(h)r=e.iterator;else if(f)r=e;else{if(!(i=Qv(e)))throw new Zv(Kv(e)+" is not iterable");if(zv(i)){for(o=0,a=qv(e);a>o;o++)if((s=_(e[o]))&&Yv(t_,s))return s;return new e_(!1)}r=Xv(e,i)}for(c=h?e.next:r.next;!(u=Wv(c,r)).done;){try{s=_(u.value)}catch(t3){$v(r,"throw",t3)}if("object"==typeof s&&s&&Yv(t_,s))return s}return new e_(!1)},r_=Rt("iterator"),i_=!1;try{var o_=0,a_={next:function(){return{done:!!o_++}},return:function(){i_=!0}};a_[r_]=function(){return this},Array.from(a_,(function(){throw 2}))}catch(t3){}var s_=function(e,t){try{if(!t&&!i_)return!1}catch(t3){return!1}var n=!1;try{var r={};r[r_]=function(){return{next:function(){return{done:n=!0}}}},e(r)}catch(t3){}return n},c_=Ci,u_=C,l_=z,d_=Ei,h_=Ir,f_=Qm,p_=n_,m_=pf,v_=de,__=re,g_=fe,y_=D,E_=s_,T_=Uo,k_=Bf,S_=function(e,t,n){var r=-1!==e.indexOf("Map"),i=-1!==e.indexOf("Weak"),o=r?"set":"add",a=u_[e],s=a&&a.prototype,c=a,u={},l=function(e){var t=l_(s[e]);h_(s,e,"add"===e?function(e){return t(this,0===e?0:e),this}:"delete"===e?function(e){return!(i&&!g_(e))&&t(this,0===e?0:e)}:"get"===e?function(e){return i&&!g_(e)?void 0:t(this,0===e?0:e)}:"has"===e?function(e){return!(i&&!g_(e))&&t(this,0===e?0:e)}:function(e,n){return t(this,0===e?0:e,n),this})};if(d_(e,!v_(a)||!(i||s.forEach&&!y_((function(){(new a).entries().next()})))))c=n.getConstructor(t,e,r,o),f_.enable();else if(d_(e,!0)){var d=new c,h=d[o](i?{}:-0,1)!==d,f=y_((function(){d.has(1)})),p=E_((function(e){new a(e)})),m=!i&&y_((function(){for(var e=new a,t=5;t--;)e[o](t,t);return!e.has(-0)}));p||((c=t((function(e,t){m_(e,s);var n=k_(new a,e,c);return __(t)||p_(t,n[o],{that:n,AS_ENTRIES:r}),n}))).prototype=s,s.constructor=c),(f||m)&&(l("delete"),l("has"),r&&l("get")),(m||h)&&l(o),i&&s.clear&&delete s.clear}return u[e]=c,c_({global:!0,constructor:!0,forced:c!==a},u),T_(c,e),i||n.setStrong(c,e,r),c},I_=fo,b_=So,A_=df,R_=Jo,C_=pf,w_=re,D_=n_,N_=Zl,x_=ed,O_=zp,P_=N,M_=Qm.fastKey,L_=nr.set,V_=nr.getterFor,U_={getConstructor:function(e,t,n,r){var i=e((function(e,i){C_(e,o),L_(e,{type:t,index:I_(null),first:null,last:null,size:0}),P_||(e.size=0),w_(i)||D_(i,e[r],{that:e,AS_ENTRIES:n})})),o=i.prototype,a=V_(t),s=function(e,t,n){var r,i,o=a(e),s=c(e,t);return s?s.value=n:(o.last=s={index:i=M_(t,!0),key:t,value:n,previous:r=o.last,next:null,removed:!1},o.first||(o.first=s),r&&(r.next=s),P_?o.size++:e.size++,"F"!==i&&(o.index[i]=s)),e},c=function(e,t){var n,r=a(e),i=M_(t);if("F"!==i)return r.index[i];for(n=r.first;n;n=n.next)if(n.key===t)return n};return A_(o,{clear:function(){for(var e=a(this),t=e.first;t;)t.removed=!0,t.previous&&(t.previous=t.previous.next=null),t=t.next;e.first=e.last=null,e.index=I_(null),P_?e.size=0:this.size=0},delete:function(e){var t=this,n=a(t),r=c(t,e);if(r){var i=r.next,o=r.previous;delete n.index[r.index],r.removed=!0,o&&(o.next=i),i&&(i.previous=o),n.first===r&&(n.first=i),n.last===r&&(n.last=o),P_?n.size--:t.size--}return!!r},forEach:function(e){for(var t,n=a(this),r=R_(e,arguments.length>1?arguments[1]:void 0);t=t?t.next:n.first;)for(r(t.value,t.key,this);t&&t.removed;)t=t.previous},has:function(e){return!!c(this,e)}}),A_(o,n?{get:function(e){var t=c(this,e);return t&&t.value},set:function(e,t){return s(this,0===e?0:e,t)}}:{add:function(e){return s(this,e=0===e?0:e,e)}}),P_&&b_(o,"size",{configurable:!0,get:function(){return a(this).size}}),i},setStrong:function(e,t,n){var r=t+" Iterator",i=V_(t),o=V_(r);N_(e,t,(function(e,t){L_(this,{type:r,target:e,state:i(e),kind:t,last:null})}),(function(){for(var e=o(this),t=e.kind,n=e.last;n&&n.removed;)n=n.previous;return e.target&&(e.last=n=n?n.next:e.state.first)?x_("keys"===t?n.key:"values"===t?n.value:[n.key,n.value],!1):(e.target=null,x_(void 0,!0))}),n?"entries":"values",!n,!0),O_(t)}};S_("Map",(function(e){return function(){return e(this,arguments.length?arguments[0]:void 0)}}),U_);var F_=Math.log,B_=Math.LOG10E,H_=Math.log10||function(e){return F_(e)*B_};Ci({target:"Math",stat:!0},{log10:H_});var j_=z(1..valueOf),G_="\t\n\v\f\r \u2028\u2029\ufeff",W_=ae,J_=Bi,K_=G_,z_=z("".replace),q_=RegExp("^["+K_+"]+"),Y_=RegExp("(^|[^"+K_+"])["+K_+"]+$"),X_=function(e){return function(t){var n=J_(W_(t));return 1&e&&(n=z_(n,q_,"")),2&e&&(n=z_(n,Y_,"$1")),n}},Q_={start:X_(1),end:X_(2),trim:X_(3)},$_=Ci,Z_=N,eg=C,tg=Ao,ng=z,rg=Ei,ig=ft,og=Bf,ag=_e,sg=Ve,cg=Mt,ug=D,lg=br.f,dg=w.f,hg=en.f,fg=j_,pg=Q_.trim,mg="Number",vg=eg[mg];tg[mg];var _g=vg.prototype,gg=eg.TypeError,yg=ng("".slice),Eg=ng("".charCodeAt),Tg=function(e){var t,n,r,i,o,a,s,c,u=cg(e,"number");if(sg(u))throw new gg("Cannot convert a Symbol value to a number");if("string"==typeof u&&u.length>2)if(u=pg(u),43===(t=Eg(u,0))||45===t){if(88===(n=Eg(u,2))||120===n)return NaN}else if(48===t){switch(Eg(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=yg(u,2)).length,s=0;s<a;s++)if((c=Eg(o,s))<48||c>i)return NaN;return parseInt(o,r)}return+u},kg=rg(mg,!vg(" 0o1")||!vg("0b1")||vg("+0x1")),Sg=function(e){var t,n=arguments.length<1?0:vg(function(e){var t=cg(e,"number");return"bigint"==typeof t?t:Tg(t)}(e));return ag(_g,t=this)&&ug((function(){fg(t)}))?og(Object(n),this,Sg):n};Sg.prototype=_g,kg&&(_g.constructor=Sg),$_({global:!0,constructor:!0,wrap:!0,forced:kg},{Number:Sg});kg&&function(e,t){for(var n,r=Z_?lg(t):"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(","),i=0;r.length>i;i++)ig(t,n=r[i])&&!ig(e,n)&&hg(e,n,dg(t,n))}(tg[mg],vg);var Ig=fe,bg=Math.floor,Ag=Number.isInteger||function(e){return!Ig(e)&&isFinite(e)&&bg(e)===e};Ci({target:"Number",stat:!0},{isInteger:Ag}),Ci({target:"Number",stat:!0},{isNaN:function(e){return e!=e}});var Rg=Dr,Cg=Bi,wg=ae,Dg=RangeError,Ng=function(e){var t=Cg(wg(this)),n="",r=Rg(e);if(r<0||Infinity===r)throw new Dg("Wrong number of repetitions");for(;r>0;(r>>>=1)&&(t+=t))1&r&&(n+=t);return n},xg=Ci,Og=z,Pg=Dr,Mg=j_,Lg=Ng,Vg=D,Ug=RangeError,Fg=String,Bg=Math.floor,Hg=Og(Lg),jg=Og("".slice),Gg=Og(1..toFixed),Wg=function(e,t,n){return 0===t?n:t%2==1?Wg(e,t-1,n*e):Wg(e*e,t/2,n)},Jg=function(e,t,n){for(var r=-1,i=n;++r<6;)i+=t*e[r],e[r]=i%1e7,i=Bg(i/1e7)},Kg=function(e,t){for(var n=6,r=0;--n>=0;)r+=e[n],e[n]=Bg(r/t),r=r%t*1e7},zg=function(e){for(var t=6,n="";--t>=0;)if(""!==n||0===t||0!==e[t]){var r=Fg(e[t]);n=""===n?r:n+Hg("0",7-r.length)+r}return n};xg({target:"Number",proto:!0,forced:Vg((function(){return"0.000"!==Gg(8e-5,3)||"1"!==Gg(.9,0)||"1.25"!==Gg(1.255,2)||"1000000000000000128"!==Gg(0xde0b6b3a7640080,0)}))||!Vg((function(){Gg({})}))},{toFixed:function(e){var t,n,r,i,o=Mg(this),a=Pg(e),s=[0,0,0,0,0,0],c="",u="0";if(a<0||a>20)throw new Ug("Incorrect fraction digits");if(o!=o)return"NaN";if(o<=-1e21||o>=1e21)return Fg(o);if(o<0&&(c="-",o=-o),o>1e-21)if(t=function(e){for(var t=0,n=e;n>=4096;)t+=12,n/=4096;for(;n>=2;)t+=1,n/=2;return t}(o*Wg(2,69,1))-69,n=t<0?o*Wg(2,-t,1):o/Wg(2,t,1),n*=4503599627370496,(t=52-t)>0){for(Jg(s,0,n),r=a;r>=7;)Jg(s,1e7,0),r-=7;for(Jg(s,Wg(10,r,1),0),r=t-1;r>=23;)Kg(s,1<<23),r-=23;Kg(s,1<<r),Jg(s,1,1),Kg(s,2),u=zg(s)}else Jg(s,0,n),Jg(s,1<<-t,0),u=zg(s)+Hg("0",a);return u=a>0?c+((i=u.length)<=a?"0."+Hg("0",a-i)+u:jg(u,0,i-a)+"."+jg(u,i-a)):c+u}});var qg=N,Yg=z,Xg=M,Qg=D,$g=Wi,Zg=ei,ey=L,ty=lt,ny=ne,ry=Object.assign,iy=Object.defineProperty,oy=Yg([].concat),ay=!ry||Qg((function(){if(qg&&1!==ry({b:1},ry(iy({},"a",{enumerable:!0,get:function(){iy(this,"b",{value:3,enumerable:!1})}}),{b:2})).b)return!0;var e={},t={},n=Symbol("assign detection"),r="abcdefghijklmnopqrst";return e[n]=7,r.split("").forEach((function(e){t[e]=e})),7!==ry({},e)[n]||$g(ry({},t)).join("")!==r}))?function(e,t){for(var n=ty(e),r=arguments.length,i=1,o=Zg.f,a=ey.f;r>i;)for(var s,c=ny(arguments[i++]),u=o?oy($g(c),o(c)):$g(c),l=u.length,d=0;l>d;)s=u[d++],qg&&!Xg(a,c,s)||(n[s]=c[s]);return n}:ry,sy=ay;Ci({target:"Object",stat:!0,arity:2,forced:Object.assign!==sy},{assign:sy}),Ci({target:"Object",stat:!0,sham:!N},{create:fo});var cy=Ci,uy=N,ly=Hi.f;cy({target:"Object",stat:!0,forced:Object.defineProperties!==ly,sham:!uy},{defineProperties:ly});var dy=Ci,hy=N,fy=en.f;dy({target:"Object",stat:!0,forced:Object.defineProperty!==fy,sham:!hy},{defineProperty:fy});var py=Ci,my=D,vy=ue,_y=w.f,gy=N;py({target:"Object",stat:!0,forced:!gy||my((function(){_y(1)})),sham:!gy},{getOwnPropertyDescriptor:function(e,t){return _y(vy(e),t)}});var yy=ai,Ey=ue,Ty=w,ky=eu;Ci({target:"Object",stat:!0,sham:!N},{getOwnPropertyDescriptors:function(e){for(var t,n,r=Ey(e),i=Ty.f,o=yy(r),a={},s=0;o.length>s;)void 0!==(n=i(r,t=o[s++]))&&ky(a,t,n);return a}});var Sy=Ci,Iy=D,by=po.f;Sy({target:"Object",stat:!0,forced:Iy((function(){return!Object.getOwnPropertyNames(1)}))},{getOwnPropertyNames:by});var Ay=lt,Ry=al,Cy=$u;Ci({target:"Object",stat:!0,forced:D((function(){Ry(1)})),sham:!Cy},{getPrototypeOf:function(e){return Ry(Ay(e))}});var wy=lt,Dy=Wi;Ci({target:"Object",stat:!0,forced:D((function(){Dy(1)}))},{keys:function(e){return Dy(wy(e))}}),Ci({target:"Object",stat:!0},{setPrototypeOf:Ol});var Ny=Vi,xy=Di?{}.toString:function(){return"[object "+Ny(this)+"]"};Di||Ir(Object.prototype,"toString",xy,{unsafe:!0});var Oy=N,Py=D,My=z,Ly=al,Vy=Wi,Uy=ue,Fy=My(L.f),By=My([].push),Hy=Oy&&Py((function(){var e=Object.create(null);return e[2]=2,!Fy(e,2)})),jy=function(e){return function(t){for(var n,r=Uy(t),i=Vy(r),o=Hy&&null===Ly(r),a=i.length,s=0,c=[];a>s;)n=i[s++],Oy&&!(o?n in r:Fy(r,n))||By(c,e?[n,r[n]]:r[n]);return c}},Gy={entries:jy(!0),values:jy(!1)}.values;Ci({target:"Object",stat:!0},{values:function(e){return Gy(e)}});var Wy=C,Jy=D,Ky=Bi,zy=Q_.trim,qy=G_,Yy=z("".charAt),Xy=Wy.parseFloat,Qy=Wy.Symbol,$y=Qy&&Qy.iterator,Zy=1/Xy(qy+"-0")!=-Infinity||$y&&!Jy((function(){Xy(Object($y))}))?function(e){var t=zy(Ky(e)),n=Xy(t);return 0===n&&"-"===Yy(t,0)?-0:n}:Xy;Ci({global:!0,forced:parseFloat!==Zy},{parseFloat:Zy});var eE=C,tE=D,nE=z,rE=Bi,iE=Q_.trim,oE=G_,aE=eE.parseInt,sE=eE.Symbol,cE=sE&&sE.iterator,uE=/^[+-]?0x/i,lE=nE(uE.exec),dE=8!==aE(oE+"08")||22!==aE(oE+"0x16")||cE&&!tE((function(){aE(Object(cE))}))?function(e,t){var n=iE(rE(e));return aE(n,t>>>0||(lE(uE,n)?16:10))}:aE;Ci({global:!0,forced:parseInt!==dE},{parseInt:dE});var hE,fE,pE,mE,vE=TypeError,_E=function(e,t){if(e<t)throw new vE("Not enough arguments");return e},gE=/(?:ipad|iphone|ipod).*applewebkit/i.test(Ee),yE=C,EE=Qs,TE=Jo,kE=de,SE=ft,IE=D,bE=$i,AE=mo,RE=jt,CE=_E,wE=gE,DE=Gd,NE=yE.setImmediate,xE=yE.clearImmediate,OE=yE.process,PE=yE.Dispatch,ME=yE.Function,LE=yE.MessageChannel,VE=yE.String,UE=0,FE={},BE="onreadystatechange";IE((function(){hE=yE.location}));var HE=function(e){if(SE(FE,e)){var t=FE[e];delete FE[e],t()}},jE=function(e){return function(){HE(e)}},GE=function(e){HE(e.data)},WE=function(e){yE.postMessage(VE(e),hE.protocol+"//"+hE.host)};NE&&xE||(NE=function(e){CE(arguments.length,1);var t=kE(e)?e:ME(e),n=AE(arguments,1);return FE[++UE]=function(){EE(t,void 0,n)},fE(UE),UE},xE=function(e){delete FE[e]},DE?fE=function(e){OE.nextTick(jE(e))}:PE&&PE.now?fE=function(e){PE.now(jE(e))}:LE&&!wE?(mE=(pE=new LE).port2,pE.port1.onmessage=GE,fE=TE(mE.postMessage,mE)):yE.addEventListener&&kE(yE.postMessage)&&!yE.importScripts&&hE&&"file:"!==hE.protocol&&!IE(WE)?(fE=WE,yE.addEventListener("message",GE,!1)):fE=BE in RE("script")?function(e){bE.appendChild(RE("script"))[BE]=function(){bE.removeChild(this),HE(e)}}:function(e){setTimeout(jE(e),0)});var JE={set:NE,clear:xE},KE=C,zE=N,qE=Object.getOwnPropertyDescriptor,YE=function(e){if(!zE)return KE[e];var t=qE(KE,e);return t&&t.value},XE=function(){this.head=null,this.tail=null};XE.prototype={add:function(e){var t={item:e,next:null},n=this.tail;n?n.next=t:this.head=t,this.tail=t},get:function(){var e=this.head;if(e)return null===(this.head=e.next)&&(this.tail=null),e.item}};var QE,$E,ZE,eT,tT,nT=XE,rT=/ipad|iphone|ipod/i.test(Ee)&&"undefined"!=typeof Pebble,iT=/web0s(?!.*chrome)/i.test(Ee),oT=C,aT=YE,sT=Jo,cT=JE.set,uT=nT,lT=gE,dT=rT,hT=iT,fT=Gd,pT=oT.MutationObserver||oT.WebKitMutationObserver,mT=oT.document,vT=oT.process,_T=oT.Promise,gT=aT("queueMicrotask");if(!gT){var yT=new uT,ET=function(){var e,t;for(fT&&(e=vT.domain)&&e.exit();t=yT.get();)try{t()}catch(t3){throw yT.head&&QE(),t3}e&&e.enter()};lT||fT||hT||!pT||!mT?!dT&&_T&&_T.resolve?((eT=_T.resolve(void 0)).constructor=_T,tT=sT(eT.then,eT),QE=function(){tT(ET)}):fT?QE=function(){vT.nextTick(ET)}:(cT=sT(cT,oT),QE=function(){cT(ET)}):($E=!0,ZE=mT.createTextNode(""),new pT(ET).observe(ZE,{characterData:!0}),QE=function(){ZE.data=$E=!$E}),gT=function(e){yT.head||QE(),yT.add(e)}}var TT=gT,kT=function(e){try{return{error:!1,value:e()}}catch(t3){return{error:!0,value:t3}}},ST=C.Promise,IT=C,bT=ST,AT=de,RT=Ei,CT=Mn,wT=Rt,DT=jd,NT=Re;bT&&bT.prototype;var xT=wT("species"),OT=!1,PT=AT(IT.PromiseRejectionEvent),MT=RT("Promise",(function(){var e=CT(bT),t=e!==String(bT);if(!t&&66===NT)return!0;if(!NT||NT<51||!/native code/.test(e)){var n=new bT((function(e){e(1)})),r=function(e){e((function(){}),(function(){}))};if((n.constructor={})[xT]=r,!(OT=n.then((function(){}))instanceof r))return!0}return!(t||"BROWSER"!==DT&&"DENO"!==DT||PT)})),LT={CONSTRUCTOR:MT,REJECTION_EVENT:PT,SUBCLASSING:OT},VT={},UT=Ge,FT=TypeError,BT=function(e){var t,n;this.promise=new e((function(e,r){if(void 0!==t||void 0!==n)throw new FT("Bad Promise constructor");t=e,n=r})),this.resolve=UT(t),this.reject=UT(n)};VT.f=function(e){return new BT(e)};var HT,jT,GT,WT=Ci,JT=Gd,KT=C,zT=M,qT=Ir,YT=Ol,XT=Uo,QT=zp,$T=Ge,ZT=de,ek=fe,tk=pf,nk=om,rk=JE.set,ik=TT,ok=function(e,t){try{1===arguments.length?console.error(e):console.error(e,t)}catch(t3){}},ak=kT,sk=nT,ck=nr,uk=ST,lk=VT,dk="Promise",hk=LT.CONSTRUCTOR,fk=LT.REJECTION_EVENT,pk=LT.SUBCLASSING,mk=ck.getterFor(dk),vk=ck.set,_k=uk&&uk.prototype,gk=uk,yk=_k,Ek=KT.TypeError,Tk=KT.document,kk=KT.process,Sk=lk.f,Ik=Sk,bk=!!(Tk&&Tk.createEvent&&KT.dispatchEvent),Ak="unhandledrejection",Rk=function(e){var t;return!(!ek(e)||!ZT(t=e.then))&&t},Ck=function(e,t){var n,r,i,o=t.value,a=1===t.state,s=a?e.ok:e.fail,c=e.resolve,u=e.reject,l=e.domain;try{s?(a||(2===t.rejection&&Ok(t),t.rejection=1),!0===s?n=o:(l&&l.enter(),n=s(o),l&&(l.exit(),i=!0)),n===e.promise?u(new Ek("Promise-chain cycle")):(r=Rk(n))?zT(r,n,c,u):c(n)):u(o)}catch(t3){l&&!i&&l.exit(),u(t3)}},wk=function(e,t){e.notified||(e.notified=!0,ik((function(){for(var n,r=e.reactions;n=r.get();)Ck(n,e);e.notified=!1,t&&!e.rejection&&Nk(e)})))},Dk=function(e,t,n){var r,i;bk?((r=Tk.createEvent("Event")).promise=t,r.reason=n,r.initEvent(e,!1,!0),KT.dispatchEvent(r)):r={promise:t,reason:n},!fk&&(i=KT["on"+e])?i(r):e===Ak&&ok("Unhandled promise rejection",n)},Nk=function(e){zT(rk,KT,(function(){var t,n=e.facade,r=e.value;if(xk(e)&&(t=ak((function(){JT?kk.emit("unhandledRejection",r,n):Dk(Ak,n,r)})),e.rejection=JT||xk(e)?2:1,t.error))throw t.value}))},xk=function(e){return 1!==e.rejection&&!e.parent},Ok=function(e){zT(rk,KT,(function(){var t=e.facade;JT?kk.emit("rejectionHandled",t):Dk("rejectionhandled",t,e.value)}))},Pk=function(e,t,n){return function(r){e(t,r,n)}},Mk=function(e,t,n){e.done||(e.done=!0,n&&(e=n),e.value=t,e.state=2,wk(e,!0))},Lk=function(e,t,n){if(!e.done){e.done=!0,n&&(e=n);try{if(e.facade===t)throw new Ek("Promise can't be resolved itself");var r=Rk(t);r?ik((function(){var n={done:!1};try{zT(r,t,Pk(Lk,n,e),Pk(Mk,n,e))}catch(t3){Mk(n,t3,e)}})):(e.value=t,e.state=1,wk(e,!1))}catch(t3){Mk({done:!1},t3,e)}}};if(hk&&(yk=(gk=function(e){tk(this,yk),$T(e),zT(HT,this);var t=mk(this);try{e(Pk(Lk,t),Pk(Mk,t))}catch(t3){Mk(t,t3)}}).prototype,(HT=function(e){vk(this,{type:dk,done:!1,notified:!1,parent:!1,reactions:new sk,rejection:!1,state:0,value:null})}).prototype=qT(yk,"then",(function(e,t){var n=mk(this),r=Sk(nk(this,gk));return n.parent=!0,r.ok=!ZT(e)||e,r.fail=ZT(t)&&t,r.domain=JT?kk.domain:void 0,0===n.state?n.reactions.add(r):ik((function(){Ck(r,n)})),r.promise})),jT=function(){var e=new HT,t=mk(e);this.promise=e,this.resolve=Pk(Lk,t),this.reject=Pk(Mk,t)},lk.f=Sk=function(e){return e===gk||undefined===e?new jT(e):Ik(e)},ZT(uk)&&_k!==Object.prototype)){GT=_k.then,pk||qT(_k,"then",(function(e,t){var n=this;return new gk((function(e,t){zT(GT,n,e,t)})).then(e,t)}),{unsafe:!0});try{delete _k.constructor}catch(t3){}YT&&YT(_k,yk)}WT({global:!0,constructor:!0,wrap:!0,forced:hk},{Promise:gk}),XT(gk,dk,!1),QT(dk);var Vk=ST,Uk=LT.CONSTRUCTOR||!s_((function(e){Vk.all(e).then(void 0,(function(){}))})),Fk=M,Bk=Ge,Hk=VT,jk=kT,Gk=n_;Ci({target:"Promise",stat:!0,forced:Uk},{all:function(e){var t=this,n=Hk.f(t),r=n.resolve,i=n.reject,o=jk((function(){var n=Bk(t.resolve),o=[],a=0,s=1;Gk(e,(function(e){var c=a++,u=!1;s++,Fk(n,t,e).then((function(e){u||(u=!0,o[c]=e,--s||r(o))}),i)})),--s||r(o)}));return o.error&&i(o.value),n.promise}});var Wk=Ci,Jk=LT.CONSTRUCTOR,Kk=ST,zk=ve,qk=de,Yk=Ir,Xk=Kk&&Kk.prototype;if(Wk({target:"Promise",proto:!0,forced:Jk,real:!0},{catch:function(e){return this.then(void 0,e)}}),qk(Kk)){var Qk=zk("Promise").prototype.catch;Xk.catch!==Qk&&Yk(Xk,"catch",Qk,{unsafe:!0})}var $k=M,Zk=Ge,eS=VT,tS=kT,nS=n_;Ci({target:"Promise",stat:!0,forced:Uk},{race:function(e){var t=this,n=eS.f(t),r=n.reject,i=tS((function(){var i=Zk(t.resolve);nS(e,(function(e){$k(i,t,e).then(n.resolve,r)}))}));return i.error&&r(i.value),n.promise}});var rS=VT;Ci({target:"Promise",stat:!0,forced:LT.CONSTRUCTOR},{reject:function(e){var t=rS.f(this);return(0,t.reject)(e),t.promise}});var iS=an,oS=fe,aS=VT,sS=function(e,t){if(iS(e),oS(t)&&t.constructor===e)return t;var n=aS.f(e);return(0,n.resolve)(t),n.promise},cS=Ci,uS=LT.CONSTRUCTOR,lS=sS;ve("Promise"),cS({target:"Promise",stat:!0,forced:uS},{resolve:function(e){return lS(this,e)}});var dS=Ci,hS=ST,fS=D,pS=ve,mS=de,vS=om,_S=sS,gS=Ir,yS=hS&&hS.prototype;if(dS({target:"Promise",proto:!0,real:!0,forced:!!hS&&fS((function(){yS.finally.call({then:function(){}},(function(){}))}))},{finally:function(e){var t=vS(this,pS("Promise")),n=mS(e);return this.then(n?function(n){return _S(t,e()).then((function(){return n}))}:e,n?function(n){return _S(t,e()).then((function(){throw n}))}:e)}}),mS(hS)){var ES=pS("Promise").prototype.finally;yS.finally!==ES&&gS(yS,"finally",ES,{unsafe:!0})}var TS=Qs,kS=Ge,SS=an;Ci({target:"Reflect",stat:!0,forced:!D((function(){Reflect.apply((function(){}))}))},{apply:function(e,t,n){return TS(kS(e),t,SS(n))}});var IS=ft,bS=M,AS=fe,RS=an,CS=function(e){return void 0!==e&&(IS(e,"value")||IS(e,"writable"))},wS=w,DS=al;Ci({target:"Reflect",stat:!0},{get:function e(t,n){var r,i,o=arguments.length<3?t:arguments[2];return RS(t)===o?t[n]:(r=wS.f(t,n))?CS(r)?r.value:void 0===r.get?void 0:bS(r.get,o):AS(i=DS(t))?e(i,n,o):void 0}}),Ci({target:"Reflect",stat:!0},{ownKeys:ai});var NS=fe,xS=Q,OS=Rt("match"),PS=function(e){var t;return NS(e)&&(void 0!==(t=e[OS])?!!t:"RegExp"===xS(e))},MS=an,LS=function(){var e=MS(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},VS=M,US=ft,FS=_e,BS=LS,HS=RegExp.prototype,jS=function(e){var t=e.flags;return void 0!==t||"flags"in HS||US(e,"flags")||!FS(HS,e)?t:VS(BS,e)},GS=D,WS=C.RegExp,JS=GS((function(){var e=WS("a","y");return e.lastIndex=2,null!==e.exec("abcd")})),KS=JS||GS((function(){return!WS("a","y").sticky})),zS=JS||GS((function(){var e=WS("^r","gy");return e.lastIndex=2,null!==e.exec("str")})),qS={BROKEN_CARET:zS,MISSED_STICKY:KS,UNSUPPORTED_Y:JS},YS=en.f,XS=D,QS=C.RegExp,$S=XS((function(){var e=QS(".","s");return!(e.dotAll&&e.test("\n")&&"s"===e.flags)})),ZS=D,eI=C.RegExp,tI=ZS((function(){var e=eI("(?<a>b)","g");return"b"!==e.exec("b").groups.a||"bc"!=="b".replace(e,"$<a>c")})),nI=N,rI=C,iI=z,oI=Ei,aI=Bf,sI=En,cI=fo,uI=br.f,lI=_e,dI=PS,hI=Bi,fI=jS,pI=qS,mI=function(e,t,n){n in e||YS(e,n,{configurable:!0,get:function(){return t[n]},set:function(e){t[n]=e}})},vI=Ir,_I=D,gI=ft,yI=nr.enforce,EI=zp,TI=$S,kI=tI,SI=Rt("match"),II=rI.RegExp,bI=II.prototype,AI=rI.SyntaxError,RI=iI(bI.exec),CI=iI("".charAt),wI=iI("".replace),DI=iI("".indexOf),NI=iI("".slice),xI=/^\?<[^\s\d!#%&*+<=>@^][^\s!#%&*+<=>@^]*>/,OI=/a/g,PI=/a/g,MI=new II(OI)!==OI,LI=pI.MISSED_STICKY,VI=pI.UNSUPPORTED_Y,UI=nI&&(!MI||LI||TI||kI||_I((function(){return PI[SI]=!1,II(OI)!==OI||II(PI)===PI||"/a/i"!==String(II(OI,"i"))})));if(oI("RegExp",UI)){for(var FI=function(e,t){var n,r,i,o,a,s,c=lI(bI,this),u=dI(e),l=void 0===t,d=[],h=e;if(!c&&u&&l&&e.constructor===FI)return e;if((u||lI(bI,e))&&(e=e.source,l&&(t=fI(h))),e=void 0===e?"":hI(e),t=void 0===t?"":hI(t),h=e,TI&&"dotAll"in OI&&(r=!!t&&DI(t,"s")>-1)&&(t=wI(t,/s/g,"")),n=t,LI&&"sticky"in OI&&(i=!!t&&DI(t,"y")>-1)&&VI&&(t=wI(t,/y/g,"")),kI&&(o=function(e){for(var t,n=e.length,r=0,i="",o=[],a=cI(null),s=!1,c=!1,u=0,l="";r<=n;r++){if("\\"===(t=CI(e,r)))t+=CI(e,++r);else if("]"===t)s=!1;else if(!s)switch(!0){case"["===t:s=!0;break;case"("===t:if(i+=t,"?:"===NI(e,r+1,r+3))continue;RI(xI,NI(e,r+1))&&(r+=2,c=!0),u++;continue;case">"===t&&c:if(""===l||gI(a,l))throw new AI("Invalid capture group name");a[l]=!0,o[o.length]=[l,u],c=!1,l="";continue}c?l+=t:i+=t}return[i,o]}(e),e=o[0],d=o[1]),a=aI(II(e,t),c?this:bI,FI),(r||i||d.length)&&(s=yI(a),r&&(s.dotAll=!0,s.raw=FI(function(e){for(var t,n=e.length,r=0,i="",o=!1;r<=n;r++)"\\"!==(t=CI(e,r))?o||"."!==t?("["===t?o=!0:"]"===t&&(o=!1),i+=t):i+="[\\s\\S]":i+=t+CI(e,++r);return i}(e),n)),i&&(s.sticky=!0),d.length&&(s.groups=d)),e!==h)try{sI(a,"source",""===h?"(?:)":h)}catch(t3){}return a},BI=uI(II),HI=0;BI.length>HI;)mI(FI,II,BI[HI++]);bI.constructor=FI,FI.prototype=bI,vI(rI,"RegExp",FI,{constructor:!0})}EI("RegExp");var jI=M,GI=z,WI=Bi,JI=LS,KI=qS,zI=fo,qI=nr.get,YI=$S,XI=tI,QI=st("native-string-replace",String.prototype.replace),$I=RegExp.prototype.exec,ZI=$I,eb=GI("".charAt),tb=GI("".indexOf),nb=GI("".replace),rb=GI("".slice),ib=function(){var e=/a/,t=/b*/g;return jI($I,e,"a"),jI($I,t,"a"),0!==e.lastIndex||0!==t.lastIndex}(),ob=KI.BROKEN_CARET,ab=void 0!==/()??/.exec("")[1];(ib||ab||ob||YI||XI)&&(ZI=function(e){var t,n,r,i,o,a,s,c=this,u=qI(c),l=WI(e),d=u.raw;if(d)return d.lastIndex=c.lastIndex,t=jI(ZI,d,l),c.lastIndex=d.lastIndex,t;var h=u.groups,f=ob&&c.sticky,p=jI(JI,c),m=c.source,v=0,_=l;if(f&&(p=nb(p,"y",""),-1===tb(p,"g")&&(p+="g"),_=rb(l,c.lastIndex),c.lastIndex>0&&(!c.multiline||c.multiline&&"\n"!==eb(l,c.lastIndex-1))&&(m="(?: "+m+")",_=" "+_,v++),n=new RegExp("^(?:"+m+")",p)),ab&&(n=new RegExp("^"+m+"$(?!\\s)",p)),ib&&(r=c.lastIndex),i=jI($I,f?n:c,_),f?i?(i.input=rb(i.input,v),i[0]=rb(i[0],v),i.index=c.lastIndex,c.lastIndex+=i[0].length):c.lastIndex=0:ib&&i&&(c.lastIndex=c.global?i.index+i[0].length:r),ab&&i&&i.length>1&&jI(QI,i[0],n,(function(){for(o=1;o<arguments.length-2;o++)void 0===arguments[o]&&(i[o]=void 0)})),i&&h)for(i.groups=a=zI(null),o=0;o<h.length;o++)a[(s=h[o])[0]]=i[s[1]];return i});var sb=ZI;Ci({target:"RegExp",proto:!0,forced:/./.exec!==sb},{exec:sb});var cb=Cn.PROPER,ub=Ir,lb=an,db=Bi,hb=D,fb=jS,pb="toString",mb=RegExp.prototype,vb=mb[pb],_b=hb((function(){return"/a/b"!==vb.call({source:"a",flags:"b"})})),gb=cb&&vb.name!==pb;(_b||gb)&&ub(mb,pb,(function(){var e=lb(this);return"/"+db(e.source)+"/"+db(fb(e))}),{unsafe:!0}),S_("Set",(function(e){return function(){return e(this,arguments.length?arguments[0]:void 0)}}),U_);var yb=PS,Eb=TypeError,Tb=function(e){if(yb(e))throw new Eb("The method doesn't accept regular expressions");return e},kb=Rt("match"),Sb=function(e){var t=/./;try{"/./"[e](t)}catch(n){try{return t[kb]=!1,"/./"[e](t)}catch(r){}}return!1},Ib=Ci,bb=Tb,Ab=ae,Rb=Bi,Cb=Sb,wb=z("".indexOf);Ib({target:"String",proto:!0,forced:!Cb("includes")},{includes:function(e){return!!~wb(Rb(Ab(this)),Rb(bb(e)),arguments.length>1?arguments[1]:void 0)}});var Db=z,Nb=Dr,xb=Bi,Ob=ae,Pb=Db("".charAt),Mb=Db("".charCodeAt),Lb=Db("".slice),Vb=function(e){return function(t,n){var r,i,o=xb(Ob(t)),a=Nb(n),s=o.length;return a<0||a>=s?e?"":void 0:(r=Mb(o,a))<55296||r>56319||a+1===s||(i=Mb(o,a+1))<56320||i>57343?e?Pb(o,a):r:e?Lb(o,a,a+2):i-56320+(r-55296<<10)+65536}},Ub={codeAt:Vb(!1),charAt:Vb(!0)},Fb=Ub.charAt,Bb=Bi,Hb=nr,jb=Zl,Gb=ed,Wb="String Iterator",Jb=Hb.set,Kb=Hb.getterFor(Wb);jb(String,"String",(function(e){Jb(this,{type:Wb,string:Bb(e),index:0})}),(function(){var e,t=Kb(this),n=t.string,r=t.index;return r>=n.length?Gb(void 0,!0):(e=Fb(n,r),t.index+=e.length,Gb(e,!1))}));var zb=M,qb=Ir,Yb=sb,Xb=D,Qb=Rt,$b=En,Zb=Qb("species"),eA=RegExp.prototype,tA=function(e,t,n,r){var i=Qb(e),o=!Xb((function(){var t={};return t[i]=function(){return 7},7!==""[e](t)})),a=o&&!Xb((function(){var t=!1,n=/a/;return"split"===e&&((n={}).constructor={},n.constructor[Zb]=function(){return n},n.flags="",n[i]=/./[i]),n.exec=function(){return t=!0,null},n[i](""),!t}));if(!o||!a||n){var s=/./[i],c=t(i,""[e],(function(e,t,n,r,i){var a=t.exec;return a===Yb||a===eA.exec?o&&!i?{done:!0,value:zb(s,t,n,r)}:{done:!0,value:zb(e,n,t,r)}:{done:!1}}));qb(String.prototype,e,c[0]),qb(eA,i,c[1])}r&&$b(eA[i],"sham",!0)},nA=Ub.charAt,rA=function(e,t,n){return t+(n?nA(e,t).length:1)},iA=M,oA=an,aA=de,sA=Q,cA=sb,uA=TypeError,lA=function(e,t){var n=e.exec;if(aA(n)){var r=iA(n,e,t);return null!==r&&oA(r),r}if("RegExp"===sA(e))return iA(cA,e,t);throw new uA("RegExp#exec called on incompatible receiver")},dA=M,hA=an,fA=re,pA=Vr,mA=Bi,vA=ae,_A=Ke,gA=rA,yA=lA;tA("match",(function(e,t,n){return[function(t){var n=vA(this),r=fA(t)?void 0:_A(t,e);return r?dA(r,t,n):new RegExp(t)[e](mA(n))},function(e){var r=hA(this),i=mA(e),o=n(t,r,i);if(o.done)return o.value;if(!r.global)return yA(r,i);var a=r.unicode;r.lastIndex=0;for(var s,c=[],u=0;null!==(s=yA(r,i));){var l=mA(s[0]);c[u]=l,""===l&&(r.lastIndex=gA(i,pA(r.lastIndex),a)),u++}return 0===u?null:c}]}));var EA=z,TA=Vr,kA=Bi,SA=ae,IA=EA(Ng),bA=EA("".slice),AA=Math.ceil,RA=function(e){return function(t,n,r){var i,o,a=kA(SA(t)),s=TA(n),c=a.length,u=void 0===r?" ":kA(r);return s<=c||""===u?a:((o=IA(u,AA((i=s-c)/u.length))).length>i&&(o=bA(o,0,i)),e?a+o:o+a)}},CA={start:RA(!1),end:RA(!0)},wA=/Version\/10(?:\.\d+){1,2}(?: [\w./]+)?(?: Mobile\/\w+)? Safari\//.test(Ee),DA=CA.start;Ci({target:"String",proto:!0,forced:wA},{padStart:function(e){return DA(this,e,arguments.length>1?arguments[1]:void 0)}});var NA=z,xA=lt,OA=Math.floor,PA=NA("".charAt),MA=NA("".replace),LA=NA("".slice),VA=/\$([$&'`]|\d{1,2}|<[^>]*>)/g,UA=/\$([$&'`]|\d{1,2})/g,FA=Qs,BA=M,HA=z,jA=tA,GA=D,WA=an,JA=de,KA=re,zA=Dr,qA=Vr,YA=Bi,XA=ae,QA=rA,$A=Ke,ZA=function(e,t,n,r,i,o){var a=n+e.length,s=r.length,c=UA;return void 0!==i&&(i=xA(i),c=VA),MA(o,c,(function(o,c){var u;switch(PA(c,0)){case"$":return"$";case"&":return e;case"`":return LA(t,0,n);case"'":return LA(t,a);case"<":u=i[LA(c,1,-1)];break;default:var l=+c;if(0===l)return o;if(l>s){var d=OA(l/10);return 0===d?o:d<=s?void 0===r[d-1]?PA(c,1):r[d-1]+PA(c,1):o}u=r[l-1]}return void 0===u?"":u}))},eR=lA,tR=Rt("replace"),nR=Math.max,rR=Math.min,iR=HA([].concat),oR=HA([].push),aR=HA("".indexOf),sR=HA("".slice),cR=function(e){return void 0===e?e:String(e)},uR="$0"==="a".replace(/./,"$0"),lR=!!/./[tR]&&""===/./[tR]("a","$0"),dR=!GA((function(){var e=/./;return e.exec=function(){var e=[];return e.groups={a:"7"},e},"7"!=="".replace(e,"$<a>")}));jA("replace",(function(e,t,n){var r=lR?"$":"$0";return[function(e,n){var r=XA(this),i=KA(e)?void 0:$A(e,tR);return i?BA(i,e,r,n):BA(t,YA(r),e,n)},function(e,i){var o=WA(this),a=YA(e);if("string"==typeof i&&-1===aR(i,r)&&-1===aR(i,"$<")){var s=n(t,o,a,i);if(s.done)return s.value}var c=JA(i);c||(i=YA(i));var u,l=o.global;l&&(u=o.unicode,o.lastIndex=0);for(var d,h=[];null!==(d=eR(o,a))&&(oR(h,d),l);){""===YA(d[0])&&(o.lastIndex=QA(a,qA(o.lastIndex),u))}for(var f="",p=0,m=0;m<h.length;m++){for(var v,_=YA((d=h[m])[0]),g=nR(rR(zA(d.index),a.length),0),y=[],E=1;E<d.length;E++)oR(y,cR(d[E]));var T=d.groups;if(c){var k=iR([_],y,g,a);void 0!==T&&oR(k,T),v=YA(FA(i,void 0,k))}else v=ZA(_,a,g,y,T,i);g>=p&&(f+=sR(a,p,g)+v,p=g+_.length)}return f+sR(a,p)}]}),!dR||!uR||lR);var hR=Object.is||function(e,t){return e===t?0!==e||1/e==1/t:e!=e&&t!=t},fR=M,pR=an,mR=re,vR=ae,_R=hR,gR=Bi,yR=Ke,ER=lA;tA("search",(function(e,t,n){return[function(t){var n=vR(this),r=mR(t)?void 0:yR(t,e);return r?fR(r,t,n):new RegExp(t)[e](gR(n))},function(e){var r=pR(this),i=gR(e),o=n(t,r,i);if(o.done)return o.value;var a=r.lastIndex;_R(a,0)||(r.lastIndex=0);var s=ER(r,i);return _R(r.lastIndex,a)||(r.lastIndex=a),null===s?-1:s.index}]}));var TR=M,kR=z,SR=tA,IR=an,bR=re,AR=ae,RR=om,CR=rA,wR=Vr,DR=Bi,NR=Ke,xR=lA,OR=D,PR=qS.UNSUPPORTED_Y,MR=Math.min,LR=kR([].push),VR=kR("".slice),UR=!OR((function(){var e=/(?:)/,t=e.exec;e.exec=function(){return t.apply(this,arguments)};var n="ab".split(e);return 2!==n.length||"a"!==n[0]||"b"!==n[1]})),FR="c"==="abbc".split(/(b)*/)[1]||4!=="test".split(/(?:)/,-1).length||2!=="ab".split(/(?:ab)*/).length||4!==".".split(/(.?)(.?)/).length||".".split(/()()/).length>1||"".split(/.?/).length;SR("split",(function(e,t,n){var r="0".split(void 0,0).length?function(e,n){return void 0===e&&0===n?[]:TR(t,this,e,n)}:t;return[function(t,n){var i=AR(this),o=bR(t)?void 0:NR(t,e);return o?TR(o,t,i,n):TR(r,DR(i),t,n)},function(e,i){var o=IR(this),a=DR(e);if(!FR){var s=n(r,o,a,i,r!==t);if(s.done)return s.value}var c=RR(o,RegExp),u=o.unicode,l=(o.ignoreCase?"i":"")+(o.multiline?"m":"")+(o.unicode?"u":"")+(PR?"g":"y"),d=new c(PR?"^(?:"+o.source+")":o,l),h=void 0===i?4294967295:i>>>0;if(0===h)return[];if(0===a.length)return null===xR(d,a)?[a]:[];for(var f=0,p=0,m=[];p<a.length;){d.lastIndex=PR?0:p;var v,_=xR(d,PR?VR(a,p):a);if(null===_||(v=MR(wR(d.lastIndex+(PR?p:0)),a.length))===f)p=CR(a,p,u);else{if(LR(m,VR(a,f,p)),m.length===h)return m;for(var g=1;g<=_.length-1;g++)if(LR(m,_[g]),m.length===h)return m;p=f=v}}return LR(m,VR(a,f)),m}]}),FR||!UR,PR);var BR,HR=Ci,jR=Ho,GR=w.f,WR=Vr,JR=Bi,KR=Tb,zR=ae,qR=Sb,YR=jR("".slice),XR=Math.min,QR=qR("startsWith");HR({target:"String",proto:!0,forced:!!(QR||(BR=GR(String.prototype,"startsWith"),!BR||BR.writable))&&!QR},{startsWith:function(e){var t=JR(zR(this));KR(e);var n=WR(XR(arguments.length>1?arguments[1]:void 0,t.length)),r=JR(e);return YR(t,n,n+r.length)===r}});var $R=Cn.PROPER,ZR=D,eC=G_,tC=Q_.trim;Ci({target:"String",proto:!0,forced:function(e){return ZR((function(){return!!eC[e]()||"
"!=="
"[e]()||$R&&eC[e].name!==e}))}("trim")},{trim:function(){return tC(this)}});var nC=ae,rC=Bi,iC=/"/g,oC=z("".replace),aC=function(e,t,n,r){var i=rC(nC(e)),o="<"+t;return""!==n&&(o+=" "+n+'="'+oC(rC(r),iC,""")+'"'),o+">"+i+"</"+t+">"},sC=D,cC=function(e){return sC((function(){var t=""[e]('"');return t!==t.toLowerCase()||t.split('"').length>3}))},uC=aC;Ci({target:"String",proto:!0,forced:cC("link")},{link:function(e){return uC(this,"a","href",e)}});var lC=aC;Ci({target:"String",proto:!0,forced:cC("small")},{small:function(){return lC(this,"small","","")}});var dC,hC,fC,pC={},mC={get exports(){return pC},set exports(e){pC=e}},vC=uf,_C=N,gC=C,yC=de,EC=fe,TC=ft,kC=Vi,SC=Fe,IC=En,bC=Ir,AC=So,RC=_e,CC=al,wC=Ol,DC=Rt,NC=gt,xC=nr.enforce,OC=nr.get,PC=gC.Int8Array,MC=PC&&PC.prototype,LC=gC.Uint8ClampedArray,VC=LC&&LC.prototype,UC=PC&&CC(PC),FC=MC&&CC(MC),BC=Object.prototype,HC=gC.TypeError,jC=DC("toStringTag"),GC=NC("TYPED_ARRAY_TAG"),WC="TypedArrayConstructor",JC=vC&&!!wC&&"Opera"!==kC(gC.opera),KC=!1,zC={Int8Array:1,Uint8Array:1,Uint8ClampedArray:1,Int16Array:2,Uint16Array:2,Int32Array:4,Uint32Array:4,Float32Array:4,Float64Array:8},qC={BigInt64Array:8,BigUint64Array:8},YC=function(e){var t=CC(e);if(EC(t)){var n=OC(t);return n&&TC(n,WC)?n[WC]:YC(t)}},XC=function(e){if(!EC(e))return!1;var t=kC(e);return TC(zC,t)||TC(qC,t)};for(dC in zC)(fC=(hC=gC[dC])&&hC.prototype)?xC(fC)[WC]=hC:JC=!1;for(dC in qC)(fC=(hC=gC[dC])&&hC.prototype)&&(xC(fC)[WC]=hC);if((!JC||!yC(UC)||UC===Function.prototype)&&(UC=function(){throw new HC("Incorrect invocation")},JC))for(dC in zC)gC[dC]&&wC(gC[dC],UC);if((!JC||!FC||FC===BC)&&(FC=UC.prototype,JC))for(dC in zC)gC[dC]&&wC(gC[dC].prototype,FC);if(JC&&CC(VC)!==FC&&wC(VC,FC),_C&&!TC(FC,jC))for(dC in KC=!0,AC(FC,jC,{configurable:!0,get:function(){return EC(this)?this[GC]:void 0}}),zC)gC[dC]&&IC(gC[dC],GC,dC);var QC={NATIVE_ARRAY_BUFFER_VIEWS:JC,TYPED_ARRAY_TAG:KC&&GC,aTypedArray:function(e){if(XC(e))return e;throw new HC("Target is not a typed array")},aTypedArrayConstructor:function(e){if(yC(e)&&(!wC||RC(UC,e)))return e;throw new HC(SC(e)+" is not a typed array constructor")},exportTypedArrayMethod:function(e,t,n,r){if(_C){if(n)for(var i in zC){var o=gC[i];if(o&&TC(o.prototype,e))try{delete o.prototype[e]}catch(t3){try{o.prototype[e]=t}catch(a){}}}FC[e]&&!n||bC(FC,e,n?t:JC&&MC[e]||t,r)}},exportTypedArrayStaticMethod:function(e,t,n){var r,i;if(_C){if(wC){if(n)for(r in zC)if((i=gC[r])&&TC(i,e))try{delete i[e]}catch(t3){}if(UC[e]&&!n)return;try{return bC(UC,e,n?t:JC&&UC[e]||t)}catch(t3){}}for(r in zC)!(i=gC[r])||i[e]&&!n||bC(i,e,t)}},getTypedArrayConstructor:YC,isView:function(e){if(!EC(e))return!1;var t=kC(e);return"DataView"===t||TC(zC,t)||TC(qC,t)},isTypedArray:XC,TypedArray:UC,TypedArrayPrototype:FC},$C=C,ZC=D,ew=s_,tw=QC.NATIVE_ARRAY_BUFFER_VIEWS,nw=$C.ArrayBuffer,rw=$C.Int8Array,iw=!tw||!ZC((function(){rw(1)}))||!ZC((function(){new rw(-1)}))||!ew((function(e){new rw,new rw(null),new rw(1.5),new rw(e)}),!0)||ZC((function(){return 1!==new rw(new nw(2),1,void 0).length})),ow=Dr,aw=RangeError,sw=function(e){var t=ow(e);if(t<0)throw new aw("The argument can't be less than 0");return t},cw=RangeError,uw=function(e,t){var n=sw(e);if(n%t)throw new cw("Wrong offset");return n},lw=Math.round,dw=Vi,hw=Mt,fw=TypeError,pw=function(e){var t=hw(e,"number");if("number"==typeof t)throw new fw("Can't convert number to bigint");return BigInt(t)},mw=Jo,vw=M,_w=em,gw=lt,yw=Fr,Ew=Uv,Tw=Nv,kw=bv,Sw=function(e){var t=dw(e);return"BigInt64Array"===t||"BigUint64Array"===t},Iw=QC.aTypedArrayConstructor,bw=pw,Aw=function(e){var t,n,r,i,o,a,s,c,u=_w(this),l=gw(e),d=arguments.length,h=d>1?arguments[1]:void 0,f=void 0!==h,p=Tw(l);if(p&&!kw(p))for(c=(s=Ew(l,p)).next,l=[];!(a=vw(c,s)).done;)l.push(a.value);for(f&&d>2&&(h=mw(h,arguments[2])),n=yw(l),r=new(Iw(u))(n),i=Sw(r),t=0;n>t;t++)o=f?h(l[t],t):l[t],r[t]=i?bw(o):+o;return r},Rw=Fr,Cw=function(e,t,n){for(var r=0,i=arguments.length>2?n:Rw(t),o=new e(i);i>r;)o[r]=t[r++];return o},ww=Ci,Dw=C,Nw=M,xw=N,Ow=iw,Pw=QC,Mw=jp,Lw=pf,Vw=j,Uw=En,Fw=Ag,Bw=Vr,Hw=gf,jw=uw,Gw=function(e){var t=lw(e);return t<0?0:t>255?255:255&t},Ww=Ut,Jw=ft,Kw=Vi,zw=fe,qw=Ve,Yw=fo,Xw=_e,Qw=Ol,$w=br.f,Zw=Aw,eD=Ta.forEach,tD=zp,nD=So,rD=en,iD=w,oD=Cw,aD=Bf,sD=nr.get,cD=nr.set,uD=nr.enforce,lD=rD.f,dD=iD.f,hD=Dw.RangeError,fD=Mw.ArrayBuffer,pD=fD.prototype,mD=Mw.DataView,vD=Pw.NATIVE_ARRAY_BUFFER_VIEWS,_D=Pw.TYPED_ARRAY_TAG,gD=Pw.TypedArray,yD=Pw.TypedArrayPrototype,ED=Pw.isTypedArray,TD="BYTES_PER_ELEMENT",kD="Wrong length",SD=function(e,t){nD(e,t,{configurable:!0,get:function(){return sD(this)[t]}})},ID=function(e){var t;return Xw(pD,e)||"ArrayBuffer"===(t=Kw(e))||"SharedArrayBuffer"===t},bD=function(e,t){return ED(e)&&!qw(t)&&t in e&&Fw(+t)&&t>=0},AD=function(e,t){return t=Ww(t),bD(e,t)?Vw(2,e[t]):dD(e,t)},RD=function(e,t,n){return t=Ww(t),!(bD(e,t)&&zw(n)&&Jw(n,"value"))||Jw(n,"get")||Jw(n,"set")||n.configurable||Jw(n,"writable")&&!n.writable||Jw(n,"enumerable")&&!n.enumerable?lD(e,t,n):(e[t]=n.value,e)};xw?(vD||(iD.f=AD,rD.f=RD,SD(yD,"buffer"),SD(yD,"byteOffset"),SD(yD,"byteLength"),SD(yD,"length")),ww({target:"Object",stat:!0,forced:!vD},{getOwnPropertyDescriptor:AD,defineProperty:RD}),mC.exports=function(e,t,n){var r=e.match(/\d+/)[0]/8,i=e+(n?"Clamped":"")+"Array",o="get"+e,a="set"+e,s=Dw[i],c=s,u=c&&c.prototype,l={},d=function(e,t){lD(e,t,{get:function(){return function(e,t){var n=sD(e);return n.view[o](t*r+n.byteOffset,!0)}(this,t)},set:function(e){return function(e,t,i){var o=sD(e);o.view[a](t*r+o.byteOffset,n?Gw(i):i,!0)}(this,t,e)},enumerable:!0})};vD?Ow&&(c=t((function(e,t,n,i){return Lw(e,u),aD(zw(t)?ID(t)?void 0!==i?new s(t,jw(n,r),i):void 0!==n?new s(t,jw(n,r)):new s(t):ED(t)?oD(c,t):Nw(Zw,c,t):new s(Hw(t)),e,c)})),Qw&&Qw(c,gD),eD($w(s),(function(e){e in c||Uw(c,e,s[e])})),c.prototype=u):(c=t((function(e,t,n,i){Lw(e,u);var o,a,s,l=0,h=0;if(zw(t)){if(!ID(t))return ED(t)?oD(c,t):Nw(Zw,c,t);o=t,h=jw(n,r);var f=t.byteLength;if(void 0===i){if(f%r)throw new hD(kD);if((a=f-h)<0)throw new hD(kD)}else if((a=Bw(i)*r)+h>f)throw new hD(kD);s=a/r}else s=Hw(t),o=new fD(a=s*r);for(cD(e,{buffer:o,byteOffset:h,byteLength:a,length:s,view:new mD(o)});l<s;)d(e,l++)})),Qw&&Qw(c,gD),u=c.prototype=Yw(yD)),u.constructor!==c&&Uw(u,"constructor",c),uD(u).TypedArrayConstructor=c,_D&&Uw(u,_D,i);var h=c!==s;l[i]=c,ww({global:!0,constructor:!0,forced:h,sham:!vD},l),TD in c||Uw(c,TD,r),TD in u||Uw(u,TD,r),tD(i)}):mC.exports=function(){},pC("Float32",(function(e){return function(t,n,r){return e(this,t,n,r)}})),pC("Uint8",(function(e){return function(t,n,r){return e(this,t,n,r)}}));var CD=lt,wD=Pr,DD=Fr,ND=fh,xD=Math.min,OD=[].copyWithin||function(e,t){var n=CD(this),r=DD(n),i=wD(e,r),o=wD(t,r),a=arguments.length>2?arguments[2]:void 0,s=xD((void 0===a?r:wD(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]:ND(n,i),i+=c,o+=c;return n},PD=QC,MD=z(OD),LD=PD.aTypedArray;(0,PD.exportTypedArrayMethod)("copyWithin",(function(e,t){return MD(LD(this),e,t,arguments.length>2?arguments[2]:void 0)}));var VD=Ta.every,UD=QC.aTypedArray;(0,QC.exportTypedArrayMethod)("every",(function(e){return VD(UD(this),e,arguments.length>1?arguments[1]:void 0)}));var FD=Lf,BD=pw,HD=Vi,jD=M,GD=D,WD=QC.aTypedArray,JD=QC.exportTypedArrayMethod,KD=z("".slice);JD("fill",(function(e){var t=arguments.length;WD(this);var n="Big"===KD(HD(this),0,3)?BD(e):+e;return jD(FD,this,n,t>1?arguments[1]:void 0,t>2?arguments[2]:void 0)}),GD((function(){var e=0;return new Int8Array(2).fill({valueOf:function(){return e++}}),1!==e})));var zD=om,qD=QC.aTypedArrayConstructor,YD=QC.getTypedArrayConstructor,XD=function(e){return qD(zD(e,YD(e)))},QD=Cw,$D=XD,ZD=Ta.filter,eN=function(e,t){return QD($D(e),t)},tN=QC.aTypedArray;(0,QC.exportTypedArrayMethod)("filter",(function(e){var t=ZD(tN(this),e,arguments.length>1?arguments[1]:void 0);return eN(this,t)}));var nN=Ta.find,rN=QC.aTypedArray;(0,QC.exportTypedArrayMethod)("find",(function(e){return nN(rN(this),e,arguments.length>1?arguments[1]:void 0)}));var iN=Ta.findIndex,oN=QC.aTypedArray;(0,QC.exportTypedArrayMethod)("findIndex",(function(e){return iN(oN(this),e,arguments.length>1?arguments[1]:void 0)}));var aN=Ta.forEach,sN=QC.aTypedArray;(0,QC.exportTypedArrayMethod)("forEach",(function(e){aN(sN(this),e,arguments.length>1?arguments[1]:void 0)})),(0,QC.exportTypedArrayStaticMethod)("from",Aw,iw);var cN=Wr.includes,uN=QC.aTypedArray;(0,QC.exportTypedArrayMethod)("includes",(function(e){return cN(uN(this),e,arguments.length>1?arguments[1]:void 0)}));var lN=Wr.indexOf,dN=QC.aTypedArray;(0,QC.exportTypedArrayMethod)("indexOf",(function(e){return lN(dN(this),e,arguments.length>1?arguments[1]:void 0)}));var hN=C,fN=D,pN=z,mN=QC,vN=hd,_N=Rt("iterator"),gN=hN.Uint8Array,yN=pN(vN.values),EN=pN(vN.keys),TN=pN(vN.entries),kN=mN.aTypedArray,SN=mN.exportTypedArrayMethod,IN=gN&&gN.prototype,bN=!fN((function(){IN[_N].call([1])})),AN=!!IN&&IN.values&&IN[_N]===IN.values&&"values"===IN.values.name,RN=function(){return yN(kN(this))};SN("entries",(function(){return TN(kN(this))}),bN),SN("keys",(function(){return EN(kN(this))}),bN),SN("values",RN,bN||!AN,{name:"values"}),SN(_N,RN,bN||!AN,{name:"values"});var CN=QC.aTypedArray,wN=QC.exportTypedArrayMethod,DN=z([].join);wN("join",(function(e){return DN(CN(this),e)}));var NN=Qs,xN=Cd,ON=QC.aTypedArray;(0,QC.exportTypedArrayMethod)("lastIndexOf",(function(e){var t=arguments.length;return NN(xN,ON(this),t>1?[e,arguments[1]]:[e])}));var PN=Ta.map,MN=XD,LN=QC.aTypedArray;(0,QC.exportTypedArrayMethod)("map",(function(e){return PN(LN(this),e,arguments.length>1?arguments[1]:void 0,(function(e,t){return new(MN(e))(t)}))}));var VN=Vd.left,UN=QC.aTypedArray;(0,QC.exportTypedArrayMethod)("reduce",(function(e){var t=arguments.length;return VN(UN(this),e,t,t>1?arguments[1]:void 0)}));var FN=Vd.right,BN=QC.aTypedArray;(0,QC.exportTypedArrayMethod)("reduceRight",(function(e){var t=arguments.length;return FN(BN(this),e,t,t>1?arguments[1]:void 0)}));var HN=QC.aTypedArray,jN=QC.exportTypedArrayMethod,GN=Math.floor;jN("reverse",(function(){for(var e,t=this,n=HN(t).length,r=GN(n/2),i=0;i<r;)e=t[i],t[i++]=t[--n],t[n]=e;return t}));var WN=C,JN=M,KN=QC,zN=Fr,qN=uw,YN=lt,XN=D,QN=WN.RangeError,$N=WN.Int8Array,ZN=$N&&$N.prototype,ex=ZN&&ZN.set,tx=KN.aTypedArray,nx=KN.exportTypedArrayMethod,rx=!XN((function(){var e=new Uint8ClampedArray(2);return JN(ex,e,{length:1,0:3},1),3!==e[1]})),ix=rx&&KN.NATIVE_ARRAY_BUFFER_VIEWS&&XN((function(){var e=new $N(2);return e.set(1),e.set("2",1),0!==e[0]||2!==e[1]}));nx("set",(function(e){tx(this);var t=qN(arguments.length>1?arguments[1]:void 0,1),n=YN(e);if(rx)return JN(ex,this,n,t);var r=this.length,i=zN(n),o=0;if(i+t>r)throw new QN("Wrong length");for(;o<i;)this[t+o]=n[o++]}),!rx||ix);var ox=XD,ax=mo,sx=QC.aTypedArray;(0,QC.exportTypedArrayMethod)("slice",(function(e,t){for(var n=ax(sx(this),e,t),r=ox(this),i=0,o=n.length,a=new r(o);o>i;)a[i]=n[i++];return a}),D((function(){new Int8Array(1).slice()})));var cx=Ta.some,ux=QC.aTypedArray;(0,QC.exportTypedArrayMethod)("some",(function(e){return cx(ux(this),e,arguments.length>1?arguments[1]:void 0)}));var lx=Ho,dx=D,hx=Ge,fx=_h,px=yh,mx=Eh,vx=Re,_x=kh,gx=QC.aTypedArray,yx=QC.exportTypedArrayMethod,Ex=C.Uint16Array,Tx=Ex&&lx(Ex.prototype.sort),kx=!(!Tx||dx((function(){Tx(new Ex(2),null)}))&&dx((function(){Tx(new Ex(2),{})}))),Sx=!!Tx&&!dx((function(){if(vx)return vx<74;if(px)return px<67;if(mx)return!0;if(_x)return _x<602;var e,t,n=new Ex(516),r=Array(516);for(e=0;e<516;e++)t=e%4,n[e]=515-e,r[e]=e-2*t+3;for(Tx(n,(function(e,t){return(e/4|0)-(t/4|0)})),e=0;e<516;e++)if(n[e]!==r[e])return!0}));yx("sort",(function(e){return void 0!==e&&hx(e),Sx?Tx(this,e):fx(gx(this),function(e){return function(t,n){return void 0!==e?+e(t,n)||0:n!=n?-1:t!=t?1:0===t&&0===n?1/t>0&&1/n<0?1:-1:t>n}}(e))}),!Sx||kx);var Ix=Vr,bx=Pr,Ax=XD,Rx=QC.aTypedArray;(0,QC.exportTypedArrayMethod)("subarray",(function(e,t){var n=Rx(this),r=n.length,i=bx(e,r);return new(Ax(n))(n.buffer,n.byteOffset+i*n.BYTES_PER_ELEMENT,Ix((void 0===t?r:bx(t,r))-i))}));var Cx=Qs,wx=QC,Dx=D,Nx=mo,xx=C.Int8Array,Ox=wx.aTypedArray,Px=wx.exportTypedArrayMethod,Mx=[].toLocaleString,Lx=!!xx&&Dx((function(){Mx.call(new xx(1))}));Px("toLocaleString",(function(){return Cx(Mx,Lx?Nx(Ox(this)):Ox(this),Nx(arguments))}),Dx((function(){return[1,2].toLocaleString()!==new xx([1,2]).toLocaleString()}))||!Dx((function(){xx.prototype.toLocaleString.call([1,2])})));var Vx=QC.exportTypedArrayMethod,Ux=D,Fx=z,Bx=C.Uint8Array,Hx=Bx&&Bx.prototype||{},jx=[].toString,Gx=Fx([].join);Ux((function(){jx.call({})}))&&(jx=function(){return Gx(this)});var Wx=Hx.toString!==jx;Vx("toString",jx,Wx);var Jx=z,Kx=df,zx=Qm.getWeakData,qx=pf,Yx=an,Xx=re,Qx=fe,$x=n_,Zx=ft,eO=nr.set,tO=nr.getterFor,nO=Ta.find,rO=Ta.findIndex,iO=Jx([].splice),oO=0,aO=function(e){return e.frozen||(e.frozen=new sO)},sO=function(){this.entries=[]},cO=function(e,t){return nO(e.entries,(function(e){return e[0]===t}))};sO.prototype={get:function(e){var t=cO(this,e);if(t)return t[1]},has:function(e){return!!cO(this,e)},set:function(e,t){var n=cO(this,e);n?n[1]=t:this.entries.push([e,t])},delete:function(e){var t=rO(this.entries,(function(t){return t[0]===e}));return~t&&iO(this.entries,t,1),!!~t}};var uO,lO={getConstructor:function(e,t,n,r){var i=e((function(e,i){qx(e,o),eO(e,{type:t,id:oO++,frozen:null}),Xx(i)||$x(i,e[r],{that:e,AS_ENTRIES:n})})),o=i.prototype,a=tO(t),s=function(e,t,n){var r=a(e),i=zx(Yx(t),!0);return!0===i?aO(r).set(t,n):i[r.id]=n,e};return Kx(o,{delete:function(e){var t=a(this);if(!Qx(e))return!1;var n=zx(e);return!0===n?aO(t).delete(e):n&&Zx(n,t.id)&&delete n[t.id]},has:function(e){var t=a(this);if(!Qx(e))return!1;var n=zx(e);return!0===n?aO(t).has(e):n&&Zx(n,t.id)}}),Kx(o,n?{get:function(e){var t=a(this);if(Qx(e)){var n=zx(e);if(!0===n)return aO(t).get(e);if(n)return n[t.id]}},set:function(e,t){return s(this,e,t)}}:{add:function(e){return s(this,e,!0)}}),i}},dO=av,hO=C,fO=z,pO=df,mO=Qm,vO=S_,_O=lO,gO=fe,yO=nr.enforce,EO=D,TO=Un,kO=Object,SO=Array.isArray,IO=kO.isExtensible,bO=kO.isFrozen,AO=kO.isSealed,RO=kO.freeze,CO=kO.seal,wO=!hO.ActiveXObject&&"ActiveXObject"in hO,DO=function(e){return function(){return e(this,arguments.length?arguments[0]:void 0)}},NO=vO("WeakMap",DO,_O),xO=NO.prototype,OO=fO(xO.set);if(TO)if(wO){uO=_O.getConstructor(DO,"WeakMap",!0),mO.enable();var PO=fO(xO.delete),MO=fO(xO.has),LO=fO(xO.get);pO(xO,{delete:function(e){if(gO(e)&&!IO(e)){var t=yO(this);return t.frozen||(t.frozen=new uO),PO(this,e)||t.frozen.delete(e)}return PO(this,e)},has:function(e){if(gO(e)&&!IO(e)){var t=yO(this);return t.frozen||(t.frozen=new uO),MO(this,e)||t.frozen.has(e)}return MO(this,e)},get:function(e){if(gO(e)&&!IO(e)){var t=yO(this);return t.frozen||(t.frozen=new uO),MO(this,e)?LO(this,e):t.frozen.get(e)}return LO(this,e)},set:function(e,t){if(gO(e)&&!IO(e)){var n=yO(this);n.frozen||(n.frozen=new uO),MO(this,e)?OO(this,e,t):n.frozen.set(e,t)}else OO(this,e,t);return this}})}else dO&&EO((function(){var e=RO([]);return OO(new NO,e,1),!bO(e)}))&&pO(xO,{set:function(e,t){var n;return SO(e)&&(bO(e)?n=RO:AO(e)&&(n=CO)),OO(this,e,t),n&&n(e),this}});var VO={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},UO=jt("span").classList,FO=UO&&UO.constructor&&UO.constructor.prototype,BO=FO===Object.prototype?void 0:FO,HO=C,jO=VO,GO=BO,WO=Bu,JO=En,KO=function(e){if(e&&e.forEach!==WO)try{JO(e,"forEach",WO)}catch(t3){e.forEach=WO}};for(var zO in jO)jO[zO]&&KO(HO[zO]&&HO[zO].prototype);KO(GO);var qO=C,YO=VO,XO=BO,QO=hd,$O=En,ZO=Uo,eP=Rt("iterator"),tP=QO.values,nP=function(e,t){if(e){if(e[eP]!==tP)try{$O(e,eP,tP)}catch(t3){e[eP]=tP}if(ZO(e,t,!0),YO[t])for(var n in QO)if(e[n]!==QO[n])try{$O(e,n,QO[n])}catch(t3){e[n]=QO[n]}}};for(var rP in YO)nP(qO[rP]&&qO[rP].prototype,rP);nP(XO,"DOMTokenList");var iP=C,oP=Qs,aP=de,sP=jd,cP=Ee,uP=mo,lP=_E,dP=iP.Function,hP=/MSIE .\./.test(cP)||"BUN"===sP&&function(){var e=iP.Bun.version.split(".");return e.length<3||"0"===e[0]&&(e[1]<3||"3"===e[1]&&"0"===e[2])}(),fP=function(e,t){var n=t?2:1;return hP?function(r,i){var o=lP(arguments.length,1)>n,a=aP(r)?r:dP(r),s=o?uP(arguments,n):[],c=o?function(){oP(a,this,s)}:a;return t?e(c,i):e(c)}:e},pP=Ci,mP=C,vP=fP(mP.setInterval,!0);pP({global:!0,bind:!0,forced:mP.setInterval!==vP},{setInterval:vP});var _P=Ci,gP=C,yP=fP(gP.setTimeout,!0);_P({global:!0,bind:!0,forced:gP.setTimeout!==yP},{setTimeout:yP});var EP=D,TP=N,kP=Rt("iterator"),SP=!EP((function(){var e=new URL("b?a=1&b=2&c=3","https://a"),t=e.searchParams,n=new URLSearchParams("a=1&a=2&b=3"),r="";return e.pathname="c%20d",t.forEach((function(e,n){t.delete("b"),r+=n+e})),n.delete("a",2),n.delete("b",void 0),!t.size&&!TP||!t.sort||"https://a/c%20d?a=1&c=3"!==e.href||"3"!==t.get("c")||"a=1"!==String(new URLSearchParams("?a=1"))||!t[kP]||"a"!==new URL("https://a@b").username||"b"!==new URLSearchParams(new URLSearchParams("a=b")).get("a")||"xn--e1aybc"!==new URL("https://тест").host||"#%D0%B1"!==new URL("https://a#б").hash||"a1c3"!==r||"x"!==new URL("https://x",void 0).host})),IP=an,bP=jv,AP=Jo,RP=M,CP=lt,wP=function(e,t,n,r){try{return r?t(IP(n)[0],n[1]):t(n)}catch(t3){bP(e,"throw",t3)}},DP=bv,NP=aa,xP=Fr,OP=eu,PP=Uv,MP=Nv,LP=Array,VP=z,UP=2147483647,FP=/[^\0-\u007E]/,BP=/[.\u3002\uFF0E\uFF61]/g,HP="Overflow: input needs wider integers to process",jP=RangeError,GP=VP(BP.exec),WP=Math.floor,JP=String.fromCharCode,KP=VP("".charCodeAt),zP=VP([].join),qP=VP([].push),YP=VP("".replace),XP=VP("".split),QP=VP("".toLowerCase),$P=function(e){return e+22+75*(e<26)},ZP=function(e,t,n){var r=0;for(e=n?WP(e/700):e>>1,e+=WP(e/t);e>455;)e=WP(e/35),r+=36;return WP(r+36*e/(e+38))},eM=function(e){var t=[];e=function(e){for(var t=[],n=0,r=e.length;n<r;){var i=KP(e,n++);if(i>=55296&&i<=56319&&n<r){var o=KP(e,n++);56320==(64512&o)?qP(t,((1023&i)<<10)+(1023&o)+65536):(qP(t,i),n--)}else qP(t,i)}return t}(e);var n,r,i=e.length,o=128,a=0,s=72;for(n=0;n<e.length;n++)(r=e[n])<128&&qP(t,JP(r));var c=t.length,u=c;for(c&&qP(t,"-");u<i;){var l=UP;for(n=0;n<e.length;n++)(r=e[n])>=o&&r<l&&(l=r);var d=u+1;if(l-o>WP((UP-a)/d))throw new jP(HP);for(a+=(l-o)*d,o=l,n=0;n<e.length;n++){if((r=e[n])<o&&++a>UP)throw new jP(HP);if(r===o){for(var h=a,f=36;;){var p=f<=s?1:f>=s+26?26:f-s;if(h<p)break;var m=h-p,v=36-p;qP(t,JP($P(p+m%v))),h=WP(m/v),f+=36}qP(t,JP($P(h))),s=ZP(a,d,u===c),a=0,u++}}a++,o++}return zP(t,"")},tM=Ci,nM=z,rM=Pr,iM=RangeError,oM=String.fromCharCode,aM=String.fromCodePoint,sM=nM([].join);tM({target:"String",stat:!0,arity:1,forced:!!aM&&1!==aM.length},{fromCodePoint:function(e){for(var t,n=[],r=arguments.length,i=0;r>i;){if(t=+arguments[i++],rM(t,1114111)!==t)throw new iM(t+" is not a valid code point");n[i]=t<65536?oM(t):oM(55296+((t-=65536)>>10),t%1024+56320)}return sM(n,"")}});var cM=Ci,uM=C,lM=YE,dM=ve,hM=M,fM=z,pM=N,mM=SP,vM=Ir,_M=So,gM=df,yM=Uo,EM=kl,TM=nr,kM=pf,SM=de,IM=ft,bM=Jo,AM=Vi,RM=an,CM=fe,wM=Bi,DM=fo,NM=j,xM=Uv,OM=Nv,PM=ed,MM=_E,LM=_h,VM=Rt("iterator"),UM="URLSearchParams",FM=UM+"Iterator",BM=TM.set,HM=TM.getterFor(UM),jM=TM.getterFor(FM),GM=lM("fetch"),WM=lM("Request"),JM=lM("Headers"),KM=WM&&WM.prototype,zM=JM&&JM.prototype,qM=uM.TypeError,YM=uM.encodeURIComponent,XM=String.fromCharCode,QM=dM("String","fromCodePoint"),$M=parseInt,ZM=fM("".charAt),eL=fM([].join),tL=fM([].push),nL=fM("".replace),rL=fM([].shift),iL=fM([].splice),oL=fM("".split),aL=fM("".slice),sL=fM(/./.exec),cL=/\+/g,uL=/^[0-9a-f]+$/i,lL=function(e,t){var n=aL(e,t,t+2);return sL(uL,n)?$M(n,16):NaN},dL=function(e){for(var t=0,n=128;n>0&&e&n;n>>=1)t++;return t},hL=function(e){var t=null;switch(e.length){case 1:t=e[0];break;case 2:t=(31&e[0])<<6|63&e[1];break;case 3:t=(15&e[0])<<12|(63&e[1])<<6|63&e[2];break;case 4:t=(7&e[0])<<18|(63&e[1])<<12|(63&e[2])<<6|63&e[3]}return t>1114111?null:t},fL=function(e){for(var t=(e=nL(e,cL," ")).length,n="",r=0;r<t;){var i=ZM(e,r);if("%"===i){if("%"===ZM(e,r+1)||r+3>t){n+="%",r++;continue}var o=lL(e,r+1);if(o!=o){n+=i,r++;continue}r+=2;var a=dL(o);if(0===a)i=XM(o);else{if(1===a||a>4){n+="�",r++;continue}for(var s=[o],c=1;c<a&&!(++r+3>t||"%"!==ZM(e,r));){var u=lL(e,r+1);if(u!=u){r+=3;break}if(u>191||u<128)break;tL(s,u),r+=2,c++}if(s.length!==a){n+="�";continue}var l=hL(s);null===l?n+="�":i=QM(l)}}n+=i,r++}return n},pL=/[!'()~]|%20/g,mL={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+"},vL=function(e){return mL[e]},_L=function(e){return nL(YM(e),pL,vL)},gL=EM((function(e,t){BM(this,{type:FM,target:HM(e).entries,index:0,kind:t})}),UM,(function(){var e=jM(this),t=e.target,n=e.index++;if(!t||n>=t.length)return e.target=null,PM(void 0,!0);var r=t[n];switch(e.kind){case"keys":return PM(r.key,!1);case"values":return PM(r.value,!1)}return PM([r.key,r.value],!1)}),!0),yL=function(e){this.entries=[],this.url=null,void 0!==e&&(CM(e)?this.parseObject(e):this.parseQuery("string"==typeof e?"?"===ZM(e,0)?aL(e,1):e:wM(e)))};yL.prototype={type:UM,bindURL:function(e){this.url=e,this.update()},parseObject:function(e){var t,n,r,i,o,a,s,c=this.entries,u=OM(e);if(u)for(n=(t=xM(e,u)).next;!(r=hM(n,t)).done;){if(o=(i=xM(RM(r.value))).next,(a=hM(o,i)).done||(s=hM(o,i)).done||!hM(o,i).done)throw new qM("Expected sequence with length 2");tL(c,{key:wM(a.value),value:wM(s.value)})}else for(var l in e)IM(e,l)&&tL(c,{key:l,value:wM(e[l])})},parseQuery:function(e){if(e)for(var t,n,r=this.entries,i=oL(e,"&"),o=0;o<i.length;)(t=i[o++]).length&&(n=oL(t,"="),tL(r,{key:fL(rL(n)),value:fL(eL(n,"="))}))},serialize:function(){for(var e,t=this.entries,n=[],r=0;r<t.length;)e=t[r++],tL(n,_L(e.key)+"="+_L(e.value));return eL(n,"&")},update:function(){this.entries.length=0,this.parseQuery(this.url.query)},updateURL:function(){this.url&&this.url.update()}};var EL=function(){kM(this,TL);var e=BM(this,new yL(arguments.length>0?arguments[0]:void 0));pM||(this.size=e.entries.length)},TL=EL.prototype;if(gM(TL,{append:function(e,t){var n=HM(this);MM(arguments.length,2),tL(n.entries,{key:wM(e),value:wM(t)}),pM||this.length++,n.updateURL()},delete:function(e){for(var t=HM(this),n=MM(arguments.length,1),r=t.entries,i=wM(e),o=n<2?void 0:arguments[1],a=void 0===o?o:wM(o),s=0;s<r.length;){var c=r[s];if(c.key!==i||void 0!==a&&c.value!==a)s++;else if(iL(r,s,1),void 0!==a)break}pM||(this.size=r.length),t.updateURL()},get:function(e){var t=HM(this).entries;MM(arguments.length,1);for(var n=wM(e),r=0;r<t.length;r++)if(t[r].key===n)return t[r].value;return null},getAll:function(e){var t=HM(this).entries;MM(arguments.length,1);for(var n=wM(e),r=[],i=0;i<t.length;i++)t[i].key===n&&tL(r,t[i].value);return r},has:function(e){for(var t=HM(this).entries,n=MM(arguments.length,1),r=wM(e),i=n<2?void 0:arguments[1],o=void 0===i?i:wM(i),a=0;a<t.length;){var s=t[a++];if(s.key===r&&(void 0===o||s.value===o))return!0}return!1},set:function(e,t){var n=HM(this);MM(arguments.length,1);for(var r,i=n.entries,o=!1,a=wM(e),s=wM(t),c=0;c<i.length;c++)(r=i[c]).key===a&&(o?iL(i,c--,1):(o=!0,r.value=s));o||tL(i,{key:a,value:s}),pM||(this.size=i.length),n.updateURL()},sort:function(){var e=HM(this);LM(e.entries,(function(e,t){return e.key>t.key?1:-1})),e.updateURL()},forEach:function(e){for(var t,n=HM(this).entries,r=bM(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 gL(this,"keys")},values:function(){return new gL(this,"values")},entries:function(){return new gL(this,"entries")}},{enumerable:!0}),vM(TL,VM,TL.entries,{name:"entries"}),vM(TL,"toString",(function(){return HM(this).serialize()}),{enumerable:!0}),pM&&_M(TL,"size",{get:function(){return HM(this).entries.length},configurable:!0,enumerable:!0}),yM(EL,UM),cM({global:!0,constructor:!0,forced:!mM},{URLSearchParams:EL}),!mM&&SM(JM)){var kL=fM(zM.has),SL=fM(zM.set),IL=function(e){if(CM(e)){var t,n=e.body;if(AM(n)===UM)return t=e.headers?new JM(e.headers):new JM,kL(t,"content-type")||SL(t,"content-type","application/x-www-form-urlencoded;charset=UTF-8"),DM(e,{body:NM(0,wM(n)),headers:NM(0,t)})}return e};if(SM(GM)&&cM({global:!0,enumerable:!0,dontCallGetSet:!0,forced:!0},{fetch:function(e){return GM(e,arguments.length>1?IL(arguments[1]):{})}}),SM(WM)){var bL=function(e){return kM(this,KM),new WM(e,arguments.length>1?IL(arguments[1]):{})};KM.constructor=bL,bL.prototype=KM,cM({global:!0,constructor:!0,dontCallGetSet:!0,forced:!0},{Request:bL})}}var AL,RL=Ci,CL=N,wL=SP,DL=C,NL=Jo,xL=z,OL=Ir,PL=So,ML=pf,LL=ft,VL=ay,UL=function(e){var t=CP(e),n=NP(this),r=arguments.length,i=r>1?arguments[1]:void 0,o=void 0!==i;o&&(i=AP(i,r>2?arguments[2]:void 0));var a,s,c,u,l,d,h=MP(t),f=0;if(!h||this===LP&&DP(h))for(a=xP(t),s=n?new this(a):LP(a);a>f;f++)d=o?i(t[f],f):t[f],OP(s,f,d);else for(s=n?new this:[],l=(u=PP(t,h)).next;!(c=RP(l,u)).done;f++)d=o?wP(u,i,[c.value,f],!0):c.value,OP(s,f,d);return s.length=f,s},FL=mo,BL=Ub.codeAt,HL=function(e){var t,n,r=[],i=XP(YP(QP(e),BP,"."),".");for(t=0;t<i.length;t++)n=i[t],qP(r,GP(FP,n)?"xn--"+eM(n):n);return zP(r,".")},jL=Bi,GL=Uo,WL=_E,JL={URLSearchParams:EL,getState:HM},KL=nr,zL=KL.set,qL=KL.getterFor("URL"),YL=JL.URLSearchParams,XL=JL.getState,QL=DL.URL,$L=DL.TypeError,ZL=DL.parseInt,eV=Math.floor,tV=Math.pow,nV=xL("".charAt),rV=xL(/./.exec),iV=xL([].join),oV=xL(1..toString),aV=xL([].pop),sV=xL([].push),cV=xL("".replace),uV=xL([].shift),lV=xL("".split),dV=xL("".slice),hV=xL("".toLowerCase),fV=xL([].unshift),pV="Invalid scheme",mV="Invalid host",vV="Invalid port",_V=/[a-z]/i,gV=/[\d+-.a-z]/i,yV=/\d/,EV=/^0x/i,TV=/^[0-7]+$/,kV=/^\d+$/,SV=/^[\da-f]+$/i,IV=/[\0\t\n\r #%/:<>?@[\\\]^|]/,bV=/[\0\t\n\r #/:<>?@[\\\]^|]/,AV=/^[\u0000-\u0020]+/,RV=/(^|[^\u0000-\u0020])[\u0000-\u0020]+$/,CV=/[\t\n\r]/g,wV=function(e){var t,n,r,i;if("number"==typeof e){for(t=[],n=0;n<4;n++)fV(t,e%256),e=eV(e/256);return iV(t,".")}if("object"==typeof e){for(t="",r=function(e){for(var t=null,n=1,r=null,i=0,o=0;o<8;o++)0!==e[o]?(i>n&&(t=r,n=i),r=null,i=0):(null===r&&(r=o),++i);return i>n?r:t}(e),n=0;n<8;n++)i&&0===e[n]||(i&&(i=!1),r===n?(t+=n?":":"::",i=!0):(t+=oV(e[n],16),n<7&&(t+=":")));return"["+t+"]"}return e},DV={},NV=VL({},DV,{" ":1,'"':1,"<":1,">":1,"`":1}),xV=VL({},NV,{"#":1,"?":1,"{":1,"}":1}),OV=VL({},xV,{"/":1,":":1,";":1,"=":1,"@":1,"[":1,"\\":1,"]":1,"^":1,"|":1}),PV=function(e,t){var n=BL(e,0);return n>32&&n<127&&!LL(t,e)?e:encodeURIComponent(e)},MV={ftp:21,file:null,http:80,https:443,ws:80,wss:443},LV=function(e,t){var n;return 2===e.length&&rV(_V,nV(e,0))&&(":"===(n=nV(e,1))||!t&&"|"===n)},VV=function(e){var t;return e.length>1&&LV(dV(e,0,2))&&(2===e.length||"/"===(t=nV(e,2))||"\\"===t||"?"===t||"#"===t)},UV=function(e){return"."===e||"%2e"===hV(e)},FV={},BV={},HV={},jV={},GV={},WV={},JV={},KV={},zV={},qV={},YV={},XV={},QV={},$V={},ZV={},eU={},tU={},nU={},rU={},iU={},oU={},aU=function(e,t,n){var r,i,o,a=jL(e);if(t){if(i=this.parse(a))throw new $L(i);this.searchParams=null}else{if(void 0!==n&&(r=new aU(n,!0)),i=this.parse(a,null,r))throw new $L(i);(o=XL(new YL)).bindURL(this),this.searchParams=o}};aU.prototype={type:"URL",parse:function(e,t,n){var r,i,o,a,s,c=this,u=t||FV,l=0,d="",h=!1,f=!1,p=!1;for(e=jL(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=cV(e,AV,""),e=cV(e,RV,"$1")),e=cV(e,CV,""),r=UL(e);l<=r.length;){switch(i=r[l],u){case FV:if(!i||!rV(_V,i)){if(t)return pV;u=HV;continue}d+=hV(i),u=BV;break;case BV:if(i&&(rV(gV,i)||"+"===i||"-"===i||"."===i))d+=hV(i);else{if(":"!==i){if(t)return pV;d="",u=HV,l=0;continue}if(t&&(c.isSpecial()!==LL(MV,d)||"file"===d&&(c.includesCredentials()||null!==c.port)||"file"===c.scheme&&!c.host))return;if(c.scheme=d,t)return void(c.isSpecial()&&MV[c.scheme]===c.port&&(c.port=null));d="","file"===c.scheme?u=$V:c.isSpecial()&&n&&n.scheme===c.scheme?u=jV:c.isSpecial()?u=KV:"/"===r[l+1]?(u=GV,l++):(c.cannotBeABaseURL=!0,sV(c.path,""),u=rU)}break;case HV:if(!n||n.cannotBeABaseURL&&"#"!==i)return pV;if(n.cannotBeABaseURL&&"#"===i){c.scheme=n.scheme,c.path=FL(n.path),c.query=n.query,c.fragment="",c.cannotBeABaseURL=!0,u=oU;break}u="file"===n.scheme?$V:WV;continue;case jV:if("/"!==i||"/"!==r[l+1]){u=WV;continue}u=zV,l++;break;case GV:if("/"===i){u=qV;break}u=nU;continue;case WV:if(c.scheme=n.scheme,i===AL)c.username=n.username,c.password=n.password,c.host=n.host,c.port=n.port,c.path=FL(n.path),c.query=n.query;else if("/"===i||"\\"===i&&c.isSpecial())u=JV;else if("?"===i)c.username=n.username,c.password=n.password,c.host=n.host,c.port=n.port,c.path=FL(n.path),c.query="",u=iU;else{if("#"!==i){c.username=n.username,c.password=n.password,c.host=n.host,c.port=n.port,c.path=FL(n.path),c.path.length--,u=nU;continue}c.username=n.username,c.password=n.password,c.host=n.host,c.port=n.port,c.path=FL(n.path),c.query=n.query,c.fragment="",u=oU}break;case JV:if(!c.isSpecial()||"/"!==i&&"\\"!==i){if("/"!==i){c.username=n.username,c.password=n.password,c.host=n.host,c.port=n.port,u=nU;continue}u=qV}else u=zV;break;case KV:if(u=zV,"/"!==i||"/"!==nV(d,l+1))continue;l++;break;case zV:if("/"!==i&&"\\"!==i){u=qV;continue}break;case qV:if("@"===i){h&&(d="%40"+d),h=!0,o=UL(d);for(var m=0;m<o.length;m++){var v=o[m];if(":"!==v||p){var _=PV(v,OV);p?c.password+=_:c.username+=_}else p=!0}d=""}else if(i===AL||"/"===i||"?"===i||"#"===i||"\\"===i&&c.isSpecial()){if(h&&""===d)return"Invalid authority";l-=UL(d).length+1,d="",u=YV}else d+=i;break;case YV:case XV:if(t&&"file"===c.scheme){u=eU;continue}if(":"!==i||f){if(i===AL||"/"===i||"?"===i||"#"===i||"\\"===i&&c.isSpecial()){if(c.isSpecial()&&""===d)return mV;if(t&&""===d&&(c.includesCredentials()||null!==c.port))return;if(a=c.parseHost(d))return a;if(d="",u=tU,t)return;continue}"["===i?f=!0:"]"===i&&(f=!1),d+=i}else{if(""===d)return mV;if(a=c.parseHost(d))return a;if(d="",u=QV,t===XV)return}break;case QV:if(!rV(yV,i)){if(i===AL||"/"===i||"?"===i||"#"===i||"\\"===i&&c.isSpecial()||t){if(""!==d){var g=ZL(d,10);if(g>65535)return vV;c.port=c.isSpecial()&&g===MV[c.scheme]?null:g,d=""}if(t)return;u=tU;continue}return vV}d+=i;break;case $V:if(c.scheme="file","/"===i||"\\"===i)u=ZV;else{if(!n||"file"!==n.scheme){u=nU;continue}switch(i){case AL:c.host=n.host,c.path=FL(n.path),c.query=n.query;break;case"?":c.host=n.host,c.path=FL(n.path),c.query="",u=iU;break;case"#":c.host=n.host,c.path=FL(n.path),c.query=n.query,c.fragment="",u=oU;break;default:VV(iV(FL(r,l),""))||(c.host=n.host,c.path=FL(n.path),c.shortenPath()),u=nU;continue}}break;case ZV:if("/"===i||"\\"===i){u=eU;break}n&&"file"===n.scheme&&!VV(iV(FL(r,l),""))&&(LV(n.path[0],!0)?sV(c.path,n.path[0]):c.host=n.host),u=nU;continue;case eU:if(i===AL||"/"===i||"\\"===i||"?"===i||"#"===i){if(!t&&LV(d))u=nU;else if(""===d){if(c.host="",t)return;u=tU}else{if(a=c.parseHost(d))return a;if("localhost"===c.host&&(c.host=""),t)return;d="",u=tU}continue}d+=i;break;case tU:if(c.isSpecial()){if(u=nU,"/"!==i&&"\\"!==i)continue}else if(t||"?"!==i)if(t||"#"!==i){if(i!==AL&&(u=nU,"/"!==i))continue}else c.fragment="",u=oU;else c.query="",u=iU;break;case nU:if(i===AL||"/"===i||"\\"===i&&c.isSpecial()||!t&&("?"===i||"#"===i)){if(".."===(s=hV(s=d))||"%2e."===s||".%2e"===s||"%2e%2e"===s?(c.shortenPath(),"/"===i||"\\"===i&&c.isSpecial()||sV(c.path,"")):UV(d)?"/"===i||"\\"===i&&c.isSpecial()||sV(c.path,""):("file"===c.scheme&&!c.path.length&&LV(d)&&(c.host&&(c.host=""),d=nV(d,0)+":"),sV(c.path,d)),d="","file"===c.scheme&&(i===AL||"?"===i||"#"===i))for(;c.path.length>1&&""===c.path[0];)uV(c.path);"?"===i?(c.query="",u=iU):"#"===i&&(c.fragment="",u=oU)}else d+=PV(i,xV);break;case rU:"?"===i?(c.query="",u=iU):"#"===i?(c.fragment="",u=oU):i!==AL&&(c.path[0]+=PV(i,DV));break;case iU:t||"#"!==i?i!==AL&&("'"===i&&c.isSpecial()?c.query+="%27":c.query+="#"===i?"%23":PV(i,DV)):(c.fragment="",u=oU);break;case oU:i!==AL&&(c.fragment+=PV(i,NV))}l++}},parseHost:function(e){var t,n,r;if("["===nV(e,0)){if("]"!==nV(e,e.length-1))return mV;if(t=function(e){var t,n,r,i,o,a,s,c=[0,0,0,0,0,0,0,0],u=0,l=null,d=0,h=function(){return nV(e,d)};if(":"===h()){if(":"!==nV(e,1))return;d+=2,l=++u}for(;h();){if(8===u)return;if(":"!==h()){for(t=n=0;n<4&&rV(SV,h());)t=16*t+ZL(h(),16),d++,n++;if("."===h()){if(0===n)return;if(d-=n,u>6)return;for(r=0;h();){if(i=null,r>0){if(!("."===h()&&r<4))return;d++}if(!rV(yV,h()))return;for(;rV(yV,h());){if(o=ZL(h(),10),null===i)i=o;else{if(0===i)return;i=10*i+o}if(i>255)return;d++}c[u]=256*c[u]+i,2!=++r&&4!==r||u++}if(4!==r)return;break}if(":"===h()){if(d++,!h())return}else if(h())return;c[u++]=t}else{if(null!==l)return;d++,l=++u}}if(null!==l)for(a=u-l,u=7;0!==u&&a>0;)s=c[u],c[u--]=c[l+a-1],c[l+--a]=s;else if(8!==u)return;return c}(dV(e,1,-1)),!t)return mV;this.host=t}else if(this.isSpecial()){if(e=HL(e),rV(IV,e))return mV;if(t=function(e){var t,n,r,i,o,a,s,c=lV(e,".");if(c.length&&""===c[c.length-1]&&c.length--,(t=c.length)>4)return e;for(n=[],r=0;r<t;r++){if(""===(i=c[r]))return e;if(o=10,i.length>1&&"0"===nV(i,0)&&(o=rV(EV,i)?16:8,i=dV(i,8===o?1:2)),""===i)a=0;else{if(!rV(10===o?kV:8===o?TV:SV,i))return e;a=ZL(i,o)}sV(n,a)}for(r=0;r<t;r++)if(a=n[r],r===t-1){if(a>=tV(256,5-t))return null}else if(a>255)return null;for(s=aV(n),r=0;r<n.length;r++)s+=n[r]*tV(256,3-r);return s}(e),null===t)return mV;this.host=t}else{if(rV(bV,e))return mV;for(t="",n=UL(e),r=0;r<n.length;r++)t+=PV(n[r],DV);this.host=t}},cannotHaveUsernamePasswordPort:function(){return!this.host||this.cannotBeABaseURL||"file"===this.scheme},includesCredentials:function(){return""!==this.username||""!==this.password},isSpecial:function(){return LL(MV,this.scheme)},shortenPath:function(){var e=this.path,t=e.length;!t||"file"===this.scheme&&1===t&&LV(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 null!==i?(u+="//",e.includesCredentials()&&(u+=n+(r?":"+r:"")+"@"),u+=wV(i),null!==o&&(u+=":"+o)):"file"===t&&(u+="//"),u+=e.cannotBeABaseURL?a[0]:a.length?"/"+iV(a,"/"):"",null!==s&&(u+="?"+s),null!==c&&(u+="#"+c),u},setHref:function(e){var t=this.parse(e);if(t)throw new $L(t);this.searchParams.update()},getOrigin:function(){var e=this.scheme,t=this.port;if("blob"===e)try{return new sU(e.path[0]).origin}catch(t3){return"null"}return"file"!==e&&this.isSpecial()?e+"://"+wV(this.host)+(null!==t?":"+t:""):"null"},getProtocol:function(){return this.scheme+":"},setProtocol:function(e){this.parse(jL(e)+":",FV)},getUsername:function(){return this.username},setUsername:function(e){var t=UL(jL(e));if(!this.cannotHaveUsernamePasswordPort()){this.username="";for(var n=0;n<t.length;n++)this.username+=PV(t[n],OV)}},getPassword:function(){return this.password},setPassword:function(e){var t=UL(jL(e));if(!this.cannotHaveUsernamePasswordPort()){this.password="";for(var n=0;n<t.length;n++)this.password+=PV(t[n],OV)}},getHost:function(){var e=this.host,t=this.port;return null===e?"":null===t?wV(e):wV(e)+":"+t},setHost:function(e){this.cannotBeABaseURL||this.parse(e,YV)},getHostname:function(){var e=this.host;return null===e?"":wV(e)},setHostname:function(e){this.cannotBeABaseURL||this.parse(e,XV)},getPort:function(){var e=this.port;return null===e?"":jL(e)},setPort:function(e){this.cannotHaveUsernamePasswordPort()||(""===(e=jL(e))?this.port=null:this.parse(e,QV))},getPathname:function(){var e=this.path;return this.cannotBeABaseURL?e[0]:e.length?"/"+iV(e,"/"):""},setPathname:function(e){this.cannotBeABaseURL||(this.path=[],this.parse(e,tU))},getSearch:function(){var e=this.query;return e?"?"+e:""},setSearch:function(e){""===(e=jL(e))?this.query=null:("?"===nV(e,0)&&(e=dV(e,1)),this.query="",this.parse(e,iU)),this.searchParams.update()},getSearchParams:function(){return this.searchParams.facade},getHash:function(){var e=this.fragment;return e?"#"+e:""},setHash:function(e){""!==(e=jL(e))?("#"===nV(e,0)&&(e=dV(e,1)),this.fragment="",this.parse(e,oU)):this.fragment=null},update:function(){this.query=this.searchParams.serialize()||null}};var sU=function(e){var t=ML(this,cU),n=WL(arguments.length,1)>1?arguments[1]:void 0,r=zL(t,new aU(e,!1,n));CL||(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())},cU=sU.prototype,uU=function(e,t){return{get:function(){return qL(this)[e]()},set:t&&function(e){return qL(this)[t](e)},configurable:!0,enumerable:!0}};if(CL&&(PL(cU,"href",uU("serialize","setHref")),PL(cU,"origin",uU("getOrigin")),PL(cU,"protocol",uU("getProtocol","setProtocol")),PL(cU,"username",uU("getUsername","setUsername")),PL(cU,"password",uU("getPassword","setPassword")),PL(cU,"host",uU("getHost","setHost")),PL(cU,"hostname",uU("getHostname","setHostname")),PL(cU,"port",uU("getPort","setPort")),PL(cU,"pathname",uU("getPathname","setPathname")),PL(cU,"search",uU("getSearch","setSearch")),PL(cU,"searchParams",uU("getSearchParams")),PL(cU,"hash",uU("getHash","setHash"))),OL(cU,"toJSON",(function(){return qL(this).serialize()}),{enumerable:!0}),OL(cU,"toString",(function(){return qL(this).serialize()}),{enumerable:!0}),QL){var lU=QL.createObjectURL,dU=QL.revokeObjectURL;lU&&OL(sU,"createObjectURL",NL(lU,QL)),dU&&OL(sU,"revokeObjectURL",NL(dU,QL))}GL(sU,"URL"),RL({global:!0,constructor:!0,forced:!wL,sham:!CL},{URL:sU});var hU=M;Ci({target:"URL",proto:!0,enumerable:!0},{toJSON:function(){return hU(URL.prototype.toString,this)}});let fU=!0,pU=!0;function mU(e,t,n){const r=e.match(t);return r&&r.length>=n&&parseInt(r[n],10)}function vU(e,t,n){if(!e.RTCPeerConnection)return;const r=e.RTCPeerConnection.prototype,i=r.addEventListener;r.addEventListener=function(e,r){if(e!==t)return i.apply(this,arguments);const o=e=>{const t=n(e);t&&(r.handleEvent?r.handleEvent(t):r(t))};return this._eventMap=this._eventMap||{},this._eventMap[t]||(this._eventMap[t]=new Map),this._eventMap[t].set(r,o),i.apply(this,[e,o])};const o=r.removeEventListener;r.removeEventListener=function(e,n){if(e!==t||!this._eventMap||!this._eventMap[t])return o.apply(this,arguments);if(!this._eventMap[t].has(n))return o.apply(this,arguments);const r=this._eventMap[t].get(n);return this._eventMap[t].delete(n),0===this._eventMap[t].size&&delete this._eventMap[t],0===Object.keys(this._eventMap).length&&delete this._eventMap,o.apply(this,[e,r])},Object.defineProperty(r,"on"+t,{get(){return this["_on"+t]},set(e){this["_on"+t]&&(this.removeEventListener(t,this["_on"+t]),delete this["_on"+t]),e&&this.addEventListener(t,this["_on"+t]=e)},enumerable:!0,configurable:!0})}function _U(e){return"boolean"!=typeof e?new Error("Argument type: "+typeof e+". Please use a boolean."):(fU=e,e?"adapter.js logging disabled":"adapter.js logging enabled")}function gU(e){return"boolean"!=typeof e?new Error("Argument type: "+typeof e+". Please use a boolean."):(pU=!e,"adapter.js deprecation warnings "+(e?"disabled":"enabled"))}function yU(){if("object"==typeof window){if(fU)return;"undefined"!=typeof console&&"function"==typeof console.log&&console.log.apply(console,arguments)}}function EU(e,t){pU&&console.warn(e+" is deprecated, please use "+t+" instead.")}function TU(e){return"[object Object]"===Object.prototype.toString.call(e)}function kU(e){return TU(e)?Object.keys(e).reduce((function(t,n){const r=TU(e[n]),i=r?kU(e[n]):e[n],o=r&&!Object.keys(i).length;return void 0===i||o?t:Object.assign(t,{[n]:i})}),{}):e}function SU(e,t,n){t&&!n.has(t.id)&&(n.set(t.id,t),Object.keys(t).forEach((r=>{r.endsWith("Id")?SU(e,e.get(t[r]),n):r.endsWith("Ids")&&t[r].forEach((t=>{SU(e,e.get(t),n)}))})))}function IU(e,t,n){const r=n?"outbound-rtp":"inbound-rtp",i=new Map;if(null===t)return i;const o=[];return e.forEach((e=>{"track"===e.type&&e.trackIdentifier===t.id&&o.push(e)})),o.forEach((t=>{e.forEach((n=>{n.type===r&&n.trackId===t.id&&SU(e,n,i)}))})),i}const bU=yU;function AU(e,t){const n=e&&e.navigator;if(!n.mediaDevices)return;const r=function(e){if("object"!=typeof e||e.mandatory||e.optional)return e;const t={};return Object.keys(e).forEach((n=>{if("require"===n||"advanced"===n||"mediaSource"===n)return;const r="object"==typeof e[n]?e[n]:{ideal:e[n]};void 0!==r.exact&&"number"==typeof r.exact&&(r.min=r.max=r.exact);const i=function(e,t){return e?e+t.charAt(0).toUpperCase()+t.slice(1):"deviceId"===t?"sourceId":t};if(void 0!==r.ideal){t.optional=t.optional||[];let e={};"number"==typeof r.ideal?(e[i("min",n)]=r.ideal,t.optional.push(e),e={},e[i("max",n)]=r.ideal,t.optional.push(e)):(e[i("",n)]=r.ideal,t.optional.push(e))}void 0!==r.exact&&"number"!=typeof r.exact?(t.mandatory=t.mandatory||{},t.mandatory[i("",n)]=r.exact):["min","max"].forEach((e=>{void 0!==r[e]&&(t.mandatory=t.mandatory||{},t.mandatory[i(e,n)]=r[e])}))})),e.advanced&&(t.optional=(t.optional||[]).concat(e.advanced)),t},i=function(e,i){if(t.version>=61)return i(e);if((e=JSON.parse(JSON.stringify(e)))&&"object"==typeof e.audio){const t=function(e,t,n){t in e&&!(n in e)&&(e[n]=e[t],delete e[t])};t((e=JSON.parse(JSON.stringify(e))).audio,"autoGainControl","googAutoGainControl"),t(e.audio,"noiseSuppression","googNoiseSuppression"),e.audio=r(e.audio)}if(e&&"object"==typeof e.video){let o=e.video.facingMode;o=o&&("object"==typeof o?o:{ideal:o});const a=t.version<66;if(o&&("user"===o.exact||"environment"===o.exact||"user"===o.ideal||"environment"===o.ideal)&&(!n.mediaDevices.getSupportedConstraints||!n.mediaDevices.getSupportedConstraints().facingMode||a)){let t;if(delete e.video.facingMode,"environment"===o.exact||"environment"===o.ideal?t=["back","rear"]:"user"!==o.exact&&"user"!==o.ideal||(t=["front"]),t)return n.mediaDevices.enumerateDevices().then((n=>{let a=(n=n.filter((e=>"videoinput"===e.kind))).find((e=>t.some((t=>e.label.toLowerCase().includes(t)))));return!a&&n.length&&t.includes("back")&&(a=n[n.length-1]),a&&(e.video.deviceId=o.exact?{exact:a.deviceId}:{ideal:a.deviceId}),e.video=r(e.video),bU("chrome: "+JSON.stringify(e)),i(e)}))}e.video=r(e.video)}return bU("chrome: "+JSON.stringify(e)),i(e)},o=function(e){return t.version>=64?e:{name:{PermissionDeniedError:"NotAllowedError",PermissionDismissedError:"NotAllowedError",InvalidStateError:"NotAllowedError",DevicesNotFoundError:"NotFoundError",ConstraintNotSatisfiedError:"OverconstrainedError",TrackStartError:"NotReadableError",MediaDeviceFailedDueToShutdown:"NotAllowedError",MediaDeviceKillSwitchOn:"NotAllowedError",TabCaptureError:"AbortError",ScreenCaptureError:"AbortError",DeviceCaptureError:"AbortError"}[e.name]||e.name,message:e.message,constraint:e.constraint||e.constraintName,toString(){return this.name+(this.message&&": ")+this.message}}};if(n.getUserMedia=function(e,t,r){i(e,(e=>{n.webkitGetUserMedia(e,t,(e=>{r&&r(o(e))}))}))}.bind(n),n.mediaDevices.getUserMedia){const e=n.mediaDevices.getUserMedia.bind(n.mediaDevices);n.mediaDevices.getUserMedia=function(t){return i(t,(t=>e(t).then((e=>{if(t.audio&&!e.getAudioTracks().length||t.video&&!e.getVideoTracks().length)throw e.getTracks().forEach((e=>{e.stop()})),new DOMException("","NotFoundError");return e}),(e=>Promise.reject(o(e))))))}}}function RU(e){e.MediaStream=e.MediaStream||e.webkitMediaStream}function CU(e){if("object"==typeof e&&e.RTCPeerConnection&&!("ontrack"in e.RTCPeerConnection.prototype)){Object.defineProperty(e.RTCPeerConnection.prototype,"ontrack",{get(){return this._ontrack},set(e){this._ontrack&&this.removeEventListener("track",this._ontrack),this.addEventListener("track",this._ontrack=e)},enumerable:!0,configurable:!0});const t=e.RTCPeerConnection.prototype.setRemoteDescription;e.RTCPeerConnection.prototype.setRemoteDescription=function(){return this._ontrackpoly||(this._ontrackpoly=t=>{t.stream.addEventListener("addtrack",(n=>{let r;r=e.RTCPeerConnection.prototype.getReceivers?this.getReceivers().find((e=>e.track&&e.track.id===n.track.id)):{track:n.track};const i=new Event("track");i.track=n.track,i.receiver=r,i.transceiver={receiver:r},i.streams=[t.stream],this.dispatchEvent(i)})),t.stream.getTracks().forEach((n=>{let r;r=e.RTCPeerConnection.prototype.getReceivers?this.getReceivers().find((e=>e.track&&e.track.id===n.id)):{track:n};const i=new Event("track");i.track=n,i.receiver=r,i.transceiver={receiver:r},i.streams=[t.stream],this.dispatchEvent(i)}))},this.addEventListener("addstream",this._ontrackpoly)),t.apply(this,arguments)}}else vU(e,"track",(e=>(e.transceiver||Object.defineProperty(e,"transceiver",{value:{receiver:e.receiver}}),e)))}function wU(e){if("object"==typeof e&&e.RTCPeerConnection&&!("getSenders"in e.RTCPeerConnection.prototype)&&"createDTMFSender"in e.RTCPeerConnection.prototype){const t=function(e,t){return{track:t,get dtmf(){return void 0===this._dtmf&&("audio"===t.kind?this._dtmf=e.createDTMFSender(t):this._dtmf=null),this._dtmf},_pc:e}};if(!e.RTCPeerConnection.prototype.getSenders){e.RTCPeerConnection.prototype.getSenders=function(){return this._senders=this._senders||[],this._senders.slice()};const n=e.RTCPeerConnection.prototype.addTrack;e.RTCPeerConnection.prototype.addTrack=function(e,r){let i=n.apply(this,arguments);return i||(i=t(this,e),this._senders.push(i)),i};const r=e.RTCPeerConnection.prototype.removeTrack;e.RTCPeerConnection.prototype.removeTrack=function(e){r.apply(this,arguments);const t=this._senders.indexOf(e);-1!==t&&this._senders.splice(t,1)}}const n=e.RTCPeerConnection.prototype.addStream;e.RTCPeerConnection.prototype.addStream=function(e){this._senders=this._senders||[],n.apply(this,[e]),e.getTracks().forEach((e=>{this._senders.push(t(this,e))}))};const r=e.RTCPeerConnection.prototype.removeStream;e.RTCPeerConnection.prototype.removeStream=function(e){this._senders=this._senders||[],r.apply(this,[e]),e.getTracks().forEach((e=>{const t=this._senders.find((t=>t.track===e));t&&this._senders.splice(this._senders.indexOf(t),1)}))}}else if("object"==typeof e&&e.RTCPeerConnection&&"getSenders"in e.RTCPeerConnection.prototype&&"createDTMFSender"in e.RTCPeerConnection.prototype&&e.RTCRtpSender&&!("dtmf"in e.RTCRtpSender.prototype)){const t=e.RTCPeerConnection.prototype.getSenders;e.RTCPeerConnection.prototype.getSenders=function(){const e=t.apply(this,[]);return e.forEach((e=>e._pc=this)),e},Object.defineProperty(e.RTCRtpSender.prototype,"dtmf",{get(){return void 0===this._dtmf&&("audio"===this.track.kind?this._dtmf=this._pc.createDTMFSender(this.track):this._dtmf=null),this._dtmf}})}}function DU(e){if(!e.RTCPeerConnection)return;const t=e.RTCPeerConnection.prototype.getStats;e.RTCPeerConnection.prototype.getStats=function(){const[e,n,r]=arguments;if(arguments.length>0&&"function"==typeof e)return t.apply(this,arguments);if(0===t.length&&(0===arguments.length||"function"!=typeof e))return t.apply(this,[]);const i=function(e){const t={};return e.result().forEach((e=>{const n={id:e.id,timestamp:e.timestamp,type:{localcandidate:"local-candidate",remotecandidate:"remote-candidate"}[e.type]||e.type};e.names().forEach((t=>{n[t]=e.stat(t)})),t[n.id]=n})),t},o=function(e){return new Map(Object.keys(e).map((t=>[t,e[t]])))};if(arguments.length>=2){const r=function(e){n(o(i(e)))};return t.apply(this,[r,e])}return new Promise(((e,n)=>{t.apply(this,[function(t){e(o(i(t)))},n])})).then(n,r)}}function NU(e){if(!("object"==typeof e&&e.RTCPeerConnection&&e.RTCRtpSender&&e.RTCRtpReceiver))return;if(!("getStats"in e.RTCRtpSender.prototype)){const t=e.RTCPeerConnection.prototype.getSenders;t&&(e.RTCPeerConnection.prototype.getSenders=function(){const e=t.apply(this,[]);return e.forEach((e=>e._pc=this)),e});const n=e.RTCPeerConnection.prototype.addTrack;n&&(e.RTCPeerConnection.prototype.addTrack=function(){const e=n.apply(this,arguments);return e._pc=this,e}),e.RTCRtpSender.prototype.getStats=function(){const e=this;return this._pc.getStats().then((t=>IU(t,e.track,!0)))}}if(!("getStats"in e.RTCRtpReceiver.prototype)){const t=e.RTCPeerConnection.prototype.getReceivers;t&&(e.RTCPeerConnection.prototype.getReceivers=function(){const e=t.apply(this,[]);return e.forEach((e=>e._pc=this)),e}),vU(e,"track",(e=>(e.receiver._pc=e.srcElement,e))),e.RTCRtpReceiver.prototype.getStats=function(){const e=this;return this._pc.getStats().then((t=>IU(t,e.track,!1)))}}if(!("getStats"in e.RTCRtpSender.prototype)||!("getStats"in e.RTCRtpReceiver.prototype))return;const t=e.RTCPeerConnection.prototype.getStats;e.RTCPeerConnection.prototype.getStats=function(){if(arguments.length>0&&arguments[0]instanceof e.MediaStreamTrack){const e=arguments[0];let t,n,r;return this.getSenders().forEach((n=>{n.track===e&&(t?r=!0:t=n)})),this.getReceivers().forEach((t=>(t.track===e&&(n?r=!0:n=t),t.track===e))),r||t&&n?Promise.reject(new DOMException("There are more than one sender or receiver for the track.","InvalidAccessError")):t?t.getStats():n?n.getStats():Promise.reject(new DOMException("There is no sender or receiver for the track.","InvalidAccessError"))}return t.apply(this,arguments)}}function xU(e){e.RTCPeerConnection.prototype.getLocalStreams=function(){return this._shimmedLocalStreams=this._shimmedLocalStreams||{},Object.keys(this._shimmedLocalStreams).map((e=>this._shimmedLocalStreams[e][0]))};const t=e.RTCPeerConnection.prototype.addTrack;e.RTCPeerConnection.prototype.addTrack=function(e,n){if(!n)return t.apply(this,arguments);this._shimmedLocalStreams=this._shimmedLocalStreams||{};const r=t.apply(this,arguments);return this._shimmedLocalStreams[n.id]?-1===this._shimmedLocalStreams[n.id].indexOf(r)&&this._shimmedLocalStreams[n.id].push(r):this._shimmedLocalStreams[n.id]=[n,r],r};const n=e.RTCPeerConnection.prototype.addStream;e.RTCPeerConnection.prototype.addStream=function(e){this._shimmedLocalStreams=this._shimmedLocalStreams||{},e.getTracks().forEach((e=>{if(this.getSenders().find((t=>t.track===e)))throw new DOMException("Track already exists.","InvalidAccessError")}));const t=this.getSenders();n.apply(this,arguments);const r=this.getSenders().filter((e=>-1===t.indexOf(e)));this._shimmedLocalStreams[e.id]=[e].concat(r)};const r=e.RTCPeerConnection.prototype.removeStream;e.RTCPeerConnection.prototype.removeStream=function(e){return this._shimmedLocalStreams=this._shimmedLocalStreams||{},delete this._shimmedLocalStreams[e.id],r.apply(this,arguments)};const i=e.RTCPeerConnection.prototype.removeTrack;e.RTCPeerConnection.prototype.removeTrack=function(e){return this._shimmedLocalStreams=this._shimmedLocalStreams||{},e&&Object.keys(this._shimmedLocalStreams).forEach((t=>{const n=this._shimmedLocalStreams[t].indexOf(e);-1!==n&&this._shimmedLocalStreams[t].splice(n,1),1===this._shimmedLocalStreams[t].length&&delete this._shimmedLocalStreams[t]})),i.apply(this,arguments)}}function OU(e,t){if(!e.RTCPeerConnection)return;if(e.RTCPeerConnection.prototype.addTrack&&t.version>=65)return xU(e);const n=e.RTCPeerConnection.prototype.getLocalStreams;e.RTCPeerConnection.prototype.getLocalStreams=function(){const e=n.apply(this);return this._reverseStreams=this._reverseStreams||{},e.map((e=>this._reverseStreams[e.id]))};const r=e.RTCPeerConnection.prototype.addStream;e.RTCPeerConnection.prototype.addStream=function(t){if(this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{},t.getTracks().forEach((e=>{if(this.getSenders().find((t=>t.track===e)))throw new DOMException("Track already exists.","InvalidAccessError")})),!this._reverseStreams[t.id]){const n=new e.MediaStream(t.getTracks());this._streams[t.id]=n,this._reverseStreams[n.id]=t,t=n}r.apply(this,[t])};const i=e.RTCPeerConnection.prototype.removeStream;function o(e,t){let n=t.sdp;return Object.keys(e._reverseStreams||[]).forEach((t=>{const r=e._reverseStreams[t],i=e._streams[r.id];n=n.replace(new RegExp(i.id,"g"),r.id)})),new RTCSessionDescription({type:t.type,sdp:n})}e.RTCPeerConnection.prototype.removeStream=function(e){this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{},i.apply(this,[this._streams[e.id]||e]),delete this._reverseStreams[this._streams[e.id]?this._streams[e.id].id:e.id],delete this._streams[e.id]},e.RTCPeerConnection.prototype.addTrack=function(t,n){if("closed"===this.signalingState)throw new DOMException("The RTCPeerConnection's signalingState is 'closed'.","InvalidStateError");const r=[].slice.call(arguments,1);if(1!==r.length||!r[0].getTracks().find((e=>e===t)))throw new DOMException("The adapter.js addTrack polyfill only supports a single stream which is associated with the specified track.","NotSupportedError");if(this.getSenders().find((e=>e.track===t)))throw new DOMException("Track already exists.","InvalidAccessError");this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{};const i=this._streams[n.id];if(i)i.addTrack(t),Promise.resolve().then((()=>{this.dispatchEvent(new Event("negotiationneeded"))}));else{const r=new e.MediaStream([t]);this._streams[n.id]=r,this._reverseStreams[r.id]=n,this.addStream(r)}return this.getSenders().find((e=>e.track===t))},["createOffer","createAnswer"].forEach((function(t){const n=e.RTCPeerConnection.prototype[t],r={[t](){const e=arguments;return arguments.length&&"function"==typeof arguments[0]?n.apply(this,[t=>{const n=o(this,t);e[0].apply(null,[n])},t=>{e[1]&&e[1].apply(null,t)},arguments[2]]):n.apply(this,arguments).then((e=>o(this,e)))}};e.RTCPeerConnection.prototype[t]=r[t]}));const a=e.RTCPeerConnection.prototype.setLocalDescription;e.RTCPeerConnection.prototype.setLocalDescription=function(){return arguments.length&&arguments[0].type?(arguments[0]=function(e,t){let n=t.sdp;return Object.keys(e._reverseStreams||[]).forEach((t=>{const r=e._reverseStreams[t],i=e._streams[r.id];n=n.replace(new RegExp(r.id,"g"),i.id)})),new RTCSessionDescription({type:t.type,sdp:n})}(this,arguments[0]),a.apply(this,arguments)):a.apply(this,arguments)};const s=Object.getOwnPropertyDescriptor(e.RTCPeerConnection.prototype,"localDescription");Object.defineProperty(e.RTCPeerConnection.prototype,"localDescription",{get(){const e=s.get.apply(this);return""===e.type?e:o(this,e)}}),e.RTCPeerConnection.prototype.removeTrack=function(e){if("closed"===this.signalingState)throw new DOMException("The RTCPeerConnection's signalingState is 'closed'.","InvalidStateError");if(!e._pc)throw new DOMException("Argument 1 of RTCPeerConnection.removeTrack does not implement interface RTCRtpSender.","TypeError");if(!(e._pc===this))throw new DOMException("Sender was not created by this connection.","InvalidAccessError");let t;this._streams=this._streams||{},Object.keys(this._streams).forEach((n=>{this._streams[n].getTracks().find((t=>e.track===t))&&(t=this._streams[n])})),t&&(1===t.getTracks().length?this.removeStream(this._reverseStreams[t.id]):t.removeTrack(e.track),this.dispatchEvent(new Event("negotiationneeded")))}}function PU(e,t){!e.RTCPeerConnection&&e.webkitRTCPeerConnection&&(e.RTCPeerConnection=e.webkitRTCPeerConnection),e.RTCPeerConnection&&t.version<53&&["setLocalDescription","setRemoteDescription","addIceCandidate"].forEach((function(t){const n=e.RTCPeerConnection.prototype[t],r={[t](){return arguments[0]=new("addIceCandidate"===t?e.RTCIceCandidate:e.RTCSessionDescription)(arguments[0]),n.apply(this,arguments)}};e.RTCPeerConnection.prototype[t]=r[t]}))}function MU(e,t){vU(e,"negotiationneeded",(e=>{const n=e.target;if(!(t.version<72||n.getConfiguration&&"plan-b"===n.getConfiguration().sdpSemantics)||"stable"===n.signalingState)return e}))}var LU=Object.freeze({__proto__:null,shimMediaStream:RU,shimOnTrack:CU,shimGetSendersWithDtmf:wU,shimGetStats:DU,shimSenderReceiverGetStats:NU,shimAddTrackRemoveTrackWithNative:xU,shimAddTrackRemoveTrack:OU,shimPeerConnection:PU,fixNegotiationNeeded:MU,shimGetUserMedia:AU,shimGetDisplayMedia:function(e,t){e.navigator.mediaDevices&&"getDisplayMedia"in e.navigator.mediaDevices||e.navigator.mediaDevices&&("function"==typeof t?e.navigator.mediaDevices.getDisplayMedia=function(n){return t(n).then((t=>{const r=n.video&&n.video.width,i=n.video&&n.video.height,o=n.video&&n.video.frameRate;return n.video={mandatory:{chromeMediaSource:"desktop",chromeMediaSourceId:t,maxFrameRate:o||3}},r&&(n.video.mandatory.maxWidth=r),i&&(n.video.mandatory.maxHeight=i),e.navigator.mediaDevices.getUserMedia(n)}))}:console.error("shimGetDisplayMedia: getSourceId argument is not a function"))}});function VU(e,t){const n=e&&e.navigator,r=e&&e.MediaStreamTrack;if(n.getUserMedia=function(e,t,r){EU("navigator.getUserMedia","navigator.mediaDevices.getUserMedia"),n.mediaDevices.getUserMedia(e).then(t,r)},!(t.version>55&&"autoGainControl"in n.mediaDevices.getSupportedConstraints())){const e=function(e,t,n){t in e&&!(n in e)&&(e[n]=e[t],delete e[t])},t=n.mediaDevices.getUserMedia.bind(n.mediaDevices);if(n.mediaDevices.getUserMedia=function(n){return"object"==typeof n&&"object"==typeof n.audio&&(n=JSON.parse(JSON.stringify(n)),e(n.audio,"autoGainControl","mozAutoGainControl"),e(n.audio,"noiseSuppression","mozNoiseSuppression")),t(n)},r&&r.prototype.getSettings){const t=r.prototype.getSettings;r.prototype.getSettings=function(){const n=t.apply(this,arguments);return e(n,"mozAutoGainControl","autoGainControl"),e(n,"mozNoiseSuppression","noiseSuppression"),n}}if(r&&r.prototype.applyConstraints){const t=r.prototype.applyConstraints;r.prototype.applyConstraints=function(n){return"audio"===this.kind&&"object"==typeof n&&(n=JSON.parse(JSON.stringify(n)),e(n,"autoGainControl","mozAutoGainControl"),e(n,"noiseSuppression","mozNoiseSuppression")),t.apply(this,[n])}}}}function UU(e){"object"==typeof e&&e.RTCTrackEvent&&"receiver"in e.RTCTrackEvent.prototype&&!("transceiver"in e.RTCTrackEvent.prototype)&&Object.defineProperty(e.RTCTrackEvent.prototype,"transceiver",{get(){return{receiver:this.receiver}}})}function FU(e,t){if("object"!=typeof e||!e.RTCPeerConnection&&!e.mozRTCPeerConnection)return;!e.RTCPeerConnection&&e.mozRTCPeerConnection&&(e.RTCPeerConnection=e.mozRTCPeerConnection),t.version<53&&["setLocalDescription","setRemoteDescription","addIceCandidate"].forEach((function(t){const n=e.RTCPeerConnection.prototype[t],r={[t](){return arguments[0]=new("addIceCandidate"===t?e.RTCIceCandidate:e.RTCSessionDescription)(arguments[0]),n.apply(this,arguments)}};e.RTCPeerConnection.prototype[t]=r[t]}));const 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(){const[e,i,o]=arguments;return r.apply(this,[e||null]).then((e=>{if(t.version<53&&!i)try{e.forEach((e=>{e.type=n[e.type]||e.type}))}catch(dB){if("TypeError"!==dB.name)throw dB;e.forEach(((t,r)=>{e.set(r,Object.assign({},t,{type:n[t.type]||t.type}))}))}return e})).then(i,o)}}function BU(e){if("object"!=typeof e||!e.RTCPeerConnection||!e.RTCRtpSender)return;if(e.RTCRtpSender&&"getStats"in e.RTCRtpSender.prototype)return;const t=e.RTCPeerConnection.prototype.getSenders;t&&(e.RTCPeerConnection.prototype.getSenders=function(){const e=t.apply(this,[]);return e.forEach((e=>e._pc=this)),e});const n=e.RTCPeerConnection.prototype.addTrack;n&&(e.RTCPeerConnection.prototype.addTrack=function(){const e=n.apply(this,arguments);return e._pc=this,e}),e.RTCRtpSender.prototype.getStats=function(){return this.track?this._pc.getStats(this.track):Promise.resolve(new Map)}}function HU(e){if("object"!=typeof e||!e.RTCPeerConnection||!e.RTCRtpSender)return;if(e.RTCRtpSender&&"getStats"in e.RTCRtpReceiver.prototype)return;const t=e.RTCPeerConnection.prototype.getReceivers;t&&(e.RTCPeerConnection.prototype.getReceivers=function(){const e=t.apply(this,[]);return e.forEach((e=>e._pc=this)),e}),vU(e,"track",(e=>(e.receiver._pc=e.srcElement,e))),e.RTCRtpReceiver.prototype.getStats=function(){return this._pc.getStats(this.track)}}function jU(e){e.RTCPeerConnection&&!("removeStream"in e.RTCPeerConnection.prototype)&&(e.RTCPeerConnection.prototype.removeStream=function(e){EU("removeStream","removeTrack"),this.getSenders().forEach((t=>{t.track&&e.getTracks().includes(t.track)&&this.removeTrack(t)}))})}function GU(e){e.DataChannel&&!e.RTCDataChannel&&(e.RTCDataChannel=e.DataChannel)}function WU(e){if("object"!=typeof e||!e.RTCPeerConnection)return;const t=e.RTCPeerConnection.prototype.addTransceiver;t&&(e.RTCPeerConnection.prototype.addTransceiver=function(){this.setParametersPromises=[];let e=arguments[1]&&arguments[1].sendEncodings;void 0===e&&(e=[]),e=[...e];const n=e.length>0;n&&e.forEach((e=>{if("rid"in e){if(!/^[a-z0-9]{0,16}$/i.test(e.rid))throw new TypeError("Invalid RID value provided.")}if("scaleResolutionDownBy"in e&&!(parseFloat(e.scaleResolutionDownBy)>=1))throw new RangeError("scale_resolution_down_by must be >= 1.0");if("maxFramerate"in e&&!(parseFloat(e.maxFramerate)>=0))throw new RangeError("max_framerate must be >= 0.0")}));const r=t.apply(this,arguments);if(n){const{sender:t}=r,n=t.getParameters();(!("encodings"in n)||1===n.encodings.length&&0===Object.keys(n.encodings[0]).length)&&(n.encodings=e,t.sendEncodings=e,this.setParametersPromises.push(t.setParameters(n).then((()=>{delete t.sendEncodings})).catch((()=>{delete t.sendEncodings}))))}return r})}function JU(e){if("object"!=typeof e||!e.RTCRtpSender)return;const t=e.RTCRtpSender.prototype.getParameters;t&&(e.RTCRtpSender.prototype.getParameters=function(){const e=t.apply(this,arguments);return"encodings"in e||(e.encodings=[].concat(this.sendEncodings||[{}])),e})}function KU(e){if("object"!=typeof e||!e.RTCPeerConnection)return;const t=e.RTCPeerConnection.prototype.createOffer;e.RTCPeerConnection.prototype.createOffer=function(){return this.setParametersPromises&&this.setParametersPromises.length?Promise.all(this.setParametersPromises).then((()=>t.apply(this,arguments))).finally((()=>{this.setParametersPromises=[]})):t.apply(this,arguments)}}function zU(e){if("object"!=typeof e||!e.RTCPeerConnection)return;const t=e.RTCPeerConnection.prototype.createAnswer;e.RTCPeerConnection.prototype.createAnswer=function(){return this.setParametersPromises&&this.setParametersPromises.length?Promise.all(this.setParametersPromises).then((()=>t.apply(this,arguments))).finally((()=>{this.setParametersPromises=[]})):t.apply(this,arguments)}}var qU=Object.freeze({__proto__:null,shimOnTrack:UU,shimPeerConnection:FU,shimSenderGetStats:BU,shimReceiverGetStats:HU,shimRemoveStream:jU,shimRTCDataChannel:GU,shimAddTransceiver:WU,shimGetParameters:JU,shimCreateOffer:KU,shimCreateAnswer:zU,shimGetUserMedia:VU,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){const e=new DOMException("getDisplayMedia without video constraints is undefined");return e.name="NotFoundError",e.code=8,Promise.reject(e)}return!0===n.video?n.video={mediaSource:t}:n.video.mediaSource=t,e.navigator.mediaDevices.getUserMedia(n)})}});function YU(e){if("object"==typeof e&&e.RTCPeerConnection){if("getLocalStreams"in e.RTCPeerConnection.prototype||(e.RTCPeerConnection.prototype.getLocalStreams=function(){return this._localStreams||(this._localStreams=[]),this._localStreams}),!("addStream"in e.RTCPeerConnection.prototype)){const t=e.RTCPeerConnection.prototype.addTrack;e.RTCPeerConnection.prototype.addStream=function(e){this._localStreams||(this._localStreams=[]),this._localStreams.includes(e)||this._localStreams.push(e),e.getAudioTracks().forEach((n=>t.call(this,n,e))),e.getVideoTracks().forEach((n=>t.call(this,n,e)))},e.RTCPeerConnection.prototype.addTrack=function(e,...n){return n&&n.forEach((e=>{this._localStreams?this._localStreams.includes(e)||this._localStreams.push(e):this._localStreams=[e]})),t.apply(this,arguments)}}"removeStream"in e.RTCPeerConnection.prototype||(e.RTCPeerConnection.prototype.removeStream=function(e){this._localStreams||(this._localStreams=[]);const t=this._localStreams.indexOf(e);if(-1===t)return;this._localStreams.splice(t,1);const n=e.getTracks();this.getSenders().forEach((e=>{n.includes(e.track)&&this.removeTrack(e)}))})}}function XU(e){if("object"==typeof e&&e.RTCPeerConnection&&("getRemoteStreams"in e.RTCPeerConnection.prototype||(e.RTCPeerConnection.prototype.getRemoteStreams=function(){return this._remoteStreams?this._remoteStreams:[]}),!("onaddstream"in e.RTCPeerConnection.prototype))){Object.defineProperty(e.RTCPeerConnection.prototype,"onaddstream",{get(){return this._onaddstream},set(e){this._onaddstream&&(this.removeEventListener("addstream",this._onaddstream),this.removeEventListener("track",this._onaddstreampoly)),this.addEventListener("addstream",this._onaddstream=e),this.addEventListener("track",this._onaddstreampoly=e=>{e.streams.forEach((e=>{if(this._remoteStreams||(this._remoteStreams=[]),this._remoteStreams.includes(e))return;this._remoteStreams.push(e);const t=new Event("addstream");t.stream=e,this.dispatchEvent(t)}))})}});const t=e.RTCPeerConnection.prototype.setRemoteDescription;e.RTCPeerConnection.prototype.setRemoteDescription=function(){const e=this;return this._onaddstreampoly||this.addEventListener("track",this._onaddstreampoly=function(t){t.streams.forEach((t=>{if(e._remoteStreams||(e._remoteStreams=[]),e._remoteStreams.indexOf(t)>=0)return;e._remoteStreams.push(t);const n=new Event("addstream");n.stream=t,e.dispatchEvent(n)}))}),t.apply(e,arguments)}}}function QU(e){if("object"!=typeof e||!e.RTCPeerConnection)return;const t=e.RTCPeerConnection.prototype,n=t.createOffer,r=t.createAnswer,i=t.setLocalDescription,o=t.setRemoteDescription,a=t.addIceCandidate;t.createOffer=function(e,t){const r=arguments.length>=2?arguments[2]:arguments[0],i=n.apply(this,[r]);return t?(i.then(e,t),Promise.resolve()):i},t.createAnswer=function(e,t){const n=arguments.length>=2?arguments[2]:arguments[0],i=r.apply(this,[n]);return t?(i.then(e,t),Promise.resolve()):i};let s=function(e,t,n){const r=i.apply(this,[e]);return n?(r.then(t,n),Promise.resolve()):r};t.setLocalDescription=s,s=function(e,t,n){const r=o.apply(this,[e]);return n?(r.then(t,n),Promise.resolve()):r},t.setRemoteDescription=s,s=function(e,t,n){const r=a.apply(this,[e]);return n?(r.then(t,n),Promise.resolve()):r},t.addIceCandidate=s}function $U(e){const t=e&&e.navigator;if(t.mediaDevices&&t.mediaDevices.getUserMedia){const e=t.mediaDevices,n=e.getUserMedia.bind(e);t.mediaDevices.getUserMedia=e=>n(ZU(e))}!t.getUserMedia&&t.mediaDevices&&t.mediaDevices.getUserMedia&&(t.getUserMedia=function(e,n,r){t.mediaDevices.getUserMedia(e).then(n,r)}.bind(t))}function ZU(e){return e&&void 0!==e.video?Object.assign({},e,{video:kU(e.video)}):e}function eF(e){if(!e.RTCPeerConnection)return;const t=e.RTCPeerConnection;e.RTCPeerConnection=function(e,n){if(e&&e.iceServers){const t=[];for(let n=0;n<e.iceServers.length;n++){let r=e.iceServers[n];void 0===r.urls&&r.url?(EU("RTCIceServer.url","RTCIceServer.urls"),r=JSON.parse(JSON.stringify(r)),r.urls=r.url,delete r.url,t.push(r)):t.push(e.iceServers[n])}e.iceServers=t}return new t(e,n)},e.RTCPeerConnection.prototype=t.prototype,"generateCertificate"in t&&Object.defineProperty(e.RTCPeerConnection,"generateCertificate",{get:()=>t.generateCertificate})}function tF(e){"object"==typeof e&&e.RTCTrackEvent&&"receiver"in e.RTCTrackEvent.prototype&&!("transceiver"in e.RTCTrackEvent.prototype)&&Object.defineProperty(e.RTCTrackEvent.prototype,"transceiver",{get(){return{receiver:this.receiver}}})}function nF(e){const t=e.RTCPeerConnection.prototype.createOffer;e.RTCPeerConnection.prototype.createOffer=function(e){if(e){void 0!==e.offerToReceiveAudio&&(e.offerToReceiveAudio=!!e.offerToReceiveAudio);const t=this.getTransceivers().find((e=>"audio"===e.receiver.track.kind));!1===e.offerToReceiveAudio&&t?"sendrecv"===t.direction?t.setDirection?t.setDirection("sendonly"):t.direction="sendonly":"recvonly"===t.direction&&(t.setDirection?t.setDirection("inactive"):t.direction="inactive"):!0!==e.offerToReceiveAudio||t||this.addTransceiver("audio",{direction:"recvonly"}),void 0!==e.offerToReceiveVideo&&(e.offerToReceiveVideo=!!e.offerToReceiveVideo);const n=this.getTransceivers().find((e=>"video"===e.receiver.track.kind));!1===e.offerToReceiveVideo&&n?"sendrecv"===n.direction?n.setDirection?n.setDirection("sendonly"):n.direction="sendonly":"recvonly"===n.direction&&(n.setDirection?n.setDirection("inactive"):n.direction="inactive"):!0!==e.offerToReceiveVideo||n||this.addTransceiver("video",{direction:"recvonly"})}return t.apply(this,arguments)}}function rF(e){"object"!=typeof e||e.AudioContext||(e.AudioContext=e.webkitAudioContext)}var iF=Object.freeze({__proto__:null,shimLocalStreamsAPI:YU,shimRemoteStreamsAPI:XU,shimCallbacksAPI:QU,shimGetUserMedia:$U,shimConstraints:ZU,shimRTCIceServerUrls:eF,shimTrackEventTransceiver:tF,shimCreateOfferLegacy:nF,shimAudioContext:rF}),oF={},aF={get exports(){return oF},set exports(e){oF=e}};!function(e){const t={generateIdentifier:function(){return Math.random().toString(36).substring(2,12)}};t.localCName=t.generateIdentifier(),t.splitLines=function(e){return e.trim().split("\n").map((e=>e.trim()))},t.splitSections=function(e){return e.split("\nm=").map(((e,t)=>(t>0?"m="+e:e).trim()+"\r\n"))},t.getDescription=function(e){const n=t.splitSections(e);return n&&n[0]},t.getMediaSections=function(e){const n=t.splitSections(e);return n.shift(),n},t.matchPrefix=function(e,n){return t.splitLines(e).filter((e=>0===e.indexOf(n)))},t.parseCandidate=function(e){let t;t=0===e.indexOf("a=candidate:")?e.substring(12).split(" "):e.substring(10).split(" ");const n={foundation:t[0],component:{1:"rtp",2:"rtcp"}[t[1]]||t[1],protocol:t[2].toLowerCase(),priority:parseInt(t[3],10),ip:t[4],address:t[4],port:parseInt(t[5],10),type:t[7]};for(let r=8;r<t.length;r+=2)switch(t[r]){case"raddr":n.relatedAddress=t[r+1];break;case"rport":n.relatedPort=parseInt(t[r+1],10);break;case"tcptype":n.tcpType=t[r+1];break;case"ufrag":n.ufrag=t[r+1],n.usernameFragment=t[r+1];break;default:void 0===n[t[r]]&&(n[t[r]]=t[r+1])}return n},t.writeCandidate=function(e){const t=[];t.push(e.foundation);const n=e.component;"rtp"===n?t.push(1):"rtcp"===n?t.push(2):t.push(n),t.push(e.protocol.toUpperCase()),t.push(e.priority),t.push(e.address||e.ip),t.push(e.port);const r=e.type;return t.push("typ"),t.push(r),"host"!==r&&e.relatedAddress&&e.relatedPort&&(t.push("raddr"),t.push(e.relatedAddress),t.push("rport"),t.push(e.relatedPort)),e.tcpType&&"tcp"===e.protocol.toLowerCase()&&(t.push("tcptype"),t.push(e.tcpType)),(e.usernameFragment||e.ufrag)&&(t.push("ufrag"),t.push(e.usernameFragment||e.ufrag)),"candidate:"+t.join(" ")},t.parseIceOptions=function(e){return e.substring(14).split(" ")},t.parseRtpMap=function(e){let t=e.substring(9).split(" ");const n={payloadType:parseInt(t.shift(),10)};return t=t[0].split("/"),n.name=t[0],n.clockRate=parseInt(t[1],10),n.channels=3===t.length?parseInt(t[2],10):1,n.numChannels=n.channels,n},t.writeRtpMap=function(e){let t=e.payloadType;void 0!==e.preferredPayloadType&&(t=e.preferredPayloadType);const n=e.channels||e.numChannels||1;return"a=rtpmap:"+t+" "+e.name+"/"+e.clockRate+(1!==n?"/"+n:"")+"\r\n"},t.parseExtmap=function(e){const t=e.substring(9).split(" ");return{id:parseInt(t[0],10),direction:t[0].indexOf("/")>0?t[0].split("/")[1]:"sendrecv",uri:t[1],attributes:t.slice(2).join(" ")}},t.writeExtmap=function(e){return"a=extmap:"+(e.id||e.preferredId)+(e.direction&&"sendrecv"!==e.direction?"/"+e.direction:"")+" "+e.uri+(e.attributes?" "+e.attributes:"")+"\r\n"},t.parseFmtp=function(e){const t={};let n;const r=e.substring(e.indexOf(" ")+1).split(";");for(let i=0;i<r.length;i++)n=r[i].trim().split("="),t[n[0].trim()]=n[1];return t},t.writeFmtp=function(e){let t="",n=e.payloadType;if(void 0!==e.preferredPayloadType&&(n=e.preferredPayloadType),e.parameters&&Object.keys(e.parameters).length){const r=[];Object.keys(e.parameters).forEach((t=>{void 0!==e.parameters[t]?r.push(t+"="+e.parameters[t]):r.push(t)})),t+="a=fmtp:"+n+" "+r.join(";")+"\r\n"}return t},t.parseRtcpFb=function(e){const t=e.substring(e.indexOf(" ")+1).split(" ");return{type:t.shift(),parameter:t.join(" ")}},t.writeRtcpFb=function(e){let t="",n=e.payloadType;return void 0!==e.preferredPayloadType&&(n=e.preferredPayloadType),e.rtcpFeedback&&e.rtcpFeedback.length&&e.rtcpFeedback.forEach((e=>{t+="a=rtcp-fb:"+n+" "+e.type+(e.parameter&&e.parameter.length?" "+e.parameter:"")+"\r\n"})),t},t.parseSsrcMedia=function(e){const t=e.indexOf(" "),n={ssrc:parseInt(e.substring(7,t),10)},r=e.indexOf(":",t);return r>-1?(n.attribute=e.substring(t+1,r),n.value=e.substring(r+1)):n.attribute=e.substring(t+1),n},t.parseSsrcGroup=function(e){const t=e.substring(13).split(" ");return{semantics:t.shift(),ssrcs:t.map((e=>parseInt(e,10)))}},t.getMid=function(e){const n=t.matchPrefix(e,"a=mid:")[0];if(n)return n.substring(6)},t.parseFingerprint=function(e){const t=e.substring(14).split(" ");return{algorithm:t[0].toLowerCase(),value:t[1].toUpperCase()}},t.getDtlsParameters=function(e,n){return{role:"auto",fingerprints:t.matchPrefix(e+n,"a=fingerprint:").map(t.parseFingerprint)}},t.writeDtlsParameters=function(e,t){let n="a=setup:"+t+"\r\n";return e.fingerprints.forEach((e=>{n+="a=fingerprint:"+e.algorithm+" "+e.value+"\r\n"})),n},t.parseCryptoLine=function(e){const t=e.substring(9).split(" ");return{tag:parseInt(t[0],10),cryptoSuite:t[1],keyParams:t[2],sessionParams:t.slice(3)}},t.writeCryptoLine=function(e){return"a=crypto:"+e.tag+" "+e.cryptoSuite+" "+("object"==typeof e.keyParams?t.writeCryptoKeyParams(e.keyParams):e.keyParams)+(e.sessionParams?" "+e.sessionParams.join(" "):"")+"\r\n"},t.parseCryptoKeyParams=function(e){if(0!==e.indexOf("inline:"))return null;const t=e.substring(7).split("|");return{keyMethod:"inline",keySalt:t[0],lifeTime:t[1],mkiValue:t[2]?t[2].split(":")[0]:void 0,mkiLength:t[2]?t[2].split(":")[1]:void 0}},t.writeCryptoKeyParams=function(e){return e.keyMethod+":"+e.keySalt+(e.lifeTime?"|"+e.lifeTime:"")+(e.mkiValue&&e.mkiLength?"|"+e.mkiValue+":"+e.mkiLength:"")},t.getCryptoParameters=function(e,n){return t.matchPrefix(e+n,"a=crypto:").map(t.parseCryptoLine)},t.getIceParameters=function(e,n){const r=t.matchPrefix(e+n,"a=ice-ufrag:")[0],i=t.matchPrefix(e+n,"a=ice-pwd:")[0];return r&&i?{usernameFragment:r.substring(12),password:i.substring(10)}:null},t.writeIceParameters=function(e){let t="a=ice-ufrag:"+e.usernameFragment+"\r\na=ice-pwd:"+e.password+"\r\n";return e.iceLite&&(t+="a=ice-lite\r\n"),t},t.parseRtpParameters=function(e){const n={codecs:[],headerExtensions:[],fecMechanisms:[],rtcp:[]},r=t.splitLines(e)[0].split(" ");n.profile=r[2];for(let o=3;o<r.length;o++){const i=r[o],a=t.matchPrefix(e,"a=rtpmap:"+i+" ")[0];if(a){const r=t.parseRtpMap(a),o=t.matchPrefix(e,"a=fmtp:"+i+" ");switch(r.parameters=o.length?t.parseFmtp(o[0]):{},r.rtcpFeedback=t.matchPrefix(e,"a=rtcp-fb:"+i+" ").map(t.parseRtcpFb),n.codecs.push(r),r.name.toUpperCase()){case"RED":case"ULPFEC":n.fecMechanisms.push(r.name.toUpperCase())}}}t.matchPrefix(e,"a=extmap:").forEach((e=>{n.headerExtensions.push(t.parseExtmap(e))}));const i=t.matchPrefix(e,"a=rtcp-fb:* ").map(t.parseRtcpFb);return n.codecs.forEach((e=>{i.forEach((t=>{e.rtcpFeedback.find((e=>e.type===t.type&&e.parameter===t.parameter))||e.rtcpFeedback.push(t)}))})),n},t.writeRtpDescription=function(e,n){let r="";r+="m="+e+" ",r+=n.codecs.length>0?"9":"0",r+=" "+(n.profile||"UDP/TLS/RTP/SAVPF")+" ",r+=n.codecs.map((e=>void 0!==e.preferredPayloadType?e.preferredPayloadType:e.payloadType)).join(" ")+"\r\n",r+="c=IN IP4 0.0.0.0\r\n",r+="a=rtcp:9 IN IP4 0.0.0.0\r\n",n.codecs.forEach((e=>{r+=t.writeRtpMap(e),r+=t.writeFmtp(e),r+=t.writeRtcpFb(e)}));let i=0;return n.codecs.forEach((e=>{e.maxptime>i&&(i=e.maxptime)})),i>0&&(r+="a=maxptime:"+i+"\r\n"),n.headerExtensions&&n.headerExtensions.forEach((e=>{r+=t.writeExtmap(e)})),r},t.parseRtpEncodingParameters=function(e){const n=[],r=t.parseRtpParameters(e),i=-1!==r.fecMechanisms.indexOf("RED"),o=-1!==r.fecMechanisms.indexOf("ULPFEC"),a=t.matchPrefix(e,"a=ssrc:").map((e=>t.parseSsrcMedia(e))).filter((e=>"cname"===e.attribute)),s=a.length>0&&a[0].ssrc;let c;const u=t.matchPrefix(e,"a=ssrc-group:FID").map((e=>e.substring(17).split(" ").map((e=>parseInt(e,10)))));u.length>0&&u[0].length>1&&u[0][0]===s&&(c=u[0][1]),r.codecs.forEach((e=>{if("RTX"===e.name.toUpperCase()&&e.parameters.apt){let t={ssrc:s,codecPayloadType:parseInt(e.parameters.apt,10)};s&&c&&(t.rtx={ssrc:c}),n.push(t),i&&(t=JSON.parse(JSON.stringify(t)),t.fec={ssrc:s,mechanism:o?"red+ulpfec":"red"},n.push(t))}})),0===n.length&&s&&n.push({ssrc:s});let l=t.matchPrefix(e,"b=");return l.length&&(l=0===l[0].indexOf("b=TIAS:")?parseInt(l[0].substring(7),10):0===l[0].indexOf("b=AS:")?1e3*parseInt(l[0].substring(5),10)*.95-16e3:void 0,n.forEach((e=>{e.maxBitrate=l}))),n},t.parseRtcpParameters=function(e){const n={},r=t.matchPrefix(e,"a=ssrc:").map((e=>t.parseSsrcMedia(e))).filter((e=>"cname"===e.attribute))[0];r&&(n.cname=r.value,n.ssrc=r.ssrc);const i=t.matchPrefix(e,"a=rtcp-rsize");n.reducedSize=i.length>0,n.compound=0===i.length;const o=t.matchPrefix(e,"a=rtcp-mux");return n.mux=o.length>0,n},t.writeRtcpParameters=function(e){let t="";return e.reducedSize&&(t+="a=rtcp-rsize\r\n"),e.mux&&(t+="a=rtcp-mux\r\n"),void 0!==e.ssrc&&e.cname&&(t+="a=ssrc:"+e.ssrc+" cname:"+e.cname+"\r\n"),t},t.parseMsid=function(e){let n;const r=t.matchPrefix(e,"a=msid:");if(1===r.length)return n=r[0].substring(7).split(" "),{stream:n[0],track:n[1]};const i=t.matchPrefix(e,"a=ssrc:").map((e=>t.parseSsrcMedia(e))).filter((e=>"msid"===e.attribute));return i.length>0?(n=i[0].value.split(" "),{stream:n[0],track:n[1]}):void 0},t.parseSctpDescription=function(e){const n=t.parseMLine(e),r=t.matchPrefix(e,"a=max-message-size:");let i;r.length>0&&(i=parseInt(r[0].substring(19),10)),isNaN(i)&&(i=65536);const o=t.matchPrefix(e,"a=sctp-port:");if(o.length>0)return{port:parseInt(o[0].substring(12),10),protocol:n.fmt,maxMessageSize:i};const a=t.matchPrefix(e,"a=sctpmap:");if(a.length>0){const e=a[0].substring(10).split(" ");return{port:parseInt(e[0],10),protocol:e[1],maxMessageSize:i}}},t.writeSctpDescription=function(e,t){let n=[];return n="DTLS/SCTP"!==e.protocol?["m="+e.kind+" 9 "+e.protocol+" "+t.protocol+"\r\n","c=IN IP4 0.0.0.0\r\n","a=sctp-port:"+t.port+"\r\n"]:["m="+e.kind+" 9 "+e.protocol+" "+t.port+"\r\n","c=IN IP4 0.0.0.0\r\n","a=sctpmap:"+t.port+" "+t.protocol+" 65535\r\n"],void 0!==t.maxMessageSize&&n.push("a=max-message-size:"+t.maxMessageSize+"\r\n"),n.join("")},t.generateSessionId=function(){return Math.random().toString().substr(2,22)},t.writeSessionBoilerplate=function(e,n,r){let i;const o=void 0!==n?n:2;i=e||t.generateSessionId();return"v=0\r\no="+(r||"thisisadapterortc")+" "+i+" "+o+" IN IP4 127.0.0.1\r\ns=-\r\nt=0 0\r\n"},t.getDirection=function(e,n){const r=t.splitLines(e);for(let t=0;t<r.length;t++)switch(r[t]){case"a=sendrecv":case"a=sendonly":case"a=recvonly":case"a=inactive":return r[t].substring(2)}return n?t.getDirection(n):"sendrecv"},t.getKind=function(e){return t.splitLines(e)[0].split(" ")[0].substring(2)},t.isRejected=function(e){return"0"===e.split(" ",2)[1]},t.parseMLine=function(e){const n=t.splitLines(e)[0].substring(2).split(" ");return{kind:n[0],port:parseInt(n[1],10),protocol:n[2],fmt:n.slice(3).join(" ")}},t.parseOLine=function(e){const n=t.matchPrefix(e,"o=")[0].substring(2).split(" ");return{username:n[0],sessionId:n[1],sessionVersion:parseInt(n[2],10),netType:n[3],addressType:n[4],address:n[5]}},t.isValidSDP=function(e){if("string"!=typeof e||0===e.length)return!1;const n=t.splitLines(e);for(let t=0;t<n.length;t++)if(n[t].length<2||"="!==n[t].charAt(1))return!1;return!0},e.exports=t}(aF);var sF=oF,cF=e({__proto__:null,default:sF},[oF]);function uF(e){if(!e.RTCIceCandidate||e.RTCIceCandidate&&"foundation"in e.RTCIceCandidate.prototype)return;const t=e.RTCIceCandidate;e.RTCIceCandidate=function(e){if("object"==typeof e&&e.candidate&&0===e.candidate.indexOf("a=")&&((e=JSON.parse(JSON.stringify(e))).candidate=e.candidate.substring(2)),e.candidate&&e.candidate.length){const n=new t(e),r=sF.parseCandidate(e.candidate);for(const e in r)e in n||Object.defineProperty(n,e,{value:r[e]});return n.toJSON=function(){return{candidate:n.candidate,sdpMid:n.sdpMid,sdpMLineIndex:n.sdpMLineIndex,usernameFragment:n.usernameFragment}},n}return new t(e)},e.RTCIceCandidate.prototype=t.prototype,vU(e,"icecandidate",(t=>(t.candidate&&Object.defineProperty(t,"candidate",{value:new e.RTCIceCandidate(t.candidate),writable:"false"}),t)))}function lF(e){!e.RTCIceCandidate||e.RTCIceCandidate&&"relayProtocol"in e.RTCIceCandidate.prototype||vU(e,"icecandidate",(e=>{if(e.candidate){const t=sF.parseCandidate(e.candidate.candidate);"relay"===t.type&&(e.candidate.relayProtocol={0:"tls",1:"tcp",2:"udp"}[t.priority>>24])}return e}))}function dF(e,t){if(!e.RTCPeerConnection)return;"sctp"in e.RTCPeerConnection.prototype||Object.defineProperty(e.RTCPeerConnection.prototype,"sctp",{get(){return void 0===this._sctp?null:this._sctp}});const n=e.RTCPeerConnection.prototype.setRemoteDescription;e.RTCPeerConnection.prototype.setRemoteDescription=function(){if(this._sctp=null,"chrome"===t.browser&&t.version>=76){const{sdpSemantics:e}=this.getConfiguration();"plan-b"===e&&Object.defineProperty(this,"sctp",{get(){return void 0===this._sctp?null:this._sctp},enumerable:!0,configurable:!0})}if(function(e){if(!e||!e.sdp)return!1;const t=sF.splitSections(e.sdp);return t.shift(),t.some((e=>{const t=sF.parseMLine(e);return t&&"application"===t.kind&&-1!==t.protocol.indexOf("SCTP")}))}(arguments[0])){const e=function(e){const t=e.sdp.match(/mozilla...THIS_IS_SDPARTA-(\d+)/);if(null===t||t.length<2)return-1;const n=parseInt(t[1],10);return n!=n?-1:n}(arguments[0]),n=function(e){let n=65536;return"firefox"===t.browser&&(n=t.version<57?-1===e?16384:2147483637:t.version<60?57===t.version?65535:65536:2147483637),n}(e),r=function(e,n){let r=65536;"firefox"===t.browser&&57===t.version&&(r=65535);const i=sF.matchPrefix(e.sdp,"a=max-message-size:");return i.length>0?r=parseInt(i[0].substring(19),10):"firefox"===t.browser&&-1!==n&&(r=2147483637),r}(arguments[0],e);let i;i=0===n&&0===r?Number.POSITIVE_INFINITY:0===n||0===r?Math.max(n,r):Math.min(n,r);const o={};Object.defineProperty(o,"maxMessageSize",{get:()=>i}),this._sctp=o}return n.apply(this,arguments)}}function hF(e){if(!e.RTCPeerConnection||!("createDataChannel"in e.RTCPeerConnection.prototype))return;function t(e,t){const n=e.send;e.send=function(){const r=arguments[0],i=r.length||r.size||r.byteLength;if("open"===e.readyState&&t.sctp&&i>t.sctp.maxMessageSize)throw new TypeError("Message too large (can send a maximum of "+t.sctp.maxMessageSize+" bytes)");return n.apply(e,arguments)}}const n=e.RTCPeerConnection.prototype.createDataChannel;e.RTCPeerConnection.prototype.createDataChannel=function(){const e=n.apply(this,arguments);return t(e,this),e},vU(e,"datachannel",(e=>(t(e.channel,e.target),e)))}function fF(e){if(!e.RTCPeerConnection||"connectionState"in e.RTCPeerConnection.prototype)return;const t=e.RTCPeerConnection.prototype;Object.defineProperty(t,"connectionState",{get(){return{completed:"connected",checking:"connecting"}[this.iceConnectionState]||this.iceConnectionState},enumerable:!0,configurable:!0}),Object.defineProperty(t,"onconnectionstatechange",{get(){return this._onconnectionstatechange||null},set(e){this._onconnectionstatechange&&(this.removeEventListener("connectionstatechange",this._onconnectionstatechange),delete this._onconnectionstatechange),e&&this.addEventListener("connectionstatechange",this._onconnectionstatechange=e)},enumerable:!0,configurable:!0}),["setLocalDescription","setRemoteDescription"].forEach((e=>{const n=t[e];t[e]=function(){return this._connectionstatechangepoly||(this._connectionstatechangepoly=e=>{const t=e.target;if(t._lastConnectionState!==t.connectionState){t._lastConnectionState=t.connectionState;const n=new Event("connectionstatechange",e);t.dispatchEvent(n)}return e},this.addEventListener("iceconnectionstatechange",this._connectionstatechangepoly)),n.apply(this,arguments)}}))}function pF(e,t){if(!e.RTCPeerConnection)return;if("chrome"===t.browser&&t.version>=71)return;if("safari"===t.browser&&t.version>=605)return;const n=e.RTCPeerConnection.prototype.setRemoteDescription;e.RTCPeerConnection.prototype.setRemoteDescription=function(t){if(t&&t.sdp&&-1!==t.sdp.indexOf("\na=extmap-allow-mixed")){const n=t.sdp.split("\n").filter((e=>"a=extmap-allow-mixed"!==e.trim())).join("\n");e.RTCSessionDescription&&t instanceof e.RTCSessionDescription?arguments[0]=new e.RTCSessionDescription({type:t.type,sdp:n}):t.sdp=n}return n.apply(this,arguments)}}function mF(e,t){if(!e.RTCPeerConnection||!e.RTCPeerConnection.prototype)return;const n=e.RTCPeerConnection.prototype.addIceCandidate;n&&0!==n.length&&(e.RTCPeerConnection.prototype.addIceCandidate=function(){return arguments[0]?("chrome"===t.browser&&t.version<78||"firefox"===t.browser&&t.version<68||"safari"===t.browser)&&arguments[0]&&""===arguments[0].candidate?Promise.resolve():n.apply(this,arguments):(arguments[1]&&arguments[1].apply(null),Promise.resolve())})}function vF(e,t){if(!e.RTCPeerConnection||!e.RTCPeerConnection.prototype)return;const n=e.RTCPeerConnection.prototype.setLocalDescription;n&&0!==n.length&&(e.RTCPeerConnection.prototype.setLocalDescription=function(){let e=arguments[0]||{};if("object"!=typeof e||e.type&&e.sdp)return n.apply(this,arguments);if(e={type:e.type,sdp:e.sdp},!e.type)switch(this.signalingState){case"stable":case"have-local-offer":case"have-remote-pranswer":e.type="offer";break;default:e.type="answer"}if(e.sdp||"offer"!==e.type&&"answer"!==e.type)return n.apply(this,[e]);return("offer"===e.type?this.createOffer:this.createAnswer).apply(this).then((e=>n.apply(this,[e])))})}var _F=Object.freeze({__proto__:null,shimRTCIceCandidate:uF,shimRTCIceCandidateRelayProtocol:lF,shimMaxMessageSize:dF,shimSendThrowTypeError:hF,shimConnectionState:fF,removeExtmapAllowMixed:pF,shimAddIceCandidateNullOrEmpty:mF,shimParameterlessSetLocalDescription:vF});!function({window:e}={},t={shimChrome:!0,shimFirefox:!0,shimSafari:!0}){const n=yU,r=function(e){const t={browser:null,version:null};if(void 0===e||!e.navigator||!e.navigator.userAgent)return t.browser="Not a browser.",t;const{navigator:n}=e;if(n.mozGetUserMedia)t.browser="firefox",t.version=mU(n.userAgent,/Firefox\/(\d+)\./,1);else if(n.webkitGetUserMedia||!1===e.isSecureContext&&e.webkitRTCPeerConnection)t.browser="chrome",t.version=mU(n.userAgent,/Chrom(e|ium)\/(\d+)\./,2);else{if(!e.RTCPeerConnection||!n.userAgent.match(/AppleWebKit\/(\d+)\./))return t.browser="Not a supported browser.",t;t.browser="safari",t.version=mU(n.userAgent,/AppleWebKit\/(\d+)\./,1),t.supportsUnifiedPlan=e.RTCRtpTransceiver&&"currentDirection"in e.RTCRtpTransceiver.prototype}return t}(e),i={browserDetails:r,commonShim:_F,extractVersion:mU,disableLog:_U,disableWarnings:gU,sdp:cF};switch(r.browser){case"chrome":if(!LU||!PU||!t.shimChrome)return n("Chrome shim is not included in this adapter release."),i;if(null===r.version)return n("Chrome shim can not determine version, not shimming."),i;n("adapter.js shimming chrome."),i.browserShim=LU,mF(e,r),vF(e),AU(e,r),RU(e),PU(e,r),CU(e),OU(e,r),wU(e),DU(e),NU(e),MU(e,r),uF(e),lF(e),fF(e),dF(e,r),hF(e),pF(e,r);break;case"firefox":if(!qU||!FU||!t.shimFirefox)return n("Firefox shim is not included in this adapter release."),i;n("adapter.js shimming firefox."),i.browserShim=qU,mF(e,r),vF(e),VU(e,r),FU(e,r),UU(e),jU(e),BU(e),HU(e),GU(e),WU(e),JU(e),KU(e),zU(e),uF(e),fF(e),dF(e,r),hF(e);break;case"safari":if(!iF||!t.shimSafari)return n("Safari shim is not included in this adapter release."),i;n("adapter.js shimming safari."),i.browserShim=iF,mF(e,r),vF(e),eF(e),nF(e),QU(e),YU(e),XU(e),tF(e),$U(e),rF(e),uF(e),lF(e),dF(e,r),hF(e),pF(e,r);break;default:n("Unsupported browser!")}}({window:"undefined"==typeof window?void 0:window});var gF,yF=Object.create,EF=Object.defineProperty,TF=Object.defineProperties,kF=Object.getOwnPropertyDescriptor,SF=Object.getOwnPropertyDescriptors,IF=Object.getOwnPropertyNames,bF=Object.getOwnPropertySymbols,AF=Object.getPrototypeOf,RF=Object.prototype.hasOwnProperty,CF=Object.prototype.propertyIsEnumerable,wF=Reflect.get,DF=Math.pow,NF=function(e,t,n){return t in e?EF(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n},xF=function(e,t){for(var n in t||(t={}))RF.call(t,n)&&NF(e,n,t[n]);if(bF){var r,i=c(bF(t));try{for(i.s();!(r=i.n()).done;){n=r.value;CF.call(t,n)&&NF(e,n,t[n])}}catch(o){i.e(o)}finally{i.f()}}return e},OF=function(e,t){return TF(e,SF(t))},PF=function(e,t){var n={};for(var r in e)RF.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&bF){var i,o=c(bF(e));try{for(o.s();!(i=o.n()).done;){r=i.value;t.indexOf(r)<0&&CF.call(e,r)&&(n[r]=e[r])}}catch(a){o.e(a)}finally{o.f()}}return n},MF=function(e,t){return function(){return t||e((t={exports:{}}).exports,t),t.exports}},LF=function(e,t){for(var n in t)EF(e,n,{get:t[n],enumerable:!0})},VF=function(e,t,n){return n=null!=e?yF(AF(e)):{},function(e,t,n,r){if(t&&"object"==S(t)||"function"==typeof t){var i,o=c(IF(t));try{var a=function(){var o=i.value;!RF.call(e,o)&&o!==n&&EF(e,o,{get:function(){return t[o]},enumerable:!(r=kF(t,o))||r.enumerable})};for(o.s();!(i=o.n()).done;)a()}catch(s){o.e(s)}finally{o.f()}}return e}(!t&&e&&e.__esModule?n:EF(n,"default",{value:e,enumerable:!0}),e)},UF=function(e,t,n,r){for(var i,o=r>1?void 0:r?kF(t,n):t,a=e.length-1;a>=0;a--)(i=e[a])&&(o=(r?i(t,n,o):i(o))||o);return r&&o&&EF(t,n,o),o},FF=function(e,t,n){return NF(e,"symbol"!=S(t)?t+"":t,n)},BF=function(e,t,n){return wF(AF(e),n,t)},HF=function(e,t,n){return new Promise((function(r,i){var o=function(e){try{s(n.next(e))}catch(tJ){i(tJ)}},a=function(e){try{s(n.throw(e))}catch(tJ){i(tJ)}},s=function(e){return e.done?r(e.value):Promise.resolve(e.value).then(o,a)};s((n=n.apply(e,t)).next())}))},jF=MF((function(e,t){var n=Object.prototype.hasOwnProperty,r="~";function i(){}function o(e,t,n){this.fn=e,this.context=t,this.once=n||!1}function a(e,t,n,i,a){if("function"!=typeof n)throw new TypeError("The listener must be a function");var s=new o(n,i||e,a),c=r?r+t:t;return e._events[c]?e._events[c].fn?e._events[c]=[e._events[c],s]:e._events[c].push(s):(e._events[c]=s,e._eventsCount++),e}function s(e,t){0==--e._eventsCount?e._events=new i:delete e._events[t]}function c(){this._events=new i,this._eventsCount=0}Object.create&&(i.prototype=Object.create(null),(new i).__proto__||(r=!1)),c.prototype.eventNames=function(){var e,t,i=[];if(0===this._eventsCount)return i;for(t in e=this._events)n.call(e,t)&&i.push(r?t.slice(1):t);return Object.getOwnPropertySymbols?i.concat(Object.getOwnPropertySymbols(e)):i},c.prototype.listeners=function(e){var t=r?r+e:e,n=this._events[t];if(!n)return[];if(n.fn)return[n.fn];for(var i=0,o=n.length,a=new Array(o);i<o;i++)a[i]=n[i].fn;return a},c.prototype.listenerCount=function(e){var t=r?r+e:e,n=this._events[t];return n?n.fn?1:n.length:0},c.prototype.emit=function(e,t,n,i,o,a){var s=r?r+e:e;if(!this._events[s])return!1;var c,u,l=this._events[s],d=arguments.length;if(l.fn){switch(l.once&&this.removeListener(e,l.fn,void 0,!0),d){case 1:return l.fn.call(l.context),!0;case 2:return l.fn.call(l.context,t),!0;case 3:return l.fn.call(l.context,t,n),!0;case 4:return l.fn.call(l.context,t,n,i),!0;case 5:return l.fn.call(l.context,t,n,i,o),!0;case 6:return l.fn.call(l.context,t,n,i,o,a),!0}for(u=1,c=new Array(d-1);u<d;u++)c[u-1]=arguments[u];l.fn.apply(l.context,c)}else{var h,f=l.length;for(u=0;u<f;u++)switch(l[u].once&&this.removeListener(e,l[u].fn,void 0,!0),d){case 1:l[u].fn.call(l[u].context);break;case 2:l[u].fn.call(l[u].context,t);break;case 3:l[u].fn.call(l[u].context,t,n);break;case 4:l[u].fn.call(l[u].context,t,n,i);break;default:if(!c)for(h=1,c=new Array(d-1);h<d;h++)c[h-1]=arguments[h];l[u].fn.apply(l[u].context,c)}}return!0},c.prototype.on=function(e,t,n){return a(this,e,t,n,!1)},c.prototype.once=function(e,t,n){return a(this,e,t,n,!0)},c.prototype.removeListener=function(e,t,n,i){var o=r?r+e:e;if(!this._events[o])return this;if(!t)return s(this,o),this;var a=this._events[o];if(a.fn)a.fn===t&&(!i||a.once)&&(!n||a.context===n)&&s(this,o);else{for(var c=0,u=[],l=a.length;c<l;c++)(a[c].fn!==t||i&&!a[c].once||n&&a[c].context!==n)&&u.push(a[c]);u.length?this._events[o]=1===u.length?u[0]:u:s(this,o)}return this},c.prototype.removeAllListeners=function(e){var t;return e?(t=r?r+e:e,this._events[t]&&s(this,t)):(this._events=new i,this._eventsCount=0),this},c.prototype.off=c.prototype.removeListener,c.prototype.addListener=c.prototype.on,c.prefixed=r,c.EventEmitter=c,void 0!==t&&(t.exports=c)})),GF=MF((function(e,t){var n=t.exports={v:[{name:"version",reg:/^(\d*)$/}],o:[{name:"origin",reg:/^(\S*) (\d*) (\d*) (\S*) IP(\d) (\S*)/,names:["username","sessionId","sessionVersion","netType","ipVer","address"],format:"%s %s %d %s IP%d %s"}],s:[{name:"name"}],i:[{name:"description"}],u:[{name:"uri"}],e:[{name:"email"}],p:[{name:"phone"}],z:[{name:"timezones"}],r:[{name:"repeats"}],t:[{name:"timing",reg:/^(\d*) (\d*)/,names:["start","stop"],format:"%d %d"}],c:[{name:"connection",reg:/^IN IP(\d) (\S*)/,names:["version","ip"],format:"IN IP%d %s"}],b:[{push:"bandwidth",reg:/^(TIAS|AS|CT|RR|RS):(\d*)/,names:["type","limit"],format:"%s:%s"}],m:[{reg:/^(\w*) (\d*) ([\w/]*)(?: (.*))?/,names:["type","port","protocol","payloads"],format:"%s %d %s %s"}],a:[{push:"rtp",reg:/^rtpmap:(\d*) ([\w\-.]*)(?:\s*\/(\d*)(?:\s*\/(\S*))?)?/,names:["payload","codec","rate","encoding"],format:function(e){return e.encoding?"rtpmap:%d %s/%s/%s":e.rate?"rtpmap:%d %s/%s":"rtpmap:%d %s"}},{push:"fmtp",reg:/^fmtp:(\d*) ([\S| ]*)/,names:["payload","config"],format:"fmtp:%d %s"},{name:"control",reg:/^control:(.*)/,format:"control:%s"},{name:"rtcp",reg:/^rtcp:(\d*)(?: (\S*) IP(\d) (\S*))?/,names:["port","netType","ipVer","address"],format:function(e){return null!=e.address?"rtcp:%d %s IP%d %s":"rtcp:%d"}},{push:"rtcpFbTrrInt",reg:/^rtcp-fb:(\*|\d*) trr-int (\d*)/,names:["payload","value"],format:"rtcp-fb:%s trr-int %d"},{push:"rtcpFb",reg:/^rtcp-fb:(\*|\d*) ([\w-_]*)(?: ([\w-_]*))?/,names:["payload","type","subtype"],format:function(e){return null!=e.subtype?"rtcp-fb:%s %s %s":"rtcp-fb:%s %s"}},{push:"ext",reg:/^extmap:(\d+)(?:\/(\w+))?(?: (urn:ietf:params:rtp-hdrext:encrypt))? (\S*)(?: (\S*))?/,names:["value","direction","encrypt-uri","uri","config"],format:function(e){return"extmap:%d"+(e.direction?"/%s":"%v")+(e["encrypt-uri"]?" %s":"%v")+" %s"+(e.config?" %s":"")}},{name:"extmapAllowMixed",reg:/^(extmap-allow-mixed)/},{push:"crypto",reg:/^crypto:(\d*) ([\w_]*) (\S*)(?: (\S*))?/,names:["id","suite","config","sessionConfig"],format:function(e){return null!=e.sessionConfig?"crypto:%d %s %s %s":"crypto:%d %s %s"}},{name:"setup",reg:/^setup:(\w*)/,format:"setup:%s"},{name:"connectionType",reg:/^connection:(new|existing)/,format:"connection:%s"},{name:"mid",reg:/^mid:([^\s]*)/,format:"mid:%s"},{name:"msid",reg:/^msid:(.*)/,format:"msid:%s"},{name:"ptime",reg:/^ptime:(\d*(?:\.\d*)*)/,format:"ptime:%d"},{name:"maxptime",reg:/^maxptime:(\d*(?:\.\d*)*)/,format:"maxptime:%d"},{name:"direction",reg:/^(sendrecv|recvonly|sendonly|inactive)/},{name:"icelite",reg:/^(ice-lite)/},{name:"iceUfrag",reg:/^ice-ufrag:(\S*)/,format:"ice-ufrag:%s"},{name:"icePwd",reg:/^ice-pwd:(\S*)/,format:"ice-pwd:%s"},{name:"fingerprint",reg:/^fingerprint:(\S*) (\S*)/,names:["type","hash"],format:"fingerprint:%s %s"},{push:"candidates",reg:/^candidate:(\S*) (\d*) (\S*) (\d*) (\S*) (\d*) typ (\S*)(?: raddr (\S*) rport (\d*))?(?: tcptype (\S*))?(?: generation (\d*))?(?: network-id (\d*))?(?: network-cost (\d*))?/,names:["foundation","component","transport","priority","ip","port","type","raddr","rport","tcptype","generation","network-id","network-cost"],format:function(e){var t="candidate:%s %d %s %d %s %d typ %s";return t+=null!=e.raddr?" raddr %s rport %d":"%v%v",t+=null!=e.tcptype?" tcptype %s":"%v",null!=e.generation&&(t+=" generation %d"),t+=null!=e["network-id"]?" network-id %d":"%v",t+=null!=e["network-cost"]?" network-cost %d":"%v"}},{name:"endOfCandidates",reg:/^(end-of-candidates)/},{name:"remoteCandidates",reg:/^remote-candidates:(.*)/,format:"remote-candidates:%s"},{name:"iceOptions",reg:/^ice-options:(\S*)/,format:"ice-options:%s"},{push:"ssrcs",reg:/^ssrc:(\d*) ([\w_-]*)(?::(.*))?/,names:["id","attribute","value"],format:function(e){var t="ssrc:%d";return null!=e.attribute&&(t+=" %s",null!=e.value&&(t+=":%s")),t}},{push:"ssrcGroups",reg:/^ssrc-group:([\x21\x23\x24\x25\x26\x27\x2A\x2B\x2D\x2E\w]*) (.*)/,names:["semantics","ssrcs"],format:"ssrc-group:%s %s"},{name:"msidSemantic",reg:/^msid-semantic:\s?(\w*) (\S*)/,names:["semantic","token"],format:"msid-semantic: %s %s"},{push:"groups",reg:/^group:(\w*) (.*)/,names:["type","mids"],format:"group:%s %s"},{name:"rtcpMux",reg:/^(rtcp-mux)/},{name:"rtcpRsize",reg:/^(rtcp-rsize)/},{name:"sctpmap",reg:/^sctpmap:([\w_/]*) (\S*)(?: (\S*))?/,names:["sctpmapNumber","app","maxMessageSize"],format:function(e){return null!=e.maxMessageSize?"sctpmap:%s %s %s":"sctpmap:%s %s"}},{name:"xGoogleFlag",reg:/^x-google-flag:([^\s]*)/,format:"x-google-flag:%s"},{push:"rids",reg:/^rid:([\d\w]+) (\w+)(?: ([\S| ]*))?/,names:["id","direction","params"],format:function(e){return e.params?"rid:%s %s %s":"rid:%s %s"}},{push:"imageattrs",reg:new RegExp("^imageattr:(\\d+|\\*)[\\s\\t]+(send|recv)[\\s\\t]+(\\*|\\[\\S+\\](?:[\\s\\t]+\\[\\S+\\])*)(?:[\\s\\t]+(recv|send)[\\s\\t]+(\\*|\\[\\S+\\](?:[\\s\\t]+\\[\\S+\\])*))?"),names:["pt","dir1","attrs1","dir2","attrs2"],format:function(e){return"imageattr:%s %s %s"+(e.dir2?" %s %s":"")}},{name:"simulcast",reg:new RegExp("^simulcast:(send|recv) ([a-zA-Z0-9\\-_~;,]+)(?:\\s?(send|recv) ([a-zA-Z0-9\\-_~;,]+))?$"),names:["dir1","list1","dir2","list2"],format:function(e){return"simulcast:%s %s"+(e.dir2?" %s %s":"")}},{name:"simulcast_03",reg:/^simulcast:[\s\t]+([\S+\s\t]+)$/,names:["value"],format:"simulcast: %s"},{name:"framerate",reg:/^framerate:(\d+(?:$|\.\d+))/,format:"framerate:%s"},{name:"sourceFilter",reg:/^source-filter: *(excl|incl) (\S*) (IP4|IP6|\*) (\S*) (.*)/,names:["filterMode","netType","addressTypes","destAddress","srcList"],format:"source-filter: %s %s %s %s %s"},{name:"bundleOnly",reg:/^(bundle-only)/},{name:"label",reg:/^label:(.+)/,format:"label:%s"},{name:"sctpPort",reg:/^sctp-port:(\d+)$/,format:"sctp-port:%s"},{name:"maxMessageSize",reg:/^max-message-size:(\d+)$/,format:"max-message-size:%s"},{push:"tsRefClocks",reg:/^ts-refclk:([^\s=]*)(?:=(\S*))?/,names:["clksrc","clksrcExt"],format:function(e){return"ts-refclk:%s"+(null!=e.clksrcExt?"=%s":"")}},{name:"mediaClk",reg:/^mediaclk:(?:id=(\S*))? *([^\s=]*)(?:=(\S*))?(?: *rate=(\d+)\/(\d+))?/,names:["id","mediaClockName","mediaClockValue","rateNumerator","rateDenominator"],format:function(e){var t="mediaclk:";return t+=null!=e.id?"id=%s %s":"%v%s",t+=null!=e.mediaClockValue?"=%s":"",t+=null!=e.rateNumerator?" rate=%s":"",t+=null!=e.rateDenominator?"/%s":""}},{name:"keywords",reg:/^keywds:(.+)$/,format:"keywds:%s"},{name:"content",reg:/^content:(.+)/,format:"content:%s"},{name:"bfcpFloorCtrl",reg:/^floorctrl:(c-only|s-only|c-s)/,format:"floorctrl:%s"},{name:"bfcpConfId",reg:/^confid:(\d+)/,format:"confid:%s"},{name:"bfcpUserId",reg:/^userid:(\d+)/,format:"userid:%s"},{name:"bfcpFloorId",reg:/^floorid:(.+) (?:m-stream|mstrm):(.+)/,names:["id","mStream"],format:"floorid:%s mstrm:%s"},{push:"invalid",names:["value"]}]};Object.keys(n).forEach((function(e){n[e].forEach((function(e){e.reg||(e.reg=/(.*)/),e.format||(e.format="%s")}))}))})),WF=MF((function(e){var t=function(e){return String(Number(e))===e?Number(e):e},n=function(e,n,r){var i=e.name&&e.names;e.push&&!n[e.push]?n[e.push]=[]:i&&!n[e.name]&&(n[e.name]={});var o=e.push?{}:i?n[e.name]:n;(function(e,n,r,i){if(i&&!r)n[i]=t(e[1]);else for(var o=0;o<r.length;o+=1)null!=e[o+1]&&(n[r[o]]=t(e[o+1]))})(r.match(e.reg),o,e.names,e.name),e.push&&n[e.push].push(o)},r=GF(),i=RegExp.prototype.test.bind(/^([a-z])=(.*)/);e.parse=function(e){var t={},o=[],a=t;return e.split(/(\r\n|\r|\n)/).filter(i).forEach((function(e){var t=e[0],i=e.slice(2);"m"===t&&(o.push({rtp:[],fmtp:[]}),a=o[o.length-1]);for(var s=0;s<(r[t]||[]).length;s+=1){var c=r[t][s];if(c.reg.test(i))return n(c,a,i)}})),t.media=o,t};var o=function(e,n){var r=n.split(/=(.+)/,2);return 2===r.length?e[r[0]]=t(r[1]):1===r.length&&n.length>1&&(e[r[0]]=void 0),e};e.parseParams=function(e){return e.split(/;\s?/).reduce(o,{})},e.parseFmtpConfig=e.parseParams,e.parsePayloads=function(e){return e.toString().split(" ").map(Number)},e.parseRemoteCandidates=function(e){for(var n=[],r=e.split(" ").map(t),i=0;i<r.length;i+=3)n.push({component:r[i],ip:r[i+1],port:r[i+2]});return n},e.parseImageAttributes=function(e){return e.split(" ").map((function(e){return e.substring(1,e.length-1).split(",").reduce(o,{})}))},e.parseSimulcastStreamList=function(e){return e.split(";").map((function(e){return e.split(",").map((function(e){var n,r=!1;return"~"!==e[0]?n=t(e):(n=t(e.substring(1,e.length)),r=!0),{scid:n,paused:r}}))}))}})),JF=MF((function(e,t){var n=GF(),r=/%[sdv%]/g,i=function(e){var t=1,n=arguments,i=n.length;return e.replace(r,(function(e){if(t>=i)return e;var r=n[t];switch(t+=1,e){case"%%":return"%";case"%s":return String(r);case"%d":return Number(r);case"%v":return""}}))},o=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 o=0;o<t.names.length;o+=1){var a=t.names[o];t.name?r.push(n[t.name][a]):r.push(n[t.names[o]])}else r.push(n[t.name]);return i.apply(null,r)},a=["v","o","s","i","u","e","p","c","b","t","r","z","a"],s=["i","c","b","a"];t.exports=function(e,t){t=t||{},null==e.version&&(e.version=0),null==e.name&&(e.name=" "),e.media.forEach((function(e){null==e.payloads&&(e.payloads="")}));var r=t.outerOrder||a,i=t.innerOrder||s,c=[];return r.forEach((function(t){n[t].forEach((function(n){n.name in e&&null!=e[n.name]?c.push(o(t,n,e)):n.push in e&&null!=e[n.push]&&e[n.push].forEach((function(e){c.push(o(t,n,e))}))}))})),e.media.forEach((function(e){c.push(o("m",n.m[0],e)),i.forEach((function(t){n[t].forEach((function(n){n.name in e&&null!=e[n.name]?c.push(o(t,n,e)):n.push in e&&null!=e[n.push]&&e[n.push].forEach((function(e){c.push(o(t,n,e))}))}))}))})),c.join("\r\n")+"\r\n"}})),KF=MF((function(e){var t=WF(),n=JF();e.write=n,e.parse=t.parse,e.parseParams=t.parseParams,e.parseFmtpConfig=t.parseFmtpConfig,e.parsePayloads=t.parsePayloads,e.parseRemoteCandidates=t.parseRemoteCandidates,e.parseImageAttributes=t.parseImageAttributes,e.parseSimulcastStreamList=t.parseSimulcastStreamList})),zF=MF((function(e,t){var n=t.exports={v:[{name:"version",reg:/^(\d*)$/}],o:[{name:"origin",reg:/^(\S*) (\d*) (\d*) (\S*) IP(\d) (\S*)/,names:["username","sessionId","sessionVersion","netType","ipVer","address"],format:"%s %s %d %s IP%d %s"}],s:[{name:"name"}],i:[{name:"description"}],u:[{name:"uri"}],e:[{name:"email"}],p:[{name:"phone"}],z:[{name:"timezones"}],r:[{name:"repeats"}],t:[{name:"timing",reg:/^(\d*) (\d*)/,names:["start","stop"],format:"%d %d"}],c:[{name:"connection",reg:/^IN IP(\d) (\S*)/,names:["version","ip"],format:"IN IP%d %s"}],b:[{push:"bandwidth",reg:/^(TIAS|AS|CT|RR|RS):(\d*)/,names:["type","limit"],format:"%s:%s"}],m:[{reg:/^(\w*) (\d*) ([\w/]*)(?: (.*))?/,names:["type","port","protocol","payloads"],format:"%s %d %s %s"}],a:[{push:"rtp",reg:/^rtpmap:(\d*) ([\w\-.]*)(?:\s*\/(\d*)(?:\s*\/(\S*))?)?/,names:["payload","codec","rate","encoding"],format:function(e){return e.encoding?"rtpmap:%d %s/%s/%s":e.rate?"rtpmap:%d %s/%s":"rtpmap:%d %s"}},{push:"fmtp",reg:/^fmtp:(\d*) ([\S| ]*)/,names:["payload","config"],format:"fmtp:%d %s"},{name:"control",reg:/^control:(.*)/,format:"control:%s"},{name:"rtcp",reg:/^rtcp:(\d*)(?: (\S*) IP(\d) (\S*))?/,names:["port","netType","ipVer","address"],format:function(e){return null!=e.address?"rtcp:%d %s IP%d %s":"rtcp:%d"}},{push:"rtcpFbTrrInt",reg:/^rtcp-fb:(\*|\d*) trr-int (\d*)/,names:["payload","value"],format:"rtcp-fb:%s trr-int %d"},{push:"rtcpFb",reg:/^rtcp-fb:(\*|\d*) ([\w-_]*)(?: ([\w-_]*))?/,names:["payload","type","subtype"],format:function(e){return null!=e.subtype?"rtcp-fb:%s %s %s":"rtcp-fb:%s %s"}},{push:"ext",reg:/^extmap:(\d+)(?:\/(\w+))?(?: (urn:ietf:params:rtp-hdrext:encrypt))? (\S*)(?: (\S*))?/,names:["value","direction","encrypt-uri","uri","config"],format:function(e){return"extmap:%d"+(e.direction?"/%s":"%v")+(e["encrypt-uri"]?" %s":"%v")+" %s"+(e.config?" %s":"")}},{name:"extmapAllowMixed",reg:/^(extmap-allow-mixed)/},{push:"crypto",reg:/^crypto:(\d*) ([\w_]*) (\S*)(?: (\S*))?/,names:["id","suite","config","sessionConfig"],format:function(e){return null!=e.sessionConfig?"crypto:%d %s %s %s":"crypto:%d %s %s"}},{name:"setup",reg:/^setup:(\w*)/,format:"setup:%s"},{name:"connectionType",reg:/^connection:(new|existing)/,format:"connection:%s"},{name:"mid",reg:/^mid:([^\s]*)/,format:"mid:%s"},{name:"msid",reg:/^msid:(.*)/,format:"msid:%s"},{name:"ptime",reg:/^ptime:(\d*(?:\.\d*)*)/,format:"ptime:%d"},{name:"maxptime",reg:/^maxptime:(\d*(?:\.\d*)*)/,format:"maxptime:%d"},{name:"direction",reg:/^(sendrecv|recvonly|sendonly|inactive)/},{name:"icelite",reg:/^(ice-lite)/},{name:"iceUfrag",reg:/^ice-ufrag:(\S*)/,format:"ice-ufrag:%s"},{name:"icePwd",reg:/^ice-pwd:(\S*)/,format:"ice-pwd:%s"},{name:"fingerprint",reg:/^fingerprint:(\S*) (\S*)/,names:["type","hash"],format:"fingerprint:%s %s"},{push:"candidates",reg:/^candidate:(\S*) (\d*) (\S*) (\d*) (\S*) (\d*) typ (\S*)(?: raddr (\S*) rport (\d*))?(?: tcptype (\S*))?(?: generation (\d*))?(?: network-id (\d*))?(?: network-cost (\d*))?/,names:["foundation","component","transport","priority","ip","port","type","raddr","rport","tcptype","generation","network-id","network-cost"],format:function(e){var t="candidate:%s %d %s %d %s %d typ %s";return t+=null!=e.raddr?" raddr %s rport %d":"%v%v",t+=null!=e.tcptype?" tcptype %s":"%v",null!=e.generation&&(t+=" generation %d"),t+=null!=e["network-id"]?" network-id %d":"%v",t+=null!=e["network-cost"]?" network-cost %d":"%v"}},{name:"endOfCandidates",reg:/^(end-of-candidates)/},{name:"remoteCandidates",reg:/^remote-candidates:(.*)/,format:"remote-candidates:%s"},{name:"iceOptions",reg:/^ice-options:(\S*)/,format:"ice-options:%s"},{push:"ssrcs",reg:/^ssrc:(\d*) ([\w_-]*)(?::(.*))?/,names:["id","attribute","value"],format:function(e){var t="ssrc:%d";return null!=e.attribute&&(t+=" %s",null!=e.value&&(t+=":%s")),t}},{push:"ssrcGroups",reg:/^ssrc-group:([\x21\x23\x24\x25\x26\x27\x2A\x2B\x2D\x2E\w]*) (.*)/,names:["semantics","ssrcs"],format:"ssrc-group:%s %s"},{name:"msidSemantic",reg:/^msid-semantic:\s?(\w*) (\S*)/,names:["semantic","token"],format:"msid-semantic: %s %s"},{push:"groups",reg:/^group:(\w*) (.*)/,names:["type","mids"],format:"group:%s %s"},{name:"rtcpMux",reg:/^(rtcp-mux)/},{name:"rtcpRsize",reg:/^(rtcp-rsize)/},{name:"sctpmap",reg:/^sctpmap:([\w_/]*) (\S*)(?: (\S*))?/,names:["sctpmapNumber","app","maxMessageSize"],format:function(e){return null!=e.maxMessageSize?"sctpmap:%s %s %s":"sctpmap:%s %s"}},{name:"xGoogleFlag",reg:/^x-google-flag:([^\s]*)/,format:"x-google-flag:%s"},{push:"rids",reg:/^rid:([\d\w]+) (\w+)(?: ([\S| ]*))?/,names:["id","direction","params"],format:function(e){return e.params?"rid:%s %s %s":"rid:%s %s"}},{push:"imageattrs",reg:new RegExp("^imageattr:(\\d+|\\*)[\\s\\t]+(send|recv)[\\s\\t]+(\\*|\\[\\S+\\](?:[\\s\\t]+\\[\\S+\\])*)(?:[\\s\\t]+(recv|send)[\\s\\t]+(\\*|\\[\\S+\\](?:[\\s\\t]+\\[\\S+\\])*))?"),names:["pt","dir1","attrs1","dir2","attrs2"],format:function(e){return"imageattr:%s %s %s"+(e.dir2?" %s %s":"")}},{name:"simulcast",reg:new RegExp("^simulcast:(send|recv) ([a-zA-Z0-9\\-_~;,]+)(?:\\s?(send|recv) ([a-zA-Z0-9\\-_~;,]+))?$"),names:["dir1","list1","dir2","list2"],format:function(e){return"simulcast:%s %s"+(e.dir2?" %s %s":"")}},{name:"simulcast_03",reg:/^simulcast:[\s\t]+([\S+\s\t]+)$/,names:["value"],format:"simulcast: %s"},{name:"framerate",reg:/^framerate:(\d+(?:$|\.\d+))/,format:"framerate:%s"},{name:"sourceFilter",reg:/^source-filter: *(excl|incl) (\S*) (IP4|IP6|\*) (\S*) (.*)/,names:["filterMode","netType","addressTypes","destAddress","srcList"],format:"source-filter: %s %s %s %s %s"},{name:"bundleOnly",reg:/^(bundle-only)/},{name:"label",reg:/^label:(.+)/,format:"label:%s"},{name:"sctpPort",reg:/^sctp-port:(\d+)$/,format:"sctp-port:%s"},{name:"maxMessageSize",reg:/^max-message-size:(\d+)$/,format:"max-message-size:%s"},{push:"tsRefClocks",reg:/^ts-refclk:([^\s=]*)(?:=(\S*))?/,names:["clksrc","clksrcExt"],format:function(e){return"ts-refclk:%s"+(null!=e.clksrcExt?"=%s":"")}},{name:"mediaClk",reg:/^mediaclk:(?:id=(\S*))? *([^\s=]*)(?:=(\S*))?(?: *rate=(\d+)\/(\d+))?/,names:["id","mediaClockName","mediaClockValue","rateNumerator","rateDenominator"],format:function(e){var t="mediaclk:";return t+=null!=e.id?"id=%s %s":"%v%s",t+=null!=e.mediaClockValue?"=%s":"",t+=null!=e.rateNumerator?" rate=%s":"",t+=null!=e.rateDenominator?"/%s":""}},{name:"keywords",reg:/^keywds:(.+)$/,format:"keywds:%s"},{name:"content",reg:/^content:(.+)/,format:"content:%s"},{name:"bfcpFloorCtrl",reg:/^floorctrl:(c-only|s-only|c-s)/,format:"floorctrl:%s"},{name:"bfcpConfId",reg:/^confid:(\d+)/,format:"confid:%s"},{name:"bfcpUserId",reg:/^userid:(\d+)/,format:"userid:%s"},{name:"bfcpFloorId",reg:/^floorid:(.+) (?:m-stream|mstrm):(.+)/,names:["id","mStream"],format:"floorid:%s mstrm:%s"},{push:"invalid",names:["value"]}]};Object.keys(n).forEach((function(e){n[e].forEach((function(e){e.reg||(e.reg=/(.*)/),e.format||(e.format="%s")}))}))})),qF=MF((function(e){var t=function(e){return String(Number(e))===e?Number(e):e},n=function(e,n,r){var i=e.name&&e.names;e.push&&!n[e.push]?n[e.push]=[]:i&&!n[e.name]&&(n[e.name]={});var o=e.push?{}:i?n[e.name]:n;(function(e,n,r,i){if(i&&!r)n[i]=t(e[1]);else for(var o=0;o<r.length;o+=1)null!=e[o+1]&&(n[r[o]]=t(e[o+1]))})(r.match(e.reg),o,e.names,e.name),e.push&&n[e.push].push(o)},r=zF(),i=RegExp.prototype.test.bind(/^([a-z])=(.*)/);e.parse=function(e){var t={},o=[],a=t;return e.split(/(\r\n|\r|\n)/).filter(i).forEach((function(e){var t=e[0],i=e.slice(2);"m"===t&&(o.push({rtp:[],fmtp:[]}),a=o[o.length-1]);for(var s=0;s<(r[t]||[]).length;s+=1){var c=r[t][s];if(c.reg.test(i))return n(c,a,i)}})),t.media=o,t};var o=function(e,n){var r=n.split(/=(.+)/,2);return 2===r.length?e[r[0]]=t(r[1]):1===r.length&&n.length>1&&(e[r[0]]=void 0),e};e.parseParams=function(e){return e.split(/;\s?/).reduce(o,{})},e.parseFmtpConfig=e.parseParams,e.parsePayloads=function(e){return e.toString().split(" ").map(Number)},e.parseRemoteCandidates=function(e){for(var n=[],r=e.split(" ").map(t),i=0;i<r.length;i+=3)n.push({component:r[i],ip:r[i+1],port:r[i+2]});return n},e.parseImageAttributes=function(e){return e.split(" ").map((function(e){return e.substring(1,e.length-1).split(",").reduce(o,{})}))},e.parseSimulcastStreamList=function(e){return e.split(";").map((function(e){return e.split(",").map((function(e){var n,r=!1;return"~"!==e[0]?n=t(e):(n=t(e.substring(1,e.length)),r=!0),{scid:n,paused:r}}))}))}})),YF=MF((function(e,t){var n=zF(),r=/%[sdv%]/g,i=function(e){var t=1,n=arguments,i=n.length;return e.replace(r,(function(e){if(t>=i)return e;var r=n[t];switch(t+=1,e){case"%%":return"%";case"%s":return String(r);case"%d":return Number(r);case"%v":return""}}))},o=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 o=0;o<t.names.length;o+=1){var a=t.names[o];t.name?r.push(n[t.name][a]):r.push(n[t.names[o]])}else r.push(n[t.name]);return i.apply(null,r)},a=["v","o","s","i","u","e","p","c","b","t","r","z","a"],s=["i","c","b","a"];t.exports=function(e,t){t=t||{},null==e.version&&(e.version=0),null==e.name&&(e.name=" "),e.media.forEach((function(e){null==e.payloads&&(e.payloads="")}));var r=t.outerOrder||a,i=t.innerOrder||s,c=[];return r.forEach((function(t){n[t].forEach((function(n){n.name in e&&null!=e[n.name]?c.push(o(t,n,e)):n.push in e&&null!=e[n.push]&&e[n.push].forEach((function(e){c.push(o(t,n,e))}))}))})),e.media.forEach((function(e){c.push(o("m",n.m[0],e)),i.forEach((function(t){n[t].forEach((function(n){n.name in e&&null!=e[n.name]?c.push(o(t,n,e)):n.push in e&&null!=e[n.push]&&e[n.push].forEach((function(e){c.push(o(t,n,e))}))}))}))})),c.join("\r\n")+"\r\n"}})),XF=MF((function(e){var t=qF(),n=YF();e.write=n,e.parse=t.parse,e.parseParams=t.parseParams,e.parseFmtpConfig=t.parseFmtpConfig,e.parsePayloads=t.parsePayloads,e.parseRemoteCandidates=t.parseRemoteCandidates,e.parseImageAttributes=t.parseImageAttributes,e.parseSimulcastStreamList=t.parseSimulcastStreamList})),QF=VF(jF()),$F=((gF=$F||{})[gF.INVALID_PARAMETER=4096]="INVALID_PARAMETER",gF[gF.INVALID_OPERATION=4097]="INVALID_OPERATION",gF[gF.NOT_SUPPORTED=4098]="NOT_SUPPORTED",gF[gF.DEVICE_NOT_FOUND=4099]="DEVICE_NOT_FOUND",gF[gF.INITIALIZE_FAILED=4100]="INITIALIZE_FAILED",gF[gF.SIGNAL_CHANNEL_SETUP_FAILED=16385]="SIGNAL_CHANNEL_SETUP_FAILED",gF[gF.SIGNAL_CHANNEL_ERROR=16386]="SIGNAL_CHANNEL_ERROR",gF[gF.ICE_TRANSPORT_ERROR=16387]="ICE_TRANSPORT_ERROR",gF[gF.JOIN_ROOM_FAILED=16388]="JOIN_ROOM_FAILED",gF[gF.CREATE_OFFER_FAILED=16389]="CREATE_OFFER_FAILED",gF[gF.SIGNAL_CHANNEL_RECONNECTION_FAILED=16390]="SIGNAL_CHANNEL_RECONNECTION_FAILED",gF[gF.UPLINK_RECONNECTION_FAILED=16391]="UPLINK_RECONNECTION_FAILED",gF[gF.DOWNLINK_RECONNECTION_FAILED=16392]="DOWNLINK_RECONNECTION_FAILED",gF[gF.REMOTE_STREAM_NOT_EXIST=16400]="REMOTE_STREAM_NOT_EXIST",gF[gF.CLIENT_BANNED=16448]="CLIENT_BANNED",gF[gF.SERVER_TIMEOUT=16449]="SERVER_TIMEOUT",gF[gF.SUBSCRIPTION_TIMEOUT=16450]="SUBSCRIPTION_TIMEOUT",gF[gF.PLAY_NOT_ALLOWED=16451]="PLAY_NOT_ALLOWED",gF[gF.DEVICE_AUTO_RECOVER_FAILED=16452]="DEVICE_AUTO_RECOVER_FAILED",gF[gF.START_PUBLISH_CDN_FAILED=16453]="START_PUBLISH_CDN_FAILED",gF[gF.STOP_PUBLISH_CDN_FAILED=16454]="STOP_PUBLISH_CDN_FAILED",gF[gF.START_MIX_TRANSCODE_FAILED=16455]="START_MIX_TRANSCODE_FAILED",gF[gF.STOP_MIX_TRANSCODE_FAILED=16456]="STOP_MIX_TRANSCODE_FAILED",gF[gF.NOT_SUPPORTED_H264=16457]="NOT_SUPPORTED_H264",gF[gF.SWITCH_ROLE_FAILED=16458]="SWITCH_ROLE_FAILED",gF[gF.API_CALL_TIMEOUT=16459]="API_CALL_TIMEOUT",gF[gF.SCHEDULE_FAILED=16460]="SCHEDULE_FAILED",gF[gF.API_CALL_ABORTED=16461]="API_CALL_ABORTED",gF[gF.SPC_INITIALIZED_FAILED=16462]="SPC_INITIALIZED_FAILED",gF[gF.VIDEO_MANAGER_ERROR=16463]="VIDEO_MANAGER_ERROR",gF[gF.UNKNOWN=65535]="UNKNOWN",gF),ZF=$F,eB=function(e){function t(e){var n,o=e.name,a=void 0===o?"RtcError":o,s=e.message,c=e.code,u=void 0===c?ZF.UNKNOWN:c,l=e.extraCode,d=void 0===l?0:l,h=e.constraint;i(this,t);var f="<".concat(function(e){for(var t in ZF)if(ZF[t]===e)return t;return"UNKNOWN"}(u)," 0x").concat(u.toString(16),">"),p="".concat(s).concat(h?" constraint: ".concat(h):"").concat(null!=s&&s.includes(f)?"":" ".concat(f));return n=r(this,t,[p]),FF(n,"code"),FF(n,"extraCode"),FF(n,"message"),FF(n,"originMessage"),FF(n,"name"),FF(n,"constraint"),n.code=u,n.extraCode=d,n.name=a,n.message=p,n.constraint=h,n.originMessage=s,n}return d(t,e),s(t,[{key:"getCode",value:function(){return this.code}},{key:"getExtraCode",value:function(){return this.extraCode}},{key:"toString",value:function(){return this.originMessage}}])}(b(Error)),tB=eB,nB=((new Date).getTime(),0),rB=function(){return(new Date).getTime()+nB},iB=function(){var e=new Date;return e.setTime(rB()),e.toLocaleString()},oB=function(e){var t=String(e.getMilliseconds());return"padStart"in String.prototype&&(t=t.toString().padStart(3,"0")),"".concat(e.toTimeString().replace(/.*(\d{2}:\d{2}:\d{2}).*/,"$1"),":").concat(t)},aB={};LF(aB,{bytes2ms:function(){return YH},convertObjectNumberToInt:function(){return Uj},copyProperties:function(){return qH},deepClone:function(){return Cj},deepMerge:function(){return Rj},delay:function(){return Fj},fibonacci:function(){return nj},formatedTime:function(){return Nj},getConstructorName:function(){return vj},getContainerFromElement:function(){return Dj},getEnv:function(){return BH},getInternalVersion:function(){return Tj},getLoggerUrl:function(){return jH},getMuteStateFromFlag:function(){return Ij},getNetworkType:function(){return WH},getNumNetworkType:function(){return zH},getReconnectionTimeout:function(){return rj},getStringByteLength:function(){return Pj},getTurnServer:function(){return bj},getUint32Version:function(){return Vj},getValueType:function(){return ij},getViewListFromView:function(){return wj},glog:function(){return ZH},ipv4ToUint32:function(){return Aj},isArray:function(){return dj},isAudioWorkletSupported:function(){return _j},isBoolean:function(){return uj},isConstructor:function(){return mj},isEmpty:function(){return Sj},isFunction:function(){return oj},isLangChinese:function(){return ej},isMediaStreamTrack:function(){return hj},isNumber:function(){return cj},isObject:function(){return lj},isOverseaSdkAppId:function(){return HH},isPlainObject:function(){return tj},isPortrait:function(){return Mj},isPromise:function(){return pj},isRemoteTrack:function(){return fj},isString:function(){return sj},isUndefined:function(){return aj},loadImage:function(){return Lj},ms2bytes:function(){return QH},ms2samples:function(){return $H},performanceNow:function(){return yj},promiseAny:function(){return gj},samples2ms:function(){return XH},setNetworkType:function(){return KH},stringify:function(){return xj},stringifyIncludeValue:function(){return Oj},throttlePromise:function(){return Bj}});var sB={};LF(sB,{AUDIO_MUTE_BIT:function(){return KB},AUDIO_STAT_BIT:function(){return JB},AUX_STAT_BIT:function(){return WB},AUX_STREAM_MSID:function(){return QB},BACKEND_ENV:function(){return BB},BASE_DOC_URL:function(){return kB},BASE_HOST:function(){return gB},CAPABILITIES_KEYS:function(){return UH},CLASS_NAME:function(){return wH},CLOUD_CONSOLE_URL:function(){return TB},CROSS_ROOM_BIT:function(){return YB},DATA_FREEZE_TIMING:function(){return kH},DEFAULT_ASSETS_URL:function(){return SB},DOC_URL:function(){return IB},DTLS_STATE_UNKNOWN:function(){return sH},ENV_NAME:function(){return wB},EXCHANGE_SDP_TIMEOUT:function(){return _H},IS_WORKER:function(){return fB},IS_WORKLET:function(){return pB},KIBANA_EVENT:function(){return pH},LOCAL_STREAM_PUBLISH_STATE:function(){return TH},LOGGER_CMD_TYPE:function(){return CB},LOGGER_DOMAIN:function(){return bB},LOGGER_DOMAIN_OVERSEA:function(){return AB},LOG_LEVEL:function(){return DB},LOG_LEVEL_NAME:function(){return PH},MAIN_STREAM_MSID:function(){return XB},MAX_RTT:function(){return FH},MICROPHONE_COMMUNICATIONS:function(){return OH},MICROPHONE_DEFAULT:function(){return NH},MUTE_ALL_BIT:function(){return qB},NAME:function(){return UB},NETWORK_TYPE:function(){return OB},NOT_SUPPORTED_H264:function(){return EH},PAUSED_RETRY_COUNT:function(){return DH},PEERCONNECTION_CONNECTING_TIMEOUT:function(){return AH},PEER_CONNECTION_STATE:function(){return cH},PEER_LEAVE_REASON:function(){return MH},RECOVER_CAPTURE_INTERVAL:function(){return VH},REMOTE_STREAM_TYPE_AUX:function(){return ZB},REMOTE_STREAM_TYPE_MAIN:function(){return $B},RENDER_FREEZE_TIMING:function(){return SH},SCHEDULE_DOMAIN:function(){return RH},SCHEDULE_TIMEOUT:function(){return CH},SDP_SEMANTICS_PLAN_B:function(){return yH},SDP_SEMANTICS_UNIFIED_PLAN:function(){return gH},SECOND_HOST:function(){return yB},SIGNAL_PING_PONG_INTERVAL:function(){return xB},SIGNAL_PING_TIMEOUT:function(){return NB},SIGNAL_RECONNECTION_COUNT:function(){return fH},SMALL_STAT_BIT:function(){return GB},SPEAKER_DEFAULT:function(){return xH},STORAGE_EXPIRES_TIME:function(){return PB},STREAM_TYPE_BIG:function(){return IH},STREAM_TYPE_SMALL:function(){return bH},SUBSCRIBE_SMALL_RETRY_COUNT:function(){return LH},SYNC_USER_LIST_INTERVAL:function(){return mH},Scene:function(){return HB},THIRD_HOST:function(){return EB},TRANSPORT_DIRECTION:function(){return FB},TRTC_ERROR_ASSISTANCE:function(){return RB},TRTC_QUALITY_BAD:function(){return iH},TRTC_QUALITY_DISCONNECTED:function(){return aH},TRTC_QUALITY_EXCELLENT:function(){return tH},TRTC_QUALITY_GOOD:function(){return nH},TRTC_QUALITY_POOR:function(){return rH},TRTC_QUALITY_UNKNOWN:function(){return eH},TRTC_QUALITY_VERY_BAD:function(){return oH},UPDATE_OFFER_TIMEOUT:function(){return vH},VIDEO_MUTE_BIT:function(){return zB},VIDEO_STAT_BIT:function(){return jB},audioProfileMap:function(){return MB},getRetryCount:function(){return dH},getScriptDir:function(){return mB},innerVersion:function(){return cB},loggerProxy:function(){return vB},screenProfileMap:function(){return VB},setLoggerProxy:function(){return _B},setRetryCount:function(){return lH},setVersion:function(){return lB},version:function(){return uB},videoProfileMap:function(){return LB}});var cB="4.15.00.1600",uB="5.0.0";function lB(e){uB=e;var t=_(e.split(".").map((function(e){return parseInt(e,10)})),3),n=t[0],r=t[1],i=t[2];cB="".concat(n,".").concat(Math.min(15,r),".").concat(Math.min(15,i),".").concat(r.toString().padStart(2,"0")).concat(i.toString().padStart(2,"0"))}var dB,hB,fB="undefined"!=typeof importScripts,pB="undefined"!=typeof registerProcessor,mB=function(){var e=fB?self.location.href:document.currentScript.src;return e.substring(0,e.lastIndexOf("/")+1)},vB="",_B=function(e){return vB=e},gB="web.sdk.qcloud.com",yB="web.sdk.tencent.cn",EB="web.sdk.cloud.tencent.cn",TB="https://console.cloud.tencent.com/trtc",kB="https://".concat(gB,"/trtc/webrtc/v5/doc"),SB="https://web.sdk.qcloud.com/trtc/webrtc/v5/assets/",IB="".concat(kB,"/zh-cn/"),bB="https://yun.tim.qq.com",AB="https://apisgp.my-imcloud.com",RB="trtc_error_assistance",CB={LOG:"jssdk_log",EVENT:"jssdk_event",KEY_POINT:"jssdk_new_endreport",KV_STAT:"jssdk_key_metrics_report"},wB={QCLOUD:"qcloud",OLD_CLOUD_LADDER:"trtc",WEBRTC:"webrtc"},DB=((hB=DB||{})[hB.TRACE=0]="TRACE",hB[hB.DEBUG=1]="DEBUG",hB[hB.INFO=2]="INFO",hB[hB.WARN=3]="WARN",hB[hB.ERROR=4]="ERROR",hB[hB.NONE=5]="NONE",hB),NB=18e3,xB=2e3,OB={unknown:0,wifi:1,"3g":2,"2g":3,"4g":4,wired:5,"5g":6},PB=6048e5,MB={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}},LB={"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}},VB={"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}},UB={CANVAS:"canvas",AUDIO:"audio",VIDEO:"video",SCREEN:"screen",SMALL:"small",BIG:"big",AUXILIARY:"auxiliary",SMALL_VIDEO:"smallVideo",FACING_MODE_USER:"user",FACING_MODE_ENVIRONMENT:"environment",MUTE:"mute",UNMUTE:"unmute",ENDED:"ended",PLAYING:"playing",PAUSE:"pause",ERROR:"error",LOADEDDATA:"loadeddata",LOADEDMETADATA:"loadedmetadata",AUDIO_INPUT:"audioinput",VIDEO_INPUT:"videoinput",DETAIL:"detail",TEXT:"text",MAIN:"main",BACKUP:"backup",BANNED:"banned",KICK:"kick",USER_TIME_OUT:"user_time_out",ROOM_DISBAND:"room_disband",SEI_MESSAGE:"sei-message",ADD:"add",REMOVE:"remove",REPLACE:"replace",TRACK:"track",SUBSCRIBE:"subscribe",UNSUBSCRIBE:"unsubscribe",TRANSCEIVER_DIRECTION_SENDONLY:"sendonly",TRANSCEIVER_DIRECTION_RECVONLY:"recvonly",ENTER_PICTURE_IN_PICTURE:"enterpictureinpicture",LEAVE_PICTURE_IN_PICTURE:"leavepictureinpicture"},FB={INACTIVE:"inactive",SENDONLY:"sendonly",RECVONLY:"recvonly"},BB={OLD_CLOUD_LADDER:"wss://trtc.rtc.qq.com",WEBRTC:"wss://webrtc.qq.com"},HB=((dB=HB||{}).LIVE="live",dB.RTC="rtc",dB),jB=1,GB=2,WB=4,JB=8,KB=64,zB=16,qB=112,YB=128,XB="5Y2wZK8nANNAoVw6dSAHVjNxrD1ObBM2kBPV",QB="224d130c-7b5c-415b-aaa2-79c2eb5a6df2",$B=UB.MAIN,ZB=UB.AUXILIARY,eH=0,tH=1,nH=2,rH=3,iH=4,oH=5,aH=6,sH="unknown",cH={NEW:"new",CONNECTING:"connecting",FAILED:"failed",CLOSED:"closed",DISCONNECTED:"disconnected",CONNECTED:"connected",COMPLETED:"completed"},uH=1/0;function lH(e){uH=e}function dH(){return uH}var hH,fH=30,pH={JOIN:"join",DELTA_JOIN:"delta-join",REJOIN:"rejoin",LEAVE:"leave",DELTA_LEAVE:"delta-leave",PUBLISH:"publish",DELTA_PUBLISH:"delta-publish",UNPUBLISH:"unpublish",SUBSCRIBE:"subscribe",UNSUBSCRIBE:"unsubscribe",UPLINK_CONNECTION:"uplink-connection",UPLINK_RECONNECTION:"uplink-reconnection",DOWNLINK_CONNECTION:"downlink-connection",DOWNLINK_RECONNECTION:"downlink-reconnection",ON_TRACK:"ontrack",ICE_CONNECTION_STATE:"iceConnectionState",LOCAL_STREAM_INITIALIZE:"stream-initialize",SIGNAL_CONNECTION:"websocketConnectionState",SIGNAL_RECONNECTION:"websocketReconnectionState",UPDATE_STREAM:"update-stream",RECOVER_LOCAL_AUDIO_TRACK:"recover-local-audio-track",RECOVER_LOCAL_VIDEO_TRACK:"recover-local-video-track",RECOVER_SUBSCRIPTION:"recover-subscription",START_MIX_TRANSCODE:"start-mix-transcode",STOP_MIX_TRANSCODE:"stop-mix-transcode",PLAYER_ERROR:"player-error",SCHEDULE:"schedule",LOAD_WORKLET:"load-worklet",VIDEO_FROZEN_COUNT:"videoFrozenCount",GET_USER_MEDIA_RETRY:"getUserMedia-retry"},mH=1e4,vH=1e4,_H=1e4,gH="unified-plan",yH="plan-b",EH=1028,TH=((hH=TH||{})[hH.UNPUBLISH=-1]="UNPUBLISH",hH[hH.PUBLISHING=0]="PUBLISHING",hH[hH.PUBLISHED=1]="PUBLISHED",hH),kH=500,SH=1e3,IH=UB.BIG,bH=UB.SMALL,AH=1e4,RH={MAIN:"schedule.cloud-rtc.com",BACKUP:"schedule.cloud-rtc.net",MAIN_OVERSEA:"schedule.rtc-web.com",BACKUP_OVERSEA:"schedule.rtc-web.io",MAIN_OVERSEA_BACKUP:"intl-schedule.cloud-rtc.com"},CH=2e3,wH={TRTC:"TRTC",CLIENT:"Client",LOCAL_STREAM:"LocalStream",REMOTE_STREAM:"RemoteStream",STREAM:"Stream"},DH=5,NH="default",xH=NH,OH="communications",PH=Object.keys(DB),MH=["normal leave","timeout leave","kick","role change"],LH=10,VH=2e3,UH=["width","height","frameRate","facingMode","sampleRate","sampleSize","channelCount","deviceId","min","max"],FH=1e4,BH=function(){return new URLSearchParams(location.search).get("trtc_env")||""},HH=function(e){return Number(e)<14e8},jH=function(e,t){var n;n=vB||(HH(e)?AB:bB);var r=Math.floor(Math.random()*DF(2,31));return"".concat(n,"/v5/AVQualityReportSvc/C2S?random=").concat(r,"&sdkappid=").concat(e,"&cmdtype=").concat(t)},GH="unknown";function WH(){if("unknown"!==GH)return GH;var e=navigator,t=e.userAgent,n=e.connection,r=(t.match(/NetType\/\S+/)||[])[0]||"";"3gnet"===(r=r.toLowerCase().replace("nettype/",""))&&(r="3g");var i=n&&n.type&&n.type.toLowerCase(),o=n&&n.effectiveType&&n.effectiveType.toLowerCase();return"slow-2"===o&&(o="2g"),i&&(GH=JH(i,o)),GH}function JH(e,t){if(OB[e])return e;switch(e){case"cellular":case"wimax":return t||"unknown";case"ethernet":return"wired";default:return"unknown"}}function KH(e){GH=JH(e)}function zH(){return OB[WH()]}function qH(e,t){var n,r=c(Reflect.ownKeys(t));try{for(r.s();!(n=r.n()).done;){var i=n.value;if("constructor"!==i&&"prototype"!==i&&"name"!==i){var o=Object.getOwnPropertyDescriptor(t,i)||"";Object.defineProperty(e,i,o)}}}catch(a){r.e(a)}finally{r.f()}return e}function YH(e){return XH(e/4,arguments.length>1&&void 0!==arguments[1]?arguments[1]:48e3)}function XH(e){return 1e3*e/(arguments.length>1&&void 0!==arguments[1]?arguments[1]:48e3)}function QH(e){return 4*$H(e,arguments.length>1&&void 0!==arguments[1]?arguments[1]:48e3)}function $H(e){return e*(arguments.length>1&&void 0!==arguments[1]?arguments[1]:48e3)/1e3}var ZH="undefined"!=typeof window&&"function"==typeof window.glog?window.glog:function(){},ej=function(){var e=navigator.language;return"zh"===(e=e.substring(0,2))},tj=function(e){if(!e||"object"!=S(e)||"[object Object]"!=Object.prototype.toString.call(e))return!1;var t=Object.getPrototypeOf(e);if(null===t)return!0;var n=Object.prototype.hasOwnProperty.call(t,"constructor")&&t.constructor;return"function"==typeof n&&n instanceof n&&Function.prototype.toString.call(n)===Function.prototype.toString.call(Object)};function nj(e){var t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1;return e<=1?t:nj(e-1,t,(arguments.length>1&&void 0!==arguments[1]?arguments[1]:1)+t)}function rj(e){return e>8?3e4:1e3*nj(e)}function ij(e){return Reflect.apply(Object.prototype.toString,e,[]).replace(/^\[object\s(\w+)\]$/,"$1").toLowerCase()}var oj=function(e){return"function"==typeof e},aj=function(e){return void 0===e},sj=function(e){return"string"==typeof e},cj=function(e){return"number"==typeof e},uj=function(e){return"boolean"==typeof e},lj=function(e){return"object"===ij(e)},dj=function(e){return"array"===ij(e)},hj=function(e){return ij(e)==="MediaStreamTrack".toLowerCase()},fj=function(e){return e.isRemote},pj=function(e){return"promise"===ij(e)},mj=function(e){return oj(e)&&e.prototype.constructor===e},vj=function(e){return mj(e)?e.prototype.constructor.name:""},_j="undefined"!=typeof AudioWorkletNode;function gj(e){return new Promise((function(t,n){var r=[];e.forEach((function(i){i.then(t).catch((function(t){r.push(t),r.length===e.length&&n(r)}))}))}))}function yj(){return performance&&performance.now?Math.floor(performance.now()):Date.now()}var Ej=function(e){return+e<10?"0".concat(e):e},Tj=function(e){var t=e.match(/^\d+\.\d+\.\d+/)[0];if(!t)return e;var n=t.split("."),r=Ej(n[1])+Ej(n[2]);return n[1]-15>0&&(n[1]="15"),n[2]-15>0&&(n[2]="15"),"".concat(n.join("."),".").concat(r)},kj=Object.prototype.hasOwnProperty;function Sj(e){if(null==e)return!0;if("boolean"==typeof e)return!1;if("number"==typeof e)return 0===e;if("string"==typeof e||"function"==typeof e||Array.isArray(e))return 0===e.length;if(e instanceof Error)return""===e.message;if(tj(e))switch(Object.prototype.toString.call(e)){case"[object File]":case"[object Map]":case"[object Set]":return 0===e.size;case"[object Object]":for(var t in e)if(kj.call(e,t))return!1;return!0}return!1}function Ij(e,t){return{userId:t,hasAudio:!!(e&JB),hasVideo:!!(e&jB),hasAuxiliary:!!(e&WB),hasSmall:!!(e&GB),audioMuted:!!(e&KB),videoMuted:!!(e&zB),audioAvailable:!(!(e&JB)||e&KB),videoAvailable:!(!(e&jB)||e&zB)}}function bj(e){var t={urls:e.url.startsWith("turn:")||e.url.startsWith("turns:")?e.url:"turn:".concat(e.url)};return!aj(e.username)&&!aj(e.credential)&&(t.username=e.username,t.credential=e.credential,t.credentialType="password",aj(e.credentialType)||(t.credentialType=e.credentialType)),t}function Aj(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];if(!sj(e))return 0;var n=e.split(".");return t?(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 Rj=function(e,t,n,r){if(!lj(e)||!lj(t))return 0;for(var i,o=0,a=Object.keys(t),s=0,c=a.length;s<c;s++)if(i=a[s],!(aj(t[i])||n&&n.includes(i)))if(lj(e[i])&&lj(t[i]))o+=Rj(e[i],t[i],n,r);else{if(r&&r.includes(t[i]))continue;e[i]!==t[i]&&(e[i]=Cj(t[i]),o+=1)}return o};function Cj(e){if(dj(e)){var t=[];return e.forEach((function(e,n){t[n]=Cj(e)})),t}if(lj(e)){var n={};return Object.keys(e).forEach((function(t){n[t]=Cj(e[t])})),n}return e}var wj=function(e){var t=[];if(dj(e))t=T(e);else if(sj(e)){var n=document.getElementById(e);n&&t.push(n)}else e&&t.push(e);return t},Dj=function(e){return sj(e)?document.getElementById(e):e},Nj=function(){return function(e){var t=function(e){return e<10?"0".concat(e):"".concat(e)},n=e.getFullYear(),r=e.getMonth()+1,i=e.getDate(),o=t(e.getHours()),a=t(e.getMinutes()),s=t(e.getSeconds());return"".concat(n,"/").concat(r,"/").concat(i," ").concat(o,":").concat(a,":").concat(s)}(new Date)};function xj(e,t){var n=t.keysToInclude,r=t.keysToExclude;try{if(dj(e))return"[".concat(e.map((function(e){return xj(e,{keysToInclude:n,keysToExclude:r})})).join(","),"]");if(!tj(e)||!dj(n)&&!dj(r))return JSON.stringify(e);var i={},o=new Set(n),a=new Set(r);return Object.keys(e).forEach((function(t){(0===a.size&&o.has(t)||0===o.size&&!a.has(t))&&(i[t]=tj(e[t])||dj(e[t])?JSON.parse(xj(e[t],{keysToExclude:r,keysToInclude:n})):e[t])})),JSON.stringify(i)}catch(i){return"{}"}}function Oj(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=[];return Object.keys(e).forEach((function(r){t===e[r]&&n.push(r)})),xj(e,{keysToInclude:n})}function Pj(e){return e.replace(/[\u4e00-\u9fa5]/g,"aa").length}var Mj=function(){var e,t,n,r;return null!=(e=window.screen)&&e.orientation?!(null==(r=null==(n=null==(t=window.screen)?void 0:t.orientation)?void 0:n.type)||!r.includes("portrait")):0===window.orientation||180===window.orientation},Lj=function(e){return HF(void 0,null,p().mark((function t(){return p().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",new Promise((function(t,n){var r;if(sj(e))(r=new Image).crossOrigin="anonymous",r.src=e;else if((r=e).complete)return void t(r);r.onload=function(){return t(r)},r.onerror=function(){n(new tB({code:ZF.INVALID_PARAMETER,message:"load image failed, url: ".concat(e)}))}})));case 1:case"end":return t.stop()}}),t)})))},Vj=function(e){var t=e.split(".");return+t[0]<<24|+t[1]<<16|+t[2]<<8|+t[3]},Uj=function(e){return Object.keys(e).forEach((function(t){cj(e[t])&&(t.startsWith("uint")||t.startsWith("int"))?e[t]=Math.floor(e[t]):(tj(e[t])||dj(e[t]))&&Uj(e[t])})),e};function Fj(e,t){return new Promise((function(n){var r=setTimeout(n,e);t&&t(r)}))}function Bj(e,t){var n=null;return function(){for(var r=arguments.length,i=new Array(r),o=0;o<r;o++)i[o]=arguments[o];return n||((n=e.apply(t||this,i)).finally((function(){return n=null})),n)}}function Hj(e){var t=e.url,n=e.body,r=e.method,i=void 0===r?"POST":r,o=e.timeout,a=e.priority;return new Promise((function(e,r){if("fetch"in window)return fetch(t,{method:i,body:n,priority:a}).then((function(e){return e.text()})).then((function(t){try{e({data:JSON.parse(t)})}catch(tJ){e({data:t})}}),r);var s=new XMLHttpRequest;s.onreadystatechange=function(){if(4===s.readyState)if(s.status>=200&&s.status<300)try{var t=JSON.parse(s.response);e({data:t})}catch(t){e({data:s.response})}else r({status:s.status,statusText:s.statusText||"request failed!"})},s.timeout=o||5e3,s.open(i,t,!0),s.send(n)}))}function jj(e){return HF(this,null,p().mark((function t(){var n,r,i,o;return p().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=yj(),r=JSON.stringify(e),t.prev=1,CompressionStream&&!(r.length<=2800)){t.next=4;break}return t.abrupt("return",r);case 4:return i=new Blob([r],{type:"application/json"}).stream().pipeThrough(new CompressionStream("gzip")),t.next=7,new Response(i);case 7:return t.next=9,t.sent.blob();case 9:return t.next=11,t.sent.arrayBuffer();case 11:return o=t.sent,t.abrupt("return",(qW.debug("compressJSON ".concat(r.length," -> ").concat(o.byteLength," ").concat(yj()-n,"ms")),o));case 15:return t.prev=15,t.t0=t.catch(1),t.abrupt("return",r);case 18:case"end":return t.stop()}}),t,null,[[1,15]])})))}var Gj=Object.prototype.hasOwnProperty,Wj=function(e){return"function"==typeof e},Jj=function(e){return void 0===e},Kj=function(e){return e.isRemote};function zj(e){if(null==e)return!0;if("boolean"==typeof e)return!1;if("number"==typeof e)return 0===e;if("string"==typeof e||"function"==typeof e||Array.isArray(e))return 0===e.length;if(e instanceof Error)return""===e.message;if(function(e){if(!e||"object"!=S(e)||"[object Object]"!=Object.prototype.toString.call(e))return!1;var t=Object.getPrototypeOf(e);if(null===t)return!0;var n=Object.prototype.hasOwnProperty.call(t,"constructor")&&t.constructor;return"function"==typeof n&&n instanceof n&&Function.prototype.toString.call(n)===Function.prototype.toString.call(Object)}(e))switch(Object.prototype.toString.call(e)){case"[object File]":case"[object Map]":case"[object Set]":return 0===e.size;case"[object Object]":for(var t in e)if(Gj.call(e,t))return!1;return!0}return!1}var qj=function(e){var t=e.retryFunction,n=e.settings,r=e.onError,i=e.onRetrying,o=e.onRetryFailed,a=e.onRetrySuccess,s=e.context;return function(){for(var e=this,c=arguments.length,u=new Array(c),l=0;l<c;l++)u[l]=arguments[l];var d=n.retries,h=void 0===d?5:d,f=n.timeout,m=void 0===f?1e3:f,v=0,_=-1,g=0,y=function(n,c){return HF(e,null,p().mark((function e(){var l,d,f,E,T=this;return p().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return l=s||this,e.prev=1,e.next=4,t.apply(l,u);case 4:d=e.sent,v>0&&a&&a.call(this,v),v=0,n(d),e.next=12;break;case 8:e.prev=8,e.t0=e.catch(1),f=function(){clearTimeout(_),v=0,g=2,c(e.t0)},E=function(){2!==g&&v<(Wj(h)?h():h)?(v++,g=1,Wj(i)&&i.call(T,v,f),_=window.setTimeout((function(){_=-1,y(n,c)}),Wj(m)?m(v):m)):(f(),Wj(o)&&o.call(T,e.t0))},Wj(r)?r.call(this,{error:e.t0,retry:E,reject:c,retryFuncArgs:u,retriedCount:v}):E();case 12:case"end":return e.stop()}}),e,this,[[1,8]])})))};return new Promise(y)}},Yj=function(){return s((function e(t){i(this,e),FF(this,"userId"),FF(this,"remoteUserId"),FF(this,"id"),FF(this,"sdkAppId"),FF(this,"type"),FF(this,"isLocal"),this.id=t.id,this.userId=t.userId,this.sdkAppId=t.sdkAppId,this.remoteUserId=t.remoteUserId,this.isLocal="boolean"!=typeof t.isLocal||t.isLocal,this.type=this.isLocal?"":t.type}),[{key:"createChild",value:function(e){return Object.setPrototypeOf(e,this)}},{key:"setUserId",value:function(e){this.userId=e}},{key:"setSdkAppId",value:function(e){this.sdkAppId=e}},{key:"log",value:function(e,t){var n=this.isLocal?this.userId:this.remoteUserId;t.unshift("[".concat(this.isLocal?"↑":"↓").concat(this.type&&"main"!==this.type?"*":"").concat(this.id).concat(n?"|".concat(n):"","]")),qW.log(e,t,Jj(this.userId)||zj(this.userId),this.userId,this.sdkAppId)}},{key:"info",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];this.log(2,t)}},{key:"debug",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];this.log(1,t)}},{key:"warn",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];this.log(3,t)}},{key:"error",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];this.log(4,t)}}])}(),Xj={};LF(Xj,{ANDROID_VERSION:function(){return lG},CHROME_MAJOR_VERSION:function(){return pW},CHROME_VERSION:function(){return mW},EDGE_VERSION:function(){return _G},EDG_MAJOR_VERSION:function(){return EG},EDG_VERSION:function(){return yG},FIREFOX_MAJOR_VERSION:function(){return mG},FIREFOX_VERSION:function(){return pG},HUAWEI_VERSION:function(){return tW},IE_VERSION:function(){return NG},IOS_MAIN_VERSION:function(){return TW},IOS_VERSION:function(){return EW},IPADQQB_VERSION:function(){return jG},IS_ANDROID:function(){return uG},IS_ANDROID_WEBVIEW:function(){return yW},IS_ANY_SAFARI:function(){return _W},IS_CHROME:function(){return hW},IS_CHROME_OS:function(){return KG},IS_CHROMIUM_BASE:function(){return dW},IS_EDG:function(){return gG},IS_EDGE:function(){return vG},IS_ELECTRON:function(){return YG},IS_FIREFOX:function(){return fG},IS_HEADLESS_CHROME:function(){return fW},IS_HONOR:function(){return eW},IS_HUAWEI:function(){return ZG},IS_HUAWEIBROWSER:function(){return $G},IS_IE:function(){return DG},IS_IE8:function(){return wG},IS_IOS:function(){return cG},IS_IOS_13_OR_14:function(){return IW},IS_IOS_15_1:function(){return SW},IS_IPAD:function(){return iG},IS_IPADQQB:function(){return HG},IS_IPAD_PRO:function(){return oG},IS_IPHONE:function(){return aG},IS_IPOD:function(){return sG},IS_LINUX:function(){return JG},IS_LOCAL:function(){return bW},IS_MAC:function(){return WG},IS_MACQQB:function(){return FG},IS_MIBROWSER:function(){return XG},IS_MQQB:function(){return MG},IS_NATIVE_ANDROID:function(){return hG},IS_OLD_ANDROID:function(){return dG},IS_OPENHARMONY:function(){return cW},IS_OPPOBROWSER:function(){return iW},IS_SAFARI:function(){return vW},IS_SAFARI_15_1:function(){return kW},IS_SAMSUNGBROWSER:function(){return nW},IS_SOGOU:function(){return SG},IS_SOGOUM:function(){return TG},IS_TBS:function(){return bG},IS_UCBROWSER:function(){return qG},IS_VIVOBROWSER:function(){return aW},IS_WECHAT:function(){return xG},IS_WIN:function(){return GG},IS_WQQB:function(){return VG},IS_WX:function(){return zG},IS_X5MQQB:function(){return PG},IS_XWEB:function(){return RG},MACQQB_VERSION:function(){return BG},MI_VERSION:function(){return QG},MQQB_VERSION:function(){return LG},OPENHARMONY_VERSION:function(){return uW},OPPO_VERSION:function(){return oW},SAFARI_VERSION:function(){return gW},SAMSUNG_VERSION:function(){return rW},SOGOUM_VERSION:function(){return kG},SOGOU_VERSION:function(){return IG},TBS_VERSION:function(){return AG},UA_DATA_STRING:function(){return NW},USER_AGENT:function(){return $j},VIVO_VERSION:function(){return sW},WECHAT_VERSION:function(){return OG},WQQB_VERSION:function(){return UG},XWEB_VERSION:function(){return CG},browserInfo:function(){return RW},getBrowserInfo:function(){return CW},getChromeMajorVersion:function(){return lW},getDeviceModel:function(){return OW},getOSName:function(){return MW},getOSNumber:function(){return LW},getOSString:function(){return VW},getOSType:function(){return FW},getTerminalType:function(){return UW},getUserAgentData:function(){return xW},isLocalStorageEnabled:function(){return AW},isMobile:function(){return DW}});var Qj,$j="undefined"==typeof navigator?"":navigator.userAgent,Zj=function(e){return new RegExp(e,"i").test($j)},eG=function(e){if(Zj(e)){var t=new RegExp("".concat(e,"\\/([\\d.]+)")),n=$j.match(t);if(n&&n[1])return n[1]}return""},tG=function(e){if(Zj(e)){var t=new RegExp("".concat(e,"\\/(\\d+)")),n=$j.match(t);if(n&&n[1])return parseFloat(n[1])}return NaN},nG=/AppleWebKit\/([\d.]+)/i.exec($j),rG=nG?parseFloat(nG[1]):NaN,iG=Zj("iPad"),oG="undefined"!=typeof navigator&&navigator.maxTouchPoints&&navigator.maxTouchPoints>2&&Zj("Macintosh"),aG=Zj("iPhone")&&!iG,sG=Zj("iPod"),cG=aG||iG||sG||oG,uG=Zj("Android"),lG=function(){if(uG){var e=$j.match(/Android (\d+)(?:\.(\d+))?(?:\.(\d+))*/i);if(e){var t=e[1]&&parseFloat(e[1]),n=e[2]&&parseFloat(e[2]);if(t&&n)return parseFloat("".concat(e[1],".").concat(e[2]));if(t)return t}}return NaN}(),dG=uG&&Zj("webkit")&&lG<2.3,hG=uG&&lG<5&&rG<537,fG=Zj("Firefox"),pG=eG("Firefox"),mG=tG("Firefox"),vG=Zj("Edge"),_G=eG("Edge"),gG=Zj("Edg"),yG=eG("Edg"),EG=tG("Edg"),TG=Zj("SogouMobileBrowser"),kG=eG("SogouMobileBrowser"),SG=Zj("MetaSr\\s"),IG=eG("MetaSr\\s"),bG=Zj("TBS"),AG=eG("TBS"),RG=Zj("XWEB"),CG=eG("XWEB"),wG=Zj("MSIE\\s8\\.0"),DG=Zj("MSIE\\/\\d+"),NG=function(){if(DG){var e=/MSIE\s(\d+)\.\d/.exec($j),t=e&&parseFloat(e[1]);return!t&&/Trident\/7.0/i.test($j)&&/rv:11.0/.test($j)&&(t=11),t}return NaN}(),xG=Zj("(micromessenger|webbrowser)"),OG=eG("MicroMessenger"),PG=!bG&&Zj("MQQBrowser")&&Zj("COVC"),MG=!bG&&Zj("MQQBrowser")&&!Zj("COVC"),LG=MG||PG?eG("MQQBrowser"):"",VG=!bG&&Zj(" QQBrowser"),UG=eG(" QQBrowser"),FG=!bG&&Zj("QQBrowserLite"),BG=eG("QQBrowserLite"),HG=!bG&&Zj("MQBHD"),jG=eG("MQBHD"),GG=Zj("Windows"),WG=!cG&&Zj("MAC OS X"),JG=!uG&&Zj("Linux"),KG=Zj("CrOS"),zG=Zj("MicroMessenger"),qG=Zj("UCBrowser"),YG=Zj("Electron"),XG=Zj("MiuiBrowser"),QG=eG("MiuiBrowser"),$G=Zj("HuaweiBrowser"),ZG=Zj("Huawei")||Zj("HUAWEI"),eW=Zj("Honor")||Zj("HONOR"),tW=eG("HuaweiBrowser"),nW=Zj("SamsungBrowser"),rW=eG("SamsungBrowser"),iW=Zj("HeyTapBrowser"),oW=eG("HeyTapBrowser"),aW=Zj("VivoBrowser"),sW=eG("VivoBrowser"),cW=Zj("OpenHarmony"),uW=eG("OpenHarmony"),lW=function(){return tG("Chrome")},dW=Zj("Chrome"),hW=!vG&&!SG&&!TG&&!bG&&!RG&&!gG&&!VG&&!XG&&!$G&&!nW&&!iW&&!aW&&dW,fW=Zj("HeadlessChrome"),pW=lW(),mW=eG("Chrome"),vW=!dW&&!MG&&!PG&&!FG&&!HG&&Zj("Safari"),_W=vW||cG,gW=eG("Version"),yW=/Android.*(wv|.0.0.0)/.test($j),EW=function(){if(oG)return gW;if(cG){var e=$j.match(/OS (\d+)_(\d+)/i);if(e&&e[1]){var t=e[1];return e[2]&&(t+=".".concat(e[2])),t}}return""}(),TW=Number(EW.split(".")[0]),kW="15.1"===gW,SW="15.1"===EW,IW=14===(Qj=Number(EW.split(".")[0]))||13===Qj,bW="undefined"!=typeof location&&("file:"===location.protocol||"localhost"===location.hostname||"127.0.0.1"===location.hostname),AW=function(){var e;return function(){if(void 0===e)try{e=!!window.localStorage}catch(rJ){e=!1}return e}}(),RW=CW();function CW(){var e,t=new Map([[fG,["Firefox",pG]],[gG,["Edg",yG]],[hW,["Chrome",mW]],[vW,["Safari",gW]],[bG,["TBS",AG]],[RG,["XWEB",CG]],[xG&&aG,["WeChat",OG]],[VG,["QQ(Win)",UG]],[MG,["QQ(Mobile)",LG]],[PG,["QQ(Mobile X5)",LG]],[FG,["QQ(Mac)",BG]],[HG,["QQ(iPad)",jG]],[XG,["MI",QG]],[$G,["HW",tW]],[nW,["Samsung",rW]],[iW,["OPPO",oW]],[aW,["VIVO",sW]],[vG,["EDGE",_G]],[TG,["SogouMobile",kG]],[SG,["Sogou",IG]]]),n="unknown",r="unknown";return t.has(!0)&&(n=(e=_(t.get(!0),2))[0],r=e[1]),{name:n,version:r}}var wW=null;function DW(){return wW&&"boolean"==typeof wW.mobile?wW.mobile:uG||cG||aG||iG||cW}var NW="";function xW(){return HF(this,null,p().mark((function e(){return p().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!wW){e.next=2;break}return e.abrupt("return",wW);case 2:if(navigator.userAgentData&&"function"==typeof navigator.userAgentData.getHighEntropyValues){e.next=4;break}return e.abrupt("return",null);case 4:return e.prev=4,e.next=7,navigator.userAgentData.getHighEntropyValues(["architecture","bitness","model","platformVersion","fullVersionList"]);case 7:return(wW=e.sent)&&!NW&&(NW="UAData: ".concat(wW.platform,"/").concat(wW.platformVersion),wW.architecture&&wW.bitness&&(NW+=" ".concat(wW.architecture,"/").concat(wW.bitness)),wW.mobile&&(NW+=" mobile"),wW.model&&(NW+=" model: ".concat(wW.model)),wW.fullVersionList&&(NW+=" ".concat(wW.fullVersionList.filter((function(e){return"Not/A)Brand"!==e.brand})).map((function(e){return"".concat(e.brand,"/").concat(e.version)})).join(",")))),e.abrupt("return",wW);case 12:return e.prev=12,e.t0=e.catch(4),e.abrupt("return",null);case 15:case"end":return e.stop()}}),e,null,[[4,12]])})))}function OW(){return(null==wW?void 0:wW.model)||""}var PW=new Map([[uG,"Android"],[cG,"iOS"],[GG,"Windows"],[WG,"MacOS"],[JG,"Linux"],[KG,"ChromeOS"]]),MW=function(){return PW.get(!0)?PW.get(!0):wW?wW.platform:"unknown"};function LW(){return GG?1:uG?2:WG?3:cG?4:JG?5:KG?6:0}var VW=function(){var e=MW();return e+="/".concat(RW.name,"/").concat(vW?RW.version:RW.version.split(".")[0]),null!=wW&&wW.platformVersion&&(e+="/".concat(wW.platformVersion)),null!=wW&&wW.architecture&&(e+="/".concat(wW.architecture)),e};function UW(){return uG?4:aG?2:iG?3:WG?12:GG?5:JG?13:cW?22:1}function FW(){return uG?"Android":aG?"iPhone":iG?"iPad":WG?"Mac":GG?"Windows":JG?"Linux":"unknown"}var BW,HW=new(VF(jF(),1).default),jW=((BW=jW||{}).ROOM_DESTROY="1",BW.JOIN_START="21",BW.JOIN_SCHEDULE_SUCCESS="22",BW.JOIN_SIGNAL_CONNECTION_START="23",BW.JOIN_SIGNAL_CONNECTION_END="24",BW.JOIN_SEND_CMD="25",BW.JOIN_RECEIVED_CMD_RES="26",BW.JOIN_SUCCESS="27",BW.JOIN_FAILED="28",BW.LEAVE_START="51",BW.LEAVE_SEND_CMD="52",BW.LEAVE_SUCCESS="53",BW.PUBLISH_START="61",BW.SEND_FIRST_VIDEO_FRAME="62",BW.PUBLISH_FAILED="63",BW.SUBSCRIBE_START="81",BW.SUBSCRIBE_SUCCESS="82",BW.SUBSCRIBE_FAILED="84",BW.UNSUBSCRIBE_SUCCESS="83",BW.LOCAL_TRACK_CAPTURE_START="101",BW.LOCAL_TRACK_CAPTURE_SUCCESS="102",BW.LOCAL_TRACK_CAPTURE_FAILED="103",BW.LOCAL_TRACK_PUBLISHED="104",BW.LOCAL_TRACK_UNPUBLISHED="105",BW.LOCAL_TRACK_REPLACED="106",BW.SWITCH_DEVICE_SUCCESS="107",BW.TRACK_MUTED="108",BW.TRACK_UNMUTED="109",BW.REMOTE_TRACK_SUBSCRIBED="110",BW.REMOTE_TRACK_UNSUBSCRIBED="111",BW.LOCAL_TRACK_RECAPTURE="112",BW.PLAY_TRACK_START="151",BW.PLAYER_STATE_CHANGED="152",BW.VIDEO_LOADED_DATA="153",BW.AUTOPLAY_DIALOG_CLICK_CONFIRM="154",BW.SIGNAL_CONNECTION_STATE_CHANGED="201",BW.PEER_CONNECTION_STATE_CHANGED="202",BW.SINGLE_CONNECTION_STAT="203",BW.SPC_RECONNECTED="204",BW.HEARTBEAT_REPORT="251",BW.RECEIVED_PUBLISHED_USER_LIST="252",BW.REMOTE_PUBLISH_STATE_CHANGED="253",BW.AUDIO_LEVEL_INTERVAL="260",BW.NETWORK_QUALITY="261",BW.VIDEO_CODEC_IMPLEMENTATION_CHANGED="262",BW.QUALITY_LIMITATION_CHANGED="263",BW.LOG="264",BW),GW=jW,WW="%cTRTC%c%s",JW="padding: 1px 4px;border-radius: 3px;color: #fff;background: #1E88E5;",KW="display: inline",zW=function(){function e(){i(this,e),FF(this,"_isEnableUploadLog",!0),FF(this,"_localJoinedUser",new Map),FF(this,"_queue",[]),FF(this,"_timeoutId",-1),FF(this,"_logLevel",1),FF(this,"_logLevelToUpload",2),!fB&&!pB&&(this.checkURLParam(),this.installEvents())}return s(e,[{key:"isAbleToUpload",get:function(){return this._isEnableUploadLog&&-1!==this._timeoutId}},{key:"installEvents",value:function(){var e=this;HW.on(GW.JOIN_SCHEDULE_SUCCESS,(function(t){var n,r=t.schedule;null!=(n=null==r?void 0:r.config)&&n.logLevelToUpload&&DB[r.config.logLevelToUpload]&&(e._logLevelToUpload=r.config.logLevelToUpload)})),HW.on(GW.JOIN_SUCCESS,(function(t){var n=t.room;e.addJoinedUser({userId:n.userId,sdkAppId:n.sdkAppId}),e.startUpload()})),HW.once(GW.JOIN_FAILED,(function(){e.startUpload()})),HW.on(GW.LEAVE_SUCCESS,(function(t){var n=t.room;e.deleteJoinedUser(n.userId)}))}},{key:"startUpload",value:function(){-1===this._timeoutId&&this.uploadInterval()}},{key:"addJoinedUser",value:function(e){this._localJoinedUser.set(e.userId,e),this.startUpload()}},{key:"deleteJoinedUser",value:function(e){this._localJoinedUser.delete(e)}},{key:"uploadInterval",value:function(){var e=this;this.upload().catch((function(){})),this._timeoutId=window.setTimeout((function(){return e.uploadInterval()}),5e3)}},{key:"getLogsToUpload",value:function(){var e=this,t={map:new Map,splicedQueue:[]};if(this._queue[0].forAllJoinedClients&&0===this._localJoinedUser.size)return t;for(var n=0,r=function(){var r=e._queue[n];if(r.forAllJoinedClients)e._localJoinedUser.forEach((function(e){var n=e.userId,i=e.sdkAppId;t.map.has(n)?t.map.get(n).logs.push(r):t.map.set(n,{userId:n,sdkAppId:i,logs:[r]})}));else if(sj(r.userId)&&cj(r.sdkAppId)){var i=r.userId,o=r.sdkAppId;t.map.has(i)?t.map.get(i).logs.push(r):t.map.set(i,{userId:i,sdkAppId:o,logs:[r]})}};n<this._queue.length&&50!==n;n++)r();return t.map.size>0&&(t.splicedQueue=this._queue.splice(0,n)),t}},{key:"upload",value:function(){return HF(this,null,p().mark((function e(){var t,n,r,i,o,a,s,c,u,l;return p().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(0!==this._queue.length&&this._isEnableUploadLog){e.next=2;break}return e.abrupt("return");case 2:if(t=this.getLogsToUpload(),n=t.map,r=t.splicedQueue,0!==n.size){e.next=5;break}return e.abrupt("return");case 5:e.prev=5,i=T(n.values()),o=0;case 8:if(!(o<i.length)){e.next=16;break}return a=i[o],s=a.userId,c=a.sdkAppId,u=a.logs,e.next=12,this.uploadLogWithRetry(JSON.stringify({timestamp:iB(),sdkAppId:String(c),userId:s,version:uB,log:u.map((function(e){return e.log})).join("\n")}),c);case 12:u.forEach((function(e){return e.uploaded=!0}));case 13:o++,e.next=8;break;case 16:e.next=20;break;case 18:e.prev=18,e.t0=e.catch(5);case 20:l=r.filter((function(e){return!e.uploaded})),l.length>0&&(this._queue=l.concat(this._queue));case 22:case"end":return e.stop()}}),e,this,[[5,18]])})))}},{key:"uploadLogWithRetry",value:function(e,t){return qj({retryFunction:function(){return Hj({url:jH(t,CB.LOG),body:e,timeout:5e3,priority:"low"})},settings:{retries:3,timeout:2e3},onError:function(e){(0,e.retry)()}})()}},{key:"getPrefix",value:function(e){var t=new Date;return t.setTime(rB()),"[".concat(oB(t),"] <").concat(DB[e],">")}},{key:"getLogLevel",value:function(){return this._logLevel}},{key:"setLogLevel",value:function(e){aj(DB[e])||(this._logLevel!==e&&this.info("setLogLevel",e),this._logLevel=e)}},{key:"enableUploadLog",value:function(){this._isEnableUploadLog=!0}},{key:"disableUploadLog",value:function(){this.warn("disableUploadLog"),this._isEnableUploadLog=!1}},{key:"logChunkToString",value:function(e){if(sj(e))return e;try{return e instanceof Error?e.toString():JSON.stringify(e)}catch(dB){return""}}},{key:"log",value:function(t,n){var r,i,o,a=this,s=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],c=arguments.length>3?arguments[3]:void 0,u=arguments.length>4?arguments[4]:void 0;n.unshift(this.getPrefix(t));var l={log:n.reduce((function(e,t){return"".concat(e," ").concat(a.logChunkToString(t)).trim()}),""),level:t,userId:c,sdkAppId:u,forAllJoinedClients:s};if(HW.emit(GW.LOG,{log:l}),this._isEnableUploadLog&&t>=this._logLevelToUpload&&this._queue.push(l),!(t<this._logLevel)){var d=(null==(o=DB[t])?void 0:o.toLowerCase())||"info";e.PRINT_LOG_TAG?(r=console)[d].apply(r,[WW,JW,KW].concat(T(n))):(i=console)[d].apply(i,T(n))}}},{key:"debug",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];this.log(1,t)}},{key:"info",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];this.log(2,t)}},{key:"warn",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];this.log(3,t)}},{key:"error",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];this.log(4,t)}},{key:"createLogger",value:function(e){return new Yj(e)}},{key:"checkURLParam",value:function(){var e=new URLSearchParams(location.search).get("logLevelToUpload"),t=e?Number(e):-1;DB[t]&&(this._logLevelToUpload=t)}},{key:"getQueue",value:function(){return this._queue}}])}();FF(zW,"PRINT_LOG_TAG",!(cG||uG||fW));var qW=new zW,YW=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(function(e){var t=16*Math.random()|0;return("x"==e?t:3&t|8).toString(16)}))},XW=function(){return s((function e(){i(this,e),FF(this,"_prefix","TRTC"),FF(this,"_queue",new Map)}),[{key:"getRealKey",value:function(e){return"".concat(this._prefix,"_").concat(e)}},{key:"checkStorage",value:function(){var e=this;AW()&&(setInterval(this.doFlush.bind(this),2e4),Object.keys(localStorage).filter((function(t){if(t.startsWith(e._prefix))try{var n=localStorage.getItem(t);if(!n)return!1;var r=JSON.parse(n);if(r&&r.expiresIn<Date.now())return!0}catch(n){return!1}return!1})).forEach((function(e){return localStorage.removeItem(e)})))}},{key:"doFlush",value:function(){if(AW())try{var e,t=c(this._queue);try{for(t.s();!(e=t.n()).done;){var n=_(e.value,2),r=n[0],i=n[1];localStorage.setItem(r,JSON.stringify(i))}}catch(o){t.e(o)}finally{t.f()}}catch(r){qW.warn(r)}}},{key:"getItem",value:function(e){if(!AW())return null;try{var t=localStorage.getItem(this.getRealKey(e));if(!t)return null;var n=JSON.parse(t);return n&&n.expiresIn>=Date.now()?n.value:null}catch(t){qW.warn(t)}}},{key:"setItem",value:function(e,t){if(AW())try{var n={expiresIn:Date.now()+PB,value:t};this._queue.set(this.getRealKey(e),n)}catch(n){qW.warn(n)}}},{key:"deleteItem",value:function(e){if(!AW())return!1;try{return e=this.getRealKey(e),this._queue.delete(e),localStorage.removeItem(e),!0}catch(dB){return qW.warn(dB),!1}}},{key:"clear",value:function(){if(AW())try{localStorage.clear()}catch(rJ){qW.warn(rJ)}}}])}(),QW=new XW,$W={};LF($W,{HTTPS_API:function(){return DK},IS_GET_CAPABILITIES_SUPPORTED:function(){return YK},IS_GET_SETTINGS_SUPPORTED:function(){return qK},IS_GET_SYNCHRONIZATION_SOURCES_SUPPORTED:function(){return zK},IS_INSERTABLE_STREAM_SUPPORTED:function(){return XK},IS_JITTER_BUFFER_TARGET_SUPPORTED:function(){return cz},IS_RTC_RTP_SENDER_SUPPORTED:function(){return WK},IS_SCRIPT_TRANSFORM_SUPPORTED:function(){return QK},IS_SEI_SUPPORTED:function(){return $K},IS_SPC_SUPPORTED:function(){return jK},basis:function(){return iz},capabilityCheck:function(){return az},checkSystemRequirementsInternal:function(){return bK},decodeSupportStatus:function(){return IK},encodeSupportStatus:function(){return SK},getBrowserInfo:function(){return vK},getDisplayResolution:function(){return xK},isAddTransceiverSupported:function(){return HK},isBrowserSupported:function(){return _K},isGetReceiversSupported:function(){return UK},isGetSendersSupported:function(){return FK},isGetTransceiversSupported:function(){return BK},isGetUserMediaSupported:function(){return OK},isMediaDevicesSupported:function(){return yK},isMediaSessionSupported:function(){return tz},isMediaStreamTrackProcessorSupported:function(){return kK},isReplaceTrackSupported:function(){return JK},isRequestVideoFrameCallbackSupported:function(){return sz},isSIMDSupported:function(){return rz},isScreenCaptureApiAvailable:function(){return RK},isSelectedCandidatePair:function(){return NK},isSetParametersSupported:function(){return KK},isSmallStreamAPISupported:function(){return MK},isSmallStreamSupported:function(){return LK},isStopTransceiverSupported:function(){return GK},isTRTCSupported:function(){return AK},isUnifiedPlanDefault:function(){return VK},isUsedInHttpProtocol:function(){return TK},isWebAudioSupported:function(){return PK},isWebCodecSupported:function(){return ez},isWebCodecsSupported:function(){return gK},isWebRTCSupported:function(){return ZK},isWebTransportSupported:function(){return nz}});var ZW={};LF(ZW,{AUDIO_LEVEL_SCALE:function(){return GJ},AudioCodecPipelineType:function(){return qJ},AudioDecoderDowngradeState:function(){return IJ},AudioPlayerMode:function(){return BJ},AudioType:function(){return DJ},BASIC_TYPE:function(){return JJ},BannedReason:function(){return HJ},CONNECTION_CLOSED_REASON:function(){return dJ},ClientEvent:function(){return hJ},CodecType:function(){return YJ},ConnectionEvent:function(){return lJ},ConnectionState:function(){return SJ},DECODE_FAILED_ERROR_CODE:function(){return XJ},FacingMode:function(){return UJ},LeaveReason:function(){return jJ},LocalTrackEvent:function(){return pJ},MULTI_VIDEO_DATA_TYPE:function(){return PJ},MediaType:function(){return CJ},MediaTypeLabel:function(){return wJ},MonitorEventId:function(){return MJ},MutedFlag:function(){return yJ},NetworkQualityValue:function(){return LJ},PlayerState:function(){return mJ},ReceiveMode:function(){return VJ},RemoteStreamType:function(){return OJ},RemoteTrackEvent:function(){return gJ},RoomEvent:function(){return vJ},SceneNumber:function(){return EJ},StreamEvent:function(){return fJ},StreamType:function(){return xJ},SubscribeMediaType:function(){return WJ},TIMER_TYPE:function(){return $J},TRACK_ACTION:function(){return RJ},TRACK_KIND:function(){return AJ},TrackEvent:function(){return _J},UserRole:function(){return kJ},UserRoleNumber:function(){return TJ},VideoCodec:function(){return KJ},VideoCodecPipelineType:function(){return zJ},VideoContentHint:function(){return QJ},VideoDecoderDowngradeState:function(){return bJ},VideoPlayerMode:function(){return FJ},VideoType:function(){return NJ}});var eJ,tJ,nJ,rJ,iJ,oJ,aJ,sJ,cJ,uJ,lJ=((uJ=lJ||{}).TRACK_ADDED="track-added",uJ.TRACK_UPDATED="track-updated",uJ.TRACK_SUBSCRIBED="track-subscribed",uJ.STREAM_ADDED="stream-added",uJ.STREAM_REMOVED="stream-removed",uJ.STREAM_UPDATED="stream-updated",uJ.STREAM_PUBLISHED="stream-published",uJ.STREAM_SUBSCRIBED="stream-subscribed",uJ.STREAM_UNSUBSCRIBED="stream-unsubscribed",uJ.STATE_CHANGED="state-changed",uJ.ERROR="error",uJ.CONNECTION_STATE_CHANGED="connection-state-changed",uJ.FIREWALL_RESTRICTION="firewall-restriction",uJ.SEI_MESSAGE="sei-message",uJ.CLOSED="closed",uJ),dJ=function(e){return e.REMOTE_LEAVE="remote user exitRoom",e.REMOTE_UNPUBLISH="remote user unpublished",e.LOCAL_LEAVE="you exitRoom",e.LOCAL_UNPUBLISH="you unpublished",e.LOCAL_UNSUBSCRIBE="you unsubscribed",e.SWITCH_ROLE="you switch role to audience",e}(dJ||{}),hJ=((cJ=hJ||{}).STREAM_ADDED="stream-added",cJ.STREAM_REMOVED="stream-removed",cJ.STREAM_UPDATED="stream-updated",cJ.STREAM_SUBSCRIBED="stream-subscribed",cJ.CONNECTION_STATE_CHANGED="connection-state-changed",cJ.PEER_JOIN="peer-join",cJ.PEER_LEAVE="peer-leave",cJ.MUTE_AUDIO="mute-audio",cJ.MUTE_VIDEO="mute-video",cJ.UNMUTE_AUDIO="unmute-audio",cJ.UNMUTE_VIDEO="unmute-video",cJ.CLIENT_BANNED="client-banned",cJ.NETWORK_QUALITY="network-quality",cJ.AUDIO_VOLUME="audio-volume",cJ.SEI_MESSAGE="sei-message",cJ.ERROR="error",cJ),fJ=((sJ=fJ||{}).PLAYER_STATE_CHANGED="player-state-changed",sJ.SCREEN_SHARING_STOPPED="screen-sharing-stopped",sJ.CONNECTION_STATE_CHANGED="connection-state-changed",sJ.DEVICE_AUTO_RECOVERED="device-auto-recovered",sJ.ERROR="error",sJ),pJ=function(e){return e.DEVICE_AUTO_RECOVERED="1",e.DEVICE_RECOVER_FAILED="5",e.DEVICE_CHANGED="2",e.ERROR="3",e.PUBLISH_STATE_CHANGED="4",e.ENCODE_FAILED="6",e}(pJ||{}),mJ=function(e){return e.PAUSED="PAUSED",e.PLAYING="PLAYING",e.STOPPED="STOPPED",e}(mJ||{}),vJ=((aJ=vJ||{}).PEER_JOIN="peer-join",aJ.PEER_LEAVE="peer-leave",aJ.SIGNAL_CONNECTION_STATE_CHANGED="signal-connection-state-changed",aJ.MEDIA_CONNECTION_STATE_CHANGED="media-connection-state-changed",aJ.BANNED="banned",aJ.NETWORK_QUALITY="network-quality",aJ.AUDIO_VOLUME="audio-volume",aJ.SEI_MESSAGE="sei-message",aJ.ERROR="error",aJ.REMOTE_PUBLISH_STATE_CHANGED="remote-publish-state-changed",aJ.REMOTE_PUBLISHED="remote-published",aJ.REMOTE_UNPUBLISHED="remote-unpublished",aJ.FIREWALL_RESTRICTION="firewall-restriction",aJ.HEARTBEAT_REPORT="heartbeat-report",aJ.CUSTOM_MESSAGE="custom-message",aJ.LAYER_DATA="layerData",aJ.FIRST_VIDEO_FRAME="first-video-frame",aJ.DUMP="dump",aJ),_J=((oJ=_J||{}).PLAYER_STATE_CHANGED="player-state-changed",oJ.MUTE="mute",oJ.UNMUTE="unmute",oJ.ERROR="error",oJ.INPUT_MEDIA_TRACK_CHANGED="input-media-track-changed",oJ.OUTPUT_MEDIA_TRACK_CHANGED="output-media-track-changed",oJ.FIRST_VIDEO_FRAME="first-video-frame",oJ),gJ=function(e){return e.DECODE_FAILED="decode-failed",e.DECODE_DOWNGRADE_STATE_CHANGED="decode-downgrade-state-changed",e}(gJ||{}),yJ=function(e){return e[e.VIDEO=1]="VIDEO",e[e.SMALL=2]="SMALL",e[e.AUX=4]="AUX",e[e.AUDIO=8]="AUDIO",e[e.VIDEO_MUTE=16]="VIDEO_MUTE",e[e.AUX_MUTE=32]="AUX_MUTE",e[e.AUDIO_MUTE=64]="AUDIO_MUTE",e}(yJ||{}),EJ=function(e){return e[e.RTC=1]="RTC",e[e.LIVE=2]="LIVE",e}(EJ||{}),TJ=function(e){return e[e.ANCHOR=20]="ANCHOR",e[e.AUDIENCE=21]="AUDIENCE",e}(TJ||{}),kJ=function(e){return e.ANCHOR="anchor",e.AUDIENCE="audience",e}(kJ||{}),SJ=function(e){return e.CONNECTED="CONNECTED",e.DISCONNECTED="DISCONNECTED",e.CONNECTING="CONNECTING",e.RECONNECTED="RECONNECTED",e.RECONNECTING="RECONNECTING",e}(SJ||{}),IJ=((iJ=IJ||{}).INITIALIZED="INITIALIZED",iJ.STARTING="STARTING",iJ.STARTED="STARTED",iJ.FAILED="FAILED",iJ),bJ=function(e){return e.INITIALIZED="INITIALIZED",e.STARTING="STARTING",e.STARTED="STARTED",e.FAILED="FAILED",e}(bJ||{}),AJ=function(e){return e.AUDIO="audio",e.VIDEO="video",e.AUXILIARY="auxVideo",e}(AJ||{}),RJ=function(e){return e.ADD="add",e.REMOVE="remove",e}(RJ||{}),CJ=function(e){return e[e.NULL=0]="NULL",e[e.AUDIO=1]="AUDIO",e[e.AUX_VIDEO=2]="AUX_VIDEO",e[e.BIG_VIDEO=4]="BIG_VIDEO",e[e.SMALL_VIDEO=8]="SMALL_VIDEO",e}(CJ||{}),wJ={1:"audio",2:"auxVideo",4:"video"},DJ=((rJ=DJ||{})[rJ.opus=111]="opus",rJ),NJ=function(e){return e[e.h264=100]="h264",e[e.vp8=101]="vp8",e}(NJ||{}),xJ=function(e){return e.Big="big",e.Small="small",e}(xJ||{}),OJ=function(e){return e.Main="main",e.Aux="auxiliary",e}(OJ||{}),PJ=function(e){return e[e.MULTI_DATA_AUDIO=1]="MULTI_DATA_AUDIO",e[e.MULTI_DATA_BIG_IMG=2]="MULTI_DATA_BIG_IMG",e[e.MULTI_DATA_SMALL_IMG=3]="MULTI_DATA_SMALL_IMG",e[e.MULTI_DATA_AUX_IMG=7]="MULTI_DATA_AUX_IMG",e[e.MULTI_DATA_TYPE_BUTT=12]="MULTI_DATA_TYPE_BUTT",e}(PJ||{}),MJ=((nJ=MJ||{})[nJ.PUBLISH_VIDEO=32768]="PUBLISH_VIDEO",nJ[nJ.PUBLISH_AUDIO=32769]="PUBLISH_AUDIO",nJ[nJ.UNPUBLISH_VIDEO=32770]="UNPUBLISH_VIDEO",nJ[nJ.UNPUBLISH_AUDIO=32771]="UNPUBLISH_AUDIO",nJ[nJ.MUTE_AUDIO=32772]="MUTE_AUDIO",nJ[nJ.MUTE_VIDEO=32773]="MUTE_VIDEO",nJ[nJ.UNMUTE_AUDIO=32774]="UNMUTE_AUDIO",nJ[nJ.UNMUTE_VIDEO=32775]="UNMUTE_VIDEO",nJ[nJ.SUBSCRIBE_VIDEO=32776]="SUBSCRIBE_VIDEO",nJ[nJ.SUBSCRIBE_AUDIO=32777]="SUBSCRIBE_AUDIO",nJ[nJ.UNSUBSCRIBE_VIDEO=32778]="UNSUBSCRIBE_VIDEO",nJ[nJ.UNSUBSCRIBE_AUDIO=32779]="UNSUBSCRIBE_AUDIO",nJ[nJ.SWITCH_CAMERA=32780]="SWITCH_CAMERA",nJ[nJ.SWITCH_MICROPHONE=32781]="SWITCH_MICROPHONE",nJ[nJ.REPLACE_VIDEO=32782]="REPLACE_VIDEO",nJ[nJ.REPLACE_AUDIO=32783]="REPLACE_AUDIO",nJ[nJ.MUTE_REMOTE_VIDEO=32784]="MUTE_REMOTE_VIDEO",nJ[nJ.MUTE_REMOTE_AUDIO=32785]="MUTE_REMOTE_AUDIO",nJ[nJ.UNMUTE_REMOTE_VIDEO=32786]="UNMUTE_REMOTE_VIDEO",nJ[nJ.UNMUTE_REMOTE_AUDIO=32787]="UNMUTE_REMOTE_AUDIO",nJ[nJ.JOIN=32788]="JOIN",nJ[nJ.LEAVE=32789]="LEAVE",nJ[nJ.SIGNAL_DISCONNECTED=32790]="SIGNAL_DISCONNECTED",nJ[nJ.SIGNAL_CONNECTED=32791]="SIGNAL_CONNECTED",nJ[nJ.TRANSPORT_UPLINK_CONNECTED=32792]="TRANSPORT_UPLINK_CONNECTED",nJ[nJ.TRANSPORT_DOWNLINK_CONNECTED=32793]="TRANSPORT_DOWNLINK_CONNECTED",nJ[nJ.SIGNAl_RECONNECTING=32794]="SIGNAl_RECONNECTING",nJ[nJ.SIGNAL_RECONNECT_SUCCESS=32795]="SIGNAL_RECONNECT_SUCCESS",nJ[nJ.SIGNAL_RECONNECT_FAIL=32796]="SIGNAL_RECONNECT_FAIL",nJ[nJ.TRANSPORT_UPLINK_RECONNECTING=32797]="TRANSPORT_UPLINK_RECONNECTING",nJ[nJ.TRANSPORT_UPLINK_RECONNECT_SUCCESS=32798]="TRANSPORT_UPLINK_RECONNECT_SUCCESS",nJ[nJ.TRANSPORT_UPLINK_RECONNECT_FAIL=32799]="TRANSPORT_UPLINK_RECONNECT_FAIL",nJ[nJ.TRANSPORT_DOWNLINK_RECONNECTING=32800]="TRANSPORT_DOWNLINK_RECONNECTING",nJ[nJ.TRANSPORT_DOWNLINK_RECONNECT_SUCCESS=32801]="TRANSPORT_DOWNLINK_RECONNECT_SUCCESS",nJ[nJ.TRANSPORT_DOWNLINK_RECONNECT_FAIL=32802]="TRANSPORT_DOWNLINK_RECONNECT_FAIL",nJ[nJ.SUBSCRIBE_SMALL_VIDEO=32803]="SUBSCRIBE_SMALL_VIDEO",nJ[nJ.UNSUBSCRIBE_SMALL_VIDEO=32804]="UNSUBSCRIBE_SMALL_VIDEO",nJ[nJ.PUBLISH_AUX=32805]="PUBLISH_AUX",nJ[nJ.UNPUBLISH_AUX=32806]="UNPUBLISH_AUX",nJ[nJ.DEVICE_CAPTURE=2003]="DEVICE_CAPTURE",nJ[nJ.VIDEO_ENCODER=4004]="VIDEO_ENCODER",nJ[nJ.VIDEO_DECODER=4005]="VIDEO_DECODER",nJ),LJ=function(e){return e[e.UNKNOWN=0]="UNKNOWN",e[e.EXCELLENT=1]="EXCELLENT",e[e.GOOD=2]="GOOD",e[e.POOR=3]="POOR",e[e.BAD=4]="BAD",e[e.VERY_BAD=5]="VERY_BAD",e[e.DISCONNECTED=6]="DISCONNECTED",e}(LJ||{}),VJ=function(e){return e[e.MANUAL=0]="MANUAL",e[e.AUTO_AUDIO=1]="AUTO_AUDIO",e[e.AUTO_VIDEO=2]="AUTO_VIDEO",e[e.AUTO_ALL=3]="AUTO_ALL",e}(VJ||{}),UJ=function(e){return e.user="user",e.environment="environment",e}(UJ||{}),FJ=function(e){return e[e.ELEMENT=0]="ELEMENT",e[e.CANVAS_FROM_ELEMENT=1]="CANVAS_FROM_ELEMENT",e[e.CANVAS_WITHOUT_ELEMENT=2]="CANVAS_WITHOUT_ELEMENT",e}(FJ||{}),BJ=function(e){return e[e.ELEMENT=0]="ELEMENT",e[e.CONTEXT=1]="CONTEXT",e}(BJ||{}),HJ=function(e){return e.BANNED="banned",e.KICK="kick",e.USER_TIME_OUT="user_time_out",e.ROOM_DISBAND="room_disband",e}(HJ||{}),jJ=((tJ=jJ||{})[tJ.USER_EXIT_REASON_TC_USER_EXIT_NORMAL=0]="USER_EXIT_REASON_TC_USER_EXIT_NORMAL",tJ[tJ.USER_EXIT_REASON_TC_USER_EXIT_TIMEOUT=1]="USER_EXIT_REASON_TC_USER_EXIT_TIMEOUT",tJ[tJ.USER_EXIT_REASON_TC_USER_EXIT_KICKED=2]="USER_EXIT_REASON_TC_USER_EXIT_KICKED",tJ[tJ.USER_EXIT_REASON_TC_USER_EXIT_CHANGED=3]="USER_EXIT_REASON_TC_USER_EXIT_CHANGED",tJ[tJ.USER_KICK_OUT_CODE_BUSINESS_USER=4]="USER_KICK_OUT_CODE_BUSINESS_USER",tJ[tJ.USER_KICK_OUT_CODE_BUSINESS_ROOM=5]="USER_KICK_OUT_CODE_BUSINESS_ROOM",tJ[tJ.USER_KICK_OUT_CODE_SERVER_USER=6]="USER_KICK_OUT_CODE_SERVER_USER",tJ[tJ.USER_KICK_OUT_CODE_SERVER_ROOM=7]="USER_KICK_OUT_CODE_SERVER_ROOM",tJ[tJ.USER_KICK_SESS_EXSIT=8]="USER_KICK_SESS_EXSIT",tJ),GJ=1e8,WJ=function(){return s((function e(){i(this,e),FF(this,"mediaType",0)}),[{key:"audio",get:function(){return!!(1&this.mediaType)},set:function(e){e?this.mediaType|=1:this.mediaType&=-2}},{key:"video",get:function(){return!!(4&this.mediaType)},set:function(e){e?this.mediaType|=4:this.mediaType&=-5}},{key:"auxiliary",get:function(){return!!(2&this.mediaType)},set:function(e){e?this.mediaType|=2:this.mediaType&=-3}},{key:"smallVideo",get:function(){return!!(8&this.mediaType)},set:function(e){e?this.mediaType|=8:this.mediaType&=-9}}])}(),JJ=function(e){return e.String="string",e.Number="number",e.Boolean="boolean",e.Array="array",e.Object="object",e}(JJ||{}),KJ=function(e){return e.H264="h264",e.H265="h265",e.VP8="vp8",e}(KJ||{}),zJ=function(e){return e[e.ENCRYPT_AND_DECRYPT=0]="ENCRYPT_AND_DECRYPT",e[e.DUMP=1]="DUMP",e[e.SEI=2]="SEI",e[e.ENCODE_AND_DECODE=3]="ENCODE_AND_DECODE",e}(zJ||{}),qJ=function(e){return e[e.ENCRYPT_AND_DECRYPT=0]="ENCRYPT_AND_DECRYPT",e[e.NTP_TO_AUDIO_FRAME=1]="NTP_TO_AUDIO_FRAME",e[e.DUMP=2]="DUMP",e[e.ENCODE_AND_DECODE=3]="ENCODE_AND_DECODE",e}(qJ||{}),YJ=function(e){return e.WebRTC="webrtc",e.WebCodecs="webcodecs",e.WebAssembly="webassembly",e}(YJ||{}),XJ=((eJ=XJ||{})[eJ.SUCCESS=0]="SUCCESS",eJ[eJ.FAILED=1]="FAILED",eJ[eJ.WEBCODEC_INIT=2]="WEBCODEC_INIT",eJ[eJ.WEBCODEC_CONFIG_NOT_SUPPORT=3]="WEBCODEC_CONFIG_NOT_SUPPORT",eJ[eJ.WEBCODEC_DECODER_ERROR=4]="WEBCODEC_DECODER_ERROR",eJ[eJ.WEBCODEC_TRACK_MUTE=5]="WEBCODEC_TRACK_MUTE",eJ[eJ.WASM_INIT=6]="WASM_INIT",eJ[eJ.WASM_WEBGL_UNAVALIABLE=7]="WASM_WEBGL_UNAVALIABLE",eJ[eJ.WASM_DECODER_ERROR=8]="WASM_DECODER_ERROR",eJ[eJ.WASM_TRACK_MUTE=9]="WASM_TRACK_MUTE",eJ[eJ.TEST=10]="TEST",eJ),QJ=function(e){return e.NONE="",e.DETAIL="detail",e.MOTION="motion",e.TEXT="text",e}(QJ||{}),$J=function(e){return e.INTERVAL="interval",e.TIMEOUT="timeout",e.RAF="raf",e.RIC="ric",e.INTERVAL_IN_WORKER="intervalInWorker",e}($J||{}),ZJ={AVOID_REPEATED_CALL:"AVOID_REPEATED_CALL",INVALID_PARAMETER_REQUIRED:"INVALID_PARAMETER_REQUIRED",INVALID_PARAMETER_TYPE:"INVALID_PARAMETER_TYPE",INVALID_PARAMETER_EMPTY:"INVALID_PARAMETER_EMPTY",INVALID_PARAMETER_INSTANCE:"INVALID_PARAMETER_INSTANCE",INVALID_PARAMETER_RANGE:"INVALID_PARAMETER_RANGE",INVALID_PARAMETER_MIN:"INVALID_PARAMETER_MIN",INVALID_PARAMETER_MAX:"INVALID_PARAMETER_MAX",INVALID_PARAMETER_STREAMTYPE:"INVALID_PARAMETER_STREAMTYPE",API_CALL_TIMEOUT:"API_CALL_TIMEOUT",SIGNAL_CHANNEL_RECONNECTION_FAILED:"SIGNAL_CHANNEL_RECONNECTION_FAILED",SIGNAL_CHANNEL_SETUP_FAILED:"SIGNAL_CHANNEL_SETUP_FAILED",ERROR_MESSAGE:"ERROR_MESSAGE",EXCHANGE_SDP_TIMEOUT:"EXCHANGE_SDP_TIMEOUT",DOWNLINK_RECONNECTION_FAILED:"DOWNLINK_RECONNECTION_FAILED",EXCHANGE_SDP_FAILED:"EXCHANGE_SDP_FAILED",UPDATE_OFFER_TIMEOUT:"UPDATE_OFFER_TIMEOUT",UPLINK_RECONNECTION_FAILED:"UPLINK_RECONNECTION_FAILED",INVALID_RECORDID:"INVALID_RECORDID",INVALID_PURE_AUDIO:"INVALID_PURE_AUDIO",INVALID_STREAMID:"INVALID_STREAMID",INVALID_USER_DEFINE_RECORDID:"INVALID_USER_DEFINE_RECORDID",INVALID_USER_DEFINE_PUSH_ARGS:"INVALID_USER_DEFINE_PUSH_ARGS",INVALID_PROXY:"INVALID_PROXY",INVALID_JOIN:"INVALID_JOIN",INVALID_ROOMID_STRING:"INVALID_ROOMID_STRING",INVALID_ROOMID_INTEGER:"INVALID_ROOMID_INTEGER",INVALID_SIGNAL_CHANNEL:"INVALID_SIGNAL_CHANNEL",JOIN_ROOM_TIMEOUT:"JOIN_ROOM_TIMEOUT",JOIN_ROOM_FAILED:"JOIN_ROOM_FAILED",REJOIN_ROOM_FAILED:"REJOIN_ROOM_FAILED",INVALID_DESTROY:"INVALID_DESTROY",INVALID_PUBLISH:"INVALID_PUBLISH",INVALID_UNPUBLISH:"INVALID_UNPUBLISH",INVALID_AUDIENCE:"INVALID_AUDIENCE",INVALID_INITIALIZE:"INVALID_INITIALIZE",INVALID_DUPLICATE_PUBLISHING:"INVALID_DUPLICATE_PUBLISHING",INVALID_SUBSCRIBE_UNDEFINED:"INVALID_SUBSCRIBE_UNDEFINED",INVALID_SUBSCRIBE_LOCAL:"INVALID_SUBSCRIBE_LOCAL",INVALID_REMOTE_STREAM:"INVALID_REMOTE_STREAM",SUBSCRIBE_FAILED:"SUBSCRIBE_FAILED",INVALID_ROLE:"INVALID_ROLE",INVALID_PARAMETER_SWITCH_ROLE:"INVALID_PARAMETER_SWITCH_ROLE",INVALID_OPERATION_SWITCH_ROLE:"INVALID_OPERATION_SWITCH_ROLE",SWITCH_ROLE_TIMEOUT:"SWITCH_ROLE_TIMEOUT",SWITCH_ROLE_FAILED:"SWITCH_ROLE_FAILED",CLIENT_BANNED:"CLIENT_BANNED",INVALID_OPERATION_START_PUBLISH_CDN:"INVALID_OPERATION_START_PUBLISH_CDN",INVALID_OPERATION_STOP_PUBLISH_CDN:"INVALID_OPERATION_STOP_PUBLISH_CDN",INVALID_STREAM_ID:"INVALID_STREAM_ID",START_PUBLISH_CDN_FAILED:"START_PUBLISH_CDN_FAILED",STOP_PUBLISH_CDN_FAILED:"STOP_PUBLISH_CDN_FAILED",START_MIX_TRANSCODE:"START_MIX_TRANSCODE",STOP_MIX_TRANSCODE:"STOP_MIX_TRANSCODE",INVALID_AUDIO_VOLUME:"INVALID_AUDIO_VOLUME",ENABLE_SMALL_STREAM_PUBLISHED:"ENABLE_SMALL_STREAM_PUBLISHED",DISABLE_SMALL_STREAM_PUBLISHED:"DISABLE_SMALL_STREAM_PUBLISHED",NOT_SUPPORTED_SMALL_STREAM:"NOT_SUPPORTED_SMALL_STREAM",INVALID_SMALL_STREAM_PROFILE:"INVALID_SMALL_STREAM_PROFILE",INVALID_PARAMETER_REMOTE_STREAM:"INVALID_PARAMETER_REMOTE_STREAM",INVALID_OPERATION_CHANGE_SMALL:"INVALID_OPERATION_CHANGE_SMALL",REMOTE_NOT_PUBLISH_SMALL_STREAM:"REMOTE_NOT_PUBLISH_SMALL_STREAM",INVALID_SWITCH_DEVICE:"INVALID_SWITCH_DEVICE",INVALID_SWITCH_DEVICE_PUBLISHING:"INVALID_SWITCH_DEVICE_PUBLISHING",INVALID_REPLACE_TRACK:"INVALID_REPLACE_TRACK",INVALID_INITIALIZE_LOCAL_STREAM:"INVALID_INITIALIZE_LOCAL_STREAM",INVALID_ADD_TRACK_REPETITIVE:"INVALID_ADD_TRACK_REPETITIVE",INVALID_ADD_TRACK_REMOVING:"INVALID_ADD_TRACK_REMOVING",INVALID_ADD_TRACK_PUBLISHING:"INVALID_ADD_TRACK_PUBLISHING",INVALID_STREAM_INITIALIZED:"INVALID_STREAM_INITIALIZED",INVALID_ADD_TRACK_NUMBER:"INVALID_ADD_TRACK_NUMBER",INVALID_REMOVE_AUDIO_TRACK:"INVALID_REMOVE_AUDIO_TRACK",INVALID_REMOVE_AUDIO_ADDING:"INVALID_REMOVE_AUDIO_ADDING",INVALID_REMOVE_AUDIO_ON:"INVALID_REMOVE_AUDIO_ON",INVALID_REMOVE_TRACK_PUBLISHING:"INVALID_REMOVE_TRACK_PUBLISHING",INVALID_REMOVE_TRACK_NOT_TRACK:"INVALID_REMOVE_TRACK_NOT_TRACK",INVALID_REMOVE_TRACK_NUMBER:"INVALID_REMOVE_TRACK_NUMBER",INVALID_REPLACE_TRACK_NO_TRACK:"INVALID_REPLACE_TRACK_NO_TRACK",REPEAT_JOIN:"REPEAT_JOIN",CLIENT_DESTROYED:"CLIENT_DESTROYED",NOT_BUG_PACKAGE:"NOT_BUG_PACKAGE",START_MIX_TRANSCODE_FAILED:"START_MIX_TRANSCODE_FAILED",STOP_MIX_TRANSCODE_FAILED:"STOP_MIX_TRANSCODE_FAILED",MIX_TRANSCODE_NOT_STARTED:"MIX_TRANSCODE_NOT_STARTED",CANNOT_LESS_THAN_ZERO:"CANNOT_LESS_THAN_ZERO",MIX_PARAMS_VIDEO_FRAMERATE:"MIX_PARAMS_VIDEO_FRAMERATE",MIX_PARAMS_VIDEO_GOP:"MIX_PARAMS_VIDEO_GOP",MIX_PARAMS_AUDIO_BITRATE:"MIX_PARAMS_AUDIO_BITRATE",MIX_PARAMS_USER_Z_ORDER:"MIX_PARAMS_USER_Z_ORDER",MIX_PARAMS_NOT_SELF:"MIX_PARAMS_NOT_SELF",MIX_PARAMS_USER_STREAM:"MIX_PARAMS_USER_STREAM",INVALID_PLAY:"INVALID_PLAY",INVALID_ELEMENT_ID:"INVALID_ELEMENT_ID",INVALID_ELEMENT_ID_TYPE:"INVALID_ELEMENT_ID_TYPE",PLAY_FAILED:"PLAY_FAILED",INVALID_USERID:"INVALID_USERID",INVALID_CREATE_STREAM_SOURCE:"INVALID_CREATE_STREAM_SOURCE",INVALID_CREATE_STREAM_SCREEN:"INVALID_CREATE_STREAM_SCREEN",INVALID_CREATE_STREAM_AUDIO:"INVALID_CREATE_STREAM_AUDIO",INVALID_CREATE_STREAM_SCREEN_AUDIO:"INVALID_CREATE_STREAM_SCREEN_AUDIO",NOT_SUPPORTED_HTTP:"NOT_SUPPORTED_HTTP",NOT_SUPPORTED_WEBRTC:"NOT_SUPPORTED_WEBRTC",NOT_SUPPORTED_PROFILE:"NOT_SUPPORTED_PROFILE",NOT_SUPPORTED_MEDIA:"NOT_SUPPORTED_MEDIA",NOT_SUPPORTED_H264ENCODE:"NOT_SUPPORTED_H264ENCODE",NOT_SUPPORTED_H264DECODE:"NOT_SUPPORTED_H264DECODE",NOT_SUPPORTED_TRACK:"NOT_SUPPORTED_TRACK",NOT_SUPPORTED_SWITCH_DEVICE:"NOT_SUPPORTED_SWITCH_DEVICE",NOT_SUPPORTED_CAPTURE:"NOT_SUPPORTED_CAPTURE",NOT_SUPPORTED_AUX:"NOT_SUPPORTED_AUX",MICROPHONE_NOT_FOUND:"MICROPHONE_NOT_FOUND",CAMERA_NOT_FOUND:"CAMERA_NOT_FOUND",SIGNAL_RESPONSE_FAILED:"SIGNAL_RESPONSE_FAILED",CATCH_HANDLER_ERROR:"CATCH_HANDLER_ERROR",API_NOT_EXIST:"API_NOT_EXIST",CONNECTION_CLOSED:"CONNECTION_CLOSED",SUBSCRIBE_ALL_FALSE:"SUBSCRIBE_ALL_FALSE",SEI_NOT_SUPPORT:"SEI_NOT_SUPPORT",SEI_DISABLED:"SEI_DISABLED",SEI_BEFORE_PUBLISH:"SEI_BEFORE_PUBLISH",SEI_NOT_VIDEO:"SEI_NOT_VIDEO",CALL_FREQUENCY_LIMIT:"CALL_FREQUENCY_LIMIT",CONNECTION_ABORTED:"CONNECTION_ABORTED",API_CALL_ABORTED:"API_CALL_ABORTED",DUPLICATE_AUX:"DUPLICATE_AUX"},eK={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(ij(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(ij(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,".")},INVALID_PARAMETER_MIN:function(e){var t=e.key,n=e.rule;e.fnName;var r=e.value;return"the min value of ".concat(t||n.name," is ").concat(n.min,", received: ").concat(r,".")},INVALID_PARAMETER_MAX:function(e){var t=e.key,n=e.rule;e.fnName;var r=e.value;return"the max value of ".concat(t||n.name," is ").concat(n.max,", 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/audience, please call switchRole("anchor") firstly before publish().',INVALID_INITIALIZE:"cannot publish stream because stream is not initialized, is switching device, or has been closed.",INVALID_DUPLICATE_PUBLISHING: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.userId,r=e.streamType;return"failed to subscribe ".concat(n," ").concat(r," 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 anchor or audience.",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 ".concat(e.message,".")},INVALID_OPERATION_START_PUBLISH_CDN:"please call startPublishCDNStream() after join room and publish the local stream.",INVALID_OPERATION_STOP_PUBLISH_CDN:"please call startPublishCDNStream() before stopPublishCDNStream().",START_PUBLISH_CDN_FAILED: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_TRACK:"localStream has not this track.",INVALID_REMOVE_TRACK_NUMBER:"remove the only video track is not supported, please use replaceTrack or muteVideo.",INVALID_REPLACE_TRACK_NO_TRACK:function(e){return"cannot replace ".concat(e.kind," track because stream has not ").concat(e.kind," track")},NOT_BUG_PACKAGE:"You need to buy packages, refer to tencent console.",START_MIX_TRANSCODE_FAILED: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 HTMLElement when calling ").concat(n,"(), received: ").concat(r,".")},PLAY_FAILED:function(e){return"".concat(e.media," play failed, browser exception: ").concat(e.error.toString())},INVALID_USERID:"userId cannot be all spaces.",INVALID_CREATE_STREAM_SOURCE:"LocalStream must be created by createStream() with either audio/video or audioSource/videoSource, but can not be mixed with audio/video and audioSource/videoSource.",INVALID_CREATE_STREAM_SCREEN:"screen/video cannot be both true.",INVALID_CREATE_STREAM_AUDIO:"audio/screenAudio cannot be both true.",INVALID_CREATE_STREAM_SCREEN_AUDIO:"when screen is true, screenAudio can be configured.",NOT_SUPPORTED_HTTP:"http protocol does not support the ability to capture microphone, camera and screen. please use https to deploy your page.",NOT_SUPPORTED_WEBRTC:"your browser or environment does not support full WebRTC capabilities.",NOT_SUPPORTED_PROFILE:"your browser does not support setVideoProfile.",NOT_SUPPORTED_MEDIA:"your browser or environment does not support navigator.mediaDevices.",NOT_SUPPORTED_H264ENCODE:"your device does not support H.264 encoding.",NOT_SUPPORTED_H264DECODE:"your device does not support H.264 decoding.",NOT_SUPPORTED_TRACK: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.",CAMERA_NOT_FOUND:"no camera detected, please check your camera.",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 in ".concat(t,".on('").concat(n,"', handler), please check your code in 'handler'.")},API_NOT_EXIST:function(e){var t=e.name;return"experimental api ".concat(t," does not exist.")},REPEAT_JOIN:function(e){return"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(!1===e?" without using h264 codec":"")},SEI_DISABLED:"SEI is disabled",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?"".concat(i," bytes"):r," in a second.")},CONNECTION_ABORTED:function(e){return"connection aborted due to: ".concat(e)},API_CALL_ABORTED:function(e){return e.message.includes("REMOTE_STREAM_NOT_EXIST")?"Subscribe ".concat(e.userId," ").concat(e.streamType," stream aborted, reason: remote user ").concat(e.userId," unpublished stream."):"API aborted, reason: ".concat(e.message)},DUPLICATE_AUX:"only one auxiliary stream can be published in a room.",NOT_SUPPORTED_AUX:"publish auxiliary stream is not supported on your browser.",INVALID_PARAMETER_STREAMTYPE:function(e){return"'streamType' is required when 'userId' is not '*', calling ".concat(e,"()")}},tK=function(e,t){return t?"".concat(kB,"/").concat(e,"/").concat(t):"".concat(kB,"/").concat(e,"/index.html")},nK=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 e=null==localStorage?void 0:localStorage.getItem(RB);if(e){e=JSON.parse(e);var t=document.createElement("script");t.type="text/javascript",t.text=e.message,document.body.appendChild(t);var n=window.TRTC_ERROR_INFO,r=window.TRTC_ERROR_LINK;return document.body.removeChild(t),{TRTC_ERROR_INFO:n,TRTC_ERROR_LINK:r}}return{}};function rK(e){var t=e.key,n=e.data,r=e.link,i=e.addDocLink,o=void 0===i||i,a="",s="",c="";oj(eK[t])?a=eK[t](n):sj(eK[t])&&(a=eK[t]);var u=nK(),l=u.TRTC_ERROR_INFO,d=u.TRTC_ERROR_LINK;r?c="".concat(r.className,".html#").concat(r.fnName):d&&d[t]&&(oj(d[t])?c=d[t](n):sj(d[t])&&(c=d[t]));var h=a;return ej()&&(l&&l[t]&&(oj(l[t])?s=l[t](n):sj(l[t])&&(s=l[t])),s&&(h=o?"".concat(s,"\n请查看文档: ").concat(tK("zh-cn",c),"\n\n"):"".concat(s,"\n\n"),h+=a)),o&&(h+=" \nRefer to: ".concat(tK("en",c),"\n")),h}var iK,oK=VF(KF(),1),aK=function(){return s((function e(){var t=this,n=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];i(this,e),FF(this,"countMap",new Map),FF(this,"distributionMap",new Map),FF(this,"version"),FF(this,"log",qW.createLogger({id:"kv"})),n&&(HW.on("102",(function(e){var n=e.track,r=e.cost;t.addSuccessEvent({key:n.kind===UB.AUDIO?501700:511700,cost:r})})),HW.on("103",(function(e){var n=e.track,r=e.error;t.addFailedEvent({key:n.kind===UB.AUDIO?501700:511700,error:r})})))}),[{key:"getReportData",value:function(){var e={msg_sdk_basic_info:{uint32_sdk_version:Vj(this.version||uB),uint32_terminal_type:15,bytes_device_name:"",bytes_os_version:"",uint32_framework:30,uint32_network_type:0},stats_count:T(this.countMap.entries()).map((function(e){var t=_(e,2);return{uint32_key:t[0],uint32_count:t[1]}})),stats_distribution:T(this.distributionMap.entries()).map((function(e){var t=_(e,2);return{uint32_key:t[0],distribution_items:T(t[1].entries()).map((function(e){var t=_(e,2);return{uint32_item_key:t[0],uint32_item_value:t[1]}}))}}))};return this.countMap.clear(),this.distributionMap.clear(),e}},{key:"clear",value:function(){this.countMap.clear(),this.distributionMap.clear()}},{key:"isEnumKey",value:function(e){var t=+String(e).slice(-3);return t>=700&&t<799}},{key:"isErrorCodeKey",value:function(e){var t=+String(e).slice(-3);return t>=600&&t<699}},{key:"isCountKey",value:function(e){var t=+String(e).slice(-3);return t>=0&&t<599}},{key:"isNumberKey",value:function(e){var t=+String(e).slice(-3);return t>=800&&t<899}},{key:"addCount",value:function(e){var t=e.key,n=e.useUV,r=void 0!==n&&n;this.isCountKey(t)?r&&this.countMap.has(t)||this.countMap.set(t,(this.countMap.get(t)||0)+1):this.log.debug("".concat(t," is not count key, last 3 number should be 0~599"))}},{key:"addEnum",value:function(e){var t,n=e.key,r=e.value,i=e.useUV,o=void 0===i||i;if(!this.isEnumKey(n))return this.log.debug("".concat(n," is not enum key, last 3 number should be 700~799"));if(!o||!this.countMap.has(n)){this.countMap.set(n,(this.countMap.get(n)||0)+1);var a=(null==(t=this.distributionMap)?void 0:t.get(n))||new Map;a.set(r,(a.get(r)||0)+1),this.distributionMap.set(n,a)}}},{key:"addNumber",value:function(e){var t,n=e.key,r=e.value,i=e.split,o=void 0===i?100:i,a=e.useUV,s=void 0!==a&&a;if(!this.isNumberKey(n))return this.log.debug("".concat(n," is not number key, last 3 number should be 800~899"));if(!s||!this.countMap.has(n)){this.countMap.set(n,(this.countMap.get(n)||0)+1);var c=(null==(t=this.distributionMap)?void 0:t.get(n))||new Map,u=0;if(cj(o))u=Math.floor(r/o);else for(var l=o.length-1;l>0;l--)if(r>o[l]){u=l;break}c.set(u,(c.get(u)||0)+1),this.distributionMap.set(n,c)}}},{key:"addSuccessEvent",value:function(e){var t=e.key,n=e.cost,r=e.timeKey,i=e.split;if(t&&(this.addEnum({key:t,value:1,useUV:!1}),n)){var o=+String(t).slice(-3);o<800&&o>=700?this.addNumber({key:r||t+100,value:n,split:i}):r||this.log.debug("time stat ignored, ".concat(t))}}},{key:"addFailedEvent",value:function(e){var t=e.key,n=e.error;if(t){var r=ZF.UNKNOWN;n&&(cj(n)?r=n:(!aj(n.extraCode)||!aj(n.code))&&(r=n.extraCode||n.code)),this.addEnum({key:t,value:0,useUV:!1}),this.addEnum({key:t,value:Math.abs(r),useUV:!1})}}}])}(),sK=((iK=sK||{})[iK.enterRoom=500700]="enterRoom",iK[iK.exitRoom=500701]="exitRoom",iK[iK.switchRole=500702]="switchRole",iK[iK.destroy=500703]="destroy",iK[iK.startLocalAudio=500704]="startLocalAudio",iK[iK.updateLocalAudio=500705]="updateLocalAudio",iK[iK.stopLocalAudio=500706]="stopLocalAudio",iK[iK.startLocalVideo=500707]="startLocalVideo",iK[iK.updateLocalVideo=500708]="updateLocalVideo",iK[iK.stopLocalVideo=500709]="stopLocalVideo",iK[iK.startScreenShare=500710]="startScreenShare",iK[iK.updateScreenShare=500711]="updateScreenShare",iK[iK.stopScreenShare=500712]="stopScreenShare",iK[iK.startRemoteVideo=500713]="startRemoteVideo",iK[iK.updateRemoteVideo=500714]="updateRemoteVideo",iK[iK.stopRemoteVideo=500715]="stopRemoteVideo",iK[iK.muteRemoteAudio=500716]="muteRemoteAudio",iK[iK.setRemoteAudioVolume=500717]="setRemoteAudioVolume",iK[iK.use=500718]="use",iK[iK.sendSEIMessage=5e5]="sendSEIMessage",iK[iK.sendCustomMessage=500001]="sendCustomMessage",iK),cK=function(e){return e[e.AudioMixer=550700]="AudioMixer",e[e.AIDenoiser=551700]="AIDenoiser",e[e.VirtualBackground=570700]="VirtualBackground",e[e.Beauty=571700]="Beauty",e[e.Watermark=572700]="Watermark",e[e.BasicBeauty=574700]="BasicBeauty",e[e.CDNStreaming=590700]="CDNStreaming",e[e.DeviceDetector=591700]="DeviceDetector",e[e.Debug=592700]="Debug",e}(cK||{}),uK=function(e){return e[e.AudioMixer=550701]="AudioMixer",e[e.AIDenoiser=551701]="AIDenoiser",e[e.VirtualBackground=570701]="VirtualBackground",e[e.Beauty=571701]="Beauty",e[e.Watermark=572701]="Watermark",e[e.BasicBeauty=574701]="BasicBeauty",e[e.CDNStreaming=590701]="CDNStreaming",e[e.DeviceDetector=591701]="DeviceDetector",e[e.Debug=592701]="Debug",e}(uK||{}),lK=function(e){return e[e.AudioMixer=550702]="AudioMixer",e[e.AIDenoiser=551702]="AIDenoiser",e[e.VirtualBackground=570702]="VirtualBackground",e[e.Beauty=571702]="Beauty",e[e.Watermark=572702]="Watermark",e[e.BasicBeauty=574702]="BasicBeauty",e[e.CDNStreaming=590702]="CDNStreaming",e[e.DeviceDetector=591702]="DeviceDetector",e[e.Debug=592702]="Debug",e}(lK||{}),dK=new aK(!0),hK=new aK(!1),fK=dK,pK={result:!1,detail:{isBrowserSupported:!1,isWebRTCSupported:!1,isWebCodecsSupported:!1,isMediaDevicesSupported:!1,isScreenShareSupported:!1,isSmallStreamSupported:!1,isH264EncodeSupported:!1,isVp8EncodeSupported:!1,isH264DecodeSupported:!1,isVp8DecodeSupported:!1}},mK=new Map([[fG,["Firefox",pG]],[gG,["Edg",yG]],[hW,["Chrome",mW]],[vW,["Safari",gW]],[bG,["TBS",AG]],[RG,["XWEB",CG]],[xG&&aG,["WeChat",OG]],[VG,["QQ(Win)",UG]],[MG,["QQ(Mobile)",LG]],[PG,["QQ(Mobile X5)",LG]],[FG,["QQ(Mac)",BG]],[HG,["QQ(iPad)",jG]],[XG,["MI",QG]],[$G,["HW",tW]],[nW,["Samsung",rW]],[iW,["OPPO",oW]],[aW,["VIVO",sW]],[vG,["EDGE",_G]],[TG,["SogouMobile",kG]],[SG,["Sogou",IG]]]);function vK(){var e=mK.get(!0);return{browserName:e?e[0]:"unknown",browserVersion:e?e[1]:"unknown"}}var _K=function(){return!(qG||vG||gG&&EG<80||fG&&mG<56)},gK=function(){return["VideoDecoder","VideoEncoder","AudioEncoder","AudioDecoder","MediaStreamTrackGenerator"].every((function(e){return e in window}))},yK=function(){if(!navigator.mediaDevices)return TK()||qW.error(eK.NOT_SUPPORTED_MEDIA),!1;var e=["getUserMedia","enumerateDevices"];return e.filter((function(e){return e in navigator.mediaDevices})).length===e.length},EK=!1;function TK(){return"http:"===location.protocol&&!bW&&(EK||qW.error(rK({key:ZJ.NOT_SUPPORTED_HTTP})),EK=!0,!0)}var kK=function(){return(null==window?void 0:window.OffscreenCanvas)&&(null==window?void 0:window.MediaStreamTrackProcessor)&&(null==window?void 0:window.MediaStreamTrackGenerator)},SK=function(){return HF(this,null,p().mark((function e(){var t,n,r,i,o,a;return p().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!pK.detail.isH264EncodeSupported||!pK.detail.isVp8EncodeSupported){e.next=2;break}return e.abrupt("return",{isH264EncodeSupported:pK.detail.isH264EncodeSupported,isVp8EncodeSupported:pK.detail.isVp8EncodeSupported});case 2:return n=!1,r=!1,e.prev=3,i=new RTCPeerConnection,(o=document.createElement(UB.CANVAS)).getContext("2d"),a=o.captureStream(0),i.addTrack(a.getVideoTracks()[0],a),e.next=10,i.createOffer();case 10:return-1!==(t=e.sent).sdp.toLowerCase().indexOf("h264")&&(n=!0),-1!==t.sdp.toLowerCase().indexOf("vp8")&&(r=!0),i.close(),pK.detail.isH264EncodeSupported=n,pK.detail.isVp8EncodeSupported=r,e.abrupt("return",{isH264EncodeSupported:pK.detail.isH264EncodeSupported,isVp8EncodeSupported:pK.detail.isVp8EncodeSupported});case 19:return e.prev=19,e.t0=e.catch(3),e.abrupt("return",{isH264EncodeSupported:!1,isVp8EncodeSupported:!1});case 22:case"end":return e.stop()}}),e,null,[[3,19]])})))},IK=function(){return HF(this,null,p().mark((function e(){var t,n,r,i;return p().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!pK.detail.isH264DecodeSupported||!pK.detail.isVp8DecodeSupported){e.next=2;break}return e.abrupt("return",{isH264DecodeSupported:pK.detail.isH264DecodeSupported,isVp8DecodeSupported:pK.detail.isVp8DecodeSupported});case 2:return n=!1,r=!1,e.prev=3,i=new RTCPeerConnection,e.next=7,i.createOffer({offerToReceiveAudio:!0,offerToReceiveVideo:!0});case 7:return-1!==(t=e.sent).sdp.toLowerCase().indexOf("h264")&&(n=!0),-1!==t.sdp.toLowerCase().indexOf("vp8")&&(r=!0),i.close(),e.abrupt("return",{isH264DecodeSupported:n,isVp8DecodeSupported:r});case 14:return e.prev=14,e.t0=e.catch(3),e.abrupt("return",{isH264DecodeSupported:!1,isVp8DecodeSupported:!1});case 17:case"end":return e.stop()}}),e,null,[[3,14]])})))},bK=Bj((function(){return HF(void 0,null,p().mark((function e(){var t,n,r,i,o,a,s,c,u,l,d,h,f,m,v;return p().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(pK.result&&pK.detail.isH264EncodeSupported&&pK.detail.isVp8EncodeSupported&&pK.detail.isH264DecodeSupported&&pK.detail.isVp8DecodeSupported)){e.next=2;break}return e.abrupt("return",pK);case 2:return t=Date.now(),n=_K(),r=ZK(),i=gK(),o=yK(),e.next=9,SK();case 9:return a=e.sent,s=a.isH264EncodeSupported,c=a.isVp8EncodeSupported,e.next=14,IK();case 14:if(u=e.sent,l=u.isH264DecodeSupported,d=u.isVp8DecodeSupported,s&&c){e.next=22;break}return e.next=20,SK();case 20:h=e.sent,qW.warn("detect encode again h264:".concat(s," vp8:").concat(c," result: ").concat(JSON.stringify(h))),s=h.isH264EncodeSupported,c=h.isVp8EncodeSupported;case 22:if(!(s&&l&&uG&&dW)||RG||bG){e.next=29;break}return e.next=25,wK();case 25:f=e.sent,m=f.encode,v=f.decode,s=m,l=v;case 29:return e.abrupt("return",(pK.result=n&&r&&o&&(s||c)&&(l||d),pK.detail.isBrowserSupported=n,pK.detail.isWebRTCSupported=r,pK.detail.isWebCodecsSupported=i,pK.detail.isMediaDevicesSupported=o,pK.detail.isScreenShareSupported=RK(),pK.detail.isSmallStreamSupported=LK(),pK.detail.isH264EncodeSupported=s,pK.detail.isVp8EncodeSupported=c,pK.detail.isH264DecodeSupported=l,pK.detail.isVp8DecodeSupported=d,pK.result||qW.error("".concat(navigator.userAgent," ").concat(Oj(pK.detail,!1))),QW.setItem(oz,{ua:navigator.userAgent,checkResult:pK}),fK.addNumber({key:523800,value:Date.now()-t}),pK));case 30:case"end":return e.stop()}}),e)})))})),AK=function(){return pK.result},RK=function(){return!(!navigator.mediaDevices||!navigator.mediaDevices.getDisplayMedia)},CK=null;function wK(){return HF(this,null,p().mark((function e(){var t=this;return p().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",CK||(CK=new Promise((function(e){return HF(t,null,p().mark((function t(){var n,r,i,o,a,s,c,u,l,d,h,f,m,v,g=this;return p().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n={encode:!1,decode:!1},r=function(){},t.prev=1,i=document.createElement("canvas"),o=i.getContext("2d"),i.width=320,i.height=240,a=setInterval((function(){o.fillText("test",Math.floor(320*Math.random()),Math.floor(240*Math.random()))}),66),s=-1,c=-1,r=function(){clearInterval(s),clearInterval(a),clearTimeout(c),l.close(),d.close(),u.getTracks().forEach((function(e){return e.stop()}))},c=setTimeout((function(){r(),e(n)}),2e3),u=i.captureStream(),l=new RTCPeerConnection({}),d=new RTCPeerConnection({offerToReceiveAudio:!0,offerToReceiveVideo:!0}),l.addEventListener("icecandidate",(function(e){return d.addIceCandidate(e.candidate)})),d.addEventListener("icecandidate",(function(e){return l.addIceCandidate(e.candidate)})),l.addTrack(u.getVideoTracks()[0],u),t.next=10,l.createOffer();case 10:return h=t.sent,t.next=13,l.setLocalDescription(h);case 13:return t.next=15,d.setRemoteDescription(h);case 15:return t.next=17,d.createAnswer();case 17:return f=t.sent,m=oK.default.parse(f.sdp),v=m.media[0].rtp.findIndex((function(e){return"H264"===e.codec})),m.media[0].rtp=[m.media[0].rtp[v]],m.media[0].fmtp=m.media[0].fmtp.filter((function(e){return e.payload===m.media[0].rtp[0].payload})),m.media[0].rtcpFb&&(m.media[0].rtcpFb=m.media[0].rtcpFb.filter((function(e){return e.payload===m.media[0].rtp[0].payload}))),f.sdp=oK.default.write(m),t.next=26,d.setLocalDescription(f);case 26:return t.next=28,l.setRemoteDescription(f);case 28:s=setInterval((function(){return HF(g,null,p().mark((function t(){var i,o,a,s;return p().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n.encode&&n.decode&&(r(),e(n)),t.next=3,Promise.all([l.getSenders()[0].getStats(),d.getReceivers()[0].getStats()]);case 3:i=t.sent,o=_(i,2),a=o[0],s=o[1],n.encode||a.forEach((function(e){"outbound-rtp"===e.type&&e.mediaType===UB.VIDEO&&e.bytesSent>0&&(n.encode=!0)})),n.decode||s.forEach((function(e){"inbound-rtp"===e.type&&e.mediaType===UB.VIDEO&&e.bytesReceived>0&&(n.decode=!0)}));case 8:case"end":return t.stop()}}),t)})))}),100),t.next=34;break;case 31:t.prev=31,t.t0=t.catch(1),r(),qW.warn("detectH264Supported failed",t.t0),e({encode:!0,decode:!0});case 34:case"end":return t.stop()}}),t,null,[[1,31]])})))})).then((function(e){return e.encode||(e.decode=!0),(!e.encode||!e.decode)&&qW.warn("detectH264Supported encode: ".concat(e.encode," decode: ").concat(e.decode," ").concat(NW)),e})),CK));case 1:case"end":return e.stop()}}),e)})))}var DK=function(e,t,n){"http:"===location.protocol&&!bW&&(e[t]=function(){throw new tB({code:ZF.INVALID_OPERATION,message:eK.NOT_SUPPORTED_HTTP})})},NK=function(e){return!("candidate-pair"!==e.type||!e.nominated||"in-progress"!==e.state&&"succeeded"!==e.state)&&!(uj(e.selected)&&!e.selected)};function xK(){var e="";if(screen.width){var t=screen.width?screen.width*window.devicePixelRatio:"",n=screen.height?screen.height*window.devicePixelRatio:"";e+="".concat(t," * ").concat(n)}return e}function OK(){return navigator.getUserMedia||navigator.mediaDevices&&navigator.mediaDevices.getUserMedia}function PK(){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 MK(){return"captureStream"in HTMLCanvasElement.prototype}function LK(){return!(xG||cG||pW&&pW<63)&&!(!_K()||!MK())}var VK=function(){if(aj(window.RTCRtpTransceiver)||!("currentDirection"in RTCRtpTransceiver.prototype))return!1;var e=null,t=!1;try{(e=new RTCPeerConnection({sdpSemantics:gH})).addTransceiver(UB.AUDIO),t=!0}catch(dB){}return null==e||e.close(),t};function UK(){return"RTCPeerConnection"in window&&"getReceivers"in window.RTCPeerConnection.prototype}function FK(){return"RTCPeerConnection"in window&&"getSenders"in window.RTCPeerConnection.prototype}function BK(){return"RTCPeerConnection"in window&&"getTransceivers"in window.RTCPeerConnection.prototype}function HK(){return 11!==TW&&("RTCPeerConnection"in window&&"addTransceiver"in window.RTCPeerConnection.prototype)}var jK=!(!HK()||dW&&pW<86);function GK(){return"RTCRtpTransceiver"in window&&"stop"in window.RTCRtpTransceiver.prototype}var WK="RTCRtpSender"in window;function JK(){return WK&&"replaceTrack"in window.RTCRtpSender.prototype}function KK(){return WK&&"setParameters"in window.RTCRtpSender.prototype&&FK()}var zK="RTCRtpReceiver"in window&&"getSynchronizationSources"in window.RTCRtpReceiver.prototype,qK=window.MediaStreamTrack&&"getSettings"in MediaStreamTrack.prototype,YK=window.MediaStreamTrack&&"getCapabilities"in MediaStreamTrack.prototype,XK=WK&&"createEncodedStreams"in window.RTCRtpSender.prototype&&lW()>=86,QK="RTCRtpScriptTransform"in window,$K=WK&&(XK||QK),ZK=function(){return["RTCPeerConnection","webkitRTCPeerConnection","RTCIceGatherer"].filter((function(e){return e in window})).length>0};function ez(){var e={AudioDecoder:!1,AudioEncoder:!1,VideoDecoder:!1,VideoEncoder:!1,ImageDecoder:!1};return aj(window.AudioDecoder)||(e.AudioDecoder=!0),aj(window.AudioEncoder)||(e.AudioEncoder=!0),aj(window.VideoDecoder)||(e.VideoDecoder=!0),aj(window.VideoEncoder)||(e.VideoEncoder=!0),aj(window.ImageDecoder)||(e.ImageDecoder=!0),e}function tz(){return"mediaSession"in navigator&&!aj(navigator.mediaSession.setActionHandler)}function nz(){return!aj(window.WebTransport)}function rz(){return"undefined"!=typeof WebAssembly&&WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,5,1,96,0,1,123,3,2,1,0,10,10,1,8,0,65,0,253,15,253,98,11]))}function iz(){var e={browser:"".concat(RW.name,"/").concat(RW.version),os:MW(),displayResolution:xK(),isScreenShareSupported:RK(),isWebRTCSupported:ZK(),isGetUserMediaSupported:OK(),isWebAudioSupported:PK(),isWebSocketsSupported:"WebSocket"in window&&2===window.WebSocket.CLOSING,isWebCodecSupported:ez(),isMediaSessionSupported:tz(),isWebTransportSupported:nz()};return navigator.userAgent.includes("miniProgram")&&(e.browser="mini/".concat(e.browser)),e}var oz="checkResult";function az(){TK();var e=QW.getItem(oz);e&&e.ua===navigator.userAgent&&(pK=e.checkResult),bK()}function sz(){return"requestVideoFrameCallback"in HTMLVideoElement.prototype}var cz="RTCRtpReceiver"in window&&"jitterBufferTarget"in window.RTCRtpReceiver.prototype,uz=VF(jF(),1),lz=Symbol("instance"),dz=Symbol("cacheResult"),hz=function(){return s((function e(t,n,r){i(this,e),this.oldState=t,this.newState=n,this.action=r,this.aborted=!1}),[{key:"abort",value:function(e){this.aborted=!0,_z.call(e,this.oldState,new Error("action '".concat(this.action,"' aborted")))}},{key:"toString",value:function(){return"".concat(this.action,"ing")}}])}(),fz=function(e){function t(e,n,o){var a;return i(this,t),(a=r(this,t,[n])).state=e,a.message=n,a.cause=o,a}return d(t,e),s(t)}(b(Error));var pz=new Map;function mz(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return function(r,i,o){var a=n.action||i;if(!n.context){var s=pz.get(r)||[];pz.has(r)||pz.set(r,s),s.push({from:e,to:t,action:a})}var c=o.value;o.value=function(){for(var r,i=this,o=this,s=arguments.length,u=new Array(s),l=0;l<s;l++)u[l]=arguments[l];if(n.context&&(o=gz.get("function"==typeof n.context?(r=n.context).call.apply(r,[this].concat(u)):n.context)),o.state===t)return n.sync?o[dz]:Promise.resolve(o[dz]);o.state instanceof hz&&o.state.action==n.abortAction&&o.state.abort(o);var d=null;Array.isArray(e)?0==e.length?o.state instanceof hz&&o.state.abort(o):("string"!=typeof o.state||!e.includes(o.state))&&(d=new fz(o._state,"".concat(o.name," ").concat(a," to ").concat(t," failed: current state ").concat(o._state," not from ").concat(e.join("|")))):e!==o.state&&(d=new fz(o._state,"".concat(o.name," ").concat(a," to ").concat(t," failed: current state ").concat(o._state," not from ").concat(e)));var h=function(e){if(n.fail&&n.fail.call(i,e),n.sync){if(n.ignoreError)return e;throw e}return n.ignoreError?Promise.resolve(e):Promise.reject(e)};if(d)return h(d);var f=o.state,p=new hz(f,t,a);_z.call(o,p);var m=function(e){var r;return o[dz]=e,p.aborted||(_z.call(o,t),null===(r=n.success)||void 0===r||r.call(i,o[dz])),e},v=function(e){return _z.call(o,f,e),h(e)};try{var _=c.apply(this,u);return function(e){return"object"==S(e)&&e&&"then"in e}(_)?_.then(m).catch(v):n.sync?m(_):Promise.resolve(m(_))}catch(_){return v(new fz(o._state,"".concat(o.name," ").concat(a," from ").concat(e," to ").concat(t," failed: ").concat(_),_ instanceof Error?_:new Error(String(_))))}}}}var vz="undefined"!=typeof window&&window.__AFSM__?function(e,t){window.dispatchEvent(new CustomEvent(e,{detail:t}))}:"undefined"!=typeof importScripts?function(e,t){postMessage({type:e,payload:t})}:function(){};function _z(e,t){var n=this._state;this._state=e;var r=e.toString();e&&this.emit(r,n),this.emit(gz.STATECHANGED,e,n,t),this.updateDevTools({value:e,old:n,err:t instanceof Error?t.message:String(t)})}var gz=function(e){function t(e,o,a){var s;i(this,t),(s=r(this,t)).name=e,s.groupName=o,s._state=t.INIT,e||(e=Date.now().toString(36)),a?Object.setPrototypeOf(n(s),a):a=Object.getPrototypeOf(n(s)),o||(s.groupName=s.constructor.name);var c=a[lz];return c?s.name=c.name+"-"+c.count++:a[lz]={name:s.name,count:0},s.updateDevTools({diagram:s.stateDiagram}),s}return d(t,e),s(t,[{key:"stateDiagram",get:function(){var e=Object.getPrototypeOf(this),t=pz.get(e)||[],n=new Set,r=[],i=[],o=new Set,a=Object.getPrototypeOf(e);pz.has(a)&&(a.stateDiagram.forEach((function(e){return n.add(e)})),a.allStates.forEach((function(e){return o.add(e)}))),t.forEach((function(e){var t=e.from,n=e.to,o=e.action;"string"==typeof t?r.push({from:t,to:n,action:o}):t.length?t.forEach((function(e){r.push({from:e,to:n,action:o})})):i.push({to:n,action:o})})),r.forEach((function(e){var t=e.from,r=e.to,i=e.action;o.add(t),o.add(r),o.add(i+"ing"),n.add("".concat(t," --\x3e ").concat(i,"ing : ").concat(i)),n.add("".concat(i,"ing --\x3e ").concat(r," : ").concat(i," 🟢")),n.add("".concat(i,"ing --\x3e ").concat(t," : ").concat(i," 🔴"))})),i.forEach((function(e){var t=e.to,r=e.action;n.add("".concat(r,"ing --\x3e ").concat(t," : ").concat(r," 🟢")),o.forEach((function(e){e!==t&&n.add("".concat(e," --\x3e ").concat(r,"ing : ").concat(r))}))}));var s=T(n);return Object.defineProperties(e,{stateDiagram:{value:s},allStates:{value:o}}),s}},{key:"updateDevTools",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};vz(t.UPDATEAFSM,Object.assign({name:this.name,group:this.groupName},e))}},{key:"state",get:function(){return this._state},set:function(e){_z.call(this,e)}}],[{key:"get",value:function(e){var n;return"string"==typeof e?(n=t.instances.get(e))||t.instances.set(e,n=new t(e,void 0,Object.create(t.prototype))):(n=t.instances2.get(e))||t.instances2.set(e,n=new t(e.constructor.name,void 0,Object.create(t.prototype))),n}},{key:"getState",value:function(e){var n;return null===(n=t.get(e))||void 0===n?void 0:n.state}}])}(uz.default);gz.STATECHANGED="stateChanged",gz.UPDATEAFSM="updateAFSM",gz.INIT="[*]",gz.ON="on",gz.OFF="off",gz.instances=new Map,gz.instances2=new WeakMap;var yz="undefined"!=typeof window,Ez=yz&&window.requestIdleCallback||function(e){var t=Date.now();return setTimeout((function(){e({didTimeout:!1,timeRemaining:function(){return Math.max(0,50-(Date.now()-t))}})}),1e3)},Tz=yz&&window.cancelIdleCallback||function(e){clearTimeout(e)},kz=yz&&(window.cancelAnimationFrame||window.mozCancelAnimationFrame),Sz=function(){function e(){i(this,e)}return s(e,null,[{key:"generateTaskID",value:function(){return this.currentTaskID++}},{key:"run",value:function(e,t,n){null!=n&&n.fps&&(n.delay=n.delay||Number((1e3/n.fps).toFixed(2))),n=xF("interval"===e?{delay:2e3,count:0,backgroundTask:!0}:"ric"===e?{delay:1e4,count:0}:"raf"===e?{fps:60,delay:16.6,count:0,backgroundTask:!0}:{delay:2e3,count:0,backgroundTask:!0},n);var r=OF(xF({taskID:this.generateTaskID(),loopCount:0,intervalID:null,timeoutID:null,rafID:null,ricID:null,taskName:e,callback:t},n),{delay:n.delay});return this.taskMap.set(r.taskID,r),this[e](r),r.taskID}},{key:"interval",value:function(t){return t.intervalID=setInterval((function(){t.callback(),t.loopCount+=1,e.isBreakLoop(t)}),t.delay)}},{key:"intervalInWorker",value:function(t){e.sharedWorker||(e.sharedWorker=new Worker(URL.createObjectURL(new Blob(["\n const timers = new Map();\n self.onmessage = function(e) {\n const { taskId, delay, type } = e.data;\n if (type === 'start') {\n timers.set(taskId, setInterval(() => {\n self.postMessage({ type: 'tick', taskId });\n }, delay));\n } else if (type === 'stop') {\n clearInterval(timers.get(taskId));\n timers.delete(taskId);\n }\n };\n "],{type:"application/javascript"}))),e.sharedWorker.onmessage=function(t){var n;if("tick"===t.data.type){var r=e.workerTasks.get(t.data.taskId);r&&(r.callback(),r.loopCount+=1,e.isBreakLoop(r)&&(null==(n=e.sharedWorker)||n.postMessage({type:"stop",taskId:r.taskID}),e.workerTasks.delete(r.taskID)))}}),e.workerTasks.set(t.taskID,t),e.sharedWorker.postMessage({taskId:t.taskID,delay:t.delay,type:"start"})}},{key:"timeout",value:function(t){var n=function(){if(t.callback(),t.loopCount+=1,!e.isBreakLoop(t))return t.timeoutID=setTimeout(n,t.delay)};return t.timeoutID=setTimeout(n,t.delay)}},{key:"ric",value:function(t){var n,r=yj(),i=function(){if((n=yj()-r)>=t.delay&&(r=yj()-Math.floor(n%t.delay),t.callback(),t.loopCount+=1),!e.isBreakLoop(t))return t.ricID=Ez(i,{timeout:t.delay})};return t.ricID=Ez(i,{timeout:t.delay})}},{key:"raf",value:function(t){var n,r=yj(),i=function(){return document.hidden&&t.backgroundTask?(n=yj()-r,r=yj(),t.callback(),t.loopCount+=1,e.isBreakLoop(t)?void 0:t.timeoutID=setTimeout(i,t.delay-Math.floor(n%t.delay))):((n=yj()-r)>=t.delay&&(r=yj()-Math.floor(n%t.delay),t.callback(),t.loopCount+=1),e.isBreakLoop(t)?void 0:t.rafID=requestAnimationFrame(i))};if(t.rafID=requestAnimationFrame(i),t.backgroundTask){var o=function(){if(document.hidden){var e=yj()-r;e>=t.delay?i():t.timeoutID=setTimeout(i,t.delay-e)}};document.addEventListener("visibilitychange",o),t.onVisibilitychange=o,document.hidden&&o()}return t.taskID}},{key:"hasTask",value:function(e){return this.taskMap.has(e)}},{key:"clearTask",value:function(e){if(!this.taskMap.has(e))return!0;var t=this.taskMap.get(e),n=t.intervalID,r=t.timeoutID,i=t.rafID,o=t.ricID,a=t.onVisibilitychange,s=t.worker;return s&&s.terminate(),n&&clearInterval(n),r&&clearTimeout(r),i&&kz&&kz(i),o&&Tz(o),a&&document.removeEventListener("visibilitychange",a),this.taskMap.delete(e),!0}},{key:"isBreakLoop",value:function(e){return!this.taskMap.has(e.taskID)||0!==e.count&&e.loopCount>=e.count&&(this.clearTask(e.taskID),!0)}}])}();FF(Sz,"taskMap",new Map),FF(Sz,"currentTaskID",1),FF(Sz,"sharedWorker",null),FF(Sz,"workerTasks",new Map);var Iz=Sz;UB.SEI_MESSAGE;var bz={LOADED_DATA:UB.LOADEDDATA,LOADED_META_DATA:UB.LOADEDMETADATA,MEDIA_TRACK_CHANGED:"media-track-changed",PLAYER_STATE_CHANGED:"player-state-changed",ERROR:"error"},Az={};LF(Az,{create:function(){return Cz},remove:function(){return wz}});var Rz=new WeakMap;function Cz(e,t){Rz.has(e)||Rz.set(e,[]);var n=Rz.get(e),r={add:function(e,i){return"addEventListener"in t?(n.push(t.removeEventListener.bind(t,e,i)),t.addEventListener(e,i)):(n.push(t.off.bind(t,e,i)),t.on(e,i)),r}};return r}function wz(e){var t=Rz.get(e);t&&(t.forEach((function(e){return e()})),Rz.delete(e))}var Dz=function(){return s((function e(){i(this,e),FF(this,"_roomIdMap",new Map),FF(this,"_configs"),"undefined"==typeof registerProcessor&&(this._configs={sdkAppId:"",userId:"",version:uB,env:wB.QCLOUD,browserVersion:RW.name+RW.version,ua:navigator.userAgent})}),[{key:"setConfig",value:function(e){var t=e.sdkAppId,n=e.env,r=e.userId,i=e.roomId;t!==this._configs.sdkAppId&&(this._configs.sdkAppId=String(t)),this._configs.env=n,this._configs.userId=r,this._roomIdMap.set(r,String(i))}},{key:"logSuccessEvent",value:function(e){bW||!qW.isAbleToUpload||this._configs.env===wB.QCLOUD&&this.uploadEventToKibana(OF(xF({},e),{result:"success"}))}},{key:"logFailedEvent",value:function(e){if(!bW&&qW.isAbleToUpload){var t=e.eventType,n=e.code,r=e.error,i=e.userId,o={roomId:this._roomIdMap.get(i||this._configs.userId),userId:i,eventType:t,result:"failed",code:n||(null==r?void 0:r.extraCode)||(null==r?void 0:r.code)||ZF.UNKNOWN};this._configs.env===wB.QCLOUD&&this.uploadEventToKibana(OF(xF({},o),{error:r}))}}},{key:"uploadEventToKibana",value:function(e){var t="stat-".concat(e.eventType,"-").concat(e.result);("delta-join"===e.eventType||"delta-leave"===e.eventType||"delta-publish"===e.eventType)&&(t="".concat(e.eventType,":").concat(e.delta)),this.uploadEvent({log:t,userId:e.userId}),"failed"===e.result&&(t="stat-".concat(e.eventType,"-").concat(e.result,"-").concat(e.code),this.uploadEvent({log:t,userId:e.userId,error:e.error}))}},{key:"uploadEvent",value:function(e){var t=e.log,n=e.userId,r=e.error,i={timestamp:iB(),sdkAppId:this._configs.sdkAppId,userId:n||this._configs.userId,version:uB,log:t};r&&(i.errorInfo=r.message,r.stack&&(i.errorInfo+="\n".concat(r.stack))),this.sendRequest(jH(this._configs.sdkAppId,CB.LOG),i)}},{key:"sendRequest",value:function(e,t){setTimeout((function(){return Hj({url:e,body:JSON.stringify(t),priority:"low"}).catch((function(){}))}),2e3)}}])}(),Nz=new Dz,xz=new WeakMap;function Oz(e){var t=e.settings,n=void 0===t?{retries:5,timeout:2e3}:t,r=e.onError,i=e.onRetrying,o=e.onRetryFailed;return function(e,t,a){var s=qj({retryFunction:a.value,settings:n,onError:function(n){var i,o=n.error,a=n.retry,s=n.reject,c=n.retryFuncArgs;r?r.call(this,o,(function(){var n;null!=(n=xz.get(e))&&n.has(t)?a():s(o)}),s,c):null!=(i=xz.get(e))&&i.has(t)?a():s(o)},onRetrying:function(n,r){var o;Wj(i)&&i.call(this,n,r),null!=(o=xz.get(e))&&o.has(t)&&(xz.get(e).get(t).stopRetry=r)},onRetryFailed:o});return a.value=function(){for(var n=xz.get(e),r=arguments.length,i=new Array(r),o=0;o<r;o++)i[o]=arguments[o];return n?n.set(t,{args:i}):xz.set(e,new Map([[t,{args:i}]])),s.apply(this,i).finally((function(){var n;return null==(n=xz.get(e))?void 0:n.delete(t)}))},a}}function Pz(e){var t=e.fnName,n=e.callback,r=e.validateArgs,i=void 0===r||r;return function(e,r,o){var a=o.value;return o.value=function(){for(var r,o,s=arguments.length,u=new Array(s),l=0;l<s;l++)u[l]=arguments[l];if(null!=(r=xz.get(e))&&r.has(t)){var d=xz.get(e).get(t),h=d.stopRetry,f=d.args,p=!0;if(i){var m,v=c(f);try{var _=function(){var e=m.value;if(!u.find((function(t){return t===e})))return p=!1,1};for(v.s();!(m=v.n()).done&&!_(););}catch(g){v.e(g)}finally{v.f()}}p&&(n&&n.apply(this,u),h&&h(),null==(o=xz.get(e))||o.delete(t))}return a.apply(this,u)},o}}var Mz=function(e){function t(e,n){var o;return i(this,t),(o=r(this,t,[e.id,"".concat(n,"-player")])).kind=n,FF(o,"id"),FF(o,"element",null),FF(o,"track"),FF(o,"url"),FF(o,"attr"),FF(o,"mode"),FF(o,"muted"),FF(o,"_log"),FF(o,"_pausedRetryCount"),FF(o,"_isElementPlayingFired",!1),FF(o,"_interval"),FF(o,"_delayDestroyTimeoutId",0),FF(o,"_playSuccessResolve"),FF(o,"_isReplayByRecreateMediaStreamCalled",!1),FF(o,"isInAutoPlayFailedState",!1),o.id=e.id,o._log=e.log,o.track=e.track,o.muted=e.muted,o._pausedRetryCount=DH,o._state="STOPPED",o.bindTrackEvents(),o._log.info("create ".concat(n,"-player ").concat(o.id)),o}return d(t,e),s(t,[{key:"isPlaying",get:function(){var e;return"PLAYING"===this._state&&(!1===(null==(e=this.element)?void 0:e.paused)||this.track&&"live"===this.track.readyState&&!this.track.muted)}},{key:"isStopped",get:function(){return"STOPPED"===this._state}},{key:"setAttr",value:function(e){this.attr=e}},{key:"setUrl",value:function(e){this.track&&(this.unbindTrackEvents(),this.element&&(this.element.srcObject=null),this.track=null),e!==this.url&&(this.url=e,null!==e&&this.element&&(this.element.crossOrigin="anonymous",this.element.src=e))}},{key:"play",value:function(){return HF(this,null,p().mark((function e(){var t,n=this;return p().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.isPlaying){e.next=13;break}return e.prev=1,this._delayDestroyTimeoutId&&(clearTimeout(this._delayDestroyTimeoutId),this._delayDestroyTimeoutId=0,this.bindTrackEvents(),this.bindElementEvents()),this.bindAutoPlayEvent(),e.next=6,new Promise((function(e,t){n._playSuccessResolve=e,n.element.play().then(e,t)}));case 6:e.next=13;break;case 8:if(e.prev=8,e.t0=e.catch(1),t=rK({key:ZJ.PLAY_FAILED,data:{media:this.kind,error:e.t0}}),this.track&&!this.track.muted&&this._log.warn(e.t0),!t.includes("NotAllowedError")){e.next=13;break}throw this.isInAutoPlayFailedState=!0,new tB({code:ZF.PLAY_NOT_ALLOWED,message:t});case 13:case"end":return e.stop()}}),e,this,[[1,8]])})))}},{key:"stop",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;this._isElementPlayingFired=!1,this.unbindEvents(),t>0&&!_W?this._delayDestroyTimeoutId||(this._log.info("destroy element after 3 * ".concat(t)),this._delayDestroyTimeoutId=setTimeout((function(){return e.destroyElement()}),3*t)):this.destroyElement(),this.handleStopped(UB.ENDED),this._interval>0&&Iz.clearTask(this._interval)}},{key:"destroyElement",value:function(){this.element&&(this._log.debug("destroy element"),this.element.remove(),this.element.srcObject=null,this.element=null),clearTimeout(this._delayDestroyTimeoutId),this._delayDestroyTimeoutId=0}},{key:"pause",value:function(){var e;this.isPlaying&&(null==(e=this.element)||e.pause())}},{key:"resume",value:function(){return this._log.info("resume"),this.isPlaying?Promise.resolve():SW?this.replay():this.play().catch((function(){}))}},{key:"setMuted",value:function(e){this.element&&(this.element.muted=e),this.muted=e}},{key:"replay",value:function(){return this.stop(),this.play().catch((function(){}))}},{key:"bindElementEvents",value:function(){if(this.element){var e=this.handleElementEvent.bind(this);return Cz(this.element,this.element).add(UB.PLAYING,e).add(UB.ENDED,e).add(UB.PAUSE,e).add(UB.ERROR,e).add(UB.LOADEDDATA,e).add(UB.LOADEDMETADATA,e)}}},{key:"bindTrackEvents",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.track;if(e){var t=this.handleTrackEvent.bind(this);null==Az||Az.create(e,e).add(UB.ENDED,t).add(UB.MUTE,t).add(UB.UNMUTE,t),e.readyState===UB.ENDED&&this.handleTrackEvent({type:UB.ENDED}),e.muted&&this.handleTrackEvent({type:UB.MUTE})}}},{key:"bindAutoPlayEvent",value:function(){HW.on(GW.AUTOPLAY_DIALOG_CLICK_CONFIRM,this.resume,this)}},{key:"unbindTrackEvents",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.track;e&&wz(e)}},{key:"unbindEvents",value:function(){this.element&&wz(this.element),this.unbindTrackEvents(),HW.off(GW.AUTOPLAY_DIALOG_CLICK_CONFIRM,this.resume,this)}},{key:"handleElementEvent",value:function(e){var t=this;switch(e.type){case UB.PLAYING:this.isInAutoPlayFailedState=!1,this._isElementPlayingFired=!0,this._log.info("".concat(this.kind," player is playing")),this.handlePlaying(UB.PLAYING),this._interval&&(Iz.clearTask(this._interval),this._interval=-1);break;case UB.ENDED:this._log.info("".concat(this.kind," player is ended")),this.handleStopped(UB.ENDED);break;case UB.PAUSE:this._log.info("".concat(this.kind," player is paused")),this.handlePaused(UB.PAUSE),cG&&(this._interval=Iz.run("timeout",(function(){t.element&&"PAUSED"===t._state&&t.resume()}),{delay:3e3}));break;case UB.ERROR:if(this.element&&this.element.error){this.handlePaused(UB.ERROR);var n=this.element.error,r=n.code,i=n.message;this._log.error("".concat(this.kind," ").concat(this._log.isLocal?"local":"remote"," MediaError code: ").concat(r," message: ").concat(i," userAgent: ").concat(navigator.userAgent)),Nz.uploadEvent({log:"stat-".concat(this.kind,"-").concat(pH.PLAYER_ERROR,"-").concat(r,"-").concat(navigator.userAgent),error:this.element.error}),eW||ZG?this.emit(bz.ERROR,this.element.error):this.replayByRecreateMediaStream(this.element.error)}break;case UB.LOADEDDATA:this.kind===UB.VIDEO&&this.emit(bz.LOADED_DATA);break;case UB.LOADEDMETADATA:this.kind===UB.VIDEO&&this.emit(bz.LOADED_META_DATA)}}},{key:"replayByRecreateMediaStream",value:function(e){var t=this;if(!this._isReplayByRecreateMediaStreamCalled)return this._isReplayByRecreateMediaStreamCalled=!0,this.doReplayByRecreateMediaStream(1e3).then((function(){t._log.warn("replayByRecreateMediaStream success"),Nz.uploadEvent({log:"stat-replayByRecreateMediaStream-success"}),fK.addSuccessEvent({key:t.kind===UB.AUDIO?506700:516700})})).catch((function(){var n;t._log.error("replayByRecreateMediaStream failed"),Nz.uploadEvent({log:"stat-replayByRecreateMediaStream-failed"}),fK.addFailedEvent({key:t.kind===UB.AUDIO?506700:516700,error:null==(n=t.element)?void 0:n.error}),t.emit(bz.ERROR,e)}))}},{key:"doReplayByRecreateMediaStream",value:function(e){var t=this;return this._log.warn("delay ".concat(e,"ms to recreate mediaStream")),new Promise((function(n,r){Fj(e).then((function(){t.element&&(t.element.srcObject=null,t.element.srcObject=new MediaStream([t.track]),t._log.warn("recreated mediaStream"),t.element.onerror=function(){var e,n,i;t._log.warn("element onerror ".concat(null==(n=null==(e=t.element)?void 0:e.error)?void 0:n.code," fired after recreated mediaStream")),r(null==(i=t.element)?void 0:i.error)}),Fj(5e3).then((function(){var e,i;(!t.isPlaying||null!=(e=t.element)&&e.error)&&r(null==(i=t.element)?void 0:i.error),n()}))}))})).finally((function(){t.element&&(t.element.onerror=null)}))}},{key:"handleTrackEvent",value:function(e){switch(e.type){case UB.ENDED:this.handleStopped(UB.ENDED);break;case UB.MUTE:this.handlePaused(UB.MUTE);break;case UB.UNMUTE:this._isElementPlayingFired?this.handlePlaying(UB.UNMUTE):this.mode>0&&this.handlePlaying(this.mode.toString())}}},{key:"handlePlaying",value:function(e){var t;null==(t=this._playSuccessResolve)||t.call(this,e),this.emit(bz.PLAYER_STATE_CHANGED,{type:this.kind,state:"PLAYING",reason:e})}},{key:"handlePaused",value:function(e){this.emit(bz.PLAYER_STATE_CHANGED,{type:this.kind,state:"PAUSED",reason:e})}},{key:"handleStopped",value:function(e){this.emit(bz.PLAYER_STATE_CHANGED,{type:this.kind,state:"STOPPED",reason:e})}},{key:"getElement",value:function(){return this.element}}])}(gz);UF([Oz({settings:{retries:2,timeout:0},onError:function(e,t,n,r){r[0]=(r[0]||1e3)+1e3,t()}})],Mz.prototype,"doReplayByRecreateMediaStream",1),UF([mz([],"PLAYING",{sync:!0})],Mz.prototype,"handlePlaying",1),UF([mz("PLAYING","PAUSED",{ignoreError:!0,sync:!0})],Mz.prototype,"handlePaused",1),UF([mz([],"STOPPED",{sync:!0})],Mz.prototype,"handleStopped",1);var Lz,Vz="trtc_autoplay",Uz="".concat(Vz,"_mask"),Fz="".concat(Vz,"_wrapper"),Bz="".concat(Vz,"_header"),Hz="".concat(Vz,"_content"),jz="".concat(Vz,"_action_wrapper"),Gz="".concat(Vz,"_question"),Wz="".concat(Vz,"_collapse"),Jz="".concat(Vz,"_action_confirm"),Kz="".concat(Vz,"_detail"),zz="#2473E8",qz="dialog",Yz="".concat(qz,"-show"),Xz="".concat(qz,"-1"),Qz="".concat(qz,"-2"),$z=!1,Zz=function(){return!!document.querySelector(".".concat(Fz))},eq="".concat(kB,"/").concat(ej()?"zh-cn":"en","/tutorial-21-advanced-auto-play-policy.html"),tq="<br><a href='".concat(eq,"' target='_blank'>").concat(ej()?"其他方案?":"Any other solution?","</a>"),nq="".concat(ej()?"浏览器自动播放策略:在用户与页面产生交互(点击、触摸)之前,浏览器禁止播放有声媒体。该弹窗用于帮助用户恢复音视频播放。".concat(tq):"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(tq)),rq=function(){return s((function e(){if(i(this,e),FF(this,"content","音视频播放被浏览器拦截,请点击“恢复播放”。"),FF(this,"_dialogNode",null),FF(this,"_bodyPosition",""),FF(this,"_showDetail",!1),FF(this,"_isCollapseClicked",!1),FF(this,"_isQuestionClicked",!1),ej()||(this.content='Media playback failed. Click the "Resume" to resume playback.'),!$z){var t=document.createElement("style");t.innerHTML=".".concat(Uz,"{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(Uz," div:not(.").concat(jz,"){display:block !important;}.").concat(Fz,"{padding:14px;background:#fff;border-radius:3px;box-shadow:0px 3px 15px #434343;border:1px solid #d1cfcf;max-width:500px;}.").concat(Fz," a{color:").concat(zz,";}.").concat(Bz,"{overflow:hidden;text-overflow:ellipsis;font-size:16px;font-weight:600;}.").concat(Hz,"{margin:8px 0;}.").concat(jz,"{width:100%;display:flex !important;align-items:center;justify-content:right;float:right;}.").concat(Wz,"{margin-right:auto;cursor:pointer}.").concat(Gz,"{height:100%;line-height:16px;cursor:pointer;}.").concat(Jz,"{margin-left:8px;color:#fff;background:").concat(zz,";padding:4px 12px;outline:none;border:1px solid;border-radius:3px;font-weight:bold;}.").concat(Jz,":hover{opacity:0.9;}.").concat(Wz,",.").concat(Jz,",.").concat(Hz,",.").concat(Gz,"{font-size:14px;}@media screen and (max-width:750px){.").concat(Fz,"{width:80vw;}}"),document.head.appendChild(t),$z=!0}this.addDiaLog()}),[{key:"createDiaLog",value:function(){var e=document.createElement("template");e.innerHTML='<div class="'.concat(Uz,"\"><div class='").concat(Fz,"'><div class='").concat(Bz,"'>").concat(location.host,"</div><div class='").concat(Hz,"'>").concat(this.content,"</div><div class='").concat(Kz,'\' style="visibility:hidden;width:100%;height:0;font-size:12px;color:gray;">').concat(nq,"</div><div class='").concat(jz,"'></div></div></div>").trim();var t=document.createElement("button");t.className=Jz,t.innerText=ej()?"恢复播放":"Resume",t.onclick=this.onConfirm.bind(this);var n=document.createElement("div");n.className=Gz,n.innerHTML='<?xml version="1.0" encoding="UTF-8"?>\n <svg class="icon" width="18" height="18" p-id="2030" t="1639646523624" version="1.1" viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg">\n <path d="m464 784.35c0 26.51 21.49 48 48 48s48-21.49 48-48-21.49-48-48-48-48 21.49-48 48z" p-id="2031"/>\n <path d="m512 960c-247.04 0-448-200.96-448-448s200.96-448 448-448 448 200.96 448 448-200.96 448-448 448zm0-831.71c-211.58 0-383.71 172.13-383.71 383.71 0 211.55 172.13 383.71 383.71 383.71 211.55 0 383.71-172.16 383.71-383.71 0-211.58-172.16-383.71-383.71-383.71z" p-id="2032"/>\n <path d="m512 673.7c-17.665 0-32.001-14.336-32.001-31.999v-54.112c0-52.353 40-92.352 75.328-127.65 25.887-25.92 52.672-52.672 52.672-74.017 0-53.343-43.072-96.735-95.999-96.735-53.823 0-95.999 41.536-95.999 94.559 0 17.665-14.336 31.999-32.001 31.999s-32.001-14.336-32.001-31.999c0-87.424 71.775-158.56 160-158.56s160 72.095 160 160.74c0 47.904-36.32 84.192-71.424 119.3-27.84 27.776-56.576 56.512-56.576 82.336v54.112c0 17.665-14.336 32.032-32.001 32.032z" p-id="2033"/>\n </svg>\n ',n.onclick=this.onQuestionClick.bind(this);var r=document.createElement("div");r.className=Wz,r.innerText="".concat(ej()?"详情 >":"Detail >"),r.onclick=this.onCollapseClick.bind(this);var i=e.content.firstChild,o=i.querySelector(".".concat(jz));return o.appendChild(r),o.appendChild(n),o.appendChild(t),i}},{key:"addDiaLog",value:function(){Zz()||(this._dialogNode=this.createDiaLog(),document.body.appendChild(this._dialogNode),this._dialogNode.onclick=this.onConfirm.bind(this),this._dialogNode.querySelector(".".concat(Fz)).onclick=function(e){return e.stopPropagation()},this._bodyPosition=document.body.style.position,document.body.style.position="fixed",qW.info("show autoplay dialog"),Nz.uploadEvent({log:Yz}))}},{key:"deleteDiaLog",value:function(){this._dialogNode&&(document.body.removeChild(this._dialogNode),document.body.style.position=this._bodyPosition,this._dialogNode=null)}},{key:"onConfirm",value:function(){qW.warn("confirm clicked, try resume stream"),HW.emit(GW.AUTOPLAY_DIALOG_CLICK_CONFIRM),this.deleteDiaLog()}},{key:"onCollapseClick",value:function(){var e=this._dialogNode.querySelector(".".concat(Kz));e.style.visibility="".concat(this._showDetail?"hidden":"visible"),e.style.height="".concat(this._showDetail?0:"fit-content"),this._showDetail=!this._showDetail,this._isCollapseClicked||Nz.uploadEvent({log:Xz}),this._isCollapseClicked=!0}},{key:"onQuestionClick",value:function(){window.open(eq,"_blank"),this._isQuestionClicked||Nz.uploadEvent({log:Qz}),this._isQuestionClicked=!0}}])}(),iq=rq,oq=function(e){function t(e){var n;return i(this,t),n=r(this,t,[e,UB.VIDEO]),FF(n,"stat",{}),FF(n,"_calculateTimeout",-1),FF(n,"viewMirror",!1),FF(n,"objectFit"),FF(n,"container"),FF(n,"canvas"),FF(n,"canvasTrack"),n.mode=e.canvas?1:0,n.container=e.container,n.canvas=e.canvas,aj(e.viewMirror)||(n.viewMirror=e.viewMirror),aj(e.objectFit)||(n.objectFit=e.objectFit),n.initializeElement(),n}return d(t,e),s(t,[{key:"initializeElement",value:function(){var e,t=document.createElement(UB.VIDEO);this.track&&2!==this.mode&&(t.srcObject=new MediaStream([this.track])),t.muted=!0,t.setAttribute("id","video_".concat(this.id)),t.setAttribute("style",this.styleAttribute),this.canvas&&this.canvas.setAttribute("style",this.styleAttribute),t.setAttribute("autoplay","autoplay"),t.setAttribute("playsinline","playsinline"),this.element=t,null==(e=this.container)||e.appendChild(this.elementToRender),this.bindElementEvents(),this.calculateStat()}},{key:"styleAttribute",get:function(){var e="width: 100%; height: 100%; object-fit: ".concat(this.objectFit,";background-color: black;");return this.viewMirror&&(e+="transform: scaleX(-1);"),e}},{key:"setContainer",value:function(e){var t;this.container=e,(this.track||this.canvasTrack)&&this.elementToRender&&(null==(t=this.container)||t.appendChild(this.elementToRender))}},{key:"bindElementEvents",value:function(){var e=y(t,"bindElementEvents",this,3)([]);this.handleElementEvent=this.handleElementEvent.bind(this),e&&e.add(UB.ENTER_PICTURE_IN_PICTURE,this.handleElementEvent).add(UB.LEAVE_PICTURE_IN_PICTURE,this.handleElementEvent)}},{key:"handleTrackEvent",value:function(e){var n;y(t,"handleTrackEvent",this,3)([e]),e.type===UB.MUTE&&null!=(n=this.stat)&&n.fps&&(this.stat.fps=0)}},{key:"handleElementEvent",value:function(e){var n;if(2!==this.mode){y(t,"handleElementEvent",this,3)([e]);var r=e.type;if(r===UB.PAUSE&&(this.container&&document.getElementById(this.container.id)||this._log.warn("".concat(this.kind," player has been remove, element ID: ").concat(null==(n=this.container)?void 0:n.id)),this._pausedRetryCount>0&&!Zz()&&(this._log.info("".concat(this.kind," player auto resume when paused")),this.resume(),this._pausedRetryCount--),this.stat.fps&&(this.stat.fps=0)),this.viewMirror&&this.element){var i=this.element.style.transform;r===UB.ENTER_PICTURE_IN_PICTURE?this.element.style.transform=i.replace("scaleX(-1)",""):r===UB.LEAVE_PICTURE_IN_PICTURE&&!i.includes("scaleX")&&(this.element.style.transform="".concat(i," scaleX(-1)"))}}}},{key:"setCanvas",value:function(e){var t,n,r,i,o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;this.canvas!==e&&(null==(t=this.canvas)||t.remove(),null==e||e.setAttribute("style",this.styleAttribute),this.canvas=e,this.mode=e?o:0,2===this.mode&&this.setTrack(e.captureStream().getVideoTracks()[0]),e?(null==(n=this.element)||n.remove(),null==(r=this.container)||r.appendChild(e)):this.element&&(null==(i=this.container)||i.appendChild(this.element)))}},{key:"setAttr",value:function(e){var n=Object.assign({autoplay:"autoplay",playsinline:"playsinline",muted:!0},e);n.style=Object.assign({width:"100%",height:"100%"},n.style),y(t,"setAttr",this,3)([n])}},{key:"mirror",get:function(){return this.viewMirror}},{key:"setRect",value:function(e,t){this.elementToRender&&(this.elementToRender.style.width="".concat(e,"px"),this.elementToRender.style.height="".concat(t,"px"))}},{key:"setViewMirror",value:function(e){this.elementToRender&&(this.elementToRender.style.transform=e?"scaleX(-1)":""),this.viewMirror=e}},{key:"setObjectFit",value:function(e){this.elementToRender&&(this.elementToRender.style.objectFit="".concat(e)),this.objectFit=e}},{key:"setPoster",value:function(e){this.element&&(this.element.poster=e)}},{key:"stop",value:function(){var e,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;y(t,"stop",this,3)([n]),null==(e=this.canvas)||e.remove()}},{key:"play",value:function(){return this.element?this.elementToRender&&this.elementToRender.parentElement!==this.container&&this.container&&this.container.append(this.elementToRender):this.initializeElement(),2===this.mode?Promise.resolve():y(t,"play",this,3)([])}},{key:"elementToRender",get:function(){return this.canvas||this.element}},{key:"setTrack",value:function(e){e!==this.track&&(this.unbindTrackEvents(),this.track=e,this.emit(bz.MEDIA_TRACK_CHANGED,e),null!==e&&(this.bindTrackEvents(),this.element&&2!==this.mode&&(this.element.srcObject=new MediaStream([e]),this.element.remove()),this.elementToRender&&this.elementToRender.parentElement!==this.container&&this.container&&this.container.append(this.elementToRender)))}},{key:"getVideoFrame",value:function(){if(this.canvas)return this.canvas.toDataURL("image/png");if(!this.element)return"";var e=document.createElement("canvas");return e.width=this.element.videoWidth,e.height=this.element.videoHeight,e.getContext("2d").drawImage(this.element,0,0),e.toDataURL("image/png")}},{key:"getElement",value:function(){return this.element}},{key:"calculateStat",value:function(){var e=this;try{if(sz()&&this.element&&this._calculateTimeout<0){var t=0,n=null,r=function(i,o){e.stat.width=o.width,e.stat.height=o.height,n&&(e.stat.fps=Math.round((o.presentedFrames-n.presentedFrames)/(i-t)*1e3)),t=i,n=o,e._calculateTimeout=-1,e.element&&(e._calculateTimeout=setTimeout((function(){var t;return null==(t=e.element)?void 0:t.requestVideoFrameCallback(r)}),2e3))};this.element.requestVideoFrameCallback(r)}}catch(t){this._log.warn("init stat failed",t)}}}])}(Mz);function aq(e,t){return HF(this,null,p().mark((function n(){return p().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(e.audioWorklet){n.next=2;break}return n.abrupt("return",Promise.reject("audioWorklet is not supported"));case 2:return n.prev=2,n.next=5,e.audioWorklet.addModule(t);case 5:qW.info("worklet addModule success"),n.next=11;break;case 8:throw n.prev=8,n.t0=n.catch(2),qW.info("worklet addModule catch error. ".concat(n.t0.message)),n.t0;case 11:case"end":return n.stop()}}),n,null,[[2,8]])})))}"undefined"!=typeof AudioContext?Lz=AudioContext:"undefined"!=typeof webkitAudioContext?Lz=webkitAudioContext:"undefined"!=typeof mozAudioContext&&(Lz=mozAudioContext);var sq,cq=-1;!function e(){try{if(sq)return;(sq=new Lz({sampleRate:48e3})).onstatechange=function(){qW.info("context state: ".concat(sq.state).concat("running"!==sq.state?" visibilityState: ".concat(document.visibilityState):"")),uq()},clearTimeout(cq)}catch(Qj){qW.error("initAudioContext failed: ".concat(Qj," typeof AudioContextClass: ").concat(S(Lz))),cq=setTimeout(e,1e3)}}();var uq=function(){"suspended"===sq.state?(hq(),document.addEventListener("click",uq)):"interrupted"===sq.state?hq():(document.removeEventListener("visibilitychange",uq),document.removeEventListener("click",uq))},lq=0,dq=-1;function hq(){return new Promise((function(e,t){if("running"===sq.state)return e();Date.now()-lq<1e3?(clearTimeout(dq),dq=setTimeout((function(){lq=Date.now(),sq.resume().then(e,t)}),1e3)):(clearTimeout(dq),lq=Date.now(),sq.resume().then(e,t))})).catch((function(e){qW.warn("context resume failed: ".concat(e)),document.addEventListener("visibilitychange",uq)}))}document.addEventListener("click",uq);var fq=function(e){return sq},pq=function(){return s((function e(){i(this,e),FF(this,"node"),FF(this,"node2"),FF(this,"pre",new Set),FF(this,"next",new Set),FF(this,"context"),FF(this,"connectedNodes",new Set)}),[{key:"setContext",value:function(e){this.context=e,this.node&&e.addMixWeight()}},{key:"removeContext",value:function(){var e;this.node&&(null==(e=this.context)||e.reduceMixWeight()),delete this.context}},{key:"replaceNode",value:function(e){var t;if(e!==this.node)try{this.node?this._disconnect():null==(t=this.context)||t.addMixWeight(),this.node=e,this.preNodeReconnect(),this.reconnect()}catch(hH){qW.error(hH)}}},{key:"setNode",value:function(e,t){var n;if(!this.node)try{null==(n=this.context)||n.addMixWeight(),this.node=e,t&&(this.node2=t),this.preNodeReconnect(),this.reconnect(),fK.addSuccessEvent({key:502701})}catch(iJ){qW.error(iJ),fK.addFailedEvent({key:502701,error:iJ})}}},{key:"deleteNode",value:function(){var e;if(this.node)try{this._disconnect(),delete this.node,delete this.node2,null==(e=this.context)||e.reduceMixWeight(),this.preNodeReconnect(),fK.addSuccessEvent({key:502702})}catch(dB){qW.error(dB),fK.addFailedEvent({key:502702,error:dB})}}},{key:"preNodeReconnect",value:function(){this.pre.forEach((function(e){e.node?e.reconnect():e.preNodeReconnect()}))}},{key:"connectNext",value:function(e){this.next.forEach((function(t){e._connect(t.node)||t.connectNext(e)}))}},{key:"_connect",value:function(e){return!(!this.node||!e)&&((this.node2||this.node).connect(e),this.connectedNodes.add(e),!0)}},{key:"_disconnect",value:function(){var e=this;this.connectedNodes.forEach((function(t){var n;return null==(n=e.node2||e.node)?void 0:n.disconnect(t)})),this.connectedNodes.clear()}},{key:"reconnect",value:function(){this._disconnect(),this.connectNext(this)}},{key:"pipeTo",value:function(){for(var e=this,t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return n.forEach((function(t){e.next.add(t),t.pre.add(e)})),this}}])}(),mq=function(e){function t(){var e,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:256;return i(this,t),(e=r(this,t)).fftSize=n,FF(e,"dataArray",new Uint8Array(0)),e}return d(t,e),s(t,[{key:"setNode",value:function(e){e.fftSize=this.fftSize,this.dataArray=new Uint8Array(e.frequencyBinCount),y(t,"setNode",this,3)([e])}},{key:"getByteTimeDomainData",value:function(){var e;return null==(e=this.node)||e.getByteTimeDomainData(this.dataArray),this.dataArray}},{key:"level",get:function(){var e;return null==(e=this.node)||e.getByteTimeDomainData(this.dataArray),Math.max.apply(Math,T(this.dataArray))/128-1}},{key:"timeDomainPathData",get:function(){for(var e=this.getByteTimeDomainData(),t=0,n=0,r="M".concat(t,",").concat(n),i=0;i<e.length;i++)n=e[i]/128*100/2,r+="L".concat(t,",").concat(n),t+=1;return r}}])}(pq),vq=function(){return s((function e(){i(this,e),FF(this,"source",new pq),FF(this,"gain",new pq),FF(this,"destination",new pq)}),[{key:"volume",get:function(){var e;return(null==(e=this.gain.node)?void 0:e.gain.value)||1}},{key:"setVolume",value:function(e){1!==e?(this.gain.node||this.gain.setNode(fq().createGain()),this.gain.node.gain.value=e):this.gain.node&&this.gain.deleteNode()}},{key:"replaceSource",value:function(e){this.source.replaceNode(Eq(e))}},{key:"track",get:function(){var e;return null==(e=this.stream)?void 0:e.getAudioTracks()[0]}},{key:"stream",get:function(){var e;return null==(e=this.destination.node)?void 0:e.stream}}])}(),_q=function(e){function t(e){var n;return i(this,t),(n=r(this,t)).context=e,FF(n,"denoiser",new pq),FF(n,"voiceChanger",new pq),n.source.pipeTo(n.denoiser.pipeTo(n.voiceChanger.pipeTo(n.gain.pipeTo(n.destination)))),n}return d(t,e),s(t,[{key:"connect",value:function(){this.context.inputs.has(this)||(this.destination.setNode(this.context.destination),this.source.setContext(this.context),this.denoiser.setContext(this.context),this.voiceChanger.setContext(this.context),this.gain.setContext(this.context),this.context.inputs.add(this))}},{key:"disconnect",value:function(){this.context.inputs.has(this)&&(this.destination.deleteNode(),this.source.removeContext(),this.denoiser.removeContext(),this.voiceChanger.removeContext(),this.gain.removeContext(),this.context.inputs.delete(this))}},{key:"remove",value:function(){this.gain.deleteNode(),this.denoiser.deleteNode(),this.voiceChanger.deleteNode(),this.source.deleteNode(),this.disconnect()}},{key:"setVolume",value:function(e){1!==e?(this.gain.node||this.gain.setNode(this.context.audioContext.createGain()),this.gain.node.gain.value=e):this.gain.node&&this.gain.deleteNode()}}])}(vq),gq=function(){return s((function e(){i(this,e),FF(this,"audioContext",fq()),FF(this,"destination",this.audioContext.createMediaStreamDestination()),FF(this,"inputs",new Set),FF(this,"mixWeight",0),this.destination.channelCount=1}),[{key:"addMixWeight",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1;this.mixWeight+=e,this.mixWeight-1==e+1>>1&&this.mixOnChange()}},{key:"reduceMixWeight",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1;this.addMixWeight(-e)}},{key:"close",value:function(){this.inputs.forEach((function(e){return e.remove()}))}},{key:"mixTrack",get:function(){return this.destination.stream.getAudioTracks()[0]}}])}(),yq=new WeakMap;function Eq(e){var t=yq.get(e);if(t)return t;var n=fq();if(e instanceof HTMLAudioElement)t=n.createMediaElementSource(e);else{if(!(e instanceof MediaStreamTrack))return e;t=n.createMediaStreamSource(new MediaStream([e]))}return yq.set(e,t),t}var Tq=function(){function e(t){i(this,e),FF(this,"_volume",0),FF(this,"_volumeDb",0),FF(this,"_log"),FF(this,"_scriptProcessorNode",null),FF(this,"_audioWorkletNode",null),FF(this,"_interval",200),FF(this,"ready",this.preload());var n=t.log;this._log=n,HW.on(GW.AUDIO_LEVEL_INTERVAL,this.handleAudioLevelInterval,this)}return s(e,[{key:"node",get:function(){return this._audioWorkletNode||this._scriptProcessorNode}},{key:"preload",value:function(){var t=this;if(!e.workletReady){e.workletReady=aq(e.audioContext,URL.createObjectURL(new Blob(['class VolumeMeterWorklet extends AudioWorkletProcessor{constructor(){super(),this.volume=0,this.intervalTime=200,this.tick=200,this.isStop=!1,this.cache=[],this.sentFirstInfo1=!1,this.unmute=!1,this.port.onmessage=t=>{var e=t.data;switch(e.name){case"chunk":this.cache.push(...e.data),this.sentFirstInfo1||(this.port.postMessage({cl:e.data.length}),this.sentFirstInfo1=!0);break;case"setIntervalTime":this.intervalTime=e.intervalTime;break;case"unmute":this.unmute=!0;break;case"stop":this.isStop=!0}}}process(t,s){t=t[0],s=s[0];if(t||s){if(this.isStop)return!1;var i=s&&s[0]?s[0].length:0,h=this.cache.length,a=(i<h?(s[0].set(this.cache.slice(0,i)),this.cache=this.cache.slice(i)):this.unmute&&s[0].set(t[0]),(i<h?s:t)[0]);if(a){let e=0;for(let t=0;t<a.length;++t)e=Math.max(Math.abs(a[t]),e);s=a.reduce((t,e)=>t+e*e,0)/a.length;this.volume=e,this.tick-=a.length,this.tick<0&&(this.tick+=this.intervalTime/1e3*sampleRate,this.port.postMessage({volume:this.volume,volumeDb:Math.max(10*Math.log10(s)+100,0)/100,cacheLen:h,outputLen:i}))}}return!0}}registerProcessor("volume-meter",VolumeMeterWorklet);'],{type:"application/javascript"})))}return e.workletReady.then((function(){return t.initAudioWorklet()})).catch((function(e){return t._log.error("volumeMeter preload error: ".concat(e)),t.initScriptProcessor()}))}},{key:"initAudioWorklet",value:function(){var t=this;if(!this._audioWorkletNode)try{this._audioWorkletNode=new AudioWorkletNode(e.audioContext,"volume-meter");var n=!1;this._audioWorkletNode.port.onmessage=function(r){e.lastMessageTime=Date.now(),t._volume=r.data.volume||0,t._volumeDb=r.data.volumeDb||0,!n&&r.data.cacheLen&&r.data.outputLen&&(t._log.warn("worklet play success"),n=!0)},this.handleAudioLevelInterval({interval:this._interval})}catch(n){this._log.error("volumeMeter init audio worklet error: ".concat(n)),Nz.logFailedEvent({userId:this._log.userId,eventType:pH.LOAD_WORKLET,error:n}),this.initScriptProcessor()}}},{key:"initScriptProcessor",value:function(){var t=this;if(!this._scriptProcessorNode)try{this._scriptProcessorNode=fq().createScriptProcessor(2048,1,1),this._scriptProcessorNode.onaudioprocess=function(n){e.lastMessageTime=Date.now();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}}catch(rJ){this._log.error("volumeMeter init script processor error: ".concat(rJ))}}},{key:"destroy",value:function(){this._scriptProcessorNode&&(this._scriptProcessorNode.onaudioprocess=null),this._audioWorkletNode&&(this._audioWorkletNode.port.postMessage({name:"stop"}),this._audioWorkletNode.port.onmessage=null),this._audioWorkletNode=null,this._scriptProcessorNode=null,HW.off(GW.AUDIO_LEVEL_INTERVAL,this.handleAudioLevelInterval,this)}},{key:"getInternalAudioLevel",value:function(){return this._volume}},{key:"getCalculatedVolume",value:function(){return parseFloat(this._volume.toFixed(2))}},{key:"getVolumeDb",value:function(){return Math.floor(100*this._volumeDb)}},{key:"handleAudioLevelInterval",value:function(e){var t,n=e.interval;this._interval=n,null==(t=this._audioWorkletNode)||t.port.postMessage({name:"setIntervalTime",intervalTime:n})}}],[{key:"isRunning",get:function(){return Date.now()-e.lastMessageTime<2e3}}])}();FF(Tq,"lastMessageTime",0),FF(Tq,"audioContext",fq()),FF(Tq,"workletReady");var kq=Tq,Sq=function(e){function t(e){var n;return i(this,t),n=r(this,t),FF(n,"_volumeMeter"),n._volumeMeter=new kq(e),n}return d(t,e),s(t,[{key:"deleteNode",value:function(){y(t,"deleteNode",this,3)([]),this._volumeMeter.destroy()}},{key:"init",value:function(){return HF(this,null,p().mark((function e(){return p().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._volumeMeter.preload();case 2:this.setNode(this._volumeMeter.node);case 3:case"end":return e.stop()}}),e,this)})))}},{key:"getCalculatedVolume",value:function(){return this._volumeMeter.getCalculatedVolume()}},{key:"getInternalAudioLevel",value:function(){return this._volumeMeter.getInternalAudioLevel()}},{key:"getVolumeDb",value:function(){return this._volumeMeter.getVolumeDb()}},{key:"write",value:function(e){if(this.node){var t=e.allocationSize({planeIndex:0}),n=new Float32Array(t>>2);e.copyTo(n,{planeIndex:0}),this.node.port.postMessage({name:"chunk",data:n},[n.buffer]),e.close()}}}])}(pq),Iq=kq,bq=VF(jF(),1),Aq=function(e){return function(t){return t.deviceId===e}},Rq=function(){return s((function e(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"Input";i(this,e),FF(this,"kind"),FF(this,"type"),FF(this,"devices",[]),this.kind=t,this.type=n}),[{key:"update",value:function(e,t){var n=this,r=e.filter((function(e){return e.kind==="".concat(n.kind).concat(n.type.toLocaleLowerCase())}));1===this.devices.length&&Dq(this.devices[0])||t&&(r.forEach((function(e){if(e.deviceId&&!n.devices.find(Aq(e.deviceId))){var r="".concat(n.kind).concat(n.type,"Added");qW.warn("".concat(r,": ").concat(JSON.stringify(e))),t.emit(r,e)}})),this.devices.forEach((function(e){if(e.deviceId&&!r.find(Aq(e.deviceId))){var i="".concat(n.kind).concat(n.type,"Removed");qW.warn("".concat(i,": ").concat(JSON.stringify(e))),t.emit(i,e)}}))),this.devices=r}},{key:"hasDevice",value:function(e){return!!this.devices.find((function(t){return t.deviceId===e}))}}])}(),Cq=function(e){function t(){var e;return i(this,t),e=r(this,t),FF(e,"audioInputs",new Rq(UB.AUDIO)),FF(e,"videoInputs",new Rq(UB.VIDEO)),FF(e,"audioOutputs",new Rq(UB.AUDIO,"Output")),e.init(),navigator.mediaDevices&&(navigator.mediaDevices.addEventListener&&navigator.mediaDevices.addEventListener("devicechange",(function(){return e.update()})),"ondevicechange"in navigator.mediaDevices||Iz.run("interval",(function(){e.update()}),{delay:1e4})),e}return d(t,e),s(t,[{key:"init",value:function(){var e=this;Nq().then((function(t){e.audioInputs.update(t),e.videoInputs.update(t),e.audioOutputs.update(t)}))}},{key:"update",value:function(){return HF(this,arguments,(function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;return p().mark((function n(){var r;return p().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,Nq(t);case 2:return r=n.sent,n.abrupt("return",(e.audioInputs.update(r,e),e.videoInputs.update(r,e),e.audioOutputs.update(r,e),e));case 4:case"end":return n.stop()}}),n)}))()}))}}])}(bq.EventEmitter),wq=pB||fB?null:new Cq;function Dq(e){return e.deviceId===e.groupId&&""===e.groupId}function Nq(){return HF(this,arguments,(function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;return p().mark((function t(){var n,r,i;return p().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!TK()&&yK()){t.next=2;break}return t.abrupt("return",[]);case 2:return t.next=4,navigator.mediaDevices.enumerateDevices();case 4:if(n=t.sent,0===e){t.next=22;break}if(r={audio:!1,video:!1},n.forEach((function(e){Dq(e)&&(e.kind===UB.AUDIO_INPUT?r.audio=!0:e.kind===UB.VIDEO_INPUT&&(r.video=!0))})),2===e&&(r.audio=!1),1===e&&(r.video=!1),!r.audio&&!r.video){t.next=22;break}return t.prev=8,t.next=11,navigator.mediaDevices.getUserMedia(r);case 11:i=t.sent,r.audio&&hq(),t.next=18;break;case 15:t.prev=15,t.t0=t.catch(8),qW.debug("capture before getDevices failed: ",t.t0);case 18:return t.next=20,navigator.mediaDevices.enumerateDevices();case 20:n=t.sent,null==i||i.getTracks().forEach((function(e){return e.stop()}));case 22:return t.abrupt("return",n.map((function(e,t){var n={kind:e.kind,deviceId:e.deviceId,groupId:e.groupId,label:e.label||"".concat(e.kind,"_").concat(t)};return e.deviceId.length>0&&Vq.add("".concat(e.deviceId,"_").concat(e.kind)),e.getCapabilities&&(n.getCapabilities=function(){return e.getCapabilities()}),n})));case 23:case"end":return t.stop()}}),t,null,[[8,15]])}))()}))}function xq(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return wq.update(e?1:0).then((function(e){return e.audioInputs.devices}))}function Oq(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return wq.update(e?2:0).then((function(e){return e.videoInputs.devices}))}var Pq=!1;function Mq(){return HF(this,null,p().mark((function e(){return p().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(e.prev=0,e.t0=Pq,e.t0){e.next=11;break}return Pq=!0,e.t1=qW,e.t2="speakers:",e.next=8,Lq();case 8:e.t3=e.sent.map((function(e){return" ".concat(e.deviceId.slice(0,8),": ").concat(e.label)})),e.t4=e.t2.concat.call(e.t2,e.t3),e.t1.info.call(e.t1,e.t4);case 11:e.next=15;break;case 13:e.prev=13,e.t5=e.catch(0);case 15:case"end":return e.stop()}}),e,null,[[0,13]])})))}function Lq(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return HF(this,null,p().mark((function t(){return p().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",((cG||vW)&&(e=!1),wq.update(e?1:0).then((function(e){return e.audioOutputs.devices}))));case 1:case"end":return t.stop()}}),t)})))}var Vq=new Set;function Uq(e,t){return HF(this,null,p().mark((function n(){var r;return p().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,xq();case 2:return r=n.sent.find((function(e){return e.deviceId===NH})),n.abrupt("return",!t&&(null==r?void 0:r.groupId)===e||(null==r?void 0:r.groupId)===e&&r.label===t);case 4:case"end":return n.stop()}}),n)})))}function Fq(e){return HF(this,arguments,(function(e){var t=e.newDeviceId,n=e.oldDeviceId,r=e.oldGroupId,i=e.oldLabel,o=e.kind;return p().mark((function e(){return p().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t===n){e.next=4;break}e.t0=!1,e.next=12;break;case 4:if(o!==UB.AUDIO||t!==NH){e.next=10;break}return e.next=7,Uq(r,i);case 7:e.t1=e.sent,e.next=11;break;case 10:e.t1=!0;case 11:e.t0=e.t1;case 12:return e.abrupt("return",e.t0);case 13:case"end":return e.stop()}}),e)}))()}))}var Bq,Hq=function(e){function t(e){var n;return i(this,t),(n=r(this,t)).log=e,FF(n,"volumeMeter"),FF(n,"volumeDestination"),FF(n,"analyser",new mq),n.volumeMeter=new Sq({log:n.log}),n.volumeDestination=new pq,n.volumeMeter.pipeTo(n.volumeDestination),n}return d(t,e),s(t,[{key:"destroy",value:function(){this.gain.deleteNode(),this.volumeMeter.deleteNode(),this.analyser.deleteNode(),this.source.deleteNode(),this.destination.deleteNode(),this.volumeDestination.deleteNode()}}])}(vq),jq=function(e){function t(e){var n;return i(this,t),n=r(this,t,[e,UB.AUDIO]),FF(n,"_outputDeviceId"),FF(n,"_volume",1),FF(n,"_destination",fq().createMediaStreamDestination()),FF(n,"pipeline"),FF(n,"volumeMeterMode","worklet"),n.mode=0,n.pipeline=new Hq(n._log),n}return d(t,e),s(t,[{key:"getMediaStream",value:function(){return this.pipeline.stream||(this.track?new MediaStream([this.track]):null)}},{key:"initializeElement",value:function(e){if("15.2"!==EW&&"15.3"!==EW&&"15.4"!==EW||!this.muted){var t=Bq||new Audio;t.setAttribute("autoplay","autoplay"),t.srcObject=this.getMediaStream(),t.muted=this.muted,this.element=t,cj(e)&&(this.element.volume=Math.min(Math.max(e,0),1)),t===Bq&&(Bq=void 0),this.bindElementEvents()}else this._log.info("audioElement is muted.")}},{key:"play",value:function(e){return HF(this,null,p().mark((function n(){return p().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(!this.track){n.next=10;break}if(this.pipeline.source.node||this.pipeline.replaceSource(this.track),this.element||this.initializeElement(null==e?void 0:e.volume),n.t0=this._outputDeviceId,!n.t0){n.next=7;break}return n.next=7,this.setSinkId(this._outputDeviceId);case 7:return"worklet"===this.volumeMeterMode?this.pipeline.volumeMeter.init():"analyser"===this.volumeMeterMode&&this.pipeline.analyser.setNode(fq().createAnalyser()),Mq(),n.abrupt("return",BF(t.prototype,this,"play").call(this));case 10:case"end":return n.stop()}}),n,this)})))}},{key:"stop",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;this.pipeline.destroy(),y(t,"stop",this,3)([e])}},{key:"setSinkId",value:function(e){return HF(this,null,p().mark((function t(){var n,r;return p().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this._outputDeviceId!==e&&(this._outputDeviceId=e),t.t0=this.element&&this.element.sinkId!==e,!t.t0){t.next=5;break}return t.next=5,null==(r=(n=this.element).setSinkId)?void 0:r.call(n,e);case 5:case"end":return t.stop()}}),t,this)})))}},{key:"useDestination",get:function(){return!!this.pipeline.stream}},{key:"setLoop",value:function(e){this.element&&(this.element.loop=e)}},{key:"getAudioLevel",value:function(){return this.pipeline.volumeMeter.getCalculatedVolume()}},{key:"getInternalAudioLevel",value:function(){return this.pipeline.volumeMeter.getInternalAudioLevel()}}])}(Mz),Gq=function(e){function t(){return i(this,t),r(this,t,arguments)}return d(t,e),s(t,[{key:"setTrack",value:function(e){this.track!==e&&(this.unbindTrackEvents(),this.track=e,this.emit(bz.MEDIA_TRACK_CHANGED,e),e&&(this.bindTrackEvents(),this.element&&(this.element.srcObject=new MediaStream([e]))))}},{key:"setVolume",value:function(e){this._volume=e,this.element&&(this.element.volume=e)}}])}(jq),Wq=function(e){function t(e){var n;return i(this,t),n=r(this,t,[e]),FF(n,"_sourceElement"),FF(n,"_output",new pq),n.pipeline.source.pipeTo(n.pipeline.gain.pipeTo(n.pipeline.volumeMeter.pipeTo(n._output),n.pipeline.destination)),n}return d(t,e),s(t,[{key:"setOutput",value:function(){this.mode=1,this._output.setNode(fq().destination)}},{key:"write",value:function(e){this.pipeline.volumeMeter.write(e)}},{key:"setTrack",value:function(e){var t,n;(null==(n=null==(t=this.element)?void 0:t.error)?void 0:n.code)!==MediaError.MEDIA_ERR_DECODE&&this.track!==e&&(this.unbindTrackEvents(),this.track=e,this.emit(bz.MEDIA_TRACK_CHANGED,e),e?(this.bindTrackEvents(),this._sourceElement?this._sourceElement.srcObject=new MediaStream([e]):!this.useDestination&&this.element&&(this.element.srcObject=new MediaStream([e])),this.pipeline.replaceSource(e)):this.pipeline.source.deleteNode())}},{key:"setVolume",value:function(e){this._volume=e,this.useDestination?(this.pipeline.setVolume(e),this._log.info("set pipeline volume: ".concat(e))):e<=1?this.element?(this._log.info("set element volume: ".concat(e)),this.element.volume=e):this._log.info("set element volume: no element"):cG||(this._log.info("start set pipeline volume: ".concat(e)),this.pipeline.setVolume(e),this.element&&!this._sourceElement&&(this.pipeline.destination.setNode(this._destination),wz(this.element),this._sourceElement=this.element,this._sourceElement.muted=!0,this.element=null,this.play()))}},{key:"stop",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;this.pipeline.destroy();var n=this._sourceElement||this.element;n&&_W&&(Bq=n),this._sourceElement&&(this._sourceElement.srcObject=null,delete this._sourceElement),y(t,"stop",this,3)([e])}}])}(jq),Jq=function(e){function t(e){var n,o,a=e.userId,s=e.sdkAppId,c=e.mediaType,u=e.room,l=e.PlayerClass,d=void 0===l?1===c?Wq:oq:l;return i(this,t),n=r(this,t),FF(n,"id",YW()),FF(n,"userId",""),FF(n,"isRemote"),FF(n,"mediaType"),FF(n,"room"),FF(n,"user"),FF(n,"_log"),FF(n,"_inputTrack"),FF(n,"_outputTrack"),FF(n,"isPlayCalled"),FF(n,"container",null),FF(n,"player"),FF(n,"subVideoPlayerMap"),FF(n,"muted",!1),FF(n,"abortCtrl"),FF(n,"objectFit","cover"),FF(n,"mirror"),FF(n,"isScreen",!1),FF(n,"manager"),FF(n,"trackSettings"),FF(n,"isFirstVideoFrameEmitted",!1),n.userId=a||"",n.mediaType=c,n._log=qW.createLogger({id:"".concat(n.kind[0],"t"),userId:null==(o=u||n.room)?void 0:o.userId,remoteUserId:n instanceof pY?void 0:n.userId,sdkAppId:s,type:2===n.mediaType?"auxiliary":"main",isLocal:n instanceof pY}),n.player=new d({id:n.userId||n.id,track:null,muted:!1,container:null,log:n._log}),n.player.on(bz.PLAYER_STATE_CHANGED,(function(e){HW.emit(GW.PLAYER_STATE_CHANGED,xF({track:n},e)),n.emit("player-state-changed",e)})),n.kind===UB.VIDEO&&(n.player.on(bz.LOADED_DATA,(function(){n.emitFirstVideoFrameEvent(bz.LOADED_DATA),HW.emit(GW.VIDEO_LOADED_DATA,{track:n})})),n.player.on(bz.LOADED_META_DATA,(function(){n.emitFirstVideoFrameEvent(bz.LOADED_META_DATA)})),n.player.on(bz.MEDIA_TRACK_CHANGED,(function(e){var t;null==(t=n.subVideoPlayerMap)||t.forEach((function(t){return t.setTrack(e)}))}))),n.onTrackMuted=n.onTrackMuted.bind(n),n.onTrackUnmuted=n.onTrackUnmuted.bind(n),n.onTrackEnded=n.onTrackEnded.bind(n),n.onPlayerError&&n.player.on(bz.ERROR,n.onPlayerError.bind(n)),n}return d(t,e),s(t,[{key:"log",get:function(){return this._log||qW}},{key:"kind",get:function(){return 1===this.mediaType?UB.AUDIO:UB.VIDEO}},{key:"strMediaType",get:function(){return 4===this.mediaType?UB.VIDEO:2===this.mediaType?UB.SCREEN:UB.AUDIO}},{key:"streamType",get:function(){return 2&this.mediaType?"auxiliary":"main"}},{key:"isMediaTrackActive",get:function(){return!!this.mediaTrack&&(!this.mediaTrack.muted&&"live"===this.mediaTrack.readyState&&this.mediaTrack.enabled)}},{key:"play",value:function(e,t){return HF(this,null,p().mark((function n(){var r;return p().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(r=dj(e)?e[0]:e,!this.isPlayCalled){n.next=14;break}if(this.log.info("play update options: ".concat(JSON.stringify(t))),t&&!aj(t.muted)&&this.setPlayerMute(t.muted),t&&!aj(t.objectFit)&&(this.objectFit=t.objectFit),n.t0=this.player instanceof oq,!n.t0){n.next=13;break}if(this.player.setObjectFit(this.objectFit),this.container!==r&&r&&(this.container=r,this.player.setContainer(r)),n.t1=dj(e)&&e.length>=1,!n.t1){n.next=13;break}return n.next=13,this.playSubContainer(e.slice(1),t);case 13:return n.abrupt("return");case 14:if(t&&!aj(t.muted)?this.setPlayerMute(t.muted):(!this.isRemote||this.kind===UB.VIDEO)&&this.setPlayerMute(!0),t&&!aj(t.objectFit)&&(this.objectFit=t.objectFit),this.player instanceof oq&&(this.player.setObjectFit(this.objectFit),t&&!aj(t.poster)&&this.player.setPoster(t.poster)),this.isPlayCalled=!0,r&&(this.container=r,this.player instanceof oq&&this.player.setContainer(r)),HW.emit(GW.PLAY_TRACK_START,{track:this}),this._outputTrack){n.next=17;break}return this.log.info("play has not mediaTrack, abort"),n.abrupt("return");case 17:return this._log.info("play with options: ".concat(JSON.stringify(t))),n.prev=18,this.player.setTrack(this.playerMediaTrack),n.next=22,this.player.play(t);case 22:if(n.t2=dj(e)&&e.length>1,!n.t2){n.next=26;break}return n.next=26,this.playSubContainer(e.slice(1),t);case 26:n.next=31;break;case 28:throw n.prev=28,n.t3=n.catch(18),this.handleAutoPlayFailed(n.t3),n.t3;case 31:case"end":return n.stop()}}),n,this,[[18,28]])})))}},{key:"setMirror",value:function(e,t){if(!this.isScreen&&this.kind===UB.VIDEO&&!aj(e)&&e!==this.mirror){this.mirror=e;var n=this.player;t&&(n=t);var r=this.manager;if(uj(this.mirror))return n.setViewMirror(this.mirror),void(r&&(r.mirror=!1));switch(this.mirror){case"view":r&&(r.mirror=!1),n.setViewMirror(!0);break;case"publish":r&&(r.mirror=!0),n.setViewMirror(!0);break;case"both":r&&(r.mirror=!0),n.setViewMirror(!1)}}}},{key:"playSubContainer",value:function(e,t){return HF(this,null,p().mark((function n(){var r,i,o,a,s,u,l,d,h,f,m=this;return p().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(this._outputTrack&&this.kind!==UB.AUDIO){n.next=2;break}return n.abrupt("return");case 2:this.subVideoPlayerMap||(this.subVideoPlayerMap=new Map),this.subVideoPlayerMap.forEach((function(t,n){var r;e.find((function(e){return n===e}))||(t.stop(),null==(r=m.subVideoPlayerMap)||r.delete(n))})),r=c(e.entries());try{for(r.s();!(i=r.n()).done;)o=_(i.value,2),a=o[0],s=o[1],(u=this.subVideoPlayerMap.get(s))?t&&(aj(t.objectFit)||u.setObjectFit(t.objectFit)):this.subVideoPlayerMap.set(s,new oq({id:this.userId||this.id,track:this.playerMediaTrack,container:s,muted:this.player.muted,objectFit:this.objectFit,log:this.log.createChild({id:"vp-sub".concat(a+1)})}))}catch(p){r.e(p)}finally{r.f()}l=T(this.subVideoPlayerMap.values()),d=c(l),n.prev=7,d.s();case 9:if((h=d.n()).done){n.next=16;break}return(f=h.value).setViewMirror(this.player.mirror),n.next=14,f.play();case 14:n.next=9;break;case 16:n.next=21;break;case 18:n.prev=18,n.t0=n.catch(7),d.e(n.t0);case 21:return n.prev=21,d.f(),n.finish(21);case 24:case"end":return n.stop()}}),n,this,[[7,18,21,24]])})))}},{key:"setAudioOutput",value:function(e){return this.player.setSinkId(e)}},{key:"setAudioVolume",value:function(e){this.player.setVolume(e)}},{key:"getAudioLevel",value:function(){return this.player.getAudioLevel()||0}},{key:"getInternalAudioLevel",value:function(){var e;return(null==(e=this.player)?void 0:e.getInternalAudioLevel())||0}},{key:"stop",value:function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];this.isPlayCalled&&(this.isPlayCalled=!1,this.player&&(this.log.info("stop ".concat(this.kind," player")),this.player.stop(Kj(this)&&!e?this.jitterBufferDelay:0)),this.subVideoPlayerMap&&this.subVideoPlayerMap.size>0&&this.subVideoPlayerMap.forEach((function(e){e.stop()})),this.container=null)}},{key:"resume",value:function(){return HF(this,null,p().mark((function e(){var t;return p().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(e.t0=this.isPlayCalled,!e.t0){e.next=4;break}return e.next=4,null==(t=this.player)?void 0:t.resume();case 4:case"end":return e.stop()}}),e,this)})))}},{key:"close",value:function(){this.log.info("close"),this.isPlayCalled&&this.stop(!0)}},{key:"setMute",value:function(e){this.muted=e,this._inputTrack&&(this._inputTrack.enabled=!e),this._outputTrack&&(this._outputTrack.enabled=!e),this.emit(e?"mute":"unmute",this),HW.emit(e?GW.TRACK_MUTED:GW.TRACK_UNMUTED,{track:this})}},{key:"setPlayerMute",value:function(e){this.player.setMuted(e)}},{key:"mediaTrack",get:function(){return this._inputTrack||null}},{key:"outMediaTrack",get:function(){return this._outputTrack||null}},{key:"playerMediaTrack",get:function(){return this.outMediaTrack}},{key:"installTrackEvent",value:function(e){Cz(e,e).add(UB.MUTE,this.onTrackMuted).add(UB.UNMUTE,this.onTrackUnmuted).add(UB.ENDED,this.onTrackEnded),e.muted&&this.onTrackMuted(),e.readyState===UB.ENDED&&this.onTrackEnded()}},{key:"uninstallTrackEvent",value:function(e){wz(e)}},{key:"setInputMediaStreamTrack",value:function(e){var t,n=this._inputTrack;if(e!==n)return this._inputTrack=e,this.trackSettings=null==(t=e.getSettings)?void 0:t.call(e),e.enabled=!this.muted,n&&this.uninstallTrackEvent(n),this.installTrackEvent(e),this.emit("input-media-track-changed",e||null,n||null),this.manager?this.manager.changeInput(this):this.setOutputMediaStreamTrack(e)}},{key:"setOutputMediaStreamTrack",value:function(e){var t;e!==this._outputTrack&&(this.isRemote?this.log.debug("setOutputMediaStreamTrack",e.label):this.log.info("setOutputMediaStreamTrack",null==(t=e.getSettings)?void 0:t.call(e).deviceId,e.label),this._outputTrack=e,this._inputTrack&&(this._outputTrack.contentHint=this._inputTrack.contentHint,this._outputTrack.enabled=this._inputTrack.enabled),this.updatePlayingState(!!e),this.emit("output-media-track-changed",e))}},{key:"setMediaType",value:function(e){this.mediaType=e}},{key:"updatePlayingState",value:function(e){var t=this;if(this.isPlayCalled)if(e){if(this.player.setTrack(this.playerMediaTrack),this.player.isStopped)return this.player.play().catch((function(e){return t.handleAutoPlayFailed(e)})),void this.log.info("playing state updated, play ".concat(this.kind))}else if(!this.player.isStopped)return this.player.stop(Kj(this)?this.jitterBufferDelay:0),void this.log.info("playing state updated, stop ".concat(this.kind));this.log.debug("updatePlayingState abort ".concat(this.isPlayCalled," ").concat(e," ").concat(this.player.isStopped))}},{key:"handleAutoPlayFailed",value:function(e){var t=this;if(this.room&&this.room.enableAutoPlayDialog)new iq;else{var n=function(){t.resume().then((function(){document.removeEventListener("click",n,!0)}))};document.addEventListener("click",n,!0)}this.emit("error",e)}},{key:"getVideoFrame",value:function(){return this.player instanceof oq?this.player.getVideoFrame():""}},{key:"emitFirstVideoFrameEvent",value:function(e){var t,n,r;if(!this.isFirstVideoFrameEmitted){var i=null==(t=this.mediaTrack)?void 0:t.getSettings(),o=(null==i?void 0:i.width)||(null==(n=this.player.element)?void 0:n.videoWidth)||0,a=(null==i?void 0:i.height)||(null==(r=this.player.element)?void 0:r.videoHeight)||0;e===bz.LOADED_META_DATA&&!o&&!a||(e===bz.LOADED_DATA&&!o&&!a&&this._log.warn("the dimension of video is 0x0 in first-video-frame event"),this.isFirstVideoFrameEmitted=!0,this.emit("first-video-frame",{width:o,height:a,streamType:this.streamType,userId:this.isRemote?this.userId:""}))}}},{key:"onTrackMuted",value:function(){this._log.warn("".concat(this.kind," track is unable to provide media output"))}},{key:"onTrackUnmuted",value:function(){this._log.info("".concat(this.kind," track is able to provide media output"))}},{key:"onTrackEnded",value:function(){this._log.warn("".concat(this.kind," track ended"))}}])}(gz);UF([mz([],gz.INIT,{sync:!0})],Jq.prototype,"close",1);var Kq=Object.prototype.hasOwnProperty;var zq=function(e){if(null==e)return!0;if("boolean"==typeof e)return!1;if("number"==typeof e)return 0===e;if("string"==typeof e||"function"==typeof e||Array.isArray(e))return 0===e.length;if(e instanceof Error)return""===e.message;if(tj(e))switch(Object.prototype.toString.call(e)){case"[object File]":case"[object Map]":case"[object Set]":return 0===e.size;case"[object Object]":for(var t in e)if(Kq.call(e,t))return!1;return!0}return!1},qq=qj({retryFunction:function(e){return HF(this,null,p().mark((function t(){var n,r,i,o,a,s;return p().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=Xq(e),qW.info("getUserMedia with constraints: ".concat(JSON.stringify(n))),r=[],i=[],o=["label","deviceId","groupId"],t.t0=n.audio,!t.t0){t.next=9;break}return t.next=7,xq();case 7:r=t.sent,qW.info("microphones: ".concat(xj(r.map((function(e){return OF(xF({},e),{groupId:e.groupId.substring(0,8)})})),{keysToInclude:o})));case 9:if(t.t1=n.video,!t.t1){t.next=15;break}return t.next=13,Oq();case 13:i=t.sent,qW.info("cameras: ".concat(xj(i,{keysToInclude:o})));case 15:return t.prev=15,t.next=18,navigator.mediaDevices.getUserMedia(n);case 18:return a=t.sent,t.abrupt("return",(YK&&a.getTracks().forEach((function(e){qW.info("".concat(e.kind," capabilities: ").concat(xj(e.getCapabilities(),{keysToInclude:UH})))})),n.audio&&hq(),a));case 22:throw t.prev=22,t.t2=t.catch(15),s=t.t2.message,"NotFoundError"===t.t2.name&&(e.video&&i&&0===i.length&&(s=rK({key:ZJ.CAMERA_NOT_FOUND})),e.audio&&r&&0===r.length&&(s=rK({key:ZJ.MICROPHONE_NOT_FOUND}))),new tB({code:ZF.INITIALIZE_FAILED,name:t.t2.name,message:s,constraint:t.t2.constraint});case 26:case"end":return t.stop()}}),t,null,[[15,22]])})))},settings:{retries:3,timeout:500},onError:function(e){var t=e.error,n=e.retry,r=e.reject,i=e.retryFuncArgs,o=e.retriedCount+1;"NotReadableError"===t.name||"OverconstrainedError"===t.name?(1===o?(i[0].video&&(i[0].maxResolution=!1,(!vW||i[0].width*i[0].height<=2073600)&&i[0].frameRate&&(i[0].frameRate=i[0].frameRate>10?10:5)),i[0].retryWhenExactFailed&&i[0].useExactDeviceId&&(i[0].useExactDeviceId=!1)):2===o?i[0].useDeviceIdOnly=!0:3===o&&!i[0].useExactDeviceId&&(i[0].useTrueAsConstraint=!0),n()):r(t),i[0].microphoneId&&Yq(i[0].microphoneId,!1),i[0].cameraId&&Yq(i[0].cameraId,!0)},onRetrying:function(e){qW.warn("getUserMedia NotReadableError observed, retrying [".concat(e,"/3]"))},onRetryFailed:function(e){Nz.logFailedEvent({eventType:pH.GET_USER_MEDIA_RETRY,error:e})},onRetrySuccess:function(e){Nz.logSuccessEvent({eventType:pH.GET_USER_MEDIA_RETRY}),Nz.uploadEvent({log:"stat-".concat(pH.GET_USER_MEDIA_RETRY,"-success-").concat(e)})}});function Yq(e,t){return HF(this,null,p().mark((function n(){var r;return p().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(!t){n.next=6;break}return n.next=3,Oq();case 3:n.t0=n.sent,n.next=9;break;case 6:return n.next=8,xq();case 8:n.t0=n.sent;case 9:r=n.t0.find((function(t){return t.deviceId===e})),r&&oj(r.getCapabilities)&&qW.warn(xj(r.getCapabilities(),{keysToInclude:UH}));case 11:case"end":return n.stop()}}),n)})))}function Xq(e){return{audio:Qq(e),video:$q(e)}}function Qq(e){if(!e.audio)return!1;if(e.useTrueAsConstraint)return!0;var t={echoCancellation:!0,noiseSuppression:!0,autoGainControl:!0,sampleRate:e.sampleRate};return!zq(e.microphoneId)&&(t.deviceId=e.useExactDeviceId?{exact:e.microphoneId}:e.microphoneId,e.useDeviceIdOnly)?t:(cj(e.channelCount)&&(t.channelCount=e.channelCount),uj(e.echoCancellation)&&!e.echoCancellation&&(t.echoCancellation=!1),uj(e.noiseSuppression)&&!e.noiseSuppression&&(t.noiseSuppression=!1),uj(e.autoGainControl)&&!e.autoGainControl&&(t.autoGainControl=!1),!!zq(t)||t)}function $q(e){if(!e.video)return!1;if(e.useTrueAsConstraint)return!0;var t=e.maxResolution,n=void 0===t||t,r={};return e.cameraId?r.deviceId=e.useExactDeviceId?{exact:e.cameraId}:e.cameraId:e.facingMode&&(r.facingMode=e.facingMode),e.useDeviceIdOnly&&!zq(r)?r:(e.width&&(r.width={ideal:e.width},n&&!fG&&(r.width.max=e.width)),e.height&&(r.height={ideal:e.height},n&&!fG&&(r.height.max=e.height)),fG&&WG&&e.width&&e.height&&e.width*e.height<101376&&(r.width=e.width,r.height=e.height),e.frameRate&&(r.frameRate=e.frameRate),!!zq(r)||r)}var Zq=qq;function eY(e){return rY((function(t,n){return function(){for(var n=arguments.length,r=new Array(n),i=0;i<n;i++)r[i]=arguments[i];return HF(this,null,p().mark((function n(){return p().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,e.apply(this,r);case 2:return n.abrupt("return",t.apply(this,r));case 3:case"end":return n.stop()}}),n,this)})))}}))}function tY(e){return rY((function(t,n){return function(){for(var n=arguments.length,r=new Array(n),i=0;i<n;i++)r[i]=arguments[i];return HF(this,null,p().mark((function n(){var i;return p().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,t.apply(this,r);case 2:return i=n.sent,n.next=5,e.call.apply(e,[this].concat(r));case 5:return n.abrupt("return",i);case 6:case"end":return n.stop()}}),n,this)})))}}))}function nY(e){return rY((function(t,n){return function(){for(var n=arguments.length,r=new Array(n),i=0;i<n;i++)r[i]=arguments[i];return HF(this,null,p().mark((function n(){return p().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.prev=0,n.next=3,t.apply(this,r);case 3:return n.abrupt("return",n.sent);case 6:n.prev=6,n.t0=n.catch(0),e.call(this,n.t0);case 9:case"end":return n.stop()}}),n,this,[[0,6]])})))}}))}function rY(e){return function(t,n,r){return r.value=e(r.value,n),r}}var iY=function(){var e=!1,t=document.visibilityState;return function(){document.visibilityState!==t&&qW.info("visibility change: ".concat(document.visibilityState)),!e&&(document.addEventListener("visibilitychange",(function(){qW.info("visibility change: ".concat(document.visibilityState)),t=document.visibilityState})),e=!0)}}(),oY=0,aY=function(){return s((function e(){i(this,e),FF(this,"log",qW.createLogger({id:"fq".concat(++oY)})),FF(this,"isRunning",!1),FF(this,"queue",[])}),[{key:"length",get:function(){return this.queue.length}},{key:"lastQueueItem",get:function(){return 0===this.length?null:this.queue[this.length-1]}},{key:"push",value:function(e){var t,n,r=arguments.length>1&&void 0!==arguments[1]&&arguments[1],i=xF({},e),o=new Promise((function(e,t){i.resolve=e,i.reject=t}));return i.promise=o,r?this.length<=1?this.queue.push(i):null==(n=null==(t=this.lastQueueItem)?void 0:t.promise)||n.then(i.resolve,i.reject):this.queue.push(i),this.log.debug("push ".concat(this.length)),this.isRunning||this.callNext(),o}},{key:"shift",value:function(){var e=this.queue.shift();return this.log.debug("shift ".concat(this.length)),e}},{key:"callNext",value:function(){var e=this;if(!this.isRunning&&0!==this.length){this.log.debug("callNext ",this.length);var t=this.queue[0],n=t.fn,r=t.args,i=t.context,o=t.resolve,a=t.reject;this.isRunning=!0,n.apply(i,r).then(o,a).finally((function(){e.isRunning=!1,e.shift(),e.callNext()}))}}}])}(),sY=new WeakMap,cY=new WeakMap;function uY(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return function(t,n,r){var i=r.value;return r.value=function(){for(var t=sY.get(this)||new aY,n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return sY.set(this,t),t.push({fn:i,args:r,context:this},e)},r}}function lY(e){return function(t,n,r){var i=r.value;return r.value=function(){for(var t,n,r,o=[],a=arguments.length,s=new Array(a),c=0;c<a;c++)s[c]=arguments[c];return null==(n=null==(t=sY.get(this))?void 0:t.queue)||n.forEach((function(e){return o.push(e)})),null==(r=cY.get(this))||r.forEach((function(e){return null==e?void 0:e.queue.forEach((function(e){return o.push(e)}))})),o.forEach((function(t){t.reject(new tB({code:ZF.API_CALL_ABORTED,message:e}))})),sY.delete(this),cY.delete(this),i.apply(this,s)},r}}function dY(e){return function(t,n,r){var i=r.value,o=function(t){return e.apply(void 0,T(t))};return r.value=function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];var r=cY.get(this)||new Map,a=r.get(o(t))||new aY;return r.set(o(t),a),cY.set(this,r),a.push({fn:i,args:t,context:this})},r}}function hY(e,t){return rY((function(n,r){return function(){var r=e;try{for(var i=arguments.length,o=new Array(i),a=0;a<i;a++)o[a]=arguments[a];var s=n.apply(this,o),c=yj();return pj(s)?s.then((function(e){return t?fK.addSuccessEvent({key:r,cost:yj()-c}):fK.addSuccessEvent({key:r}),e})).catch((function(e){throw fK.addFailedEvent({key:r,error:e}),e})):(fK.addSuccessEvent({key:r}),s)}catch(s){throw fK.addFailedEvent({key:r,error:s}),s}}}))}var fY=function(e){function t(e,n){var o;return i(this,t),o=r(this,t,[{mediaType:e,PlayerClass:n}]),FF(o,"isRemote",!1),FF(o,"deviceId"),FF(o,"groupId",""),FF(o,"label",""),FF(o,"_isRecapturing",!1),FF(o,"_lastRecaptureTime",0),FF(o,"_onMuteTimeoutId",-1),FF(o,"_encodeCheckTimeoutId",-1),FF(o,"profile"),o}return d(t,e),s(t,[{key:"enableEncodeFrame",get:function(){return!1}},{key:"isPublishing",get:function(){return"publishing"===this.state.toString()}},{key:"isPublished",get:function(){return"publish"===this.state}},{key:"encodeFrame",value:function(e,t){throw new Error("Method not implemented.")}},{key:"installTrackEvent",value:function(e){Cz(e,e).add(UB.MUTE,this.onTrackMuted).add(UB.UNMUTE,this.onTrackUnmuted).add(UB.ENDED,this.onTrackEnded),e.muted&&this.onTrackMuted(),e.readyState===UB.ENDED&&this.onTrackEnded()}},{key:"uninstallTrackEvent",value:function(e){wz(e)}},{key:"setStateToCapture",value:function(){}},{key:"capture",value:function(e){return HF(this,null,p().mark((function t(){var n,r,i,o;return p().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(t.prev=0,r=yj(),HW.emit(GW.LOCAL_TRACK_CAPTURE_START,{track:this}),!e.customSource){t.next=7;break}(i=new MediaStream).addTrack(e.customSource),t.next=11;break;case 7:return null==(n=this.mediaTrack)||n.stop(),t.next=10,Zq(e);case 10:i=t.sent;case 11:return o=i.getTracks()[0],t.next=14,this.setInputMediaStreamTrack(o);case 14:return e.customSource||(this.updateDeviceIdInUse(),this.listenDeviceChange()),HW.emit(GW.LOCAL_TRACK_CAPTURE_SUCCESS,{track:this,cost:yj()-r}),t.abrupt("return",i);case 19:throw t.prev=19,t.t0=t.catch(0),HW.emit(GW.LOCAL_TRACK_CAPTURE_FAILED,{track:this,error:t.t0}),this.log.error("getUserMedia error observed ".concat(t.t0)),t.t0;case 22:case"end":return t.stop()}}),t,this,[[0,19]])})))}},{key:"setInputMediaStreamTrack",value:function(e){return this.state===gz.INIT&&this.setStateToCapture(),y(t,"setInputMediaStreamTrack",this,3)([e])}},{key:"setOutputMediaStreamTrack",value:function(e){var n;if(y(t,"setOutputMediaStreamTrack",this,3)([e]),this.isPublishing||this.isPublished)return null==(n=this.room)?void 0:n.replaceTrack(this)}},{key:"publish",value:function(e,t){return this.room=e,this.emit("4",{mediaType:this.strMediaType,state:"starting",prevState:"stopped"}),this.userId=e.userId,this._log.setUserId(e.userId),this._log.setSdkAppId(e.sdkAppId),t}},{key:"unpublish",value:function(){this.room&&this.room.localTracks.delete(this),HW.emit(GW.LOCAL_TRACK_UNPUBLISHED,{track:this})}},{key:"updateDeviceIdInUse",value:function(){return HF(this,null,p().mark((function e(){var t,n,r,i,o=this;return p().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.mediaTrack||!qK){e.next=7;break}return t=this.mediaTrack.getSettings(),n=t.deviceId,r=t.groupId,i=this.mediaTrack.label,e.next=4,Fq({newDeviceId:n,oldDeviceId:this.deviceId,oldGroupId:this.groupId,oldLabel:this.label,kind:this.kind});case 4:if(e.t0=e.sent,e.t0){e.next=7;break}this.deviceId=n,this.label=i,r&&(this.groupId=r),Nq().then((function(e){var t=e.find((function(e){return e.deviceId===n}));t&&o.emit("2",t)}));case 7:case"end":return e.stop()}}),e,this)})))}},{key:"setProfile",value:function(e){this.log.info("setProfile",e),Object.assign(this.profile,e)}},{key:"isNeedToRecapture",value:function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return!(!this.deviceId||!this.mediaTrack||this.kind===UB.AUDIO&&!function(e){if(e instanceof CanvasCaptureMediaStreamTrack||!(e instanceof MediaStreamTrack))return!1;var t=e.label.toLocaleLowerCase();if(t.includes("mic")||t.includes("麦克风"))return!0;var n="".concat(((null==e?void 0:e.getSettings())||{}).deviceId,"_").concat(UB.AUDIO_INPUT);return!!Vq.has(n)}(this.mediaTrack)||this.kind===UB.VIDEO&&!function(e){if(e instanceof CanvasCaptureMediaStreamTrack||!(e instanceof MediaStreamTrack))return!1;var t=e.label.toLocaleLowerCase();if(t.includes("camera")||t.includes("webcam"))return!0;var n="".concat(((null==e?void 0:e.getSettings())||{}).deviceId,"_").concat(UB.VIDEO_INPUT);return!!Vq.has(n)}(this.mediaTrack)||this._isRecapturing||e&&WG&&vW)}},{key:"onTrackMuted",value:function(){var e=this;if(y(t,"onTrackMuted",this,3)([]),iY(),this.isNeedToRecapture(!0)){if(Date.now()-this._lastRecaptureTime<VH)return void setTimeout((function(){return e.onTrackMuted()}),VH);this._onMuteTimeoutId=setTimeout((function(){return HF(e,null,p().mark((function e(){var t;return p().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(null==(t=this.mediaTrack)||!t.muted){e.next=8;break}if(!cG&&!uG||"visible"===document.visibilityState){e.next=3;break}return e.abrupt("return");case 3:return e.t0=this,e.next=6,this.getRecoverCaptureDeviceId();case 6:e.t1=e.sent,e.t0.recapture.call(e.t0,e.t1);case 8:case"end":return e.stop()}}),e,this)})))}),5e3)}}},{key:"onTrackUnmuted",value:function(){y(t,"onTrackUnmuted",this,3)([]),this._onMuteTimeoutId>0&&clearTimeout(this._onMuteTimeoutId)}},{key:"onTrackEnded",value:function(){return HF(this,null,p().mark((function e(){var n=this;return p().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(BF(t.prototype,this,"onTrackEnded").call(this),!this.isNeedToRecapture()){e.next=9;break}if(!(Date.now()-this._lastRecaptureTime<VH)){e.next=4;break}return setTimeout((function(){return n.onTrackEnded()}),VH),e.abrupt("return");case 4:return e.t0=this,e.next=7,this.getRecoverCaptureDeviceId();case 7:e.t1=e.sent,e.t0.recapture.call(e.t0,e.t1);case 9:case"end":return e.stop()}}),e,this)})))}},{key:"recapture",value:function(e){return HF(this,null,p().mark((function t(){var n,r,i,o=this;return p().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this._isRecapturing&&this._inputTrack){t.next=2;break}return t.abrupt("return");case 2:if(this.log.warn("recapture trying"),null==(n=this._inputTrack)||n.stop(),this._isRecapturing=!0,this._lastRecaptureTime=Date.now(),r={useExactDeviceId:!0},"user"!==e&&"environment"!==e){t.next=8;break}r.facingMode=e,t.next=21;break;case 8:if("audio"!==this.kind){t.next=14;break}return t.next=11,xq();case 11:t.t0=t.sent,t.next=17;break;case 14:return t.next=16,Oq();case 16:t.t0=t.sent;case 17:if(t.t1=t.t0.find((function(t){return t.deviceId===e})),!t.t1){t.next=20;break}i=e;case 20:r.deviceId=i;case 21:return t.abrupt("return",this.capture(r).then((function(){o._isRecapturing=!1,o.log.warn("recapture success"),o.emit("1",{deviceId:o.deviceId}),HW.emit(GW.LOCAL_TRACK_RECAPTURE,{track:o})})).catch((function(e){o._isRecapturing=!1,o.log.warn("recapture failed ".concat(e.message)),o.emit("5",e),HW.emit(GW.LOCAL_TRACK_RECAPTURE,{track:o,error:e})})));case 22:case"end":return t.stop()}}),t,this)})))}},{key:"getRecoverCaptureDeviceId",value:function(){return HF(this,null,p().mark((function e(){var t,n,r,i;return p().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(t=this instanceof EY)||!this.facingMode){e.next=3;break}return e.abrupt("return",this.facingMode);case 3:if(!(n=this.deviceId)){e.next=18;break}if(r=(mY.get(n)||0)+1,mY.set(n,r),!(r>=3)){e.next=18;break}if(!t){e.next=13;break}return e.next=10,Oq();case 10:e.t0=e.sent.find((function(e){return!mY.has(e.deviceId)})),e.next=16;break;case 13:return e.next=15,xq();case 15:e.t0=e.sent.find((function(e){return!mY.has(e.deviceId)}));case 16:(i=e.t0)&&(this.log.warn("".concat(n," capture fail ").concat(r," times, change new ").concat(i.deviceId)),n=i.deviceId);case 18:return e.abrupt("return",n);case 19:case"end":return e.stop()}}),e,this)})))}},{key:"close",value:function(){var e;y(t,"close",this,3)([]),this._inputTrack&&(this._inputTrack.stop(),this.uninstallTrackEvent(this._inputTrack)),null==(e=this.manager)||e.removeInput(this)}}])}(Jq);UF([mz(gz.INIT,"capture",{ignoreError:!0,sync:!0})],fY.prototype,"setStateToCapture",1),UF([uY()],fY.prototype,"capture",1),UF([mz("capture","publish",{ignoreError:!0,success:function(){var e,t,n=this;this.room.localTracks.add(this),HW.emit(GW.LOCAL_TRACK_PUBLISHED,{track:this}),this.emit("4",{mediaType:this.strMediaType,state:"started",prevState:"starting"}),!(((null==(t=null==(e=this.room)?void 0:e.networkQuality)?void 0:t.uplinkNetworkQuality)||0)>3)&&(this._encodeCheckTimeoutId=setTimeout((function(){var e,t;if(!(((null==(t=null==(e=n.room)?void 0:e.networkQuality)?void 0:t.uplinkNetworkQuality)||0)>3)&&n.isPublished&&n.isMediaTrackActive){var r=n.kind===UB.AUDIO,i=n.stat.bytesSent>0;fK[i?"addSuccessEvent":"addFailedEvent"]({key:r?503700:513702}),i||(fK.addEnum({key:r?503701:513703,value:LW()}),Nz.uploadEvent({log:"stat-encode-failed-".concat(n.kind,"-").concat(OW()||VW()),userId:n.userId}),n.log.warn("encode failed"),n.emit("6",n))}}),5e3))},fail:function(e){var t="error";if(e.cause instanceof RTCError){var n=e.cause;n.message.includes("timeout")?t="timeout":n.code===ZF.API_CALL_ABORTED&&(t="api-call")}this.emit("4",{mediaType:this.strMediaType,state:"stopped",prevState:"starting",reason:t,error:e.cause||e})}}),hY(521714,!1)],fY.prototype,"publish",1),UF([rY((function(e){return function(){return HF(this,null,p().mark((function t(){var n;return p().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:n="publish"===this.state?"started":"starting",e.call(this),this.emit("4",{mediaType:this.strMediaType,state:"stopped",prevState:n,reason:"api-call"}),clearTimeout(this._encodeCheckTimeoutId);case 2:case"end":return t.stop()}}),t,this)})))}})),mz([],"capture",{sync:!0})],fY.prototype,"unpublish",1);var pY=fY,mY=new Map;HW.on(GW.SWITCH_DEVICE_SUCCESS,(function(e){e.track.deviceId&&mY.delete(e.track.deviceId)}));var vY=function(e){function t(e){var n;return i(this,t),n=r(this,t,[1,Gq]),FF(n,"mediaType",1),FF(n,"volume",0),FF(n,"profile",{echoCancellation:!0,autoGainControl:!0,noiseSuppression:!0,sampleRate:48e3,channelCount:1,bitrate:40}),FF(n,"playerMuted",!0),FF(n,"pipeline"),FF(n,"earMonitorGainNode",new pq),FF(n,"_output",new pq),FF(n,"stat",{bytesSent:0,packetsSent:0,audioLevel:0,totalAudioEnergy:0}),n.manager=e,n.pipeline=new _q(e),n.pipeline.gain.pipeTo(n.earMonitorGainNode.pipeTo(n._output),n.player.pipeline.volumeMeter),n.handleMicrophoneAdded=n.handleMicrophoneAdded.bind(n),n.handleMicrophoneRemoved=n.handleMicrophoneRemoved.bind(n),n}return d(t,e),s(t,[{key:"dbVolume",get:function(){return Iq.isRunning?this.player.pipeline.volumeMeter.getVolumeDb():Math.floor(Math.max(10*Math.log10(this.volume)+100,0))}},{key:"getAudioLevel",value:function(){var e=(this.volume||y(t,"getAudioLevel",this,3)([]))*this.captureVolume;return e>1?1:e}},{key:"setInputMediaStreamTrack",value:function(e){return HF(this,null,p().mark((function n(){var r,i,o;return p().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=this.trackSettings||{},fK.addEnum({key:501701,value:r.channelCount||0,useUV:!1}),fK.addEnum({key:501702,value:r.sampleRate||0,useUV:!1}),fK.addEnum({key:502700,value:0}),i=r.sampleRate,o=r.channelCount,this._log.info("local audio track input ".concat(JSON.stringify({sampleRate:i,channelCount:o}))),this.pipeline.replaceSource(e),n.next=7,BF(t.prototype,this,"setInputMediaStreamTrack").call(this,e);case 7:this.updatePlayingState(!!e);case 8:case"end":return n.stop()}}),n,this)})))}},{key:"capture",value:function(e){var n=e.deviceId,r=e.customSource,i=e.useExactDeviceId,o=void 0===i||i,a=e.retryWhenExactFailed,s=void 0===a||a;return y(t,"capture",this,3)([{video:!1,audio:!0,microphoneId:n,echoCancellation:this.profile.echoCancellation,autoGainControl:this.profile.autoGainControl,noiseSuppression:this.profile.noiseSuppression,sampleRate:this.profile.sampleRate,channelCount:this.profile.channelCount,useExactDeviceId:o,retryWhenExactFailed:s,customSource:r}])}},{key:"switchDevice",value:function(e){return HF(this,null,p().mark((function t(){return p().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.mediaTrack){t.next=22;break}if(this.deviceId!==e){t.next=10;break}if(e!==NH){t.next=9;break}return t.next=5,Uq(this.groupId,this.label);case 5:if(!t.sent){t.next=7;break}return t.abrupt("return");case 7:t.next=10;break;case 9:return t.abrupt("return");case 10:return t.prev=10,this.log.info("switchDevice audio to: ".concat(e)),this.mediaTrack&&this.mediaTrack.stop(),t.next=15,this.capture({deviceId:e,useExactDeviceId:!0,retryWhenExactFailed:!1});case 15:HW.emit(GW.SWITCH_DEVICE_SUCCESS,{track:this}),this.log.info("switch microphone success"),t.next=22;break;case 19:throw t.prev=19,t.t0=t.catch(10),this.log.error("switch microphone failed ".concat(t.t0)),this.deviceId&&this.recapture(this.deviceId),t.t0;case 22:case"end":return t.stop()}}),t,this,[[10,19]])})))}},{key:"listenDeviceChange",value:function(){wq&&!wq.listeners("audioInputRemoved").includes(this.handleMicrophoneRemoved)&&wq.on("audioInputRemoved",this.handleMicrophoneRemoved,this)}},{key:"handleMicrophoneRemoved",value:function(e){return HF(this,null,p().mark((function t(){var n;return p().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(e.deviceId!==this.deviceId){t.next=6;break}return this.log.warn("current microphone is lost: ".concat(JSON.stringify(e))),F$(this.userId,{eventId:2003,param1:6,streamType:1}),t.next=4,xq();case 4:(n=t.sent)[0]?this.recapture(n[0].deviceId):wq.on("audioInputAdded",this.handleMicrophoneAdded,this);case 6:case"end":return t.stop()}}),t,this)})))}},{key:"handleMicrophoneAdded",value:function(e){this.log.warn("microphone added: ".concat(JSON.stringify(e))),this.recapture(e.deviceId)}},{key:"update3A",value:function(e){return HF(this,arguments,(function(e){var t=this,n=e.echoCancellation,r=e.noiseSuppression,i=e.autoGainControl;return p().mark((function e(){var o;return p().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(o=!1,!aj(n)&&n!==t.profile.echoCancellation&&(t.profile.echoCancellation=n,o=!0),!aj(r)&&r!==t.profile.noiseSuppression&&(t.profile.noiseSuppression=r,o=!0),!aj(i)&&i!==t.profile.autoGainControl&&(t.profile.autoGainControl=i,o=!0),e.t0=o&&t.deviceId,!e.t0){e.next=8;break}return e.next=8,t.recapture(t.deviceId);case 8:case"end":return e.stop()}}),e)}))()}))}},{key:"captureVolume",get:function(){return this.pipeline.volume}},{key:"setCaptureVolume",value:function(e){this.pipeline.setVolume(e/100),this.pipeline.gain.node&&fK.addEnum({key:502700,value:2})}},{key:"setAudioVolume",value:function(e){y(t,"setAudioVolume",this,3)([0]),cG&&this.player.setMuted(!0),this.earMonitorGainNode.node||(this.earMonitorGainNode.setNode(fq().createGain()),this._output.setNode(fq().destination)),this.earMonitorGainNode.node.gain.value=e}},{key:"enableTrackANS",value:function(e){var t=this;if(this._inputTrack){var n=this._inputTrack.getConstraints();return n.noiseSuppression=e,this._inputTrack.applyConstraints(n).catch((function(n){return t._log.warn("".concat(e?"enable":"disable"," ANS failed "),n)}))}}},{key:"addDenoiser",value:function(e){var t;pW<=92&&48e3!==(null==(t=this.trackSettings)?void 0:t.sampleRate)?this._log.warn("denoiser only support sampleRate 48000 before chrome 93"):(fK.addEnum({key:502700,value:1}),this.pipeline.denoiser.setNode(e),this.enableTrackANS(!1))}},{key:"removeDenoiser",value:function(e){this.pipeline.denoiser.node===e&&(this.pipeline.denoiser.deleteNode(),this.enableTrackANS(!0))}},{key:"close",value:function(){this.pipeline.remove(),this.earMonitorGainNode.deleteNode(),this._output.deleteNode(),wq.off("audioInputAdded",this.handleMicrophoneAdded,this),wq.off("audioInputRemoved",this.handleMicrophoneRemoved,this),y(t,"close",this,3)([])}},{key:"recapture",value:function(e){return HF(this,null,p().mark((function n(){var r;return p().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.prev=0,n.next=3,BF(t.prototype,this,"recapture").call(this,e);case 3:case 13:n.next=16;break;case 5:return n.prev=5,n.t0=n.catch(0),n.next=9,xq();case 9:if(r=n.sent.find((function(t){return t.deviceId!==e})),!r){n.next=15;break}return n.next=13,BF(t.prototype,this,"recapture").call(this,r.deviceId);case 15:throw n.t0;case 16:case"end":return n.stop()}}),n,this,[[0,5]])})))}},{key:"encodeFrame",value:function(e){return this.manager?this.manager.encodePipeline.reduceRight((function(e,t){return t?t({frame:e}):e}),e):e}},{key:"enableEncodeFrame",get:function(){return!!this.manager&&this.manager.encodePipeline.some((function(e){return e}))}}])}(pY),_Y=function(){return s((function e(t){var n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];i(this,e),this.dataView=t,this.isSEI&&(n?this.addPreventionByte():this.removePreventionByte())}),[{key:"addPreventionByte",value:function(){for(var e=this.seiPayloadStartIndex,t=this.dataView.byteLength-2,n=[],r=0,i=e;i<=t;i++){var o=this.dataView.getInt8(i);switch(o){case 0:case 1:case 2:case 3:2===r&&(n.push(3),r=0),0==o?r++:r=0,n.push(o);break;default:r=0,n.push(o)}}n.push(this.dataView.getInt8(this.dataView.byteLength-1));var a=new DataView(new Uint8Array([].concat(T(new Uint8Array(this.dataView.buffer).slice(0,e)),n)).buffer);this.dataView=a}},{key:"removePreventionByte",value:function(){for(var e=this.seiPayloadStartIndex,t=this.dataView.byteLength-1,n=[],r=0,i=e;i<=t;i++)switch(this.dataView.getInt8(i)){case 0:r++,n.push(this.dataView.getInt8(i));break;case 3:2!==r&&n.push(this.dataView.getInt8(i)),r=0;break;default:n.push(this.dataView.getInt8(i)),r=0}var o=new DataView(new Uint8Array([].concat(T(new Uint8Array(this.dataView.buffer).slice(0,e)),n)).buffer);this.dataView=o}},{key:"isSEI",get:function(){return 6===this.dataView.getUint8(4)}},{key:"seiPayloadStartIndex",get:function(){for(var e=6,t=6;t<this.dataView.buffer.byteLength&&(e++,255===this.dataView.getUint8(t));t++);return e}},{key:"seiPayloadType",get:function(){return this.isSEI?this.dataView.getUint8(5):null}},{key:"seiPayload",get:function(){if(!this.isSEI)return null;for(var e=0,t=6,n=6;n<this.dataView.buffer.byteLength;n++){var r=this.dataView.getUint8(n);if(t++,255!==r){e+=r;break}e+=255}for(var i=new ArrayBuffer(e),o=new DataView(i),a=0;a<i.byteLength;a++,t++)o.setInt8(a,this.dataView.getInt8(t));return o}}])}(),gY=function(){return s((function e(){i(this,e),FF(this,"_seiMessageList",[]),FF(this,"_smallSeiMessageList",[]),FF(this,"_seiPayloadType",243)}),[{key:"encodeSEINalu",value:function(e){var t=e.byteLength,n=parseInt(String(t/255),10),r=t%255,i=[];i.push(0,0,0,1,6,this._seiPayloadType);for(var o=0;o<n;o++)i.push(255);i.push(r);var a=new DataView(e);return i.push.apply(i,T(new Uint8Array(a.buffer))),i.push(128),new _Y(new DataView(new Uint8Array(i).buffer),!0)}},{key:"sendSEI",value:function(e,t){null!=t&&t.seiPayloadType&&(this._seiPayloadType=t.seiPayloadType),this._seiMessageList.push(e),null!=t&&t.small&&this._smallSeiMessageList.push(e)}},{key:"isEmpty",value:function(){return!this._seiMessageList.length}},{key:"getNaluCount",value:function(e){for(var t=0,n=0,r=new DataView(e),i=0;i<e.byteLength;i++)switch(r.getUint8(i)){case 0:t++;break;case 1:(2===t||3===t)&&n++,t=0;break;default:t=0}return n}},{key:"encode",value:function(e,t){var n=t?this._smallSeiMessageList:this._seiMessageList;if(n.length>0&&e.data.byteLength>0){var r=9-this.getNaluCount(e.data);if(r<=0)return 0;for(var i=n.splice(0,r).reverse().map(this.encodeSEINalu.bind(this)),o=i.reduce((function(e,t){return e+t.dataView.byteLength}),0),a=new ArrayBuffer(o+e.data.byteLength),s=new DataView(a),c=new DataView(e.data),u=0,l=0;l<i.length;l++)for(var d=0;d<i[l].dataView.byteLength;d++)s.setInt8(u++,i[l].dataView.getInt8(d));for(var h=0;h<e.data.byteLength;h++)s.setInt8(u++,c.getInt8(h));return e.data=a,i.length}return 0}}])}(),yY=function(e){function t(e){var n,o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:4;i(this,t),n=r(this,t,[o,oq]),FF(n,"profile",{width:640,height:480,frameRate:15,bitrate:500}),FF(n,"avoidCropping",!1),FF(n,"_scaleResolutionDownBy"),FF(n,"stat",{bytesSent:0,packetsSent:0,framesEncoded:0,framesSent:0,frameWidth:0,frameHeight:0,fpsCapture:0}),FF(n,"small"),FF(n,"isNeedToSetBandwidth"),FF(n,"muteImage"),FF(n,"manager"),FF(n,"_seiCodec",new gY),n.manager=e;var a=function(){n.isAllowed2k4k(n.profile)?n.room&&n.settings.height>=1440&&"publish"===n.state&&n.room.sendAbilityStatus({"2k4k":1}):(n.log.warn("Resolution is reset to 1080p, need to upgrade ability here https://cloud.tencent.com/document/product/647/85386"),n.setProfile(OF(xF({},n.profile),{width:1920,height:1080})),n.applyProfile())};return n.on("input-media-track-changed",a),n.on("publish",a),n.handleCameraAdded=n.handleCameraAdded.bind(n),n.handleCameraRemoved=n.handleCameraRemoved.bind(n),n}return d(t,e),s(t,[{key:"facingMode",get:function(){if(qK&&this.mediaTrack)return this.mediaTrack.getSettings().facingMode}},{key:"isQosClearFirst",get:function(){var e;return"detail"===(null==(e=this._inputTrack)?void 0:e.contentHint)}},{key:"setMute",value:function(e){return HF(this,null,p().mark((function n(){var r,i,o;return p().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(!sj(e)){n.next=11;break}if(this.muteImage!==e){n.next=3;break}return n.abrupt("return");case 3:return n.next=5,null==(r=this.manager)?void 0:r.deleteWatermark("mute");case 5:return n.next=7,null==(i=this.manager)?void 0:i.setWatermark({x:0,y:0,width:this.settings.width,height:this.settings.height,type:"mute",zIndex:999,imageUrl:e});case 7:this.muteImage=e,BF(t.prototype,this,"setMute").call(this,!1),n.next=15;break;case 11:return n.next=13,null==(o=this.manager)?void 0:o.deleteWatermark("mute");case 13:this.muteImage=void 0,BF(t.prototype,this,"setMute").call(this,e);case 15:case"end":return n.stop()}}),n,this)})))}},{key:"capture",value:function(e){var n=e.deviceId,r=e.facingMode,i=e.useExactDeviceId,o=void 0===i||i,a=e.customSource,s=e.retryWhenExactFailed,c=void 0===s||s;return y(t,"capture",this,3)([{audio:!1,video:!0,facingMode:r||this.facingMode,cameraId:n,width:this.profile.width,height:this.profile.height,frameRate:this.profile.frameRate,useExactDeviceId:o,retryWhenExactFailed:c,customSource:a}])}},{key:"setProfile",value:function(e){var n=xF({},e),r=n.width>n.height;n.width*n.height<=19200&&uG&&dW&&(this.log.warn("resolution is ".concat(n.width,"*").concat(n.height,", fallback to 240*180")),n.width=r?240:180,n.height=r?180:240,n.bitrate=Math.max(n.bitrate,150)),n.width*n.height>921600&&IW&&(n.width=r?1280:720,n.height=r?720:1280,this.log.warn("reset to 1280 * 720 on iOS 13~14")),this.avoidCropping&&(dW||fG)&&!DW()&&n.width*n.height<=230400&&n.width/n.height==16/9&&(this._scaleResolutionDownBy=1280/n.width,n.width=1280,n.height=720,this.log.warn("capture 720p, scale: ".concat(this._scaleResolutionDownBy))),n.bitrate&&(this.isNeedToSetBandwidth=n.bitrate!==this.profile.bitrate),this.isAllowed2k4k(this.profile)?y(t,"setProfile",this,3)([n]):(this.log.warn("Resolution is reset to 1080p, need to upgrade ability here https://cloud.tencent.com/document/product/647/85386"),y(t,"setProfile",this,3)([OF(xF({},this.profile),{width:1920,height:1080})]))}},{key:"applyProfile",value:function(){return HF(this,null,p().mark((function e(){var t,n;return p().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.mediaTrack){e.next=2;break}return e.abrupt("return");case 2:if(n=this.settings,e.t0=!(n.height===this.profile.height&&n.width===this.profile.width&&n.frameRate===this.profile.frameRate||!this.deviceId),!e.t0){e.next=15;break}if(16!==TW){e.next=10;break}return e.next=8,this.recapture(this.deviceId);case 8:e.next=13;break;case 10:return e.next=12,null==(t=this.mediaTrack)?void 0:t.applyConstraints({width:this.profile.width,height:this.profile.height,frameRate:this.profile.frameRate});case 12:this.manager&&this.manager.changeInput(this);case 13:this.room&&this.settings.height>=1440&&"publish"===this.state&&this.room.sendAbilityStatus({"2k4k":1}),e.t0=this.isNeedToSetBandwidth&&this.room&&this.room.setBandWidth;case 15:if(!e.t0){e.next=17;break}return e.abrupt("return",(this.isNeedToSetBandwidth=!1,this.room.setBandWidth({bandwidth:this.profile.bitrate,type:UB.VIDEO,videoType:UB.BIG})));case 17:case"end":return e.stop()}}),e,this)})))}},{key:"settings",get:function(){var e={width:this.profile.width,height:this.profile.height,frameRate:this.profile.frameRate};return qK&&this.mediaTrack&&Object.assign(e,this.mediaTrack.getSettings()),e}},{key:"scaleResolutionDownBy",get:function(){if(this._scaleResolutionDownBy)return this._scaleResolutionDownBy;var e=this.settings;return e.width===this.profile.width&&e.height===this.profile.height?1:Mj()&&this.profile.width>this.profile.height&&e.height>e.width?Math.max(e.width/this.profile.height,e.height/this.profile.width,1):Math.max(e.width/this.profile.width,e.height/this.profile.height,1)}},{key:"isAllowed2k4k",value:function(e){var t;return!(this.room&&this.room.scheduleResult&&!this.isScreen&&!(e.height*e.width<3686400))||1===(null==(t=this.room.scheduleResult.trtcAutoConf)?void 0:t["2k4k"])}},{key:"isNeedToSwitchDevice",value:function(e){return!(!this.mediaTrack||this.deviceId===e||this.facingMode===e)}},{key:"switchDevice",value:function(e){return HF(this,null,p().mark((function t(){var n;return p().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(t.prev=0,this.isNeedToSwitchDevice(e)){t.next=3;break}return t.abrupt("return");case 3:return n={useExactDeviceId:!0,retryWhenExactFailed:!1},"user"===e||"environment"===e?n.facingMode=e:n.deviceId=e,this.mediaTrack.stop(),t.next=8,this.capture(n);case 8:HW.emit(GW.SWITCH_DEVICE_SUCCESS,{track:this}),this.log.info("switch camera success"),t.next=15;break;case 12:throw t.prev=12,t.t0=t.catch(0),this.log.error("switch camera failed ".concat(t.t0)),this.deviceId&&this.recapture(this.deviceId),t.t0;case 15:case"end":return t.stop()}}),t,this,[[0,12]])})))}},{key:"listenDeviceChange",value:function(){wq&&!wq.listeners("videoInputRemoved").includes(this.handleCameraRemoved)&&wq.on("videoInputRemoved",this.handleCameraRemoved,this)}},{key:"handleCameraRemoved",value:function(e){return HF(this,null,p().mark((function t(){var n;return p().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(e.deviceId!==this.deviceId){t.next=6;break}return this.log.warn("current camera is lost: ".concat(JSON.stringify(e))),F$(this.userId,{eventId:2003,param1:7,streamType:2}),t.next=4,Oq();case 4:(n=t.sent)[0]?this.recapture(n[0].deviceId):wq.on("videoInputAdded",this.handleCameraAdded,this);case 6:case"end":return t.stop()}}),t,this)})))}},{key:"handleCameraAdded",value:function(e){return HF(this,null,p().mark((function t(){return p().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:this.log.warn("camera added: ".concat(JSON.stringify(e))),this.recapture(e.deviceId);case 1:case"end":return t.stop()}}),t,this)})))}},{key:"encodeFrame",value:function(e,t){if(!this.manager)return e;var n=t?8:this.mediaType;return this.manager.encodePipeline.reduceRight((function(e,t){return t?t({frame:e,mediaType:n}):e}),e)}},{key:"enableEncodeFrame",get:function(){return!!this.manager&&this.manager.encodePipeline.some((function(e){return e}))}},{key:"play",value:function(e,n){return aj(this.mirror)&&!this.isScreen&&this.setMirror("view"),y(t,"play",this,3)([e,n])}},{key:"close",value:function(){wq.off("videoInputAdded",this.handleCameraAdded,this),wq.off("videoInputRemoved",this.handleCameraRemoved,this),y(t,"close",this,3)([])}},{key:"recapture",value:function(e){return HF(this,null,p().mark((function n(){var r;return p().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.prev=0,n.next=3,BF(t.prototype,this,"recapture").call(this,e);case 3:case 13:n.next=16;break;case 5:return n.prev=5,n.t0=n.catch(0),n.next=9,Oq();case 9:if(r=n.sent.find((function(t){return t.deviceId!==e})),!r){n.next=15;break}return n.next=13,BF(t.prototype,this,"recapture").call(this,r.deviceId);case 15:throw n.t0;case 16:case"end":return n.stop()}}),n,this,[[0,5]])})))}},{key:"setContentHint",value:function(e){this.mediaTrack&&"contentHint"in this.mediaTrack&&(this.mediaTrack.contentHint!==e&&(this.log.info("setContentHint ".concat(e)),this.mediaTrack.contentHint=e),this.outMediaTrack&&this.outMediaTrack.contentHint!==e&&(this.outMediaTrack.contentHint=e))}}])}(pY);UF([tY((function(e){this.setContentHint(e.contentHint||"motion")}))],yY.prototype,"capture",1);var EY=yY,TY=YW();if("undefined"!=typeof navigator&&navigator.mediaDevices&&"setCaptureHandleConfig"in navigator.mediaDevices)try{navigator.mediaDevices.setCaptureHandleConfig({handle:TY,exposeOrigin:!0,permittedOrigins:["*"]})}catch(Qj){}function kY(e,t){return HF(this,null,p().mark((function n(){var r,i;return p().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(!("CropTarget"in window&&"fromElement"in CropTarget&&oj(e.cropTo))){n.next=14;break}if(n.prev=1,(null==(r=e.getCaptureHandle())?void 0:r.handle)===TY){n.next=4;break}return n.abrupt("return");case 4:return n.next=6,CropTarget.fromElement(t);case 6:return i=n.sent,n.next=9,e.cropTo(i);case 9:n.next=14;break;case 11:n.prev=11,n.t0=n.catch(1),qW.warn("cropTo target failed ".concat(n.t0));case 14:case"end":return n.stop()}}),n,null,[[1,11]])})))}function SY(e){var t={echoCancellation:e.echoCancellation,autoGainControl:e.autoGainControl,noiseSuppression:e.noiseSuppression,sampleRate:e.sampleRate,channelCount:e.channelCount};return aj(e.microphoneId)||(t.deviceId=e.microphoneId),{audio:t,video:!1}}function IY(e){var t={preferCurrentTab:"current-tab"===e.preferDisplaySurface||!!e.captureElement,systemAudio:"include",selfBrowserSurface:"include",surfaceSwitching:"include"},n={width:vW?{max:e.width}:{ideal:e.width,max:e.width},height:vW?{max:e.height}:{ideal:e.height,max:e.height},frameRate:e.frameRate,displaySurface:e.preferDisplaySurface||"monitor"};if(t.video=n,e.systemAudio){var r=e.echoCancellation,i=void 0===r||r,o=e.noiseSuppression,a=void 0!==o&&o,s=e.autoGainControl,c=void 0!==s&&s;t.audio={echoCancellation:i,noiseSuppression:a,autoGainControl:c,sampleRate:48e3}}return t}var bY=function(e){return HF(this,null,p().mark((function t(){var n,r,i,o,a;return p().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=null,r=IY(e),qW.info("getDisplayMedia with constraints: ".concat(JSON.stringify(r))),t.next=4,navigator.mediaDevices.getDisplayMedia(r);case 4:if(i=t.sent,e.systemAudio&&0===i.getAudioTracks().length&&(hW&&pW<74||vW||fG)&&qW.warn("Your browser not support capture system audio"),!(o=i.getVideoTracks()[0])){t.next=21;break}if(!e.frameRate){t.next=17;break}return t.prev=9,t.next=12,o.applyConstraints({frameRate:{min:e.frameRate,ideal:e.frameRate},width:e.width,height:e.height});case 12:t.next=17;break;case 14:t.prev=14,t.t0=t.catch(9),qW.warn("screen applyConstraints failed: ".concat(t.t0));case 17:if(t.t1=e.captureElement,!t.t1){t.next=21;break}return t.next=21,kY(o,e.captureElement);case 21:if(!e.audio){t.next=28;break}return a=SY(e),qW.info("getUserMedia with constraints: ".concat(JSON.stringify(a))),t.next=26,navigator.mediaDevices.getUserMedia(a);case 26:n=t.sent,i.addTrack(n.getAudioTracks()[0]);case 28:return t.abrupt("return",i);case 29:case"end":return t.stop()}}),t,null,[[9,14]])})))},AY=function(e){function t(e){var n;return i(this,t),n=r(this,t,[e,2]),FF(n,"profile",{width:1920,height:1080,frameRate:5,bitrate:1600}),FF(n,"objectFit","contain"),FF(n,"isScreen",!0),n._log.id="s-".concat(n._log.id),n}return d(t,e),s(t,[{key:"capture",value:function(e){return HF(this,arguments,(function(e){var t=this,n=e.systemAudio,r=void 0!==n&&n,i=e.autoGainControl,o=e.echoCancellation,a=e.noiseSuppression,s=e.audioTrack,c=e.videoTrack,u=e.captureElement,l=e.preferDisplaySurface;return p().mark((function e(){var n;return p().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(e.prev=0,!c&&!s){e.next=5;break}n=new MediaStream,c&&n.addTrack(c),s&&n.addTrack(s),e.next=8;break;case 5:return e.next=7,bY({audio:!1,systemAudio:r,width:t.profile.width,height:t.profile.height,frameRate:t.profile.frameRate,autoGainControl:i,echoCancellation:o,noiseSuppression:a,captureElement:u,preferDisplaySurface:l});case 7:n=e.sent;case 8:return e.next=10,t.setInputMediaStreamTrack(n.getVideoTracks()[0]);case 10:return e.abrupt("return",n);case 13:throw e.prev=13,e.t0=e.catch(0),t.log.error("getDisplayMedia error observed ".concat(e.t0)),e.t0 instanceof tB?e.t0:new tB({code:ZF.INITIALIZE_FAILED,name:e.t0.name,message:e.t0.message});case 16:case"end":return e.stop()}}),e,null,[[0,13]])}))()}))}},{key:"switchDevice",value:function(e){return HF(this,null,p().mark((function e(){return p().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:throw new Error("Method not implemented.");case 1:case"end":return e.stop()}}),e)})))}}])}(EY);UF([tY((function(e){this.setContentHint(e.contentHint||"detail")}))],AY.prototype,"capture",1);var RY,CY=function(e){function t(e){var n;return i(this,t),(n=r(this,t,[e]))._log.id="s-".concat(n._log.id),n}return d(t,e),s(t)}(vY);function wY(e){return HF(this,null,p().mark((function t(){var n,r;return p().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=fq(),RY||(RY=aq(n,URL.createObjectURL(new Blob(["registerProcessor('dumper', class extends AudioWorkletProcessor {process(inputs) {this.port.postMessage(inputs);return true;}});"],{type:"application/javascript"})))),t.next=4,RY;case 4:return r=new AudioWorkletNode(n,"dumper",{numberOfInputs:e.length,numberOfOutputs:0}),t.abrupt("return",(e.forEach((function(e,t){return e.connect(r,0,t)})),new ReadableStream({start:function(e){r.port.onmessage=function(t){e.enqueue(t.data)}},cancel:function(){e.forEach((function(e){return e.disconnect(r)})),r.port.close()}})));case 6:case"end":return t.stop()}}),t)})))}var DY=function(e){function t(e){var n;return i(this,t),(n=r(this,t)).room=e,FF(n,"_localAudioTrack"),FF(n,"_localScreenAudioTrack"),FF(n,"log",qW.createLogger({id:"am"})),FF(n,"denoiser"),FF(n,"voiceChanger"),FF(n,"mixChangedDebounce"),FF(n,"encodePipeline",[]),FF(n,"decodePipeline",[]),e&&(n.log.setUserId(e.userId),n.log.setSdkAppId(e.sdkAppId)),n}return d(t,e),s(t,[{key:"_localAudioPipline",get:function(){var e;return null==(e=this._localAudioTrack)?void 0:e.pipeline}},{key:"dump",value:function(e){var t,n,r=this;if(this._localAudioTrack){var i=[],o=[];null!=(t=this._localAudioPipline)&&t.source.node&&(i.push(this._localAudioPipline.source.node),o.push("mic")),null!=(n=this._localAudioPipline)&&n.denoiser.node&&(i.push(this._localAudioPipline.denoiser.node),o.push("mic-processed")),this.mixWeight>1&&(i.push(this.audioContext.createMediaStreamSource(this._localAudioPipline.stream)),o.push("mix")),this.log.info("dump audio track ".concat(o,", duration: ").concat(e));var a=new AbortController,s=[],c=setTimeout((function(){r.log.info('dump audio track complete please input "download()" to download.'),a.abort("timeout")}),1e3*e),u=function(){for(var e=0;e<o.length;e++){var t=URL.createObjectURL(new Blob(s[e])),n=document.createElement("a");n.href=t,n.download="".concat(o[e],".pcm"),n.style.display="none",document.body.appendChild(n),n.click(),URL.revokeObjectURL(t),n.remove()}clearTimeout(c),a.abort("download")},l=wY(i).then((function(e){return e.pipeTo(new WritableStream({write:function(e){e.forEach((function(e,t){return s[t]=s[t]?s[t].concat(e[0]):[e[0]]}))}}),a).catch((function(e){return u}))}));return{then:l.then.bind(l),download:u}}}},{key:"getPCM",value:function(e){var t,n=this;if(aj(WritableStream))this.log.warn("getPCM failed: browser not support WritableStream");else{if(null!=(t=this._localAudioPipline)&&t.source.node){this.log.warn("getPCM");var r=new Float32Array(1920),i=0,o=new AbortController;return wY([this._localAudioPipline.source.node]).then((function(t){return t.pipeTo(new WritableStream({write:function(t){t[0][0]&&(r.set(t[0][0],i),(i+=t[0][0].length)>=1920&&(i=0,e(r),r=new Float32Array(1920)))}}),o).catch((function(e){return n.log.warn("stop getPCM reason:".concat(e))}))})),o}this.log.warn("getPCM failed: no local audio track")}}},{key:"hasScreenAudioTrack",get:function(){return null!==this._localScreenAudioTrack}},{key:"hasAudioTrack",get:function(){return!aj(this._localAudioTrack)}},{key:"changeInput",value:function(e){return e instanceof CY?(this._localScreenAudioTrack=e,e.pipeline.connect(),this.mixOnChange()):e instanceof vY?(this._localAudioTrack=e,this.denoiser&&e.addDenoiser(this.denoiser),e.pipeline.connect(),this.mixOnChange()):e instanceof g$?e.setOutputMediaStreamTrack(e.mediaTrack):void 0}},{key:"mixOnChange",value:function(){var e=this;return this.mixChangedDebounce||(this.mixChangedDebounce=Promise.resolve().then((function(){var t,n;return delete e.mixChangedDebounce,Promise.all([null==(t=e._localAudioTrack)?void 0:t.setOutputMediaStreamTrack(e.mixWeight>1?e.mixTrack:e._localAudioTrack.mediaTrack),null==(n=e._localScreenAudioTrack)?void 0:n.setOutputMediaStreamTrack(e.mixWeight>1?e.mixTrack:e._localScreenAudioTrack.mediaTrack)])}))),this.mixChangedDebounce}},{key:"removeInput",value:function(e){e instanceof CY?delete this._localScreenAudioTrack:e instanceof vY&&delete this._localAudioTrack}},{key:"addDenoiser",value:function(e){var t;this.denoiser=e,null==(t=this._localAudioTrack)||t.addDenoiser(e)}},{key:"removeDenoiser",value:function(e){var t;delete this.denoiser,null==(t=this._localAudioTrack)||t.removeDenoiser(e)}},{key:"addVoiceChanger",value:function(e,t){var n;this.voiceChanger=[e,t],null==(n=this._localAudioTrack)||n.pipeline.voiceChanger.setNode(e,t)}},{key:"removeVoiceChanger",value:function(){var e;delete this.voiceChanger,null==(e=this._localAudioTrack)||e.pipeline.voiceChanger.deleteNode()}},{key:"destroy",value:function(){this.close()}},{key:"addEncodeProcessor",value:function(e){var t,n=e.processor,r=e.type;this.encodePipeline.includes(n)||(this.encodePipeline[r]=n,null==(t=this.room)||t.enableInsertableStreams())}},{key:"addDecodeProcessor",value:function(e){var t,n=e.processor,r=e.type;this.decodePipeline.includes(n)||(this.decodePipeline[r]=n,null==(t=this.room)||t.enableInsertableStreams())}},{key:"removeEncodeProcessor",value:function(e){var t=e.type;this.encodePipeline[t]=void 0}},{key:"removeDecodeProcessor",value:function(e){var t=e.type;this.decodePipeline[t]=void 0}}])}(gq);function NY(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:30,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:2;return rY((function(n,r){return function(){for(var i=this,o=arguments.length,a=new Array(o),s=0;s<o;s++)a[s]=arguments[s];return new Promise((function(o,s){var c=setTimeout((function(){var n=new tB({code:ZF.API_CALL_TIMEOUT,message:"checkPendingPromise ".concat(r,"() timeout ").concat(e,"s")});qW.warn(n),2===t?s(n):1===t&&o()}),1e3*e);n.apply(i,a).then(o,s).finally((function(){clearTimeout(c)}))}))}}))}var xY={};function OY(){}LF(xY,{Events:function(){return qY},Inspect:function(){return FY},LastSink:function(){return BY},Sink:function(){return HY},Subscribe:function(){return jY},TimeoutError:function(){return YY},audit:function(){return lQ},bindCallback:function(){return NX},bindNodeCallback:function(){return xX},buffer:function(){return dX},bufferCount:function(){return uX},bufferTime:function(){return r$},call:function(){return PY},catchError:function(){return s$},combineLatest:function(){return rX},concat:function(){return eX},concatMap:function(){return jQ},concatMapTo:function(){return GQ},count:function(){return UX},create:function(){return WY},debounce:function(){return fQ},debounceTime:function(){return pQ},defer:function(){return pX},delay:function(){return o$},deliver:function(){return JY},dispose:function(){return LY},elementAt:function(){return vQ},empty:function(){return MX},every:function(){return bQ},exhaustMap:function(){return XQ},exhaustMapTo:function(){return QQ},filter:function(){return GX},find:function(){return _Q},findIndex:function(){return yQ},first:function(){return TQ},fromAnimationFrame:function(){return wX},fromArray:function(){return gX},fromEvent:function(){return SX},fromEventPattern:function(){return kX},fromFetch:function(){return bX},fromIterable:function(){return AX},fromPromise:function(){return IX},fromReadableStream:function(){return CX},fromReader:function(){return RX},groupBy:function(){return ZQ},identity:function(){return MY},ignoreElements:function(){return JX},iif:function(){return nX},inspect:function(){return VY},interval:function(){return yX},last:function(){return SQ},map:function(){return NQ},mapTo:function(){return xQ},max:function(){return FX},merge:function(){return $Y},mergeMap:function(){return KQ},mergeMapTo:function(){return zQ},min:function(){return BX},never:function(){return OX},nothing:function(){return OY},of:function(){return _X},pairwise:function(){return wQ},pipe:function(){return GY},race:function(){return ZY},range:function(){return DX},reduce:function(){return VX},retry:function(){return m$},scan:function(){return RQ},share:function(){return QY},shareReplay:function(){return tX},skip:function(){return eQ},skipUntil:function(){return nQ},skipWhile:function(){return iQ},startWith:function(){return oX},subject:function(){return fX},subscribe:function(){return l$},sum:function(){return HX},switchMap:function(){return VQ},switchMapTo:function(){return FQ},take:function(){return zX},takeLast:function(){return $X},takeUntil:function(){return YX},takeWhile:function(){return QX},tap:function(){return h$},throttle:function(){return cQ},throwError:function(){return PX},timeInterval:function(){return t$},timeout:function(){return p$},timer:function(){return EX},toPromise:function(){return c$},toReadableStream:function(){return u$},withLatestFrom:function(){return sX},zip:function(){return iX}});var PY=function(e){return e()},MY=function(e){return e};function LY(){this.dispose()}var VY=function(){return"undefined"!=typeof __FASTRX_DEVTOOLS__},UY=1,FY=function(e){function t(){return i(this,t),r(this,t,arguments)}return d(t,e),s(t,[{key:"toString",value:function(){return"".concat(this.name,"(").concat(this.args.length?T(this.args).join(", "):"",")")}},{key:"subscribe",value:function(e){var t=new zY(e,this,this.streamId++);return qY.subscribe({id:this.id,end:!1},{nodeId:t.sourceId,streamId:t.id}),this(t),t}}])}(b(Function)),BY=function(){return s((function e(){i(this,e),this.defers=new Set,this.disposed=!1}),[{key:"next",value:function(e){}},{key:"complete",value:function(){this.dispose()}},{key:"error",value:function(e){this.dispose()}},{key:"bindDispose",get:function(){var e=this;return function(){return e.dispose()}}},{key:"dispose",value:function(){this.disposed=!0,this.complete=OY,this.error=OY,this.next=OY,this.dispose=OY,this.subscribe=OY,this.doDefer()}},{key:"subscribe",value:function(e){return e instanceof FY?e.subscribe(this):e(this),this}},{key:"bindSubscribe",get:function(){var e=this;return function(t){return e.subscribe(t)}}},{key:"doDefer",value:function(){this.defers.forEach(PY),this.defers.clear()}},{key:"defer",value:function(e){this.defers.add(e)}},{key:"removeDefer",value:function(e){this.defers.delete(e)}},{key:"reset",value:function(){this.disposed=!1,delete this.complete,delete this.next,delete this.dispose,delete this.next,delete this.subscribe}},{key:"resetNext",value:function(){delete this.next}},{key:"resetComplete",value:function(){delete this.complete}},{key:"resetError",value:function(){delete this.error}}])}(),HY=function(e){function t(e){var n;return i(this,t),(n=r(this,t)).sink=e,e.defer(n.bindDispose),n}return d(t,e),s(t,[{key:"next",value:function(e){this.sink.next(e)}},{key:"complete",value:function(){this.sink.complete()}},{key:"error",value:function(e){this.sink.error(e)}}])}(BY),jY=function(e){function t(e){var n,o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:OY,a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:OY,s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:OY;if(i(this,t),(n=r(this,t))._next=o,n._error=a,n._complete=s,n.then=OY,e instanceof FY){var c={toString:function(){return"subscribe"},id:0,source:e};n.defer((function(){qY.defer(c,0)})),qY.create(c),qY.pipe(c),n.sourceId=c.id,n.subscribe(e),qY.subscribe({id:c.id,end:!0}),o==OY?n._next=function(e){return qY.next(c,0,e)}:n.next=function(e){qY.next(c,0,e),o(e)},s==OY?n._complete=function(){return qY.complete(c,0)}:n.complete=function(){n.dispose(),qY.complete(c,0),s()},a==OY?n._error=function(e){return qY.complete(c,0,e)}:n.error=function(e){n.dispose(),qY.complete(c,0,e),a()}}else n.subscribe(e);return n}return d(t,e),s(t,[{key:"next",value:function(e){this._next(e)}},{key:"complete",value:function(){this.dispose(),this._complete()}},{key:"error",value:function(e){this.dispose(),this._error(e)}}])}(BY);function GY(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r];return n.reduce((function(e,t){return t(e)}),e)}function WY(e,t,n){if(VY()){var r=Object.defineProperties(Object.setPrototypeOf(e,FY.prototype),{streamId:{value:0,writable:!0,configurable:!0},name:{value:t,writable:!0,configurable:!0},args:{value:n,writable:!0,configurable:!0},id:{value:0,writable:!0,configurable:!0}});qY.create(r);for(var i=0;i<n.length;i++){var o=n[i];"function"==typeof o&&o instanceof FY&&qY.addSource(r,o)}return r}return e}function JY(e,t){return function(){for(var n=arguments,r=arguments.length,i=new Array(r),a=0;a<r;a++)i[a]=arguments[a];return function(r){if(r instanceof FY){var a=WY((function(t){var n=o(e,[t].concat(i));n.sourceId=a.id,n.subscribe(r)}),t,n);return a.source=r,qY.pipe(a),a}return function(t){return r(o(e,[t].concat(i)))}}}}function KY(e,t){window.postMessage({source:"fastrx-devtools-backend",payload:{event:e,payload:t}})}var zY=function(e){function t(e,n,o){var a;return i(this,t),(a=r(this,t,[e])).source=n,a.id=o,a.sourceId=e.sourceId,a.defer((function(){qY.defer(a.source,a.id)})),a}return d(t,e),s(t,[{key:"next",value:function(e){qY.next(this.source,this.id,e),this.sink.next(e)}},{key:"complete",value:function(){qY.complete(this.source,this.id),this.sink.complete()}},{key:"error",value:function(e){qY.complete(this.source,this.id,e),this.sink.error(e)}}])}(HY),qY={addSource:function(e,t){KY("addSource",{id:e.id,name:e.toString(),source:{id:t.id,name:t.toString()}})},next:function(e,t,n){KY("next",{id:e.id,streamId:t,data:n&&n.toString()})},subscribe:function(e,t){KY("subscribe",{id:e.id,end:e.end,sink:{nodeId:t&&t.nodeId,streamId:t&&t.streamId}})},complete:function(e,t,n){KY("complete",{id:e.id,streamId:t,err:n?n.toString():null})},defer:function(e,t){KY("defer",{id:e.id,streamId:t})},pipe:function(e){KY("pipe",{name:e.toString(),id:e.id,source:{id:e.source.id,name:e.source.toString()}})},update:function(e){KY("update",{id:e.id,name:e.toString()})},create:function(e){e.id||(e.id=UY++),KY("create",{name:e.toString(),id:e.id})}},YY=function(e){function t(e){var n;return i(this,t),(n=r(this,t,["timeout after ".concat(e,"ms")])).timeout=e,n}return d(t,e),s(t)}(b(Error)),XY=function(e){function t(e){var n;return i(this,t),(n=r(this,t)).source=e,n.sinks=new Set,n}return d(t,e),s(t,[{key:"add",value:function(e){var t=this;e.defer((function(){return t.remove(e)})),1===this.sinks.add(e).size&&(this.reset(),this.subscribe(this.source))}},{key:"remove",value:function(e){this.sinks.delete(e),0===this.sinks.size&&this.dispose()}},{key:"next",value:function(e){this.sinks.forEach((function(t){return t.next(e)}))}},{key:"complete",value:function(){this.sinks.forEach((function(e){return e.complete()})),this.sinks.clear()}},{key:"error",value:function(e){this.sinks.forEach((function(t){return t.error(e)})),this.sinks.clear()}}])}(BY);function QY(){var e=arguments;return function(t){var n=new XY(t);if(t instanceof FY){var r=WY((function(e){n.add(e)}),"share",e);return n.sourceId=r.id,r.source=t,qY.pipe(r),r}return WY(n.add.bind(n),"share",e)}}function $Y(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return WY((function(e){var n=new HY(e),r=t.length;n.complete=function(){0==--r&&e.complete()},t.forEach(n.bindSubscribe)}),"merge",arguments)}function ZY(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return WY((function(e){var n=new Map;t.forEach((function(t){var r=new HY(e);n.set(t,r),r.complete=function(){n.delete(t),0===n.size?e.complete():r.dispose()},r.next=function(e){n.delete(t),n.forEach((function(e){return e.dispose()})),r.resetNext(),r.resetComplete(),r.next(e)}})),t.forEach((function(e){return n.get(e).subscribe(e)}))}),"race",arguments)}function eX(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return WY((function(e){var n=0,r=t.length,i=new HY(e);i.complete=function(){n<r&&!i.disposed?(i.doDefer(),i.subscribe(t[n++])):e.complete()},i.complete()}),"concat",arguments)}function tX(e){var t=arguments;return function(n){var r=new XY(n),i=[];return r.next=function(t){i.push(t),i.length>e&&i.shift(),this.sinks.forEach((function(e){return e.next(t)}))},WY((function(e){e.defer((function(){return r.remove(e)})),i.forEach((function(t){return e.next(t)})),r.add(e)}),"shareReplay",t)}}function nX(e,t,n){return WY((function(r){return e()?t(r):n(r)}),"iif",arguments)}function rX(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return WY((function(e){var n=t.length,r=n,i=n,o=new Array(n),a=function(){0==--i&&e.complete()};t.forEach((function(t,n){var i=new HY(e);i.next=function(t){0==--r?(i.next=function(t){o[n]=t,e.next(o)},i.next(t)):o[n]=t},i.complete=a,i.subscribe(t)}))}),"combineLatest",arguments)}function iX(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return WY((function(e){var n=t.length,r=n,i=new Array(n),o=function(){0==--r&&e.complete()};t.forEach((function(t,n){var r=new HY(e),a=[];i[n]=a,r.next=function(t){a.push(t),i.every((function(e){return e.length}))&&e.next(i.map((function(e){return e.shift()})))},r.complete=o,r.subscribe(t)}))}),"zip",arguments)}function oX(){for(var e=arguments,t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return function(t){return WY((function(e){for(var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:n.length;r<i&&!e.disposed;)e.next(n[r++]);e.disposed||e.subscribe(t)}),"startWith",e)}}var aX=function(e){function t(e){var n;i(this,t),n=r(this,t,[e]);for(var o=new HY(n.sink),a=arguments.length,s=new Array(a>1?a-1:0),c=1;c<a;c++)s[c-1]=arguments[c];return o.next=function(e){return n.buffer=e},o.complete=OY,o.subscribe(rX.apply(void 0,s)),n}return d(t,e),s(t,[{key:"next",value:function(e){this.buffer&&this.sink.next([e].concat(T(this.buffer)))}}])}(HY),sX=JY(aX,"withLatestFrom"),cX=function(e){function t(e,n,o){var a;return i(this,t),(a=r(this,t,[e])).bufferSize=n,a.startBufferEvery=o,a.buffer=[],a.count=0,a.startBufferEvery&&(a.buffers=[[]]),a}return d(t,e),s(t,[{key:"next",value:function(e){this.startBufferEvery?(this.count++===this.startBufferEvery&&(this.buffers.push([]),this.count=1),this.buffers.forEach((function(t){t.push(e)})),this.buffers[0].length===this.bufferSize&&this.sink.next(this.buffers.shift())):(this.buffer.push(e),this.buffer.length===this.bufferSize&&(this.sink.next(this.buffer),this.buffer=[]))}},{key:"complete",value:function(){var e=this;this.buffer.length?this.sink.next(this.buffer):this.buffers.length&&this.buffers.forEach((function(t){return e.sink.next(t)})),y(t,"complete",this,3)([])}}])}(HY),uX=JY(cX,"bufferCount"),lX=function(e){function t(e,n){var o;i(this,t),(o=r(this,t,[e])).buffer=[];var a=new HY(e);return a.next=function(t){e.next(o.buffer),o.buffer=[]},a.complete=OY,a.subscribe(n),o}return d(t,e),s(t,[{key:"next",value:function(e){this.buffer.push(e)}},{key:"complete",value:function(){this.buffer.length&&this.sink.next(this.buffer),y(t,"complete",this,3)([])}}])}(HY),dX=JY(lX,"buffer"),hX=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function a(e){try{c(r.next(e))}catch(eJ){o(eJ)}}function s(e){try{c(r.throw(e))}catch(eJ){o(eJ)}}function c(e){e.done?i(e.value):function(e){return e instanceof n?e:new n((function(t){t(e)}))}(e.value).then(a,s)}c((r=r.apply(e,t||[])).next())}))};function fX(e){var t=arguments,n=QY()(WY((function(t){n.next=function(e){return t.next(e)},n.complete=function(){return t.complete()},n.error=function(e){return t.error(e)},e&&t.subscribe(e)}),"subject",t));return n.next=OY,n.complete=OY,n.error=OY,n}function pX(e){return WY((function(t){return t.subscribe(e())}),"defer",arguments)}var mX=function(e){return function(t){setTimeout((function(){return e(t)}))}},vX=function(e){return mX((function(t){for(var n=0;!t.disposed&&n<e.length;n++)t.next(e[n]);t.complete()}))};function _X(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return WY(vX(t),"of",arguments)}function gX(e){return WY(vX(e),"fromArray",arguments)}function yX(e){return WY((function(t){var n=0,r=setInterval((function(){return t.next(n++)}),e);return t.defer((function(){clearInterval(r)})),"interval"}),"interval",arguments)}function EX(e,t){return WY((function(n){var r=0,i=setTimeout((function(){if(n.removeDefer(o),n.next(r++),t){var e=setInterval((function(){return n.next(r++)}),t);n.defer((function(){clearInterval(e)}))}else n.complete()}),e),o=function(){clearTimeout(i)};n.defer(o)}),"timer",arguments)}function TX(e,t){return function(n){var r=function(e){return n.next(e)};n.defer((function(){return t(r)})),e(r)}}function kX(e,t){return WY(TX(e,t),"fromEventPattern",arguments)}function SX(e,t){if("on"in e&&"off"in e)return WY(TX((function(n){return e.on(t,n)}),(function(n){return e.off(t,n)})),"fromEvent",arguments);if("addListener"in e&&"removeListener"in e)return WY(TX((function(n){return e.addListener(t,n)}),(function(n){return e.removeListener(t,n)})),"fromEvent",arguments);if("addEventListener"in e)return WY(TX((function(n){return e.addEventListener(t,n)}),(function(n){return e.removeEventListener(t,n)})),"fromEvent",arguments);throw"target is not a EventDispachter"}function IX(e){return WY((function(t){e.then(t.next.bind(t),t.error.bind(t))}),"fromPromise",arguments)}function bX(e,t){return WY(pX((function(){return IX(fetch(e,t))})),"fromFetch",arguments)}function AX(e){return WY(mX((function(t){try{var n,r=c(e);try{for(r.s();!(n=r.n()).done;){var i=n.value;if(t.disposed)return;t.next(i)}}catch(o){r.e(o)}finally{r.f()}t.complete()}catch(i){t.error(i)}})),"fromIterable",arguments)}function RX(e){var t=this,n=function(r){return hX(t,void 0,void 0,p().mark((function t(){var i,o,a;return p().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!r.disposed){t.next=2;break}return t.abrupt("return");case 2:return t.next=4,e.read();case 4:if(i=t.sent,o=i.done,a=i.value,!o){t.next=12;break}return r.complete(),t.abrupt("return");case 12:r.next(a),n(r);case 13:case"end":return t.stop()}}),t)})))};return WY((function(e){n(e)}),"fromReader",arguments)}function CX(e){return WY((function(t){var n=new AbortController,r=n.signal;t.defer((function(){return n.abort("cancelled")})),e.pipeTo(new WritableStream({write:function(e){t.next(e)},close:function(){t.complete()},abort:function(e){t.error(e)}}),{signal:r}).then((function(){return t.complete()}),(function(e){return t.error(e)}))}),"fromReadableStream",arguments)}function wX(){return WY((function(e){var t=requestAnimationFrame((function n(r){e.disposed||(e.next(r),t=requestAnimationFrame(n))}));e.defer((function(){return cancelAnimationFrame(t)}))}),"fromAnimationFrame",arguments)}function DX(e,t){return WY((function(n){for(var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:e,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:t+e;r<i&&!n.disposed;)n.next(r++);return n.complete(),"range"}),"range",arguments)}function NX(e,t){for(var n=arguments.length,r=new Array(n>2?n-2:0),i=2;i<n;i++)r[i-2]=arguments[i];return WY((function(n){var i=r.concat((function(e){return n.next(e),n.complete()}));e.apply(t,i)}),"bindCallback",arguments)}function xX(e,t){for(var n=arguments.length,r=new Array(n>2?n-2:0),i=2;i<n;i++)r[i-2]=arguments[i];return WY((function(n){var i=r.concat((function(e,t){return e?n.error(e):(n.next(t),n.complete())}));e.apply(t,i)}),"bindNodeCallback",arguments)}function OX(){return WY((function(){}),"never",arguments)}function PX(e){return WY((function(t){return t.error(e)}),"throwError",arguments)}function MX(){return WY((function(e){return e.complete()}),"empty",arguments)}var LX=function(e){function t(e,n,o){var a;i(this,t),(a=r(this,t,[e])).f=n;var s=function(){a.sink.next(a.acc),a.sink.complete()};return void 0===o?a.next=function(e){a.acc=e,a.complete=s,a.resetNext()}:(a.acc=o,a.complete=s),a}return d(t,e),s(t,[{key:"next",value:function(e){this.acc=this.f(this.acc,e)}}])}(HY),VX=JY(LX,"reduce"),UX=function(e){return JY(LX,"count")((function(t,n){return e(n)?t+1:t}),0)},FX=function(){return JY(LX,"max")(Math.max)},BX=function(){return JY(LX,"min")(Math.min)},HX=function(){return JY(LX,"sum")((function(e,t){return e+t}),0)},jX=function(e){function t(e,n,o){var a;return i(this,t),(a=r(this,t,[e])).filter=n,a.thisArg=o,a}return d(t,e),s(t,[{key:"next",value:function(e){this.filter.call(this.thisArg,e)&&this.sink.next(e)}}])}(HY),GX=JY(jX,"filter"),WX=function(e){function t(){return i(this,t),r(this,t,arguments)}return d(t,e),s(t,[{key:"next",value:function(e){}}])}(HY),JX=JY(WX,"ignoreElements"),KX=function(e){function t(e,n){var o;return i(this,t),(o=r(this,t,[e])).count=n,o}return d(t,e),s(t,[{key:"next",value:function(e){this.sink.next(e),0==--this.count&&this.complete()}}])}(HY),zX=JY(KX,"take"),qX=function(e){function t(e,n){var o;i(this,t),o=r(this,t,[e]);var a=new HY(e);return a.next=function(){return e.complete()},a.complete=LY,a.subscribe(n),o}return d(t,e),s(t)}(HY),YX=JY(qX,"takeUntil"),XX=function(e){function t(e,n){var o;return i(this,t),(o=r(this,t,[e])).f=n,o}return d(t,e),s(t,[{key:"next",value:function(e){this.f(e)?this.sink.next(e):this.complete()}}])}(HY),QX=JY(XX,"takeWhile"),$X=function(e){return VX((function(t,n){return t.push(n),t.length>e&&t.shift(),t}),[])},ZX=function(e){function t(e,n){var o;return i(this,t),(o=r(this,t,[e])).count=n,o}return d(t,e),s(t,[{key:"next",value:function(e){0==--this.count&&(this.next=y(t,"next",this,1))}}])}(HY),eQ=JY(ZX,"skip"),tQ=function(e){function t(e,n){var o;i(this,t),o=r(this,t,[e]),e.next=OY;var a=new HY(e);return a.next=function(){a.dispose(),e.resetNext()},a.complete=LY,a.subscribe(n),o}return d(t,e),s(t)}(HY),nQ=JY(tQ,"skipUntil"),rQ=function(e){function t(e,n){var o;return i(this,t),(o=r(this,t,[e])).f=n,o}return d(t,e),s(t,[{key:"next",value:function(e){this.f(e)||(this.next=y(t,"next",this,1),this.next(e))}}])}(HY),iQ=JY(rQ,"skipWhile"),oQ={leading:!0,trailing:!1},aQ=function(e){function t(e,n,o){var a;return i(this,t),(a=r(this,t,[e])).durationSelector=n,a.trailing=o,a}return d(t,e),s(t,[{key:"cacheValue",value:function(e){this.last=e,this.disposed&&this.throttle(e)}},{key:"send",value:function(e){this.sink.next(e),this.throttle(e)}},{key:"throttle",value:function(e){this.reset(),this.subscribe(this.durationSelector(e))}},{key:"next",value:function(){this.complete()}},{key:"complete",value:function(){this.dispose(),this.trailing&&this.send(this.last)}}])}(HY),sQ=function(e){function t(e,n){var o,a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:oQ;return i(this,t),(o=r(this,t,[e])).durationSelector=n,o.config=a,o._throttle=new aQ(o.sink,o.durationSelector,o.config.trailing),o._throttle.dispose(),o}return d(t,e),s(t,[{key:"next",value:function(e){this._throttle.disposed&&this.config.leading?this._throttle.send(e):this._throttle.cacheValue(e)}},{key:"complete",value:function(){this._throttle.throttle=OY,this._throttle.complete(),y(t,"complete",this,3)([])}}])}(HY),cQ=JY(sQ,"throttle"),uQ={leading:!1,trailing:!0},lQ=function(e){return JY(sQ,"audit")(e,uQ)},dQ=function(e){function t(){return i(this,t),r(this,t,arguments)}return d(t,e),s(t,[{key:"next",value:function(){this.complete()}},{key:"complete",value:function(){this.dispose(),this.sink.next(this.last)}}])}(HY),hQ=function(e){function t(e,n){var o;return i(this,t),(o=r(this,t,[e])).durationSelector=n,o._debounce=new dQ(o.sink),o._debounce.dispose(),o}return d(t,e),s(t,[{key:"next",value:function(e){this._debounce.dispose(),this._debounce.reset(),this._debounce.last=e,this._debounce.subscribe(this.durationSelector(e))}},{key:"complete",value:function(){this._debounce.complete(),y(t,"complete",this,3)([])}}])}(HY),fQ=JY(hQ,"debounce"),pQ=function(e){return JY(hQ,"debounceTime")((function(t){return EX(e)}))},mQ=function(e){function t(e,n,o){var a;return i(this,t),(a=r(this,t,[e])).count=n,a.defaultValue=o,a}return d(t,e),s(t,[{key:"next",value:function(e){0==this.count--&&(this.defaultValue=e,this.complete())}},{key:"complete",value:function(){void 0!==this.defaultValue?(this.sink.next(this.defaultValue),y(t,"complete",this,3)([])):this.error(new Error("not enough elements in sequence"))}}])}(HY),vQ=JY(mQ,"elementAt"),_Q=function(e){return function(t){return zX(1)(iQ((function(t){return!e(t)}))(t))}},gQ=function(e){function t(e,n){var o;return i(this,t),(o=r(this,t,[e])).f=n,o.i=0,o}return d(t,e),s(t,[{key:"next",value:function(e){this.f(e)?(this.sink.next(this.i++),this.complete()):++this.i}}])}(HY),yQ=JY(gQ,"findIndex"),EQ=function(e){function t(e,n,o){var a;return i(this,t),(a=r(this,t,[e])).f=n,a.defaultValue=o,a.index=0,a}return d(t,e),s(t,[{key:"next",value:function(e){(!this.f||this.f(e,this.index++))&&(this.defaultValue=e,this.complete())}},{key:"complete",value:function(){void 0!==this.defaultValue?(this.sink.next(this.defaultValue),y(t,"complete",this,3)([])):this.error(new Error("no elements in sequence"))}}])}(HY),TQ=JY(EQ,"first"),kQ=function(e){function t(e,n,o){var a;return i(this,t),(a=r(this,t,[e])).f=n,a.defaultValue=o,a.index=0,a}return d(t,e),s(t,[{key:"next",value:function(e){(!this.f||this.f(e,this.index++))&&(this.defaultValue=e)}},{key:"complete",value:function(){void 0!==this.defaultValue?(this.sink.next(this.defaultValue),y(t,"complete",this,3)([])):this.error(new Error("no elements in sequence"))}}])}(HY),SQ=JY(kQ,"last"),IQ=function(e){function t(e,n){var o;return i(this,t),(o=r(this,t,[e])).predicate=n,o.index=0,o}return d(t,e),s(t,[{key:"next",value:function(e){this.predicate(e,this.index++)?this.result=!0:(this.result=!1,this.complete())}},{key:"complete",value:function(){void 0!==this.result?(this.sink.next(this.result),y(t,"complete",this,3)([])):this.error(new Error("no elements in sequence"))}}])}(HY),bQ=JY(IQ,"every"),AQ=function(e){function t(e,n,o){var a;return i(this,t),(a=r(this,t,[e])).f=n,void 0===o?a.next=function(e){a.acc=e,a.resetNext(),a.sink.next(a.acc)}:a.acc=o,a}return d(t,e),s(t,[{key:"next",value:function(e){this.sink.next(this.acc=this.f(this.acc,e))}}])}(HY),RQ=JY(AQ,"scan"),CQ=function(e){function t(){var e;return i(this,t),(e=r(this,t,arguments)).hasLast=!1,e}return d(t,e),s(t,[{key:"next",value:function(e){this.hasLast?this.sink.next([this.last,e]):this.hasLast=!0,this.last=e}}])}(HY),wQ=JY(CQ,"pairwise"),DQ=function(e){function t(e,n,o){var a;return i(this,t),(a=r(this,t,[e])).mapper=n,a.thisArg=o,a}return d(t,e),s(t,[{key:"next",value:function(e){y(t,"next",this,3)([this.mapper.call(this.thisArg,e)])}}])}(HY),NQ=JY(DQ,"map"),xQ=function(e){return JY(DQ,"mapTo")((function(t){return e}))},OQ=function(e){function t(e,n,o){var a;return i(this,t),(a=r(this,t,[e])).data=n,a.context=o,a}return d(t,e),s(t,[{key:"next",value:function(e){var t=this.context.combineResults;t?this.sink.next(t(this.data,e)):this.sink.next(e)}},{key:"tryComplete",value:function(){this.context.resetComplete(),this.dispose()}}])}(HY),PQ=function(e){function t(e,n,o){var a;return i(this,t),(a=r(this,t,[e])).makeSource=n,a.combineResults=o,a.index=0,a}return d(t,e),s(t,[{key:"subInner",value:function(e,t){var n=this.currentSink=new t(this.sink,e,this);this.complete=this.tryComplete,n.complete=n.tryComplete,n.subscribe(this.makeSource(e,this.index++))}},{key:"tryComplete",value:function(){this.currentSink.resetComplete(),this.dispose()}}])}(HY),MQ=function(e){function t(){return i(this,t),r(this,t,arguments)}return d(t,e),s(t)}(OQ),LQ=function(e){function t(){return i(this,t),r(this,t,arguments)}return d(t,e),s(t,[{key:"next",value:function(e){var t=this;this.subInner(e,MQ),this.next=function(e){t.currentSink.dispose(),t.subInner(e,MQ)}}}])}(PQ),VQ=JY(LQ,"switchMap");function UQ(e){return function(t,n){return e((function(){return t}),n)}}var FQ=UQ(JY(LQ,"switchMapTo")),BQ=function(e){function t(){return i(this,t),r(this,t,arguments)}return d(t,e),s(t,[{key:"tryComplete",value:function(){this.dispose(),this.context.sources.length?this.context.subNext():(this.context.resetNext(),this.context.resetComplete())}}])}(OQ),HQ=function(e){function t(){var e;return i(this,t),(e=r(this,t,arguments)).sources=[],e.next2=e.sources.push.bind(e.sources),e}return d(t,e),s(t,[{key:"next",value:function(e){this.next2(e),this.subNext()}},{key:"subNext",value:function(){this.next=this.next2,this.subInner(this.sources.shift(),BQ),this.disposed&&0===this.sources.length&&this.currentSink.resetComplete()}},{key:"tryComplete",value:function(){0===this.sources.length&&this.currentSink.resetComplete(),this.dispose()}}])}(PQ),jQ=JY(HQ,"concatMap"),GQ=UQ(JY(HQ,"concatMapTo")),WQ=function(e){function t(){return i(this,t),r(this,t,arguments)}return d(t,e),s(t,[{key:"tryComplete",value:function(){this.context.inners.delete(this),y(t,"dispose",this,3)([]),0===this.context.inners.size&&this.context.resetComplete()}}])}(OQ),JQ=function(e){function t(){var e;return i(this,t),(e=r(this,t,arguments)).inners=new Set,e}return d(t,e),s(t,[{key:"next",value:function(e){this.subInner(e,WQ),this.inners.add(this.currentSink)}},{key:"tryComplete",value:function(){1===this.inners.size?this.inners.forEach((function(e){return e.resetComplete()})):this.dispose()}}])}(PQ),KQ=JY(JQ,"mergeMap"),zQ=UQ(JY(JQ,"mergeMapTo")),qQ=function(e){function t(){return i(this,t),r(this,t,arguments)}return d(t,e),s(t,[{key:"dispose",value:function(){this.context.resetNext(),y(t,"dispose",this,3)([])}}])}(OQ),YQ=function(e){function t(){return i(this,t),r(this,t,arguments)}return d(t,e),s(t,[{key:"next",value:function(e){this.next=OY,this.subInner(e,qQ)}}])}(PQ),XQ=JY(YQ,"exhaustMap"),QQ=UQ(JY(YQ,"exhaustMapTo")),$Q=function(e){function t(e,n){var o;return i(this,t),(o=r(this,t,[e])).f=n,o.groups=new Map,o}return d(t,e),s(t,[{key:"next",value:function(e){var n=this.f(e),r=this.groups.get(n);void 0===r&&((r=fX()).key=n,this.groups.set(n,r),y(t,"next",this,3)([r])),r.next(e)}},{key:"complete",value:function(){this.groups.forEach((function(e){return e.complete()})),y(t,"complete",this,3)([])}},{key:"error",value:function(e){this.groups.forEach((function(t){return t.error(e)})),y(t,"error",this,3)([e])}}])}(HY),ZQ=JY($Q,"groupBy"),e$=function(e){function t(){var e;return i(this,t),(e=r(this,t,arguments)).start=new Date,e}return d(t,e),s(t,[{key:"next",value:function(e){this.sink.next({value:e,interval:Number(new Date)-Number(this.start)}),this.start=new Date}}])}(HY),t$=JY(e$,"timeInterval"),n$=function(e){function t(e,n){var o;return i(this,t),(o=r(this,t,[e])).miniseconds=n,o.buffer=[],o.id=setInterval((function(){o.sink.next(o.buffer.concat()),o.buffer.length=0}),o.miniseconds),o}return d(t,e),s(t,[{key:"next",value:function(e){this.buffer.push(e)}},{key:"complete",value:function(){this.sink.next(this.buffer),y(t,"complete",this,3)([])}},{key:"dispose",value:function(){clearInterval(this.id),y(t,"dispose",this,3)([])}}])}(HY),r$=JY(n$,"bufferTime"),i$=function(e){function t(e,n){var o;return i(this,t),(o=r(this,t,[e])).buffer=[],o.delayTime=n,o}return d(t,e),s(t,[{key:"dispose",value:function(){clearTimeout(this.timeoutId),y(t,"dispose",this,3)([])}},{key:"delay",value:function(e){var n=this;this.timeoutId=setTimeout((function(){var e=n.buffer.shift();if(e){var r=e.time,i=e.data;y(t,"next",n,3)([i]),n.buffer.length&&n.delay(Number(n.buffer[0].time)-Number(r))}}),e)}},{key:"next",value:function(e){this.buffer.length||this.delay(this.delayTime),this.buffer.push({time:new Date,data:e})}},{key:"complete",value:function(){var e=this;this.timeoutId=setTimeout((function(){return y(t,"complete",e,3)([])}),this.delayTime)}}])}(HY),o$=JY(i$,"delay"),a$=function(e){function t(e,n){var o;return i(this,t),(o=r(this,t,[e])).selector=n,o}return d(t,e),s(t,[{key:"error",value:function(e){this.dispose(),this.selector(e)(this.sink)}}])}(HY),s$=JY(a$,"catchError"),c$=function(){return function(e){return new Promise((function(t,n){var r;new jY(e,(function(e){return r=e}),n,(function(){return t(r)}))}))}},u$=function(){return function(e){var t;return new ReadableStream({start:function(n){t=new jY(e,n.enqueue.bind(n),n.error.bind(n),n.close.bind(n))},cancel:function(){t.dispose()}})}},l$=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:OY,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:OY,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:OY;return function(r){return new jY(r,e,t,n)}},d$=function(e){function t(e,n){var o;return i(this,t),o=r(this,t,[e]),n instanceof Function?o.next=function(t){n(t),e.next(t)}:(n.next&&(o.next=function(t){n.next(t),e.next(t)}),n.complete&&(o.complete=function(){n.complete(),e.complete()}),n.error&&(o.error=function(t){n.error(t),e.error(t)})),o}return d(t,e),s(t)}(HY),h$=JY(d$,"tap"),f$=function(e){function t(e,n){var o;return i(this,t),(o=r(this,t,[e])).timeout=n,o.id=setTimeout((function(){return o.error(new YY(o.timeout))}),o.timeout),o}return d(t,e),s(t,[{key:"next",value:function(e){y(t,"next",this,3)([e]),clearTimeout(this.id),this.next=y(t,"next",this,1)}},{key:"dispose",value:function(){clearTimeout(this.id),y(t,"dispose",this,3)([])}}])}(HY),p$=JY(f$,"timeout"),m$=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1/0;return function(t){if(t instanceof FY){var n=WY((function(r){var i=e,o=new HY(r);o.error=function(e){i-- >0?o.subscribe(t):r.error(e)},o.sourceId=n.id,o.subscribe(t)}),"retry",[e]);return n.source=t,qY.pipe(n),n}return function(n){var r=e,i=new HY(n);i.error=function(e){r-- >0?t(i):n.error(e)},t(i)}}},v$=function(e){function t(e,n,o){var a;i(this,t),(a=r(this,t,[{userId:n.userId,sdkAppId:e.sdkAppId,mediaType:o,room:e}])).room=e,a.user=n,FF(a,"tinyId"),FF(a,"isRemote",!0),FF(a,"jitterBufferDelay",0),FF(a,"availableState"),FF(a,"remotePublishState"),FF(a,"_triggerCheckDecodeSubject",fX(SX(a,t.STATE_SUBSCRIBE))),a.tinyId=n.tinyId,a.availableState=new gz("".concat(n.userId,"-").concat(a.mediaType,"-available"),"remote-track-available"),a.remotePublishState=new gz("".concat(n.userId,"-").concat(a.mediaType,"-remote-publish"),"remote-track-publish"),GY($Y(SX(a,gz.STATECHANGED),SX(a.remotePublishState,gz.STATECHANGED)),NQ((function(){return a.isRemotePublished&&(a.isSubscribed||a.isSubscribing)})),l$((function(e){a.availableState.state!==(e?gz.ON:gz.OFF)&&(a.availableState.state=e?gz.ON:gz.OFF),a.updatePlayingState(e)})));var s=GY(SX(a.player,bz.ERROR),GX((function(e){return e.code===MediaError.MEDIA_ERR_DECODE}))),c=GY(EX(5e3),GX((function(){return!(a.ignoreDecodeError||!a.isSubscribed||!a.isPlayCalled||!a.stat.bytesReceived)&&(!a.player.isPlaying&&!(a.kind===UB.AUDIO?a.getAudioLevel()>0:a.stat.framesDecoded>0)||(a.reportDecodeResult(!0),!1))}))),u=GY(ZY(s,c),YX(SX(a,gz.INIT)));return GY(a._triggerCheckDecodeSubject,GX((function(){return!a.ignoreDecodeError})),FQ(u),l$((function(e){a.reportDecodeResult(!1,e)}))),a}return d(t,e),s(t,[{key:"setMute",value:function(e){this.isRemotePublished&&y(t,"setMute",this,3)([e])}},{key:"setInputMediaStreamTrack",value:function(e){y(t,"setInputMediaStreamTrack",this,3)([e]),this.isRemotePublished&&this.isSubscribed&&this.player.setTrack(this.outMediaTrack)}},{key:"checkDecodeResult",value:function(){this._triggerCheckDecodeSubject.next(!0)}},{key:"waitHasMediaTrack",value:function(){var e=this;return new Promise((function(t){e.mediaTrack?t():e.once("input-media-track-changed",t)}))}},{key:"ignoreDecodeError",get:function(){var e,t;return((null==(t=null==(e=this.room)?void 0:e.networkQuality)?void 0:t.downlinkNetworkQuality)||0)>3||this.player.isInAutoPlayFailedState}},{key:"isSubscribing",get:function(){return"subscribeing"===this.state.toString()}},{key:"isSubscribed",get:function(){return this.state===t.STATE_SUBSCRIBE}},{key:"isAvailable",get:function(){return this.availableState.state===gz.ON}},{key:"isNeedPlay",get:function(){return this.isAvailable&&this.isPlayCalled}},{key:"subscribe",value:function(e){return e}},{key:"unsubscribe",value:function(){this.player.setTrack(null),"main"===this.streamType&&"video"===this.kind&&this.room.changeType(!1,this.user)}},{key:"reportDecodeResult",value:function(e,t){var n=this.kind===UB.AUDIO;fK[e?"addSuccessEvent":"addFailedEvent"]({key:n?504700:514702}),e||(fK.addEnum({key:n?504701:514703,value:LW()}),Nz.uploadEvent({log:"stat-decode-failed-".concat(this.kind,"-").concat(OW()||VW()),userId:this.room.userId}),this._log.warn("decode failed: isPlaying: ".concat(this.player.isPlaying," ").concat(this.kind===UB.AUDIO?"audioLevel: ".concat(this.getAudioLevel()):"framesDecoded: ".concat(this.stat.framesDecoded>0))),this.emit("decode-failed",{error:t}))}},{key:"updatePlayingState",value:function(e){if(this.isPlayCalled&&this.player.isStopped===e){if(e&&(!this.isSubscribed||!this.isRemotePublished||!this.outMediaTrack))return void this.log.info("abort play, isSubscribed: ".concat(this.isSubscribed," isAvailable: ").concat(this.isRemotePublished," hasTrack: ").concat(!!this.outMediaTrack," "));y(t,"updatePlayingState",this,3)([e])}}},{key:"close",value:function(){y(t,"close",this,3)([]),this.outMediaTrack&&this.uninstallTrackEvent(this.outMediaTrack)}},{key:"onFlagChanged",value:function(){this.remotePublishState.state=this.isRemotePublished?gz.ON:gz.OFF}},{key:"onTrackMuted",value:function(){this.isNeedPlay&&y(t,"onTrackMuted",this,3)([])}},{key:"onTrackUnmuted",value:function(){this.isNeedPlay&&y(t,"onTrackUnmuted",this,3)([])}},{key:"onTrackEnded",value:function(){this.isNeedPlay&&y(t,"onTrackEnded",this,3)([])}}])}(Jq);FF(v$,"STATE_SUBSCRIBE","subscribe"),UF([NY(5,1)],v$.prototype,"waitHasMediaTrack",1),UF([mz(gz.INIT,v$.STATE_SUBSCRIBE,{success:function(){this.log.info("subscribed"),HW.emit(GW.REMOTE_TRACK_SUBSCRIBED,{track:this})},ignoreError:!0}),hY(521716,!1)],v$.prototype,"subscribe",1),UF([mz(v$.STATE_SUBSCRIBE,gz.INIT,{sync:!0,success:function(){this.log.info("unsubscribed"),HW.emit(GW.REMOTE_TRACK_UNSUBSCRIBED,{track:this})}})],v$.prototype,"unsubscribe",1);var _$=v$,g$=function(e){function t(e,n){var o;return i(this,t),o=r(this,t,[e,n,1]),FF(o,"volume",0),FF(o,"mediaType",1),FF(o,"stat",{bytesReceived:0,packetsReceived:0,packetsLost:0,end2EndDelay:0,jitterBufferDelay:0}),o.manager=e.audioManager,o}return d(t,e),s(t,[{key:"dbVolume",get:function(){return Iq.isRunning?this.player.pipeline.volumeMeter.getVolumeDb():Math.floor(Math.max(10*Math.log10(this.volume)+100,0))}},{key:"decodeFrame",value:function(e){if(!this.manager)return e;var t,n=e,r=c(this.manager.decodePipeline);try{for(r.s();!(t=r.n()).done;){var i=t.value;if(i&&!(n=i({frame:n,track:this})))return}}catch(o){r.e(o)}finally{r.f()}return n}},{key:"getAudioLevel",value:function(){var e=this.volume||y(t,"getAudioLevel",this,3)([]);return e>1?1:e}},{key:"isRemotePublished",get:function(){return this.user.muteState.audioAvailable}}])}(_$),y$=[-1,-1,1,-1,-1,1,1,1],E$=[0,0,1,0,0,1,1,1],T$=function(e){function t(e,n){var o;if(i(this,t),(o=r(this,t)).context=e,FF(o,"name"),FF(o,"input"),FF(o,"output"),FF(o,"texture"),FF(o,"ctx2d",null),FF(o,"fbo"),FF(o,"width",0),FF(o,"height",0),FF(o,"x",0),FF(o,"y",0),FF(o,"program"),FF(o,"vertexShader"),FF(o,"fragmentShader"),FF(o,"totalFrames",0),FF(o,"dropFrames",0),FF(o,"matchInputSize",!0),FF(o,"texCoordBuffer"),FF(o,"positionBuffer"),FF(o,"lastInfo",{name:"",timestamp:0,totalFrames:0,x:0,y:0,width:0,height:0,fps:0}),FF(o,"cost",0),FF(o,"_canvas",null),FF(o,"_image"),FF(o,"log"),o.context.on("disconnect",o.close,o),o.name=n.name,o.log=n.logger,o.matchInputSize=!1!==n.matchInputSize,o.width=n.width||e.width,o.height=n.height||e.height,o._image=n.image,e instanceof M$)return e.ctx&&n.create2d&&("function"==typeof OffscreenCanvas&&16!==TW?o._canvas=new OffscreenCanvas(o.width,o.height):(o._canvas=document.createElement("canvas"),o._canvas.width=o.width,o._canvas.height=o.height),o.ctx2d=o._canvas.getContext("2d"),o._image=o._canvas),f(o);try{var a=e.ctx;o.texCoordBuffer=o.createBuffer(E$),o.positionBuffer=o.createBuffer(y$),!1!==n.createTexture&&(o.texture=a.createTexture(),o.useTexture(),a.texParameteri(a.TEXTURE_2D,a.TEXTURE_MIN_FILTER,a.LINEAR),a.texParameteri(a.TEXTURE_2D,a.TEXTURE_MAG_FILTER,a.LINEAR),a.texParameteri(a.TEXTURE_2D,a.TEXTURE_WRAP_S,a.CLAMP_TO_EDGE),a.texParameteri(a.TEXTURE_2D,a.TEXTURE_WRAP_T,a.CLAMP_TO_EDGE),a.pixelStorei(a.PACK_ALIGNMENT,1),a.pixelStorei(a.UNPACK_ALIGNMENT,1)),n.useFbo&&(o.fbo=a.createFramebuffer(),o.useBufferFrame(),o.useTexture(),a.texImage2D(a.TEXTURE_2D,0,a.RGBA,o.width,o.height,0,a.RGBA,a.UNSIGNED_BYTE,null),a.framebufferTexture2D(a.FRAMEBUFFER,a.COLOR_ATTACHMENT0,a.TEXTURE_2D,o.texture,0)),n.useDefaultProgram?o.program=e.defaultProgam:(n.vertexShaderSource||n.fragmentShaderSource)&&(o.vertexShader=n.vertexShaderSource?e.createShader(a.VERTEX_SHADER,n.vertexShaderSource):e.defaultVShader,o.fragmentShader=n.fragmentShaderSource?e.createShader(a.FRAGMENT_SHADER,n.fragmentShaderSource):e.defaultFShader,o.program=e.createProgram(o.vertexShader,o.fragmentShader))}catch(a){o.context.destroy(new tB({code:ZF.VIDEO_MANAGER_ERROR,extraCode:3,message:"create video node ".concat(o.name," error ").concat(a.message||a)}))}return o}return d(t,e),s(t,[{key:"image",get:function(){return this._image},set:function(e){this._image=e}},{key:"createFramebuffer",value:function(e){var t=this.context.ctx,n=t.createFramebuffer();return t.bindFramebuffer(t.FRAMEBUFFER,n),t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,e,0),n}},{key:"connect",value:function(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r];return e.addInput.apply(e,[this].concat(n)),this.output=e,e}},{key:"addInput",value:function(e){this.input=e,this.matchInputSize&&e.width&&e.height&&this.resize(e.width,e.height)}},{key:"requestFrame",value:function(e){var t=Date.now();return!!(this.context instanceof P$&&this.render(e)||this.context instanceof M$&&this.render2d(e))&&(this.totalFrames++,this.cost=Date.now()-t,!0)}},{key:"render2d",value:function(e){var t;return!(null==(t=this.input)||!t.requestFrame(e))&&this.draw2d(this.input.image,0,0,this.width,this.height)}},{key:"update",value:function(){var e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;null==(e=this.output)||e.update(t)}},{key:"disconnect",value:function(){for(var e,t,n=arguments.length,r=new Array(n),i=0;i<n;i++)r[i]=arguments[i];null==(t=this.output)||(e=t).removeInput.apply(e,[this].concat(r)),delete this.output}},{key:"removeInput",value:function(e){delete this.input}},{key:"close",value:function(){var e,t;if(this.context.off("disconnect",this.close,this),null==(e=this.output)||e.removeInput(this),delete this.output,null==(t=this.input)||t.disconnect(),this.context instanceof P$){var n=this.context.ctx;n.deleteBuffer(this.texCoordBuffer),n.deleteBuffer(this.positionBuffer),this.fbo&&n.deleteFramebuffer(this.fbo),this.texture&&n.deleteTexture(this.texture),this.vertexShader&&this.vertexShader!==this.context.defaultVShader&&n.deleteShader(this.vertexShader),this.fragmentShader&&this.fragmentShader!==this.context.defaultFShader&&n.deleteShader(this.fragmentShader),this.program&&this.program!==this.context.defaultProgam&&n.deleteProgram(this.program)}this._canvas&&(this._canvas.width=0,this._canvas.height=0,this.ctx2d=null),this.removeAllListeners()}},{key:"useTexture",value:function(){this.useTextures(this.texture)}},{key:"useInputTexture",value:function(){var e;this.useTextures(null==(e=this.input)?void 0:e.texture)}},{key:"useTextures",value:function(){for(var e=this.context.ctx,t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];n.forEach((function(t,n){t&&(e.activeTexture(e.TEXTURE0+n),e.bindTexture(e.TEXTURE_2D,t))}))}},{key:"useProgram",value:function(){this.context.ctx.useProgram(this.program)}},{key:"useBufferFrame",value:function(){var e=this.context.ctx;e.bindFramebuffer(e.FRAMEBUFFER,this.fbo||null)}},{key:"createBuffer",value:function(e){var t=this.context.ctx,n=t.createBuffer();return t.bindBuffer(t.ARRAY_BUFFER,n),t.bufferData(t.ARRAY_BUFFER,new Float32Array(e),t.STATIC_DRAW),n}},{key:"setTexBuffer",value:function(e){var t=this.context.ctx;t.bindBuffer(t.ARRAY_BUFFER,this.texCoordBuffer),t.bufferData(t.ARRAY_BUFFER,new Float32Array(e),t.STATIC_DRAW)}},{key:"setPosBuffer",value:function(e){var t=this.context.ctx;t.bindBuffer(t.ARRAY_BUFFER,this.positionBuffer),t.bufferData(t.ARRAY_BUFFER,new Float32Array(e),t.STATIC_DRAW)}},{key:"changeBufferData",value:function(e,t){var n=this.context.ctx;n.bindBuffer(n.ARRAY_BUFFER,e),n.bufferData(n.ARRAY_BUFFER,new Float32Array(t),n.STATIC_DRAW)}},{key:"setAttributes",value:function(){for(var e=this.context.ctx,t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];n.forEach((function(t,n){e.enableVertexAttribArray(n),e.bindBuffer(e.ARRAY_BUFFER,t),e.vertexAttribPointer(n,2,e.FLOAT,!1,0,0)}))}},{key:"getVertexPoint",value:function(e,t){return[e/this.width*2-1,t/this.height*2-1]}},{key:"layout2texCoords",value:function(e){return[].concat(T(this.getVertexPoint(e.x,e.y)),T(this.getVertexPoint(e.x+e.width,e.y)),T(this.getVertexPoint(e.x,e.y+e.height)),T(this.getVertexPoint(e.x+e.width,e.y+e.height)))}},{key:"resize",value:function(e,t){if(this.width!==e||this.height!==t){if(this.width=e,this.height=t,this._canvas&&(this._canvas.width=e,this._canvas.height=t),this.texture&&this.fbo){this.useTexture();var n=this.context.ctx;n.texImage2D(n.TEXTURE_2D,0,n.RGBA,e,t,0,n.RGBA,n.UNSIGNED_BYTE,null)}this.output&&this.output.matchInputSize&&this.output.resize(e,t)}}},{key:"draw",value:function(e,t){this.setAttributes(e||this.positionBuffer,t||this.texCoordBuffer);var n=this.context.ctx;n.drawArrays(n.TRIANGLE_STRIP,0,4)}},{key:"draw2d",value:function(e,t,n,r,i){return!(!this.ctx2d||!e)&&(e instanceof ImageData?this.ctx2d.putImageData(e,t,n):(this.ctx2d.drawImage(e,t,n,r,i),"undefined"!=typeof VideoFrame&&e instanceof VideoFrame&&e.close()),!0)}},{key:"getInfo",value:function(){var e,t=this.totalFrames,n=this.x,r=this.y,i=this.width,o=this.height,a=this.name,s=this.cost,c=Date.now(),u=(t-this.lastInfo.totalFrames)/((c-this.lastInfo.timestamp)/1e3)|0;return this.lastInfo={totalFrames:t,x:n,y:r,width:i,height:o,timestamp:c,fps:u,name:a,cost:s},xF({parent:null==(e=this.input)?void 0:e.getInfo()},this.lastInfo)}},{key:"createTexture",value:function(e){var t=this.context.ctx,n=t.createTexture();return this.useTextures(n),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,t.LINEAR),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MAG_FILTER,t.LINEAR),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE),t.pixelStorei(t.PACK_ALIGNMENT,1),t.pixelStorei(t.UNPACK_ALIGNMENT,1),t.texImage2D(t.TEXTURE_2D,0,t.RGBA,t.RGBA,t.UNSIGNED_BYTE,e),n}}])}(gz);UF([mz(gz.INIT,"connected",{sync:!0})],T$.prototype,"connect",1),UF([mz("connected",gz.INIT,{ignoreError:!0,sync:!0})],T$.prototype,"disconnect",1),UF([mz([],"closed",{sync:!0})],T$.prototype,"close",1);var k$=GY(yX(250),NQ((function(){return performance.now()})),QY()),S$=[0,1,1,1,0,0,1,0],I$=function(e){function t(e,n){var o;return i(this,t),o=r(this,t,[e,Object.assign({useDefaultProgram:!0,createTexture:!1,name:"destination"},n)]),FF(o,"_intervalId",0),FF(o,"_sequence",0),FF(o,"checkGLError",!1),FF(o,"checkVisibilityChange"),e instanceof M$?o.ctx2d=e.ctx||null:e.available&&null!=n&&n.mirrorUpAndDown&&o.setTexBuffer(S$),o}return d(t,e),s(t,[{key:"start",value:function(e){var t=this;this.log.info("".concat(this.name," start render ").concat(e," fps")),Iz.clearTask(this._intervalId),this._intervalId=Iz.run("intervalInWorker",(function(){if(e!==t.context.frameRate&&(Iz.clearTask(t._intervalId),t.start(t.context.frameRate)),t.requestFrame(t._sequence++),t.checkGLError&&t.context instanceof P$){var n=t.context.ctx.getError();n&&t.context.destroy(new tB({code:ZF.VIDEO_MANAGER_ERROR,extraCode:5,message:"".concat(t.name," req ").concat(t._sequence," render ").concat(t.totalFrames," faild ").concat(n)}))}}),{fps:this.context.frameRate})}},{key:"render",value:function(e){var t;return!(null==(t=this.input)||!t.requestFrame(e))&&(this.useProgram(),this.useBufferFrame(),this.useInputTexture(),this.draw(),!0)}},{key:"addInput",value:function(e){for(var n=arguments.length,r=new Array(n>1?n-1:0),i=1;i<n;i++)r[i-1]=arguments[i];y(t,"addInput",this,3)([e].concat(r)),this.start(this.context.frameRate)}},{key:"update",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;if(this._intervalId&&(Iz.clearTask(this._intervalId),this._intervalId=0,1===t)){this.log.info("".concat(this.name," use requestVideoFrameCallback"));var n=function(){document.hidden&&(e.start(e.context.frameRate),e.log.info("".concat(e.name," use timer")),document.removeEventListener("visibilitychange",n))};document.addEventListener("visibilitychange",n)}this.requestFrame(this._sequence++)}},{key:"removeInput",value:function(e){y(t,"removeInput",this,3)([e]),Iz.clearTask(this._intervalId)}},{key:"resize",value:function(e,n){y(t,"resize",this,3)([e,n]),this.context.setSize(e,n)}},{key:"close",value:function(){y(t,"close",this,3)([]),Iz.clearTask(this._intervalId),document.removeEventListener("visibilitychange",this.checkVisibilityChange)}}])}(T$),b$=function(e){function t(e,n){var o,a;return i(this,t),a=r(this,t,[e,n]),FF(a,"_videoTrack"),FF(a,"_muteOb"),FF(a,"_closedOb",SX(a,"closed")),FF(a,"_subscription"),FF(a,"_canvasContainer"),Number(gW)<17&&(a._canvasContainer=document.createElement("div"),a._canvasContainer.style.display="none"),o=_(e._canvas.captureStream().getVideoTracks(),1),a._videoTrack=o[0],a._muteOb=SX(a._videoTrack,"mute"),GY(SX(a._videoTrack,"ended"),YX(a._closedOb),l$((function(){a.context.destroy(new tB({code:ZF.VIDEO_MANAGER_ERROR,extraCode:8,message:"video track ended"}))}))),a}return d(t,e),s(t,[{key:"enableCheckMute",value:function(){var e=this;this._subscription=GY(this._muteOb,YX(this._closedOb),FQ(function(e){return function(t){var n=performance.now();GY(k$,iQ((function(t){return t-n<e})),zX(1))(t)}}(5e3)),l$((function(){var t;null!=(t=e._videoTrack)&&t.muted&&e.context.destroy(new tB({code:ZF.VIDEO_MANAGER_ERROR,extraCode:7,message:"video track muted"}))})))}},{key:"disableCheckMute",value:function(){var e;null==(e=this._subscription)||e.dispose()}},{key:"videoTrack",get:function(){return this._videoTrack}},{key:"putCanvasIntoDom",value:function(){!this.context._canvas||!this._canvasContainer||document.getElementById(this.context._canvas.id)||(this.log.info("".concat(this.name," put canvas to body")),document.body.appendChild(this._canvasContainer),this._canvasContainer.appendChild(this.context._canvas))}},{key:"render",value:function(e){return this.putCanvasIntoDom(),y(t,"render",this,3)([e])}},{key:"render2d",value:function(e){return this.putCanvasIntoDom(),y(t,"render2d",this,3)([e])}},{key:"close",value:function(){var e,n;y(t,"close",this,3)([]),null==(e=this._videoTrack)||e.stop(),delete this._videoTrack,null==(n=this._canvasContainer)||n.remove()}}])}(I$),A$=function(e){function t(){return i(this,t),r(this,t,arguments)}return d(t,e),s(t,[{key:"render",value:function(e){var t;return!(null==(t=this.input)||!t.requestFrame(e))}}])}(b$),R$=function(e){function t(e,n,o){var a;return i(this,t),(a=r(this,t,[e,{name:"smallDestination",logger:o}])).resolution=n,a}return d(t,e),s(t,[{key:"resize",value:function(e,n){var r,i=e*n,o=this.resolution.width*this.resolution.height;this.log.info("big res: ".concat(e,"*").concat(n," small res: ").concat(this.resolution.width,"*").concat(this.resolution.height," ")),i>o?r=i/o:(this.log.warn("Small stream resolution is not smaller than big stream, which is invalid. big: ".concat(e," * ").concat(n," small: ").concat(this.resolution.width," * ").concat(this.resolution.height)),r=i/19200),y(t,"resize",this,3)([e/Math.sqrt(r),n/Math.sqrt(r)])}}])}(b$),C$=function(e){function t(e,n){var o;return i(this,t),o=r(this,t,[e,xF({name:"imageSource"},n)]),FF(o,"_lastImage"),FF(o,"_totalFrames",0),FF(o,"_autoResize",!1),FF(o,"_canvasRendered"),FF(o,"_videoCallbackId",0),o._autoResize=!1!==(null==n?void 0:n.autoResize),16===TW&&(o._canvasRendered=fX(),GY(o._canvasRendered,oX(o._image),VQ((function(e){return e instanceof HTMLCanvasElement?SX(e,"rendered"):MX()})),YX(SX(o,"closed")),l$((function(){o.update()})))),o}return d(t,e),s(t,[{key:"tryVideoFrameCallback",value:function(e){var t=this;this._videoCallbackId&&e.cancelVideoFrameCallback(this._videoCallbackId),sz()&&!document.hidden&&(this._videoCallbackId=e.requestVideoFrameCallback((function(e,n){document.hidden||(t._totalFrames=n.presentedFrames,t.update(1))})))}},{key:"_render",value:function(e,t){var n,r=this.width,i=this.height,o=this.image;if(o instanceof HTMLVideoElement){if(this.tryVideoFrameCallback(o),r=o.videoWidth,i=o.videoHeight,!r||!i)return!1;o.width=r,o.height=i}else if(o instanceof HTMLImageElement||o instanceof ImageData||o instanceof ImageBitmap){if(r=o.width,i=o.height,o!==this._lastImage)this._lastImage=o;else if(r===this.width&&i===this.height)return!1}else o instanceof HTMLCanvasElement||o instanceof OffscreenCanvas?(r=o.width,i=o.height,this._lastImage=o):"undefined"!=typeof VideoFrame&&o instanceof VideoFrame&&(r=o.displayWidth,i=o.displayHeight,null==(n=this._lastImage)||n.close(),this._lastImage=o);if(!this._autoResize)return!0;if(this.width===r&&this.height===i&&this.totalFrames){if(t){this.useTexture();var a=this.context.ctx;a.texSubImage2D(a.TEXTURE_2D,0,0,0,a.RGBA,a.UNSIGNED_BYTE,o)}}else{if(t){this.useTexture();var s=this.context.ctx;s.texImage2D(s.TEXTURE_2D,0,s.RGBA,s.RGBA,s.UNSIGNED_BYTE,o)}this.resize(r,i)}return!0}},{key:"image",get:function(){return this._image},set:function(e){var t;null==(t=this._canvasRendered)||t.next(e),this._image=e}},{key:"render",value:function(e){return this._render(e,!0)}},{key:"render2d",value:function(e){return this._render(e,!1)}}])}(T$),w$=function(e){function t(e,n,o){var a;return i(this,t),(a=r(this,t,[e,o]))._player=n,a.name="videoPlayerSource",GY(SX(a._player,bz.PLAYER_STATE_CHANGED),YX(SX(a,"closed")),GX((function(e){return"PLAYING"===e.state})),l$((function(){a.tryVideoFrameCallback(a._player.element)}))),a}return d(t,e),s(t,[{key:"image",get:function(){return this._player.element}}])}(C$),D$=function(e){function t(e,n,o){var a;return i(this,t),(a=r(this,t,[e,new oq({id:o.name,track:n,muted:!0,container:null,objectFit:"contain",log:o.logger}),o])).name="videoTrackSource",a._player.play(),a}return d(t,e),s(t,[{key:"replaceTrack",value:function(e){this._player.setTrack(e),this._player.play()}},{key:"close",value:function(){y(t,"close",this,3)([]),this._player.stop()}}])}(w$),N$=function(e){function t(e){var n;return i(this,t),n=r(this,t),FF(n,"frameRate"),FF(n,"_canvas"),FF(n,"log"),FF(n,"hasAlpha",!1),FF(n,"name"),FF(n,"error"),n.name=e.name,n.log=e.logger.createChild({id:"vc-".concat(n.name)}),n.frameRate=e.frameRate,n}return d(t,e),s(t,[{key:"width",get:function(){var e;return(null==(e=this._canvas)?void 0:e.width)||0},set:function(e){this._canvas&&(this._canvas.width=e)}},{key:"height",get:function(){var e;return(null==(e=this._canvas)?void 0:e.height)||0},set:function(e){this._canvas&&(this._canvas.height=e)}},{key:"setSize",value:function(e,t){this._canvas&&(this._canvas.width=e,this._canvas.height=t)}},{key:"createVideoTrackSource",value:function(e,t){return new D$(this,e,{logger:this.log,name:t})}},{key:"createVideoTrackDestination",value:function(e){return new b$(this,e)}},{key:"createVideoImageSource",value:function(e,t){return new C$(this,t?Object.assign(t,{logger:this.log,image:e}):{logger:this.log,image:e})}},{key:"createVideoPlayerSource",value:function(e,t){return new w$(this,e,t?Object.assign(t,{logger:this.log}):{logger:this.log})}},{key:"available",get:function(){return"created"===this.state}},{key:"disconnect",value:function(){this.emit("disconnect")}}])}(gz);FF(N$,"_ids",0);var x$={alpha:!0,antialias:!1,premultipliedAlpha:!1,preserveDrawingBuffer:!1,depth:!1,stencil:!1,failIfMajorPerformanceCaveat:!0,powerPreference:"low-power"},O$=function(e){function t(){var e;return i(this,t),e=r(this,t,arguments),FF(e,"defaultProgam"),FF(e,"defaultVShader"),FF(e,"defaultFShader"),FF(e,"ctx"),e}return d(t,e),s(t,[{key:"create",value:function(){var e=this;if(this._canvas||(this._canvas=document.createElement("canvas"),this._canvas.id="trtc_".concat(this.name,"_").concat(N$._ids++)),this.ctx=this._canvas.getContext("webgl2",x$),!this.ctx)throw new tB({code:ZF.VIDEO_MANAGER_ERROR,extraCode:2,message:"webgl2 not supported"});this.defaultVShader=this.createShader(this.ctx.VERTEX_SHADER,"\n// 顶点着色器\nattribute vec4 a_position;\nattribute vec2 a_texCoord;\nvarying vec2 v_texCoord;\n\nvoid main() {\n gl_Position = a_position;\n v_texCoord = a_texCoord;\n}\n"),this.defaultFShader=this.createShader(this.ctx.FRAGMENT_SHADER,"\n// 片元着色器\nprecision mediump float;\nvarying vec2 v_texCoord;\nuniform sampler2D u_texture;\n\nvoid main() {\n gl_FragColor = texture2D(u_texture, v_texCoord);\n} "),this.defaultProgam=this.createProgram(this.defaultVShader,this.defaultFShader),this._canvas.addEventListener("webglcontextlost",(function(){e.destroy(new tB({code:ZF.VIDEO_MANAGER_ERROR,extraCode:4,message:"webgl context lost"}))}))}},{key:"destroy",value:function(e){var t="";return e&&(t=e.message,this.error=e,fK.addFailedEvent({key:512702,error:e})),this.disconnect(),this.log.info("video context destroy".concat(t)?": ".concat(t):""),this.ctx&&(this.ctx.deleteShader(this.defaultVShader),this.ctx.deleteShader(this.defaultFShader),this.ctx.deleteProgram(this.defaultProgam),delete this.ctx),e}},{key:"width",set:function(e){var n;null==(n=this.ctx)||n.viewport(0,0,e,this.height),E(t,"width",e,this,1,1)}},{key:"height",set:function(e){var n;null==(n=this.ctx)||n.viewport(0,0,this.width,e),E(t,"height",e,this,1,1)}},{key:"setSize",value:function(e,n){var r;null==(r=this.ctx)||r.viewport(0,0,e,n),y(t,"setSize",this,3)([e,n])}},{key:"createShader",value:function(e,t){var n=this.ctx,r=n.createShader(e);return n.shaderSource(r,t),n.compileShader(r),r}},{key:"createProgram",value:function(e,t){var n=this.ctx,r=n.createProgram();return n.attachShader(r,e),n.attachShader(r,t),n.linkProgram(r),n.getProgramParameter(r,n.LINK_STATUS)||this.log.error(n.getProgramInfoLog(r)),r}}])}(N$);FF(O$,"UNAVAILABLE","unavailable"),UF([mz(gz.INIT,"created",{sync:!0,fail:function(e){this.log.error("video gl context create failed",e.cause),fK.addFailedEvent({key:512700,error:e.cause||e})},success:function(){this.log.info("video context created use webgl"),fK.addSuccessEvent({key:512700})}})],O$.prototype,"create",1),UF([mz("created",gz.INIT,{ignoreError:!0,sync:!0,success:function(e){e&&this.emit(O$.UNAVAILABLE,e),this.removeAllListeners()}})],O$.prototype,"destroy",1);var P$=O$,M$=function(e){function t(){var e;return i(this,t),e=r(this,t,arguments),FF(e,"ctx"),e}return d(t,e),s(t,[{key:"create",value:function(e){var t=this;if(this.hasAlpha=e.alpha,this._canvas=document.createElement("canvas"),this._canvas.id="trtc_".concat(this.name,"_").concat(N$._ids++),this.ctx=this._canvas.getContext("2d",{alpha:e.alpha}),!this.ctx)throw new tB({code:ZF.VIDEO_MANAGER_ERROR,extraCode:2,message:"2d context not supported"});this._canvas.addEventListener("contextlost",(function(){t.log.error("2d context lost")})),this._canvas.addEventListener("contextrestored",(function(){t.log.warn("2d context restored")}))}},{key:"destroy",value:function(e){var t="";e&&(t=e.message,this.error=e,fK.addFailedEvent({key:512703,error:e})),this.disconnect(),this.log.info("video context destroy ".concat(t?": ".concat(t):"")),delete this.ctx,this._canvas&&(this._canvas.remove(),this._canvas.width=0,this._canvas.height=0,delete this._canvas),this.removeAllListeners(),fK.addSuccessEvent({key:512703})}}])}(N$);UF([mz(gz.INIT,"created",{sync:!0,fail:function(e){this.log.error("video 2d context create failed",e.cause),fK.addFailedEvent({key:512701,error:e.cause||e})},success:function(){this.log.info("video context created use 2d"),fK.addSuccessEvent({key:512701})}})],M$.prototype,"create",1),UF([mz("created",gz.INIT,{ignoreError:!0,sync:!0})],M$.prototype,"destroy",1);var L$=function(e){function t(e,n){var o,a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:4;return i(this,t),o=r(this,t,[e,n,a]),FF(o,"mediaType",4),FF(o,"source"),FF(o,"stat",{bytesReceived:0,packetsReceived:0,packetsLost:0,framesReceived:0,framesDecoded:0,frameWidth:0,frameHeight:0,end2EndDelay:0,jitterBufferDelay:0}),o.manager=e.videoManager,o.once("first-video-frame",(function(e){o.room.emit("first-video-frame",e)})),o}return d(t,e),s(t,[{key:"play",value:function(e,n){var r=this;return(uj(null==n?void 0:n.canvasRender)?n.canvasRender:17===TW)&&!this.source&&this.useCanvasPlayer(),y(t,"play",this,3)([e,n]).then((function(){r.player.calculateStat()}))}},{key:"useCanvasPlayer",value:function(){if(this.log.info("useCanvasPlayer(), has element:".concat(!!this.player.element)),this.player.element){var e=new M$({frameRate:15,logger:this.log,name:this.userId});e.create({alpha:!1});var t=new I$(e,{name:"remotePlayer",logger:this.log});this.source=e.createVideoPlayerSource(this.player),this.source.connect(t),this.player.setCanvas(e._canvas),sz()||(this.updateCanvasPlayerFPS=this.updateCanvasPlayerFPS.bind(this,e),this.room.on("heartbeat-report",this.updateCanvasPlayerFPS,this))}}},{key:"updateCanvasPlayerFPS",value:function(e){var t=this.decodeFPS,n=function(e){return[15,30,45,60].reduce((function(t,n){return Math.abs(n-e)<Math.abs(t-e)?n:t}))}(t);!cj(t)||t<=0?this.log.debug("updateCanvasPlayerFPS() ignore decoder: ".concat(t," ")):n!==e.frameRate?(this.log.info("updateCanvasPlayerFPS() decoder: ".concat(t,", closest: ").concat(n,", current: ").concat(e.frameRate)),e.frameRate=n):this.log.debug("updateCanvasPlayerFPS() ignore ClosestFPS ".concat(n," == ").concat(e.frameRate))}},{key:"decodeFPS",get:function(){var e,t=this,n=(null==(e=this.room.heartbeatReport)?void 0:e.msg_down_stream_info.find((function(e){return e.msg_user_info.str_identifier===t.userId})))||{},r=n.msg_video_status,i=2===this.mediaType?7:this.isSmall?3:2;if(!r||0===r.length)return 0;var o=r.find((function(e){return e.uint32_video_stream_type===i}));return(null==o?void 0:o.uint32_video_dec_fps)||0}},{key:"stop",value:function(){return this.room.off("heartbeat-report",this.updateCanvasPlayerFPS,this),y(t,"stop",this,3)([])}},{key:"decodeFrame",value:function(e){if(!this.manager)return e;var t,n=c(this.manager.decodePipeline);try{for(n.s();!(t=n.n()).done;){var r=t.value;if(r&&!(e=r({frame:e,track:this})))return}}catch(i){n.e(i)}finally{n.f()}return e}},{key:"isBig",get:function(){return 4===this.mediaType}},{key:"isSmall",get:function(){return 8===this.mediaType}},{key:"changeType",value:function(e){this.room.changeType(e,this.user)}},{key:"isRemotePublished",get:function(){return this.user.muteState.videoAvailable}},{key:"setMirror",value:function(e){"publish"===e||"both"===e||y(t,"setMirror",this,3)([e])}},{key:"onDecodeDowngradeStateChanged",value:function(e){this.emit("decode-downgrade-state-changed",e)}}])}(_$),V$=function(e){function t(e,n){var o;return i(this,t),o=r(this,t,[e,n,2]),FF(o,"mediaType",2),FF(o,"objectFit","contain"),o}return d(t,e),s(t,[{key:"isRemotePublished",get:function(){return this.user.muteState.hasAuxiliary}}])}(L$),U$=new Map;function F$(e,t){var n=OF(xF({},t),{timestamp:rB()});U$.has(e)?U$.get(e).push(n):U$.set(e,[n])}function B$(e){if(U$.has(e)){var t=U$.get(e).map((function(e){return{uint32_event_id:e.eventId,uint64_date:e.timestamp,str_userid:e.remoteUserId,uint32_param1:e.param1,uint32_param2:e.param2,uint32_video_stream_type:e.streamType}}));return U$.delete(e),t}return[]}HW.on(GW.JOIN_SUCCESS,(function(e){F$(e.room.userId,{eventId:32788})})),HW.on(GW.LEAVE_START,(function(e){F$(e.room.userId,{eventId:32789})})),HW.on(GW.LOCAL_TRACK_PUBLISHED,(function(e){var t=e.track;if(t.room){var n=32769;4===t.mediaType?n=32768:2===t.mediaType&&(n=32805),F$(t.room.userId,{eventId:n})}})),HW.on(GW.LOCAL_TRACK_UNPUBLISHED,(function(e){var t=e.track;if(t.room){var n=32771;4===t.mediaType?n=32770:2===t.mediaType&&(n=32806),F$(t.room.userId,{eventId:n})}})),HW.on(GW.TRACK_MUTED,(function(e){var t=e.track;t.room&&(t.kind===UB.AUDIO?F$(t.room.userId,{eventId:t.isRemote?32785:32772,remoteUserId:t.isRemote?t.userId:void 0}):F$(t.room.userId,{eventId:t.isRemote?32784:32773,remoteUserId:t.isRemote?t.userId:void 0}))})),HW.on(GW.TRACK_UNMUTED,(function(e){var t=e.track;t.room&&(t.kind===UB.AUDIO?F$(t.room.userId,{eventId:t.isRemote?32787:32774,remoteUserId:t.isRemote?t.userId:void 0}):F$(t.room.userId,{eventId:t.isRemote?32786:32775,remoteUserId:t.isRemote?t.userId:void 0}))})),HW.on(GW.REMOTE_TRACK_SUBSCRIBED,(function(e){var t=e.track;t.room&&(1===t.mediaType&&F$(t.room.userId,{eventId:32777,remoteUserId:t.userId}),4===t.mediaType&&F$(t.room.userId,{eventId:32776,remoteUserId:t.userId}),8===t.mediaType&&F$(t.room.userId,{eventId:32803,remoteUserId:t.userId}))})),HW.on(GW.REMOTE_TRACK_UNSUBSCRIBED,(function(e){var t=e.track;t.room&&(1===t.mediaType&&F$(t.room.userId,{eventId:32779,remoteUserId:t.userId}),4===t.mediaType&&F$(t.room.userId,{eventId:32778,remoteUserId:t.userId}),8===t.mediaType&&F$(t.room.userId,{eventId:32804,remoteUserId:t.userId}))})),HW.on(GW.SWITCH_DEVICE_SUCCESS,(function(e){var t=e.track;t.room&&F$(t.room.userId,{eventId:t.kind===UB.VIDEO?32780:32781})})),HW.on(GW.LOCAL_TRACK_REPLACED,(function(e){var t=e.track;t.room&&F$(t.room.userId,{eventId:t.kind===UB.VIDEO?32782:32783})})),HW.on(GW.SIGNAL_CONNECTION_STATE_CHANGED,(function(e){var t,n=e.room,r=e.prevState;switch(e.state){case"CONNECTED":t="RECONNECTING"===r?32795:32791;break;case"DISCONNECTED":t="RECONNECTING"===r?32796:32790;break;case"RECONNECTING":t=32794}t&&F$(n.userId,{eventId:t})})),HW.on(GW.PEER_CONNECTION_STATE_CHANGED,(function(e){var t,n=e.room,r=e.prevState,i=e.state,o=e.remoteUserId,a=!!o;switch(i){case"CONNECTED":t="RECONNECTING"===r?a?32801:32798:a?32793:32792;break;case"DISCONNECTED":"RECONNECTING"===r&&(t=a?32802:32799);break;case"RECONNECTING":t=a?32800:32797}t&&F$(n.userId,{eventId:t,remoteUserId:o})})),HW.on(GW.VIDEO_CODEC_IMPLEMENTATION_CHANGED,(function(e){e.implementation;var t=e.userId,n=e.remoteUserId,r=e.codec,i=e.isHWCodec,o=i?1:0;e.prevImplementation||(o=i?3:2);var a="h264"===r?0:2,s={eventId:4004,param1:o,param2:a,streamType:e.streamType||2};n&&(s.remoteUserId=n,s.eventId=4005),F$(t,s),fK.addEnum({key:n?514701:513701,value:o}),fK.addEnum({key:n?514700:513700,value:a})})),HW.on(GW.LOCAL_TRACK_RECAPTURE,(function(e){var t=e.track,n=e.error;if(t.userId){var r={eventId:2003,param1:0};t.kind===UB.AUDIO?(r.streamType=1,n&&(r.param1=2)):(r.streamType="auxiliary"===t.streamType?7:2,n&&(r.param1=8)),F$(t.userId,r)}}));var H$=function(e){function t(e,n){var o,a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"userId";return i(this,t),(o=r(this,t)).mySelfId=e,o._log=n,o.key=a,FF(o,"userMap",new Map),FF(o,"remotePublishedUserMap",new Map),o}return d(t,e),s(t,[{key:"hasRobotUser",get:function(){return!!T(this.remotePublishedUserMap.values()).find((function(e){return e.isRobot}))}},{key:"getPublishedUser",value:function(e){return this.remotePublishedUserMap.get(e)}},{key:"addUser",value:function(e){var t=e[this.key],n=e.userId,r=e.tinyId,i=e.role;if(!this.userMap.has(t)){var o={userId:n,tinyId:r,role:20===i?"anchor":"audience"};this.userMap.set(t,o),this.emit("1",o)}}},{key:"deleteUser",value:function(e,t){var n=this.userMap.get(e);if(n){var r="peer leave [".concat(e,"]");aj(t)||(r+=":".concat(MH[t])),this._log.info(r);var i=this.remotePublishedUserMap.get(e);if(i){var o=i.muteState;i.flag=0,this.emit("5",i.userId),this.deleteRemotePublishedUser(e),this.emit("6",{prevMuteState:o,muteState:i.muteState,flag:0})}this.userMap.delete(e),this.emit("2",n.userId)}}},{key:"setUserList",value:function(e){var t=this;this.userMap.forEach((function(n){e.findIndex((function(e){return e[t.key]===n[t.key]}))<0&&t.deleteUser(n[t.key],0)})),e.forEach((function(e){!t.userMap.has(e[t.key])&&e[t.key]!==t.mySelfId&&t.addUser(e)}))}},{key:"addRemotePublishedUser",value:function(e){this.remotePublishedUserMap.has(e[this.key])||this.remotePublishedUserMap.set(e[this.key],e)}},{key:"deleteRemotePublishedUser",value:function(e){this.remotePublishedUserMap.has(e)&&this.remotePublishedUserMap.delete(e)}},{key:"setRemotePublishedUserList",value:function(e){var t=this;this.remotePublishedUserMap.forEach((function(n){var r=n[t.key];if(e.findIndex((function(e){return e[t.key]===n[t.key]}))<0){t._log.info("remote [".concat(r,"] unpublish"));var i=n.muteState;n.flag=0,t.emit("5",n.userId),t.deleteRemotePublishedUser(r),t.emit("6",{prevMuteState:i,muteState:n.muteState,flag:0})}})),e.forEach((function(e){var n,r=e[t.key];if(r!==t.mySelfId){var i=e.flag,o=e.userId,a=e.tinyId,s=Ij(i,o),c=null==(n=t.remotePublishedUserMap.get(r))?void 0:n.muteState;if(c){var u=t.remotePublishedUserMap.get(r);u&&u.flag!==i&&(u.flag=i,t._log.info("remote publish updated: ".concat(JSON.stringify(u.muteState))),t.emit("6",{prevMuteState:c,muteState:s,flag:i}))}else t._log.info("remote publish. state: ".concat(JSON.stringify(s))),t.addUser({userId:o,tinyId:a,role:20}),t.emit("3",e),t.emit("6",{prevMuteState:Ij(0,o),muteState:s,flag:i})}}))}},{key:"clear",value:function(){this.userMap.clear(),this.remotePublishedUserMap.clear()}}])}(VF(jF(),1).EventEmitter);function j$(e){var t=e.timesInSecond,n=e.maxSizeInSecond,r=e.getSize;return rY((function(e,i){var o=new WeakMap;return HW.on(GW.ROOM_DESTROY,(function(e){var t=e.room;return o.delete(t)})),function(){for(var a=o.get(this),s=arguments.length,c=new Array(s),u=0;u<s;u++)c[u]=arguments[u];if(a||(a={callCountInSecond:0,timestamp:0,totalSizeInSecond:0},o.set(this,a)),0===a.timestamp?a.timestamp=Date.now():Date.now()-a.timestamp>1e3&&(a.timestamp=Date.now(),a.callCountInSecond=0,a.totalSizeInSecond=0),r&&(a.totalSizeInSecond+=r.apply(void 0,c)),0!==a.timestamp&&Date.now()-a.timestamp<1e3&&(a.callCountInSecond>=t||a.totalSizeInSecond>n))throw new tB({code:ZF.INVALID_OPERATION,message:rK({key:ZJ.CALL_FREQUENCY_LIMIT,data:{isTimes:a.callCountInSecond>=t,isSize:a.totalSizeInSecond>n,name:i,timesInSecond:t,maxSizeInSecond:n}})});a.callCountInSecond++,e.call.apply(e,[this].concat(c))}}))}var G$,W$=!0,J$={SCENE_LIVE:"live",SCENE_RTC:"rtc",ROLE_ANCHOR:"anchor",ROLE_AUDIENCE:"audience",STREAM_TYPE_MAIN:"main",STREAM_TYPE_SUB:"sub",AUDIO_PROFILE_STANDARD:"standard",AUDIO_PROFILE_STANDARD_STEREO:"standard-stereo",AUDIO_PROFILE_HIGH:"high",AUDIO_PROFILE_HIGH_STEREO:"high-stereo",QOS_PREFERENCE_SMOOTH:"smooth",QOS_PREFERENCE_CLEAR:"clear",SPEAKER:"Speakerphone",HEADSET:"Headset earpiece"},K$={INVALID_PARAMETER:5e3,INVALID_OPERATION:5100,ENV_NOT_SUPPORTED:5200,DEVICE_ERROR:5300,SERVER_ERROR:5400,OPERATION_FAILED:5500,OPERATION_ABORT:5998,UNKNOWN_ERROR:5999},z$=((G$=z$||{})[G$.INVALID_PARAMETER=5e3]="INVALID_PARAMETER",G$[G$.INVALID_PARAMETER_REQUIRED=5001]="INVALID_PARAMETER_REQUIRED",G$[G$.INVALID_PARAMETER_TYPE=5002]="INVALID_PARAMETER_TYPE",G$[G$.INVALID_PARAMETER_EMPTY=5003]="INVALID_PARAMETER_EMPTY",G$[G$.INVALID_PARAMETER_INSTANCE=5004]="INVALID_PARAMETER_INSTANCE",G$[G$.INVALID_PARAMETER_RANGE=5005]="INVALID_PARAMETER_RANGE",G$[G$.INVALID_PARAMETER_LESS_THAN_ZERO=5006]="INVALID_PARAMETER_LESS_THAN_ZERO",G$[G$.INVALID_PARAMETER_MIN=5007]="INVALID_PARAMETER_MIN",G$[G$.INVALID_PARAMETER_MAX=5008]="INVALID_PARAMETER_MAX",G$[G$.INVALID_ELEMENT_ID=5009]="INVALID_ELEMENT_ID",G$[G$.INVALID_ELEMENT_ID_TYPE=5010]="INVALID_ELEMENT_ID_TYPE",G$[G$.INVALID_STREAM_ID=5011]="INVALID_STREAM_ID",G$[G$.INVALID_ROOM_ID_STRING=5012]="INVALID_ROOM_ID_STRING",G$[G$.INVALID_ROOM_ID_INTEGER=5013]="INVALID_ROOM_ID_INTEGER",G$[G$.INVALID_STREAM_TYPE=5014]="INVALID_STREAM_TYPE",G$[G$.INVALID_ROOM_ID_REQUIED=5015]="INVALID_ROOM_ID_REQUIED",G$[G$.INVALID_ROOM_ID_INTEGER_STRING=5016]="INVALID_ROOM_ID_INTEGER_STRING",G$[G$.INVALID_BUFFER_EMPTY=5017]="INVALID_BUFFER_EMPTY",G$[G$.INVALID_BUFFER_OVERSIZE=5018]="INVALID_BUFFER_OVERSIZE",G$[G$.INVALID_OPERATION=5100]="INVALID_OPERATION",G$[G$.INVALID_OPERATION_NOT_JOINED=5101]="INVALID_OPERATION_NOT_JOINED",G$[G$.INVALID_OPERATION_REMOTE_USER_NOT_EXIST=5102]="INVALID_OPERATION_REMOTE_USER_NOT_EXIST",G$[G$.INVALID_OPERATION_STREAM_TYPE_NOT_EXIST=5103]="INVALID_OPERATION_STREAM_TYPE_NOT_EXIST",G$[G$.INVALID_OPERATION_REPEAT_CALL=5104]="INVALID_OPERATION_REPEAT_CALL",G$[G$.INVALID_OPERATION_NEED_VIDEO=5105]="INVALID_OPERATION_NEED_VIDEO",G$[G$.INVALID_OPERATION_NEED_AUDIO=5106]="INVALID_OPERATION_NEED_AUDIO",G$[G$.INVALID_ROLE_AUDIENCE=5107]="INVALID_ROLE_AUDIENCE",G$[G$.INVALID_NOT_ENABLE_SEI=5108]="INVALID_NOT_ENABLE_SEI",G$[G$.INVALID_NEED_CALL_PUBLISHED=5109]="INVALID_NEED_CALL_PUBLISHED",G$[G$.ENV_NOT_SUPPORTED=5200]="ENV_NOT_SUPPORTED",G$[G$.NOT_SUPPORTED_HTTP=5201]="NOT_SUPPORTED_HTTP",G$[G$.NOT_SUPPORTED_WEBRTC=5202]="NOT_SUPPORTED_WEBRTC",G$[G$.NOT_SUPPORTED_H264_ENCODE=5203]="NOT_SUPPORTED_H264_ENCODE",G$[G$.NOT_SUPPORTED_H264_DECODE=5204]="NOT_SUPPORTED_H264_DECODE",G$[G$.NOT_SUPPORTED_SCREEN_SHARE=5205]="NOT_SUPPORTED_SCREEN_SHARE",G$[G$.NOT_SUPPORTED_SMALL_VIDEO=5206]="NOT_SUPPORTED_SMALL_VIDEO",G$[G$.NOT_SUPPORTED_SEI=5207]="NOT_SUPPORTED_SEI",G$[G$.NOT_SUPPORTED_WEBGL=5208]="NOT_SUPPORTED_WEBGL",G$[G$.NOT_SUPPORTED_CHROME_VERSION=5209]="NOT_SUPPORTED_CHROME_VERSION",G$[G$.NOT_SUPPORTED_PLUGIN=5210]="NOT_SUPPORTED_PLUGIN",G$[G$.DEVICE_ERROR=5300]="DEVICE_ERROR",G$[G$.DEVICE_NOT_FOUND_ERROR=5301]="DEVICE_NOT_FOUND_ERROR",G$[G$.DEVICE_NOT_ALLOWED_ERROR=5302]="DEVICE_NOT_ALLOWED_ERROR",G$[G$.DEVICE_NOT_READABLE_ERROR=5303]="DEVICE_NOT_READABLE_ERROR",G$[G$.DEVICE_OVERCONSTRAINED_ERROR=5304]="DEVICE_OVERCONSTRAINED_ERROR",G$[G$.DEVICE_INVALID_STATE_ERROR=5305]="DEVICE_INVALID_STATE_ERROR",G$[G$.DEVICE_SECURITY_ERROR=5306]="DEVICE_SECURITY_ERROR",G$[G$.DEVICE_ABORT_ERROR=5307]="DEVICE_ABORT_ERROR",G$[G$.CAMERA_RECOVER_FAILED=5308]="CAMERA_RECOVER_FAILED",G$[G$.MICROPHONE_RECOVER_FAILED=5309]="MICROPHONE_RECOVER_FAILED",G$[G$.SERVER_ERROR=5400]="SERVER_ERROR",G$[G$.NEED_TO_BUY=5401]="NEED_TO_BUY",G$[G$.ACCOUNT_NO_MONEY=-100013]="ACCOUNT_NO_MONEY",G$[G$.OPERATION_FAILED=5500]="OPERATION_FAILED",G$[G$.FIREWALL_RESTRICTION=5501]="FIREWALL_RESTRICTION",G$[G$.REJOIN_FAILED=5502]="REJOIN_FAILED",G$[G$.EVENT_HANDLER_ERROR=5503]="EVENT_HANDLER_ERROR",G$[G$.VIDEO_CONTEXT_ERROR=5504]="VIDEO_CONTEXT_ERROR",G$[G$.VIDEO_DECODE_ERROR=5505]="VIDEO_DECODE_ERROR",G$[G$.OPERATION_ABORT=5998]="OPERATION_ABORT",G$[G$.UNKNOWN_ERROR=5999]="UNKNOWN_ERROR",G$);var q$=OF(xF({},eK),{INVALID_PARAMETER:function(e){var t=e.fnName;return"the parameters of the '".concat(t,"' you called does not meet the requirements, please check the API documentation.")},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(ij(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(ij(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,".")},INVALID_PARAMETER_LESS_THAN_ZERO:function(e){var t=e.key,n=e.rule,r=e.fnName;return"'".concat(t||n.name,"' cannot be less than 0 when calling ").concat(r,"().")},INVALID_PARAMETER_MIN:function(e){var t=e.key,n=e.rule,r=e.value;return"the min value of ".concat(t||n.name," is ").concat(n.min,", received: ").concat(r,".")},INVALID_PARAMETER_MAX:function(e){var t=e.key,n=e.rule,r=e.value;return"the max value of ".concat(t||n.name," is ").concat(n.max,", received: ").concat(r,".")},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 HTMLElement when calling ").concat(n,"(), received: ").concat(r,".")},INVALID_STREAM_ID:function(e){var t=e.key;return"'".concat(t,"' can only consist of uppercase and lowercase english letters (a-zA-Z), numbers (0-9), hyphens and underscores.")},INVALID_ROOM_ID_STRING:function(e){var t=e.key;return"'".concat(t,"' must be a valid string.")},INVALID_ROOM_ID_INTEGER:function(e){var t=e.key;return"'".concat(t,"' must be an integer between [1, 4294967294].")},INVALID_ROOM_ID_INTEGER_STRING:function(e){var t=e.key;return"'".concat(t,"' must be an integer but go a string, use 'parseInt' to convert it or use 'strRoomId' instead.")},INVALID_ROOM_ID_REQUIED:function(){return"at least one of 'roomId'(between [1, 4294967294]) and 'strRoomId'(not empty) is required."},INVALID_STREAM_TYPE:function(e){var t=e.fnName;return"'streamType' is required when 'userId' is not '*', calling ".concat(t,"()")},INVALID_IMAGE_URL:"The 'src' param must be filled in when the background type is image.",INVALID_OPERATION:function(e){var t=e.fnName;return"the API '".concat(t,"' you called does not meet the requirements, please check the API documentation.")},INVALID_OPERATION_NOT_JOINED:function(e){var t=e.fnName;return"cannot ".concat(t," because you are not enter room yet.")},INVALID_OPERATION_REMOTE_USER_NOT_EXIST:function(e){var t=e.fnName,n=e.value;return"cannot ".concat(t," because remote user(userId: ").concat(n.userId,") does not publishing stream.")},INVALID_OPERATION_STREAM_TYPE_NOT_EXIST:function(e){var t=e.fnName,n=e.value;return"cannot ".concat(t," because remote user(userId: ").concat(n.userId,") does not publishing ").concat(n.streamType," video.")},INVALID_OPERATION_REPEAT_CALL:function(e){var t=e.fnName;return"you are already ".concat(t,"(), cannot repeated call '").concat(t,"'.")},INVALID_OPERATION_NEED_VIDEO:function(e){var t=e.fnName;return"cannot call '".concat(t,"' because the camera is not turned on.")},INVALID_OPERATION_NEED_AUDIO:function(e){var t=e.fnName;return"cannot call '".concat(t,"' because the microphone is not turned on.")},INVALID_BUFFER_EMPTY:function(e){var t=e.key;return"the buffer size of paramerter '".concat(t,"' cannot be empty")},INVALID_BUFFER_OVERSIZE:function(){return"buffer size is over 1000 Bytes"},INVALID_ROLE_AUDIENCE:function(){return"role: 'audience' cannot call this api."},INVALID_NOT_ENABLE_SEI:function(){return"you need to enable SEI in TRTC.create({ enableSEI: true })"},INVALID_NEED_CALL_PUBLISHED:function(e){var t=e.fnName;return"you need to call ".concat(t,"() after publish stream.")},ENV_NOT_SUPPORTED:function(e){var t=e.fnName;return"the current browser does not support the capability of the function '".concat(t,"' you are calling, please check the API documentation.")},NOT_SUPPORTED_WEBRTC:"the current browser does not support WebRTC capability, please check the SDK documentation.",NOT_SUPPORTED_H264_ENCODE:"this browser does not support H264 encode.",NOT_SUPPORTED_H264_DECODE:"this browser does not support H264 decode.",NOT_SUPPORTED_SCREEN_SHARE:"this browser does not support screen share, please check the browser version.",NOT_SUPPORTED_SMALL_VIDEO:"this browser does not support small video, please check the browser version.",NOT_SUPPORTED_SEI:"this browser does not support SEI, please check the browser version.",NOT_SUPPORTED_WEBGL:"this browser does not support WebGL, please check the browser version.",NOT_SUPPORTED_CHROME_VERSION:function(e){var t=e.fnName;return"cannot call ".concat(t," because the browser version is too low, please upgrade to the latest version")},DEVICE_ERROR:function(e){var t=e.fnName,n=e.error;return"'".concat(t,"' got device exception").concat(n?", error: ".concat(n.toString(),"."):".")},DEVICE_NOT_FOUND_ERROR:function(e){var t=e.fnName,n=e.deviceType,r=void 0===n?Y$(t):n,i=e.error;return"NotFoundError, no ".concat(r," detected, please check your device and the configuration on '").concat(t,"'").concat(i?", error: ".concat(i.toString(),"."):".")},DEVICE_NOT_ALLOWED_ERROR:function(e){var t=e.fnName,n=e.deviceType,r=void 0===n?Y$(t):n,i=e.error;return"NotAllowedError, you have disabled ".concat(r," access, please allow the current application to use the ").concat(r).concat(i?", error: ".concat(i.toString(),"."):".")},DEVICE_NOT_READABLE_ERROR:function(e){var t=e.fnName,n=e.deviceType,r=void 0===n?Y$(t):n;return e.error,"NotReadableError, the ".concat(r," maybe in use by another APP, please check if the device is pre-occupied by another APP.")},DEVICE_OVERCONSTRAINED_ERROR:function(e){var t=e.fnName,n=e.deviceType;void 0===n&&Y$(t);var r=e.error;return"OverconstrainedError, the device ID is incorrect, please check whether the device ID passed in is correct".concat(r?", error: ".concat(r.toString(),"."):".")},DEVICE_INVALID_STATE_ERROR:function(e){var t=e.fnName,n=e.deviceType,r=void 0===n?Y$(t):n,i=e.error;return"InvalidStateError, after the user clicks and interacts with the page, turn on the ".concat(r).concat(i?", error: ".concat(i.toString(),"."):".")},DEVICE_SECURITY_ERROR:function(e){var t=e.fnName,n=e.deviceType,r=void 0===n?Y$(t):n,i=e.error;return"SecurityError, check whether the system security policy restricts the use of the ".concat(r,", and it is recommended to turn on the ").concat(r," after the user interacts with the page").concat(i?", error: ".concat(i.toString(),"."):".")},DEVICE_ABORT_ERROR:function(e){var t=e.fnName,n=e.deviceType;void 0===n&&Y$(t);var r=e.error;return"AbortError, an unknown exception in the system makes the device unusable, recommended to change the device or browser and re-check whether the device is normal".concat(r?" error: ".concat(r.toString(),"."):".")},CAMERA_RECOVER_FAILED:function(e){var t=e.error;return"camera recover capture failed ".concat((null==t?void 0:t.name)||"",": ").concat((null==t?void 0:t.originMessage)||(null==t?void 0:t.message))},MICROPHONE_RECOVER_FAILED:function(e){var t=e.error;return"microphone recover capture failed ".concat((null==t?void 0:t.name)||"",": ").concat((null==t?void 0:t.originMessage)||(null==t?void 0:t.message))},OPERATION_FAILED:function(e){var t=e.fnName,n=e.error;return"'".concat(t,"' failed, reason: ").concat(null==n?void 0:n.toString())},FIREWALL_RESTRICTION:function(){return"media connection failure due to firewall restrictions, please try to change your network."},EVENT_HANDLER_ERROR:function(e){var t=e.eventName;return"an error was caught on trtc.on('".concat(t,"', handler), please check your code on 'handler'.")},VIDEO_CONTEXT_ERROR:function(e){var t=e.reason,n=e.error;return"video context error ".concat(t," ").concat((null==n?void 0:n.name)||""," ").concat((null==n?void 0:n.message)||"")},SERVER_ERROR:function(e){var t=e.fnName,n=e.error;return"'".concat(t,"' got server error: ").concat(null==n?void 0:n.toString(),", please check the SDK documentation.")},NEED_TO_BUY:function(e){var t=e.value,n=e.url;return"You need to buy packages for ".concat(t,". Refer to: ").concat(n)},ACCOUNT_NO_MONEY:function(e){var t=e.fnParams;return"your TRTC account run out of credit, please recharge.".concat(t.sdkAppId?" SDKAppId: ".concat(t.sdkAppId):"")},OPERATION_ABORT:function(e){var t=e.fnName;return"'".concat(t,"' abort")},UNKNOWN_ERROR:function(e){var t=e.fnName,n=e.error;return"'".concat(t,"' throw unknown exception").concat(n?", error: ".concat(n.toString(),"."):".")}});function Y$(e){if(!e)return"camera";var t=e.toLowerCase();return t.includes("screen")?"screen share":t.includes("audio")?"microphone":"camera"}var X$=function(e){function t(e){var n,o,a,s=e.code,c=e.extraCode,u=e.message,l=void 0===u?"":u,d=e.messageParams,h=e.fnName,f=void 0===h?"":h,p=e.originError;return i(this,t),a=l||function(e){var t,n=e.code,r=e.params,i=e.enableDocLink,o=void 0!==i&&i,a="",s=z$[n];try{t=q$[s]}catch(f){t=q$.UNKNOWN_ERROR}return oj(t)?a=t(r):sj(t)&&(a=t),r.fnName&&!a.includes(r.fnName)&&("."!==a[a.length-1]&&(a+="."),a+=" thrown from ".concat(r.fnName,"()")),o&&(a+=" doc:"),a}({code:s===K$.SERVER_ERROR?s:c||s,params:xF({fnName:f,error:p},d)}),n=r(this,t,[a]),FF(n,"name","RtcError"),FF(n,"code"),FF(n,"extraCode"),FF(n,"functionName"),FF(n,"message"),FF(n,"handler"),FF(n,"originError"),n.name=z$[s],n.code=s,n.extraCode=c,n.functionName=f,n.originError=p,n.message=a,5302===n.extraCode&&null!=(o=n.originError)&&o.message.includes("system")&&(n.handler=function(){var e=document.createElement("a");GG?e.href="ms-settings:privacy-".concat({startLocalVideo:"webcam",startLocalAudio:"microphone"}[n.functionName]):WG&&(e.href="x-apple.systempreferences:com.apple.preference.security?Privacy_".concat({startLocalVideo:"Camera",startLocalAudio:"Microphone",startScreenShare:"ScreenCapture"}[n.functionName])),e.href.length>0&&e.click()}),n}return d(t,e),s(t,null,[{key:"convertFrom",value:function(e,n,r){var i=e;if(e instanceof tB){var o=e.stack,a={code:K$.UNKNOWN_ERROR,fnName:n,originError:e};switch(e.getCode()){case ZF.INVALID_PARAMETER:a.code=K$.INVALID_PARAMETER,a.message=e.message;break;case ZF.INVALID_OPERATION:a.code=K$.INVALID_OPERATION;break;case ZF.NOT_SUPPORTED:case ZF.NOT_SUPPORTED_H264:a.code=K$.ENV_NOT_SUPPORTED,e.getCode()===ZF.NOT_SUPPORTED_H264&&(a.extraCode=e.message.includes(eK.NOT_SUPPORTED_H264ENCODE)?5203:5204);break;case ZF.JOIN_ROOM_FAILED:a.messageParams={fnParams:r};case ZF.SERVER_TIMEOUT:case ZF.SWITCH_ROLE_FAILED:a.code=K$.SERVER_ERROR,a.extraCode=e.getExtraCode();break;case ZF.API_CALL_ABORTED:a.code=K$.OPERATION_ABORT;break;case ZF.DEVICE_NOT_FOUND:case ZF.DEVICE_AUTO_RECOVER_FAILED:case ZF.INITIALIZE_FAILED:a.code=5300,e.name&&(a.extraCode=function(e){var t;switch(e){case"NotFoundError":t=5301;break;case"NotAllowedError":t=5302;break;case"NotReadableError":t=5303;break;case"OverconstrainedError":t=5304;break;case"InvalidStateError":t=5305;break;case"SecurityError":t=5306;break;case"AbortError":t=5307;break;default:t=5300}return t}(e.name));break;case ZF.UNKNOWN:break;default:a.code=K$.OPERATION_FAILED}i=new t(a),o&&(i.stack+=o.substr(o.indexOf("\n")))}else{if(e instanceof t)return e;i=new t({code:K$.UNKNOWN_ERROR,fnName:n,originError:e})}return i}}])}(b(Error));var Q$=X$,$$={type:"object",properties:{cameraId:{type:"string"},useFrontCamera:{type:"boolean"},fillMode:{type:"string",values:["contain","cover","fill"]},mirror:{type:["string","boolean"],values:[!0,!1,"view","publish","both"]},small:{properties:{width:{type:"number"},height:{type:"number"},frameRate:{type:"number"},bitrate:{type:"number"}}},videoTrack:{instanceOf:MediaStreamTrack}}},Z$={type:"object",properties:{systemAudio:{type:"boolean"},fillMode:{type:"string",values:["contain","cover","fill"]},profile:{type:["string","object"],properties:{width:{type:"number"},height:{type:"number"},frameRate:{type:"number"},bitrate:{type:"number"}}},videoTrack:{instanceOf:MediaStreamTrack},audioTrack:{instanceOf:MediaStreamTrack}}},eZ={type:["string",HTMLElement,null,"array"],arrayItem:{instanceOf:HTMLElement},validate:function(e,t,n){if(sj(e)&&!document.getElementById(e))throw new Q$({code:K$.INVALID_PARAMETER,extraCode:5009,fnName:n,messageParams:{key:t}})}},tZ={name:"userId",required:!0,type:"string"},nZ={type:"object",properties:{microphoneId:{type:"string"},audioTrack:{instanceOf:MediaStreamTrack},captureVolume:{type:"number",min:0},earMonitorVolume:{type:"number",min:0,max:100},profile:{values:[J$.AUDIO_PROFILE_STANDARD,J$.AUDIO_PROFILE_STANDARD_STEREO,J$.AUDIO_PROFILE_HIGH,J$.AUDIO_PROFILE_HIGH_STEREO]},echoCancellation:{type:"boolean"},autoGainControl:{type:"boolean"},noiseSuppression:{type:"boolean"}}};function rZ(e,t){if(!e)throw new Q$({code:K$.INVALID_OPERATION,extraCode:5101,fnName:t})}function iZ(e,t,n){if(!e)throw new Q$({code:K$.INVALID_OPERATION,extraCode:5102,fnName:t,messageParams:{value:n}})}var oZ={create:[{name:"RoomConfig",instanceOf:Function},{name:"CreateConfig",type:"object",properties:{plugins:{type:"array",arrayItem:{instanceOf:Function}}}}],enterRoom:{name:"EnterRoomConfig",type:"object",required:!0,validate:function(e,t,n){if(this._room.isJoined)throw new Q$({code:K$.INVALID_OPERATION,extraCode:5104,fnName:n});if(e.roomId){if(sj(e.roomId))throw new Q$({code:K$.INVALID_PARAMETER,extraCode:5016,fnName:n,messageParams:{key:t}});if(!(/^[1-9]\d*$/.test(String(e.roomId))&&e.roomId<4294967295))throw new Q$({code:K$.INVALID_PARAMETER,extraCode:5013,fnName:n,messageParams:{key:t}})}else{if(!e.strRoomId)throw new Q$({code:K$.INVALID_PARAMETER,extraCode:5015,fnName:n});if(!/^[A-Za-z\d\s!#$%&()+\-:;<=.>?@[\]^_{}|~,]{1,64}$/.test(e.strRoomId))throw new Q$({code:K$.INVALID_PARAMETER,extraCode:5012,fnName:n,messageParams:{key:t}})}},properties:{sdkAppId:{required:!0,type:"number",allowEmpty:!1},userId:{required:!0,type:"string",allowEmpty:!1},userSig:{required:!0,type:"string",allowEmpty:!1},scene:{type:"string",values:["live","rtc"]},role:{type:"string",values:["audience","anchor"]},roomId:{type:["string","number"]},strRoomId:{type:"string"},proxy:{type:["object","string"],properties:{websocketProxy:{type:"string"},turnServer:{type:["object","array"],properties:{url:{required:!0,type:"string"},username:{type:"string"},credential:{type:"string"},credentialType:{type:"string",values:["password"]}}},loggerProxy:{type:"string"},webtransportProxy:{type:"string"}}},enableAutoPlayDialog:{type:"boolean"},userDefineRecordId:{type:"string"},latencyLevel:{type:"number"},playoutDelay:{type:"object",properties:{min:{type:"number",min:0,max:1e3},max:{type:"number",min:0,max:1e4}}}}},startLocalVideo:{name:"LocalVideoConfig",type:"object",properties:{view:eZ,mute:{type:["boolean","string"]},publish:{type:"boolean"},option:$$},validate:function(e){var t;if((null==(t=null==e?void 0:e.option)||!t.videoTrack)&&TK())throw new Q$({code:K$.ENV_NOT_SUPPORTED,extraCode:5201})}},updateLocalVideo:{name:"updateLocalVideoConfig",type:"object",required:!0,properties:{view:OF(xF({},eZ),{required:!1}),publish:{type:"boolean"},mute:{type:["boolean","string"]},option:$$}},startLocalAudio:{name:"LocalAudioConfig",type:"object",properties:{publish:{type:"boolean"},option:nZ},validate:function(e){var t;if((null==(t=null==e?void 0:e.option)||!t.audioTrack)&&TK())throw new Q$({code:K$.ENV_NOT_SUPPORTED,extraCode:5201})}},updateLocalAudio:{name:"updateLocalAudioConfig",type:"object",required:!0,properties:{publish:{type:"boolean"},mute:{type:"boolean"},option:nZ}},startScreenShare:{name:"ScreenShareConfig",type:"object",properties:{view:eZ,publish:{type:"boolean"},option:Z$},validate:function(e,t,n,r,i){var o;if(null==(o=null==e?void 0:e.option)||!o.videoTrack){if(TK())throw new Q$({code:K$.ENV_NOT_SUPPORTED,extraCode:5201});if(!RK())throw new Q$({code:K$.ENV_NOT_SUPPORTED,fnName:n,extraCode:5205})}}},updateScreenShare:{name:"updateScreenShareConfig",type:"object",required:!0,properties:{view:eZ,publish:{type:"boolean"},option:Z$}},muteRemoteAudio:[tZ,{name:"mute",required:!0,type:"boolean"}],setRemoteAudioVolume:[tZ,{name:"volume",required:!0,type:"number",min:0}],startRemoteVideo:{name:"startRemoteVideoConfig",type:"object",required:!0,properties:{view:eZ,userId:{type:"string",required:!0},streamType:{values:["main","sub"],required:!0},option:{type:"object",properties:{fillMode:{type:"string",values:["contain","cover","fill"]},mirror:{type:"boolean"}}}},validate:function(e,t,n){rZ(this._room.isJoined,n);var r=this._room.remotePublishedUserMap.get(e.userId);if(iZ(!!r,n,e),r&&("main"===e.streamType&&!r.muteState.videoAvailable||"sub"===e.streamType&&!r.muteState.hasAuxiliary))throw new Q$({code:K$.INVALID_OPERATION,extraCode:5103,fnName:n,messageParams:{value:e}})}},updateRemoteVideo:{name:"updateRemoteVideoConfig",type:"object",required:!0,properties:{view:OF(xF({},eZ),{required:!1}),userId:{type:"string",required:!0},streamType:{values:["main","sub"],required:!0},option:{type:"object",properties:{fillMode:{type:"string",values:["contain","cover","fill"]},mirror:{type:"boolean"}}}},validate:function(e,t,n){rZ(this._room.isJoined,n);var r=this._room.remotePublishedUserMap.get(e.userId);if(iZ(!!r,n,e),r&&("main"===e.streamType&&!r.muteState.videoAvailable||"sub"===e.streamType&&!r.muteState.hasAuxiliary))throw new Q$({code:K$.INVALID_OPERATION,extraCode:5103,fnName:n,messageParams:{value:e}})}},stopRemoteVideo:{name:"stopRemoteVideoConfig",type:"object",required:!0,properties:{userId:{type:"string",required:!0},streamType:{values:["main","sub"]}},validate:function(e,t,n){if("*"!==e.userId&&aj(e.streamType))throw new Q$({code:K$.INVALID_PARAMETER,extraCode:5014,fnName:n})}},switchRole:{name:"role",required:!0,values:["anchor","audience"],validate:function(e,t,n){rZ(this._room.isJoining||this._room.isJoined,n)}},enableAudioVolumeEvaluation:[{name:"interval",type:"number"},{name:"enableInBackground",type:"boolean"}],sendSEIMessage:[{name:"buffer",required:!0,instanceOf:ArrayBuffer,validate:function(e,t,n,r){if(!$K)throw new Q$({code:K$.ENV_NOT_SUPPORTED,fnName:n,extraCode:5207});if(!this._room.enableSEI)throw new Q$({code:K$.INVALID_OPERATION,fnName:n,extraCode:5108});if(e.byteLength>1e3)throw new Q$({code:K$.INVALID_PARAMETER,extraCode:5018,fnName:n});if(0===e.byteLength)throw new Q$({code:K$.INVALID_PARAMETER,extraCode:5017,messageParams:{key:t},fnName:n});rZ(this._room.isJoined,n)}},{name:"options",type:"object",properties:{seiPayloadType:{type:"number",values:[5,243]},toSubStream:{type:"boolean",validate:function(e,t,n){if(!e&&!this._room.isMainStreamPublished||e&&!this._room.isAuxStreamPublished)throw new Q$({code:K$.INVALID_OPERATION,extraCode:5109,messageParams:{key:t},fnName:n})}}}}],sendCustomMessage:{name:"message",required:!0,type:"object",properties:{cmdId:{type:"number",required:!0,min:1,max:10},data:{instanceOf:ArrayBuffer,required:!0,validate:function(e,t,n,r){if(e.byteLength>1e3)throw new Q$({code:K$.INVALID_PARAMETER,extraCode:5018,fnName:n});if(0===e.byteLength)throw new Q$({code:K$.INVALID_PARAMETER,extraCode:5017,fnName:n,messageParams:{key:t}})}}},validate:function(e,t,n){if(rZ(this._room.isJoined,n),"live"===this._room.scene&&"audience"===this._room.role)throw new Q$({code:K$.INVALID_OPERATION,extraCode:5107,fnName:n,messageParams:{key:t}})}}},aZ={TRTC:oZ},sZ=function(e){function t(){return i(this,t),r(this,t,arguments)}return d(t,e),s(t)}(b(Error));function cZ(e,t){for(var n=Cj(e),r=0;r<t.length;r++)Rj(n[r],t[r]);return n}function uZ(e){this._resolve=Promise.resolve(e)}function lZ(e){this._reject=Promise.reject(e)}var dZ=function(){function e(t,n){i(this,e),this.instance=t,this.group=n,FF(this,"started",!1),FF(this,"ops",[]),FF(this,"startSame",(function(){return!0})),FF(this,"mergeUpdate",cZ);var r=e.instances.get(t);r?r.set(n,this):e.instances.set(t,new Map([[n,this]]))}return s(e,[{key:"action",value:function(e,t,n){var r=this,i=function(t){var n;return 0===e?r.started=!0:3===e&&(r.started=!1),r.ops.shift(),null==(n=r.currentOp)||n.action(),t},o=function(t){var n,i;throw r.ops.shift(),0===e&&2===(null==(n=r.currentOp)?void 0:n.type)&&r.ops.shift().reject(new sZ("start failed")),null==(i=r.currentOp)||i.action(),t},a={type:e,action:function(){return t.apply(void 0,T(a.args)).then(i,o)},args:n,resolve:uZ,reject:lZ};try{switch(this.state){case 1:if(0===e)throw new sZ("already started");break;case 4:if(2===e)throw new sZ("not started");break;default:return this.cacheOp(a)}}catch(oJ){return Promise.reject(oJ)}return this.ops.push(a),a.promise=t.apply(void 0,T(a.args)).then(i,o)}},{key:"cacheOp",value:function(e){if(1===this.ops.length)switch(this.state){case 0:case 2:if(0===e.type)throw new sZ("already start");break;case 3:switch(e.type){case 2:throw new sZ("update not allowed when stopping");case 3:return this.currentOp.promise}break;default:throw new sZ("unknown state")}else switch(e.type){case 3:if(3===this.lastOpType)return this.lastOp.promise;var t=new sZ("keep stop");if(this.ops.slice(1).forEach((function(e){return e.reject(t)})),this.ops=this.ops.slice(0,1),3===this.state)return this.currentOp.promise;break;case 2:switch(this.lastOpType){case 2:return this.lastOp.args=this.mergeUpdate(this.lastOp.args,e.args),this.lastOp.promise;case 3:throw new sZ("update not allowed after stop")}break;case 0:switch(this.lastOpType){case 2:throw new sZ("start not allowed after update");case 0:throw new sZ("duplicate start");case 3:if(this.startSame(this.currentOp.args,e.args))throw this.ops.pop().reject(new sZ("keep start")),new sZ("already start")}}e.promise=new Promise((function(t,n){e._resolve?e._resolve.then(t):e.resolve=t,e._reject?e._reject.catch(n):e.reject=n}));var n=e.action;return e.action=function(){return n().then(e.resolve,e.reject)},this.ops.push(e),e.promise}},{key:"lastOp",get:function(){return this.ops[this.ops.length-1]}},{key:"lastOpType",get:function(){return this.lastOp.type}},{key:"currentOp",get:function(){return this.ops[0]}},{key:"state",get:function(){return this.currentOp?this.currentOp.type:this.started?1:4}}],[{key:"get",value:function(t,n){if(n){var r=e.instances.get(t);return r&&r.get(n)||new e(t,n)}}},{key:"gets",value:function(t,n){var r=e.instances.get(t),i=[];return r&&r.forEach((function(e,t){n.test(t)&&i.push(e)})),i}}])}();FF(dZ,"instances",new WeakMap);var hZ=dZ,fZ=new WeakMap,pZ=function(e,t){if(t instanceof sZ){var n=t.stack;t=new Q$({code:K$.OPERATION_ABORT,message:"".concat(e," abort: ").concat(t.message),fnName:e}),n&&(t.stack+=n.substr(n.indexOf("\n")))}throw t};function mZ(e,t){return rY((function(n,r){return function(){for(var i=arguments.length,o=new Array(i),a=0;a<i;a++)o[a]=arguments[a];var s=hZ.get(this,"string"==typeof e?e:e.call.apply(e,[this].concat(o)));return s?(t&&(s.startSame=t.bind(this)),s.action(0,n.bind(this),o).catch(pZ.bind(null,r))):n.apply(this,o)}}))}function vZ(e,t){var n=t||{},r=n.merge,i=n.debounce;return rY((function(t,n){return function(){for(var o=this,a=arguments.length,s=new Array(a),c=0;c<a;c++)s[c]=arguments[c];var u=hZ.get(this,"string"==typeof e?e:e.call.apply(e,[this].concat(s)));if(!u)return t.apply(this,s);if(r&&(u.mergeUpdate=r.bind(this)),i&&i.isNeedToDebounce.apply(this,s)){var l=i.delay,d=i.getKey;return new Promise((function(e,r){var i,a,c=null==(i=fZ.get(o))?void 0:i.get(d.apply(void 0,s));if(c){var h=c.timeoutId,f=c.resolve;clearTimeout(h),f()}var p=setTimeout((function(){if(3===u.state||4===u.state)return e();u.action(2,t.bind(o),s).catch(pZ.bind(null,n)).then(e,r)}),l);fZ.has(o)?null==(a=fZ.get(o))||a.set(d.apply(void 0,s),{timeoutId:p,resolve:e}):fZ.set(o,new Map([[d.apply(void 0,s),{timeoutId:p,resolve:e}]]))}))}return u.action(2,t.bind(this),s).catch(pZ.bind(null,n))}}))}function _Z(e){return rY((function(t,n){return function(){for(var r=this,i=arguments.length,o=new Array(i),a=0;a<i;a++)o[a]=arguments[a];var s="function"==typeof e?e.call.apply(e,[this].concat(o)):e;if(s instanceof RegExp)return Promise.all(hZ.gets(this,s).map((function(e){return e.action(3,(function(){return Promise.resolve()}),o)}))).then((function(){return t.call.apply(t,[r].concat(o))}));var c=hZ.get(this,s);return c?c.action(3,t.bind(this),o).catch(pZ.bind(null,n)):t.apply(this,o)}}))}var gZ={ERROR:"error",AUTOPLAY_FAILED:"autoplay-failed",KICKED_OUT:"kicked-out",REMOTE_USER_ENTER:"remote-user-enter",REMOTE_USER_EXIT:"remote-user-exit",REMOTE_AUDIO_AVAILABLE:"remote-audio-available",REMOTE_AUDIO_UNAVAILABLE:"remote-audio-unavailable",REMOTE_VIDEO_AVAILABLE:"remote-video-available",REMOTE_VIDEO_UNAVAILABLE:"remote-video-unavailable",AUDIO_VOLUME:"audio-volume",AUDIO_FRAME:"audio-frame",NETWORK_QUALITY:"network-quality",CONNECTION_STATE_CHANGED:"connection-state-changed",AUDIO_PLAY_STATE_CHANGED:"audio-play-state-changed",VIDEO_PLAY_STATE_CHANGED:"video-play-state-changed",SCREEN_SHARE_STOPPED:"screen-share-stopped",DEVICE_CHANGED:"device-changed",PUBLISH_STATE_CHANGED:"publish-state-changed",TRACK:"track",STATISTICS:"statistics",SEI_MESSAGE:"sei-message",CUSTOM_MESSAGE:"custom-message",VIDEO_DECODE_DOWNGRADE_STATE_CHANGED:"video-decode-downgrade-state-changed",LAYER_DATA:"layerData",FIRST_VIDEO_FRAME:"first-video-frame"},yZ=new Set([gZ.ERROR,gZ.AUTOPLAY_FAILED,gZ.KICKED_OUT,gZ.REMOTE_USER_ENTER,gZ.REMOTE_USER_EXIT,gZ.REMOTE_AUDIO_AVAILABLE,gZ.REMOTE_AUDIO_UNAVAILABLE,gZ.REMOTE_VIDEO_AVAILABLE,gZ.REMOTE_VIDEO_UNAVAILABLE,gZ.CONNECTION_STATE_CHANGED,gZ.PUBLISH_STATE_CHANGED,gZ.SCREEN_SHARE_STOPPED,gZ.DEVICE_CHANGED,gZ.FIRST_VIDEO_FRAME]);function EZ(e){return"sub"===e?"auxiliary":"auxiliary"===e?"sub":"main"}function TZ(e){return e===J$.QOS_PREFERENCE_CLEAR?"detail":e===J$.QOS_PREFERENCE_SMOOTH?"motion":""}var kZ={};LF(kZ,{bytes2ms:function(){return YH},convertObjectNumberToInt:function(){return Uj},copyProperties:function(){return qH},deepClone:function(){return Cj},deepMerge:function(){return Rj},delay:function(){return Fj},fibonacci:function(){return nj},formatedTime:function(){return Nj},getConstructorName:function(){return vj},getContainerFromElement:function(){return Dj},getEnv:function(){return BH},getInternalVersion:function(){return Tj},getLoggerUrl:function(){return jH},getMuteStateFromFlag:function(){return Ij},getNetworkType:function(){return WH},getNumNetworkType:function(){return zH},getReconnectionTimeout:function(){return rj},getStringByteLength:function(){return Pj},getTurnServer:function(){return bj},getUint32Version:function(){return Vj},getValueType:function(){return ij},getViewListFromView:function(){return wj},glog:function(){return ZH},ipv4ToUint32:function(){return Aj},isArray:function(){return dj},isAudioWorkletSupported:function(){return _j},isBoolean:function(){return uj},isConstructor:function(){return mj},isEmpty:function(){return Sj},isFunction:function(){return oj},isLangChinese:function(){return ej},isMediaStreamTrack:function(){return hj},isNumber:function(){return cj},isObject:function(){return lj},isOverseaSdkAppId:function(){return HH},isPlainObject:function(){return tj},isPortrait:function(){return Mj},isPromise:function(){return pj},isRemoteTrack:function(){return fj},isString:function(){return sj},isUndefined:function(){return aj},loadImage:function(){return Lj},ms2bytes:function(){return QH},ms2samples:function(){return $H},performanceNow:function(){return yj},promiseAny:function(){return gj},samples2ms:function(){return XH},setNetworkType:function(){return KH},stringify:function(){return xj},stringifyIncludeValue:function(){return Oj},throttlePromise:function(){return Bj}});var SZ={};LF(SZ,{ScheduleRequestType:function(){return NZ},getAbilityConfig:function(){return OZ},getScheduleDomain:function(){return PZ},isNeedToSchedule:function(){return bZ},scheduleProxy:function(){return wZ},sendScheduleRequest:function(){return CZ},setIsNeedToSchedule:function(){return AZ},setScheduleProxy:function(){return DZ}});var IZ=null,bZ=!0;function AZ(e){uj(e)&&e!==bZ&&(bZ=e,qW.info("setIsNeedToSchedule ".concat(e)))}function RZ(e,t,n){var r={totalCost:0,local:0,dns:0,tcp:0,tls:0,request:0,response:0};try{var i,o=performance.getEntriesByType("resource"),a=xZ(e,"config",UB.MAIN),s=xZ(e,"config",UB.BACKUP),u=c(o);try{for(u.s();!(i=u.n()).done;){var l=i.value;if(l.startTime>=n&&(l.name===a||l.name===s)&&l.transferSize>0){var d=l.name===a?UB.MAIN:UB.BACKUP,h=Math.round(l.duration),f=Math.round(l.domainLookupStart-l.startTime),p=l.redirectStart>0?Math.round(l.redirectEnd-l.redirectStart):0,m=l.fetchStart>0?Math.round(l.domainLookupStart-l.fetchStart):0,v=Math.round(l.domainLookupEnd-l.domainLookupStart),_=Math.round(l.requestStart-l.secureConnectionStart),g=Math.round(l.secureConnectionStart-l.connectStart),y=Math.round(l.responseStart-l.requestStart),E=Math.round(l.responseEnd-l.responseStart),T=[v,_,g,y,E];Nz.uploadEvent({log:"stat-schedule-net:".concat(h,"(").concat(f,"(").concat(p,"->").concat(m,")->").concat(T.join("->"),") ").concat(d),userId:t}),r=OF(xF({},r),{totalCost:h,local:f,dns:v,tcp:g,tls:_,request:y,response:E});break}}}catch(k){u.e(k)}finally{u.f()}}catch(o){qW.error("getScheduleDetailCost error",o)}return r}function CZ(e){return HF(this,arguments,(function(e){var t=e.userId,n=e.sdkAppId,r=e.useStringRoomId,i=e.roomId,o=e.userSig,a=e.version,s=e.frameWorkType,c=e.role,u=e.latencyLevel;return p().mark((function e(){var l,d,h,f,m,v,_,g,y;return p().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(bZ||!IZ){e.next=2;break}return e.abrupt("return",{isCached:!0,result:IZ});case 2:return l={delta:0,count:[1,1],msg:[],detail:[]},e.prev=3,(d=new FormData).append("userId",String(t)),d.append("sdkAppId",String(n)),d.append("isStrGroupId",String(r)),d.append("groupId",String(i)),d.append("sdkVersion",a),d.append("userSig",String(o)),c&&d.append("role",String(c)),u&&d.append("latencyLevel",String(u)),s&&d.append("frameWorkType",String(s)),h=yj(),e.next=9,VZ(d,l,n);case 9:return(f=e.sent).config&&(f.config.loggerDomain&&_B(f.config.loggerDomain),uj(f.config.scheduleCache)&&AZ(!f.config.scheduleCache)),l.delta=yj()-h,m=RZ(Number(n),t,h),e.abrupt("return",(IZ=f,{isCached:!1,result:f,detailCost:m}));case 15:throw e.prev=15,e.t0=e.catch(3),v=dj(e.t0)?e.t0[0]:e.t0,_=cj(v.code)?v.code:0,g="schedule failed".concat(v.message?": ".concat(v.message):""),y=new tB({code:ZF.SCHEDULE_FAILED,extraCode:_,message:rK({key:ZJ.JOIN_ROOM_FAILED,data:{error:g,code:_}})}),qW.error(g,_),y;case 19:case"end":return e.stop()}}),e,null,[[3,15]])}))()}))}"undefined"!=typeof document&&document.head.insertAdjacentHTML("beforeend",Object.values(RH).map((function(e){return'<link rel="dns-prefetch" href="https://'.concat(e,'">')})).join("\r\n")),HW.on("28",(function(){return AZ(!0)})),HW.on("63",(function(){return AZ(!0)})),HW.on("84",(function(){return AZ(!0)})),HW.on("201",(function(e){"RECONNECTING"===e.state&&AZ(!0)})),HW.on("202",(function(e){"RECONNECTING"===e.state&&AZ(!0)}));var wZ={main:"",backup:""};function DZ(e){dj(e)?(wZ.main=e[0],wZ.backup=e[1]):wZ.main=e}var NZ=function(e){return e.CONFIG="config",e.TRTC_AUTO_CONF="trtcAutoConf",e.AUDIO_AI_AUTH="audioAiAuth",e}(NZ||{});function xZ(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:UB.MAIN,r=arguments.length>3&&void 0!==arguments[3]&&arguments[3];return"https://".concat(wZ[n]||PZ(e,n,r),"/api/v1/").concat(t)}function OZ(e,t,n){var r=xZ(e,t),i=xZ(e,t,UB.BACKUP),o=new URLSearchParams(n).toString();return gj([fetch("".concat(r,"?").concat(o)).then((function(e){return e.json()})),fetch("".concat(i,"?").concat(o)).then((function(e){return e.json()}))])}function PZ(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:UB.MAIN,n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];return HH(e)?n?t===UB.MAIN?RH.MAIN_OVERSEA_BACKUP:RH.BACKUP_OVERSEA:t===UB.MAIN?RH.MAIN_OVERSEA:RH.BACKUP_OVERSEA:t===UB.MAIN?RH.MAIN:RH.BACKUP}function MZ(e,t,n){return new Promise((function(r,i){Hj({url:e,body:t,timeout:n.timeout,priority:"high"}).then((function(e){0===e.data.code?r(e.data.data):i({code:e.data.code,message:e.data.msg})})).catch(i)}))}var LZ=function(e,t){return qj({retryFunction:MZ,settings:{retries:3,timeout:0},onError:t,onRetrying:e})};function VZ(e,t,n){return new Promise((function(r,i){var o=null;gj([LZ((function(e){return t.count[0]=e+1}),(function(e){var r=e.error,i=e.retry,a=e.retriedCount,s=e.retryFuncArgs;t.msg[0]=r.message,o||(a>=1&&(s[0]=xZ(n,"config",UB.MAIN,!0)),i())}))(xZ(n,"config",UB.MAIN),e,{get timeout(){return 1e3*nj(2+t.count[0])}}),LZ((function(e){return t.count[1]=e+1}),(function(e){var r=e.error,i=e.retry,a=e.retriedCount,s=e.retryFuncArgs;t.msg[1]=r.message,o||(a>=2&&(s[0]=xZ(n,"config",UB.BACKUP,!0)),i())}))(xZ(n,"config",UB.BACKUP),e,{get timeout(){return 1e3*nj(2+t.count[1])}})]).then((function(e){r(o=e)})).catch(i)}))}var UZ=function(e){return e.startsWith("data:application/octet-stream;base64,")},FZ=function(e){return e.startsWith("file://")},BZ=function(){return s((function e(){i(this,e),FF(this,"_log"),this._log=qW.createLogger({id:"fd"})}),[{key:"download",value:function(e,t){return HF(this,null,p().mark((function n(){var r,i,o,a,s;return p().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(r=(t||{}).type,i=void 0===r?"blob":r,e=e.replace(/(^|[^:])\/{2,}/g,"$1/"),n.prev=2,o=yj(),!oj(fetch)){n.next=10;break}return n.next=7,this.downloadWithFetch(e,i);case 7:a=n.sent,n.next=13;break;case 10:return n.next=12,this.downloadWithXHR(e,i);case 12:a=n.sent;case 13:if(a&&a.data){n.next=15;break}throw new Error("data is empty");case 15:return s=yj()-o,n.abrupt("return",(this._log.info("downloaded: ".concat(e,", return type: ").concat(i,", cost: ").concat(s,"ms")),fK.addSuccessEvent({key:522700,cost:yj()-o}),a.data));case 19:throw n.prev=19,n.t0=n.catch(2),this._log.error("failed to download: ".concat(e,", error: ").concat(n.t0)),fK.addFailedEvent({key:522700,error:n.t0}),n.t0;case 22:case"end":return n.stop()}}),n,this,[[2,19]])})))}},{key:"downloadWithFetch",value:function(e,t){return HF(this,null,p().mark((function n(){var r,i;return p().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return this._log.info("download with fetch: ".concat(e,", return type: ").concat(t)),n.prev=1,n.next=4,fetch(e);case 4:if((r=n.sent).ok){n.next=7;break}throw new Error("network response was not ok");case 7:if("arraybuffer"!==t){n.next=13;break}return n.next=10,r.arrayBuffer();case 10:i=n.sent,n.next=16;break;case 13:return n.next=15,r.blob();case 15:i=n.sent;case 16:return n.abrupt("return",{data:i});case 19:throw n.prev=19,n.t0=n.catch(1),n.t0;case 22:case"end":return n.stop()}}),n,this,[[1,19]])})))}},{key:"downloadWithXHR",value:function(e,t){return this._log.info("download with xhr: ".concat(e,", return type: ").concat(t)),new Promise((function(n,r){var i=new XMLHttpRequest;i.open("GET",e,!0),i.responseType=t,i.onload=function(){200===i.status||0===i.status&&i.response?n({data:i.response}):r(new Error("XHR failed"))},i.onerror=r,i.send(null)}))}},{key:"loadWasm",value:function(e,t){return HF(this,null,p().mark((function n(){var r,i,o,a,s,c;return p().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(this._log.info("loadWasm ".concat(e,", importObject: ").concat(JSON.stringify(t))),r=yj(),i=null,o=null,!oj(WebAssembly.instantiateStreaming)||UZ(e)||FZ(e)||!oj(fetch)){n.next=13;break}return n.prev=3,a=fetch(e),n.next=7,WebAssembly.instantiateStreaming(a,t);case 7:i=n.sent.instance,n.next=13;break;case 10:n.prev=10,n.t0=n.catch(3),o=n.t0;case 13:if(i){n.next=26;break}return n.prev=14,n.next=17,this.download(e,{type:"arraybuffer"});case 17:return s=n.sent,n.next=20,WebAssembly.instantiate(s,t);case 20:i=n.sent.instance,n.next=26;break;case 23:n.prev=23,n.t1=n.catch(14),o=n.t1;case 26:if(!i){n.next=29;break}return c=yj()-r,n.abrupt("return",(this._log.info("loadedWasm ".concat(e,", cost: ").concat(c,"ms")),fK.addSuccessEvent({key:522701,cost:c}),i));case 29:throw this._log.error("failed to loadWasm ".concat(e,", error: ").concat(o)),fK.addFailedEvent({key:522701,error:o}),o;case 30:case"end":return n.stop()}}),n,this,[[3,10],[14,23]])})))}}])}();UF([Oz({settings:{timeout:0,retries:3},onRetrying:function(e){this._log.warn("download retrying: ".concat(e))}})],BZ.prototype,"download",1);var HZ=new BZ;function jZ(e){var t=this,n=e.TRTC,r=e.room,i=e.errorModule;return{TRTC:n,room:r,assetsPath:e.assetsPath,fileDownloader:HZ,innerEmitter:HW,constants:sB,environment:Xj,utils:kZ,eventLogger:Nz,log:this.room.getLogger(),loggerManager:qW,errorModule:i,kvStatManager:fK,rtcDectection:$W,trtc:this,rx:xY,enums:ZW,schedule:SZ,clearStarted:function(e,n){var r=e.getAlias(),i=hZ.instances.get(t);if(i)if(n){var o=i.get(r+n);if(!o)return;o.started=!1}else i.forEach((function(e,t){t.startsWith(r)&&(e.started=!1)}))},startGetPCM:wY,createAudioNode:Eq}}var GZ=new WeakMap;function WZ(e){var t=GZ.get(e);t&&(t.forEach((function(e){return clearTimeout(e)})),GZ.delete(e))}function JZ(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return rY((function(e,n){return function(){for(var r=arguments.length,i=new Array(r),o=0;o<r;o++)i[o]=arguments[o];try{zZ.call(this,t,i,n,this._name)}catch(iJ){return Promise.reject(iJ)}return e.apply(this,i)}}))}function KZ(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return rY((function(e,n){return function(){for(var r=arguments.length,i=new Array(r),o=0;o<r;o++)i[o]=arguments[o];try{zZ.call(this,t,i,n,this._name)}catch(iJ){throw iJ}return e.apply(this,i)}}))}function zZ(e,t,n,r){if(dj(e))for(var i=0;i<e.length;i++)qZ.call(this,{rule:e[i],value:t[i],key:e[i].name,fnName:n,className:r});else qZ.call(this,{rule:e,value:t[0],key:e.name,fnName:n,className:r})}function qZ(e){var t=this,n=e.rule,r=e.value,i=e.key,o=e.fnName,a=e.className;function s(e){return{code:K$.INVALID_PARAMETER,extraCode:e,fnName:o,messageParams:{key:i,rule:n,value:r}}}if(aj(r)){if(n.required)throw new Q$(s(5001));if(aj(n.defaultValue))return void(oj(n.validate)&&n.validate.call(this,r,i,o,a,this));r=n.defaultValue}if(Array.isArray(n.type)){for(var c=!1,u=0;u<n.type.length;u++)null===n.type[u]&&null===r&&(c=!0),oj(n.type[u])&&r instanceof n.type[u]&&(c=!0),sj(n.type[u])&&ij(r)===n.type[u].toLowerCase()&&(c=!0);if(!c)throw new Q$({code:K$.INVALID_PARAMETER,extraCode:5002,fnName:o,messageParams:{key:i,rule:{type:n.type.map((function(e){return mj(e)?vj(e):sj(e)?e:ij(e)}))},value:r}})}else if(!aj(n.type)&&ij(r)!==n.type)throw new Q$(s(5002));if(!1===n.allowEmpty){var l=cj(r)&&(0===r||Number.isNaN(r)),d=sj(r)&&""===r.trim();if(l||d)throw new Q$(s(5003))}if(n.notLessThanZero&&cj(r)&&r<0)throw new Q$(s(5006));if(!aj(n.min)&&cj(r)&&r<n.min)throw new Q$(s(5007));if(!aj(n.max)&&cj(r)&&r>n.max)throw new Q$(s(5008));if(sj(n.instanceOf)){if(!r||r._name!==n.instanceOf)throw new Q$(s(5004))}else if(oj(n.instanceOf)&&!(r instanceof n.instanceOf))throw new Q$(s(5004));if(Array.isArray(n.values)&&!n.values.includes(r))throw new Q$(s(5005));var h=n.properties;tj(h)&&lj(r)&&Object.keys(h).forEach((function(e){qZ.call(t,{rule:h[e],value:r&&r[e],key:"".concat(e),fnName:o,className:a})}));var f=n.arrayItem;tj(f)&&dj(r)&&r.forEach((function(e,n){qZ.call(t,{rule:f,value:e,key:"".concat(i,"[").concat(n,"]"),fnName:o,className:a})})),oj(n.validate)&&n.validate.call(this,r,i,o,a,this)}function YZ(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.getRemoteId,n=void 0===t?function(){return""}:t,r=e.replaceArg,i=e.getKVReportKey,o=e.ignoreLog;return rY((function(e,t){return function(){for(var a,s=this,c=arguments.length,u=new Array(c),l=0;l<c;l++)u[l]=arguments[l];function d(e,t,n){if(n&&n.includes(e))return"hided";if(r){var i=r.apply(void 0,u);if(u[i.argIndex]===t)return i.value}if(t===u||e in u)return t;try{return t instanceof HTMLElement?"id: ".concat(t.id," type:").concat(ij(t)):(JSON.stringify(t),t)}catch(i){return"type:".concat(ij(t))}}var h=this._log||qW;if(null!=o&&o.apply(void 0,u))return e.apply(this,u);u.length>0?h.info("".concat(t,"() ").concat(JSON.stringify(u,(function(e,t){return d(e,t,["userSig","privateMapKey"])})))):h.info("".concat(t,"()"));var f=i?i.apply(void 0,u):sK[t];try{var p=e.apply(this,u),m=yj();return pj(p)?p.then((function(e){return h.info("".concat(t,"() success ").concat(n.call.apply(n,[s].concat(u)))),fK.addSuccessEvent({key:f,cost:yj()-m}),e})).catch((function(e){var r,i=(e=Q$.convertFrom.call(s,e,t,1===u.length?u[0]:u)).extraCode||e.code,o=null!=(r=e.message)&&r.includes(i)?"":" code:".concat(i);throw h.error("".concat(t,"() failed ").concat(n.call.apply(n,[s].concat(u))," ").concat(e).concat(o," params: ").concat(JSON.stringify(u,d))),fK.addFailedEvent({key:f,error:e}),e})):(fK.addSuccessEvent({key:f}),p)}catch(p){var v=(p=Q$.convertFrom.call(this,p,t)).extraCode||p.code,_=null!=(a=p.message)&&a.includes(v)?"":" code:".concat(v);throw h.error("".concat(t,"() failed ").concat(p).concat(_," params: ").concat(JSON.stringify(u,d))),fK.addFailedEvent({key:f,error:p}),p}}}))}var XZ=function(e){return rY((function(t,n){return function(r,i){return HF(this,null,p().mark((function o(){var a;return p().wrap((function(o){for(;;)switch(o.prev=o.next){case 0:if(a=this._plugins.get(r)){o.next=3;break}throw this._log.error("plugin ".concat(String(r)," is not found")),new Q$({code:K$.OPERATION_ABORT,message:"plugin ".concat(String(r)," is not found"),fnName:n});case 3:if(!oj(a.constructor.isSupported)||a.constructor.isSupported()){o.next=5;break}throw this._log.error("plugin ".concat(String(r)," is not supported")),new Q$({code:K$.ENV_NOT_SUPPORTED,message:"plugin ".concat(String(r)," is not supported"),extraCode:5210,fnName:n});case 5:return o.abrupt("return",(zZ.call(this,a.getValidateRule(e),[i],n,"TRTC"),t.call(this,a,i)));case 6:case"end":return o.stop()}}),o,this)})))}}))},QZ=0,$Z=function(){return s((function e(t,n){i(this,e),FF(this,"player"),FF(this,"publisher"),FF(this,"mixInput"),this.mixInput=new _q(n),t.url?(this.player=new Audio(t.url),this.player.crossOrigin="anonymous",this.publisher=new Audio(t.url),this.publisher.crossOrigin="anonymous",this.mixInput.replaceSource(this.publisher)):this.mixInput.replaceSource(t.track),this.mixInput.connect()}),[{key:"updateSettings",value:function(e){this.player&&(aj(e.volume)||(this.volume=e.volume),aj(e.loop)||(this.loop=e.loop),aj(e.playbackRate)||(this.playbackRate=e.playbackRate))}},{key:"updateListener",value:function(e){if(this.player){if(e.onDurationChange){var t=e.onDurationChange;this.player.ondurationchange=function(e){t(e.target.duration)}}if(e.onTimeUpdate){var n=e.onTimeUpdate,r=this.player;r.ontimeupdate=function(){n(r.currentTime,r.duration)}}e.onEnded&&(this.player.onended=e.onEnded)}}},{key:"reset",value:function(){this.seek(0),this.mixInput.connect()}},{key:"seek",value:function(e){this.player&&(e<0&&e>this.player.duration||(this.player.currentTime=e,this.publisher.currentTime=e))}},{key:"play",value:function(){var e,t;return null==(e=this.publisher)||e.play(),null==(t=this.player)?void 0:t.play()}},{key:"pause",value:function(){var e,t;null==(e=this.player)||e.pause(),null==(t=this.publisher)||t.pause()}},{key:"stop",value:function(){var e;null==(e=this.player)||e.pause(),this.mixInput.disconnect()}},{key:"setOperation",value:function(e){"pause"===e&&this.pause(),"resume"===e&&(this.pause(),this.play()),"stop"===e&&(this.pause(),this.seek(0))}},{key:"volume",set:function(e){!this.player||!this.publisher||(this.player.volume=e,this.publisher.volume=e)}},{key:"loop",set:function(e){!this.player||!this.publisher||(this.player.loop=e,this.publisher.loop=e)}},{key:"playbackRate",set:function(e){!this.player||!this.publisher||(this.player.playbackRate=e,this.publisher.playbackRate=e)}}])}();function ZZ(e,t){if(t&&"function"!=typeof t)throw new Q$({code:K$.INVALID_PARAMETER,message:"start audioMixer plugin: param ".concat(e," should be a function.")})}var e0=function(){function e(t){i(this,e),this.core=t,FF(this,"log"),FF(this,"mixedMusicMap",new Map),FF(this,"cacheMusicMap",new Map),QZ+=1,this.log=t.log.createChild({id:"".concat(this.getAlias()).concat(QZ)}),this.log.info("[audioMixer] created id=".concat(this.getAlias()).concat(QZ)),this.core=t}return s(e,[{key:"getName",value:function(){return e.Name}},{key:"getAlias",value:function(){return"ax"}},{key:"getGroup",value:function(e){return null==e?void 0:e.id}},{key:"getValidateRule",value:function(t){switch(t){case"start":return e.startValidateRule;case"update":return e.updateValidateRule;case"stop":return e.stopValidateRule}}},{key:"start",value:function(e){return HF(this,null,p().mark((function t(){var n,r,i;return p().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=this.core.room,this.log.info("add music source, id: ".concat(e.id," url: ").concat(e.url,", track: ").concat(e.track)),r=e.id,e.url,!this.mixedMusicMap.has(r)){t.next=5;break}return t.abrupt("return");case 5:return(i=this.cacheMusicMap.get(r))?e.url?i.reset():(i.mixInput.replaceSource(e.track),i.mixInput.connect()):(i=new $Z(e,n.audioManager),this.cacheMusicMap.set(r,i)),i.updateListener(e),i.updateSettings(e),t.next=11,i.play();case 11:this.mixedMusicMap.set(r,i),this.log.info("start mix audio track ".concat(r," success.")),fK.addEnum({key:502700,value:3}),this.kvUpload(e);case 15:case"end":return t.stop()}}),t,this)})))}},{key:"update",value:function(e){return HF(this,null,p().mark((function t(){var n,r,i,o;return p().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=e.id,r=e.operation,i=e.seekFrom,e.playbackRate,this.log.info("update music source, ".concat(JSON.stringify(e))),o=this.mixedMusicMap.get(n)){t.next=6;break}return this.log.warn("update music source failed, music id: ".concat(n," not found.")),t.abrupt("return");case 6:o.updateSettings(e),o.updateListener(e),aj(r)||o.setOperation(r),aj(i)||o.seek(i),this.kvUpload(e);case 7:case"end":return t.stop()}}),t,this)})))}},{key:"stop",value:function(e){return HF(this,arguments,(function(e){var t=this,n=e.id;return p().mark((function e(){var r;return p().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t.mixedMusicMap.has(n)&&(t.log.info("remove music source, music id: ".concat(n)),null==(r=t.mixedMusicMap.get(n))||r.stop(),t.mixedMusicMap.delete(n)),"*"===n&&t.destroyAllMusic();case 1:case"end":return e.stop()}}),e)}))()}))}},{key:"kvUpload",value:function(e){var t=e.track,n=e.loop,r=e.volume,i=e.playbackRate,o=e.operation,a=e.seekFrom,s=e.onTimeUpdate,c=e.onDurationChange,u=e.onEnded;t&&fK.addCount({key:502711}),n&&fK.addCount({key:502703}),r&&fK.addCount({key:502704}),i&&fK.addCount({key:502705}),o&&fK.addCount({key:502706}),a&&fK.addCount({key:502707}),"function"!=typeof s&&fK.addCount({key:502709}),"function"!=typeof u&&fK.addCount({key:502710}),"function"!=typeof c&&fK.addCount({key:502708})}},{key:"destroyAllMusic",value:function(){var e=this;this.log.info("destroy all music source."),this.mixedMusicMap.forEach((function(t,n){return e.stop({id:n})}))}},{key:"destroyAllCache",value:function(){this.log.info("destroy all music cache."),this.cacheMusicMap.clear()}},{key:"destroy",value:function(){this.log.info("destroy audio mixer plugin."),this.destroyAllMusic(),this.destroyAllCache()}}])}();FF(e0,"startValidateRule",{name:"options",required:!0,type:"object",properties:{id:{type:"string",required:!0},url:{type:"string",required:!1},track:{required:!1},loop:{type:"boolean"},volume:{type:"number"}},validate:function(e,t,n){if(e.url&&"*"!==e.url){var r=e.url.split("?")[0],i=r.split(".").pop(),o=["mp3","ogg","wav","flac"].indexOf(i)>=0,a=r.startsWith("blob"),s=r.startsWith("data");if(!(o||a||s))throw new Q$({code:K$.INVALID_PARAMETER,message:"start audioMixer plugin: music url is invalid, please check your file format.",fnName:n})}if(!e.url&&!e.track)throw new Q$({code:K$.INVALID_PARAMETER,message:"start audioMixer plugin: param url or track is required.",fnName:n});ZZ("onTimeUpdate",e.onTimeUpdate),ZZ("onEnded",e.onEnded),ZZ("onDurationChange",e.onDurationChange)}}),FF(e0,"updateValidateRule",{name:"options",required:!0,type:"object",properties:{id:{type:"string",required:!0},loop:{type:"boolean"},volume:{type:"number"},seekFrom:{type:"number"},operation:{type:"string",values:["pause","resume","stop"]}},validate:function(e,t,n){ZZ("onTimeUpdate",e.onTimeUpdate),ZZ("onEnded",e.onEnded),ZZ("onDurationChange",e.onDurationChange)}}),FF(e0,"stopValidateRule",{name:"options",type:"object",required:!0,properties:{id:{type:"string",required:!0}}}),FF(e0,"Name","AudioMixer");var t0,n0=e0,r0=0,i0=function(){function e(t){i(this,e),this.core=t,FF(this,"log"),FF(this,"audioContext",fq()),FF(this,"workletNode"),r0+=1,this.log=t.log.createChild({id:"".concat(this.getAlias()).concat(r0)}),this.log.info("[audioDenoiser] created id=".concat(this.getAlias()).concat(r0)),t.assetsPath&&this.preload("".concat(t.assetsPath,"/denoiser-wasm.js")).catch((function(e){}))}return s(e,[{key:"preload",value:function(e){return t0||(t0=this.doPreload(e)),t0}},{key:"doPreload",value:function(e){return HF(this,null,p().mark((function t(){var n,r;return p().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.core.fileDownloader.download(e,{type:"blob"});case 2:return n=t.sent,r=URL.createObjectURL(n),t.prev=4,t.next=7,aq(this.audioContext,r);case 7:t.next=12;break;case 9:throw t.prev=9,t.t0=t.catch(4),this.log.error("load worklet failed",t.t0),t.t0;case 12:return t.prev=12,URL.revokeObjectURL(r),t.finish(12);case 15:case"end":return t.stop()}}),t,this,[[4,9,12,15]])})))}},{key:"getName",value:function(){return e.Name}},{key:"getAlias",value:function(){return"ad"}},{key:"getGroup",value:function(){return"AIDenoiser_".concat(Date.now())}},{key:"getValidateRule",value:function(t){switch(t){case"start":return e.startValidateRule(this.core);case"update":return e.updateValidateRule;case"stop":return e.stopValidateRule}}},{key:"start",value:function(e){return HF(this,null,p().mark((function t(){var n,r,i,o,a,s,c,u,l,d=this;return p().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=this.core,r=n.room,i=n.schedule,t.next=3,this.preload("".concat(e.assetsPath,"/denoiser-wasm.js"));case 3:if(this.workletNode){t.next=15;break}return o=String(Date.now()).slice(0,-3),t.next=7,a0(i,OF(xF({},e),{timestamp:o}));case 7:if(a=t.sent,s=a.auth,c=a.sign,u=a.status,l=a.message,s){t.next=14;break}throw this.log.info("RTCAIDenoiser: ".concat(e.userId," auth result: ").concat(s,". Message: ").concat(l)),new Q$({code:K$.INVALID_PARAMETER,message:l});case 14:this.workletNode=new AudioWorkletNode(this.audioContext,"trtc-denoiser-processor",{numberOfInputs:1,numberOfOutputs:1}),this.workletNode.port.postMessage({type:"init",data:{sdkAppId:String(e.sdkAppId),userId:e.userId,timestamp:o,sign:c,status:u}}),this.workletNode.port.onmessage=function(e){var t,n=e.data;if("cost"===n.type){var r=(null==n?void 0:n.max)>20?"warn":(null==n?void 0:n.max)>10?"info":"debug";d.log[r]("avg cost: ".concat(n.value," max: ").concat(null==n?void 0:n.max,"(").concat(oB(new Date(null==n?void 0:n.maxCostTimestamp)),") hist: ").concat(null==(t=null==n?void 0:n.hist)?void 0:t.join(" ")))}else"log"===n.type&&d.log[n.logLevel]("".concat(n.value))};case 15:this.workletNode.port.postMessage({type:"enable"}),r.audioManager.addDenoiser(this.workletNode),r.sendAbilityStatus({ai_denoise:1});case 16:case"end":return t.stop()}}),t,this)})))}},{key:"update",value:function(){return HF(this,null,p().mark((function e(){return p().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:case"end":return e.stop()}}),e)})))}},{key:"stop",value:function(){return HF(this,null,p().mark((function e(){var t;return p().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.workletNode){e.next=2;break}return e.abrupt("return");case 2:return t=this.core.room,this.workletNode.port.postMessage({type:"disable"}),e.next=6,t.audioManager.removeDenoiser(this.workletNode);case 6:case"end":return e.stop()}}),e,this)})))}},{key:"destroy",value:function(){this.workletNode&&(this.workletNode.port.onmessage=null)}}],[{key:"startValidateRule",value:function(e){return{name:"options",required:!0,type:"object",properties:{sdkAppId:{type:"number",required:!0},userId:{type:"string",required:!0},userSig:{type:"string",required:!0}},validate:function(t,n,r,i){if(!e.room.audioManager.hasAudioTrack)throw new Q$({code:K$.INVALID_OPERATION,extraCode:5106,fnName:r})}}}}])}();FF(i0,"updateValidateRule",{type:"object"}),FF(i0,"stopValidateRule",{type:"object"}),FF(i0,"Name","AIDenoiser");var o0=i0;function a0(e,t){return HF(this,arguments,(function(e,t){var n=t.sdkAppId,r=t.userId,i=t.userSig,o=t.timestamp;return p().mark((function t(){var a,s,c,u,l,d,h,f;return p().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,e.getAbilityConfig(n,e.ScheduleRequestType.AUDIO_AI_AUTH,{sdkAppId:n,userId:r,userSig:i,timestamp:o});case 3:if(a=t.sent,s=a.data,c=s.errCode,u=s.errMsg,l=s.sign,"1"!==(d=s.status)){t.next=11;break}return t.abrupt("return",{auth:!0,sign:l,status:d,message:u});case 11:h="Init RTCAIDenoiser failed.",f="",t.t0=c,t.next=1===t.t0?15:2===t.t0?17:3===t.t0?19:4===t.t0?21:5===t.t0?23:6===t.t0?25:27;break;case 15:return f="Please check your params.",t.abrupt("break",27);case 17:return f="You need to buy packages. Refer to: https://cloud.tencent.com/document/product/647/44247",t.abrupt("break",27);case 19:return f="Server is invalid. Please contact our engineer. ",t.abrupt("break",27);case 21:return f="Your packages is not active. Refer to: https://cloud.tencent.com/document/product/647/44247",t.abrupt("break",27);case 23:return f="Your packages is expired. Refer to: https://cloud.tencent.com/document/product/647/44247",t.abrupt("break",27);case 25:return f="Your version is not supported.",t.abrupt("break",27);case 27:return t.abrupt("return",{auth:!1,status:d,message:u?"".concat(h," Reason: ").concat(u,". ").concat(f):"".concat(h,", ").concat(f)});case 30:return t.prev=30,t.t1=t.catch(0),t.abrupt("return",{auth:!1,status:"0",message:"Init RTCAIDenoiser failed. All requests failed. ".concat(t.t1)});case 33:case"end":return t.stop()}}),t,null,[[0,30]])}))()}))}var s0=function(e){function t(){var e;return i(this,t),e=r(this,t),FF(e,"observer"),FF(e,"state","nominal"),e.onPressureChange=e.onPressureChange.bind(e),e}return d(t,e),s(t,[{key:"stateNum",get:function(){switch(this.state){case"nominal":return 1;case"fair":return 2;case"serious":return 3;case"critical":return 4}}},{key:"start",value:function(){return HF(this,null,p().mark((function e(){return p().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.observer){e.next=12;break}if(e.prev=1,e.t0="PressureObserver"in window&&!uG,!e.t0){e.next=7;break}return this.observer=new PressureObserver(this.onPressureChange),e.next=7,this.observer.observe("cpu",{sampleInterval:2e3});case 7:e.next=12;break;case 9:e.prev=9,e.t1=e.catch(1),Nz.uploadEvent({log:"stat-pressure-detector-start-failed",error:e.t1});case 12:case"end":return e.stop()}}),e,this,[[1,9]])})))}},{key:"onPressureChange",value:function(e){var t=this.stateNum,n=e[e.length-1];this.state=n.state,(this.stateNum>3||t>3)&&qW.info("".concat(n.source,": ").concat(n.state)),this.emit("state-changed",{type:n.source,state:this.state})}},{key:"destroy",value:function(){var e;try{null==(e=this.observer)||e.disconnect(),this.observer=null}catch(hH){Nz.uploadEvent({log:"stat-pressure-detector-destroy-failed",error:hH})}}}])}(VF(jF(),1).EventEmitter),c0=new s0;function u0(e){var t=_(e,2),n=t[0],r=t[1],i=r.byteLength,o=parseInt(String(i/255),10),a=i%255,s=[];s.push(0,0,0,1,6,n);for(var c=0;c<o;c++)s.push(255);s.push(a);var u=new DataView(r);return s.push.apply(s,T(new Uint8Array(u.buffer))),s.push(128),new _Y(new DataView(new Uint8Array(s).buffer),!0)}function l0(e){return"empty"===e.type||0===e.data.byteLength}function d0(e){return 1===e.getInt32(0)&&6===e.getInt8(4)}function h0(e){for(var t=0,n=0,r=new DataView(e),i=0;i<e.byteLength;i++)switch(r.getUint8(i)){case 0:t++;break;case 1:(2===t||3===t)&&n++,t=0;break;default:t=0}return n}function f0(e){var t=e.frame,n=e.seiMessageList;if(!n||0===n.length||0===t.data.byteLength)return t;var r=9-h0(t.data);if(r<=0)return t;for(var i=n.splice(0,r).reverse().map(u0),o=i.reduce((function(e,t){return e+t.dataView.byteLength}),0),a=new ArrayBuffer(o+t.data.byteLength),s=new DataView(a),c=new DataView(t.data),u=0,l=0;l<i.length;l++)for(var d=0;d<i[l].dataView.byteLength;d++)s.setInt8(u++,i[l].dataView.getInt8(d));for(var h=0;h<t.data.byteLength;h++)s.setInt8(u++,c.getInt8(h));return t.data=a,t}function p0(e){var t=e.frame,n=e.onSEI;try{var r=new DataView(t.data);if(l0(t)||!d0(r))return t;for(var i=[],o=0,a=-1,s=-1,c=0;c<t.data.byteLength;c++){var u=r.getUint8(c);if(0===u)o++;else if(1===u){if(2===o||3===o){var l=c-o;if(-1===a?a=l:-1===s&&(s=l,i.push(new _Y(new DataView(r.buffer.slice(a,s)))),a=l,s=-1),6!==r.getUint8(c+1)){t.data=r.buffer.slice(l);break}}o=0}else o=0}null==n||n(i.reverse())}catch(r){}return t}var m0=0,v0=function(){function e(t){i(this,e),this.core=t,FF(this,"log"),FF(this,"_seiMessageList",[]),FF(this,"_smallSeiMessageList",[]),FF(this,"_subStreamSeiMessageList",[]),m0++,this.log=t.log.createChild({id:"".concat(this.getAlias()).concat(m0)}),this.log.info("[sei] created id=".concat(this.getAlias()).concat(m0)),this.core=t,this.encode=this.encode.bind(this),this.decode=this.decode.bind(this)}return s(e,[{key:"encode",value:function(e){var t=e.frame,n=e.mediaType;try{var r;return f0({frame:t,seiMessageList:8===n?this._smallSeiMessageList:2===n?this._subStreamSeiMessageList:this._seiMessageList})}catch(r){this.log.warn(r)}return t}},{key:"decode",value:function(e){var t=this,n=e.frame,r=e.track;return p0({frame:n,onSEI:function(e){e.forEach((function(e){t.core.trtc.emit(gZ.SEI_MESSAGE,{seiPayloadType:e.seiPayloadType,data:e.seiPayload.buffer,userId:r.userId,streamType:2===r.mediaType?"sub":"main"})}))}})}},{key:"destroy",value:function(){this.log.debug("destory"),this.stop(),delete this.core}},{key:"getValidateRule",value:function(e){switch(e){case"start":case"update":case"stop":return{type:"object"}}}},{key:"start",value:function(){this.core.room.videoManager.addEncodeProcessor({processor:XK?this.encode:f0,type:2}),this.core.room.videoManager.addDecodeProcessor({processor:XK?this.decode:p0,type:2})}},{key:"stop",value:function(){this.core.room.videoManager.removeEncodeProcessor({type:2}),this.core.room.videoManager.removeDecodeProcessor({type:2})}},{key:"update",value:function(e){var t,n=e.buffer,r=e.options,i=[r.seiPayloadType,n],o=!!r.small;r.toSubStream?this._subStreamSeiMessageList.push(i):(this._seiMessageList.push(i),o&&this._smallSeiMessageList.push(i)),null==(t=this.core.room.scriptTransformWorker)||t.postMessage({type:"sei",data:i,isMain:!r.toSubStream,small:o})}},{key:"getName",value:function(){return e.Name}},{key:"getAlias",value:function(){return"sei"}},{key:"getGroup",value:function(){return"sei"}}])}();FF(v0,"autoStart",!0),FF(v0,"Name","SEI");var _0=v0;function g0(e){var t=e.frame,n=e.onDump;return null==n||n(),t}function y0(e){var t=e.frame,n=e.onDump;return null==n||n(),t}var E0={"play() error: NotAllowedError:":{tips:function(e){return e.includes("main <video>")||e.includes("main <audio>")?"Remote stream auto play is restricted and playback fails":"Local stream playback failure, generally only occurs in Android WeChat devices, no need to handle"},color:"red",class:"red"},"updateStream() try to recover local stream":{tips:"Device acquisition exception, automatic recovery is in progress"},"updateStream() recover local stream successfully":{tips:"Device acquisition exception, automatic recovery is successful"},"updateStream() failed to recover local stream":{tips:"Device acquisition exception, automatic recovery failed"},"main stream - video track is muted":{tips:"Indicates that the received video data is not enough for playback. This is usually caused by network reasons. When enough data is received for playback, the state will change to unmuted."},"main stream - audio track is muted":{tips:"Indicates that the received audio data is not enough for playback. This is usually caused by network reasons. When enough data is received for playback, the state will change to unmuted."},"auxiliary stream - video track is muted":{tips:"Indicates that the received screen sharing data is not enough for playback. This is usually caused by network reasons. When enough data is received for playback, the state will change to unmuted."},"main stream - video track is unable to provide media output":{tips:"Indicates that the received video data is not enough for playback. This is usually caused by network reasons. When enough data is received for playback, the state will change to unmuted."},"main stream - audio track is unable to provide media output":{tips:"Indicates that the received audio data is not enough for playback. This is usually caused by network reasons. When enough data is received for playback, the state will change to unmuted."},"auxiliary stream - video track is unable to provide media output":{tips:"Indicates that the received screen sharing data is not enough for playback. This is usually caused by network reasons. When enough data is received for playback, the state will change to unmuted."},"main stream - video track is unmuted":{tips:"Received enough playback video data"},"main stream - audio track is unmuted":{tips:"Received enough playback audio data"},"auxiliary stream - video track is unmuted":{tips:"Received enough playback screen sharing data"},"main stream - audio player track is ended":{tips:"Remote audio track stopped"},"main stream - video player track is ended":{tips:"Remote video track stopped"},"auxiliary stream - video player track is ended":{tips:"Received enough playback screen sharing data"},"stream - video track is muted":{tips:"Camera capture is paused, usually due to the device being occupied by other applications or the browser media permission being revoked. The client needs to re-capture.",color:"orange"},"stream - video track is unable to provide media output":{tips:"The camera acquisition is paused, usually because the device is occupied by other applications or the browser media permissions are revoked, and the customer needs to re-acquire. SDK v4.11.4+ will automatically resume acquisition without customer intervention",color:"orange"},"video track is unable to provide media output":{tips:function(e){return e.includes("↓")?"The remote track is temporarily unable to decode data, which may be caused by network fluctuations":"The camera acquisition is paused, usually because the device is occupied by other applications or the browser media permissions are revoked. The SDK will automatically resume the acquisition."},color:"orange"},"stream - video player track is ended":{tips:"The camera acquisition stops, usually because the device is unplugged. In this case, the SDK will automatically resume acquisition, and the access side does not need to handle it. It may also be caused by the device being occupied by other applications or the browser media permissions being reclaimed. It is recommended to remind the user to re-acquire on the page."},"video player track is ended":{tips:"The camera acquisition stops, usually because the device is unplugged. In this case, the SDK will automatically resume acquisition, and the access side does not need to handle it. It may also be caused by the device being occupied by other applications or the browser media permissions being reclaimed. It is recommended to remind the user to re-acquire on the page."},"stream - audio track is muted":{tips:"Microphone capture is paused, usually due to the device being occupied by other applications or the browser media permission being revoked. The client needs to re-capture.",color:"orange"},"audio track is unable to provide media output":{tips:function(e){return e.includes("↓")?"The remote track is temporarily unable to decode data, which may be caused by network fluctuations":"Microphone acquisition is paused, usually because the device is occupied by other applications or the browser media permissions are revoked. The SDK will automatically resume the acquisition."},color:"orange"},"stream - audio track is unable to provide media output":{tips:"The microphone acquisition is paused, usually because the device is occupied by other applications or the browser media permissions are revoked. The SDK will automatically resume the acquisition.",color:"orange"},"stream - audio player track is ended":{tips:"The microphone acquisition stops, usually because the device is unplugged. In this case, the SDK will automatically resume acquisition, and the access side does not need to handle it. It may also be caused by the device being occupied by other applications or the browser media permissions being reclaimed. It is recommended to remind the user to re-acquire on the page."},"audio player track is ended":{tips:"The microphone acquisition stops, usually because the device is unplugged. In this case, the SDK will automatically resume acquisition, and the access side does not need to handle it. It may also be caused by the device being occupied by other applications or the browser media permissions being reclaimed. It is recommended to remind the user to re-acquire on the page."},"is adding audio track to current published local stream":{tips:"add audio track",color:"orange"},"is removing audio track from current published local stream":{tips:"remove audio track",color:"orange"},"is removing video track from current published local stream":{tips:"remove video track",color:"orange"},"is adding video track to current published local stream":{tips:"add video track",color:"orange"},"is replacing audio track to current published local main stream":{tips:"replace audio track",color:"orange"},"is replacing video track to current published local main stream":{tips:"replace video track",color:"orange"},"downlink network quality change":{tips:"Downstream network quality change: 1: excellent, 2: good, 3: average, 4: poor, 5: extremely poor"},"uplink network quality change":{tips:"Upstream network quality change: 1: excellent, 2: good, 3: average, 4: poor, 5: extremely poor"},"localStream mute video":{tips:"mute upstream video stream",color:"orange"},"localStream unmute video":{tips:"unmute upstream video stream",color:"orange"},"localStream mute audio":{tips:"mute upstream audio stream",color:"orange"},"localStream unmute audio":{tips:"unmute upstream audio stream",color:"orange"},"black detected":{tips:"Detect black screen, which means fps = 0. It is usually caused by network, and the network will be recovered after a while. If the network is normal but has not been restored, it is an abnormal situation."},'main stream start to play with options: {"muted":true}':{tips:"Play the remote stream in silent mode. Generally, the remote stream does not need to be played in silent mode. You need to confirm whether the parameters passed in the client stream.play API call are correct.",color:"orange"},"main stream - audio player is starting playing":{tips:"Remote stream audio playback success",color:"#0dd90d",class:"success"},"main stream - video player is starting playing":{tips:"Remote stream video playback success",color:"#0dd90d",class:"success"},"video player is playing":{tips:"Local video playback success",color:"#0dd90d",class:"success"},"audio player is playing":{tips:"Local audio playback success",color:"#0dd90d",class:"success"},"stream - video player is starting playing":{tips:"Local video playback success",color:"#0dd90d",class:"success"},"stream - audio player is starting playing":{tips:"Local audio playback success",color:"#0dd90d",class:"success"},"switch camera success":{tips:"Switch camera success",color:"#0dd90d",class:"success"},"switch microphone success":{tips:"Switch microphone success",color:"#0dd90d",class:"success"},gotStream:{tips:"Local stream capture success"},"local stream is published successfully":{tips:"Publish success",color:"#0dd90d",class:"success"},"encoderImplementation change to OpenH264":{tips:"Use software encoding"},"encoderImplementation change to ExternalEncoder":{tips:"Use hardware encoding"},"getUserMedia with constraints":{tips:"Start media (camera/microphone) capture"},"getDisplayMedia with constraints":{tips:"Start screen sharing capture"},"client-banned":{tips:"Kicked out of the room",color:"red",class:"red",textColor:"#fff"},user_timeout:{tips:"The backend is too long without receiving SDK heartbeat, which is usually caused by the JS thread being blocked for a long time. If the reproduction probability is high, the application browser Performance tool analyzes where the JS thread is blocked.",color:"red",class:"red",textColor:"#fff"},"schedule failed":{tips:"Signaling request failed, does not affect the normal room entry process, SDK will connect to the default signaling domain."},"updateStream() video flag is true, but no camera detected, set video to false":{tips:"When trying to resume camera acquisition, the camera acquisition is not resumed because it is detected that there is no camera.",color:"orange",class:"orange",textColor:"#fff"},"qualityLimitationReason change to bandwidth":{tips:"bandwidth estimation is not enough to limit the quality of the encoding, which may cause the code rate, frame rate, and resolution to be lowered.",color:"orange",class:"orange",textColor:"#fff"},"qualityLimitationReason change to cpu":{tips:"cpu load is too high to limit the quality of the encoding, which may cause the code rate, frame rate, and resolution to be lowered.",color:"orange",class:"orange",textColor:"#fff"},"visibility change: hidden":{tips:"User page switched to backend, in mobile devices, this will cause the device to pause the capture, and it will be restored when the user switches backend to the frontend.",color:"orange",class:"orange",textColor:"#fff"},"visibility change: visible":{tips:"User page switched to frontend",color:"orange",class:"orange",textColor:"#fff"},"main stream - audio player is paused":{tips:"The remote stream audio playback is paused, which usually has two possibilities:\n 1. The business side passes in the div tag container for playing audio and video to be removed by the business side from the DOM.\n 2. If the user is in Chrome 70 and below, when the div container is moved, the playback will be paused.",color:"orange",class:"orange",textColor:"#fff"},"main stream - video player is paused":{tips:"The remote stream video playback is paused, which usually has two possibilities:\n 1. The business side passes in the div tag container for playing audio and video to be removed by the business side from the DOM.\n 2. If the user is in Chrome 70 and below, when the div container is moved, the playback will be paused.",color:"orange",class:"orange",textColor:"#fff"},'"displaySurface":"window"':{tips:"Screen sharing captures the application window",color:"blue",class:"blue",textColor:"#fff"},'"displaySurface":"monitor"':{tips:"Screen sharing captures the entire screen",color:"blue",class:"blue",textColor:"#fff"},'"displaySurface":"browser"':{tips:"Screen sharing captures a certain tab page",color:"blue",class:"blue",textColor:"#fff"},updateMediaSettings:{tips:"The resolution and frame rate below are the actual resolution and frame rate captured",color:"blue",class:"blue",textColor:"#fff"},"main stream start to play with":{tips:"Call remoteStream.play interface",color:"blue",class:"blue",textColor:"#fff"},"stream start to play with":{tips:"Call localStream.play interface",color:"blue",class:"blue",textColor:"#fff"},"main setAudioVolume to 0":{tips:"Business side calls remoteStream.setAudioVolume(0) interface to set the playback volume to 0, which will cause the playback to be silent",color:"orange",class:"orange",textColor:"#fff"},"screen sharing was stopped because the video track is ended":{tips:"Screen sharing capture stopped, possible reasons: user clicks the stop button, the window/page shared by the user is closed, etc.",color:"orange",class:"orange",textColor:"#fff"},"Join() => joining room":{tips:"Call client.join interface",color:"blue",class:"blue",textColor:"#fff"},"publish() => publishing local stream":{tips:"Call client.publish interface",color:"blue",class:"blue",textColor:"#fff"},"subscribe() => subscribe to":{tips:"Call client.subscribe interface",color:"blue",class:"blue",textColor:"#fff"},"switchRole() => switch role":{tips:"Call client.switchRole interface",color:"blue",class:"blue",textColor:"#fff"}};["enterRoom","exitRoom","switchRole","destroy","startLocalAudio","updateLocalAudio","stopLocalAudio","startLocalVideo","updateLocalVideo","stopLocalVideo","startScreenShare","updateScreenShare","stopScreenShare","startRemoteVideo","updateRemoteVideo","stopRemoteVideo","muteRemoteAudio","setRemoteAudioVolume"].forEach((function(e){E0["".concat(e,"()")]={tips:"Call trtc.".concat(e),color:"blue",class:"blue",textColor:"#fff"}}));var T0,k0=0,S0=function(){function e(t){i(this,e),this.core=t,FF(this,"_core"),FF(this,"log"),FF(this,"dumpLocalVideoMap",{}),FF(this,"dumpRemoteVideoMap",{}),FF(this,"dialog"),this._core=t,this.log=t.log.createChild({id:"".concat(this.getAlias()).concat(++k0)}),this.log.info("created")}return s(e,[{key:"getName",value:function(){return e.Name}},{key:"getAlias",value:function(){return"dm"}},{key:"getGroup",value:function(){return"dm"}},{key:"getValidateRule",value:function(e){switch(e){case"start":return{name:"StartDebugOptions",required:!1};case"update":return{name:"UpdateDebugOptions",required:!1};case"stop":return{name:"StopDebugOptions",required:!1}}}},{key:"start",value:function(){return HF(this,null,p().mark((function e(){var t;return p().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(e.t0=!new URLSearchParams(location.search).has("trtcDebug")&&"true"!==(null==(t=window.sessionStorage)?void 0:t.getItem("TRTC_ENABLE_DEBUG_PLUGIN")),e.t0){e.next=5;break}return e.next=4,this.openDebugDiaLog();case 4:this.addVideoProcessor();case 5:case"end":return e.stop()}}),e,this)})))}},{key:"update",value:function(){}},{key:"stop",value:function(){this.closeDebugDiaLog(),this.removeVideoProcessor()}},{key:"destroy",value:function(){this.stop()}},{key:"openDebugDiaLog",value:function(){return HF(this,null,p().mark((function e(){var t,n,r;return p().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(e.prev=0,!T0){e.next=6;break}return e.next=4,T0;case 4:e.next=11;break;case 6:return n=Date.now(),r=new URLSearchParams(location.search).get("trtcDebugDialogPath")||(null==(t=window.sessionStorage)?void 0:t.getItem("TRTC_DEBUG_DIALOG_PATH"))||"https://unpkg.com/".concat("trtc-sdk-v5","@").concat(uB,"/assets/debug-dialog.js"),T0=this.loadScript(r),e.next=10,T0;case 10:this.log.info("download debug dialog script cost: ".concat(Date.now()-n,"ms"));case 11:this.dialog=new TRTCDebugDialog(this._core,this.log,this.dumpLocalVideoMap,this.dumpRemoteVideoMap),this._core.kvStatManager.addSuccessEvent({key:592705}),e.next=17;break;case 14:e.prev=14,e.t0=e.catch(0),this._core.kvStatManager.addFailedEvent({key:592705}),this.log.error("load debug dialog script failed: ",JSON.stringify(e.t0));case 17:case"end":return e.stop()}}),e,this,[[0,14]])})))}},{key:"closeDebugDiaLog",value:function(){var e;null==(e=this.dialog)||e.closeDialog(),this.dialog=null}},{key:"addVideoProcessor",value:function(){this._core.room.videoManager.addEncodeProcessor({processor:this._core.rtcDectection.IS_INSERTABLE_STREAM_SUPPORTED?this.encodeVideo.bind(this):g0,type:1}),this._core.room.videoManager.addDecodeProcessor({processor:this._core.rtcDectection.IS_INSERTABLE_STREAM_SUPPORTED?this.decodeVideo.bind(this):y0,type:1})}},{key:"removeVideoProcessor",value:function(){this._core.room.videoManager.removeEncodeProcessor({type:1}),this._core.room.videoManager.removeDecodeProcessor({type:1})}},{key:"encodeVideo",value:function(e){var t=this,n=e.frame,r=e.mediaType;return g0({frame:n,onDump:function(){if(r){var e=2===r?"sub":"main",i=t.dumpLocalVideoMap[e];i&&(i.data.push(n.data),i.duration>0&&Date.now()-i.startTimestamp>1e3*i.duration&&i.onDumpEnd())}}})}},{key:"decodeVideo",value:function(e){var t=this,n=e.frame,r=e.track;return y0({frame:n,onDump:function(){if(r){var e=t.dumpRemoteVideoMap["".concat(r.userId,"-").concat(r.streamType)];e&&(e.data.push(n.data),e.duration>0&&Date.now()-e.startTimestamp>1e3*e.duration&&e.onDumpEnd())}}})}},{key:"loadScript",value:function(e){var t=this;return new Promise((function(n,r){t.log.info("loading debug dialog from ".concat(e));var i=document.createElement("script");i.type="text/javascript",i.onload=n,i.onerror=r,i.crossOrigin="anonymous",i.src=e,document.head.append?document.head.append(i):document.getElementsByTagName("head")[0].appendChild(i)}))}}])}();FF(S0,"Name","Debug"),FF(S0,"autoStart",!0),UF([Oz({settings:{timeout:3e3,retries:3},onError:function(e,t,n){var r;null!=(r=null==e?void 0:e.message)&&r.includes("timeout")?t():n(e)}})],S0.prototype,"loadScript",1);var I0=S0,b0=function(e){switch(e){case"webCodecs":return 504703;case"wasm":return 504704}throw new Error("decoder type not supported")},A0=function(){return s((function e(t,n,r){var o=this;i(this,e),FF(this,"trackDoneOB"),FF(this,"startOB"),FF(this,"stopOB"),FF(this,"inputFrameCount",0),FF(this,"decodedFrameCount",0),FF(this,"type","auto"),FF(this,"config"),FF(this,"decoder"),FF(this,"_decodeSink");var a=t.kvStatManager;t.trtc,this.config=r.config,this.trackDoneOB=SX(n,gz.INIT),this.stopOB=fX(this.trackDoneOB),this.startOB=fX(),"auto"===r.type?this.type="webCodecs":this.type=r.type;var s=fX();GY(this.startOB,oX(0),VQ((function(e){var t=o.pipe(n);return s.next("STARTING"),n.log.info("decoder type: ".concat(o.type)),GY(t,YX(o.stopOB),l$((function(){}),(function(t){n.log.error(t),a.addFailedEvent({key:b0(o.type),error:t}),e>4?o.startOB.error(t):o.startOB.next(e+1)}))),GY(t,zX(1),s$(MX))})),YX(this.stopOB),l$((function(){n.player.setOutput(),s.next("STARTED")}),(function(e){s.next("FAILED")}),(function(){a.addSuccessEvent({key:b0(o.type)}),a.addSuccessEvent({key:504702})})))}),[{key:"mock",value:function(e){this._decodeSink?this._decodeSink.error(e):this.startOB.next(0)}},{key:"close",value:function(e){this.stopOB.next(e)}},{key:"pipe",value:function(e){var t=this;return QY()((function(n){return HF(t,null,p().mark((function t(){var r,i=this;return p().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:this._decodeSink=n,n.defer((function(){var e;null==(e=i.decoder)||e.close()})),r=this.type,t.prev=2,t.t0=r,t.next="webCodecs"===t.t0?6:"wasm"===t.t0?8:9;break;case 6:return this.decoder=new AudioDecoder({error:function(t){e.log.error(t),n.error(4)},output:function(t){i.decodedFrameCount++,n.next(t),e.player.write(t)}}),t.abrupt("break",9);case 8:return t.abrupt("break",9);case 9:this.decoder.configure(this.config),t.next=15;break;case 12:t.prev=12,t.t1=t.catch(2),e.log.error(t.t1),n.error("webCodecs"===r?2:6);case 15:case"end":return t.stop()}}),t,this,[[2,12]])})))}))}},{key:"decodeFrame",value:function(e){var t;this.inputFrameCount++,"configured"===(null==(t=this.decoder)?void 0:t.state)&&this.decoder.decode(new EncodedAudioChunk({data:e.data,timestamp:e.timestamp,type:"key"}))}}])}(),R0={type:"object"},C0=function(){function e(t){i(this,e),this.core=t,FF(this,"log"),FF(this,"contextMap",new Map),FF(this,"decodeProcessorMap",new WeakMap),this.log=t.log.createChild({id:"".concat(this.getAlias())})}return s(e,[{key:"getAlias",value:function(){return e.Name}},{key:"getGroup",value:function(e){return e.track.userId+e.track.streamType}},{key:"getName",value:function(){return e.Name}},{key:"getValidateRule",value:function(e){return R0}},{key:"start",value:function(e){var t=this,n=e.track;this.decodeProcessorMap.set(n,this.decode(e)),this.core.room.audioManager.addDecodeProcessor({processor:function(e){var n=e.frame,r=e.track;return t.decodeProcessorMap.has(r)?t.decodeProcessorMap.get(r)({frame:n,track:r}):n},type:3})}},{key:"decode",value:function(e){var t=this;return function(n){var r=n.frame,i=n.track;if(i!==e.track)return r;if(t.contextMap.has(i))return t.contextMap.get(i).decodeFrame(r);var o=new A0(t.core,i,e);return GY(o.trackDoneOB,zX(1),l$((function(){t.core.clearStarted(t,t.getGroup(e)),t.stop({track:i})}))),t.contextMap.set(i,o),o.decodeFrame(r)}}},{key:"stop",value:function(e){var t=e.track,n=this.contextMap.get(t);n&&(n.close("stop"),this.contextMap.delete(t),0===this.contextMap.size&&this.core.room.audioManager.removeDecodeProcessor({type:3}))}},{key:"update",value:function(e){var t=this.contextMap.get(e.track);if(t){if("mock"===e.type)return void t.mock(10);t.close("update"),this.contextMap.set(e.track,new A0(this.core,e.track,e))}}}])}();FF(C0,"Name","TRTCAudioDecoder");var w0=C0,D0=0,N0=new Set,x0=null;lB("5.10.1-beta.8"),QW.checkStorage(),az();var O0={RtcError:Q$,ErrorCode:K$,ErrorCodeDictionary:z$},P0=function(e){function t(e,n){var o;return i(this,t),o=r(this,t),FF(o,"_room"),FF(o,"_eventListened",new Set),FF(o,"_localVideoTrack",null),FF(o,"_localAudioTrack",null),FF(o,"_localScreenTrack",null),FF(o,"_localScreenAudioTrack",null),FF(o,"_localVideoConfig",null),FF(o,"_localScreenConfig",null),FF(o,"_localAudioConfig",null),FF(o,"_remoteVideoConfigMap",new Map),FF(o,"_remoteAudioConfigMap",new Map),FF(o,"_remoteAudioVolumeMap",new Map),FF(o,"_remoteAudioMuteMap",new Map),FF(o,"_mediaTrackMap",new WeakMap),FF(o,"_log",qW.createLogger({id:"t".concat(++D0)})),FF(o,"_plugins",new Map),FF(o,"_networkQuality",null),FF(o,"_speakerId"),FF(o,"_getPCMAbortCtrl"),o._room=new e(xF({logger:o._log,frameWorkType:t.frameWorkType},n)),o._room.videoDecodeFallbackType=n.videoDecodeFallback,o._log.info("create() ".concat(JSON.stringify(n,(function(e,t){return"plugins"===e?t.map((function(e){return e.Name})):t})))),Object.defineProperties(o,{dumpAudio:{enumerable:!1,value:function(e){return this._room.audioManager.dump(e)}}}),n.plugins&&n.plugins.forEach((function(e){o._use(e,n.assetsPath)})),o._use(n0,n.assetsPath),o._use(o0,n.assetsPath),o._use(w0,n.assetsPath||SB),o._use(I0),n.enableSEI&&$K&&o._use(_0),o._room.on("audio-volume",(function(e){!e.find((function(e){return""===e.userId}))&&o._localAudioTrack&&e.push({userId:"",volume:Math.floor(100*o._localAudioTrack.getAudioLevel())}),1===n.volumeType&&e.forEach((function(e){var t,n=""===e.userId?o._localAudioTrack:null==(t=o.room.remotePublishedUserMap.get(e.userId))?void 0:t.remoteAudioTrack;n&&(e.volume=n.dbVolume)})),o.emit(gZ.AUDIO_VOLUME,{result:e.sort((function(e,t){return t.volume-e.volume}))})})),o._room.videoManager.on("error",(function(e){o._log.error(new Q$({code:K$.OPERATION_FAILED,extraCode:5504,message:e.message,originError:e}))})),o._listenEvents(),o._initActiveSpeaker(),function(e,t){var n=e.emit;e.emit=function(){for(var r=arguments.length,i=new Array(r),o=0;o<r;o++)i[o]=arguments[o];try{return n.apply(e,i)}catch(iJ){var a=rK({key:ZJ.CATCH_HANDLER_ERROR,data:{name:t,event:i[0]},addDocLink:!1});return qW.warn("".concat(a,"\n\n").concat(iJ.stack)),!1}}}(o,"trtc"),o}return d(t,e),s(t,[{key:"room",get:function(){return this._room}},{key:"_listenEvents",value:function(){var e=this;Cz(this,this._room).add("peer-join",(function(t){var n=t.userId;e.emit(gZ.REMOTE_USER_ENTER,{userId:n})})).add("peer-leave",(function(t){e.emit(gZ.REMOTE_USER_EXIT,{userId:t}),e._remoteAudioVolumeMap.delete(t)})).add("banned",(function(t){e._exitRoom().finally((function(){e.emit(gZ.KICKED_OUT,{reason:t.reason})}))})).add("error",(function(t){e._exitRoom().finally((function(){e.emit(gZ.ERROR,Q$.convertFrom(t))}))})).add("signal-connection-state-changed",(function(t){e.emit(gZ.CONNECTION_STATE_CHANGED,t)})).add("network-quality",(function(t){e._networkQuality=t;var n=OF(xF({},t),{uplinkRTT:Math.min(t.uplinkRTT,FH),downlinkRTT:Math.min(t.downlinkRTT,FH)});e.emit(gZ.NETWORK_QUALITY,n)})).add("remote-published",(function(t){[t.remoteAudioTrack,t.remoteVideoTrack,t.remoteAuxiliaryTrack].forEach((function(n){Cz(n,n).add("player-state-changed",(function(r){var i=OF(xF({},r),{userId:t.userId});n.kind===UB.VIDEO&&(i.streamType=EZ(n.streamType)),e.emit(n.kind===UB.AUDIO?gZ.AUDIO_PLAY_STATE_CHANGED:gZ.VIDEO_PLAY_STATE_CHANGED,i)})).add("error",(function(t){t.getCode()===ZF.PLAY_NOT_ALLOWED&&e.emit(gZ.AUTOPLAY_FAILED,{userId:n.userId,resume:function(){return n.player.resume()}})}))}))})).add("remote-unpublished",(function(e){[e.remoteAudioTrack,e.remoteVideoTrack,e.remoteAuxiliaryTrack].forEach((function(e){wz(e)}))})).add("remote-publish-state-changed",(function(t){var n=t.prevMuteState,r=t.muteState,i=r.userId,o=n.audioAvailable,a=n.videoAvailable,s=r.audioAvailable,c=r.videoAvailable;s||e._remoteAudioConfigMap.delete(i),c||e._remoteVideoConfigMap.delete("".concat(i,"_main")),r.hasAuxiliary||e._remoteVideoConfigMap.delete("".concat(i,"_sub")),a!==c&&(c?e._onVideoAvailable({userId:i,streamType:"main"}):e._onVideoUnavailable({userId:i,streamType:"main"}),e.emit(c?gZ.REMOTE_VIDEO_AVAILABLE:gZ.REMOTE_VIDEO_UNAVAILABLE,{userId:i,streamType:"main"})),o!==s&&(s?e._onAudioAvailable({userId:i}):e._onAudioUnavailable({userId:i,muteState:r}),e.emit(s?gZ.REMOTE_AUDIO_AVAILABLE:gZ.REMOTE_AUDIO_UNAVAILABLE,{userId:i})),n.hasAuxiliary!==r.hasAuxiliary&&(r.hasAuxiliary?e._onVideoAvailable({userId:i,streamType:"sub"}):e._onVideoUnavailable({userId:i,streamType:"sub"}),e.emit(r.hasAuxiliary?gZ.REMOTE_VIDEO_AVAILABLE:gZ.REMOTE_VIDEO_UNAVAILABLE,{userId:i,streamType:"sub"}))})).add("sei-message",(function(t){e.emit(gZ.SEI_MESSAGE,OF(xF({},t),{streamType:EZ(t.streamType)}))})).add("firewall-restriction",(function(){e.emit(gZ.ERROR,new Q$({code:K$.OPERATION_FAILED,extraCode:5501}))})).add("heartbeat-report",(function(t){var n,r,i,o,a,s,c,u={2:"big",3:"small",7:"sub"},l={rtt:Math.min(t.msg_up_stream_info.msg_network_status.uint32_rtt||(null==(n=t.msg_down_stream_info[0])?void 0:n.msg_network_status.uint32_rtt)||(null==(r=e._networkQuality)?void 0:r.uplinkRTT)||(null==(i=e._networkQuality)?void 0:i.downlinkRTT)||0,FH),upLoss:(null==(o=e._networkQuality)?void 0:o.uplinkLoss)||0,downLoss:(null==(a=e._networkQuality)?void 0:a.downlinkLoss)||0,bytesSent:t.bytes_sent||0,bytesReceived:t.bytes_received||0,localStatistics:{audio:{bitrate:((null==(s=t.msg_up_stream_info.msg_audio_status)?void 0:s.uint32_audio_codec_bitrate)||0)/1e3,audioLevel:((null==(c=t.msg_up_stream_info.msg_audio_status)?void 0:c.uint32_audio_level)||0)/GJ},video:t.msg_up_stream_info.msg_video_status.filter((function(e){return u[e.uint32_video_stream_type]})).map((function(e){return{bitrate:(e.uint32_video_codec_bitrate||0)/1e3,width:e.uint32_video_width,height:e.uint32_video_height,frameRate:e.uint32_video_enc_fps,videoType:u[e.uint32_video_stream_type]}}))},remoteStatistics:t.msg_down_stream_info.map((function(e){return{userId:e.msg_user_info.str_identifier,audio:{bitrate:(e.msg_audio_status.uint32_audio_codec_bitrate||0)/1e3,audioLevel:(e.msg_audio_status.uint32_audio_level||0)/GJ},video:e.msg_video_status.map((function(e){return{bitrate:(e.uint32_video_codec_bitrate||0)/1e3,width:e.uint32_video_width,height:e.uint32_video_height,frameRate:e.uint32_video_dec_fps,videoType:u[e.uint32_video_stream_type]}}))}}))};e.emit(gZ.STATISTICS,l)})).add("custom-message",(function(t){e.emit(gZ.CUSTOM_MESSAGE,t)})).add("layerData",(function(t){return e.emit(gZ.LAYER_DATA,t)})).add("first-video-frame",(function(t){e.emit(gZ.FIRST_VIDEO_FRAME,OF(xF({},t),{streamType:EZ(t.streamType)}))})),Cz(this,wq).add("audioInputAdded",(function(t){e.emit(gZ.DEVICE_CHANGED,{type:"microphone",action:"add",device:t})})).add("audioInputRemoved",(function(t){e.emit(gZ.DEVICE_CHANGED,{type:"microphone",action:"remove",device:t})})).add("videoInputAdded",(function(t){e.emit(gZ.DEVICE_CHANGED,{type:"camera",action:"add",device:t})})).add("videoInputRemoved",(function(t){e.emit(gZ.DEVICE_CHANGED,{type:"camera",action:"remove",device:t})})).add("audioOutputAdded",(function(t){return HF(e,null,p().mark((function e(){var n;return p().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.emit(gZ.DEVICE_CHANGED,{type:"speaker",action:"add",device:t}),!x0||x0.deviceId!==xH){e.next=5;break}return e.next=3,Lq();case 3:n=e.sent.find((function(e){return e.deviceId===xH})),n&&x0.groupId!==n.groupId&&(x0=n,this.emit(gZ.DEVICE_CHANGED,{type:"speaker",action:"active",device:n}));case 5:case"end":return e.stop()}}),e,this)})))})).add("audioOutputRemoved",(function(t){return HF(e,null,p().mark((function e(){var n,r,i;return p().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.emit(gZ.DEVICE_CHANGED,{type:"speaker",action:"remove",device:t}),e.next=3,Lq();case 3:if((n=e.sent[0])&&x0&&x0.groupId!==n.groupId){e.next=6;break}return e.abrupt("return");case 6:r=x0.deviceId===t.deviceId,i=x0.deviceId===xH&&x0.deviceId===n.deviceId,(r||i)&&(x0=n,this.emit(gZ.DEVICE_CHANGED,{type:"speaker",action:"active",device:n}));case 8:case"end":return e.stop()}}),e,this)})))}))}},{key:"use",value:function(e){var t,n;"plugin"in e?(t=e.plugin,n=e.assetsPath):t=e,this._use(t,n||SB)}},{key:"_use",value:function(e,n){if(this._plugins.get(e.Name))this._log.warn("duplicate install plugin",e.Name);else{var r=new e(jZ.call(this,{TRTC:t,room:this._room,errorModule:O0,assetsPath:n}));this._plugins.set(e.Name,r),e.autoStart&&this.startPlugin(e.Name)}}},{key:"enterRoom",value:function(e){return HF(this,null,p().mark((function n(){var r,i,o,a,s,c,u,l,d,h,f;return p().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return o=e.scene,a=void 0===o?"rtc":o,s=e.enableAutoPlayDialog,c=void 0===s||s,u=e.autoReceiveAudio,l=void 0===u||u,d=e.autoReceiveVideo,h=void 0!==d&&d,e.proxy&&(this._room.setProxyServer(e.proxy),!sj(e.proxy)&&e.proxy.turnServer&&(null==(i=(r=this._room).setTurnServer)||i.call(r,e.proxy.turnServer,e.proxy.iceTransportPolicy))),this._room.enableAutoPlayDialog=c,this._room.autoReceiveAudio=l,this._room.autoReceiveVideo=h,uj(e.preferHW)&&(this._room.preferHW=e.preferHW),e.playoutDelay&&(this._room.playoutDelay=e.playoutDelay),e.jitterBufferDelay&&(this._room.jitterBufferDelay=e.jitterBufferDelay),f={sdkAppId:e.sdkAppId,userId:e.userId,userSig:e.userSig,privateMapKey:e.privateMapKey||null,latencyLevel:e.latencyLevel,role:"audience"===e.role?21:20,roomId:e.roomId||0,strRoomId:e.strRoomId||"",businessInfo:e.businessInfo||null,streamId:null,userDefineRecordId:e.userDefineRecordId||null,frameWorkType:e.frameWorkType,component:e.component,language:e.language,priority:e.priority,useVp8:e.useVp8,keepAlive:e.keepAlive},e.strRoomId&&!e.roomId?this._room.useStringRoomId=!0:this._room.useStringRoomId=!1,n.next=6,this._room.join(f,a,t.frameWorkType);case 6:this._checkTrackToPublish(),c0.start();case 8:case"end":return n.stop()}}),n,this)})))}},{key:"exitRoom",value:function(){return HF(this,null,p().mark((function e(){return p().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._exitRoom();case 2:return e.abrupt("return",e.sent);case 3:case"end":return e.stop()}}),e,this)})))}},{key:"switchRole",value:function(e,t){return HF(this,null,p().mark((function n(){return p().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return null!=t&&t.privateMapKey&&(this._room.privateMapKey=t.privateMapKey),null!=t&&t.latencyLevel&&(this._room.latencyLevel=t.latencyLevel),n.next=4,this._room.switchRole(e);case 4:"anchor"===e&&this._checkTrackToPublish();case 5:case"end":return n.stop()}}),n,this)})))}},{key:"destroy",value:function(){wz(this),this.removeAllListeners(),this._room.destroy(),N0.delete(this),0===N0.size&&c0.destroy(),this._localAudioTrack&&this.stopLocalAudio(),this._localVideoTrack&&this.stopLocalVideo(),this._localScreenTrack&&this.stopScreenShare(),this._plugins.forEach((function(e){var t;return null==(t=e.destroy)?void 0:t.call(e)})),this._plugins.clear(),HW.off("102",this._onLocalTrackCaptured,this)}},{key:"startLocalAudio",value:function(){return HF(this,arguments,(function(){var e=this,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{publish:!0};return p().mark((function r(){var i,o,a,s,c,u,l;return p().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if(!e._localAudioTrack){r.next=3;break}return e._log.warn("local audio is already started"),r.abrupt("return");case 3:return i=n.publish,o=void 0===i||i,a=n.mute,s=n.option,c=new vY(e._room.audioManager),u={},l={muted:!0},s&&(aj(s.microphoneId)?aj(s.audioTrack)||(u.customSource=s.audioTrack):u.deviceId=s.microphoneId,s&&cj(s.captureVolume)&&c.setCaptureVolume(s.captureVolume),aj(s.profile)||(sj(s.profile)?MB[s.profile]&&c.setProfile(MB[s.profile]):c.setProfile(s.profile)),cj(s.earMonitorVolume)&&(l.muted=!(s.earMonitorVolume>0),l.volume=s.earMonitorVolume),aj(s.echoCancellation)||(c.profile.echoCancellation=s.echoCancellation),aj(s.noiseSuppression)||(c.profile.noiseSuppression=s.noiseSuppression),aj(s.autoGainControl)||(c.profile.autoGainControl=s.autoGainControl)),c.on("5",(function(t){e.emit(gZ.ERROR,new Q$({code:K$.DEVICE_ERROR,extraCode:5309,messageParams:{error:t}}))})),c.on("2",(function(t){e.emit(gZ.DEVICE_CHANGED,{type:"microphone",action:"active",device:t})})),c.on("4",(function(t){var n;t.error&&(n=Q$.convertFrom(t.error)),e.emit(gZ.PUBLISH_STATE_CHANGED,OF(xF({},t),{error:n}))})),e._listenOutputTrackChanged(c),e._speakerId&&c.setAudioOutput(e._speakerId),r.next=12,c.capture(u);case 12:return aj(a)||c.setMute(a),Cz(c,c).add("player-state-changed",(function(t){e.emit(gZ.AUDIO_PLAY_STATE_CHANGED,OF(xF({},t),{userId:""}))})),e.listeners(gZ.AUDIO_FRAME).length>0&&(e._getPCMAbortCtrl=e._room.audioManager.getPCM((function(n){e.emit(t.EVENT.AUDIO_FRAME,{data:n})}))),e._getPCMAbortCtrl&&c.on("input-media-track-changed",(function(){e._getPCMAbortCtrl&&(e._getPCMAbortCtrl.abort("inputMediaTrackChanged"),e._getPCMAbortCtrl=e._room.audioManager.getPCM((function(n){e.emit(t.EVENT.AUDIO_FRAME,{data:n})})))})),o&&e._room.isJoined&&e._room.publish(c).catch((function(){})),e._localAudioTrack=c,e._localAudioConfig=OF(xF({},n),{publish:o}),r.next=21,e._updateAudioPlayOption({playOption:l,track:c});case 21:case"end":return r.stop()}}),r)}))()}))}},{key:"updateLocalAudio",value:function(e){return HF(this,null,p().mark((function t(){var n,r,i,o;return p().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this._localAudioTrack&&this._localAudioConfig){t.next=2;break}return t.abrupt("return");case 2:if(n=e.publish,r=e.mute,i=e.option,o={},t.t0=i,!t.t0){t.next=18;break}if(!i.microphoneId){t.next=10;break}return t.next=8,this._localAudioTrack.switchDevice(i.microphoneId);case 8:t.next=14;break;case 10:if(t.t1=aj(i.audioTrack),t.t1){t.next=14;break}return t.next=14,this._localAudioTrack.setInputMediaStreamTrack(i.audioTrack);case 14:return aj(i.captureVolume)||this._localAudioTrack.setCaptureVolume(i.captureVolume),aj(i.earMonitorVolume)||(o.muted=!(i.earMonitorVolume>0),o.volume=i.earMonitorVolume),t.next=18,this._localAudioTrack.update3A(i);case 18:return this._room.isJoined&&!aj(n)&&(n&&!this._localAudioConfig.publish&&this._room.publish(this._localAudioTrack).catch((function(){})),this._localAudioConfig.publish&&!n&&this._room.unpublish(this._localAudioTrack).catch((function(){}))),aj(r)||this._localAudioTrack.setMute(r),t.next=22,this._updateAudioPlayOption({playOption:o,track:this._localAudioTrack,prevConfig:this._localAudioConfig});case 22:Rj(this._localAudioConfig,e);case 23:case"end":return t.stop()}}),t,this)})))}},{key:"stopLocalAudio",value:function(){return HF(this,null,p().mark((function e(){return p().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(e.t0=this._localAudioTrack,!e.t0){e.next=13;break}if(e.t1=this._room.isJoined,!e.t1){e.next=6;break}return e.next=6,this._room.unpublish(this._localAudioTrack).catch((function(){}));case 6:this._localAudioTrack.stop(),this._localAudioTrack.close(),this._room.audioManager.removeInput(this._localAudioTrack),wz(this._localAudioTrack),this._localAudioTrack=null,this._localAudioConfig=null,this._getPCMAbortCtrl&&(this._getPCMAbortCtrl.abort("stopLocalAudio"),delete this._getPCMAbortCtrl);case 13:case"end":return e.stop()}}),e,this)})))}},{key:"startLocalVideo",value:function(){return HF(this,arguments,(function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{publish:!0,view:null};return p().mark((function n(){var r,i,o,a,s,c,u,l;return p().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(!e._localVideoTrack){n.next=3;break}return e._log.warn("local video is already started"),n.abrupt("return");case 3:return r=t.view,i=t.publish,o=void 0===i||i,a=t.mute,s=t.option,c=new EY(e._room.videoManager),u={},l={},uj(null==s?void 0:s.avoidCropping)&&(c.avoidCropping=s.avoidCropping),s&&(s.cameraId?u.deviceId=s.cameraId:aj(s.useFrontCamera)?aj(s.videoTrack)||(u.customSource=s.videoTrack):u.facingMode=s.useFrontCamera?UB.FACING_MODE_USER:UB.FACING_MODE_ENVIRONMENT,s.qosPreference&&(u.contentHint=TZ(s.qosPreference)),aj(s.profile)||(sj(s.profile)?LB[s.profile]&&c.setProfile(LB[s.profile]):c.setProfile(s.profile)),aj(s.fillMode)||(l.objectFit=s.fillMode),aj(s.mirror)||(l.mirror=s.mirror),aj(s.small)||(LK()?sj(s.small)?c.small=LB[s.small]:!0===s.small?c.small=LB["120p"]:c.small=s.small:e._log.warn("small stream is not supported"))),c.once("first-video-frame",(function(t){e.emit(gZ.FIRST_VIDEO_FRAME,OF(xF({},t),{streamType:EZ(t.streamType)}))})),c.on("5",(function(t){e.emit(gZ.ERROR,new Q$({code:K$.DEVICE_ERROR,extraCode:5308,messageParams:{error:t}}))})),c.on("2",(function(t){e.emit(gZ.DEVICE_CHANGED,{type:"camera",action:"active",device:t})})),c.on("4",(function(t){var n;t.error&&(n=Q$.convertFrom(t.error)),e.emit(gZ.PUBLISH_STATE_CHANGED,OF(xF({},t),{error:n}))})),e._listenOutputTrackChanged(c),n.next=13,c.capture(u);case 13:if(n.t0=aj(a),n.t0){n.next=17;break}return n.next=17,c.setMute(a);case 17:return Cz(c,c).add("player-state-changed",(function(t){e.emit(gZ.VIDEO_PLAY_STATE_CHANGED,OF(xF({},t),{userId:"",streamType:"main"}))})),o&&e._room.isJoined&&e._room.publish(c).catch((function(){})),e._localVideoTrack=c,e._localVideoConfig=OF(xF({},t),{view:r,publish:o}),n.next=23,e._updateVideoPlayOption({view:r,playOption:l,track:c});case 23:case"end":return n.stop()}}),n)}))()}))}},{key:"updateLocalVideo",value:function(e){return HF(this,null,p().mark((function t(){var n,r,i,o,a,s;return p().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this._localVideoTrack&&this._localVideoConfig){t.next=2;break}return t.abrupt("return");case 2:if(n=e.view,r=e.publish,i=e.mute,o=e.option,a={},!o){t.next=28;break}if(aj(o.profile)||(sj(o.profile)?LB[o.profile]&&this._localVideoTrack.setProfile(LB[o.profile]):this._localVideoTrack.setProfile(o.profile),(!o.cameraId||!this._localVideoTrack.isNeedToSwitchDevice(o.cameraId))&&aj(o.useFrontCamera)&&this._localVideoTrack.applyProfile()),!o.cameraId){t.next=10;break}return t.next=8,this._localVideoTrack.switchDevice(o.cameraId);case 8:t.next=19;break;case 10:if(!aj(o.useFrontCamera)){t.next=17;break}if(t.t0=aj(o.videoTrack),t.t0){t.next=15;break}return t.next=15,this._localVideoTrack.setInputMediaStreamTrack(o.videoTrack);case 15:t.next=19;break;case 17:return t.next=19,this._localVideoTrack.switchDevice(o.useFrontCamera?UB.FACING_MODE_USER:UB.FACING_MODE_ENVIRONMENT);case 19:if(aj(o.fillMode)||(a.objectFit=o.fillMode),aj(o.mirror)||(a.mirror=o.mirror),o.qosPreference&&this._localVideoTrack.mediaTrack&&this._localVideoTrack.setContentHint(TZ(o.qosPreference)),!o.small){t.next=27;break}s=!this._localVideoTrack.small,LK()?(!0===o.small?this._localVideoTrack.small=LB["120p"]:sj(o.small)?this._localVideoTrack.small=LB[o.small]:this._localVideoTrack.small=o.small,this._room.videoManager.update(),s&&this._room.enableSmall(!0)):this._log.warn("small stream is not supported"),t.next=28;break;case 27:!1===o.small&&this._localVideoTrack.small&&(delete this._localVideoTrack.small,this._room.videoManager.update(),this._room.enableSmall(!1));case 28:if(this._room.isJoined&&!aj(r)&&(r&&!this._localVideoConfig.publish&&this._room.publish(this._localVideoTrack).catch((function(){})),this._localVideoConfig.publish&&!r&&this._room.unpublish(this._localVideoTrack).catch((function(){}))),t.t1=aj(i),t.t1){t.next=33;break}return t.next=33,this._localVideoTrack.setMute(i);case 33:return t.next=35,this._updateVideoPlayOption({view:n,playOption:a,track:this._localVideoTrack,prevConfig:this._localVideoConfig});case 35:Rj(this._localVideoConfig,e);case 36:case"end":return t.stop()}}),t,this)})))}},{key:"stopLocalVideo",value:function(){return HF(this,null,p().mark((function e(){return p().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(e.t0=this._localVideoTrack,!e.t0){e.next=11;break}if(e.t1=this._room.isJoined,!e.t1){e.next=6;break}return e.next=6,this._room.unpublish(this._localVideoTrack).catch((function(){}));case 6:this._localVideoTrack.stop(),this._localVideoTrack.close(),wz(this._localVideoTrack),this._localVideoTrack=null,this._localVideoConfig=null;case 11:case"end":return e.stop()}}),e,this)})))}},{key:"startScreenShare",value:function(){return HF(this,arguments,(function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{publish:!0,view:null};return p().mark((function n(){var r,i,o,a,s,c,u,l,d,h,f,m;return p().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(!e._localScreenTrack){n.next=3;break}return e._log.warn("screen share is already started"),n.abrupt("return");case 3:return r=t.view,i=void 0===r?null:r,o=t.publish,a=void 0===o||o,s=t.option,(c=new AY(e._room.videoManager)).on("4",(function(t){var n;t.error&&(n=Q$.convertFrom(t.error)),e.emit(gZ.PUBLISH_STATE_CHANGED,OF(xF({},t),{error:n}))})),c.once("first-video-frame",(function(t){e.emit(gZ.FIRST_VIDEO_FRAME,OF(xF({},t),{streamType:EZ(t.streamType)}))})),e._listenOutputTrackChanged(c),"main"===t.streamType&&(c.mediaType=4),u=null,l={},d={},s&&(aj(s.profile)||(sj(s.profile)?VB[s.profile]&&c.setProfile(VB[s.profile]):c.setProfile(s.profile)),s.systemAudio&&(l.systemAudio=!0,l.echoCancellation=s.echoCancellation,l.noiseSuppression=s.noiseSuppression,l.autoGainControl=s.autoGainControl),aj(s.fillMode)||(d.objectFit=s.fillMode),s.videoTrack&&(l.videoTrack=s.videoTrack),s.audioTrack&&(l.audioTrack=s.audioTrack),s.captureElement&&(l.captureElement=s.captureElement),s.preferDisplaySurface&&(l.preferDisplaySurface=s.preferDisplaySurface),s.qosPreference&&(l.contentHint=TZ(s.qosPreference))),n.next=9,c.capture(l);case 9:if(h=n.sent,c.mediaTrack.addEventListener(UB.ENDED,(function(){e._stopScreenShare(),e.emit(gZ.SCREEN_SHARE_STOPPED)})),n.t0=h.getAudioTracks()[0],!n.t0){n.next=17;break}return u=new CY(e._room.audioManager),n.next=16,u.setInputMediaStreamTrack(h.getAudioTracks()[0]);case 16:e._speakerId&&u.setAudioOutput(e._speakerId);case 17:if(Cz(c,c).add("player-state-changed",(function(t){e.emit(gZ.VIDEO_PLAY_STATE_CHANGED,OF(xF({},t),{userId:"",streamType:"sub"}))})),!a||!e._room.isJoined){n.next=21;break}m=[c],u&&m.push(u),(f=e._room).publish.apply(f,m).catch((function(){}));case 21:return e._localScreenTrack=c,e._localScreenAudioTrack=u,e._localScreenConfig=OF(xF({},t),{view:i,publish:a}),n.next=26,e._updateVideoPlayOption({view:i,playOption:d,track:c});case 26:case"end":return n.stop()}}),n)}))()}))}},{key:"updateScreenShare",value:function(e){return HF(this,null,p().mark((function t(){var n,r,i,o,a;return p().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this._localScreenTrack&&this._localScreenConfig){t.next=2;break}return t.abrupt("return");case 2:return n=e.view,r=e.publish,i=e.option,o={},i&&(aj(i.fillMode)||(o.objectFit=i.fillMode),i.qosPreference)&&(a=TZ(i.qosPreference),this._localScreenTrack.setContentHint(a)),this._room.isJoined&&!aj(r)&&(r&&!this._localScreenConfig.publish&&(this._room.publish(this._localScreenTrack).catch((function(){})),this._localScreenAudioTrack&&this._room.publish(this._localScreenAudioTrack).catch((function(){}))),this._localScreenConfig.publish&&!r&&(this._room.unpublish(this._localScreenTrack).catch((function(){})),this._localScreenAudioTrack&&this._room.unpublish(this._localScreenAudioTrack).catch((function(){})))),t.next=7,this._updateVideoPlayOption({view:n,playOption:o,track:this._localScreenTrack,prevConfig:this._localScreenConfig});case 7:Rj(this._localScreenConfig,e);case 8:case"end":return t.stop()}}),t,this)})))}},{key:"stopScreenShare",value:function(){return HF(this,null,p().mark((function e(){return p().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._stopScreenShare();case 2:return e.abrupt("return",e.sent);case 3:case"end":return e.stop()}}),e,this)})))}},{key:"startRemoteVideo",value:function(e){return HF(this,null,p().mark((function t(){var n,r,i,o,a,s,c,u;return p().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=e.view,r=e.userId,i=e.streamType,o=e.option,a="".concat(r,"_").concat(i),!this._remoteVideoConfigMap.has(a)){t.next=4;break}return this._log.warn("remote video has already started. userId:".concat(r,", streamType:").concat(i)),t.abrupt("return");case 4:if(s=this._room.remotePublishedUserMap.get(r)){t.next=7;break}return t.abrupt("return");case 7:return c={},u="main"===i?s.remoteVideoTrack:s.remoteAuxiliaryTrack,this._listenOutputTrackChanged(u),o&&(aj(o.fillMode)||(c.objectFit=o.fillMode),aj(o.mirror)||(c.mirror=o.mirror),aj(o.poster)||(c.poster=o.poster),c.canvasRender=o.canvasRender,"main"===i&&!aj(o.small)&&(!s.remoteVideoTrack.isSubscribing&&!s.remoteVideoTrack.isSubscribed&&s.remoteVideoTrack.setMediaType(o.small?8:4),this._room.changeType(o.small,u.user))),t.next=12,this._room.subscribe(u);case 12:return t.next=14,this._enableVideoDecodeFallback(u,i);case 14:return t.next=16,this._updateVideoPlayOption({view:n,playOption:c,track:u});case 16:this._emitTrackEvent(u),this._remoteVideoConfigMap.set(a,{config:e}),o&&!aj(o.receiveWhenViewVisible)&&this._observeView({remoteTrack:u,view:n,receiveWhenViewVisible:o.receiveWhenViewVisible,viewRoot:null==o?void 0:o.viewRoot});case 19:case"end":return t.stop()}}),t,this)})))}},{key:"updateRemoteVideo",value:function(e){return HF(this,null,p().mark((function t(){var n,r,i,o,a,s,c,u,l,d,h,f,m,v,_;return p().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(i=e.view,o=e.userId,a=e.streamType,s=e.option,c="".concat(o,"_").concat(a),(u=this._remoteVideoConfigMap.get(c))&&this._room.remotePublishedUserMap.has(o)){t.next=3;break}return t.abrupt("return");case 3:if(l={},s&&(aj(s.fillMode)||(l.objectFit=s.fillMode),aj(s.mirror)||(l.mirror=s.mirror)),d=null,h=this._room.remotePublishedUserMap.get(o),"main"===a&&null!=h&&h.muteState.hasVideo&&(d=h.remoteVideoTrack),"sub"===a&&null!=h&&h.muteState.hasAuxiliary&&(d=h.remoteAuxiliaryTrack),d){t.next=8;break}return t.abrupt("return");case 8:return f=u.config,"main"===a&&s&&!aj(s.small)&&this._room.changeType(s.small,d.user),t.next=12,this._updateVideoPlayOption({view:i,playOption:l,track:d,prevConfig:f});case 12:Rj(f,e),m=aj(null==s?void 0:s.receiveWhenViewVisible)?null==(n=f.option)?void 0:n.receiveWhenViewVisible:s.receiveWhenViewVisible,v=aj(i)?f.view:i,_=aj(null==s?void 0:s.viewRoot)?null==(r=f.option)?void 0:r.viewRoot:s.viewRoot,this._observeView({remoteTrack:d,view:v,receiveWhenViewVisible:m,viewRoot:_});case 15:case"end":return t.stop()}}),t,this)})))}},{key:"stopRemoteVideo",value:function(e){return HF(this,null,p().mark((function t(){return p().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this._stopRemoteVideo(e));case 1:case"end":return t.stop()}}),t,this)})))}},{key:"_stopRemoteVideo",value:function(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];return HF(this,null,p().mark((function n(){var r,i,o,a,s,c,u,l,d;return p().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:r=[],(i=this._room.remotePublishedUserMap.get(e.userId))&&(o=i.muteState,a=i.remoteVideoTrack,s=i.remoteAuxiliaryTrack,"main"===e.streamType&&(a.stop(),o.hasVideo&&r.push(a)),"sub"===e.streamType&&(s.stop(),o.hasAuxiliary&&r.push(s))),c=0,u=r;case 3:if(!(c<u.length)){n.next=13;break}if(l=u[c],n.t0=t,!n.t0){n.next=10;break}return n.next=9,this._room.unsubscribe(l);case 9:this._mediaTrackMap.delete(l.outMediaTrack);case 10:c++,n.next=3;break;case 13:(d=this._remoteVideoConfigMap.get("".concat(e.userId,"_").concat(e.streamType)))&&d.observer&&d.observer.disconnect(),this._remoteVideoConfigMap.delete("".concat(e.userId,"_").concat(e.streamType));case 15:case"end":return n.stop()}}),n,this)})))}},{key:"muteRemoteAudio",value:function(e,t){return HF(this,null,p().mark((function n(){var r,i,o,a;return p().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(this._remoteAudioMuteMap.set(e,t),n.prev=1,"*"!==e){n.next=30;break}if(!t){n.next=8;break}return n.next=6,this._stopRemoteAudio({userId:e});case 6:n.next=28;break;case 8:r=T(this._room.remotePublishedUserMap.values()),i=c(r),n.prev=10,i.s();case 12:if((o=i.n()).done){n.next=20;break}if(a=o.value,n.t0=a.muteState.hasAudio&&!this._remoteAudioConfigMap.has(a.userId),!n.t0){n.next=18;break}return n.next=18,this._startRemoteAudio({userId:a.userId});case 18:n.next=12;break;case 20:n.next=25;break;case 22:n.prev=22,n.t1=n.catch(10),i.e(n.t1);case 25:return n.prev=25,i.f(),n.finish(25);case 28:n.next=39;break;case 30:if(!t){n.next=35;break}return n.next=33,this._stopRemoteAudio({userId:e});case 33:n.next=39;break;case 35:if(n.t2=this._remoteAudioConfigMap.has(e),n.t2){n.next=39;break}return n.next=39,this._startRemoteAudio({userId:e});case 39:n.next=44;break;case 41:throw n.prev=41,n.t3=n.catch(1),this._remoteAudioMuteMap.delete(e),n.t3;case 44:case"end":return n.stop()}}),n,this,[[1,41],[10,22,25,28]])})))}},{key:"setRemoteAudioVolume",value:function(e,t){if("*"===e){var n,r=c(T(this._room.remotePublishedUserMap.values()));try{for(r.s();!(n=r.n()).done;){var i=n.value;this._remoteAudioVolumeMap.set(i.userId,t),i.remoteAudioTrack.isSubscribed&&this._updateAudioPlayOption({playOption:{volume:t},track:i.remoteAudioTrack})}}catch(a){r.e(a)}finally{r.f()}}else if(e){var o=this._room.remotePublishedUserMap.get(e);this._remoteAudioVolumeMap.set(e,t),o&&o.remoteAudioTrack.isSubscribed&&this._updateAudioPlayOption({playOption:{volume:t},track:o.remoteAudioTrack})}}},{key:"startPlugin",value:function(e,t){return HF(this,null,p().mark((function n(){return p().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.abrupt("return",e.start(t));case 1:case"end":return n.stop()}}),n)})))}},{key:"updatePlugin",value:function(e,t){return HF(this,null,p().mark((function n(){return p().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.abrupt("return",e.update(t));case 1:case"end":return n.stop()}}),n)})))}},{key:"stopPlugin",value:function(e,t){return HF(this,null,p().mark((function n(){return p().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.abrupt("return",e.stop(t));case 1:case"end":return n.stop()}}),n)})))}},{key:"enableAudioVolumeEvaluation",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:2e3,t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];this._room.enableAudioVolumeEvaluation(e,t)}},{key:"on",value:function(e,n,r){var i=this;return this.listeners(e).includes(n)||(this._log.debug("on",e),y(t,"on",this,3)([e,n,r]),this._eventListened.add(e),e===t.EVENT.AUDIO_FRAME&&!this._getPCMAbortCtrl&&(this._getPCMAbortCtrl=this._room.audioManager.getPCM((function(e){i.emit(t.EVENT.AUDIO_FRAME,{data:e})})),this._localAudioTrack&&this._localAudioTrack.on("input-media-track-changed",(function(){i._getPCMAbortCtrl&&(i._getPCMAbortCtrl.abort("inputMediaTrackChanged"),i._getPCMAbortCtrl=i._room.audioManager.getPCM((function(e){i.emit(t.EVENT.AUDIO_FRAME,{data:e})})))})))),this}},{key:"emit",value:function(e){for(var n=arguments.length,r=new Array(n>1?n-1:0),i=1;i<n;i++)r[i-1]=arguments[i];try{yZ.has(e)&&this._log.debug("emit ".concat(e," ").concat(JSON.stringify(r)))}catch(iJ){}return y(t,"emit",this,3)([e].concat(r))}},{key:"off",value:function(e,n,r){var i,o;return this._log.debug("off",e),"*"===e?(this._eventListened.clear(),this.removeAllListeners(),null==(i=this._getPCMAbortCtrl)||i.abort("off"),delete this._getPCMAbortCtrl):(y(t,"off",this,3)([e,n,r]),e===t.EVENT.AUDIO_FRAME&&(null==(o=this._getPCMAbortCtrl)||o.abort("off"),delete this._getPCMAbortCtrl)),this}},{key:"getAudioTrack",value:function(){var e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{userId:"",streamType:"main"},n=null,r="main",i=!1;if(sj(t)?e=t:(e=t.userId,i=!0===t.processed,t.streamType&&(r=t.streamType)),e){var o=this._room.remotePublishedUserMap.get(e);o&&(n=o.remoteAudioTrack)}else n="sub"===r?this._localScreenAudioTrack:this._localAudioTrack;return n?i&&n.outMediaTrack&&n.outMediaTrack!==n.mediaTrack?n.outMediaTrack.clone():n.mediaTrack:null}},{key:"getVideoTrack",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{userId:"",streamType:"main"},t=e.userId,n=void 0===t?"":t,r=e.streamType,i=void 0===r?"main":r,o=e.processed,a=void 0!==o&&o,s=null;if(""===n)"main"===i&&this._localVideoTrack&&(s=this._localVideoTrack),"sub"===i&&this._localScreenTrack&&(s=this._localScreenTrack);else{var c=this._room.remotePublishedUserMap.get(n);c&&(s="main"===i?c.remoteVideoTrack:c.remoteAuxiliaryTrack)}return s?a&&s.outMediaTrack&&s.outMediaTrack!==s.mediaTrack?s.outMediaTrack.clone():s.mediaTrack:null}},{key:"getVideoSnapshot",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.userId,n=e.streamType,r=void 0===n?"main":n;if(t){var i=this._room.remotePublishedUserMap.get(t);if("main"===r&&null!=i&&i.muteState.hasVideo)return i.remoteVideoTrack.getVideoFrame();if("sub"===r&&null!=i&&i.muteState.hasAuxiliary)return i.remoteAuxiliaryTrack.getVideoFrame()}else{if("main"===r&&this._localVideoTrack)return this._localVideoTrack.getVideoFrame();if("sub"===r&&this._localScreenTrack)return this._localScreenTrack.getVideoFrame()}return""}},{key:"_setCurrentSpeaker",value:function(e){var t,n;this._speakerId=e,null==(t=this._localAudioTrack)||t.setAudioOutput(e),null==(n=this._localScreenAudioTrack)||n.setAudioOutput(e),this._room.remotePublishedUserMap.forEach((function(t){return t.remoteAudioTrack.setAudioOutput(e)}))}},{key:"setCurrentSpeaker",value:function(e){return HF(this,null,p().mark((function t(){var n=this;return p().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,Lq();case 2:t.sent.forEach((function(t){t.deviceId===e&&(n._setCurrentSpeaker(e),n.emit(gZ.DEVICE_CHANGED,{type:"speaker",action:"active",device:t}),x0=t)})),this._log.warn('the "setCurrentSpeaker" method of the instance will be deprecated in the future, please use "TRTC.setCurrentSpeaker" instead. For more information, please visit: https://web.sdk.qcloud.com/trtc/webrtc/v5/doc/en/TRTC.html#.setCurrentSpeaker');case 4:case"end":return t.stop()}}),t,this)})))}},{key:"_startRemoteAudio",value:function(e){return this._doStartRemoteAudio(e)}},{key:"_doStartRemoteAudio",value:function(e){return HF(this,null,p().mark((function t(){var n,r,i,o,a,s,c=this;return p().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=e.userId,!this._remoteAudioConfigMap.has(n)){t.next=4;break}return this._log.warn("remote audio has already started. userId:".concat(n)),t.abrupt("return");case 4:if(r=this._room.remotePublishedUserMap.get(n)){t.next=7;break}return t.abrupt("return");case 7:return i={},o=r.remoteAudioTrack,this._listenOutputTrackChanged(o),this._speakerId&&o.setAudioOutput(this._speakerId),t.prev=9,a=this._remoteAudioVolumeMap.get(n),s=cj(a)?a:100,i.volume=s,this._remoteAudioConfigMap.set(n,e),t.next=15,this._room.subscribe(o);case 15:return GY(SX(o,"decode-failed"),YX(SX(o,gz.INIT)),l$((function(){c.startPlugin(w0.Name,{track:o,type:"auto",config:{codec:"opus",sampleRate:48e3,numberOfChannels:1}})}))),t.next=18,this._updateAudioPlayOption({playOption:i,track:o});case 18:t.next=23;break;case 20:throw t.prev=20,t.t0=t.catch(9),this._remoteAudioConfigMap.delete(n),t.t0;case 23:this._emitTrackEvent(o);case 24:case"end":return t.stop()}}),t,this,[[9,20]])})))}},{key:"_stopRemoteAudio",value:function(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];return HF(this,null,p().mark((function n(){var r;return p().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(r=this._room.remotePublishedUserMap.get(e.userId),n.t0=r,!n.t0){n.next=9;break}if(r.remoteAudioTrack.stop(),n.t1=r.muteState.hasAudio&&t,!n.t1){n.next=8;break}return n.next=8,this._room.unsubscribe(r.remoteAudioTrack);case 8:this._mediaTrackMap.delete(r.remoteAudioTrack.outMediaTrack);case 9:this._remoteAudioConfigMap.delete("".concat(e.userId));case 10:case"end":return n.stop()}}),n,this)})))}},{key:"_enableVideoDecodeFallback",value:function(e,t){var n,r=this,i=this._room.videoDecodeFallbackType;i&&this._plugins.has("TRTCVideoDecoder")&&(e.log.debug("remote video will fall back when decode failed",e.id),GY(SX(e,"decode-failed"),YX(SX(e,gz.INIT)),h$((function(){r.startPlugin("TRTCVideoDecoder",{type:"auto",renderer:"videoFrame",track:e,config:{codec:"avc1.420028"},fallback:i})})),FQ(SX(e,"decode-downgrade-state-changed")),l$((function(i){n=i.state,r.emit(gZ.VIDEO_DECODE_DOWNGRADE_STATE_CHANGED,OF(xF({},i),{streamType:t,userId:e.userId}))}),(function(t){e.log.error("fallback",t)}),(function(){"STARTED"===n&&e.log.info("fallback complete")}))))}},{key:"_updateVideoPlayOption",value:function(e){return HF(this,arguments,(function(e){var t=e.view,n=e.playOption,r=e.track,i=e.prevConfig;return p().mark((function e(){var o,a;return p().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r.setMirror(n.mirror),!(aj(t)&&i&&i.view)||Sj(n)){e.next=6;break}if(o=wj(i.view),e.t0=o.length>0,!e.t0){e.next=6;break}return e.next=6,r.play(o,n);case 6:if(aj(t)){e.next=14;break}if(!((a=wj(t)).length>0)){e.next=13;break}return e.next=11,r.play(a,n);case 11:e.next=14;break;case 13:r.stop();case 14:case"end":return e.stop()}}),e)}))()}))}},{key:"_updateAudioPlayOption",value:function(e){return HF(this,arguments,(function(e){var t=e.playOption,n=void 0===t?{}:t,r=e.track;return e.prevConfig,p().mark((function e(){return p().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r.isPlayCalled){e.next=8;break}return e.prev=1,e.next=4,r.play(null,n);case 4:e.next=8;break;case 6:e.prev=6,e.t0=e.catch(1);case 8:aj(n.muted)||r.setPlayerMute(n.muted),aj(n.volume)||r.setAudioVolume(n.volume/100);case 9:case"end":return e.stop()}}),e,null,[[1,6]])}))()}))}},{key:"_listenOutputTrackChanged",value:function(e){var t=this;0===e.listeners("output-media-track-changed").length&&e.on("output-media-track-changed",(function(){return t._emitTrackEvent(e,!1)}))}},{key:"_emitTrackEvent",value:function(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],n=e.isRemote?e.userId:"";e.outMediaTrack&&(t&&this._mediaTrackMap.get(e.outMediaTrack)===n||(this._mediaTrackMap.set(e.outMediaTrack,n),this.emit(gZ.TRACK,{userId:n,streamType:EZ(e.streamType),track:e.outMediaTrack,sourceTrack:e.mediaTrack})))}},{key:"_checkTrackToPublish",value:function(){var e,t,n,r,i=[];if(null!=(t=this._localAudioConfig)&&t.publish&&this._localAudioTrack&&i.push(this._localAudioTrack),null!=(n=this._localVideoConfig)&&n.publish&&this._localVideoTrack&&i.push(this._localVideoTrack),null!=(r=this._localScreenConfig)&&r.publish&&(this._localScreenTrack&&i.push(this._localScreenTrack),this._localScreenAudioTrack&&i.push(this._localScreenAudioTrack)),0!==i.length)return(e=this._room).publish.apply(e,i).catch((function(){}))}},{key:"_observeView",value:function(e){var t=this,n=e.remoteTrack,r=e.view,i=e.receiveWhenViewVisible,o=void 0!==i&&i,a=e.viewRoot;if(!aj(r)){var s=this._remoteVideoConfigMap.get("".concat(n.userId,"_").concat(EZ(n.streamType)));if(s){var c=s.observer||void 0;if(null===r||dj(r)&&0===r.length||!o)return null==c||c.disconnect(),void(n.isSubscribed||this._room.subscribe(n).catch((function(){})));var u=s.visibleViewMap||new Map,l=-1;(!c||c.root!==a)&&(null==c||c.disconnect(),u.clear(),c=new IntersectionObserver((function(e){e.forEach((function(e){u.set(e.target,e.isIntersecting)})),clearTimeout(l),l=window.setTimeout((function(){var e=T(u.values()).find((function(e){return e}));n.log.info("view is".concat(e?"":" not"," visible")),e?n.isSubscribed||t._room.subscribe(n).catch((function(){})):n.isSubscribed&&t._room.unsubscribe(n).catch((function(){}))}),200)}),{root:a}));var d=new Set(wj(r));u.forEach((function(e,t){d.has(t)||(c.unobserve(t),u.delete(t))})),d.forEach((function(e){u.set(e,!0),c.observe(e)})),c.takeRecords().forEach((function(e){u.set(e.target,e.isIntersecting)})),s.visibleViewMap=u,s.observer=c}}}},{key:"_exitRoom",value:function(){return HF(this,null,p().mark((function e(){var t=this;return p().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(e.t0=this._room.isJoined,!e.t0){e.next=4;break}return e.next=4,this._room.leave();case 4:new Set([].concat(T(this._remoteAudioConfigMap.keys()),T(this._remoteAudioMuteMap.keys()))).forEach((function(e){t._stopRemoteAudio({userId:e}).catch()})),T(this._remoteVideoConfigMap.keys()).forEach((function(e){var n=e.includes("main")?"main":"sub",r=e.split("_".concat(n))[0];r&&t._stopRemoteVideo({userId:r,streamType:n}).catch()})),this._remoteVideoConfigMap.clear(),this._remoteAudioConfigMap.clear(),this._remoteAudioMuteMap.clear(),this._remoteAudioVolumeMap.clear(),WZ(this),this._room.remotePublishedUserMap.forEach((function(e){wz(e.remoteAudioTrack),wz(e.remoteVideoTrack),wz(e.remoteAuxiliaryTrack)}));case 12:case"end":return e.stop()}}),e,this)})))}},{key:"_stopScreenShare",value:function(){return HF(this,null,p().mark((function e(){var t,n,r;return p().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._localScreenTrack){e.next=7;break}if(!this._room.isJoined){e.next=6;break}return r=[this._localScreenTrack],this._localScreenAudioTrack&&r.push(this._localScreenAudioTrack),e.next=6,null==(t=this._room)?void 0:(n=t).unpublish.apply(n,r).catch((function(){}));case 6:this._localScreenTrack.stop(),this._localScreenTrack.close(),this._localScreenAudioTrack&&(this._localScreenAudioTrack.stop(),this._localScreenAudioTrack.close(),this._room.audioManager.removeInput(this._localScreenAudioTrack),this._localScreenAudioTrack=null),wz(this._localScreenTrack),this._localScreenTrack=null,this._localScreenConfig=null;case 7:case"end":return e.stop()}}),e,this)})))}},{key:"_onLocalTrackCaptured",value:function(e){"audio"===e.track.kind&&(!x0||Dq(x0))&&(this._initActiveSpeaker(),HW.off("102",this._onLocalTrackCaptured,this))}},{key:"_initActiveSpeaker",value:function(){return HF(this,null,p().mark((function e(){var t;return p().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!x0||Dq(x0)){e.next=4;break}this.emit(gZ.DEVICE_CHANGED,{type:"speaker",action:"active",device:x0}),e.next=8;break;case 4:return e.next=6,Lq();case 6:(t=e.sent)[0]&&!Dq(t[0])?(x0=t[0],this.emit(gZ.DEVICE_CHANGED,{type:"speaker",action:"active",device:t[0]})):HW.on("102",this._onLocalTrackCaptured,this);case 8:case"end":return e.stop()}}),e,this)})))}},{key:"_onAudioAvailable",value:function(e){var t=e.userId,n=this._remoteAudioMuteMap.has(t)?this._remoteAudioMuteMap.get(t):this._remoteAudioMuteMap.get("*");(!1===n||this._room.autoReceiveAudio&&!n)&&this._doStartRemoteAudio({userId:t}).catch((function(){}))}},{key:"_onVideoAvailable",value:function(e){var t=this,n=e.userId,r=e.streamType;if(this._room.autoReceiveVideo){var i=this._room.remotePublishedUserMap.get(n);if(i){var o,a="main"===r?i.remoteVideoTrack:i.remoteAuxiliaryTrack,s=[a];this._room.autoReceiveAudio&&i.remoteAudioTrack.isAvailable&&s.push(i.remoteAudioTrack),(o=this._room).subscribe.apply(o,s).then((function(){t._emitTrackEvent(a)})).catch((function(){}))}}}},{key:"_onAudioUnavailable",value:function(e){var t=e.userId,n=e.muteState;n.hasAudio&&n.audioMuted||this._stopRemoteAudio({userId:t},!1).catch((function(){}))}},{key:"_onVideoUnavailable",value:function(e){var t=e.userId,n=e.streamType;this._stopRemoteVideo({userId:t,streamType:n},!1).catch((function(){}))}},{key:"sendSEIMessage",value:function(e,t){var n,r=this._plugins.get("SEI");r&&(r.update({buffer:e,options:OF(xF({seiPayloadType:243},t),{small:!(null==(n=this._localVideoTrack)||!n.small)})}),fK.addCount({key:5e5,useUV:!0}))}},{key:"sendCustomMessage",value:function(e){var t,n;null==(n=(t=this._room).sendCustomMessage)||n.call(t,e),fK.addCount({key:500001,useUV:!0})}}],[{key:"create",value:function(e){}},{key:"_create",value:function(e,n){!function(){var e;W$&&(W$=!1,5!==qW.getLogLevel()&&(console.info("******************************************************************************"),console.info("* TRTC Web SDK"),console.info("* API Document: ".concat(kB,"/en/index.html")),console.info("* Changelog: ".concat(kB,"/en/tutorial-01-info-changelog.html")),console.info("* Report issues: https://github.com/LiteAVSDK/TRTC_Web/issues"),console.info("******************************************************************************")),qW.info("TRTC Web SDK Version:",uB),bW||qW.debug("Build Time:","2025-04-24 16:49:15"),qW.info("UA:",navigator.userAgent),qW.info("URL: ".concat(location.href).concat("IFRAME"===(null==(e=self.frameElement)?void 0:e.tagName)?" in iframe":"")),xW().then((function(e){e&&qW.info(NW)})))}();var r=new t(e,n||{});return N0.add(r),r}},{key:"setLogLevel",value:function(e,t){qW.setLogLevel(e),aj(t)||(t?qW.enableUploadLog():qW.disableUploadLog())}},{key:"isSupported",value:function(){return bK()}},{key:"getCameraList",value:function(){return Oq(!(arguments.length>0&&void 0!==arguments[0])||arguments[0])}},{key:"getMicrophoneList",value:function(){return xq(!(arguments.length>0&&void 0!==arguments[0])||arguments[0])}},{key:"getSpeakerList",value:function(){return Lq(!(arguments.length>0&&void 0!==arguments[0])||arguments[0])}},{key:"setCurrentSpeaker",value:function(e){return HF(this,null,p().mark((function n(){var r,i,o=this;return p().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(!uG||e!==J$.SPEAKER&&e!==J$.HEADSET){n.next=9;break}return n.next=3,t.getMicrophoneList();case 3:if(r=n.sent,i="",r.forEach((function(t){t.label===e&&(i=t.deviceId)})),i){n.next=7;break}return n.abrupt("return");case 7:return N0.forEach((function(e){return HF(o,null,p().mark((function t(){return p().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(t.t0=e._localAudioTrack,!t.t0){t.next=4;break}return t.next=4,e.updateLocalAudio({option:{microphoneId:i}});case 4:case"end":return t.stop()}}),t)})))})),n.abrupt("return");case 9:return n.next=11,Lq();case 11:n.sent.forEach((function(t){t.deviceId===e&&(N0.forEach((function(n){n._setCurrentSpeaker(e),n.emit(gZ.DEVICE_CHANGED,{type:"speaker",action:"active",device:t})})),x0=t)}));case 12:case"end":return n.stop()}}),n)})))}},{key:"_addKVStat",value:function(e){var t=e.type,n=e.key,r=e.value,i=e.base,o=e.useUV,a=e.version;switch(a&&(hK.version=a),t){case"count":hK.addCount({key:n,useUV:o});break;case"enum":hK.addEnum({key:n,value:r,useUV:o});break;case"number":hK.addNumber({key:n,value:r,split:i})}}}])}(QF.EventEmitter);FF(P0,"_loggerManager",qW),FF(P0,"EVENT",gZ),FF(P0,"ERROR_CODE",K$),FF(P0,"TYPE",J$),FF(P0,"frameWorkType",30),UF([YZ({replaceArg:function(e){return{argIndex:0,value:{name:"plugin"in e?e.plugin.Name:e.Name,assetsPath:"assetsPath"in e?null==e?void 0:e.assetsPath:"default"}}}})],P0.prototype,"use",1),UF([JZ(aZ.TRTC.enterRoom),mZ("room",(function(e,t){var n=_(e,1)[0],r=_(t,1)[0];return(n.roomId||n.strRoomId)===(r.roomId||r.strRoomId)&&n.userId===r.userId&&n.sdkAppId===r.sdkAppId})),rY((function(e){return function(t){return this._log.setUserId(t.userId),this._log.setSdkAppId(t.sdkAppId),e.call(this,t)}})),YZ()],P0.prototype,"enterRoom",1),UF([YZ()],P0.prototype,"exitRoom",1),UF([JZ(aZ.TRTC.switchRole),vZ("room",{merge:function(e,t){return t}}),YZ()],P0.prototype,"switchRole",1),UF([YZ()],P0.prototype,"destroy",1),UF([JZ(aZ.TRTC.startLocalAudio),mZ("audio",(function(e,t){var n,r,i=_(e,1)[0],o=_(t,1)[0];return(null==(n=null==i?void 0:i.option)?void 0:n.microphoneId)===(null==(r=null==o?void 0:o.option)?void 0:r.microphoneId)})),YZ()],P0.prototype,"startLocalAudio",1),UF([JZ(aZ.TRTC.updateLocalAudio),vZ("audio",{debounce:{delay:200,getKey:function(){return"".concat(D0,"-localAudio")},isNeedToDebounce:function(e){var t;return!aj(null==(t=e.option)?void 0:t.captureVolume)}}}),YZ()],P0.prototype,"updateLocalAudio",1),UF([_Z("audio"),YZ()],P0.prototype,"stopLocalAudio",1),UF([JZ(aZ.TRTC.startLocalVideo),mZ("video",(function(e,t){var n,r,i=_(e,1)[0],o=_(t,1)[0];return(null==(n=null==i?void 0:i.option)?void 0:n.cameraId)===(null==(r=null==o?void 0:o.option)?void 0:r.cameraId)})),YZ()],P0.prototype,"startLocalVideo",1),UF([JZ(aZ.TRTC.updateLocalVideo),vZ("video"),YZ()],P0.prototype,"updateLocalVideo",1),UF([_Z("video"),YZ()],P0.prototype,"stopLocalVideo",1),UF([JZ(aZ.TRTC.startScreenShare),mZ("screen",(function(){return!0})),YZ()],P0.prototype,"startScreenShare",1),UF([JZ(aZ.TRTC.updateScreenShare),vZ("screen"),YZ()],P0.prototype,"updateScreenShare",1),UF([YZ()],P0.prototype,"stopScreenShare",1),UF([JZ(aZ.TRTC.startRemoteVideo),mZ((function(e){return"v".concat(e.userId).concat(e.streamType)}),(function(){return!0})),YZ({getRemoteId:function(e){return"".concat(e.userId,"_").concat(e.streamType)}})],P0.prototype,"startRemoteVideo",1),UF([JZ(aZ.TRTC.updateRemoteVideo),vZ((function(e){return"v".concat(e.userId).concat(e.streamType)})),YZ({getRemoteId:function(e){return"".concat(e.userId,"_").concat(e.streamType)}})],P0.prototype,"updateRemoteVideo",1),UF([JZ(aZ.TRTC.stopRemoteVideo),rY((function(e){return function(t){return HF(this,null,p().mark((function n(){var r,i=this;return p().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if("*"!==t.userId){n.next=3;break}return r=[],n.abrupt("return",(this._room.remotePublishedUserMap.forEach((function(e){i._remoteVideoConfigMap.has("".concat(e.userId,"_main"))&&r.push(i.stopRemoteVideo({streamType:"main",userId:e.userId}).catch((function(){}))),i._remoteVideoConfigMap.has("".concat(e.userId,"_sub"))&&r.push(i.stopRemoteVideo({streamType:"sub",userId:e.userId}).catch((function(){})))})),Promise.all(r)));case 3:return n.abrupt("return",e.call(this,t));case 4:case"end":return n.stop()}}),n,this)})))}})),YZ({getRemoteId:function(e){return"".concat(e.userId,"_").concat(e.streamType)}})],P0.prototype,"stopRemoteVideo",1),UF([_Z((function(e){return"v".concat(e.userId).concat(e.streamType)}))],P0.prototype,"_stopRemoteVideo",1),UF([JZ.apply(void 0,T(aZ.TRTC.muteRemoteAudio)),YZ({getRemoteId:function(e){return e}})],P0.prototype,"muteRemoteAudio",1),UF([KZ.apply(void 0,T(aZ.TRTC.setRemoteAudioVolume)),function(e,t){return rY((function(n,r){return function(){for(var r=this,i=arguments.length,o=new Array(i),a=0;a<i;a++)o[a]=arguments[a];var s=GZ.get(this);s||(s=new Map,GZ.set(this,s));var c=t.apply(void 0,o),u=s.get(c);if(!u||u<=0){n.apply(this,o);var l=setTimeout((function(){var e;null==(e=GZ.get(r))||e.delete(c)}),e);s.set(c,l)}else{clearTimeout(u);var d=window.setTimeout((function(){var e;n.apply(r,o),null==(e=GZ.get(r))||e.delete(c)}),e);s.set(c,d)}}}))}(200,(function(e){return e})),YZ({getRemoteId:function(e){return e}})],P0.prototype,"setRemoteAudioVolume",1),UF([XZ("start"),tY((function(e){var t;return null==(t=e.afterStart)?void 0:t.call(e)})),mZ((function(e,t){return e.disableRandomCall?null:e.getAlias()+e.getGroup(t)})),YZ({replaceArg:function(e){return{argIndex:0,value:e.getName()}},getKVReportKey:function(e){return cK[e.getName()]},ignoreLog:function(e){return"Debug"===e.getName()}})],P0.prototype,"startPlugin",1),UF([XZ("update"),vZ((function(e,t){return e.disableRandomCall?null:e.getAlias()+e.getGroup(t)})),YZ({replaceArg:function(e){return{argIndex:0,value:e.getName()}},getKVReportKey:function(e){return uK[e.getName()]}})],P0.prototype,"updatePlugin",1),UF([XZ("stop"),_Z((function(e,t){if(e.disableRandomCall)return null;var n=e.getGroup(t),r=e.getAlias();return"*"===n?new RegExp("".concat(r,".*")):r+n})),YZ({replaceArg:function(e){return{argIndex:0,value:e.getName()}},getKVReportKey:function(e){return lK[e.getName()]}})],P0.prototype,"stopPlugin",1),UF([KZ.apply(void 0,T(aZ.TRTC.enableAudioVolumeEvaluation))],P0.prototype,"enableAudioVolumeEvaluation",1),UF([YZ()],P0.prototype,"getVideoSnapshot",1),UF([YZ()],P0.prototype,"_setCurrentSpeaker",1),UF([mZ((function(e){return"a".concat(e.userId)}),(function(){return!0}))],P0.prototype,"_startRemoteAudio",1),UF([rY((function(e){return function(t){return HF(this,null,p().mark((function n(){var r=this;return p().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.abrupt("return","*"===t.userId?Promise.all(T(this._room.remotePublishedUserMap.values()).map((function(e){return r._stopRemoteAudio(OF(xF({},t),{userId:e.userId})).catch((function(){}))}))):e.call(this,t));case 1:case"end":return n.stop()}}),n,this)})))}})),_Z((function(e){return"a".concat(e.userId)}))],P0.prototype,"_stopRemoteAudio",1),UF([_Z("room")],P0.prototype,"_exitRoom",1),UF([_Z("screen")],P0.prototype,"_stopScreenShare",1),UF([JZ.apply(void 0,T(aZ.TRTC.sendSEIMessage)),j$({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}})],P0.prototype,"sendSEIMessage",1),UF([JZ(aZ.TRTC.sendCustomMessage),j$({timesInSecond:30,maxSizeInSecond:8e3,getSize:function(e){return e.data.byteLength}})],P0.prototype,"sendCustomMessage",1),UF([JZ(aZ.TRTC.create)],P0,"_create",1);var M0=P0,L0=function(){return s((function e(){i(this,e),FF(this,"_set",new Set),HW.on(GW.LEAVE_SUCCESS,this.delete,this)}),[{key:"add",value:function(e){var t=e.room,n=e.roomId;if("rtc"!==t.scene){var r=this.getKey(t.userId,n||t.roomId,t.sdkAppId,t.useStringRoomId);this._set.add(r)}}},{key:"delete",value:function(e){var t=e.room,n=e.roomId;if("rtc"!==t.scene){var r=this.getKey(t.userId,t.roomId||n,t.sdkAppId,t.useStringRoomId);this._set.delete(r)}}},{key:"getKey",value:function(e,t,n,r){return"".concat(n,"_").concat(t,"_").concat(e,"_").concat(r)}},{key:"isJoined",value:function(e){var t=e.userId,n=e.roomId,r=e.sdkAppId,i=e.room;return"rtc"!==i.scene&&this._set.has(this.getKey(t,n,r,i.useStringRoomId))}}])}();function V0(){return HF(this,null,p().mark((function e(){var t,n,r,i,o,a,s,c,u,l,d,h,f,m;return p().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,xq();case 3:r=e.sent,t=r&&r.length,e.next=9;break;case 7:e.prev=7,e.t0=e.catch(0);case 9:return e.prev=9,e.next=12,Oq();case 12:i=e.sent,n=i&&i.length,e.next=18;break;case 16:e.prev=16,e.t1=e.catch(9);case 18:o={microphone:t,camera:n},a=this.checkSystemResult.detail,s=a.isH264EncodeSupported,c=a.isVp8EncodeSupported,u=a.isH264DecodeSupported,l=a.isVp8DecodeSupported,d=$W.basis(),h={webRTC:d.isWebRTCSupported,getUserMedia:d.isGetUserMediaSupported,webSocket:d.isWebSocketsSupported,screenShare:d.isScreenShareSupported,webAudio:d.isWebAudioSupported,h264Encode:s,h264Decode:u,vp8Encode:c,vp8Decode:l},f={browser:d.browser,os:d.os,trtc:h,devices:o},m={isWebCodecSupported:d.isWebCodecSupported,isMediaSessionSupported:d.isMediaSessionSupported,isWebTransportSupported:d.isWebTransportSupported},Nz.uploadEvent({log:"trtcstats-".concat(JSON.stringify(f)),userId:this.userId}),this._log.info("TrtcStats-".concat(JSON.stringify(f))),Nz.uploadEvent({log:"trtcadvancedstats-".concat(JSON.stringify(m)),userId:this.userId});case 20:case"end":return e.stop()}}),e,this,[[0,7],[9,16]])})))}var U0=VF(jF()),F0="1",B0="2",H0="3",j0="4",G0="5",W0="6",J0={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,START_PUBLISH_CDN_STREAM_RES:8196,UPDATE_PUBLISH_CDN_STREAM_RES:8198,STOP_PUBLISH_CDN_STREAM_RES:8200,USER_LIST_RES:4137,SWITCH_ROLE_RES:4110,UPDATE_CONSTRAINT_CONFIG_RES:772,REBUILD_PEER_CONNECTION_RES:4150,SPC_PUBLISH_RESULT:4146,SPC_SUBSCRIBE_RESULT:4156,ABILITY_STATUS_REPORT_RESULT:4158,SERVER_FIRST_PACKAGE_RECEIVED:5e3,RECEIVE_CUSTOM_MSG:4140},K0=[J0.UPDATE_REMOTE_MUTE_STAT,J0.UPLINK_NETWORK_STATS,J0.USER_LIST_RES,J0.MUTE_RESULT,J0.SERVER_FIRST_PACKAGE_RECEIVED,J0.RECEIVE_CUSTOM_MSG],z0={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",START_PUBLISH_CDN_STREAM_RES:"start-publish-cdn-stream-res",UPDATE_PUBLISH_CDN_STREAM_RES:"update-publish-cdn-stream-res",STOP_PUBLISH_CDN_STREAM_RES:"stop-publish-cdn-stream-res",USER_LIST_RES:"user-list-res",SWITCH_ROLE_RES:"switch_role_res",MUTE_RESULT:"mute-result",UPDATE_CONSTRAINT_CONFIG_RES:"update-contraint-config-res",REBUILD_PEER_CONNECTION_RES:"rebuild-pc-res",SPC_PUBLISH_RESULT:"spc-publish-result",SPC_SUBSCRIBE_RESULT:"spc-subscribe-result",ABILITY_STATUS_REPORT_RESULT:"ability-status-report",SERVER_FIRST_PACKAGE_RECEIVED:"first-pkg-received",RECEIVE_CUSTOM_MSG:"receive-custom-msg"},q0="publish_change",Y0="join",X0="leave",Q0="quality_report",$0="mute_uplink",Z0="publish",e1="publish_state_change",t1="unpublish",n1="subscribe",r1="unsubscribe",i1="subscribe_change",o1="start_publishing",a1="stop_publishing",s1="start_push_user_cdn",c1="stop_push_user_cdn",u1="start_mcu_mix",l1="stop_mcu_mix",d1="start_publish_cdn_stream",h1="update_publish_cdn_stream",f1="stop_publish_cdn_stream",p1="get_user_list",m1="change_role",v1="update_constraint_config",_1="rebuild_pc",g1="join/v2",y1="publish/v2",E1="subscribe/v3",T1="ability_status_report",k1="reconnect",S1="channel_msg",I1=new Set;function b1(e){var t=T(I1.values()).find((function(t){return t.room.userId===e&&!t.room.isJoined}));return t||null}var A1=function(e){function t(e){var n,o,a,s;i(this,t),n=r(this,t),FF(n,"room"),FF(n,"sdkAppId"),FF(n,"userId"),FF(n,"userSig"),FF(n,"url"),FF(n,"backupUrl"),FF(n,"race"),FF(n,"destroyed",!1),FF(n,"_socketInUse"),FF(n,"_socket"),FF(n,"_backupSocket"),FF(n,"_signalInfo",{tinyId:void 0,clientIp:"",signalIp:"",relayIp:"",relayInnerIp:"",relayPort:0,endReportExtend:void 0,bakRelayIps:[]}),FF(n,"_currentState","DISCONNECTED"),FF(n,"_isReconnecting",!1),FF(n,"_seq",0),FF(n,"_log"),FF(n,"_lastMessageTime",-1),FF(n,"_connectStartTime",-1),FF(n,"_stopConnectRetry"),FF(n,"bytesSent",0),FF(n,"bytesReceived",0),FF(n,"keepAlive",!1),FF(n,"signalDomainWhenUnifiedProxy"),FF(n,"stopKeepAliveTimeout"),FF(n,"rtt",0),n.room=e.room,n.sdkAppId=e.sdkAppId,n.userId=e.userId,n.userSig=e.userSig,n.race=!!aj(e.race)||e.race,n.signalDomainWhenUnifiedProxy=e.signalDomainWhenUnifiedProxy;var c=(null==(a=null==(o=n.room.scheduleResult)?void 0:o.config)?void 0:a.keepAliveClient)||0;return null!=(s=n.room.joinParams)&&s.keepAlive&&!c&&(c=1),c-I1.size>0&&n.room.enableSPC&&(n.keepAlive=!0,I1.add(n)),n.url=e.url,n.backupUrl=e.backupUrl,n._seq=0,n._log=qW.createLogger({id:"ws",userId:n.userId,sdkAppId:n.sdkAppId}),n.onmessage=n.onmessage.bind(n),n.onerror=n.onerror.bind(n),n.onclose=n.onclose.bind(n),n}return d(t,e),s(t,[{key:"urlParam",get:function(){var e="?sdkAppId=".concat(encodeURIComponent(this.sdkAppId),"&userId=").concat(encodeURIComponent(this.userId),"&userSig=").concat(encodeURIComponent(this.userSig),"&keepAlive=").concat(encodeURIComponent(Number(this.keepAlive)));this.signalDomainWhenUnifiedProxy&&(e+="&signalDomain=".concat(encodeURIComponent(this.signalDomainWhenUnifiedProxy)));var t=new URLSearchParams(location.search).get("clientIp");return t&&(e+="&clientIp=".concat(t)),this.race?"".concat(e,"&race=1"):e}},{key:"_urlWithParam",get:function(){return"".concat(this.url).concat(this.race?"/v2/ws":"").concat(this.urlParam)}},{key:"_backupUrlWithParam",get:function(){return"".concat(this.backupUrl).concat(this.race?"/v2/ws":"").concat(this.urlParam)}},{key:"isConnected",get:function(){return"CONNECTED"===this._currentState}},{key:"isConnecting",get:function(){return"CONNECTING"===this._currentState}},{key:"isOnline",get:function(){return"CONNECTED"===this._currentState&&Date.now()-this._lastMessageTime<12e3}},{key:"connect",value:function(){return HF(this,arguments,(function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1e4;return p().mark((function n(){var r;return p().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(!e.isConnected){n.next=2;break}return n.abrupt("return",Promise.resolve());case 2:return e._log.info("connect to [".concat(e.url,", ").concat(e.backupUrl,"]").concat(t?" timeout: ".concat(t):""," keepAlive: ").concat(Number(e.keepAlive))),e.emitConnectionStateChanged("CONNECTING"),e._connectStartTime=yj(),r=[e.connectWS({url:e._urlWithParam,isMain:!0,timeout:t})],e.race&&e._backupUrlWithParam!==e._urlWithParam&&r.push(e.connectWS({url:e._backupUrlWithParam,isMain:!1,timeout:t})),n.next=7,gj(r);case 7:e._socketInUse=n.sent,e.unbindAndCloseSocket(e._socketInUse===e._socket?UB.BACKUP:UB.MAIN),e.emitConnectionStateChanged("CONNECTED");case 10:case"end":return n.stop()}}),n)}))()}))}},{key:"connectWS",value:function(e){var t=this,n=e.url,r=e.timeout,i=e.isMain,o=new WebSocket(n);this.bindSocket(o),i?this._socket=o:this._backupSocket=o;var a=-1;return new Promise((function(e,n){o.onclose=n,o.onerror=n,o.onopen=function(){return e(o)},r&&(a=setTimeout((function(){t.unbindAndCloseSocket(i?UB.MAIN:UB.BACKUP),n(new tB({code:ZF.SIGNAL_CHANNEL_SETUP_FAILED,message:"ws connect timeout"}))}),r))})).finally((function(){o.onclose=null,o.onerror=null,o.onopen=null,clearTimeout(a)}))}},{key:"bindSocket",value:function(e){e.addEventListener("close",this.onclose),e.addEventListener("error",this.onerror),e.addEventListener("message",this.onmessage)}},{key:"unbindSocket",value:function(e){e.removeEventListener("close",this.onclose),e.removeEventListener("error",this.onerror),e.removeEventListener("message",this.onmessage)}},{key:"unbindAndCloseSocket",value:function(e){if(e===UB.MAIN){if(this._socket){this.unbindSocket(this._socket);try{this._socket.close(1e3)}catch(hH){}this._socket=null}}else if(this._backupSocket){this.unbindSocket(this._backupSocket);try{this._backupSocket.close(1e3)}catch(hH){}this._backupSocket=null}}},{key:"onclose",value:function(e){e.target===this._socketInUse&&(this._log.warn("".concat(e.target===this._socket?"main":"backup"," is closed code:").concat(e.code," ").concat(e.reason)),this.emitConnectionStateChanged("DISCONNECTED"),(!e.wasClean||1e3!==e.code)&&this.startReconnection(),this.room.isJoining&&this.emit(G0,new tB({code:ZF.SIGNAL_CHANNEL_SETUP_FAILED,message:"websocket onclose"})))}},{key:"onerror",value:function(e){this._log.error("".concat(e.target===this._socket?"main":"backup"," error observed")),this.emitConnectionStateChanged("DISCONNECTED"),e.target===this._socketInUse&&(this.unbindAndCloseSocket(UB.MAIN),this.unbindAndCloseSocket(UB.BACKUP),this._socketInUse=null,this.reconnect()),this.room.isJoining&&this.emit(G0,new tB({code:ZF.SIGNAL_CHANNEL_SETUP_FAILED,message:"websocket onerror"}))}},{key:"onmessage",value:function(e){if(this.isConnected){this._lastMessageTime=Date.now(),this.bytesReceived+=Pj(e.data);var t=JSON.parse(e.data),n=t.cmd,r=t.data,i=Object.values(J0),o=Object.keys(J0)[i.indexOf(n)],a=z0[o]||n;switch(K0.includes(n)||(this._log.debug("received ".concat(n," msg: ").concat(e.data)),a&&this._log.info("Received event: [ ".concat(a," ]"))),n){case J0.CHANNEL_SETUP_RESULT:if(0===t.code)this._signalInfo.clientIp=r.clientIp,this._signalInfo.signalIp=r.signalInnerIp,r.svrTime&&function(e){nB=e-(new Date).getTime();var t=new Date;t.setTime(e),qW.info("baseTime from server: ".concat(t," offset: ").concat(nB))}(r.svrTime),this._log.info("ChannelSetup Success ".concat(yj()-this._connectStartTime)),fK.addSuccessEvent({key:521701,cost:yj()-this._connectStartTime}),this._connectStartTime=-1,this.emit(F0,{signalInfo:this._signalInfo});else{var s=new tB({code:ZF.SIGNAL_CHANNEL_SETUP_FAILED,extraCode:t.code,message:rK({key:ZJ.SIGNAL_CHANNEL_SETUP_FAILED,data:{errorCode:t.code,errorMsg:t.message}})});this._log.error("".concat(t.code,", ").concat(t.message)),this.close(),fK.addFailedEvent({key:521701,error:s}),this.emit(G0,s)}break;case J0.JOIN_ROOM_RESULT:0===t.code&&(this._signalInfo.relayIp=r.relayOuterIp,this._signalInfo.relayInnerIp=r.relayInnerIp,this._signalInfo.bakRelayIps=r.bakRelayIps,this._signalInfo.relayPort=r.relayPort,this._signalInfo.tinyId=t.tinyId,this._signalInfo.endReportExtend=r.endReportExtend,this._log.info("signalIp:".concat(this._signalInfo.signalIp," clientIp:").concat(this._signalInfo.clientIp," relayIp: ").concat(this._signalInfo.relayIp))),this.emit(a,{data:t});break;default:this.emit(String(a),{data:t})}}}},{key:"reGetSignalChannelUrl",value:function(){return HF(this,null,p().mark((function e(){var t,n,r;return p().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(e.prev=0,this.room.joinParams){e.next=3;break}return e.abrupt("return");case 3:return AZ(!0),e.next=6,this.room.schedule(this.room.joinParams);case 6:t=this.room.getSignalChannelUrl(),n=t.mainUrl,r=t.backupUrl,this.url=n,this.backupUrl=r,e.next=12;break;case 10:e.prev=10,e.t0=e.catch(0);case 12:case"end":return e.stop()}}),e,this,[[0,10]])})))}},{key:"startReconnection",value:function(){if(this._socketInUse){this._socketInUse.onclose=null,this._socketInUse.close(4011);var e=this._socketInUse===this._socket;this.unbindAndCloseSocket(e?UB.MAIN:UB.BACKUP),this._socketInUse=null,this.emitConnectionStateChanged("DISCONNECTED"),this.reconnect()}}},{key:"reconnect",value:function(){return HF(this,null,p().mark((function e(){var t,n,r,i,o,a,s,c,u;return p().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._isReconnecting){e.next=26;break}if(this.room.isJoined||!this.keepAlive){e.next=4;break}return this.close(),e.abrupt("return");case 4:return this._isReconnecting=!0,e.prev=5,this._log.warn("reconnect"),e.next=9,this.connect();case 9:return t=this.room,n=t.roomId,r=t.useStringRoomId,i=this._signalInfo,o=i.relayIp,a=i.relayInnerIp,s=i.relayPort,e.next=18,this.sendWaitForResponse({command:k1,data:{roomId:n,useStringRoomId:r,relayInnerIp:a,relayOuterIp:o,relayPort:s},responseCommand:z0.CHANNEL_RECONNECT_RESULT});case 18:c=e.sent,0===(u=c.data).code?(this._log.warn("reconnect success"),this.stopReconnection(),fK.addSuccessEvent({key:521702,cost:yj()-this._connectStartTime}),this._connectStartTime=-1,this.room.syncUserList(),this.room.checkConnectionsToReconnect()):(fK.addFailedEvent({key:521702,error:u.code}),this._log.warn("reconnect failed, ".concat(u.code," ").concat(u.message)),this.room.reJoin()),e.next=26;break;case 23:e.prev=23,e.t0=e.catch(5),this._log.error(e.t0),this.room.reJoin();case 26:case"end":return e.stop()}}),e,this,[[5,23]])})))}},{key:"send",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(this.isConnected&&!this.room.isLeft){var n={cmd:e,data:t,userId:this.userId,tinyId:this._signalInfo.tinyId,seq:++this._seq},r=JSON.stringify(n);return this._socketInUse.send(r),this.bytesSent+=Pj(r),n.seq}}},{key:"sendWaitForResponse",value:function(e){var t=this,n=e.command,r=e.data,i=e.timeout,o=void 0===i?5e3:i,a=e.responseCommand,s=e.commandDesc,c=e.enableLog,u=void 0===c||c,l=e.addReceiveTime,d=void 0!==l&&l;return new Promise((function(e,i){var c=setTimeout((function(){t.off(a,l);var e=new tB({code:ZF.API_CALL_TIMEOUT,message:rK({key:ZJ.API_CALL_TIMEOUT,data:{commandDesc:s,command:n}})});u&&t._log.warn(e),i(e)}),o),l=function(n){n.data.seq===h&&(clearTimeout(c),t.off(a,l),d&&(n.data.receiveTime=Date.now()),e(n))};t.on(a,l);var h=t.send(n,r)}))}},{key:"sendWaitForResponseWithRetry",value:function(e){var t=this,n=e.commandDesc,r=e.command,i=e.retries,o=void 0===i?0:i,a=e.retryTimeout,s=void 0===a?0:a;return qj({retryFunction:this.sendWaitForResponse,onError:function(e){var n=e.retry;t.isOnline?n():(t._log.warn("retry ".concat(r," when connected")),t.once(H0,n))},onRetrying:function(e){t._log.warn("".concat(n||r," timeout observed, retrying [").concat(e,"/").concat(o,"]"))},settings:{retries:o,timeout:s},context:this})(e)}},{key:"getCurrentState",value:function(){return this._currentState}},{key:"getSignalInfo",value:function(){return this._signalInfo}},{key:"stopReconnection",value:function(){this._isReconnecting=!1,this._stopConnectRetry&&this._stopConnectRetry()}},{key:"close",value:function(){this._log.info("closed"),clearTimeout(this.stopKeepAliveTimeout),I1.delete(this),this.stopReconnection(),this._signalInfo={tinyId:void 0,clientIp:"",signalIp:"",relayIp:"",relayInnerIp:"",relayPort:0,bakRelayIps:[],endReportExtend:void 0},this._socketInUse=null,this.bytesSent=0,this.bytesReceived=0,this._stopConnectRetry&&this._stopConnectRetry(),this.unbindAndCloseSocket(UB.MAIN),this.unbindAndCloseSocket(UB.BACKUP),this.emitConnectionStateChanged("DISCONNECTED")}},{key:"destroy",value:function(){this.close(),this.destroyed=!0}},{key:"getBackupRelayIpPair",value:function(){var e,t=null==(e=this._signalInfo.bakRelayIps)?void 0:e.shift();return t&&(t.relayPort=t.relayPort||this._signalInfo.relayPort),t}},{key:"clearBakRelayIps",value:function(){this._signalInfo.bakRelayIps=[]}},{key:"stopKeepAliveIn",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:3600;if(this.keepAlive){this._log.info("stopKeepAlive in ".concat(t,"s")),this.stopKeepAliveTimeout=setTimeout((function(){e.keepAlive=!1,e._log.info("close due to not used ".concat(t,"s")),e.close(),e.off(z0.JOIN_ROOM_RESULT,n)}),1e3*t);var n=function(t){0===t.data.code&&(e._log.info("stopKeepAlive clear timeout"),clearTimeout(e.stopKeepAliveTimeout),e.off(z0.JOIN_ROOM_RESULT,n))};this.on(z0.JOIN_ROOM_RESULT,n)}}},{key:"emitConnectionStateChanged",value:function(e){e!==this._currentState&&(this._log.info("".concat(this._currentState," -> ").concat(e)),this.emit(B0,{prevState:this._currentState,state:e}),this._currentState=e,"CONNECTED"===e?this.emit(H0):"DISCONNECTED"===e&&this.emit(W0))}}])}(U0.default);UF([Oz({settings:{retries:1/0,timeout:2e3},onError:function(e,t){!this.room.isDestroyed&&!this.destroyed&&t()},onRetrying:function(e,t){this._log.warn("retrying to connect ".concat(e)),e>=3&&e%3==0&&this.reGetSignalChannelUrl(),t&&(this._stopConnectRetry=t,(this.room.isDestroyed||this.destroyed)&&t())}})],A1.prototype,"connect",1);var R1=VF(jF()),C1=0,w1=!1,D1=new Set,N1=!1,x1=function(){return s((function e(t){i(this,e),FF(this,"userId"),FF(this,"tinyId"),FF(this,"_sdpSemantics"),FF(this,"_isUplink"),FF(this,"_room"),FF(this,"_log"),FF(this,"_signalChannel"),FF(this,"_isErrorObserved",!1),FF(this,"_waitForPeerConnectionConnectedPromise"),FF(this,"_waitForPeerConnectionConnectedPromiseReject",null),FF(this,"_peerConnection",null),FF(this,"_emitter",new R1.default),FF(this,"_currentState","DISCONNECTED"),FF(this,"_isReconnecting",!1),FF(this,"_reconnectionCount",0),FF(this,"_reconnectionTimer",-1),FF(this,"_isFirstConnection",!0),FF(this,"_prevTime",-1),FF(this,"_localAddress"),FF(this,"_remoteAddress"),this.userId=t.userId,this.tinyId=t.tinyId,this._room=t.room,this._sdpSemantics=t.room.sdpSemantics,this._isUplink=t.isUplink,this._log=qW.createLogger({id:"n-mpc",userId:this._room.userId,remoteUserId:this.userId,sdkAppId:this._room.sdkAppId,isLocal:this._isUplink}),this._signalChannel=t.signalChannel}),[{key:"beforeConnect",value:function(){this._prevTime<0&&(this._prevTime=yj())}},{key:"afterConnect",value:function(){try{this._isFirstConnection?(this._isFirstConnection=!1,fK.addSuccessEvent({key:521705,cost:Math.min(yj()-this._prevTime,3e4)})):this._isReconnecting&&fK.addSuccessEvent({key:521706,cost:yj()-this._prevTime}),this._prevTime=-1}catch(rJ){throw this._isFirstConnection?(this._isFirstConnection=!1,fK.addFailedEvent({key:521705,error:rJ})):this._isReconnecting&&this._reconnectionCount>=3&&fK.addFailedEvent({key:521706,error:rJ}),rJ}}},{key:"initialize",value:function(){var e={iceServers:this._room.getIceServers(),iceTransportPolicy:this._room.getIceTransportPolicy(),sdpSemantics:this._sdpSemantics,bundlePolicy:"max-bundle",rtcpMuxPolicy:"require",tcpCandidatePolicy:"disable",IceTransportsType:"nohost"};this._peerConnection=new RTCPeerConnection(e),this._peerConnection.onconnectionstatechange=this.onConnectionStateChange.bind(this)}},{key:"close",value:function(e){this._log.info("close connection"),this._emitter.emit("closed",e),this._isReconnecting&&this.stopReconnection(),this.closePeerConnection(),D1.delete(this)}},{key:"closePeerConnection",value:function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];this._peerConnection&&(this._log.info("close pc"),this._peerConnection.onconnectionstatechange=null,this._peerConnection.close(),this._peerConnection=null,e&&this.emitConnectionStateChangedEvent("DISCONNECTED")),this._waitForPeerConnectionConnectedPromiseReject&&this._waitForPeerConnectionConnectedPromiseReject(new tB({code:ZF.API_CALL_ABORTED,message:"connection closed"}))}},{key:"getDTLSTransportState",value:function(){if(!this._peerConnection)return sH;var e=null;if(this._isUplink){if(!FK()||0===this._peerConnection.getSenders().length)return sH;e=this._peerConnection.getSenders()[0].transport}else{if(!UK()||0===this._peerConnection.getReceivers().length)return sH;e=this._peerConnection.getReceivers()[0].transport}return e?e.state:sH}},{key:"onConnectionStateChange",value:function(e){var t=this._peerConnection.iceConnectionState,n=this.getDTLSTransportState();if(this._log.info("connectionState: ".concat(e.target.connectionState,", ICE: ").concat(t,", DTLS: ").concat(n)),e.target.connectionState===cH.CONNECTING&&this.emitConnectionStateChangedEvent("CONNECTING"),e.target.connectionState===cH.FAILED||e.target.connectionState===cH.CLOSED){var r="connection ".concat(e.target.connectionState,". ICE Transport state: ").concat(t,", DTLS Transport state: ").concat(n),i=new tB({message:r,code:ZF.ICE_TRANSPORT_ERROR});this.emitConnectionStateChangedEvent("DISCONNECTED"),this.startReconnection(),this._isErrorObserved||this._emitter.emit("error",i)}(e.target.connectionState===cH.CONNECTED||e.target.connectionState===cH.COMPLETED)&&(this.logSelectedCandidate(),Nz.logSuccessEvent({userId:this._room.userId,eventType:pH.ICE_CONNECTION_STATE}),this.emitConnectionStateChangedEvent("CONNECTED"))}},{key:"emitConnectionStateChangedEvent",value:function(e){return e!==this._currentState&&("CONNECTED"===e?(C1=0,w1=!1,N1=!0,D1.add(this)):D1.delete(this),HW.emit(GW.PEER_CONNECTION_STATE_CHANGED,{room:this._room,prevState:this._currentState,state:e,remoteUserId:this._isUplink?void 0:this.userId}),this._emitter.emit("connection-state-changed",{prevState:this._currentState,state:e}),this._currentState=e,!0)}},{key:"getPeerConnection",value:function(){return this._peerConnection}},{key:"getRoom",value:function(){return this._room}},{key:"getUserId",value:function(){return this.userId}},{key:"getTinyId",value:function(){return this.tinyId}},{key:"logSelectedCandidate",value:function(){return HF(this,null,p().mark((function e(){var t,n,r,i,o,a,s;return p().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._peerConnection){e.next=2;break}return e.abrupt("return");case 2:return e.next=4,this._peerConnection.getStats();case 4:t=e.sent,n=c(t),e.prev=6,n.s();case 8:if((r=n.n()).done){e.next=16;break}if(i=_(r.value,2),o=i[1],!NK(o)){e.next=14;break}return a=t.get(o.localCandidateId),s=t.get(o.remoteCandidateId),a&&(this._log.info("local candidate: ".concat(a.candidateType," ").concat(a.protocol,":").concat(a.ip||a.address,":").concat(a.port," ").concat(a.networkType||""," ").concat("relay"===a.candidateType?"relayProtocol:".concat(a.relayProtocol):"")),this._localAddress="".concat(a.ip||a.address,":").concat(a.port)),s&&(this._log.info("remote candidate: ".concat(s.candidateType," ").concat(s.protocol,":").concat(s.ip||s.address,":").concat(s.port)),this._remoteAddress="".concat(s.protocol,":").concat(s.ip||s.address)),e.abrupt("break",16);case 14:e.next=8;break;case 16:e.next=21;break;case 18:e.prev=18,e.t0=e.catch(6),n.e(e.t0);case 21:return e.prev=21,n.f(),e.finish(21);case 24:case"end":return e.stop()}}),e,this,[[6,18,21,24]])})))}},{key:"getCurrentState",value:function(){return this._currentState}},{key:"waitForPeerConnectionConnected",value:function(){var e=this;return this._waitForPeerConnectionConnectedPromise||(this._waitForPeerConnectionConnectedPromise=new Promise((function(t,n){if("CONNECTED"===e._currentState)return t();e._waitForPeerConnectionConnectedPromiseReject=n;var r=function(e){"CONNECTED"===e.state&&(clearTimeout(a),o(),t())},i=function(t){t.room===e._room&&(clearTimeout(a),o(),n(new tB({code:ZF.API_CALL_ABORTED,message:rK({key:ZJ.CONNECTION_ABORTED,data:"leave room"})})))},o=function(){HW.off(GW.LEAVE_SUCCESS,i,e),e._emitter.off("connection-state-changed",r,e)},a=setTimeout((function(){o();var t=new tB({code:ZF.API_CALL_TIMEOUT,message:"connection timeout"});C1+=1,function(e){return C1>2&&!w1&&0===D1.size&&e}(e._signalChannel.isConnected)&&(e._log.warn("firewall restriction"),w1=!0,e._emitter.emit("firewall-restriction")),n(t)}),AH);HW.on(GW.LEAVE_SUCCESS,i,e),e._emitter.on("connection-state-changed",r,e)})),this._waitForPeerConnectionConnectedPromise=this._waitForPeerConnectionConnectedPromise.finally((function(){e._waitForPeerConnectionConnectedPromise=null,e._waitForPeerConnectionConnectedPromiseReject=null}))),this._waitForPeerConnectionConnectedPromise}},{key:"getReconnectionCount",value:function(){return this._reconnectionCount}},{key:"startReconnection",value:function(){this._isReconnecting=!0,this.reconnect()}},{key:"clearReconnectionTimer",value:function(){-1!==this._reconnectionTimer&&(clearTimeout(this._reconnectionTimer),this._reconnectionTimer=-1)}},{key:"stopReconnection",value:function(){this._log.info("stop reconnection"),this._isReconnecting=!1,this._reconnectionCount=0,this.clearReconnectionTimer(),this._signalChannel.off(H0,this.reconnect,this)}},{key:"beforeReconnect",value:function(){if(-1!==this._reconnectionTimer)return this._log.warn("reconnect() is reconnecting, ignore"),-1;if(this._reconnectionCount>=dH()){this._log.warn("SDK has tried reconnect for ".concat(this._reconnectionCount," times, but all failed, please check your network")),this.stopReconnection();var e=new tB({code:this._isUplink?ZF.UPLINK_RECONNECTION_FAILED:ZF.DOWNLINK_RECONNECTION_FAILED,message:rK({key:this._isUplink?ZJ.UPLINK_RECONNECTION_FAILED:ZJ.DOWNLINK_RECONNECTION_FAILED})});return this.emitConnectionStateChangedEvent("DISCONNECTED"),this._emitter.emit("error",e),-1}return this._signalChannel.isConnected?(this._reconnectionCount+=1,this._log.warn("reconnect() trying [".concat(this._reconnectionCount,"]")),1):(this._log.warn("reconnect() signal channel is not connected, suspend reconnection until signal is connected"),this._signalChannel.once(H0,this.reconnect,this),-1)}},{key:"on",value:function(e,t,n){this._emitter.on(e,t,n)}},{key:"off",value:function(e,t,n){this._emitter.off(e,t,n)}},{key:"getIsReconnecting",value:function(){return this._isReconnecting}},{key:"isH264",get:function(){var e,t;return!(null==(t=null==(e=this._peerConnection)?void 0:e.remoteDescription)||!t.sdp.includes("H264"))}},{key:"setOffer",value:function(e){var t;return null==(t=this._peerConnection)?void 0:t.setLocalDescription(e)}},{key:"setAnswer",value:function(e){var t;return null==(t=this._peerConnection)?void 0:t.setRemoteDescription(e)}}])}();UF([hY(521712,!1)],x1.prototype,"setOffer",1),UF([hY(521713,!1)],x1.prototype,"setAnswer",1);var O1=VF(XF()),P1=function(e){return O1.default.parse(e)},M1=function(e){return O1.default.write(e)},L1=function(e){var t=P1(e);return t.media.forEach((function(e){e.type===UB.AUDIO&&e.fmtp.forEach((function(e){e.config+=";sprop-stereo=1;stereo=1"}))})),M1(t)};function V1(e){var t=P1(e);return t.media.forEach((function(e){var t,n;if(e.type===UB.VIDEO){var r=new Set;e.rtp.forEach((function(e){var t=e.payload;return"H264"===e.codec&&r.add(t)})),e.fmtp.forEach((function(e){var t=e.payload,n=e.config.match(/apt=(\d+)/);n&&n[1]&&r.has(Number(n[1]))&&r.add(t)}));var i=function(e){var t=e.payload;return!r.has(t)};e.rtp=e.rtp.filter(i),e.rtcpFb=null==(t=e.rtcpFb)?void 0:t.filter(i),e.fmtp=e.fmtp.filter(i),e.payloads=null==(n=e.payloads)?void 0:n.split(" ").filter((function(e){return!r.has(Number(e))})).join(" ")}})),M1(t)}function U1(e){return Object.keys(e).filter((function(t){return e[t]}))}var F1=function(e){function t(e){var n;return i(this,t),n=r(this,t,[OF(xF({},e),{isUplink:!1})]),FF(n,"_flag",0),FF(n,"isRobot",!1),FF(n,"role","anchor"),FF(n,"remoteAudioTrack"),FF(n,"remoteVideoTrack"),FF(n,"remoteAuxiliaryTrack"),FF(n,"ssrc",{audio:0,video:0,auxiliary:0}),FF(n,"_isSDPExchanging",!1),n.flag=e.flag,n.isRobot=e.isRobot||!1,n.remoteAudioTrack=e.remoteAudioTrack||new g$(n._room,n),n.remoteVideoTrack=e.remoteVideoTrack||new L$(n._room,n),n.remoteAuxiliaryTrack=e.remoteAuxiliaryTrack||new V$(n._room,n),n}return d(t,e),s(t,[{key:"videoCodec",get:function(){var e,t,n=null==(t=null==(e=this._peerConnection)?void 0:e.remoteDescription)?void 0:t.sdp;return n?n.includes("H264")?"h264":"vp8":"h264"}},{key:"subscribeState",get:function(){var e={audio:!1,video:!1,auxiliary:!1,smallVideo:!1};return this.remoteVideoTrack.isSubscribed&&(8&this.remoteVideoTrack.mediaType?e.smallVideo=!0:e.video=!0),this.remoteAudioTrack.isSubscribed&&(e.audio=!0),this.remoteAuxiliaryTrack.isSubscribed&&(e.auxiliary=!0),e}},{key:"muteState",get:function(){return Ij(this.flag,this.userId)}},{key:"flag",get:function(){return this._flag},set:function(e){var t,n,r;e!==this._flag&&(this._flag=e,null==(t=this.remoteAudioTrack)||t.onFlagChanged(),null==(n=this.remoteVideoTrack)||n.onFlagChanged(),null==(r=this.remoteAuxiliaryTrack)||r.onFlagChanged())}},{key:"hasMainStream",get:function(){return this.muteState.hasAudio||this.muteState.hasVideo||this.muteState.hasSmall}},{key:"hasAuxStream",get:function(){return this.muteState.hasAuxiliary}},{key:"isMainStreamSubscribed",get:function(){return(this.subscribeState.audio||this.subscribeState.video||this.subscribeState.smallVideo)&&(this.muteState.hasAudio||this.muteState.hasVideo||this.muteState.hasSmall)}},{key:"isAuxStreamSubscribed",get:function(){return this.subscribeState.auxiliary&&this.muteState.hasAuxiliary}},{key:"isSmallStreamSubscribed",get:function(){return this.subscribeState.smallVideo&&this.muteState.hasSmall}},{key:"isBigStreamSubscribed",get:function(){return this.subscribeState.video&&this.muteState.hasVideo}},{key:"isStreamUnpublished",value:function(e){return e===UB.MAIN?!this.muteState.hasAudio&&!this.muteState.hasVideo:!this.muteState.hasAuxiliary}},{key:"initialize",value:function(){y(t,"initialize",this,3)([]),this.installEvents(),this._peerConnection.ontrack=this.onTrack.bind(this)}},{key:"close",value:function(e){y(t,"close",this,3)([e]),this.emitConnectionStateChangedEvent("DISCONNECTED"),this.remoteAudioTrack.close(),this.remoteVideoTrack.close(),this.remoteAuxiliaryTrack.close(),this.uninstallEvents()}},{key:"installEvents",value:function(){}},{key:"uninstallEvents",value:function(){this._emitter.removeAllListeners()}},{key:"emitConnectionStateChangedEvent",value:function(e){var n,r,i=this._currentState,o=y(t,"emitConnectionStateChangedEvent",this,3)([e]);return o&&i!==e&&(null==(n=this.remoteVideoTrack)||n.emit("connection-state-changed",{prevState:i,state:e}),null==(r=this.remoteAuxiliaryTrack)||r.emit("connection-state-changed",{prevState:i,state:e})),o}},{key:"onTrack",value:function(e){var t=e.streams[0],n=e.track,r=t.id===XB?UB.MAIN:UB.AUXILIARY;this._log.debug("ontrack ".concat(r," ").concat(n.kind));var i=UB.AUDIO;n.kind===UB.VIDEO&&(i=r===UB.MAIN?UB.VIDEO:UB.AUXILIARY);var o=this.remoteAudioTrack;i===UB.VIDEO?o=this.remoteVideoTrack:i===UB.AUXILIARY&&(o=this.remoteAuxiliaryTrack),o.setInputMediaStreamTrack(n)}},{key:"addRRTRLine",value:function(e){var t=e.split("\r\n"),n=new Map;t.forEach((function(e,r){/^a=rtcp-fb:/.test(e)&&t[r+1]&&!/^a=rtcp-fb:/.test(t[r+1])&&n.set(r+1,"".concat(e.match(/^a=rtcp-fb:\d+/)[0]," rrtr"))}));for(var r=T(n),i=0;i<r.length;i++){var o=_(r[i],2),a=o[0],s=o[1];t.splice(a+i,0,s)}return t.join("\r\n")}},{key:"addSPSDescription",value:function(e){var t=P1(e);return t.media.forEach((function(e){e.type===UB.VIDEO&&e.fmtp.forEach((function(e){e.config+=";sps-pps-idr-in-keyframe=1"}))})),M1(t)}},{key:"removeSDESDescription",value:function(e){var t=["urn:ietf:params:rtp-hdrext:sdes:mid","urn:ietf:params:rtp-hdrext:sdes:rtp-stream-id","urn:ietf:params:rtp-hdrext:sdes:repaired-rtp-stream-id"],n=P1(e);return n.media.forEach((function(e){e.ext&&(e.ext=e.ext.filter((function(e){return!t.includes(e.uri)})))})),M1(n)}},{key:"isSubscriptionStateNotChanged",value:function(e){return JSON.stringify(e)===JSON.stringify(this.subscribeState)}},{key:"subscribe",value:function(e,t){return HF(this,null,p().mark((function n(){var r,i,o;return p().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(n.prev=0,n.t0=(null==(r=this._peerConnection)?void 0:r.connectionState)===cH.NEW||(null==(i=this._peerConnection)?void 0:i.connectionState)===cH.CONNECTING,!n.t0){n.next=5;break}return n.next=5,this.waitForPeerConnectionConnected();case 5:if(!this.isSubscriptionStateNotChanged(e)){n.next=12;break}if(n.t1=this._peerConnection,n.t1){n.next=11;break}return this.initialize(),n.next=11,this.connect(e);case 11:return n.abrupt("return");case 12:if(this._log.info("subscribe ".concat(t," ").concat(JSON.stringify(e))),!this._peerConnection&&!this._isSDPExchanging){n.next=19;break}return o="subscribe_change",Object.values(e).find((function(e){return!0===e}))||(o="unsubscribe"),n.next=17,this.sendSubscription(o,e);case 17:n.next=22;break;case 19:return this.initialize(),n.next=22,this.connect(e);case 22:n.next=27;break;case 24:throw n.prev=24,n.t2=n.catch(0),this._room.isJoined&&this.isStreamUnpublished(t)?(this._log.warn("".concat(n.t2.message," ").concat(JSON.stringify(this.muteState))),new tB({code:ZF.REMOTE_STREAM_NOT_EXIST,message:"remote user ".concat(this.userId," unpublished stream")})):n.t2;case 27:case"end":return n.stop()}}),n,this,[[0,24]])})))}},{key:"unsubscribe",value:function(e){return HF(this,arguments,(function(e){var t=this,n=e.remoteTracks,r=e.streamType;return p().mark((function e(){var i,o;return p().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if("CONNECTED"!==t._currentState||("main"!==r||t.isMainStreamSubscribed)&&("auxiliary"!==r||t.isAuxStreamSubscribed)){e.next=3;break}return t._log.info("".concat(r," stream already unsubscribed")),e.abrupt("return");case 3:return i=xF({},t.subscribeState),n.forEach((function(e){switch(e.mediaType){case 1:i.audio=!1;break;case 4:i.video=!1;break;case 8:i.smallVideo=!1;break;case 2:i.auxiliary=!1}})),o="subscribe_change",Object.values(i).find((function(e){return!0===e}))||(o="unsubscribe"),t._log.info("".concat("unsubscribe"===o?o:"subscribe"," ").concat(r," [").concat(U1(i),"]")),e.next=10,t.sendSubscription(o,i);case 10:"unsubscribe"===o&&(t.closePeerConnection(),t.emitConnectionStateChangedEvent("DISCONNECTED"));case 11:case"end":return e.stop()}}),e)}))()}))}},{key:"sendSubscription",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.subscribeState,r={srcTinyId:this.tinyId,srcUserId:this.userId},i=r1,o=z0.UNSUBSCRIBE_RESULT;return"subscribe_change"===e&&(r={audio:n.audio,bigVideo:n.video,auxVideo:n.auxiliary,smallVideo:n.smallVideo,srcTinyId:this.tinyId},i=i1,o=z0.SUBSCRIBE_CHANGE_RESULT),this._signalChannel.sendWaitForResponse({command:i,data:r,responseCommand:o,timeout:1e4}).then((function(n){var r=n.data;if(0!==r.code){var i=new tB({code:r.code,message:rK({key:ZJ.ERROR_MESSAGE,data:{type:e,message:r.message}})});throw t._log.error(i),i}}))}},{key:"connect",value:function(){return HF(this,arguments,(function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.subscribeState;return p().mark((function n(){return p().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.prev=0,n.next=3,e.exchangeSDP(t);case 3:return n.next=5,e.waitForPeerConnectionConnected();case 5:n.next=10;break;case 7:throw n.prev=7,n.t0=n.catch(0),e.closePeerConnection(!0),n.t0;case 10:case"end":return n.stop()}}),n,null,[[0,7]])}))()}))}},{key:"exchangeSDP",value:function(e){return HF(this,null,p().mark((function t(){var n,r,i,o,a,s;return p().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"),n=this._peerConnection.localDescription,r=n.type,i=n.sdp,o={type:r,sdp:i,srcUserId:this.userId,srcTinyId:this.tinyId,audio:e.audio,bigVideo:e.video,auxVideo:e.auxiliary,smallVideo:e.smallVideo},t.next=11,this._signalChannel.sendWaitForResponse({command:n1,commandDesc:"exchange sdp",data:o,responseCommand:z0.SUBSCRIBE_RESULT,timeout:_H});case 11:if(a=t.sent,this._peerConnection){t.next=15;break}throw s=new tB({code:ZF.INVALID_OPERATION,message:rK({key:ZJ.CONNECTION_CLOSED})}),this._log.warn(s),s;case 15:return t.next=17,this.onSubscribeResult(a);case 17:this._isSDPExchanging=!1,t.next=23;break;case 20:throw t.prev=20,t.t0=t.catch(0),this._isSDPExchanging=!1,t.t0;case 23:case"end":return t.stop()}}),t,this,[[0,20]])})))}},{key:"createOffer",value:function(){return HF(this,null,p().mark((function e(){var t,n,r;return p().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t={voiceActivityDetection:!1},HK()&&this._sdpSemantics===gH?(this._peerConnection.addTransceiver(UB.AUDIO,{direction:FB.RECVONLY}),this._peerConnection.addTransceiver(UB.VIDEO,{direction:FB.RECVONLY}),this._peerConnection.addTransceiver(UB.VIDEO,{direction:FB.RECVONLY})):(t.offerToReceiveAudio=!0,t.offerToReceiveVideo=!0),e.next=4,this._peerConnection.createOffer(t);case 4:if(!(n=e.sent).sdp){e.next=11;break}return e.next=8,IK();case 8:r=e.sent,r.isH264DecodeSupported||(this._log.warn("remove h264 desc from sdp"),n.sdp=V1(n.sdp)),n.sdp=this.addRRTRLine(n.sdp),n.sdp=this.addSPSDescription(n.sdp),n.sdp=L1(n.sdp),this._sdpSemantics===gH&&(n.sdp=this.removeSDESDescription(n.sdp));case 11:return e.next=13,this.setOffer(n);case 13:case"end":return e.stop()}}),e,this)})))}},{key:"onSubscribeResult",value:function(e){return HF(this,null,p().mark((function t(){var n,r,i,o,a,s,c;return p().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=e&&e.data||{},r=n.code,i=n.message,o=void 0===i?"":i,a=e&&e.data&&e.data.data||{},s=a.type,c=a.sdp,r!==EH){t.next=3;break}throw new tB({code:ZF.NOT_SUPPORTED_H264,message:rK({key:ZJ.NOT_SUPPORTED_H264DECODE})});case 3:if(t.prev=3,0===r){t.next=6;break}throw new tB({code:r,message:rK({key:ZJ.EXCHANGE_SDP_FAILED,data:{errMsg:o}})});case 6:return this._log.debug("accept remote answer: ".concat(c)),t.next=9,this.setAnswer({type:s,sdp:c});case 9:this.updateSSRC(c),t.next=15;break;case 12:throw t.prev=12,t.t0=t.catch(3),this._log.error(t.t0),t.t0;case 15:case"end":return t.stop()}}),t,this,[[3,12]])})))}},{key:"updateSSRC",value:function(e){var t=this;try{P1(e).media.forEach((function(e){if(e.ssrcs)if(e.type===UB.AUDIO){var n=e.ssrcs.find((function(e){var t;return null==(t=e.value)?void 0:t.includes(XB)}));n&&(t.ssrc.audio=Number(n.id))}else{var r=e.ssrcs.find((function(e){var t;return null==(t=e.value)?void 0:t.includes(XB)})),i=e.ssrcs.find((function(e){var t;return null==(t=e.value)?void 0:t.includes(QB)}));r&&(t.ssrc.video=Number(r.id)),i&&(t.ssrc.auxiliary=Number(i.id))}}))}catch(hH){}}},{key:"getMainStreamVideoTrackId",value:function(){return this.remoteVideoTrack&&this.remoteVideoTrack.mediaTrack?this.remoteVideoTrack.mediaTrack.id:""}},{key:"getAuxStreamVideoTrackId",value:function(){return this.remoteAuxiliaryTrack&&this.remoteAuxiliaryTrack.mediaTrack?this.remoteAuxiliaryTrack.mediaTrack.id:""}},{key:"reconnect",value:function(){return HF(this,null,p().mark((function e(){var n,r=this;return p().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(BF(t.prototype,this,"beforeReconnect").call(this)<0){e.next=14;break}return e.prev=1,this.closePeerConnection(),this.initialize(),e.next=6,this.connect();case 6:this.stopReconnection(),this._log.warn("reconnect() success"),e.next=14;break;case 10:e.prev=10,e.t0=e.catch(1),n=rj(this._reconnectionCount),this._log.warn("reconnect() timeout, try again after ".concat(n/1e3,"s")),this._reconnectionTimer=setTimeout((function(){r.clearReconnectionTimer(),r.reconnect()}),n);case 14:case"end":return e.stop()}}),e,this,[[1,10]])})))}},{key:"getIsReconnecting",value:function(){return this._isReconnecting}},{key:"clearReconnectionTimer",value:function(){-1!==this._reconnectionTimer&&(clearTimeout(this._reconnectionTimer),this._reconnectionTimer=-1)}},{key:"getCurrentState",value:function(){return this._currentState}},{key:"setDelay",value:function(e){var t=e.audioDelay,n=e.videoDelay;this.remoteAudioTrack.stat.end2EndDelay=t,this.remoteVideoTrack.stat.end2EndDelay=n}},{key:"audioReceiver",get:function(){var e;return(null==(e=this._peerConnection)?void 0:e.getReceivers()[0])||null}}])}(x1);UF([rY((function(e){return function(){for(var t=this,n=arguments.length,r=new Array(n),i=0;i<n;i++)r[i]=arguments[i];return new Promise((function(n,i){var o=function(e){t._emitter.off("closed",o),i(new tB({code:ZF.API_CALL_ABORTED,message:rK({key:ZJ.CONNECTION_ABORTED,data:e})}))};t._emitter.on("closed",o),e.apply(t,r).then(n,i).finally((function(){t._emitter.off("closed",o)}))}))}}))],F1.prototype,"subscribe",1),UF([hY(521717,!1)],F1.prototype,"unsubscribe",1),UF([tY(x1.prototype.afterConnect),eY(x1.prototype.beforeConnect)],F1.prototype,"connect",1);var B1=F1,H1={voiceActivityDetection:!1},j1=function(e){function t(e){var n;return i(this,t),n=r(this,t,[OF(xF({},e),{isUplink:!0})]),FF(n,"localMainAudioTrack",null),FF(n,"localMainVideoTrack",null),FF(n,"localAuxAudioTrack",null),FF(n,"localAuxVideoTrack",null),FF(n,"ssrc",{audio:0,video:0,small:0,auxiliary:0}),FF(n,"_isPublishingAux",!1),FF(n,"_publishingLocalAudioTrack"),FF(n,"_publishingLocalVideoTrack"),FF(n,"_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}),FF(n,"flag",0),n}return d(t,e),s(t,[{key:"videoCodec",get:function(){return this._mediaSettings.videoCodec.toLowerCase()||"h264"}},{key:"isMainStreamPublished",get:function(){return!(!this.localMainAudioTrack&&!this.localMainVideoTrack)}},{key:"isAuxStreamPublished",get:function(){return!(!this.localAuxVideoTrack&&!this.localAuxAudioTrack)}},{key:"publishState",get:function(){var e,t,n,r,i=this,o={audio:!1,bigVideo:!1,smallVideo:!1,auxVideo:!1};if(this._peerConnection){var a=this._peerConnection.getSenders();a&&(BK()?(o.audio=!(null==(e=a[0])||!e.track),o.bigVideo=!(null==(t=a[1])||!t.track),o.smallVideo=!(null==(n=a[2])||!n.track),o.auxVideo=!(null==(r=a[3])||!r.track)):a.forEach((function(e){e.track&&(e.track.kind===UB.AUDIO?o.audio=!0:(o.bigVideo=!0,i._room.videoManager.hasSmall&&(o.smallVideo=!0)))})))}return o}},{key:"initialize",value:function(){y(t,"initialize",this,3)([]),this.installEvents()}},{key:"reset",value:function(){this._isReconnecting&&this.stopReconnection(),this.closePeerConnection(),this.uninstallEvents()}},{key:"close",value:function(e){y(t,"close",this,3)([e]),this.reset(),this.emitConnectionStateChangedEvent("DISCONNECTED")}},{key:"installEvents",value:function(){this._emitter.listeners("connection-state-changed").includes(this.handleConnectionStateChange)||this._emitter.on("connection-state-changed",this.handleConnectionStateChange,this)}},{key:"uninstallEvents",value:function(){this._emitter.off("connection-state-changed",this.handleConnectionStateChange,this)}},{key:"emitConnectionStateChangedEvent",value:function(e,n){var r,i,o,a=this._currentState,s=y(t,"emitConnectionStateChangedEvent",this,3)([e]);return s&&a!==e&&(n?n.emit("connection-state-changed",{prevState:a,state:e}):(null==(r=this.localMainVideoTrack)||r.emit("connection-state-changed",{prevState:a,state:e}),null==(i=this.localAuxVideoTrack)||i.emit("connection-state-changed",{prevState:a,state:e}),null==(o=this._publishingLocalVideoTrack)||o.emit("connection-state-changed",{prevState:a,state:e}))),s}},{key:"publish",value:function(e){return HF(this,arguments,(function(e){var t=this,n=e.localAudioTrack,r=e.localVideoTrack,i=e.isAuxiliary;return p().mark((function e(){var o;return p().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t._peerConnection||t.initialize(),n&&(t._publishingLocalAudioTrack=n),r&&(t._publishingLocalVideoTrack=r),t._isPublishingAux=i,r&&!i&&r.small&&(o=t._room.videoManager.smallTrack),t.sendMediaSettings(),!HK()){e.next=8;break}return e.next=6,t.publishByTransceiver({localAudioTrack:n,localVideoTrack:r,smallTrack:o,isAuxiliary:i});case 6:e.next=10;break;case 8:return e.next=10,t.publishByAddTrack({localAudioTrack:n,localVideoTrack:r,smallTrack:o});case 10:t._publishingLocalAudioTrack=null,t._publishingLocalVideoTrack=null,t._isPublishingAux=!1,i?(r&&(t.localAuxVideoTrack=r),n&&(t.localAuxAudioTrack=n)):(r&&(t.localMainVideoTrack=r),n&&(t.localMainAudioTrack=n)),t.installTrackMuteEvents(n,r),t.sendMutedFlag();case 16:case"end":return e.stop()}}),e)}))()}))}},{key:"publishByTransceiver",value:function(e){return HF(this,arguments,(function(e){var t=this,n=e.localAudioTrack,r=e.localVideoTrack,i=e.smallTrack,o=e.isAuxiliary;return p().mark((function e(){var a,s,c,u,l,d;return p().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t._log.info("publish by transceiver"),a=new MediaStream,s=null==r?void 0:r.outMediaTrack,(c=null==n?void 0:n.outMediaTrack)&&a.addTrack(c),s&&a.addTrack(s),0!==(u=t._peerConnection.getTransceivers()).length){e.next=13;break}return t._peerConnection.addTransceiver(c||UB.AUDIO,{direction:FB.SENDONLY,streams:[a]}),t._peerConnection.addTransceiver(o?UB.VIDEO:s||UB.VIDEO,{direction:FB.SENDONLY,streams:[a]}),t._peerConnection.addTransceiver(i||UB.VIDEO,{direction:FB.SENDONLY,streams:[a]}),t._peerConnection.addTransceiver(o&&s||UB.VIDEO,{direction:FB.SENDONLY,streams:[a]}),e.next=11,t.connect();case 11:e.next=41;break;case 13:if(l=[],e.t0=c,!e.t0){e.next=21;break}return u[0].sender.track||l.push(0),e.next=19,u[0].sender.replaceTrack(c);case 19:return e.next=21,t.setBandwidth({bandwidth:(null==n?void 0:n.profile.bitrate)||40,type:UB.AUDIO});case 21:if(!s){e.next=35;break}return d=o?3:1,e.next=25,u[d].sender.replaceTrack(s);case 25:return e.next=27,t.setBandwidth({bandwidth:r.profile.bitrate,type:UB.VIDEO,videoType:o?UB.AUXILIARY:UB.BIG});case 27:if(l.push(d),e.t1=i,!e.t1){e.next=35;break}return e.next=32,u[2].sender.replaceTrack(i);case 32:return e.next=34,t.setBandwidth({bandwidth:r.small.bitrate,type:UB.VIDEO,videoType:UB.SMALL});case 34:l.push(2);case 35:return e.next=37,t.setTransceiverDirection(FB.SENDONLY,l);case 37:return e.next=39,t.doPublishChange();case 39:null==r||r.emit("connection-state-changed",{prevState:"DISCONNECTED",state:"CONNECTING"}),null==r||r.emit("connection-state-changed",{prevState:"CONNECTING",state:"CONNECTED"});case 41:case"end":return e.stop()}}),e)}))()}))}},{key:"publishByAddTrack",value:function(e){return HF(this,arguments,(function(e){var t=this,n=e.localAudioTrack,r=e.localVideoTrack,i=e.smallTrack;return p().mark((function e(){var o,a,s,c;return p().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t._log.info("publish by addtrack"),o=null==r?void 0:r.outMediaTrack,a=null==n?void 0:n.outMediaTrack,!t._peerConnection||"new"===t._peerConnection.connectionState){e.next=12;break}if(e.t0=n&&a,!e.t0){e.next=7;break}return e.next=7,t.addTrack(n);case 7:if(e.t1=o,!e.t1){e.next=11;break}return e.next=11,t.addTrack(r);case 11:return e.abrupt("return");case 12:return s=new MediaStream,a&&s.addTrack(a),o&&s.addTrack(o),a&&t._peerConnection.addTrack(a,s),o&&(t._peerConnection.addTrack(o,s),i)&&((c=new MediaStream).addTrack(i),t._peerConnection.addTrack(i,c)),e.next=16,t.connect();case 16:case"end":return e.stop()}}),e)}))()}))}},{key:"enableSmall",value:function(e){return HF(this,null,p().mark((function t(){var n;return p().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=this._peerConnection.getTransceivers(),!e){t.next=10;break}if(t.t0=this._room.videoManager.smallTrack,!t.t0){t.next=8;break}return t.next=6,n[2].sender.replaceTrack(this._room.videoManager.smallTrack);case 6:return t.next=8,this.setTransceiverDirection(FB.SENDONLY,[2]);case 8:t.next=14;break;case 10:return t.next=12,n[2].sender.replaceTrack(null);case 12:return t.next=14,this.setTransceiverDirection(FB.INACTIVE,[2]);case 14:return this.updateMediaSettings(),t.next=17,this.doPublishChange();case 17:case"end":return t.stop()}}),t,this)})))}},{key:"installTrackMuteEvents",value:function(){for(var e=this,t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];n.forEach((function(t){t&&(null==t||t.on("mute",e.sendMutedFlag,e),null==t||t.on("unmute",e.sendMutedFlag,e))}))}},{key:"uninstallTrackMuteEvents",value:function(){for(var e=this,t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];n.forEach((function(t){t&&(null==t||t.off("mute",e.sendMutedFlag,e),null==t||t.off("unmute",e.sendMutedFlag,e))}))}},{key:"unpublish",value:function(e){return HF(this,arguments,(function(e){var t=this,n=e.localAudioTrack,r=e.localVideoTrack;return p().mark((function e(){var i,o,a,s;return p().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(BK()){e.next=16;break}if(!n||!n.outMediaTrack||r||!t.localMainVideoTrack){e.next=6;break}return e.next=4,t.removeTrack(n);case 4:return t.localMainAudioTrack=null,e.abrupt("return");case 6:if(!r||!r.outMediaTrack||n||!t.localMainAudioTrack){e.next=11;break}return e.next=9,t.removeTrack(r);case 9:return t.localMainVideoTrack=null,e.abrupt("return");case 11:return e.next=13,t.doUnpublish();case 13:return t.uninstallTrackMuteEvents(n,r),t.emitConnectionStateChangedEvent("DISCONNECTED",r),e.abrupt("return");case 16:if(i=r&&r===t.localAuxVideoTrack,o=null==r?void 0:r.outMediaTrack,a=t._peerConnection.getSenders(),s=[],e.t0=n,!e.t0){e.next=25;break}if(i?t.localAuxAudioTrack=null:t.localMainAudioTrack=null,e.t1=!t.localAuxAudioTrack&&!t.localMainAudioTrack,!e.t1){e.next=25;break}return e.next=24,a[0].replaceTrack(null);case 24:s.push(0);case 25:if(e.t2=o,!e.t2){e.next=42;break}if(!i){e.next=35;break}return e.next=30,a[3].replaceTrack(null);case 30:t.localAuxVideoTrack=null,t._mediaSettings=OF(xF({},t._mediaSettings),{auxVideoBps:0,auxVideoFps:0,auxVideoWidth:0,auxVideoHeight:0}),s.push(3),e.next=42;break;case 35:return e.next=37,a[1].replaceTrack(null);case 37:return e.next=39,a[2].replaceTrack(null);case 39:t.localMainVideoTrack=null,t._mediaSettings=OF(xF({},t._mediaSettings),{videoWidth:0,videoHeight:0,videoBps:0,videoFps:0,audioFs:0,audioChannel:0,audioBps:0,smallVideoWidth:0,smallVideoHeight:0,smallVideoFps:0,smallVideoBps:0}),s.push(1,2);case 42:if(!t.isMainStreamPublished&&!t.isAuxStreamPublished){e.next=49;break}return e.next=45,t.setTransceiverDirection(FB.INACTIVE,s);case 45:return e.next=47,t.doPublishChange(!1);case 47:e.next=51;break;case 49:return e.next=51,t.doUnpublish();case 51:t.uninstallTrackMuteEvents(n,r),null==r||r.emit("connection-state-changed",{prevState:t._currentState,state:"DISCONNECTED"});case 53:case"end":return e.stop()}}),e)}))()}))}},{key:"doPublishChange",value:function(){var e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];return HF(this,null,p().mark((function t(){var n,r;return p().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n={state:this.publishState,constraintConfig:this._mediaSettings},t.next=3,this._signalChannel.sendWaitForResponse({command:e1,data:n,responseCommand:z0.PUBLISH_STATE_CHANGE_RESULT,enableLog:e});case 3:r=t.sent,this.checkPublishResultCode(r.data.code,r.data.message);case 5:case"end":return t.stop()}}),t,this)})))}},{key:"doUnpublish",value:function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return this._signalChannel.sendWaitForResponse({command:t1,commandDesc:"unpublish",responseCommand:z0.UNPUBLISH_RESULT,enableLog:e}).catch((function(e){if(e.getCode()===ZF.API_CALL_TIMEOUT)return Promise.resolve();throw e}))}},{key:"updateMediaSettings",value:function(){var e=this._room.checkSystemResult.detail,t=e.isH264EncodeSupported,n=e.isVp8EncodeSupported;t?this._mediaSettings.videoCodec="H264":n&&(this._mediaSettings.videoCodec="VP8");var r=this._publishingLocalAudioTrack||this.localMainAudioTrack||this.localAuxAudioTrack,i=this.localMainVideoTrack,o=this.localAuxVideoTrack;if(this._publishingLocalVideoTrack&&(this._isPublishingAux?o=this._publishingLocalVideoTrack:i=this._publishingLocalVideoTrack),qK){if(r&&r.outMediaTrack){var a=r.outMediaTrack.getSettings();this._mediaSettings.audioChannel=a.channelCount||1,this._mediaSettings.audioBps=1e3*r.profile.bitrate,this._mediaSettings.audioFs=a.sampleRate||0}if(i&&i.outMediaTrack){var s=i.outMediaTrack.getSettings();this._mediaSettings.videoWidth=s.width||0,this._mediaSettings.videoHeight=s.height||0,this._mediaSettings.videoFps=s.frameRate||0,this._mediaSettings.videoBps=1e3*i.profile.bitrate,i.small&&(this._mediaSettings.smallVideoWidth=i.small.width,this._mediaSettings.smallVideoHeight=i.small.height,this._mediaSettings.smallVideoFps=i.small.frameRate,this._mediaSettings.smallVideoBps=1e3*i.small.bitrate)}if(o&&o.outMediaTrack){var c=o.outMediaTrack.getSettings();this._mediaSettings.auxVideoWidth=c.width||0,this._mediaSettings.auxVideoHeight=c.height||0,this._mediaSettings.auxVideoFps=c.frameRate||0,this._mediaSettings.auxVideoBps=1e3*o.profile.bitrate}}else r&&r.outMediaTrack&&(this._mediaSettings.audioChannel=r.profile.channelCount,this._mediaSettings.audioBps=1e3*r.profile.bitrate,this._mediaSettings.audioFs=r.profile.sampleRate),i&&i.outMediaTrack&&(this._mediaSettings.videoWidth=i.profile.width,this._mediaSettings.videoHeight=i.profile.height,this._mediaSettings.videoFps=i.profile.frameRate,this._mediaSettings.videoBps=1e3*i.profile.bitrate);this._log.info("updateMediaSettings: ".concat(JSON.stringify(this._mediaSettings)))}},{key:"sendMediaSettings",value:function(){var e=this;this.updateMediaSettings(),this._signalChannel.sendWaitForResponse({command:v1,data:this._mediaSettings,responseCommand:z0.UPDATE_CONSTRAINT_CONFIG_RES}).then((function(t){0!==t.data.code&&e._log.warn(t.data.message)})).catch((function(){}))}},{key:"addTrack",value:function(e){return HF(this,null,p().mark((function t(){var n;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(n=e===this.localAuxAudioTrack||e===this.localAuxVideoTrack,this._log.info("is adding ".concat(e.kind," track to current published local ").concat(n?UB.AUXILIARY:UB.MAIN," stream")),!HK()){t.next=9;break}return t.next=7,this.addTrackByTransceiver(e,n);case 7:t.next=11;break;case 9:return t.next=11,this.addTrackBySender(e);case 11:case"end":return t.stop()}}),t,this)})))}},{key:"addTrackByTransceiver",value:function(e,t){return HF(this,null,p().mark((function n(){var r,i,o;return p().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(e.mediaTrack){n.next=2;break}return n.abrupt("return");case 2:if(i=this._peerConnection.getTransceivers(),e.kind!==UB.AUDIO){n.next=8;break}return n.next=6,i[0].sender.replaceTrack(e.outMediaTrack);case 6:n.next=19;break;case 8:return o=t?3:1,n.next=11,i[o].sender.replaceTrack(e.outMediaTrack);case 11:if(n.t0=1===o&&null!=(r=this.localMainVideoTrack)&&r.small,!n.t0){n.next=15;break}return n.next=15,i[2].sender.replaceTrack(this._room.videoManager.smallTrack);case 15:if(n.t1=i[o].direction===FB.INACTIVE,!n.t1){n.next=19;break}return n.next=19,this.setTransceiverDirection(FB.SENDONLY,[o]);case 19:return this.updateMediaSettings(),n.next=22,this.doPublishChange();case 22:case"end":return n.stop()}}),n,this)})))}},{key:"addTrackBySender",value:function(e){return HF(this,null,p().mark((function t(){var n,r,i,o,a;return p().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(e.outMediaTrack){t.next=2;break}return t.abrupt("return");case 2:if(n=e.outMediaTrack,t.t0=BK()&&this._peerConnection.getTransceivers().findIndex((function(e){return"stopped"===e.direction}))>=0,!t.t0){t.next=8;break}return this._log.warn("transceiver is stopping, negotiate sdp first"),t.next=8,this.updateOffer("remove",n);case 8:if(r=this._peerConnection.getSenders().find((function(e){return e.track&&e.track.kind===n.kind})),!r||!r.track){t.next=15;break}return this._log.warn("sender already exists, remove sender first"),i=r.track,this.removeSender(r),t.next=15,this.updateOffer("remove",i);case 15:return n&&this._peerConnection.addTrack(n,new MediaStream([n])),n.kind===UB.VIDEO&&e instanceof EY&&e.small&&(o=new MediaStream,a=this._room.videoManager.smallTrack,o.addTrack(a),this._peerConnection.addTrack(a,o)),t.next=18,this.updateOffer("add",n);case 18:case"end":return t.stop()}}),t,this)})))}},{key:"isNeedToResetOfferOrder",value:function(){if(this._sdpSemantics===yH||!this._peerConnection||!this._peerConnection.localDescription)return!1;for(var e=this._peerConnection.localDescription.sdp,t=P1(e),n=0;n<t.media.length;n++)if(0===Number(t.media[n].mid)&&t.media[n].type===UB.VIDEO)return!0;return!1}},{key:"removeSender",value:function(e){var t=null;BK()&&(t=this._peerConnection.getTransceivers().find((function(t){return t.sender&&t.sender.track===e.track}))),this._peerConnection.removeTrack(e),t&&oj(t.stop)&&(this._log.info("stop transceiver"),t.stop())}},{key:"removeTrack",value:function(e){return HF(this,null,p().mark((function t(){var n;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(n=e===this.localAuxAudioTrack||e===this.localAuxVideoTrack,this._log.info("is removing ".concat(e.kind," track from current published local ").concat(n?UB.AUXILIARY:UB.MAIN," stream")),!HK()){t.next=9;break}return t.next=7,this.removeTrackByTransceiver(e,n);case 7:t.next=11;break;case 9:return t.next=11,this.removeTrackBySender(e);case 11:case"end":return t.stop()}}),t,this)})))}},{key:"removeTrackByTransceiver",value:function(e,t){return HF(this,null,p().mark((function n(){var r,i;return p().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(e.outMediaTrack){n.next=2;break}return n.abrupt("return");case 2:if(r=this._peerConnection.getTransceivers(),e.kind!==UB.AUDIO){n.next=8;break}return n.next=6,r[0].sender.replaceTrack(null);case 6:n.next=17;break;case 8:return i=t?3:1,n.next=11,r[i].sender.replaceTrack(null);case 11:if(n.t0=1===i&&e.small,!n.t0){n.next=15;break}return n.next=15,r[2].sender.replaceTrack(null);case 15:return n.next=17,this.setTransceiverDirection(FB.INACTIVE,[i]);case 17:return this.updateMediaSettings(),n.next=20,this.doPublishChange();case 20:case"end":return n.stop()}}),n,this)})))}},{key:"setTransceiverDirection",value:function(e,t){return HF(this,null,p().mark((function n(){var r,i,o,a,s,c;return p().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(fG){n.next=2;break}return n.abrupt("return");case 2:if(r=!1,i=!1,this._log.info("setting transceiver ".concat(t.join(",")," direction to ").concat(e)),o=this._peerConnection.getTransceivers(),t.forEach((function(t){o[t].direction!==e&&(o[t].direction=e,r=!0)})),!r){n.next=12;break}return this._log.info("updating offer"),n.next=9,this._peerConnection.createOffer();case 9:return a=n.sent,n.next=12,this.setOffer(a);case 12:if(s=-1,c=this._peerConnection.remoteDescription.sdp.split("\r\n").map((function(n){if(n.match(new RegExp("a=(".concat(FB.INACTIVE,"|").concat(FB.RECVONLY,"|").concat(FB.SENDONLY,")")))&&s++,t.includes(s)){if(e===FB.INACTIVE&&n.includes("a=".concat(FB.RECVONLY)))return i=!0,"a=".concat(e);if(e===FB.SENDONLY&&n.includes("a=".concat(FB.INACTIVE)))return i=!0,"a=".concat(FB.RECVONLY)}return n})).join("\r\n"),n.t0=i,!n.t0){n.next=18;break}return this._log.info("updating answer"),n.next=18,this.setAnswer({type:"answer",sdp:c});case 18:case"end":return n.stop()}}),n,this)})))}},{key:"removeTrackBySender",value:function(e){return HF(this,null,p().mark((function t(){var n,r=this;return p().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(e.outMediaTrack){t.next=2;break}return t.abrupt("return");case 2:if(e.kind!==UB.VIDEO||!this.isNeedToResetOfferOrder()||!this.localMainAudioTrack){t.next=8;break}return this.reset(),this.initialize(),t.next=7,this.publish({localAudioTrack:this.localMainAudioTrack,isAuxiliary:!1});case 7:return t.abrupt("return");case 8:return n=this._peerConnection.getSenders().find((function(t){return t.track===e.outMediaTrack})),n&&(this.removeSender(n),e.kind===UB.VIDEO&&e.small&&this._peerConnection.getSenders().forEach((function(e){e.track&&e.track.kind===UB.VIDEO&&r.removeSender(e)}))),t.next=12,this.updateOffer("remove",e.outMediaTrack);case 12:case"end":return t.stop()}}),t,this)})))}},{key:"replaceTrack",value:function(e){return HF(this,null,p().mark((function t(){var n,r,i,o;return p().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if((r=null==(n=this._peerConnection)?void 0:n.getSenders())&&0!==r.length&&e.mediaTrack){t.next=3;break}return t.abrupt("return",!1);case 3:if(i=HK()?e.kind===UB.AUDIO?r[0]:r[1]:r.find((function(t){return t.track&&t.track.kind===e.kind})),i){t.next=5;break}return t.abrupt("return",!1);case 5:if(o=e===this.localAuxAudioTrack||e===this.localAuxVideoTrack,this._log.info("is replacing ".concat(e.kind," track on ").concat(o?UB.AUXILIARY:UB.MAIN," stream")),e.kind!==UB.AUDIO){t.next=12;break}return t.next=10,i.replaceTrack(e.outMediaTrack);case 10:case 19:t.next=23;break;case 12:if(t.t0=e.kind===UB.VIDEO,!t.t0){t.next=23;break}if(!o){t.next=21;break}if(t.t1=r[3],!t.t1){t.next=19;break}return t.next=19,r[3].replaceTrack(e.outMediaTrack);case 21:return t.next=23,i.replaceTrack(e.outMediaTrack);case 23:return t.abrupt("return",!0);case 24:case"end":return t.stop()}}),t,this)})))}},{key:"updateOffer",value:function(e,t){return HF(this,null,p().mark((function n(){var r,i,o,a,s,c,u;return p().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.prev=0,n.next=3,this._peerConnection.createOffer(H1);case 3:return r=n.sent,fG&&r.sdp&&(r.sdp=this.setSDPDirection(r.sdp,"sendrecv")),n.next=7,this.setOffer(r);case 7:return i=this.updateMediaSettings(),o={action:e,trackId:t.id,kind:t.kind===UB.VIDEO?"bigVideo":t.kind,type:"offer",sdp:this._peerConnection.localDescription.sdp,constraintConfig:i,state:this.publishState},this._log.info("createOffer success, sending updated offer to remote server"),this._log.debug("updatedOffer: ".concat(o.sdp)),n.next=11,this._signalChannel.sendWaitForResponse({command:q0,data:o,responseCommand:z0.UPDATE_OFFER_RESULT,timeout:vH,commandDesc:"update offer"});case 11:return a=n.sent,s=a.data,c=s.code,u=s.message,0!==c&&this.checkPublishResultCode(c,u),n.next=18,this.acceptAnswer(a.data.data);case 18:r.sdp&&this.updateSSRC(r.sdp),n.next=24;break;case 21:throw n.prev=21,n.t0=n.catch(0),this._log.error(n.t0),n.t0;case 24:case"end":return n.stop()}}),n,this,[[0,21]])})))}},{key:"setBandwidth",value:function(e){return HF(this,arguments,(function(e){var t=this,n=e.bandwidth,r=e.type,i=e.videoType,o=e.sdp;return p().mark((function e(){var a,s,c,u;return p().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(KK()){e.next=2;break}return e.abrupt("return",o?r===UB.VIDEO?t.updateVideoBandwidthRestriction(o,n,i):t.updateAudioBandwidthRestriction(o,n):void 0);case 2:if(s=t._peerConnection.getSenders(),HK()?(c=0,r===UB.VIDEO&&(c=i===UB.SMALL?2:i===UB.AUXILIARY?3:1),a=s[c]):a=s.find((function(e){return e.track&&e.track.kind===r})),!a){e.next=18;break}return(!(u=a.getParameters()).encodings||0===u.encodings.length)&&(u.encodings=[{}]),u.encodings[0].maxBitrate=1e3*n,e.prev=7,e.next=10,a.setParameters(u);case 10:return t._log.info("".concat(i||"").concat(r," bandwidth ").concat(n," kbps")),e.abrupt("return",o);case 14:if(e.prev=14,e.t0=e.catch(7),t._log.info("failed to set bandwidth by setting maxBitrate: ".concat(e.t0)),!o){e.next=18;break}return e.abrupt("return",r===UB.VIDEO?t.updateVideoBandwidthRestriction(o,n,i):t.updateAudioBandwidthRestriction(o,n));case 18:return e.abrupt("return",o);case 19:case"end":return e.stop()}}),e,null,[[7,14]])}))()}))}},{key:"updateVideoBandwidthRestriction",value:function(e,t,n){var r="AS";fG&&(r="TIAS",t*=1e3);var i=0,o=-1;return n===UB.SMALL?i=1:n===UB.AUXILIARY&&(i=2),e=e.replace(/m=video (.*)\r\nc=IN (.*)\r\n/g,(function(e){return(o+=1)===i?"".concat(e,"b=").concat(r,":").concat(t,"\r\n"):e}))}},{key:"updateAudioBandwidthRestriction",value:function(e,t){var n="AS";return fG&&(n="TIAS",t*=1e3),e=e.replace(/m=audio (.*)\r\nc=IN (.*)\r\n/,"m=audio $1\r\nc=IN $2\r\nb=".concat(n,":").concat(t,"\r\n"))}},{key:"removeBandwidthRestriction",value:function(e){return e.replace(/b=AS:.*\r\n/,"").replace(/b=TIAS:.*\r\n/,"")}},{key:"removeVideoOrientation",value:function(e){return e.replace(/urn:3gpp:video-orientation/,"")}},{key:"connect",value:function(){return HF(this,null,p().mark((function e(){return p().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,this.exchangeSDP();case 3:return e.next=5,this.waitForPeerConnectionConnected();case 5:e.next=10;break;case 7:throw e.prev=7,e.t0=e.catch(0),this.closePeerConnection(!0),this.uninstallEvents(),e.t0;case 10:case"end":return e.stop()}}),e,this,[[0,7]])})))}},{key:"exchangeSDP",value:function(){return HF(this,null,p().mark((function e(){return p().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,this.createOffer();case 3:return this._log.info("createOffer success, sending offer to remote server"),e.next=6,this.doExchangeSDP();case 6:e.next=11;break;case 8:throw e.prev=8,e.t0=e.catch(0),e.t0;case 11:case"end":return e.stop()}}),e,this,[[0,8]])})))}},{key:"createOffer",value:function(){return HF(this,null,p().mark((function e(){var t;return p().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,this._peerConnection.createOffer(H1);case 3:return t=e.sent,e.next=6,this.setOffer(t);case 6:t.sdp&&this.updateSSRC(t.sdp),e.next=12;break;case 9:throw e.prev=9,e.t0=e.catch(0),e.t0;case 12:case"end":return e.stop()}}),e,this,[[0,9]])})))}},{key:"doExchangeSDP",value:function(){var e=this,t={command:Z0,responseCommand:z0.PUBLISH_RESULT,data:{type:this._peerConnection.localDescription.type,sdp:this.removeVideoOrientation(this._peerConnection.localDescription.sdp),screen:this.localMainVideoTrack instanceof AY||this.localAuxVideoTrack instanceof AY,state:this.publishState,constraintConfig:this._mediaSettings},enableLog:!1};return this._log.debug("sending sdp offer: ".concat(t.data.sdp)),this._signalChannel.sendWaitForResponse(t).then((function(t){var n=t.data,r=n.code,i=n.message,o=n.data;return 0===r?e.acceptAnswer(o):e.checkPublishResultCode(r,i)}))}},{key:"setSDPDirection",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"all",r=P1(e);return r.media.forEach((function(e){("all"===n||e.type===n)&&(e.direction=t)})),M1(r)}},{key:"acceptAnswer",value:function(e){return HF(this,null,p().mark((function t(){var n,r,i,o,a,s,c,u,l,d,h;return p().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(t.prev=0,!(this._publishingLocalAudioTrack||this._publishingLocalVideoTrack||this.isMainStreamPublished)){t.next=13;break}if(c=(null==(n=this._publishingLocalVideoTrack)?void 0:n.profile.bitrate)||(null==(r=this.localMainVideoTrack)?void 0:r.profile.bitrate),u=(null==(i=this._publishingLocalAudioTrack)?void 0:i.profile.bitrate)||(null==(o=this.localMainAudioTrack)?void 0:o.profile.bitrate),!c){t.next=8;break}return l=this._isPublishingAux?UB.AUXILIARY:UB.BIG,t.next=7,this.setBandwidth({bandwidth:c,type:UB.VIDEO,sdp:s,videoType:l});case 7:s=t.sent;case 8:if(t.t0=u,!t.t0){t.next=13;break}return t.next=12,this.setBandwidth({bandwidth:u,type:UB.AUDIO,sdp:s});case 12:s=t.sent;case 13:if(s=this.removeVideoOrientation(e.sdp),null==(a=this._publishingLocalVideoTrack)||!a.small){t.next=18;break}return d=this._room.smallStreamConfig,t.next=17,this.setBandwidth({bandwidth:this._publishingLocalVideoTrack.small.bitrate||d.bitrate,type:UB.VIDEO,videoType:UB.SMALL,sdp:s});case 17:s=t.sent;case 18:return h={type:e.type,sdp:s},t.next=21,this.setAnswer(h);case 21:this._log.debug("accepted answer: ".concat(s)),t.next=27;break;case 24:throw t.prev=24,t.t1=t.catch(0),this._log.error("failed to accept remote answer ".concat(t.t1)),t.t1;case 27:case"end":return t.stop()}}),t,this,[[0,24]])})))}},{key:"sendMutedFlag",value:function(e){var t,n,r;if(e!==this.localAuxAudioTrack&&e!==this.localAuxVideoTrack){var i={audio:!(null==(t=this.localMainAudioTrack)||!t.muted),bigVideo:!(null==(n=this.localMainVideoTrack)||!n.muted),auxVideo:!(null==(r=this.localAuxVideoTrack)||!r.muted)};this._log.info("send muted state: ".concat(JSON.stringify(i))),this._signalChannel.send($0,i)}}},{key:"getIsReconnecting",value:function(){return this._isReconnecting}},{key:"reconnect",value:function(){return HF(this,null,p().mark((function e(){var n,r=this;return p().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(BF(t.prototype,this,"beforeReconnect").call(this)<0){e.next=22;break}return e.prev=1,e.next=4,this._signalChannel.sendWaitForResponse({command:t1,responseCommand:z0.UNPUBLISH_RESULT,enableLog:!1});case 4:if(this.closePeerConnection(),this.initialize(),e.t0=this.isMainStreamPublished,!e.t0){e.next=10;break}return e.next=10,this.publish({localAudioTrack:this.localMainAudioTrack,localVideoTrack:this.localMainVideoTrack,isAuxiliary:!1});case 10:if(e.t1=this.isAuxStreamPublished,!e.t1){e.next=14;break}return e.next=14,this.publish({localAudioTrack:this.localAuxAudioTrack,localVideoTrack:this.localAuxVideoTrack,isAuxiliary:!0});case 14:this._log.warn("reconnect() uplink reconnect successfully"),this.stopReconnection(),e.next=22;break;case 18:e.prev=18,e.t2=e.catch(1),n=rj(this._reconnectionCount),this._log.warn("reconnect() timeout, try again after ".concat(n/1e3,"s")),this._reconnectionTimer=setTimeout((function(){r.clearReconnectionTimer(),r.reconnect()}),n);case 22:case"end":return e.stop()}}),e,this,[[1,18]])})))}},{key:"handleConnectionStateChange",value:function(e){"CONNECTED"===e.state&&(this.localMainVideoTrack||this._publishingLocalVideoTrack&&!this._isPublishingAux)&&HW.emit(GW.SEND_FIRST_VIDEO_FRAME,{room:this._room})}},{key:"updateSSRC",value:function(e){var t=this;try{P1(e).media.forEach((function(e,n){if(e.type===UB.AUDIO){var r=e.ssrcs&&e.ssrcs[0];r&&(t.ssrc.audio=Number(r.id))}else{if(t._sdpSemantics===yH&&e.ssrcGroups)return void e.ssrcGroups.forEach((function(e,n){var r=Number(e.ssrcs.split(" ")[0]);0===n?t.ssrc.video=r:1===n&&(t.ssrc.small=r)}));var i=e.ssrcs&&e.ssrcs[0];if(!i)return;switch(n){case 1:t.ssrc.video=Number(i.id);break;case 2:t.ssrc.small=Number(i.id);break;case 3:t.ssrc.auxiliary=Number(i.id)}}}))}catch(hH){}}},{key:"getVideoTrackId",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:UB.VIDEO;if(this._peerConnection){var t=this._peerConnection.getSenders();if(e===UB.AUXILIARY&&t[3]&&t[3].track)return t[3].track.id;if(e===UB.VIDEO&&t[1]&&t[1].track)return t[1].track.id}if(this.localMainVideoTrack&&e===UB.VIDEO){var n=this.localMainVideoTrack.mediaTrack;if(n)return n.id}if(this.localAuxVideoTrack&&e===UB.AUXILIARY){var r=this.localAuxVideoTrack.mediaTrack;if(r)return r.id}return""}},{key:"getSSRC",value:function(){return this.ssrc}},{key:"checkPublishResultCode",value:function(e,t){if(0!==e)throw e===EH?(this._log.error(eK.NOT_SUPPORTED_H264ENCODE),new tB({code:ZF.NOT_SUPPORTED_H264,message:rK({key:ZJ.NOT_SUPPORTED_H264ENCODE})})):new tB({code:ZF.UNKNOWN,message:rK({key:ZJ.SIGNAL_RESPONSE_FAILED,data:{signalResponse:z0.PUBLISH_RESULT,code:e,message:t}})})}}])}(x1);UF([rY((function(e){return function(){for(var t=this,n=arguments.length,r=new Array(n),i=0;i<n;i++)r[i]=arguments[i];return new Promise((function(n,i){var o=function(e){t._emitter.off("closed",o),i(new tB({code:ZF.API_CALL_ABORTED,message:rK({key:ZJ.CONNECTION_ABORTED,data:e})}))};t._emitter.on("closed",o),e.apply(t,r).then(n,i).finally((function(){t._emitter.off("closed",o)}))}))}}))],j1.prototype,"publish",1),UF([hY(521715,!1)],j1.prototype,"unpublish",1),UF([tY(x1.prototype.afterConnect),eY(x1.prototype.beforeConnect)],j1.prototype,"connect",1);var G1=j1,W1=function(){return s((function e(t,n){i(this,e),this.room=t,FF(this,"_log"),FF(this,"_prevReportTime",0),FF(this,"_prevReport",{}),FF(this,"_prevStats",null),FF(this,"_prevEncoderImplementation",""),FF(this,"_prevAuxEncoderImpl",""),FF(this,"_prevQualityLimitationReason",""),FF(this,"_prevAuxQualityLimitationReason",""),FF(this,"_prevDecoderImplementationMap",new Map),FF(this,"totalBytesSent",0),FF(this,"totalBytesReceived",0),FF(this,"_spcStats",null),this._log=n}),[{key:"statInterval",get:function(){return 0===this._prevReportTime?2:(Date.now()-this._prevReportTime)/1e3}},{key:"getSenderStats",value:function(e){return HF(this,null,p().mark((function t(){var n,r,i,o,a,s=this;return p().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(r={audio:{bytesSent:0,packetsSent:0,audioLevel:0,totalAudioEnergy:0},video:{bytesSent:0,packetsSent:0,framesEncoded:0,frameWidth:0,frameHeight:0,framesSent:0,fpsCapture:0},small:{bytesSent:0,packetsSent:0,framesEncoded:0,frameWidth:0,frameHeight:0,framesSent:0,fpsCapture:0},auxiliary:{bytesSent:0,packetsSent:0,framesEncoded:0,frameWidth:0,frameHeight:0,framesSent:0,fpsCapture:0},rtt:0},i=e.getPeerConnection(),o=e.getSSRC(),!i){t.next=18;break}if(t.prev=2,t.t0=this._spcStats,t.t0){t.next=8;break}return t.next=7,i.getStats();case 7:t.t0=t.sent;case 8:if(t.t0.forEach((function(t){var n,i,a,c;if("outbound-rtp"===t.type)if((t.mediaType||t.kind)===UB.VIDEO){if(t.ssrc===o.video?(c=UB.VIDEO,e.localMainVideoTrack):t.ssrc===o.small?c=UB.SMALL:t.ssrc===o.auxiliary&&(e.localAuxVideoTrack,c=UB.AUXILIARY),!c)return;if(r[c].bytesSent=t.bytesSent,r[c].packetsSent=t.packetsSent,r[c].framesEncoded=t.framesEncoded,aj(t.keyFramesEncoded)||(r[c].keyFramesEncoded=t.keyFramesEncoded),aj(t.nackCount)||(r[c].nackCount=t.nackCount),aj(t.pliCount)||(r[c].pliCount=t.pliCount),aj(t.retransmittedPacketsSent)||(r[c].retransmittedPacketsSent=t.retransmittedPacketsSent),aj(t.totalEncodeTime)||(r[c].totalEncodeTime=t.totalEncodeTime),aj(t.totalPacketSendDelay)||(r[c].totalPacketSendDelay=t.totalPacketSendDelay),!aj(t.encoderImplementation)&&(c===UB.VIDEO&&s._prevEncoderImplementation!==t.encoderImplementation||c===UB.AUXILIARY&&s._prevAuxEncoderImpl!==t.encoderImplementation)){var u=2,l=s._prevEncoderImplementation;c===UB.AUXILIARY&&(u=7,l=s._prevAuxEncoderImpl),HW.emit("262",{userId:e.userId,streamType:u,prevImplementation:l,implementation:t.encoderImplementation,codec:e.videoCodec,isHWCodec:t.powerEfficientEncoder}),s[c===UB.VIDEO?"_prevEncoderImplementation":"_prevAuxEncoderImpl"]=t.encoderImplementation,s._log.info("".concat(c===UB.AUXILIARY?"aux ":"","encoderImplementation change to ").concat(t.encoderImplementation,"(").concat(e.videoCodec,") HWEncoder: ").concat(t.powerEfficientEncoder))}t.ssrc===o.video?!aj(t.qualityLimitationReason)&&0!==t.bytesSent&&s._prevQualityLimitationReason!==t.qualityLimitationReason&&(s._log.info("qualityLimitationReason change to ".concat(t.qualityLimitationReason)),HW.emit("263",{userId:e.userId,reason:t.qualityLimitationReason,prevReason:s._prevQualityLimitationReason,streamType:2,isQosClearFirst:null==(n=e.localMainVideoTrack)?void 0:n.isQosClearFirst}),s._prevQualityLimitationReason=t.qualityLimitationReason):t.ssrc===o.auxiliary&&!aj(t.qualityLimitationReason)&&0!==t.bytesSent&&s._prevAuxQualityLimitationReason!==t.qualityLimitationReason&&(s._log.info("aux qualityLimitationReason change to ".concat(t.qualityLimitationReason)),HW.emit("263",{userId:e.userId,reason:t.qualityLimitationReason,prevReason:s._prevAuxQualityLimitationReason,streamType:7,isQosClearFirst:null==(i=e.localAuxVideoTrack)?void 0:i.isQosClearFirst}),s._prevAuxQualityLimitationReason=t.qualityLimitationReason)}else r.audio.bytesSent=t.bytesSent,r.audio.packetsSent=t.packetsSent;else"candidate-pair"===t.type?NK(t)&&(s.totalBytesSent=t.bytesSent,cj(t.currentRoundTripTime)&&(r.rtt=Math.floor(1e3*t.currentRoundTripTime))):"media-source"===t.type&&(t.kind===UB.AUDIO?(r.audio.audioLevel=t.audioLevel||0,r.audio.totalAudioEnergy=t.totalAudioEnergy||0,t.echoReturnLoss,t.totalSamplesDuration&&(r.audio.totalSamplesDuration=t.totalSamplesDuration)):t.kind===UB.VIDEO&&(t.trackIdentifier===e.getVideoTrackId(UB.VIDEO)?r.video.fpsCapture=t.framesPerSecond:t.trackIdentifier===e.getVideoTrackId(UB.AUXILIARY)?r.auxiliary.fpsCapture=t.framesPerSecond:r.small.fpsCapture=t.framesPerSecond));if(!aj(t.audioLevel)&&null!=(a=e.localMainAudioTrack)&&a.mediaTrack&&t.trackIdentifier===e.localMainAudioTrack.mediaTrack.id&&(r.audio.audioLevel=t.audioLevel||0),!aj(t.frameWidth)){var d=UB.SMALL;t.trackIdentifier===e.getVideoTrackId(UB.VIDEO)||t.ssrc===o.video?d=UB.VIDEO:(t.trackIdentifier===e.getVideoTrackId(UB.AUXILIARY)||t.ssrc===o.auxiliary)&&(d=UB.AUXILIARY),r[d].frameWidth=t.frameWidth,r[d].frameHeight=t.frameHeight,r[d].framesSent=t.framesSent}})),!e.localMainAudioTrack){t.next=12;break}a=e.localMainAudioTrack.getInternalAudioLevel(),r.audio.micAudioLevel=a,0===r.audio.audioLevel&&(r.audio.audioLevel=a);case 12:this.totalBytesSent||(this.totalBytesSent+=r.audio.bytesSent+r.video.bytesSent+r.auxiliary.bytesSent),Object.keys(r).forEach((function(t){t===UB.AUDIO?(e.localMainAudioTrack&&(e.localMainAudioTrack.stat=r[t]),e.localAuxAudioTrack&&(e.localAuxAudioTrack.stat=r[t])):t===UB.VIDEO?e.localMainVideoTrack&&(e.localMainVideoTrack.stat=r[t]):t===UB.AUXILIARY&&e.localAuxVideoTrack&&(e.localAuxVideoTrack.stat=r[t])})),t.next=18;break;case 15:t.prev=15,t.t1=t.catch(2),this._log.warn("failed to getStats on sender connection ".concat(t.t1));case 18:return t.abrupt("return",(0===r.rtt&&(r.rtt=(null==(n=this.room.networkQuality)?void 0:n.uplinkRTT)||0),r));case 19:case"end":return t.stop()}}),t,this,[[2,15]])})))}},{key:"getReceiverStats",value:function(e){return HF(this,null,p().mark((function t(){var n,r,i,o,a,s,c,u,l=this;return p().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(o={tinyId:e.tinyId,userId:e.userId,rtt:0,hasAudio:!1,hasVideo:!1,hasAuxiliary:!1,isSmallSubscribed:!1,audio:{bytesReceived:0,packetsReceived:0,packetsLost:0,p2pDelay:0,totalJitter:0,totalJitterCount:0,audioLevel:0,totalAudioEnergy:0,insertedSamplesForDeceleration:0,removedSamplesForAcceleration:0},video:{bytesReceived:0,packetsReceived:0,packetsLost:0,framesReceived:0,framesDecoded:0,frameWidth:0,frameHeight:0,fpsDecoded:0,freezeCount:0,totalFreezesDuration:0,totalJitter:0,totalJitterCount:0},auxiliary:{bytesReceived:0,packetsReceived:0,packetsLost:0,framesReceived:0,framesDecoded:0,frameWidth:0,frameHeight:0,fpsDecoded:0,totalJitter:0,totalJitterCount:0}},!(a=e.getPeerConnection())){t.next=19;break}if(t.prev=2,s=e.ssrc,c=e.muteState,u=e.subscribeState,t.t0=this._spcStats,t.t0){t.next=9;break}return t.next=8,a.getStats();case 8:t.t0=t.sent;case 9:t.t0.forEach((function(t){if("inbound-rtp"===t.type){var n=(t.mediaType||t.kind)===UB.AUDIO;if(n){if(t.ssrc!==s.audio||!c.hasAudio)return;o.audio.packetsReceived=t.packetsReceived,o.audio.bytesReceived=t.bytesReceived,o.audio.packetsLost=t.packetsLost,t.insertedSamplesForDeceleration&&(o.audio.insertedSamplesForDeceleration=t.insertedSamplesForDeceleration),t.removedSamplesForAcceleration&&(o.audio.removedSamplesForAcceleration=t.removedSamplesForAcceleration),t.totalSamplesDuration&&(o.audio.totalSamplesDuration=t.totalSamplesDuration),t.totalSamplesReceived&&(o.audio.totalSamplesReceived=t.totalSamplesReceived),t.concealedSamples&&(o.audio.concealedSamples=t.concealedSamples);var r=e.remoteAudioTrack;r.stat.packetsReceived=t.packetsReceived,r.stat.bytesReceived=t.bytesReceived,r.stat.packetsLost=t.packetsLost,o.audio.p2pDelay=r.stat.end2EndDelay,o.hasAudio=!0}else{if(fG&&0===t.bytesReceived)return;var i;t.ssrc===s.video&&c.hasVideo&&(o.video.packetsReceived=t.packetsReceived,o.video.bytesReceived=t.bytesReceived,o.video.packetsLost=t.packetsLost,o.video.framesReceived=t.framesReceived,o.video.framesDecoded=t.framesDecoded,o.video.fpsDecoded=t.framesPerSecond,o.hasVideo=!0,i=e.remoteVideoTrack,c.hasSmall&&u.smallVideo&&(o.isSmallSubscribed=!0),t.decoderImplementation&&(!l._prevDecoderImplementationMap.has(o.userId)||l._prevDecoderImplementationMap.get(o.userId)!==t.decoderImplementation)&&(l._log.info("".concat(o.userId," decoderImplementation change to ").concat(t.decoderImplementation," HWDecoder: ").concat(t.powerEfficientDecoder)),HW.emit("262",{userId:l.room.userId,remoteUserId:o.userId,prevImplementation:l._prevDecoderImplementationMap.get(o.userId),implementation:t.decoderImplementation,codec:e.videoCodec,isHWCodec:t.powerEfficientDecoder}),l._prevDecoderImplementationMap.set(o.userId,t.decoderImplementation))),t.ssrc===s.auxiliary&&c.hasAuxiliary&&(o.auxiliary.packetsReceived=t.packetsReceived,o.auxiliary.bytesReceived=t.bytesReceived,o.auxiliary.packetsLost=t.packetsLost,o.auxiliary.framesReceived=t.framesReceived,o.auxiliary.framesDecoded=t.framesDecoded,o.auxiliary.fpsDecoded=t.framesPerSecond,i=e.remoteAuxiliaryTrack,o.hasAuxiliary=!0),i&&(i.stat.packetsReceived=t.packetsReceived,i.stat.bytesReceived=t.bytesReceived,i.stat.packetsLost=t.packetsLost,i.stat.framesReceived=t.framesReceived,i.stat.framesDecoded=t.framesDecoded,t.jitterBufferDelay&&(i.stat.jitterBufferDelay=Math.floor(t.jitterBufferDelay/t.jitterBufferEmittedCount*1e3)))}t.jitterBufferDelay&&(n?(o.audio.totalJitter=t.jitterBufferDelay,o.audio.totalJitterCount=t.jitterBufferEmittedCount):t.ssrc===s.video&&c.hasVideo?(o.video.totalJitter=t.jitterBufferDelay,o.video.totalJitterCount=t.jitterBufferEmittedCount):t.ssrc===s.auxiliary&&c.hasAuxiliary&&(o.auxiliary.totalJitter=t.jitterBufferDelay,o.auxiliary.totalJitterCount=t.jitterBufferEmittedCount))}else"candidate-pair"===t.type&&NK(t)&&(l.totalBytesReceived=t.bytesReceived,cj(t.currentRoundTripTime)&&(o.rtt=Math.floor(1e3*t.currentRoundTripTime)));aj(t.frameWidth)||((t.trackIdentifier===e.getMainStreamVideoTrackId()||t.ssrc===s.video)&&(o.video.frameWidth=t.frameWidth,o.video.frameHeight=t.frameHeight,e.remoteVideoTrack.stat.frameWidth=t.frameWidth,e.remoteVideoTrack.stat.frameHeight=t.frameHeight),(t.trackIdentifier===e.getAuxStreamVideoTrackId()||t.ssrc===s.auxiliary)&&(o.auxiliary.frameWidth=t.frameWidth,o.auxiliary.frameHeight=t.frameHeight,e.remoteAuxiliaryTrack.stat.frameWidth=t.frameWidth,e.remoteAuxiliaryTrack.stat.frameHeight=t.frameHeight)),!aj(t.audioLevel)&&e.muteState.audioAvailable&&e.remoteAudioTrack.mediaTrack&&t.trackIdentifier===e.remoteAudioTrack.mediaTrack.id&&(o.audio.audioLevel=t.audioLevel||0,o.audio.totalAudioEnergy=t.totalAudioEnergy||0)})),0===o.audio.audioLevel&&e.muteState.audioAvailable&&(o.audio.audioLevel=e.remoteAudioTrack.getInternalAudioLevel()||0),this.totalBytesReceived||(this.totalBytesReceived+=o.audio.bytesReceived+o.video.bytesReceived+o.auxiliary.bytesReceived),aj(null==(n=e.remoteVideoTrack.player.stat)?void 0:n.fps)||(o.video.fpsRender=e.remoteVideoTrack.player.stat.fps),aj(null==(r=e.remoteAuxiliaryTrack.player.stat)?void 0:r.fps)||(o.auxiliary.fpsRender=e.remoteAuxiliaryTrack.player.stat.fps),t.next=19;break;case 16:t.prev=16,t.t1=t.catch(2),this._log.warn("failed to getStats on receiver connection ".concat(t.t1));case 19:return t.abrupt("return",(0===o.rtt&&(o.rtt=(null==(i=this.room.networkQuality)?void 0:i.uplinkRTT)||0),o));case 20:case"end":return t.stop()}}),t,this,[[2,16]])})))}},{key:"getStats",value:function(e,t){return HF(this,null,p().mark((function n(){var r,i,o,a,s,u,l,d,h,f,m,v,g;return p().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(r={},i=[],!this.room.singlePC){n.next=13;break}if(o=this.room.singlePC.getPeerConnection()){n.next=5;break}return n.abrupt("return",{senderStats:r,receiverStats:i});case 5:return a=yj(),n.next=8,o.getStats();case 8:s=n.sent,(u=yj())-a>2e3&&this._log.warn("getStats cost ".concat(u-a,"ms")),l=[],d=new Set(["inbound-rtp","outbound-rtp","track","candidate-pair","media-source"]),s.forEach((function(e){return d.has(e.type)&&l.push(e)})),this._spcStats=l;case 13:if(n.t0=e,!n.t0){n.next=18;break}return n.next=17,this.getSenderStats(e);case 17:r=n.sent;case 18:h=c(t),n.prev=19,h.s();case 21:if((f=h.n()).done){n.next=29;break}return(m=_(f.value,2))[0],v=m[1],n.next=25,this.getReceiverStats(v);case 25:g=n.sent,i.push(g);case 27:n.next=21;break;case 29:n.next=34;break;case 31:n.prev=31,n.t1=n.catch(19),h.e(n.t1);case 34:return n.prev=34,h.f(),n.finish(34);case 37:return n.abrupt("return",{senderStats:r,receiverStats:i});case 38:case"end":return n.stop()}}),n,this,[[19,31,34,37]])})))}},{key:"getDifferenceValue",value:function(e,t){if(zq(e))return t;var n=t-e;return n<0?0:n}},{key:"prepareReport",value:function(e){var t,n=this,r=e.stats,i=e.report,o=e.freezeMap;if(!zq(r.senderStats)){var a={uint32_audio_level:r.senderStats.audio.audioLevel*GJ,uint32_audio_energy:1e6*(r.senderStats.audio.totalAudioEnergy||0),uint32_audio_codec_bitrate:r.senderStats.audio.bytesSent};r.senderStats.audio.micAudioLevel&&(a.uint32_mic_audio_level=r.senderStats.audio.micAudioLevel*GJ),r.senderStats.audio.totalSamplesDuration&&(i.msg_device_info.uint32_audio_capture_cost=r.senderStats.audio.totalSamplesDuration);var s=[];if(r.senderStats.video.bytesSent){var c={uint32_video_stream_type:2,uint32_video_codec_fps:r.senderStats.video.framesSent,uint32_video_capture_fps:r.senderStats.video.fpsCapture,uint32_video_width:r.senderStats.video.frameWidth,uint32_video_height:r.senderStats.video.frameHeight,uint32_video_codec_bitrate:r.senderStats.video.bytesSent,uint32_video_enc_fps:r.senderStats.video.framesEncoded,uint32_key_frame_count:r.senderStats.video.keyFramesEncoded,uint32_nack_count:r.senderStats.video.nackCount,uint32_pli_count:r.senderStats.video.pliCount,uint32_encode_cost:1e3*(r.senderStats.video.totalEncodeTime||0),uint32_send_packet_cost:1e3*(r.senderStats.video.totalPacketSendDelay||0),uint32_video_arq_packets:r.senderStats.video.retransmittedPacketsSent};s.push(c)}if(r.senderStats.small.bytesSent){var u={uint32_video_stream_type:3,uint32_video_codec_fps:r.senderStats.small.framesSent||0,uint32_video_capture_fps:r.senderStats.small.fpsCapture||0,uint32_video_width:r.senderStats.small.frameWidth||0,uint32_video_height:r.senderStats.small.frameHeight||0,uint32_video_codec_bitrate:r.senderStats.small.bytesSent,uint32_video_enc_fps:r.senderStats.small.framesEncoded||0,uint32_key_frame_count:r.senderStats.small.keyFramesEncoded,uint32_nack_count:r.senderStats.small.nackCount,uint32_pli_count:r.senderStats.small.pliCount,uint32_encode_cost:1e3*(r.senderStats.small.totalEncodeTime||0),uint32_send_packet_cost:1e3*(r.senderStats.small.totalPacketSendDelay||0),uint32_video_arq_packets:r.senderStats.small.retransmittedPacketsSent};s.push(u)}if(r.senderStats.auxiliary.bytesSent){var l={uint32_video_stream_type:7,uint32_video_codec_fps:r.senderStats.auxiliary.framesSent||0,uint32_video_capture_fps:r.senderStats.auxiliary.fpsCapture||0,uint32_video_width:r.senderStats.auxiliary.frameWidth||0,uint32_video_height:r.senderStats.auxiliary.frameHeight||0,uint32_video_codec_bitrate:r.senderStats.auxiliary.bytesSent,uint32_video_enc_fps:r.senderStats.auxiliary.framesEncoded||0,uint32_key_frame_count:r.senderStats.auxiliary.keyFramesEncoded,uint32_nack_count:r.senderStats.auxiliary.nackCount,uint32_pli_count:r.senderStats.auxiliary.pliCount,uint32_encode_cost:1e3*(r.senderStats.auxiliary.totalEncodeTime||0),uint32_send_packet_cost:1e3*(r.senderStats.auxiliary.totalPacketSendDelay||0),uint32_video_arq_packets:r.senderStats.auxiliary.retransmittedPacketsSent};s.push(l)}var d={uint32_bitrate:0,uint32_lost:0,uint32_rtt:r.senderStats.rtt};i.msg_up_stream_info={msg_audio_status:a,msg_video_status:s,msg_network_status:d}}var h=this.statInterval;i.msg_down_stream_info=[],r.receiverStats.forEach((function(e){var t={msg_user_info:{str_identifier:e.userId,uint64_tinyid:e.tinyId},msg_network_status:{uint32_rtt:e.rtt,uint32_bitrate:0,uint32_lost:0},msg_audio_status:{},msg_video_status:[]};if(e.hasAudio){var n={uint32_audio_p2p_delay:e.audio.p2pDelay,uint32_audio_cache_ms:e.audio.totalJitter,uint32_audio_cache_ms_count:e.audio.totalJitterCount,uint32_audio_codec_bitrate:e.audio.bytesReceived,uint32_audio_total_bitrate:e.audio.bytesReceived,uint32_audio_level:1e8*e.audio.audioLevel,uint32_audio_energy:1e6*e.audio.totalAudioEnergy,uint32_audio_receive:e.audio.packetsReceived,uint32_audio_origin_lost:e.audio.packetsLost};t.msg_audio_status=n}if(e.hasVideo){var r=o.get("".concat(e.userId,"_").concat($B)),a=r?r.duration:0,s={uint32_video_stream_type:e.isSmallSubscribed?3:2,uint32_video_receive_fps:e.video.framesReceived,uint32_video_width:e.video.frameWidth,uint32_video_height:e.video.frameHeight,uint32_video_codec_bitrate:e.video.bytesReceived,uint32_video_receive:e.video.packetsReceived,uint32_video_origin_lost:e.video.packetsLost,uint32_video_block_time:a,uint32_video_dec_fps:e.video.framesDecoded,uint32_video_codec_fps:e.video.fpsRender,uint32_video_cache_ms:e.video.totalJitter,uint32_video_cache_ms_count:e.video.totalJitterCount};t.msg_video_status.push(s)}if(e.hasAuxiliary){var c=o.get("".concat(e.userId,"_").concat(ZB)),u=c?c.duration:0,l={uint32_video_stream_type:7,uint32_video_receive_fps:e.auxiliary.framesReceived,uint32_video_width:e.auxiliary.frameWidth,uint32_video_height:e.auxiliary.frameHeight,uint32_video_codec_bitrate:e.auxiliary.bytesReceived,uint32_video_receive:e.auxiliary.packetsReceived+e.auxiliary.packetsLost,uint32_video_origin_lost:e.auxiliary.packetsLost,uint32_video_block_time:u,uint32_video_dec_fps:e.auxiliary.framesDecoded,uint32_video_codec_fps:e.video.fpsRender,uint32_video_cache_ms:e.auxiliary.totalJitter,uint32_video_cache_ms_count:e.auxiliary.totalJitterCount};t.msg_video_status.push(l)}i.msg_down_stream_info.push(t)}));var f=this._prevReport,p=this._prevStats;if(this._prevReport=JSON.parse(JSON.stringify(i)),this._prevStats=JSON.parse(JSON.stringify(r)),i.msg_up_stream_info.msg_audio_status&&f.msg_up_stream_info.msg_audio_status){var m=f.msg_up_stream_info.msg_audio_status,v=i.msg_up_stream_info.msg_audio_status;if(0===m.uint32_audio_codec_bitrate)v.uint32_audio_codec_bitrate=0;else{var _=this.getDifferenceValue(m.uint32_audio_codec_bitrate,v.uint32_audio_codec_bitrate);v.uint32_audio_codec_bitrate=Math.round(8*_/h),i.msg_up_stream_info.msg_network_status.uint32_bitrate+=v.uint32_audio_codec_bitrate}null!=(t=f.msg_device_info)&&t.uint32_audio_capture_cost?i.msg_device_info.uint32_audio_capture_cost=2*Math.floor(1e3*this.getDifferenceValue(f.msg_device_info.uint32_audio_capture_cost,i.msg_device_info.uint32_audio_capture_cost)/h):delete i.msg_device_info.uint32_audio_capture_cost}var g=f.msg_up_stream_info.msg_video_status;i.msg_up_stream_info.msg_video_status.forEach((function(e){var t=g.find((function(t){return t.uint32_video_stream_type===e.uint32_video_stream_type}));if(!t||0===t.uint32_video_codec_bitrate)return e.uint32_video_codec_bitrate=0,e.uint32_video_enc_fps=0,void(e.uint32_video_codec_fps=0);var r=0,o=0,a=0;t&&e.uint32_video_codec_bitrate>=t.uint32_video_codec_bitrate&&(r=t.uint32_video_codec_bitrate,o=t.uint32_video_enc_fps,a=t.uint32_video_codec_fps);var s=n.getDifferenceValue(r,e.uint32_video_codec_bitrate);e.uint32_video_codec_bitrate=Math.round(8*s/h),i.msg_up_stream_info.msg_network_status.uint32_bitrate+=e.uint32_video_codec_bitrate,e.uint32_video_enc_fps=Math.round(n.getDifferenceValue(o,e.uint32_video_enc_fps)/h),e.uint32_video_codec_fps=Math.round(n.getDifferenceValue(a,e.uint32_video_codec_fps)/h),0===t.uint32_video_width&&0===t.uint32_video_height&&0===t.uint32_video_codec_fps&&(e.uint32_video_codec_fps=e.uint32_video_enc_fps),aj(t.uint32_key_frame_count)||(e.uint32_key_frame_count=Math.round(n.getDifferenceValue(t.uint32_key_frame_count,e.uint32_key_frame_count))),aj(t.uint32_nack_count)||(e.uint32_nack_count=Math.round(n.getDifferenceValue(t.uint32_nack_count,e.uint32_nack_count))),aj(t.uint32_pli_count)||(e.uint32_pli_count=Math.round(n.getDifferenceValue(t.uint32_pli_count,e.uint32_pli_count))),aj(t.uint32_video_arq_packets)||(e.uint32_video_arq_packets=Math.round(n.getDifferenceValue(t.uint32_video_arq_packets,e.uint32_video_arq_packets))),aj(t.uint32_encode_cost)||(e.uint32_encode_cost=Math.round(n.getDifferenceValue(t.uint32_encode_cost,e.uint32_encode_cost)/h)),aj(t.uint32_send_packet_cost)||(e.uint32_send_packet_cost=Math.round(n.getDifferenceValue(t.uint32_send_packet_cost,e.uint32_send_packet_cost)/h))}));var y=f.msg_down_stream_info;i.msg_down_stream_info=i.msg_down_stream_info.filter((function(e){return y.find((function(t){return t.msg_user_info.uint64_tinyid===e.msg_user_info.uint64_tinyid}))}));var E=i.msg_down_stream_info;return E.forEach((function(e){var t=y.find((function(t){return t.msg_user_info.uint64_tinyid===e.msg_user_info.uint64_tinyid}));if(zq(e.msg_audio_status)||zq(t.msg_audio_status))e.msg_audio_status={};else{var r=e.msg_audio_status,i=t.msg_audio_status,o=n.getDifferenceValue(i.uint32_audio_cache_ms_count,r.uint32_audio_cache_ms_count);delete r.uint32_audio_cache_ms_count,r.uint32_audio_cache_ms=Math.floor(1e3*n.getDifferenceValue(i.uint32_audio_cache_ms,r.uint32_audio_cache_ms)/o)||0;var a=n.room.remotePublishedUserMap.get(e.msg_user_info.str_identifier);a&&(a.remoteAudioTrack.stat.jitterBufferDelay=r.uint32_audio_cache_ms),r.uint32_audio_origin_lost=n.getDifferenceValue(i.uint32_audio_origin_lost,r.uint32_audio_origin_lost),r.uint32_audio_receive=n.getDifferenceValue(i.uint32_audio_receive,r.uint32_audio_receive),r.uint32_audio_receive+=r.uint32_audio_origin_lost;var s=n.getDifferenceValue(i.uint32_audio_codec_bitrate,r.uint32_audio_codec_bitrate);r.uint32_audio_codec_bitrate=Math.round(8*s/h),r.uint32_audio_total_bitrate=Math.round(8*s/h)}if(e.msg_video_status&&t.msg_video_status){var c=t.msg_video_status;e.msg_video_status=e.msg_video_status.filter((function(e){return c.find((function(t){return t.uint32_video_stream_type===e.uint32_video_stream_type}))})),e.msg_video_status.forEach((function(e){var t=c.find((function(t){return t.uint32_video_stream_type===e.uint32_video_stream_type})),r=t.uint32_video_receive,i=t.uint32_video_origin_lost,o=t.uint32_video_codec_bitrate,a=t.uint32_video_receive_fps,s=t.uint32_video_dec_fps;e.uint32_video_origin_lost=n.getDifferenceValue(i,e.uint32_video_origin_lost),e.uint32_video_receive=n.getDifferenceValue(r,e.uint32_video_receive)+e.uint32_video_origin_lost;var u=n.getDifferenceValue(o,e.uint32_video_codec_bitrate);e.uint32_video_codec_bitrate=Math.round(8*u/h);var l=n.getDifferenceValue(a,e.uint32_video_receive_fps);e.uint32_video_receive_fps=Math.round(l/h),e.uint32_video_dec_fps=Math.round(n.getDifferenceValue(s,e.uint32_video_dec_fps)/h);var d=n.getDifferenceValue(t.uint32_video_cache_ms_count,e.uint32_video_cache_ms_count);delete e.uint32_video_cache_ms_count,e.uint32_video_cache_ms=Math.floor(1e3*n.getDifferenceValue(t.uint32_video_cache_ms,e.uint32_video_cache_ms)/d)||0}))}})),p&&r.receiverStats.forEach((function(e){if(e.audio.concealedSamples&&e.audio.totalSamplesReceived){var t=p.receiverStats.find((function(t){return t.userId===e.userId}));if(t&&t.audio.concealedSamples&&t.audio.totalSamplesReceived){var n=e.audio.concealedSamples-t.audio.concealedSamples,r=e.audio.totalSamplesReceived-t.audio.totalSamplesReceived,i=Math.floor(n/r*1e3*h);if(i>1e3*h/5){var o=E.find((function(t){return t.msg_user_info.str_identifier===e.userId}));o&&(o.msg_audio_status.uint32_audio_block_time=i)}}}})),i}},{key:"getStatsReport",value:function(e){return HF(this,arguments,(function(e){var t=this,n=e.uplinkConnection,r=e.downlinkConnections,i=e.freezeMap;return p().mark((function e(){var o,a;return p().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return o={msg_device_info:{},msg_up_stream_info:{msg_audio_status:{uint32_audio_format:11,uint32_audio_sample_rate:0,uint32_audio_codec_bitrate:0,uint32_audio_receive:0,uint32_audio_origin_lost:0,uint32_audio_level:0,uint32_audio_energy:0},msg_video_status:[],msg_network_status:{uint32_bitrate:0,uint32_rtt:0,uint32_lost:0}},msg_down_stream_info:[{msg_user_info:{str_identifier:"",uint64_tinyid:0},msg_audio_status:{uint32_audio_cache_ms:0,uint32_audio_format:11,uint32_audio_sample_rate:0,uint32_audio_codec_bitrate:0,uint32_audio_total_bitrate:0,uint32_audio_level:0,uint32_audio_energy:0,uint32_audio_receive:0,uint32_audio_origin_lost:0,uint32_audio_final_lost:0},msg_video_status:[{uint32_video_cache_ms:0,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}}]},e.next=3,t.getStats(n,r);case 3:return a=e.sent,e.abrupt("return",("{}"===JSON.stringify(t._prevReport)&&(t._prevReport=JSON.parse(JSON.stringify(o))),t.prepareReport({stats:a,report:o,freezeMap:i}),t._prevReportTime=Date.now(),o));case 5:case"end":return e.stop()}}),e)}))()}))}},{key:"reset",value:function(){this._prevReportTime=0,this._prevReport={},this._prevEncoderImplementation="",this._prevQualityLimitationReason="",this._prevDecoderImplementationMap=new Map}}])}(),J1=VF(jF());function K1(e){var t={totalCost:0,local:0,redirect:0,httpCache:0,dns:0,tcp:0,tls:0,request:0,response:0};try{var n,r=c(performance.getEntriesByType("resource").reverse());try{for(r.s();!(n=r.n()).done;){var i=n.value;if(i.name===e){var o=Math.round(i.duration),a=Math.max(Math.round(i.domainLookupStart-i.startTime),0),s=i.redirectStart>0?Math.max(Math.round(i.redirectEnd-i.redirectStart),0):0,u=i.fetchStart>0?Math.max(Math.round(i.domainLookupStart-i.fetchStart),0):0,l=Math.round(i.domainLookupEnd-i.domainLookupStart),d=Math.round(i.requestStart-i.secureConnectionStart),h=Math.round(i.secureConnectionStart-i.connectStart),f=Math.round(i.responseStart-i.requestStart),p=Math.round(i.responseEnd-(i.responseStart||i.startTime));t=OF(xF({},t),{totalCost:o,local:a,redirect:s,httpCache:u,dns:l,tcp:h,tls:d,request:f,response:p});break}}}catch(m){r.e(m)}finally{r.f()}}catch(dB){}return t}var z1=function(e){function t(e){var n,o=e.signalChannel,a=e.room;return i(this,t),n=r(this,t),FF(n,"_room"),FF(n,"_signalChannel"),FF(n,"_log"),FF(n,"uplinkRTT",0),FF(n,"uplinkLoss",0),FF(n,"downlinkRTT",0),FF(n,"downlinkLoss",0),FF(n,"pingResults",{}),FF(n,"_downlinkPrevStatMap",new Map),FF(n,"_downlinkLossAndRTTMap",new Map),FF(n,"_interval",-1),FF(n,"_uplinkNetworkQuality",0),FF(n,"_downlinkNetworkQuality",0),n._room=a,n._signalChannel=o,n._log=qW.createLogger({id:"q",userId:n._room.userId,sdkAppId:n._room.sdkAppId}),n.initialize(),n}return d(t,e),s(t,[{key:"uplinkNetworkQuality",get:function(){return this._uplinkNetworkQuality},set:function(e){e!==this._uplinkNetworkQuality&&this._log.info("uplink ".concat(this.uplinkNetworkQuality," -> ").concat(e,", rtt: ").concat(this.uplinkRTT,", loss: ").concat(this.uplinkLoss," ws-rtt: ").concat(this._signalChannel.rtt)),this._uplinkNetworkQuality=e}},{key:"downlinkNetworkQuality",get:function(){return this._downlinkNetworkQuality},set:function(e){if(e!==this._downlinkNetworkQuality){var t=this.getAverageLossAndRTT(T(this._downlinkLossAndRTTMap.values())),n=t.rtt,r=t.loss;this._log.info("downlink ".concat(this.downlinkNetworkQuality," -> ").concat(e,", rtt: ").concat(n,", loss: ").concat(r," ws-rtt: ").concat(this._signalChannel.rtt))}this._downlinkNetworkQuality=e}},{key:"initialize",value:function(){var e=this;this._signalChannel.on(z0.UPLINK_NETWORK_STATS,(function(t){e.handleUplinkNetworkQuality(t)})),this._signalChannel.on(B0,this.handleSignalConnectionStateChange.bind(this)),this.start()}},{key:"handleUplinkNetworkQuality",value:function(e){var t,n;if(0===e.data.code){var r=e.data.data;if(r.delay&&this.updateDelay(r.delay),this._room.signalChannel&&r.wsRtt&&(this._room.signalChannel.rtt=r.wsRtt),!this._room.uplinkConnection)return this.uplinkNetworkQuality=0,this.uplinkLoss=0,void(this.uplinkRTT=0);var i=null==(n=null==(t=this._room)?void 0:t.uplinkConnection)?void 0:n.getPeerConnection();if(i&&this.isPeerConnectionDisconnected(i))return this.uplinkNetworkQuality=6,this.uplinkLoss=0,void(this.uplinkRTT=0);var o=r.expectAudPkg+r.expectVidPkg,a=r.recvAudPkg+r.recvVidPkg,s=o-a;0===o&&0===a||(this.uplinkLoss=s<=0?0:Math.round(s/o*100),this.uplinkRTT=r.rtt,this.uplinkNetworkQuality=this.getNetworkQuality(this.uplinkLoss,this.uplinkRTT))}}},{key:"handleDownlinkNetworkQuality",value:function(){return HF(this,null,p().mark((function e(){var t,n,r,i,o,a,s,c,u,l,d,h,f,m,v,_=this;return p().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(0!==this._room.remotePublishedUserMap.size){e.next=3;break}return this.downlinkNetworkQuality=0,e.abrupt("return");case 3:if(t=T(this._room.remotePublishedUserMap.values()),n=t.filter((function(e){var t;return(null==(t=e.getPeerConnection())?void 0:t.connectionState)===cH.CONNECTED})),t.filter((function(e){return _.isPeerConnectionDisconnected(e.getPeerConnection())})).length!==t.length){e.next=7;break}return this.downlinkNetworkQuality=6,e.abrupt("return");case 7:r=0;case 8:if(!(r<n.length)){e.next=26;break}if(i=n[r].getPeerConnection()){e.next=12;break}return e.abrupt("return");case 12:return e.next=14,this.getStat(i);case 14:if(o=e.sent,a=o.rtt,s=o.totalPacketsLost,c=o.totalPacketsReceived,this._downlinkPrevStatMap.has(i)){e.next=21;break}return this._downlinkPrevStatMap.set(i,{totalPacketsLost:s,totalPacketsReceived:c}),e.abrupt("continue",23);case 21:u=0,l=this._downlinkPrevStatMap.get(i),d=s-l.totalPacketsLost,h=c-l.totalPacketsReceived,u=d<=0||h<0?0:Math.round(d/(d+h)*100),this._downlinkPrevStatMap.set(i,{totalPacketsLost:s,totalPacketsReceived:c}),this._downlinkLossAndRTTMap.set(i,{rtt:a,loss:u,userId:n[r].getUserId(),audioDelay:n[r].remoteAudioTrack.stat.end2EndDelay,videoDelay:n[r].remoteVideoTrack.stat.end2EndDelay});case 23:r++,e.next=8;break;case 26:if(T(this._downlinkPrevStatMap.keys()).forEach((function(e){_.isPeerConnectionDisconnected(e)&&(_._downlinkPrevStatMap.delete(e),_._downlinkLossAndRTTMap.delete(e))})),0!==this._downlinkLossAndRTTMap.size){e.next=29;break}return this.downlinkRTT=0,this.downlinkLoss=0,this.downlinkNetworkQuality=0,e.abrupt("return");case 29:f=this.getAverageLossAndRTT(T(this._downlinkLossAndRTTMap.values())),m=f.rtt,v=f.loss,this.downlinkRTT=m,this.downlinkLoss=v,this.downlinkNetworkQuality=this.getNetworkQuality(v,m);case 31:case"end":return e.stop()}}),e,this)})))}},{key:"getStat",value:function(e){return HF(this,null,p().mark((function t(){var n,r,i;return p().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n={rtt:0,totalPacketsLost:0,totalPacketsReceived:0},e&&UK()){t.next=3;break}return t.abrupt("return",n);case 3:r=e.getReceivers(),t.prev=4,i=0;case 6:if(!(i<r.length)){t.next=13;break}return t.next=9,r[i].getStats();case 9:t.sent.forEach((function(e){"candidate-pair"===e.type&&cj(e.currentRoundTripTime)&&(n.rtt=Math.round(1e3*e.currentRoundTripTime)),"inbound-rtp"===e.type&&(e.mediaType===UB.AUDIO||e.mediaType===UB.VIDEO)&&(n.totalPacketsLost+=e.packetsLost,n.totalPacketsReceived+=e.packetsReceived)}));case 10:i++,t.next=6;break;case 13:return t.abrupt("return",(0===n.rtt&&(n.rtt=this.uplinkRTT),n));case 16:return t.prev=16,t.t0=t.catch(4),t.abrupt("return",n);case 19:case"end":return t.stop()}}),t,this,[[4,16]])})))}},{key:"getAverageLossAndRTT",value:function(e){var t={rtt:0,loss:0};return Array.isArray(e)&&e.length>0&&(e.forEach((function(e){t.rtt+=e.rtt,t.loss+=e.loss})),Object.keys(t).forEach((function(n){t[n]=Math.round(t[n]/e.length)}))),t}},{key:"getNetworkQuality",value:function(e,t){return e>50||t>500?5:e>30||t>350?4:e>20||t>200?3:e>10||t>100?2:e>=0||t>=0?1:0}},{key:"handleSignalConnectionStateChange",value:function(e){"DISCONNECTED"===e.state?(this.uplinkRTT=0,this.uplinkLoss=0,this.uplinkNetworkQuality=6):"CONNECTED"===e.state&&6===this.uplinkNetworkQuality&&(this.uplinkNetworkQuality=5)}},{key:"handleUplinkConnectionStateChange",value:function(e){var t=e.state;"DISCONNECTED"===t?(this.uplinkLoss=0,this.uplinkRTT=0,this.uplinkNetworkQuality=6):"CONNECTED"===t&&6===this.uplinkNetworkQuality&&(this.uplinkNetworkQuality=5)}},{key:"isPeerConnectionDisconnected",value:function(e){return!(!e||e.connectionState!==cH.DISCONNECTED&&e.connectionState!==cH.FAILED&&e.connectionState!==cH.CLOSED)}},{key:"setUplinkConnection",value:function(e){this._room.uplinkConnection=e,this._room.uplinkConnection?this._room.uplinkConnection.on("connection-state-changed",this.handleUplinkConnectionStateChange.bind(this)):(this.uplinkNetworkQuality=0,this.uplinkRTT=0,this.uplinkLoss=0)}},{key:"start",value:function(){var e=this;-1===this._interval?(this._log.debug("start network quality calculating"),this._interval=Iz.run("ric",(function(){var n;e.handleDownlinkNetworkQuality();var r=T(e._downlinkLossAndRTTMap.values());HW.emit(GW.NETWORK_QUALITY,{room:e._room,uplink:{rtt:e.uplinkRTT,loss:e.uplinkLoss},downlinks:r});var i=null==(n=e._room.scheduleResult.config)?void 0:n.pingDomainInfo,o={uplinkNetworkQuality:e.uplinkNetworkQuality,downlinkNetworkQuality:e.downlinkNetworkQuality,uplinkRTT:e.uplinkRTT,uplinkLoss:e.uplinkLoss,downlinkRTT:e.downlinkRTT,downlinkLoss:e.downlinkLoss};i&&(o=OF(xF({},o),{pingResults:e.uplinkRTT>i.rttThreshold||e.downlinkRTT>i.rttThreshold?e.pingResults:{}})),e.emit(t.EVENT_NETWORK_QUALITY,o);var a=Date.now();if(i&&(e.uplinkRTT>i.rttThreshold||e.downlinkRTT>i.rttThreshold)&&a-t.lastPingTime>1e3*i.interval){t.lastPingTime=Date.now();var s=i.domain.map((function(e){return function(e){var t=this;return new Promise((function(n){return HF(t,null,p().mark((function t(){var r,i,o,a;return p().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=setTimeout((function(){n({totalCost:1e4,local:0,dns:0,tcp:0,tls:0,request:0,response:0})}),1e4),i=Date.now(),o="https://".concat(e,"/?t=").concat(i),t.prev=1,t.next=4,fetch(o);case 4:t.next=8;break;case 6:t.prev=6,t.t0=t.catch(1);case 8:clearTimeout(r),0===(a=K1(o)).totalCost&&(a.totalCost=Date.now()-i),n(a);case 11:case"end":return t.stop()}}),t,null,[[1,6]])})))}))}(e).then((function(t){return{domain:e,cost:t.totalCost}}))}));Promise.all(s).then((function(t){e.pingResults.isPoorNetwork=t.some((function(e){return e.cost>700})),e.pingResults.timestamp=a,e.pingResults.data=t,t.forEach((function(e){fK.addSuccessEvent({key:521718,cost:e.cost})})),e._log.warn("All ping results: ".concat(JSON.stringify(t)))})).catch((function(t){e._log.warn("Error during pinging domains: ".concat(t))}))}}),{delay:2e3})):this._log.info("network quality calculating is already started")}},{key:"stop",value:function(){this._log.debug("stopped"),-1!==this._interval&&(Iz.clearTask(this._interval),this._interval=-1),this._downlinkLossAndRTTMap.clear(),this._downlinkPrevStatMap.clear()}},{key:"updateDelay",value:function(e){var t=this,n=this._room.tinyIdToUserIdMap;e.forEach((function(e){var r=e.srcTinyId,i=e.videoDelay,o=e.audioDelay,a=n.get(r);if(a){var s=t._room.remotePublishedUserMap.get(a);null==s||s.setDelay({videoDelay:i,audioDelay:o})}}))}}])}(J1.default);FF(z1,"EVENT_NETWORK_QUALITY","0"),FF(z1,"lastPingTime",0);var q1=z1;var Y1=function(){return s((function e(t){var n=this;i(this,e),FF(this,"_frameWorkType"),FF(this,"_component"),FF(this,"_language"),FF(this,"connectionType"),FF(this,"_room"),FF(this,"_signalInfo",{tinyId:void 0,clientIp:"",signalIp:"",relayIp:"",relayInnerIp:"",relayPort:0,endReportExtend:void 0}),FF(this,"_keyPrefix"),FF(this,"_log"),FF(this,"_intervalId"),FF(this,"_firstPublishedUserList"),FF(this,"_networkQuality"),FF(this,"_basicInfo"),FF(this,"_pathJoinRoom"),FF(this,"_pathLeaveRoom"),FF(this,"_pathMainVideoMap"),FF(this,"_pathMainAudioMap"),FF(this,"_pathAuxiliaryMap"),FF(this,"_remoteStreamStatMap"),FF(this,"_localStreamStat"),FF(this,"_eventMap",new Map),FF(this,"_captureCostSum",0),FF(this,"_captureCostCount",0),FF(this,"isDestroyed",!1),this._frameWorkType=t.frameWorkType||30,this._component=t.component||0,this.connectionType=t.connectionType||1,this._language=t.language||0,this._room=t.room,this._keyPrefix="key_point",this._log=qW.createLogger({id:"kpm",userId:this._room.userId,sdkAppId:this._room.sdkAppId}),Object.getOwnPropertyNames(this.__proto__).forEach((function(e){e.startsWith("handle")&&oj(n[e])&&(n[e]=function(e){var t=e.fn,n=e.context;return function(){try{for(var e=arguments.length,r=new Array(e),i=0;i<e;i++)r[i]=arguments[i];var o=t.apply(n,r);return pj(o)?o.catch((function(e){return qW.error("".concat(t.name,"() error observed ").concat(e))})):o}catch(o){qW.error("".concat(t.name,"() error observed ").concat(o))}}}({fn:n[e],context:n}))})),this.initData(),this.installEvents()}),[{key:"initData",value:function(){var e=this;this._firstPublishedUserList=[],this._networkQuality={totalUplinkRTT:0,totalUplinkLoss:0,count:0,totalDownlinkRTTAndLossMap:new Map},this._basicInfo={string_sdk_version:uB,uint32_os_type:15,string_device_name:"",string_http_user_agent:navigator.userAgent,string_os_version:"",uint32_avg_rtt:0,uint32_avg_up_loss:0,uint32_scene:"live"===this._room.scene?1:0,uint32_joining_duration:0,uint32_networkType:0,uint32_framework:this._frameWorkType,uint32_component:this._component,uint32_connection_type:this.connectionType,uint32_caller_coding_language:this._language,string_domain:location.hostname},this._pathJoinRoom={uint64_start_time:0,uint64_send_request_acc_ip_cmd_start_time:0,uint64_send_request_acc_ip_cmd_end_time:0,uint64_send_request_enter_room_cmd_start_time:0,uint64_send_request_enter_room_cmd_end_time:0,uint64_send_first_video_frame_time:0,uint64_recv_userlist_time:0,uint64_end_time:0,int32_send_request_acc_ip_cmd_ret:0,int32_send_request_enter_room_cmd_ret:0,int32_end_ret:0},this._pathLeaveRoom={uint64_start_time:0,uint64_send_request_exit_room_cmd_start_time:0,uint64_send_request_exit_room_cmd_end_time:0,uint64_end_time:0,int32_send_request_exit_room_cmd_ret:0,int32_end_ret:0},this._localStreamStat={totalVideoBitrate:0,totalVideoFPS:0,totalVideoHeight:0,totalVideoWidth:0,totalAudioLevel:0,videoCount:0,audioLevelCount:0,publishStartTime:0,statsToReport:{uint32_audio_capture_db:0,uint32_video_big_capture_fps:0,uint32_video_big_bitrate:0,uint32_video_big_resolution:0}},this._pathMainVideoMap=new Map,this._pathMainAudioMap=new Map,this._pathAuxiliaryMap=new Map,this._remoteStreamStatMap=new Map,xW().then((function(t){e._basicInfo.string_os_version=VW(),e._basicInfo.string_device_name=t&&t.mobile?t.model:e._basicInfo.string_os_version}))}},{key:"addEvent",value:function(e,t){return this._eventMap.set(e,t),HW.on(e,t),this}},{key:"installEvents",value:function(){var e=this;this.handleUnload=this.handleUnload.bind(this),window.addEventListener("pagehide",this.handleUnload),this._room.once("banned",(function(){return e.handleLeaveSuccess({room:e._room,roomId:e._room.roomId})})),this.addEvent(GW.JOIN_START,this.handleJoinStart).addEvent(GW.JOIN_SCHEDULE_SUCCESS,this.handleJoinScheduleSuccess).addEvent(GW.JOIN_SIGNAL_CONNECTION_START,this.handleSignalConnectionStart).addEvent(GW.JOIN_SIGNAL_CONNECTION_END,this.handleSignalConnectionEnd).addEvent(GW.JOIN_SEND_CMD,this.handleJoinSendCMD).addEvent(GW.JOIN_RECEIVED_CMD_RES,this.handleJoinReceivedCMDResponce).addEvent(GW.JOIN_SUCCESS,this.handleJoinSuccess).addEvent(GW.JOIN_FAILED,this.handleJoinFailed).addEvent(GW.LEAVE_START,this.handleLeaveStart).addEvent(GW.LEAVE_SUCCESS,this.handleLeaveSuccess).addEvent(GW.LEAVE_SEND_CMD,this.handleLeaveSendCMD).addEvent(GW.LOCAL_TRACK_CAPTURE_START,this.handleTrackCaptureStart).addEvent(GW.LOCAL_TRACK_CAPTURE_SUCCESS,this.handleTrackCaptureSuccess).addEvent(GW.LOCAL_TRACK_CAPTURE_FAILED,this.handleTrackCaptureFailed).addEvent(GW.PUBLISH_START,this.handlePublishStart).addEvent(GW.SEND_FIRST_VIDEO_FRAME,this.handleSendFirstVideoFrame).addEvent(GW.SUBSCRIBE_START,this.handleSubscribeStart).addEvent(GW.SUBSCRIBE_SUCCESS,this.handleSubscribed).addEvent(GW.PLAY_TRACK_START,this.handlePlayStart).addEvent(GW.VIDEO_LOADED_DATA,this.handleVideoLoadedData).addEvent(GW.PLAYER_STATE_CHANGED,(function(t){var n=t.track,r=t.state,i=t.type;!n.isRemote||!e.hitTest(n.room)||"PLAYING"===r&&(i===UB.AUDIO?e.handleAudioPlaying(n):e.handleVideoPlaying(n))})).addEvent(GW.NETWORK_QUALITY,this.handleNetworkQuality).addEvent(GW.HEARTBEAT_REPORT,this.handleHeartbeatStats).addEvent(GW.RECEIVED_PUBLISHED_USER_LIST,this.handleReceivedPublishUserList).addEvent(GW.REMOTE_PUBLISH_STATE_CHANGED,(function(t){var n=t.room,r=t.prevMuteState,i=t.muteState;if(e.hitTest(n)){var o=r.hasAudio||r.hasVideo||r.hasSmall,a=r.hasAuxiliary,s=i.hasAudio||i.hasVideo||i.hasSmall,c=i.hasAuxiliary;!o&&s&&e.handleRemoteStreamAdded(i.userId,"main"),!a&&c&&e.handleRemoteStreamAdded(i.userId,"auxiliary")}})).addEvent(GW.SINGLE_CONNECTION_STAT,(function(t){var n=t.room,r=t.stat;e.hitTest(n)&&(e._pathJoinRoom.int32_ice_cost=r.ice,e._pathJoinRoom.int32_dtls_cost=r.dtls,e._pathJoinRoom.int32_peer_connection_cost=r.peerConnection)}))}},{key:"uninstallEvents",value:function(){window.removeEventListener("pagehide",this.handleUnload),this._eventMap.forEach((function(e,t){return HW.off(t,e)})),this._eventMap.clear()}},{key:"destroy",value:function(){this.uninstallEvents(),Iz.clearTask(this._intervalId),0===this._pathJoinRoom.uint64_start_time&&(this._room=null),this.isDestroyed=!0}},{key:"handleUnload",value:function(){this._room.isJoined&&this.handleLeaveSuccess({room:this._room,roomId:this._room.roomId})}},{key:"handleJoinStart",value:function(e){this.hitTest(e.room)&&(0===this._pathJoinRoom.uint64_start_time&&(this._pathJoinRoom.uint64_start_time=Date.now()),e.params&&(aj(e.params.frameWorkType)||(this._frameWorkType=e.params.frameWorkType,this._basicInfo.uint32_framework=this._frameWorkType),aj(e.params.component)||(this._component=e.params.component,this._basicInfo.uint32_component=this._component),aj(e.params.language)||(this._language=e.params.language,this._basicInfo.uint32_caller_coding_language=this._language)))}},{key:"handleJoinScheduleSuccess",value:function(e){var t=e.room,n=e.detailCost;if(this.hitTest(t)&&n){var r=n.totalCost,i=n.local,o=n.dns,a=n.tcp,s=n.tls,c=n.request,u=n.response;this._pathJoinRoom.int32_schedule_cost=r,this._pathJoinRoom.int32_schedule_local=i,this._pathJoinRoom.int32_schedule_dns=o,this._pathJoinRoom.int32_schedule_tcp=a,this._pathJoinRoom.int32_schedule_tls=s,this._pathJoinRoom.int32_schedule_request=c,this._pathJoinRoom.int32_schedule_response=u}}},{key:"handleSignalConnectionStart",value:function(e){var t=e.room;this.hitTest(t)&&0===this._pathJoinRoom.uint64_send_request_acc_ip_cmd_start_time&&(this._pathJoinRoom.uint64_send_request_acc_ip_cmd_start_time=Date.now())}},{key:"handleSignalConnectionEnd",value:function(e){var t=e.room,n=e.error;this.hitTest(t)&&0===this._pathJoinRoom.uint64_send_request_acc_ip_cmd_end_time&&(this._pathJoinRoom.uint64_send_request_acc_ip_cmd_end_time=Date.now(),n&&(this._pathJoinRoom.int32_send_request_acc_ip_cmd_ret=n instanceof tB?Number(n.getExtraCode()||n.getCode()):ZF.UNKNOWN,this._pathJoinRoom.int32_end_ret=this._pathJoinRoom.int32_send_request_acc_ip_cmd_ret))}},{key:"handleJoinSendCMD",value:function(e){this.hitTest(e.room)&&0===this._pathJoinRoom.uint64_send_request_enter_room_cmd_start_time&&(this._pathJoinRoom.uint64_send_request_enter_room_cmd_start_time=Date.now())}},{key:"handleJoinReceivedCMDResponce",value:function(e){this.hitTest(e.room)&&0===this._pathJoinRoom.uint64_send_request_enter_room_cmd_end_time&&(this._pathJoinRoom.uint64_send_request_enter_room_cmd_end_time=Date.now(),this._pathJoinRoom.int32_send_request_enter_room_cmd_ret=e.code,0!==e.code&&(this._pathJoinRoom.int32_end_ret=this._pathJoinRoom.int32_send_request_enter_room_cmd_ret))}},{key:"handleJoinSuccess",value:function(e){this.hitTest(e.room)&&0===this._pathJoinRoom.uint64_end_time&&(this._pathJoinRoom.uint64_end_time=Date.now(),this._pathJoinRoom.int32_end_ret=0,this._signalInfo=e.room.getSignalInfo())}},{key:"handleJoinFailed",value:function(e){var t=this,n=e.room,r=e.error;this.hitTest(n)&&(this._pathJoinRoom.uint64_end_time=Date.now(),0===this._pathJoinRoom.int32_end_ret&&(this._pathJoinRoom.int32_end_ret=r.code||this._pathJoinRoom.int32_send_request_enter_room_cmd_ret||this._pathJoinRoom.int32_send_request_acc_ip_cmd_ret),setTimeout((function(){t.report()})))}},{key:"handleReceivedPublishUserList",value:function(e){this.hitTest(e.room)&&0===this._pathJoinRoom.uint64_recv_userlist_time&&(this._pathJoinRoom.uint64_recv_userlist_time=Date.now(),this._firstPublishedUserList=e.publishedUserList||[])}},{key:"handleSendFirstVideoFrame",value:function(e){var t=e.room;this.hitTest(t)&&0===this._pathJoinRoom.uint64_send_first_video_frame_time&&0!==this._pathJoinRoom.uint64_start_time&&(this._pathJoinRoom.uint64_send_first_video_frame_time=Date.now())}},{key:"handleLeaveStart",value:function(e){this.hitTest(e.room)&&(this._pathLeaveRoom.uint64_start_time=Date.now())}},{key:"handleLeaveSuccess",value:function(e){this.hitTest(e.room)&&0===this._pathLeaveRoom.uint64_end_time&&(this._pathLeaveRoom.uint64_end_time=Date.now(),0!==this._pathJoinRoom.uint64_end_time?this._basicInfo.uint32_joining_duration=this._pathLeaveRoom.uint64_end_time-this._pathJoinRoom.uint64_end_time:this._log.warn("pathJoinRoom endTime is 0"),this.report())}},{key:"handleLeaveSendCMD",value:function(e){this.hitTest(e.room)&&(this._pathLeaveRoom.uint64_send_request_exit_room_cmd_start_time=Date.now(),this._pathLeaveRoom.uint64_send_request_exit_room_cmd_end_time=Date.now())}},{key:"handleRemoteStreamAdded",value:function(e,t){var n,r="".concat(e,"_").concat(t);if(!this._remoteStreamStatMap.has(r)){var i={userId:e,totalVideoFPS:0,totalVideoBitrate:0,totalAudioLevel:0,totalAudioBitrate:0,totalLoss:0,audioCount:0,audioLevelCount:0,videoCount:0,networkQualityCount:0,streamAddedTime:Date.now(),subscribeStartTime:0,subscribedTime:0,playStreamTime:0,statsToReport:OF(xF({},Q1),{msg_user_info:new $1({userId:e,tinyId:null==(n=this._room.remotePublishedUserMap.get(e))?void 0:n.tinyId,role:20})})};i.statsToReport.uint32_stream_type="main"===t?2:7,this._remoteStreamStatMap.set(r,i)}}},{key:"handleSubscribeStart",value:function(e){var t=e.room,n=e.remotePublishedUser,r=e.streamType,i=e.subscribeState;if(this.hitTest(t)){var o=n.userId,a=n.tinyId,s=n.role,c=new $1({userId:o,tinyId:a,role:"anchor"===s?20:21}),u=Date.now(),l="".concat(o,"_").concat(r),d=this._remoteStreamStatMap.get(l);d&&0===d.subscribeStartTime&&(d.subscribeStartTime=u),"main"===r?(n.muteState.hasVideo&&(i.video||i.smallVideo)&&!this._pathMainVideoMap.has(l)&&this._pathMainVideoMap.set(l,{statsToReport:{msg_user_info:c,uint64_start_enter_time:this._pathJoinRoom.uint64_start_time,uint64_render_first_frame_time:0,uint64_combine_first_frame_time:0},userId:o,sendSubscribeCMDTime:u}),n.muteState.hasAudio&&i.audio&&!this._pathMainAudioMap.has(l)&&this._pathMainAudioMap.set(l,{statsToReport:{msg_user_info:c,uint64_start_enter_time:this._pathJoinRoom.uint64_start_time,uint64_play_first_frame_time:0},userId:o,sendSubscribeCMDTime:u})):n.muteState.hasAuxiliary&&i.auxiliary&&!this._pathAuxiliaryMap.has(l)&&this._pathAuxiliaryMap.set(l,{sendSubscribeCMDTime:u})}}},{key:"handleSubscribed",value:function(e){var t=e.room,n=e.remotePublishedUser,r=e.streamType;if(this.hitTest(t)){var i="".concat(n.userId,"_").concat(r),o=this._remoteStreamStatMap.get(i);o&&0===o.subscribedTime&&(o.subscribedTime=Date.now())}}},{key:"handlePlayStart",value:function(e){var t=e.track;if(t.isRemote&&this.hitTest(t.room)){var n="".concat(t.userId,"_").concat(t.streamType),r=this._remoteStreamStatMap.get(n);0===(null==r?void 0:r.playStreamTime)&&(r.playStreamTime=Date.now())}}},{key:"handleVideoLoadedData",value:function(e){var t=e.track;if(t.isRemote&&this.hitTest(t.room)){var n="".concat(t.userId,"_").concat(t.streamType),r=this._pathMainVideoMap.get(n);r&&0===r.statsToReport.uint64_combine_first_frame_time&&(r.statsToReport.uint64_combine_first_frame_time=Date.now())}}},{key:"handleVideoPlaying",value:function(e){var t="".concat(e.userId,"_").concat(e.streamType),n=Date.now(),r=this._pathMainVideoMap.get(t),i=this._remoteStreamStatMap.get(t);if(i){var o=i.statsToReport;if(o.uint32_video_render_first||"main"!==e.streamType?this.hasAuxFlag(e.userId):this.hasVideoFlag(e.userId)){var a=n-this._pathJoinRoom.uint64_start_time;o.uint32_video_render_first=a,fK.addNumber({key:516820,value:a})}}0===(null==r?void 0:r.statsToReport.uint64_render_first_frame_time)&&(r.statsToReport.uint64_render_first_frame_time=n)}},{key:"handleAudioPlaying",value:function(e){var t="".concat(e.userId,"_").concat(e.streamType),n=this._pathMainAudioMap.get(t);n&&0===n.statsToReport.uint64_play_first_frame_time&&(n.statsToReport.uint64_play_first_frame_time=Date.now())}},{key:"handleNetworkQuality",value:function(e){var t=this;this.hitTest(e.room)&&(this._networkQuality.totalUplinkLoss+=e.uplink.loss,this._networkQuality.totalUplinkRTT+=e.uplink.rtt,this._networkQuality.count++,e.downlinks.forEach((function(e){var n,r,i,o,a=e.rtt,s=e.loss,c=e.userId,u=e.videoDelay,l=e.audioDelay,d=t._networkQuality.totalDownlinkRTTAndLossMap.get(c);d?(d.totalRTT+=a,d.totalLoss+=s,u&&(d.totalVideoDelay=(d.totalVideoDelay||0)+u,d.videoDelayCount=(d.videoDelayCount||0)+1),l&&(d.totalAudioDelay=(d.totalAudioDelay||0)+l,d.audioDelayCount=(d.audioDelayCount||0)+1),d.count++):(u&&(r=u,i=1),l&&(n=l,o=1),t._networkQuality.totalDownlinkRTTAndLossMap.set(c,{totalRTT:a,totalLoss:s,count:1,totalAudioDelay:n,totalVideoDelay:r,audioDelayCount:o,videoDelayCount:i}))})))}},{key:"handleHeartbeatStats",value:function(e){var t=this;if(this.hitTest(e.room)){var n=e.report,r=n.msg_device_info,i=n.msg_up_stream_info,o=n.msg_down_stream_info;if(i.msg_video_status[0]){var a=i.msg_video_status[0],s=a.uint32_video_codec_bitrate,c=a.uint32_video_enc_fps,u=a.uint32_video_width,l=a.uint32_video_height;this._localStreamStat.totalVideoBitrate+=s,this._localStreamStat.totalVideoFPS+=c,this._localStreamStat.totalVideoWidth+=u,this._localStreamStat.totalVideoHeight+=l,this._localStreamStat.videoCount++}if(i.msg_audio_status){var d=i.msg_audio_status.uint32_audio_level;Math.floor(d/GJ*100)>0&&(this._localStreamStat.totalAudioLevel+=d/GJ,this._localStreamStat.audioLevelCount++)}o.forEach((function(e){var n=e.msg_user_info,r=e.msg_audio_status,i=e.msg_video_status,o=n.str_identifier,a=t._room.remotePublishedUserMap.get(o);if(i.forEach((function(e){var n=2===e.uint32_video_stream_type,r=7===e.uint32_video_stream_type,i="".concat(o,"_").concat(n?"main":"auxiliary"),s=t._remoteStreamStatMap.get(i);if(s&&(n&&null!=a&&a.remoteVideoTrack.isSubscribed||r&&null!=a&&a.remoteAuxiliaryTrack)){s.totalVideoFPS+=e.uint32_video_receive_fps,s.totalVideoBitrate+=e.uint32_video_codec_bitrate,s.videoCount++,0===s.statsToReport.uint32_video_width&&(s.statsToReport.uint32_video_width=e.uint32_video_width),0===s.statsToReport.uint32_video_height&&(s.statsToReport.uint32_video_height=e.uint32_video_height);var c=n?a.remoteVideoTrack:a.remoteAuxiliaryTrack;c.stat.jitterBufferDelay&&(s.videoJitterBufferDelay=c.stat.jitterBufferDelay),c.stat.framesReceived&&(s.statsToReport.uint32_video_consume_render_rate=Math.floor(c.stat.framesDecoded/c.stat.framesReceived*DF(10,6)))}})),!Sj(r)){var s="".concat(o,"_main"),c=t._remoteStreamStatMap.get(s);t._remoteStreamStatMap.has(s)&&c&&null!=a&&a.remoteAudioTrack.isSubscribed&&(c.totalAudioBitrate+=r.uint32_audio_codec_bitrate,c.audioCount++,a.remoteAudioTrack.stat.jitterBufferDelay&&(c.audioJitterBufferDelay=a.remoteAudioTrack.stat.jitterBufferDelay),Math.floor(r.uint32_audio_level/GJ*100)>0&&(c.totalAudioLevel+=r.uint32_audio_level/GJ,c.audioLevelCount++))}})),r.uint32_audio_capture_cost&&(this._captureCostSum+=r.uint32_audio_capture_cost,this._captureCostCount+=1,this._captureCostCount>=100&&(this._basicInfo.uint32_audio_capture_cost=Math.floor(this._captureCostSum/this._captureCostCount),this._captureCostSum=0,this._captureCostCount=0))}}},{key:"handlePublishStart",value:function(e){var t=e.room;this.hitTest(t)&&0===this._localStreamStat.publishStartTime&&(this._localStreamStat.publishStartTime=Date.now())}},{key:"handleTrackCaptureStart",value:function(e){var t=e.track;1===t.mediaType&&!this._pathJoinRoom.uint64_init_audio_start_time&&(this._pathJoinRoom.uint64_init_audio_start_time=Date.now()),4===t.mediaType&&!this._pathJoinRoom.uint64_init_camera_start_time&&(this._pathJoinRoom.uint64_init_camera_start_time=Date.now())}},{key:"handleTrackCaptureSuccess",value:function(e){var t=e.track;1===t.mediaType&&!this._pathJoinRoom.uint64_init_audio_end_time&&(this._pathJoinRoom.int32_init_audio_ret=0,this._pathJoinRoom.uint64_init_audio_end_time=Date.now()),4===t.mediaType&&!this._pathJoinRoom.uint64_init_camera_end_time&&(this._pathJoinRoom.int32_init_camera_ret=0,this._pathJoinRoom.uint64_init_camera_end_time=Date.now())}},{key:"handleTrackCaptureFailed",value:function(e){var t=e.track,n=e.error,r={NotFoundError:1,NotAllowedError:2,NotReadableError:3,OverConstrainedError:4,AbortError:5,InvalidStateError:6,SecurityError:7,TypeError:8}[n.name]||(n instanceof tB?n.getExtraCode()||n.getCode():ZF.UNKNOWN);1===t.mediaType&&!this._pathJoinRoom.uint64_init_audio_end_time&&(this._pathJoinRoom.int32_init_audio_ret=r,this._pathJoinRoom.uint64_init_audio_end_time=Date.now()),4===t.mediaType&&!this._pathJoinRoom.uint64_init_camera_end_time&&(this._pathJoinRoom.int32_init_camera_ret=r,this._pathJoinRoom.uint64_init_camera_end_time=Date.now())}},{key:"hasVideoFlag",value:function(e){return this._firstPublishedUserList.findIndex((function(t){return t.userId===e&&t.flag&jB}))>=0}},{key:"hasAudioFlag",value:function(e){return this._firstPublishedUserList.findIndex((function(t){return t.userId===e&&t.flag&JB}))>=0}},{key:"hasAuxFlag",value:function(e){return this._firstPublishedUserList.findIndex((function(t){return t.userId===e&&t.flag&WB}))>=0}},{key:"hitTest",value:function(e){return e===this._room}},{key:"prepareReport",value:function(){var e=this;if(this._captureCostCount>0&&!this._basicInfo.uint32_audio_capture_cost&&(this._basicInfo.uint32_audio_capture_cost=Math.floor(this._captureCostSum/this._captureCostCount),this._captureCostSum=0,this._captureCostCount=0),this._networkQuality.count>0&&(this._basicInfo.uint32_avg_rtt=Math.floor(this._networkQuality.totalUplinkRTT/this._networkQuality.count),this._basicInfo.uint32_avg_up_loss=Math.floor(this._networkQuality.totalUplinkLoss/this._networkQuality.count)),this._localStreamStat.videoCount>0){this._localStreamStat.statsToReport.uint32_video_big_capture_fps=Math.floor(this._localStreamStat.totalVideoFPS/this._localStreamStat.videoCount),this._localStreamStat.statsToReport.uint32_video_big_bitrate=Math.floor(this._localStreamStat.totalVideoBitrate/this._localStreamStat.videoCount);var t=Math.floor(this._localStreamStat.totalVideoWidth/this._localStreamStat.videoCount),n=Math.floor(this._localStreamStat.totalVideoHeight/this._localStreamStat.videoCount);this._localStreamStat.statsToReport.uint32_video_big_resolution=t<<16|n}this._localStreamStat.audioLevelCount>0&&(this._localStreamStat.statsToReport.uint32_audio_capture_db=Math.floor(this._localStreamStat.totalAudioLevel/this._localStreamStat.audioLevelCount*100)),this._remoteStreamStatMap.forEach((function(t,n){var r=t.userId,i=e._networkQuality.totalDownlinkRTTAndLossMap.get(r);if(i){var o=i.totalLoss,a=i.count,s=i.audioDelayCount,c=i.videoDelayCount,u=i.totalAudioDelay,l=i.totalVideoDelay;t.statsToReport.uint32_avg_down_loss=Math.floor(o/a),s&&u&&(t.statsToReport.uint32_audio_network_p2p_delay=Math.floor(u/s),t.audioJitterBufferDelay&&(t.statsToReport.uint32_p2p_delay=Math.floor(t.statsToReport.uint32_audio_network_p2p_delay+t.audioJitterBufferDelay))),c&&l&&(t.statsToReport.uint32_video_network_p2p_delay=Math.floor(l/c))}t.videoCount>0&&(t.statsToReport.uint32_video_avg_fps=Math.floor(t.totalVideoFPS/t.videoCount),t.statsToReport.uint32_video_avg_bitrate=Math.floor(t.totalVideoBitrate/t.videoCount)),t.audioCount>0&&(t.statsToReport.uint32_audio_recv_bitrate=t.statsToReport.uint32_audio_bitrate=Math.floor(t.totalAudioBitrate/t.audioCount)),t.audioLevelCount>0&&(t.statsToReport.uint32_audio_play_db=Math.floor(t.totalAudioLevel/t.audioLevelCount*100));var d=e._room.callDurationCalculator;d&&(t.statsToReport.uint32_audio_play_time=d.getDuration(n,UB.AUDIO),t.statsToReport.uint32_video_play_time=d.getDuration(n,UB.VIDEO)),t.statsToReport.uint32_video_render_first&&(t.statsToReport.uint32_video_render_first=Math.min(t.statsToReport.uint32_video_render_first,X1));var h=e._room.badCaseDetector,f=h.getDataFreezeDuration(n),p=f.dataFreeze,m=f.count,v=h.getRenderFreezeDuration(n).renderFreeze;t.statsToReport.uint32_video_block_count=m,t.statsToReport.uint32_video_block_time=Math.min(p,t.statsToReport.uint32_video_play_time),t.statsToReport.uint32_video_external_block_time=Math.min(v,t.statsToReport.uint32_video_play_time),h.isBlackStream(n)&&0===t.statsToReport.uint32_video_avg_fps?t.statsToReport.uint32_video_black_screen_subjective=1:t.statsToReport.uint32_video_black_screen_subjective=0})),this._pathMainAudioMap.forEach((function(t,n){e.hasAudioFlag(t.userId)?t.statsToReport.uint64_play_first_frame_time-t.statsToReport.uint64_start_enter_time>X1&&(t.statsToReport.uint64_play_first_frame_time=t.statsToReport.uint64_start_enter_time+X1):e._pathMainAudioMap.delete(n)})),this._pathMainVideoMap.forEach((function(t,n){e.hasVideoFlag(t.userId)?t.statsToReport.uint64_render_first_frame_time-t.statsToReport.uint64_start_enter_time>X1&&(t.statsToReport.uint64_render_first_frame_time=t.statsToReport.uint64_start_enter_time+X1):e._pathMainVideoMap.delete(n)})),this._pathJoinRoom.uint64_end_time-this._pathJoinRoom.uint64_start_time>X1&&(this._pathJoinRoom.uint64_end_time=this._pathJoinRoom.uint64_start_time+X1)}},{key:"getReportData",value:function(){this._basicInfo.uint32_networkType=zH();var e={uint32_sdk_app_id:Number(this._room.sdkAppId),msg_user_info:new $1({userId:this._room.userId,tinyId:this._room.tinyId,role:"anchor"===this._room.role?20:21}),msg_basic_info:this._basicInfo,uint32_acc_ip:Aj(this._signalInfo.relayIp),uint32_client_ip:Aj(this._signalInfo.clientIp,!1),uint32_acc_port:this._signalInfo.relayPort||0,uint64_timestamp:Date.now(),uint32_seq:Math.floor(Math.random()*DF(2,31)),msg_path_enter_room:this._pathJoinRoom,msg_path_exit_room:this._pathLeaveRoom,msg_path_recv_video:T(this._pathMainVideoMap.values()).map((function(e){return e.statsToReport})),msg_quality_statistics:T(this._remoteStreamStatMap.values()).map((function(e){return e.statsToReport})),str_room_name:String(this._room.roomId||0),msg_path_recv_audio:T(this._pathMainAudioMap.values()).map((function(e){return e.statsToReport})),uint32_info_client_ip:Aj(this._signalInfo.clientIp,!1),error_code:[],msg_local_statistics:this._localStreamStat.statsToReport,bytes_report_buf_from_0x1:this._signalInfo.endReportExtend};return Uj(e),e}},{key:"report",value:function(){return HF(this,null,p().mark((function e(){var t;return p().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,this.prepareReport(),t=this.getReportData(),e.next=5,this.upload(t);case 5:this.initData(),e.next=11;break;case 8:e.prev=8,e.t0=e.catch(0),this._log.warn(e.t0);case 11:return e.prev=11,this.isDestroyed&&(this._room=null),e.finish(11);case 14:case"end":return e.stop()}}),e,this,[[0,8,11,14]])})))}},{key:"upload",value:function(e){return HF(this,null,p().mark((function t(){var n,r,i,o,a,s;return p().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(0!==e.msg_path_enter_room.uint64_start_time){t.next=2;break}return t.abrupt("return");case 2:return n=Number(this._room.sdkAppId),t.next=5,jj(e);case 5:return r=t.sent,i=r instanceof ArrayBuffer,o="".concat(jH(n,CB.KEY_POINT),"&gzip=").concat(+i),a=!1,navigator.sendBeacon&&(a=navigator.sendBeacon(o,r)),s=[this.uploadKVStat(fK),this.uploadKVStat(hK)],a||s.push(Hj({url:o,body:r,priority:"low"})),t.next=14,Promise.all(s);case 14:case"end":return t.stop()}}),t,this)})))}},{key:"setConnectionType",value:function(e){this.connectionType=e,this._basicInfo.uint32_connection_type=e}},{key:"uploadKVStat",value:function(e){return HF(this,null,p().mark((function t(){var n,r,i,o;return p().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(0!==(n=e.getReportData()).stats_count.length||0!==n.stats_distribution.length){t.next=3;break}return t.abrupt("return");case 3:return n.msg_sdk_basic_info=OF(xF({},n.msg_sdk_basic_info),{bytes_device_name:this._basicInfo.string_device_name||"",bytes_os_version:this._basicInfo.string_os_version||"",uint32_framework:this._frameWorkType,uint32_network_type:this._basicInfo.uint32_networkType||0}),this._log.debug(n),t.next=6,jj(n);case 6:r=t.sent,i="".concat(jH(+this._room.sdkAppId,CB.KV_STAT),"&gzip=").concat(+(r instanceof ArrayBuffer)),o=!1,navigator.sendBeacon&&(o=navigator.sendBeacon(i,r)),o||Hj({url:i,body:r});case 10:case"end":return t.stop()}}),t,this)})))}}])}();UF([Oz({settings:{timeout:500,retries:3}})],Y1.prototype,"upload",1);var X1=5e3,Q1={msg_user_info:null,uint32_video_avg_fps:0,uint32_video_width:0,uint32_video_height:0,uint32_video_avg_bitrate:0,uint32_video_block_time:0,uint32_video_play_time:0,uint32_audio_block_time:0,uint32_audio_play_time:0,uint32_audio_play_db:0,uint32_avg_down_loss:0,uint32_stream_type:0,uint32_video_block_count:0,uint32_audio_block_count:0,uint32_audio_bitrate:0,uint32_video_black_screen_subjective:0,uint32_audio_recv_bitrate:0,uint32_video_external_block_time:0,uint32_video_consume_render_rate:0},$1=s((function e(t){i(this,e),FF(this,"str_identifier"),FF(this,"str_tinyid"),FF(this,"uint32_role"),this.str_identifier=String(t.userId),this.str_tinyid=String(t.tinyId||0),this.uint32_role=t.role})),Z1=Y1,e2=function(){return s((function e(){i(this,e),FF(this,"_startTime"),FF(this,"_endTime"),this._startTime=0,this._endTime=0,this.start()}),[{key:"start",value:function(){0===this._startTime&&(this._startTime=yj())}},{key:"stop",value:function(){0===this._endTime&&(this._endTime=yj())}},{key:"getDuration",value:function(){return 0===this._endTime?yj()-this._startTime:this._endTime-this._startTime}},{key:"startTime",get:function(){return this._startTime}},{key:"endTime",get:function(){return this._endTime}}])}(),t2=function(){return s((function e(t){i(this,e),FF(this,"_room",null),FF(this,"_durationMap"),FF(this,"_eventMap",new Map),this._room=t.room,this._durationMap=new Map,this.installEvents()}),[{key:"installEvents",value:function(){var e=this;this._eventMap.set(GW.REMOTE_TRACK_SUBSCRIBED,this.handleSubscribed).set(GW.REMOTE_TRACK_UNSUBSCRIBED,this.handleUnsubscribed).set(GW.REMOTE_PUBLISH_STATE_CHANGED,(function(t){var n,r=t.room,i=t.prevMuteState,o=t.muteState,a=o.userId;if(e.hitTest(r)){i.hasAudio&&!o.hasAudio&&e.stopDurationItem("".concat(a,"_main"),UB.AUDIO),i.hasVideo&&!o.hasVideo&&e.stopDurationItem("".concat(a,"_main"),UB.VIDEO),i.hasAuxiliary&&!o.hasAuxiliary&&e.stopDurationItem("".concat(a,"_auxiliary"),UB.VIDEO);var s=null==(n=e._room)?void 0:n.remotePublishedUserMap.get(a);s&&(!i.hasAudio&&o.hasAudio&&s.remoteAudioTrack.isSubscribed&&e.addDuractionItem(a,UB.AUDIO,"main"),!i.hasVideo&&o.hasVideo&&s.remoteVideoTrack.isSubscribed&&e.addDuractionItem(a,UB.VIDEO,"main"),!i.hasAuxiliary&&o.hasAuxiliary&&s.remoteAuxiliaryTrack.isSubscribed&&e.addDuractionItem(a,UB.VIDEO,"auxiliary"))}})),this._eventMap.forEach((function(t,n){return HW.on(n,t,e)}))}},{key:"uninstallEvents",value:function(){var e=this;this._eventMap.forEach((function(t,n){return HW.off(n,t,e)})),this._eventMap.clear()}},{key:"handleSubscribed",value:function(e){var t=e.track;if(this.hitTest(t.room)){var n=t.userId,r=t.streamType,i=t.kind;t.isSubscribed?this.addDuractionItem(n,i,r):this.stopDurationItem("".concat(n,"_").concat(r),i)}}},{key:"handleUnsubscribed",value:function(e){var t=e.track;this.hitTest(t.room)&&this.stopDurationItem("".concat(t.userId,"_").concat(t.streamType),t.kind)}},{key:"isRecording",value:function(e){return e.findIndex((function(e){return 0===e.endTime}))>=0}},{key:"addDuractionItem",value:function(e,t,n){var r="".concat(e,"_").concat(n),i=new e2,o=this._durationMap.get(r);o?this.isRecording(o[t])||o[t].push(i):this._durationMap.set(r,{userId:e,type:n,audio:t===UB.AUDIO?[i]:[],video:t===UB.AUDIO?[]:[i]})}},{key:"stopDurationItem",value:function(e,t){if(this._durationMap.has(e)){var n=this._durationMap.get(e)[t].find((function(e){return 0===e.endTime}));n&&n.stop()}}},{key:"hitTest",value:function(e){return this._room===e}},{key:"getDuration",value:function(e,t){return this._durationMap.has(e)?this._durationMap.get(e)[t].reduce((function(e,t){return e+t.getDuration()}),0):0}},{key:"getDurationMap",value:function(){return this._durationMap}},{key:"reset",value:function(){this._durationMap.clear()}},{key:"destroy",value:function(){this._room=null,this.uninstallEvents()}}])}(),n2=t2,r2=function(){return s((function e(t){i(this,e),FF(this,"_room"),FF(this,"_renderFreezeMap",new Map),FF(this,"_isVideoPlayingEventFiredMap",new Map),FF(this,"_dataFreezeMap",new Map),FF(this,"_monitorFreezeData",new Map),FF(this,"_eventMap",new Map),this._room=t.room,this.installEvents()}),[{key:"getRenderFreezeMap",value:function(){return this._renderFreezeMap}},{key:"getDataFreezeMap",value:function(){return this._dataFreezeMap}},{key:"installEvents",value:function(){var e=this;this._eventMap.set(GW.LEAVE_SUCCESS,(function(t){var n=t.room;e.hitTest(n)&&e.stop()})).set(GW.PLAY_TRACK_START,this.onPlayTrackStart).set(GW.UNSUBSCRIBE_SUCCESS,(function(t){var n=t.room,r=t.streamType,i=t.remotePublishedUser;if(e.hitTest(n)){var o=i.userId,a="".concat(o,"_").concat(r);e.stopDataFreeze({key:a,userId:o,type:r})}})).set(GW.REMOTE_PUBLISH_STATE_CHANGED,(function(t){var n=t.room,r=t.prevMuteState,i=t.muteState;if(e.hitTest(n)){var o=i.userId;if(r.hasVideo&&!i.hasVideo){var a="main",s="".concat(i.userId,"_").concat(a);e.stopDataFreeze({key:s,userId:o,type:a})}if(r.hasAuxiliary&&!i.hasAuxiliary){var c="auxiliary",u="".concat(i.userId,"_").concat(c);e.stopDataFreeze({key:u,userId:o,type:c})}}})).set(GW.PLAYER_STATE_CHANGED,(function(t){var n=t.track,r=t.state,i=t.reason,o=t.type;if(n.isRemote&&n.room&&e.hitTest(n.room)&&o===UB.VIDEO){if("PLAYING"===r){var a="".concat(n.userId,"_").concat(n.streamType);e._isVideoPlayingEventFiredMap.set(a,!0)}i===UB.MUTE?e.onVideoTrackMuted(n):i===UB.UNMUTE&&e.onVideoTrackUnmuted(n)}})).set(GW.HEARTBEAT_REPORT,this.onHearBeatReport),this._eventMap.forEach((function(t,n){return HW.on(n,t,e)}))}},{key:"uninstallEvents",value:function(){var e=this;this._eventMap.forEach((function(t,n){return HW.off(n,t,e)})),this._eventMap.clear()}},{key:"stop",value:function(){this._renderFreezeMap.clear(),this._dataFreezeMap.clear(),this._isVideoPlayingEventFiredMap.clear()}},{key:"onVideoTrackMuted",value:function(e){if(e.isSubscribed){var t=e.userId,n=e.streamType,r="".concat(t,"_").concat(n),i=this._dataFreezeMap.get(r),o=new e2;i?i.durationItemList.push(o):this._dataFreezeMap.set(r,{userId:t,type:n,durationItemList:[o],isFreezing:function(){var e=this.durationItemList[this.durationItemList.length-1];return e&&0===e.endTime}})}}},{key:"onVideoTrackUnmuted",value:function(e){if(e.isSubscribed){var t=e.userId,n=e.streamType,r="".concat(t,"_").concat(n);this.stopDataFreeze({key:r,userId:t,type:n})}}},{key:"onHearBeatReport",value:function(e){var t=this,n=e.room,r=e.report;this.hitTest(n)&&r.msg_down_stream_info.forEach((function(e){var n=t._room.remotePublishedUserMap.get(e.msg_user_info.str_identifier);if(n){var r=n.userId,i=n.muteState;e.msg_video_status.forEach((function(e){2===e.uint32_video_stream_type&&i.hasVideo&&!i.videoMuted&&n.remoteVideoTrack.isSubscribed&&t.handleRenderFreeze({userId:r,fps:e.uint32_video_dec_fps,type:"main"}),7===e.uint32_video_stream_type&&i.hasAuxiliary&&n.remoteAuxiliaryTrack.isSubscribed&&t.handleRenderFreeze({userId:r,fps:e.uint32_video_dec_fps,type:"auxiliary"})}))}}))}},{key:"stopDataFreeze",value:function(e){var t=e.key,n=e.userId,r=e.type,i=this._dataFreezeMap.get(t);if(i&&i.isFreezing()){var o=i.durationItemList[i.durationItemList.length-1];o.stop();var a=o.getDuration();a>kH?this._monitorFreezeData.set(t,{userId:n,type:r,duration:a}):i.durationItemList.pop()}}},{key:"getTotalDuration",value:function(e){return e.reduce((function(e,t){var n=t.getDuration();return e+Math.min(n,5e3)}),0)}},{key:"handleRenderFreeze",value:function(e){return HF(this,arguments,(function(e){var t=this,n=e.userId,r=e.fps,i=e.type;return p().mark((function e(){var o,a,s,c,u;return p().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:o="".concat(n,"_").concat(i),a=t._renderFreezeMap.get(o),r<=2?(s=yj(),a&&!a.isFreeze&&(a.freezeTimeline.push({startTime:s,endTime:0}),a.isFreeze=!0),a||t._renderFreezeMap.set(o,{userId:n,type:i,isFreeze:!0,freezeTimeline:[{startTime:s,endTime:0}],renderFreezeTotal:0})):a&&a.isFreeze&&(a.isFreeze=!1,(c=a.freezeTimeline.pop())&&(c.endTime=yj(),u=c.endTime-c.startTime,a.freezeTimeline.push(c),a.renderFreezeTotal+=Math.min(5e3,u)));case 2:case"end":return e.stop()}}),e)}))()}))}},{key:"onPlayTrackStart",value:function(e){var t=e.track;if(t.isRemote&&this.hitTest(t.room)&&t.kind===UB.VIDEO&&t.isRemotePublished){var n="".concat(t.userId,"_").concat(t.streamType);this._isVideoPlayingEventFiredMap.has(n)||this._isVideoPlayingEventFiredMap.set(n,!1)}}},{key:"getDataFreezeDuration",value:function(e){var t={dataFreeze:0,count:0},n=this._dataFreezeMap.get(e);if(n){if(n.isFreezing()){var r=n.durationItemList[n.durationItemList.length-1];r.stop(),r.getDuration()<kH&&n.durationItemList.pop()}t.dataFreeze=this.getTotalDuration(n.durationItemList),t.count=n.durationItemList.length}return t}},{key:"getRenderFreezeDuration",value:function(e){var t=this._renderFreezeMap.get(e),n=0,r=0;if(t)if(t.isFreeze){var i=yj()-t.freezeTimeline[t.freezeTimeline.length-1].startTime;n=t.renderFreezeTotal+Math.min(i,5e3),r=t.freezeTimeline.length}else n=t.renderFreezeTotal;return{renderFreeze:n,count:r}}},{key:"getMonitorFreeze",value:function(){return this._monitorFreezeData}},{key:"isBlackStream",value:function(e){return!!this._isVideoPlayingEventFiredMap.has(e)&&!this._isVideoPlayingEventFiredMap.get(e)}},{key:"resetMonitor",value:function(){this._monitorFreezeData.clear()}},{key:"hitTest",value:function(e){return e===this._room}},{key:"destroy",value:function(){this.uninstallEvents()}}])}(),i2=r2,o2=VF(jF(),1),a2=[1,0,0,0,1,1,0,1],s2=function(e){function t(e,n){var o;if(i(this,t),o=r(this,t,[e,{useDefaultProgram:!0,useFbo:!0,create2d:!0,name:"mirror",logger:n}]),e instanceof P$)try{o.setTexBuffer(a2)}catch(hH){e.destroy(new tB({code:ZF.VIDEO_MANAGER_ERROR,extraCode:3,message:"create video node ".concat(o.name," error ").concat(hH.message||hH)}))}return o}return d(t,e),s(t,[{key:"draw2d",value:function(e,n,r,i,o){if(this.ctx2d){this.ctx2d.save(),this.ctx2d.scale(-1,1),this.ctx2d.translate(-this.width,0);var a=y(t,"draw2d",this,3)([e,n,r,i,o]);return this.ctx2d.restore(),a}return!1}},{key:"render",value:function(e){var t;return!(null==(t=this.input)||!t.requestFrame(e))&&(this.useProgram(),this.useBufferFrame(),this.useInputTexture(),this.draw(),!0)}}])}(T$),c2=function(){return s((function e(t,n){i(this,e),this.node=t,this.layout=n,FF(this,"positionBuffer")}),[{key:"x",get:function(){return this.layout.x||this.node.x}},{key:"y",get:function(){return this.layout.y||this.node.y}},{key:"width",get:function(){return this.layout.width||this.node.width}},{key:"height",get:function(){return this.layout.height||this.node.height}},{key:"right",get:function(){return this.x+this.width}},{key:"bottom",get:function(){return this.y+this.height}}])}(),u2=function(e){function t(e,n){var o;return i(this,t),o=r(this,t,[e,{useDefaultProgram:!0,useFbo:!0,name:"mix",create2d:!0,logger:n}]),FF(o,"inputs",[]),o}return d(t,e),s(t,[{key:"addInput",value:function(e,t){if(this.inputs[t.zIndex])throw new Error("input already exists");var n=new c2(e,t);this.inputs[t.zIndex]=n}},{key:"resize",value:function(e,n){var r=this,i=this.inputs.reduce((function(e,t){return t?Object.assign(e,{width:Math.max(e.width,t.right),height:Math.max(e.height,t.bottom)}):e}),{width:0,height:0});y(t,"resize",this,3)([i.width,i.height]),this.context instanceof P$&&this.inputs.forEach((function(e){if(e){var t=r.layout2texCoords(e);e.positionBuffer?r.changeBufferData(e.positionBuffer,t):e.positionBuffer=r.createBuffer(t)}}))}},{key:"connect",value:function(e){for(var n=arguments.length,r=new Array(n>1?n-1:0),i=1;i<n;i++)r[i-1]=arguments[i];return y(t,"connect",this,3)([e].concat(r)),this.resize(0,0),e}},{key:"removeInput",value:function(e){this.inputs[this.inputs.findIndex((function(t){return(null==t?void 0:t.node)===e}))]=void 0}},{key:"render",value:function(e){var t=this.context.ctx;if(t.clearColor(0,0,0,0),!this.inputs.reduce((function(t,n){return(!n||!n.node.requestFrame(e))&&t}),!0)&&t){this.useProgram(),t.enable(t.BLEND),t.blendFunc(t.SRC_ALPHA,t.ONE_MINUS_SRC_ALPHA),this.useBufferFrame();for(var n=0;n<this.inputs.length;n++){var r=this.inputs[n];r&&(r.node.useTexture(),this.draw(r.positionBuffer))}return!0}return!1}},{key:"render2d",value:function(e){if(!this.inputs.reduce((function(t,n){return(!n||!n.node.requestFrame(e))&&t}),!0)&&this.ctx2d){this.ctx2d.clearRect(0,0,this.width,this.height);for(var t=0;t<this.inputs.length;t++){var n=this.inputs[t];n&&this.draw2d(n.node.image,n.x,n.y,n.width,n.height)}return!0}return!1}},{key:"getInfo",value:function(){var e=this.totalFrames,t=this.x,n=this.y,r=this.width,i=this.height,o=this.name,a=Date.now(),s=(e-this.lastInfo.totalFrames)/((a-this.lastInfo.timestamp)/1e3)|0;return this.lastInfo={totalFrames:e,x:t,y:n,width:r,height:i,timestamp:a,fps:s,name:o},xF({parent:this.inputs.filter((function(e){return e})).map((function(e){return e.node.getInfo()}))},this.lastInfo)}},{key:"close",value:function(){var e=this;y(t,"close",this,3)([]),this.inputs.forEach((function(t){var n,r;if(t&&(null==(n=t.node)||n.disconnect(),t.positionBuffer&&e.context instanceof P$))try{null==(r=e.context.ctx)||r.deleteBuffer(t.positionBuffer)}catch(sJ){}}))}}])}(T$),l2=function(e){function t(e,n){var o;i(this,t),o=r(this,t,[e,n.input,{name:"vb",create2d:!1,useDefaultProgram:!1,useFbo:!1,createTexture:!0,logger:e.log}]),FF(o,"_bgTexture"),FF(o,"_waterMarkTexture"),FF(o,"_lastMaskTexture"),FF(o,"_lastMaskFbo"),FF(o,"_textureValid",!1),FF(o,"_selfieTextureValid",!1),FF(o,"_selfieSegmentation"),FF(o,"wasm"),FF(o,"_prePrograme"),FF(o,"_segmentationMask"),FF(o,"_weixin",!1),n.selfieSegmentation&&(o._selfieSegmentation=n.selfieSegmentation,o._selfieSegmentation.onResults=o.onPredict.bind(o));try{o.init(n)}catch(iJ){e.log.error(iJ),e.destroy(new tB({code:ZF.VIDEO_MANAGER_ERROR,extraCode:6,message:"init vb node error ".concat(iJ.message||iJ)}))}return o}return d(t,e),s(t,[{key:"init",value:function(e){var t=e.Wasm,n=this.context.ctx;if(this.wasm=new t.AllIn1(n),this.wasm.blurRadius=e.blurRadius||3,this.wasm.mirror=!!e.mirror,this.wasm.vbMode="blur"===e.bg?1:e.bg instanceof HTMLImageElement?2:"green"===e.bg?3:0,e.waterMark){var r=e.waterMark,i=r.x,o=r.y,a=r.width,s=r.height;this.wasm.setWaterMark(i,o,a,s)}if(e.beautyParams){var c=e.beautyParams,u=c.beauty,l=c.brightness,d=c.ruddy;this.wasm.setBeauty(u,l,d,null==e?void 0:e.width,null==e?void 0:e.height)}if(this.program=this.wasm.init(),this.useProgram(),this.setAttributes(this.positionBuffer,this.texCoordBuffer),n.uniform1i(n.getUniformLocation(this.program,"mask"),1),e.bg instanceof HTMLImageElement&&(n.uniform1i(n.getUniformLocation(this.program,"bg"),2),this._bgTexture=this.createTexture(e.bg)),e.waterMark&&(n.uniform1i(n.getUniformLocation(this.program,"waterMark"),3),this._waterMarkTexture=this.createTexture(e.waterMark.image)),n.uniform1i(n.getUniformLocation(this.program,"lastMask"),4),this._weixin){var h=this.context.createShader(n.FRAGMENT_SHADER,"#version 300 es\nprecision highp float;\nuniform sampler2D u_texture;\nuniform sampler2D mask;\n\nin vec2 v_texCoord;\nout vec4 outColor;\nvoid main() {\n outColor = vec4(texture(u_texture, v_texCoord).rgb, texture(mask, v_texCoord).a);\n}"),f=this.context.createShader(n.VERTEX_SHADER,"#version 300 es\nin vec2 a_position;\nin vec2 a_texCoord;\nout vec2 v_texCoord;\nvoid main() {\n gl_Position = vec4(a_position.x, a_position.y, 0, 1);\n v_texCoord = a_texCoord;\n}");this._prePrograme=this.context.createProgram(f,h),n.useProgram(this._prePrograme),this.setAttributes(this.positionBuffer,this.texCoordBuffer),n.uniform1i(n.getUniformLocation(this._prePrograme,"mask"),1)}}},{key:"onPredict",value:function(e){var t,n=this.context.ctx;this._weixin&&(this._lastMaskTexture||(this._lastMaskTexture=this.createTexture(this.image),this._lastMaskFbo=this.createFramebuffer(this._lastMaskTexture))),this.useProgram(),this._weixin?this.useTexture():null==this||this._selfieSegmentation.bindTexture(),n.activeTexture(n.TEXTURE1),null==(t=this._selfieSegmentation)||t.bindTexture2d(e),n.activeTexture(n.TEXTURE2),n.bindTexture(n.TEXTURE_2D,this._bgTexture||null),n.activeTexture(n.TEXTURE3),n.bindTexture(n.TEXTURE_2D,this._waterMarkTexture||null),this.useBufferFrame(),n.drawArrays(n.TRIANGLE_STRIP,0,4),this._segmentationMask=e,this.totalFrames++}},{key:"render",value:function(e){var t,n,r,i,o=this.context.ctx,a=this.image;this.tryVideoFrameCallback(a);var s=a.videoWidth,c=a.videoHeight;if(0===s||0===c)return!1;a.width=s,a.height=c;var u=!1;if(this.totalFrames)this._weixin?this.useTexture():null==(t=this._selfieSegmentation)||t.bindTexture(),u=this._selfieTextureValid,this._selfieTextureValid=!0;else{if(!this.program)return!1;this.useTexture(),u=this._textureValid,this._textureValid=!0}return this.width===s&&this.height===c&&u?o.texSubImage2D(o.TEXTURE_2D,0,0,0,o.RGBA,o.UNSIGNED_BYTE,a):(this.resize(s,c),o.texImage2D(o.TEXTURE_2D,0,o.RGBA,o.RGBA,o.UNSIGNED_BYTE,a)),this._weixin&&(o.useProgram(this._prePrograme),this.useTexture(),this._segmentationMask&&(o.activeTexture(o.TEXTURE1),null==(n=this._selfieSegmentation)||n.bindTexture2d(this._segmentationMask),o.bindFramebuffer(o.FRAMEBUFFER,this._lastMaskFbo||null)),o.drawArrays(o.TRIANGLE_STRIP,0,4),null==(r=this._selfieSegmentation)||r.bindTexture(),this._segmentationMask?o.copyTexSubImage2D(o.TEXTURE_2D,0,0,0,0,0,s,c):o.copyTexImage2D(o.TEXTURE_2D,0,o.RGBA,0,0,s,c,0)),null==(i=this._selfieSegmentation)||i.send(s,c),this.totalFrames||(o.activeTexture(o.TEXTURE2),o.bindTexture(o.TEXTURE_2D,this._bgTexture||null),o.activeTexture(o.TEXTURE3),o.bindTexture(o.TEXTURE_2D,this._waterMarkTexture||null),o.drawArrays(o.TRIANGLE_STRIP,0,4)),!1}},{key:"close",value:function(){var e;y(t,"close",this,3)([]);var n=this.context.ctx;this._bgTexture&&n.deleteTexture(this._bgTexture),this._waterMarkTexture&&n.deleteTexture(this._waterMarkTexture),this._lastMaskTexture&&n.deleteTexture(this._lastMaskTexture),this._lastMaskFbo&&n.deleteFramebuffer(this._lastMaskFbo),this._prePrograme&&n.deleteProgram(this._prePrograme),null==(e=this.wasm)||e.close()}}])}(D$),d2=function(e){function t(e){var n;i(this,t),n=r(this,t,[e,{name:"yuv-source",useDefaultProgram:!1,create2d:!1,useFbo:!1,createTexture:!1,logger:e.log,fragmentShaderSource:"\n precision highp float;\n uniform sampler2D ySampler;\n uniform sampler2D uSampler;\n uniform sampler2D vSampler;\n varying highp vec2 textureCoord;\n const mat4 YUV2RGB = mat4(\n 1.1643828125, 0, 1.59602734375, -.87078515625,\n 1.1643828125, -.39176171875, -.81296875, .52959375,\n 1.1643828125, 2.017234375, 0, -1.081390625,\n 0, 0, 0, 1);\n void main() {\n vec3 yuv;\n yuv.r = texture2D(ySampler, textureCoord).r;\n yuv.g = texture2D(uSampler, textureCoord).r;\n yuv.b = texture2D(vSampler, textureCoord).r;\n gl_FragColor = vec4(yuv,1) * YUV2RGB;\n }\n ",vertexShaderSource:"\n attribute vec4 vertexPos;\n attribute vec2 texturePos;\n varying vec2 textureCoord;\n void main() {\n gl_Position = vertexPos;\n textureCoord = texturePos;\n }"}]),FF(n,"yTextureRef"),FF(n,"uTextureRef"),FF(n,"vTextureRef"),FF(n,"Y"),FF(n,"U"),FF(n,"V"),n.useProgram();var o=n.context.ctx;return o.pixelStorei(o.PACK_ALIGNMENT,1),o.pixelStorei(o.UNPACK_ALIGNMENT,1),n.setTexBuffer([0,1,1,1,0,0,1,0]),n.yTextureRef=n._initTexture("ySampler",0),n.uTextureRef=n._initTexture("uSampler",1),n.vTextureRef=n._initTexture("vSampler",2),n._canvas=e._canvas,n}return d(t,e),s(t,[{key:"_initTexture",value:function(e,t){var n=this.context.ctx,r=n.createTexture();return n.bindTexture(n.TEXTURE_2D,r),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MAG_FILTER,n.LINEAR),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MIN_FILTER,n.LINEAR),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_S,n.CLAMP_TO_EDGE),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_T,n.CLAMP_TO_EDGE),n.bindTexture(n.TEXTURE_2D,null),n.uniform1i(n.getUniformLocation(this.program,e),t),r}},{key:"render",value:function(e){var t=this.context.ctx,n=this.width,r=this.height;return this.useProgram(),t.viewport(0,0,n,r),t.activeTexture(t.TEXTURE0),t.bindTexture(t.TEXTURE_2D,this.yTextureRef),t.texSubImage2D(t.TEXTURE_2D,0,0,0,n,r,t.LUMINANCE,t.UNSIGNED_BYTE,this.Y),t.activeTexture(t.TEXTURE1),t.bindTexture(t.TEXTURE_2D,this.uTextureRef),t.texSubImage2D(t.TEXTURE_2D,0,0,0,n/2,r/2,t.LUMINANCE,t.UNSIGNED_BYTE,this.U),t.activeTexture(t.TEXTURE2),t.bindTexture(t.TEXTURE_2D,this.vTextureRef),t.texSubImage2D(t.TEXTURE_2D,0,0,0,n/2,r/2,t.LUMINANCE,t.UNSIGNED_BYTE,this.V),this.draw(),!0}},{key:"resize",value:function(e,n){y(t,"resize",this,3)([e,n]);var r=this.context.ctx;r.activeTexture(r.TEXTURE0),r.bindTexture(r.TEXTURE_2D,this.yTextureRef),r.texImage2D(r.TEXTURE_2D,0,r.LUMINANCE,e,n,0,r.LUMINANCE,r.UNSIGNED_BYTE,null),r.activeTexture(r.TEXTURE1),r.bindTexture(r.TEXTURE_2D,this.uTextureRef),r.texImage2D(r.TEXTURE_2D,0,r.LUMINANCE,e/2,n/2,0,r.LUMINANCE,r.UNSIGNED_BYTE,null),r.activeTexture(r.TEXTURE2),r.bindTexture(r.TEXTURE_2D,this.vTextureRef),r.texImage2D(r.TEXTURE_2D,0,r.LUMINANCE,e/2,n/2,0,r.LUMINANCE,r.UNSIGNED_BYTE,null)}}])}(T$),h2=[function(e){e.codec="avc1.420028"},function(e){delete e.hardwareAcceleration}],f2=function(e,t){switch(e){case"webCodecs":return"videoFrame"===t?514705:514706;case"wasm":return"webgl"===t?514707:"videoFrame"===t?514708:514709}throw new Error("decoder type not supported")};var p2=0,m2=function(){return s((function e(t){var n=this;i(this,e),FF(this,"id",p2++),FF(this,"trackDoneOB"),FF(this,"startOB"),FF(this,"stopOB"),FF(this,"decoder"),FF(this,"videoContext"),FF(this,"gop",0),FF(this,"gop_helper",0),FF(this,"waitFirstKeyFrame",!0),FF(this,"startTimestamp",0),FF(this,"startTime",0),FF(this,"startPerformanceTime",0),FF(this,"inputFrameCount",0),FF(this,"decodedFrameCount",0),FF(this,"decodeFrameCount",0),FF(this,"downgradeLevel",0),FF(this,"lastDowngradeTime",0),FF(this,"lastFrameDiff",0),FF(this,"lastDecodeFrameTimestamp",0),FF(this,"config"),FF(this,"gop_before_configure",[]),FF(this,"videoElement"),FF(this,"type","wasm"),FF(this,"goodType"),FF(this,"renderer","2d"),FF(this,"wasmOption"),FF(this,"createDecoder"),FF(this,"_decodeSink"),FF(this,"isReported",!1),FF(this,"track"),FF(this,"stateChangeOB"),FF(this,"failedReason");var r=t.track,o=t.createDecoder;if(this.stateChangeOB=fX(),this.track=r,this.createDecoder=o,this.wasmOption={yuvMode:"webgl"===t.renderer,wasmPath:t.wasmPath,workerMode:t.workerMode,canvas:t.canvas},this.config=t.config,this.videoElement=t.videoElement,this.renderer=t.renderer,this.trackDoneOB=SX(r.availableState,gz.OFF),this.stopOB=fX(this.trackDoneOB),"auto"===t.type){switch(t.fallback){case"wasm":this.type="wasm",this.renderer="webgl";break;case"wasm_2d":this.type="wasm",this.renderer="2d";break;case"wasm_video":this.type="wasm",this.renderer="videoFrame";break;default:this.type="webCodecs"}this.wasmOption.yuvMode="webgl"===this.renderer}else this.type=t.type;this.changeRenderer(this.renderer),GY(this.stateChangeOB,RQ((function(e,t){return e!==t&&r.onDecodeDowngradeStateChanged({type:n.type,renderer:n.renderer,reason:n.failedReason,prevState:e,state:t}),t}),"INITIALIZED"),YX(this.stopOB),l$()),this.start()}),[{key:"start",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;this.waitFirstKeyFrame=!0,this.stateChangeOB.next("STARTING");var n=GY(this.pipe(this.track),YX(this.stopOB),QY());GY(n,l$((function(){e.track.stat.framesDecoded++}),(function(n){if(e.track.log.error("".concat(e.id," play failed: ").concat(n," retryCount: ").concat(t)),fK.addFailedEvent({key:f2(e.type,e.renderer),error:n}),t>4)e.failedReason=n,e.stateChangeOB.next("FAILED");else{if(e.goodType)return void e.start(t);switch(e.type){case"webCodecs":e.type="wasm",e.changeRenderer("webgl");break;case"wasm":if("webgl"===e.renderer)e.changeRenderer("videoFrame")}e.start(t+1)}}),(function(){e.track.log.warn("".concat(e.id," decoderOB completed")),fK.addSuccessEvent({key:f2(e.type,e.renderer)}),fK.addSuccessEvent({key:514704})}))),GY(n,zX(1),l$((function(){e.track.player.handlePlaying("canvas"),e.goodType=e.type,e.stateChangeOB.next("STARTED")})))}},{key:"mock",value:function(e){this._decodeSink?this._decodeSink.error(e):this.start()}},{key:"close",value:function(e){this.stopOB.next(e)}},{key:"changeRenderer",value:function(e){this.renderer=e,"videoFrame"===this.renderer&&!kK()&&(this.renderer="2d"),this.wasmOption.yuvMode="webgl"===this.renderer}},{key:"decode",value:function(e){var t,n,r=this,i=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(!this.failedReason){this.inputFrameCount++;var o=new Uint8Array(e.data);if(!function(e){return 0===e[0]&&0===e[1]&&0===e[2]&&1===e[3]}(o)||o.length<5)return this.stateChangeOB.next("FAILED"),this.close("not h26x frame ".concat(o.subarray(0,5))),e;var a=!1;switch(31&o[4]){case 5:case 7:a=!0}if("configured"!==(null==(t=this.decoder)?void 0:t.state))return this.track.log.debug("not configured ".concat(this.inputFrameCount)),a&&(this.gop_before_configure=[]),this.gop_before_configure.push({data:e.data,timestamp:e.timestamp,type:e.type}),e;this.gop_before_configure.length>0&&!i&&(this.gop_before_configure.forEach((function(e){return r.decode(e,!0)})),this.gop_before_configure=[]);var s=e.timestamp;if(a?(this.gop=this.gop_helper,this.gop_helper=0):this.gop_helper++,this.decoder){if(this.waitFirstKeyFrame){if(!a)return void this.track.log.debug("wait first key frame ".concat(this.inputFrameCount," ").concat(o.subarray(0,5).join(" ")));this.waitFirstKeyFrame=!1,this.startTimestamp=s,this.startTime=Date.now(),this.startPerformanceTime=yj()}switch(this.downgradeLevel){case 0:case 1:break;case 2:if(this.gop_helper>this.gop>>1)return;break;case 3:if(this.gop_helper>0)return;break;default:return}return(this.decodeFrameCount<10||this.decodeFrameCount%500==0)&&this.track.log.debug("decode ".concat(this.decodeFrameCount," gop: ").concat(this.gop," ").concat(s," ").concat(null==(n=e.getMetadata)?void 0:n.call(e).rtpTimestamp)),this.decodeFrameCount++,this.lastDecodeFrameTimestamp=s,void this.decoder.decode({data:e.data,type:e.type,timestamp:this.lastDecodeFrameTimestamp})}return e}}},{key:"checkDowngradeByFrameDiff",value:function(){var e=this.downgradeLevel,t=this.decodeFrameCount-this.decodedFrameCount;t>this.lastFrameDiff?(this.downgradeLevel++,this.downgradeLevel>4&&(this.downgradeLevel=4)):t<=this.lastFrameDiff&&this.downgradeLevel>0&&this.downgradeLevel--,this.downgradeLevel!==e&&this.track.log.debug("downgrade level ".concat(e," to ").concat(this.downgradeLevel," ").concat(this.decodeFrameCount," frameDiff: ").concat(t,", lastFrameDiff: ").concat(this.lastFrameDiff)),this.lastFrameDiff=t,this.lastDowngradeTime=Date.now()}},{key:"checkDowngradeByTimestampDiff",value:function(e){var t=this.downgradeLevel;this.lastDecodeFrameTimestamp-e>9e4?(this.downgradeLevel++,this.downgradeLevel>4&&(this.downgradeLevel=4)):this.downgradeLevel>0&&this.downgradeLevel--,this.downgradeLevel!==t&&this.track.log.debug("downgrade level ".concat(t," to ").concat(this.downgradeLevel))}},{key:"pipe",value:function(e){var t=this;return function(n){return HF(t,null,p().mark((function t(){var r,i,o,a,s,c,u,l,d,h,f,m,v=this;return p().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:this._decodeSink=n,i=e.mediaTrack,n.defer((function(){var t;e.player.setCanvas(),e.setInputMediaStreamTrack(i),null==r||r.close(),null==(t=v.videoContext)||t.destroy(),delete v._decodeSink})),o=this.renderer,a=this.type,e.log.info("decoder type: ".concat(this.type," renderer: ").concat(this.renderer)),t.prev=5,t.t0=a,t.next="wasm"===t.t0?9:"webCodecs"===t.t0?11:28;break;case 9:return r=this.createDecoder(a,this.wasmOption),t.abrupt("break",29);case 11:s=0;case 12:if(!(s<=h2.length)){t.next=26;break}return t.next=15,VideoDecoder.isConfigSupported(this.config);case 15:if(c=t.sent,!c.supported){t.next=19;break}return t.abrupt("break",26);case 19:if(s!==h2.length){t.next=22;break}return n.error(3),t.abrupt("return");case 22:h2[s](this.config);case 23:s++,t.next=12;break;case 26:return r=this.createDecoder(a),t.abrupt("break",29);case 28:throw new Error("not supported yet");case 29:return u=0,r.on("videoFrame",(function(t){v.decodedFrameCount++,(++u<=10||u%500==0)&&e.log.debug("frame ".concat(u," ").concat(v.decodedFrameCount,"/").concat(v.decodeFrameCount," decoded ").concat(t.timestamp)),Date.now()-v.lastDowngradeTime>5e3&&("webCodecs"===v.type?v.checkDowngradeByFrameDiff():"wasm"===v.type&&v.checkDowngradeByTimestampDiff(t.timestamp)),n.next(t)})),r.on("error",(function(t){e.log.error(t),n.error("webCodecs"===a?4:8)})),t.next=34,r.initialize(this.videoElement);case 34:if(this._decodeSink){t.next=36;break}return t.abrupt("return");case 36:r.configure(this.config),"wasm"===a&&"webgl"===o?(this.videoContext=new P$({frameRate:15,logger:e.log,name:e.userId}),this.videoContext.create(),this.videoContext.on(P$.UNAVAILABLE,(function(t){e.log.error(t),n.error(7)})),l=new d2(this.videoContext),r.on("videoCodecInfo",(function(e){return l.resize(e.width,e.height)})),r.on("videoFrame",(function(e){l.Y=e.y,l.U=e.u,l.V=e.v,1===v.downgradeLevel?v.decodedFrameCount%2==0&&l.render(v.decodedFrameCount):l.render(v.decodedFrameCount)})),e.source=l,e.player.setCanvas(this.videoContext._canvas,2)):"videoFrame"===o?(e.player.setCanvas(),d=new MediaStreamTrackGenerator({kind:"video"}),h=d.writable.getWriter(),e.setInputMediaStreamTrack(d),r.on("videoFrame",(function(e){return h.write(e)}))):(this.videoContext=new M$({frameRate:15,logger:e.log,name:e.userId}),this.videoContext.create({alpha:!1}),f=this.videoContext.createVideoImageSource(),r.on("videoFrame",(function(e){f.image=e,f.update()})),m=new I$(this.videoContext,{name:"remotePlayer",logger:e.log}),f.connect(m),e.source=f,e.player.setCanvas(this.videoContext._canvas,2)),this.decoder=r,t.next=43;break;case 40:t.prev=40,t.t1=t.catch(5),e.log.error(t.t1),n.error("webCodecs"===a?2:6);case 43:case"end":return t.stop()}}),t,this,[[5,40]])})))}}}])}(),v2=function(e){function t(e){var n;return i(this,t),(n=r(this,t)).room=e,FF(n,"videoContext"),FF(n,"_glVideoContext"),FF(n,"_2dVideoContext"),FF(n,"destination"),FF(n,"smallVideoContext"),FF(n,"smallDestination"),FF(n,"smallTrackSource"),FF(n,"smallImageSource"),FF(n,"_isMirror",!1),FF(n,"cameraTrack"),FF(n,"cameraNode"),FF(n,"mirrorNode"),FF(n,"mixNode"),FF(n,"screenTrack"),FF(n,"screenNode"),FF(n,"selfModel",!1),FF(n,"blurRadius",3),FF(n,"arTrack"),FF(n,"Wasm"),FF(n,"waterMarkNode"),FF(n,"_waterMarkOption"),FF(n,"watermarkImageList",[]),FF(n,"_beautyParams"),FF(n,"isUsingArTrack",!1),FF(n,"_isMixScreen",!1),FF(n,"_virtualBackground"),FF(n,"_virtualBackgroundAbortCallback"),FF(n,"virtualBackgroundInstance"),FF(n,"_bgAssetPath"),FF(n,"log",qW.createLogger({id:"vm"})),FF(n,"_checkId",0),FF(n,"_use2d",!1),FF(n,"_autoSwitchRenderMode",!0),FF(n,"_selfieSegmentation"),FF(n,"encodePipeline",[]),FF(n,"decodePipeline",[]),e&&(n.log.setUserId(e.userId),n.log.setSdkAppId(e.sdkAppId)),n.smallVideoContext=new M$({frameRate:15,logger:n.log,name:"s"}),n.enablePrintDetail(),n}return d(t,e),s(t,[{key:"_hasVirtualBg",get:function(){return!!this._virtualBackground}},{key:"_hasWaterMark",get:function(){return this.watermarkImageList.length>0}},{key:"renderMode",get:function(){return this._autoSwitchRenderMode?"auto":this._use2d?"2d":"webgl"},set:function(e){if(this._autoSwitchRenderMode="auto"===e,!this._autoSwitchRenderMode){var t="2d"===e;this._use2d!==t&&(this._use2d=t,this.clear(),this.videoContext=this._use2d?this.get2dVideoContext():this.getGlVideoContext(),this.update())}}},{key:"get2dVideoContext",value:function(){return this._2dVideoContext?this._2dVideoContext.destroy():this._2dVideoContext=new M$({frameRate:15,logger:this.log,name:"m"}),this._2dVideoContext.create({alpha:this._hasWaterMark||this._hasVirtualBg}),this._2dVideoContext}},{key:"getGlVideoContext",value:function(){if(this._glVideoContext){if(this._glVideoContext.available)return this._glVideoContext}else this._glVideoContext=new P$({frameRate:15,logger:this.log,name:"m"});return this.initializeGlVideoContext(),this._glVideoContext}},{key:"initializeGlVideoContext",value:function(){var e=this;try{this._glVideoContext.create(),this._glVideoContext.on(P$.UNAVAILABLE,(function(t){var n;e.emit("error",t),e.log.warn("video context unavailable",t),null==(n=e._virtualBackgroundAbortCallback)||n.call(e,t),e.update().catch((function(t){e.log.error(t)}))}))}catch(dB){this.emit("error",dB)}}},{key:"enablePrintDetail",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:2e3;this._checkId=Iz.run("interval",(function(){e.destination&&e.log.debug(e.destination.getInfo())}),{delay:t})}},{key:"destroy",value:function(){var e,t;null==(e=this._2dVideoContext)||e.destroy(),null==(t=this._glVideoContext)||t.destroy(),this.smallVideoContext.destroy(),Iz.clearTask(this._checkId)}},{key:"needAlpha",get:function(){return this._hasWaterMark||this._hasVirtualBg}},{key:"active",get:function(){return(_W||this._isMixScreen||this._isMirror||this._hasWaterMark||this._hasVirtualBg||this._beautyParams)&&this.checkOrCreateVideoContext()}},{key:"sendCreateResult",value:function(){var e=arguments.length>1?arguments[1]:void 0,t="videoCtxGl"===(arguments.length>0&&void 0!==arguments[0]?arguments[0]:"videoCtxGl")?512700:512701;e?fK.addFailedEvent({key:t,error:e}):fK.addSuccessEvent({key:t})}},{key:"checkOrCreateVideoContext",value:function(){var e=this._use2d;if(this._autoSwitchRenderMode&&(this._use2d=!this._hasVirtualBg),this.videoContext)if(this.videoContext.available){var t=!this.videoContext.hasAlpha&&this.needAlpha;if(this._autoSwitchRenderMode&&e===this._hasVirtualBg)this.clear();else{if(!t)return!0;if(!this._use2d)return!0;this.clear()}}else{if(this._glVideoContext=new P$({frameRate:15,logger:this.log,name:"m"}),this.initializeGlVideoContext(),this._glVideoContext.available)return this.videoContext=this._glVideoContext,this.videoContext.available;this.log.warn("webgl is still not available"),this.clear(),this._use2d=!0}return this.videoContext=this._use2d?this.get2dVideoContext():this.getGlVideoContext(),this.videoContext.available}},{key:"smallTrack",get:function(){var e;return null==(e=this.smallDestination)?void 0:e.videoTrack}},{key:"hasSmall",get:function(){return!!this.smallTrack}},{key:"initialTrack",get:function(){var e;return null==(e=this.cameraTrack)?void 0:e.mediaTrack}},{key:"initVirtualBackground",value:function(e){return this._selfieSegmentation=e,this._selfieSegmentation.changeModel()}},{key:"setSmallVideo",value:function(e,t){var n=this;if(e){if(!this.smallVideoContext.available){if(this.smallVideoContext.create({alpha:!1}),!this.smallVideoContext.available)return;this.smallDestination=new R$(this.smallVideoContext,e,this.log),this.smallVideoContext.on(P$.UNAVAILABLE,(function(e){n.log.warn("small video context lost",e)}))}this.smallVideoContext.frameRate=e.frameRate,this.smallDestination.resolution=e,t?(this.smallTrackSource&&(this.smallTrackSource.close(),delete this.smallTrackSource),this.smallImageSource?this.smallImageSource.image=t:(this.smallImageSource=this.smallVideoContext.createVideoImageSource(t),this.smallImageSource.connect(this.smallDestination))):(this.smallImageSource&&(this.smallImageSource.close(),delete this.smallImageSource),this.smallTrackSource?this.smallTrackSource.replaceTrack(this.initialTrack):(this.smallTrackSource=this.smallVideoContext.createVideoTrackSource(this.initialTrack,"smallTrackSource"),this.smallTrackSource.connect(this.smallDestination)))}else this.smallVideoContext.available&&(this.smallVideoContext.destroy(),delete this.smallDestination,delete this.smallTrackSource,delete this.smallImageSource)}},{key:"_setMainOutput",value:function(e){var t;try{var n=this.cameraTrack,r=n.small,i=n.player;this.setSmallVideo(r,e),_W&&i.setCanvas(e);var o=e&&(null==(t=this.destination)?void 0:t.videoTrack)||this.initialTrack;return this.isUsingArTrack&&this.arTrack&&(this.emit("output-track-changed"),o=this.arTrack),this._selfieSegmentation&&e&&!this._use2d&&(this._selfieSegmentation._glName||this._selfieSegmentation.setCanvas(e)),this.log.info("set main output ".concat(o?o.label:"no output track")),n.setOutputMediaStreamTrack(o)}catch(n){this.log.error("set main output failed",n)}}},{key:"update",value:function(){return HF(this,null,p().mark((function e(){var t,n,r,i,o,a;return p().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.cameraTrack&&this.cameraTrack.mediaTrack){e.next=2;break}return e.abrupt("return");case 2:if(this.active){e.next=4;break}return e.abrupt("return",(this.cameraNode&&this.clear(),this._setMainOutput()));case 4:return r=this.cameraTrack,i=r.settings,o=r.profile,this._use2d||!this._virtualBackground&&!this._beautyParams?(this.destination||(this.destination=this.videoContext.createVideoTrackDestination({name:"mainDestination2d",logger:this.log})),16===TW?this.initialTrack instanceof CanvasCaptureMediaStreamTrack?(this.cameraNode&&(this.cameraNode instanceof D$?(this.cameraNode.close(),delete this.cameraNode):this.cameraNode.image=this.initialTrack.canvas),this.cameraNode||(this.cameraNode=this.videoContext.createVideoImageSource(this.initialTrack.canvas,{name:"cameraCanvasSource",logger:this.log}))):(this.cameraNode&&(this.cameraNode instanceof D$?this.cameraNode.replaceTrack(this.initialTrack):(this.cameraNode.close(),delete this.cameraNode)),this.cameraNode||(this.cameraNode=this.videoContext.createVideoTrackSource(this.initialTrack,"cameraTrackSource"))):this.cameraNode?this.cameraNode.replaceTrack(this.initialTrack):this.cameraNode=this.videoContext.createVideoTrackSource(this.initialTrack,"cameraNodeSource"),this.cameraNode.resize(i.width,i.height)):(this.cameraNode&&this.cameraNode.close(),this.destination?this.destination.disableCheckMute():this.destination=new A$(this.videoContext,{name:"mainDestination",logger:this.log}),this.cameraNode=new l2(this.videoContext,{input:this.cameraTrack.mediaTrack,width:i.width,height:i.height,mirror:this._isMirror,bg:this._virtualBackground,selfModel:this.selfModel,waterMark:this._waterMarkOption,beautyParams:this._beautyParams,useTflite:!0,blurRadius:this.blurRadius,assetPath:this._bgAssetPath,selfieSegmentation:this._selfieSegmentation,Wasm:this.Wasm}),this.cameraNode.connect(this.destination),this.destination.enableCheckMute()),this.videoContext.frameRate=o.frameRate,this._use2d&&((a=this.cameraNode).disconnect(),this._isMirror&&(this.mirrorNode||(this.mirrorNode=new s2(this.videoContext,this.log)),(a=a.connect(this.mirrorNode)).disconnect(),this.log.info("start mirror")),this.mixNode&&this.mixNode.close(),delete this.mixNode,(this._isMixScreen||this._hasWaterMark)&&(this.mixNode=new u2(this.videoContext,this.log),a.connect(this.mixNode,{zIndex:1}),this._hasWaterMark&&!this.waterMarkNode&&this._waterMarkOption&&(this.waterMarkNode=this.videoContext.createVideoImageSource(this._waterMarkOption.image,{autoResize:!1,logger:this.log}),this.waterMarkNode.resize(this._waterMarkOption.width,this._waterMarkOption.height),this.waterMarkNode.x=this._waterMarkOption.x,this.waterMarkNode.y=this._waterMarkOption.y),null==(t=this.waterMarkNode)||t.connect(this.mixNode,{zIndex:2}),this._isMixScreen&&this.screenTrack&&!this.screenNode&&(this.screenNode=this.videoContext.createVideoTrackSource(this.screenTrack.mediaTrack,"screenNodeSource")),null==(n=this.screenNode)||n.connect(this.mixNode,{zIndex:0}),a=this.mixNode,this.log.info("start mix","".concat(this.mixNode.width,"x").concat(this.mixNode.height))),a.connect(this.destination)),e.abrupt("return",(this.log.info("update ".concat(this._use2d?"2d":"webgl")),this._setMainOutput(this.videoContext._canvas)));case 7:case"end":return e.stop()}}),e,this)})))}},{key:"changeInput",value:function(e){var t,n,r,i;if(e instanceof AY)return this.log.info("change screen input",null==(t=e.mediaTrack)?void 0:t.label),this.setScreenTrack(e);if(e instanceof EY)return this.log.info("change video input",null==(n=e.mediaTrack)?void 0:n.label),this.setCameraTrack(e);if(e instanceof L$){this.log.info("change remote input",null==(r=e.mediaTrack)?void 0:r.label);var o=e.mediaTrack;return e.setOutputMediaStreamTrack(o)}this.log.warn("change unknown input",null==(i=e.mediaTrack)?void 0:i.label)}},{key:"removeInput",value:function(e){var t;e instanceof AY?(null==(t=this.screenNode)||t.close(),delete this.screenNode,delete this.screenTrack,this.update()):e instanceof EY?(this.clear(),delete this.cameraTrack,this.smallImageSource&&(this.smallImageSource.close(),delete this.smallImageSource),this.smallTrackSource&&(this.smallTrackSource.close(),delete this.smallTrackSource)):e instanceof L$&&e.source&&e.source.context.destroy()}},{key:"setCameraTrack",value:function(e){return HF(this,null,p().mark((function t(){return p().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:this.cameraTrack=e,this.update();case 1:case"end":return t.stop()}}),t,this)})))}},{key:"setScreenTrack",value:function(e){return this.screenTrack=e,this._isMixScreen&&(this.screenNode?this.screenNode.replaceTrack(e.mediaTrack):this.update()),e.setOutputMediaStreamTrack(e.mediaTrack)}},{key:"getWatermarkImage",value:function(e,t){return HF(this,null,p().mark((function n(){var r,i;return p().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(r=document.createElement("canvas"),t&&e&&(r.height=t,r.width=e),i=r.getContext("2d")){n.next=5;break}throw new tB({code:ZF.NOT_SUPPORTED,message:"Make image failed because of canvas context is null"});case 5:return n.abrupt("return",(this.watermarkImageList.sort((function(e,t){return e.zIndex-t.zIndex})),this.watermarkImageList.forEach((function(e){var t=e.image,n=e.x,r=e.y,o=e.width,a=e.height;i.drawImage(t,n,r,o,a)})),Lj(r.toDataURL())));case 6:case"end":return n.stop()}}),n,this)})))}},{key:"pushWaterMarkImageList",value:function(e){var t=e.type;this.watermarkImageList.some((function(t){return t.imageUrl===e.imageUrl&&t.height===e.height&&t.width===e.width&&t.x===e.x&&t.y===e.y&&t.type===e.type&&t.zIndex===e.zIndex}))||(("mute"===t||"watermark"===t)&&(this.watermarkImageList=this.watermarkImageList.filter((function(e){return e.type!==t}))),this.watermarkImageList.push(e))}},{key:"setBeautyParams",value:function(e){return HF(this,null,p().mark((function t(){return p().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:this._beautyParams=e,this.update();case 1:case"end":return t.stop()}}),t,this)})))}},{key:"stopBeauty",value:function(){return HF(this,null,p().mark((function e(){return p().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._beautyParams=void 0,this.update();case 1:case"end":return e.stop()}}),e,this)})))}},{key:"setWatermark",value:function(e){return HF(this,null,p().mark((function t(){var n,r,i,o,a,s,c,u,l,d,h,f,m,v,_;return p().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,Lj((null==e?void 0:e.imageElement)||e.imageUrl);case 3:i=t.sent,t.next=9;break;case 6:throw t.prev=6,t.t0=t.catch(0),new tB({code:ZF.INVALID_PARAMETER,message:"load image failed, url: ".concat(e.imageUrl)});case 9:if(o=e.x,a=void 0===o?0:o,s=e.y,c=void 0===s?0:s,u=e.width,l=void 0===u?i.width:u,d=e.height,h=void 0===d?i.height:d,f=e.type,m=void 0===f?"watermark":f,v=e.zIndex,_=void 0===v?2:v,!this.watermarkImageList.some((function(e){return e.type===m}))){t.next=20;break}return this.watermarkImageList=this.watermarkImageList.filter((function(e){return e.type!==m})),this.pushWaterMarkImageList({x:a,y:c,width:l,height:h,image:i,zIndex:_,type:m,imageUrl:e.imageUrl}),t.next=15,this.getWatermarkImage(null==(n=this.cameraTrack)?void 0:n.settings.width,null==(r=this.cameraTrack)?void 0:r.settings.height);case 15:i=t.sent,this._waterMarkOption={x:0,y:0,width:i.width,height:i.height,image:i},this.waterMarkNode?(this.waterMarkNode.x=0,this.waterMarkNode.y=0,this.waterMarkNode.resize(i.width,i.height),this.waterMarkNode.image=i):this.update(),t.next=23;break;case 20:return this.pushWaterMarkImageList({x:a,y:c,width:l,height:h,image:i,zIndex:_,type:m,imageUrl:e.imageUrl}),t.next=23,this.freshWatermark();case 23:this.log.info("set watermark",JSON.stringify(this.watermarkImageList,(function(e,t){return"imageUrl"===e?void 0:t})));case 24:case"end":return t.stop()}}),t,this,[[0,6]])})))}},{key:"deleteWatermark",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"watermark";return HF(this,null,p().mark((function t(){return p().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return this.watermarkImageList=this.watermarkImageList.filter((function(t){return t.type!==e})),this.log.info("delete watermark",e,JSON.stringify(this.watermarkImageList,(function(e,t){return"imageUrl"===e?void 0:t}))),t.next=4,this.freshWatermark();case 4:case"end":return t.stop()}}),t,this)})))}},{key:"freshWatermark",value:function(){return HF(this,null,p().mark((function e(){var t,n,r,i;return p().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return null==(t=this.waterMarkNode)||t.close(),delete this.waterMarkNode,delete this._waterMarkOption,e.next=3,this.getWatermarkImage(null==(n=this.cameraTrack)?void 0:n.settings.width,null==(r=this.cameraTrack)?void 0:r.settings.height);case 3:i=e.sent,this._waterMarkOption={x:0,y:0,width:i.width,height:i.height,image:i},this.update();case 5:case"end":return e.stop()}}),e,this)})))}},{key:"setVirtualBackground",value:function(e){return HF(this,null,p().mark((function t(){return p().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(e){t.next=4;break}delete this._virtualBackground,delete this._virtualBackgroundAbortCallback,t.next=14;break;case 4:if(e.onAbort&&(this._virtualBackgroundAbortCallback=e.onAbort),!this._use2d||this._autoSwitchRenderMode){t.next=6;break}return t.abrupt("return",Promise.reject(new Error("not support virtual background in 2d mode")));case 6:if(this._bgAssetPath=e.assetPath,"image"!==e.type){t.next=13;break}return t.next=10,Lj(e.imageUrl);case 10:this._virtualBackground=t.sent,t.next=14;break;case 13:this.blurRadius=e.blurLevel||this.blurRadius||3,this._virtualBackground=e.type;case 14:return this.log.info("".concat(this._virtualBackground?"start":"stop"," virtual background, ").concat((null==e?void 0:e.type)||"",", ").concat(this.blurRadius||"")),t.next=17,this.update();case 17:if(!this._virtualBackground||this._glVideoContext.available){t.next=19;break}throw new tB({code:ZF.INVALID_OPERATION,message:"webgl context create failed, ".concat(this._glVideoContext.error)});case 19:case"end":return t.stop()}}),t,this)})))}},{key:"mixScreen",get:function(){return this._isMixScreen},set:function(e){var t;this._isMixScreen=e,this._isMixScreen||(null==(t=this.screenNode)||t.close(),delete this.screenNode),this.update()}},{key:"mirror",get:function(){return this._isMirror},set:function(e){var t;this._isMirror!==e&&(this._isMirror=e,this._isMirror||(null==(t=this.mirrorNode)||t.close(),delete this.mirrorNode),this.update())}},{key:"enableAr",value:function(e){this.arTrack=e,this.isUsingArTrack=!0,this.update()}},{key:"updateAr",value:function(){return HF(this,null,p().mark((function e(){var t;return p().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(e.t0=null!=(t=this.cameraTrack)&&t.mediaTrack,!e.t0){e.next=4;break}return e.next=4,this.virtualBackgroundInstance.ar.updateInputTrack(this.cameraTrack.mediaTrack.clone());case 4:case"end":return e.stop()}}),e,this)})))}},{key:"disableAr",value:function(){var e;this.isUsingArTrack=!1,null==(e=this.arTrack)||e.stop(),this.arTrack=void 0,this.update()}},{key:"createDecodeContext",value:function(e){return new m2(e)}},{key:"clear",value:function(){var e;null==(e=this.videoContext)||e.disconnect(),delete this.destination,delete this.cameraNode,delete this.mirrorNode,delete this.screenNode,delete this.waterMarkNode}},{key:"addEncodeProcessor",value:function(e){var t,n=e.processor,r=e.type;this.encodePipeline.includes(n)||(this.encodePipeline[r]=n,null==(t=this.room)||t.enableInsertableStreams())}},{key:"addDecodeProcessor",value:function(e){var t,n=e.processor,r=e.type;this.decodePipeline.includes(n)||(this.decodePipeline[r]=n,null==(t=this.room)||t.enableInsertableStreams())}},{key:"removeEncodeProcessor",value:function(e){var t=e.type;this.encodePipeline[t]=void 0}},{key:"removeDecodeProcessor",value:function(e){var t=e.type;this.decodePipeline[t]=void 0}}])}(o2.EventEmitter);UF([nY((function(e){this.log.error("update failed",e)}))],v2.prototype,"update",1);var _2=0,g2=function(e){function t(e){var n;return i(this,t),n=r(this,t,["room"]),FF(n,"seq",++_2),FF(n,"sdkAppId"),FF(n,"userId"),FF(n,"userSig"),FF(n,"privateMapKey"),FF(n,"latencyLevel"),FF(n,"tinyId"),FF(n,"scene"),FF(n,"roomId"),FF(n,"useStringRoomId"),FF(n,"role","anchor"),FF(n,"joinParams",null),FF(n,"localTracks",new Set),FF(n,"enableAutoPlayDialog",!0),FF(n,"autoReceiveAudio",!0),FF(n,"autoReceiveVideo",!0),FF(n,"proxy_ws"),FF(n,"proxy_wt"),FF(n,"proxy_unified"),FF(n,"checkSystemResult",{result:!0,detail:{isBrowserSupported:!0,isWebRTCSupported:!0,isWebCodecsSupported:!0,isMediaDevicesSupported:!0,isScreenShareSupported:!0,isSmallStreamSupported:!0,isH264EncodeSupported:!0,isVp8EncodeSupported:!0,isH264DecodeSupported:!0,isVp8DecodeSupported:!0}}),FF(n,"keyPointManager"),FF(n,"audioManager"),FF(n,"videoManager"),FF(n,"callDurationCalculator"),FF(n,"badCaseDetector"),FF(n,"scheduleResult",{domains:null,iceServers:null,iceTransportPolicy:null,trtcAutoConf:null}),FF(n,"videoDecodeFallbackType"),FF(n,"_isUsingCachedSchedule",!1),FF(n,"_log",qW.createLogger({id:"r".concat(n.seq)})),FF(n,"_joinedTimestamp",0),FF(n,"_sdkType"),FF(n,"heartbeatReport"),FF(n,"quality"),FF(n,"enableSEI"),FF(n,"isDestroyed",!1),n.useStringRoomId=!!e.useStringRoomId,uj(e.autoReceiveAudio)&&(n.autoReceiveAudio=e.autoReceiveAudio),uj(e.autoReceiveVideo)&&(n.autoReceiveVideo=e.autoReceiveVideo),uj(e.enableAutoPlayDialog)&&(n.enableAutoPlayDialog=e.enableAutoPlayDialog),n._sdkType=e.sdkType,n.keyPointManager=new Z1({room:n,frameWorkType:e.frameWorkType,component:e.component,language:e.language}),n.callDurationCalculator=new n2({room:n}),n.badCaseDetector=new i2({room:n}),n.audioManager=new DY(n),n.videoManager=new v2(n),n}return d(t,e),s(t,[{key:"scriptTransformWorker",get:function(){}},{key:"isMainStreamPublished",get:function(){var e,t=c(this.localTracks);try{for(t.s();!(e=t.n()).done;){if(4&e.value.mediaType)return!0}}catch(n){t.e(n)}finally{t.f()}return!1}},{key:"isAuxStreamPublished",get:function(){var e,t=c(this.localTracks);try{for(t.s();!(e=t.n()).done;){if(2&e.value.mediaType)return!0}}catch(n){t.e(n)}finally{t.f()}return!1}},{key:"hasAuxStream",get:function(){var e,t=c(this.remotePublishedUserMap.values());try{for(t.s();!(e=t.n()).done;){if(e.value.muteState.hasAuxiliary)return!0}}catch(n){t.e(n)}finally{t.f()}return this.isAuxStreamPublished}},{key:"localMainVideoTrack",get:function(){var e,t=c(this.localTracks);try{for(t.s();!(e=t.n()).done;){var n=e.value;if(4&n.mediaType)return n}}catch(r){t.e(r)}finally{t.f()}return null}},{key:"localAuxVideoTrack",get:function(){var e,t=c(this.localTracks);try{for(t.s();!(e=t.n()).done;){var n=e.value;if(2&n.mediaType)return n}}catch(r){t.e(r)}finally{t.f()}return null}},{key:"getLogger",value:function(){return this._log}},{key:"isJoining",get:function(){return"joining"===this.state.toString()}},{key:"isJoined",get:function(){return"joined"===this.state}},{key:"isLeft",get:function(){return"left"===this.state}},{key:"addTrack",value:function(e){return HF(this,null,p().mark((function t(){return p().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.publish(e));case 1:case"end":return t.stop()}}),t,this)})))}},{key:"removeTrack",value:function(e){return HF(this,null,p().mark((function t(){return p().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.unpublish(e));case 1:case"end":return t.stop()}}),t,this)})))}},{key:"replaceTrack",value:function(e){return HF(this,null,p().mark((function e(){return p().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:case"end":return e.stop()}}),e)})))}},{key:"setEncodedDataProcessingListener",value:function(e){throw new Error("Method not implemented.")}},{key:"enableAIVoice",value:function(e){throw new Error("Method not implemented.")}},{key:"setProxyServer",value:function(e){var t=this;if(sj(e))e.startsWith("wss://")?this.proxy_ws=e:e.startsWith("https://")&&(this.proxy_wt=e);else if(tj(e)){var n=e.websocketProxy,r=e.webtransportProxy,i=e.loggerProxy,o=e.scheduleProxy,a=e.unifiedProxy;this.proxy_ws=n,this.proxy_wt=r,this.proxy_unified=a,a?(DZ([a,a]),_B("https://".concat(a))):(i&&_B(i),o&&DZ(o))}HW.once(GW.JOIN_RECEIVED_CMD_RES,(function(){return t.sendAbilityStatus({sched_domain:wZ.main,sched_back_domain:wZ.backup,signal_domain:t.proxy_ws||t.proxy_wt||""})}))}},{key:"getRemoteAudioStats",value:function(){return HF(this,null,p().mark((function e(){var t;return p().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t={},e.abrupt("return",(this.remotePublishedUserMap.forEach((function(e){t[e.userId]=e.remoteAudioTrack.stat})),t));case 2:case"end":return e.stop()}}),e,this)})))}},{key:"getTransportStats",value:function(){return HF(this,null,p().mark((function e(){var t,n,r,i,o;return p().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n={rtt:(null==(t=this.quality)?void 0:t.uplinkRTT)||0,downlinksRTT:{}},this.quality){r=c(this.quality.downlinkInfo);try{for(r.s();!(i=r.n()).done;)o=i.value,n.downlinksRTT[o.userId]=o.rtt}catch(a){r.e(a)}finally{r.f()}}return e.abrupt("return",n);case 3:case"end":return e.stop()}}),e,this)})))}},{key:"getRemoteVideoStats",value:function(){return HF(this,arguments,(function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"main";return p().mark((function n(){var r;return p().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r={},n.abrupt("return",(e.remotePublishedUserMap.forEach((function(e){var n="auxiliary"===t?e.remoteAuxiliaryTrack:e.remoteVideoTrack;r[e.userId]=n.stat})),r));case 2:case"end":return n.stop()}}),n)}))()}))}},{key:"checkDestroy",value:function(){if(this.isDestroyed)throw new tB({code:ZF.INVALID_OPERATION,message:rK({key:ZJ.CLIENT_DESTROYED,data:{funName:"join"}})})}},{key:"destroy",value:function(){if(this.isJoined)throw this._log.warn(eK.INVALID_DESTROY),new tB({code:ZF.INVALID_OPERATION,message:rK({key:ZJ.INVALID_DESTROY})});this._log.info("destroy room"),this.audioManager.destroy(),this.videoManager.destroy(),this.keyPointManager.destroy(),this.callDurationCalculator.destroy(),this.badCaseDetector.destroy(),this.isDestroyed=!0,HW.emit(GW.ROOM_DESTROY,{room:this})}},{key:"schedule",value:function(e,t){return HF(this,null,p().mark((function n(){var r,i,o,a,s,c,u,l,d=this;return p().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return a=yj(),n.prev=1,n.next=4,CZ({userId:this.userId,sdkAppId:this.sdkAppId,roomId:this.useStringRoomId?e.strRoomId:e.roomId,useStringRoomId:this.useStringRoomId,version:uB,userSig:this.userSig,role:"live"===this.scene?e.role:void 0,frameWorkType:t,latencyLevel:e.latencyLevel});case 4:s=n.sent,c=s.isCached,u=s.result,l=s.detailCost,this._isUsingCachedSchedule=c,this._log.info("schedule cache:".concat(+c," ").concat(xj(u,{keysToExclude:["username","credential"]}))),c&&HW.once(GW.JOIN_RECEIVED_CMD_RES,(function(){return d.sendAbilityStatus({scheduleCache:1})})),this.scheduleResult=xF(xF({},this.scheduleResult),u),cj(null==(r=u.config)?void 0:r.retryCount)&&lH(u.config.retryCount),sj(null==(i=u.config)?void 0:i.loggerDomain)&&_B(u.config.loggerDomain),this.videoDecodeFallbackType=(null==(o=u.config)?void 0:o.videoDecodeFallback)||this.videoDecodeFallbackType,HW.emit(GW.JOIN_SCHEDULE_SUCCESS,{room:this,schedule:this.scheduleResult,detailCost:l}),fK.addSuccessEvent({key:521700,cost:yj()-a,split:50}),n.next=14;break;case 11:throw n.prev=11,n.t0=n.catch(1),fK.addFailedEvent({key:521700,error:n.t0}),n.t0;case 14:case"end":return n.stop()}}),n,this,[[1,11]])})))}},{key:"sendAbilityStatus",value:function(e){}},{key:"enableInsertableStreams",value:function(){return Promise.resolve()}}])}(gz),y2=VF(jF()),E2=VF(XF());function T2(e){for(var t,n=[],r=function(r){if(["rtx","red","ulpfec"].includes(e.rtp[r].codec))return 1;var i=e.fmtp.filter((function(t){return t.payload===e.rtp[r].payload}))[0];n.push({payload:e.rtp[r].payload,codec:e.rtp[r].codec,fmtp:i?i.config:"",rate:e.rtp[r].rate,rtx:"rtx"===(null==(t=e.rtp[r+1])?void 0:t.codec)?e.rtp[r+1].payload:0,rtcpfb:((null==e?void 0:e.rtcpFb)||[]).filter((function(t){return t.payload===e.rtp[r].payload})).map((function(e){var t=e.type,n=e.subtype;return{id:t,params:n?[n]:[]}}))})},i=0;i<e.rtp.length;i++)r(i);return n}function k2(){return HF(this,null,p().mark((function e(){var t,n,r,i;return p().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return(t=new RTCPeerConnection).addTransceiver(UB.VIDEO,{direction:UB.TRANSCEIVER_DIRECTION_RECVONLY}),e.next=4,t.createOffer();case 4:if((n=e.sent).sdp){e.next=7;break}return e.abrupt("return",[]);case 7:return r=P1(n.sdp),i=T2(r.media[0]),e.abrupt("return",(t.close(),i));case 9:case"end":return e.stop()}}),e)})))}var S2=function(e,t){return HF(void 0,null,p().mark((function n(){var r,i,o,a,s,c,u;return p().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return i=P1(e),(o={ice:{ufrag:"",password:""},dtls:{hash:"",fingerprint:"",setup:""},audio:{codecs:[],extensions:[]},video:{codecs:[],decoders:[],extensions:[]},useDataChannel:!1}).ice.ufrag=String(i.media[0].iceUfrag),o.ice.password=i.media[0].icePwd||"",i.fingerprint&&(o.dtls.hash=i.fingerprint.type,o.dtls.fingerprint=i.fingerprint.hash,o.dtls.setup=i.setup||""),i.media[0].fingerprint&&(o.dtls.hash=i.media[0].fingerprint.type,o.dtls.fingerprint=i.media[0].fingerprint.hash),o.dtls.setup=i.media[0].setup||"",a=i.media[0],s=i.media[1],a.ext&&(o.audio.extensions=a.ext.map((function(e){return{id:e.value,uri:e.uri}}))),s.ext&&(o.video.extensions=s.ext.map((function(e){return{id:e.value,uri:e.uri}}))),c={codec:a.rtp[0].codec,fmtp:a.fmtp[0].config,payload:a.fmtp[0].payload,rate:a.rtp[0].rate,channels:a.rtp[0].encoding,rtcpfb:[],rtx:0},null==(r=a.rtcpFb)||r.forEach((function(e){var t=e.payload,n=e.type,r=e.subtype;if(t===c.payload){var i={id:n,params:[]};r&&i.params.push(r),c.rtcpfb.push(i)}})),o.audio.codecs.push(c),u=["h264","vp8"],t&&u.shift(),o.video.codecs=T(T2(s)).filter((function(e){return u.includes(e.codec.toLocaleLowerCase())})),n.next=11,k2();case 11:return o.video.decoders=n.sent.filter((function(e){return["h264","vp8"].includes(e.codec.toLocaleLowerCase())})),n.abrupt("return",o);case 13:case"end":return n.stop()}}),n)})))},I2=function(e){var t=e.serverAbility,n=e.clientAbility,r=e.offerSDP,i=e.enableCustomMessage,o=P1(r),a={extmapAllowMixed:"extmap-allow-mixed",groups:o.groups,icelite:"ice-lite",media:[],msidSemantic:{semantic:"",token:"WMS"},name:"-",origin:{address:"127.0.0.1",username:"-",sessionId:String(Date.now()),sessionVersion:1,netType:"IN",ipVer:4},timing:{start:0,stop:0},version:0},s={candidates:t.candidates.map((function(e){return{component:1,foundation:"1",generation:0,ip:e.ip,port:e.port,priority:e.priority,transport:e.foundation,type:e.type}})),connection:{version:4,ip:"0.0.0.0"},direction:UB.TRANSCEIVER_DIRECTION_RECVONLY,ext:t.audio.extensions.map((function(e){return{value:e.id,uri:e.uri}})),fingerprint:{type:t.dtls.hash,hash:t.dtls.fingerprint},fmtp:[{payload:t.audio.codecs[0].payload,config:t.audio.codecs[0].fmtp}],icePwd:t.ice.password,iceUfrag:t.ice.ufrag,mid:"0",payloads:String(t.audio.codecs[0].payload),port:o.media[0].port,protocol:o.media[0].protocol,type:UB.AUDIO,setup:t.dtls.setup,rtcpFb:t.audio.codecs[0].rtcpfb.map((function(e){return{payload:t.audio.codecs[0].payload,type:e.id,subtype:e.params[0]}})),rtcpMux:"rtcp-mux",rtcpRsize:"rtcp-rsize",rtp:[{payload:t.audio.codecs[0].payload,codec:t.audio.codecs[0].codec,rate:t.audio.codecs[0].rate,encoding:t.audio.codecs[0].channels}]};return a.media.push(s),[1,2,3].forEach((function(e){a.media.push(b2({mid:e,serverAbility:t,clientAbility:n,parsedOffer:o}))})),i&&a.media.push(o.media.find((function(e){return"dc"===e.mid}))),M1(a)},b2=function(e){var t=e.mid,n=e.serverAbility,r=e.clientAbility,i=e.parsedOffer,o=e.isDownlink,a=void 0!==o&&o,s={candidates:n.candidates.map((function(e){return{component:1,foundation:"1",generation:0,ip:e.ip,port:e.port,priority:e.priority,transport:e.foundation,type:e.type}})),connection:{version:4,ip:"0.0.0.0"},direction:UB.TRANSCEIVER_DIRECTION_RECVONLY,ext:n.video.extensions.map((function(e){return{value:e.id,uri:e.uri}})),fingerprint:{type:n.dtls.hash,hash:n.dtls.fingerprint},fmtp:[],icePwd:n.ice.password,iceUfrag:n.ice.ufrag,mid:String(t),payloads:"",port:i.media[0].port,protocol:i.media[0].protocol,type:UB.VIDEO,setup:n.dtls.setup,rtcpFb:[],rtcpMux:"rtcp-mux",rtcpRsize:"rtcp-rsize",rtp:[]};if(a){var c=n.video.decoders;(!c||0===c.length)&&(c=n.video.codecs),(!c||0===c.length)&&(c=r.video.decoders),c.forEach((function(e){A2(s,e)}))}else{var u=n.video.codecs.findIndex((function(e){return e.codec.toLowerCase()===(n.useVp8?"vp8":"h264")})),l=n.video.codecs[u]||r.video.codecs[0];A2(s,l)}return s},A2=function(e,t){e.payloads="".concat(e.payloads," ").concat(t.payload).trim(),e.fmtp.push({payload:t.payload,config:t.fmtp}),e.rtcpFb=[].concat(T(e.rtcpFb||[]),T(t.rtcpfb.map((function(e){return{payload:t.payload,type:e.id,subtype:e.params[0]}})))),e.rtp.push({payload:t.payload,codec:t.codec.toUpperCase(),rate:t.rate}),t.rtx&&(e.payloads="".concat(e.payloads," ").concat(t.rtx),e.fmtp.push({payload:t.rtx,config:"apt=".concat(t.payload)}),e.rtp.push({payload:t.rtx,codec:"rtx",rate:t.rate}))};var R2=function(e,t,n){var r=E2.default.parse(e);return r.media.forEach((function(e,i){var o;if((e.type===UB.AUDIO||e.type===UB.VIDEO)&&(function(e){if(e.rtcpFb){var t=[];e.rtcpFb.forEach((function(n,r){var i;t.push(n),e.rtcpFb&&(null==(i=e.rtcpFb[r+1])?void 0:i.payload)!==n.payload&&"rrtr"!==n.type&&t.push({payload:n.payload,type:"rrtr"})})),e.rtcpFb=t}}(e),function(e){e.type===UB.VIDEO&&e.fmtp&&e.fmtp.forEach((function(e){e.config.includes("apt")||(e.config+=";sps-pps-idr-in-keyframe=1")}))}(e),function(e){e.type===UB.AUDIO&&e.fmtp&&e.fmtp.forEach((function(e){e.config+=";sprop-stereo=1;stereo=1"}))}(e),function(e){var t=new Set(["urn:ietf:params:rtp-hdrext:sdes:mid","urn:ietf:params:rtp-hdrext:sdes:rtp-stream-id","urn:ietf:params:rtp-hdrext:sdes:repaired-rtp-stream-id"]);e.ext&&(e.ext=e.ext.filter((function(e){return!t.has(e.uri)})))}(e),e.type===UB.VIDEO))if(i<4)e.payloads="",e.fmtp=[],e.rtp=[],e.rtcpFb=[],t.video.codecs.forEach((function(t){return A2(e,t)}));else if(n){e.payloads="",e.fmtp=[],e.rtp=[],e.rtcpFb=[];var a=n.video.decoders;(!a||0===a.length)&&(a=n.video.codecs),(!a||0===a.length)&&(a=t.video.decoders),a.forEach((function(t){return A2(e,t)}))}null!=(o=e.payloads)&&o.includes("datachannel")&&r.groups&&e.mid&&(r.groups[0].mids=r.groups[0].mids.replace(e.mid,"dc"),e.mid="dc")})),E2.default.write(r)},C2=function(e){function t(e){var n;return i(this,t),(n=r(this,t)).room=e,FF(n,"mainFpsHealth",1),FF(n,"mainBitrateHealth",1),FF(n,"badMainBitrateHealthCount",0),FF(n,"lastEmitBadHealthTime",0),FF(n,"log"),!uG&&dW&&HW.on("262",n.onVideoCodecChanged,n),n.log=e.getLogger().createChild({id:"h-d"}),n}return d(t,e),s(t,[{key:"onVideoCodecChanged",value:function(e){var t=e.remoteUserId,n=e.streamType,r=e.isHWCodec,i=e.codec;if(!t&&7!==n&&"h264"===i){if(!r)return void this.room.off("heartbeat-report",this.onHeartbeatReport,this);this.room.listeners("heartbeat-report").includes(this.onHeartbeatReport)||this.room.on("heartbeat-report",this.onHeartbeatReport,this)}}},{key:"onHeartbeatReport",value:function(e){var t=this;Date.now()-this.lastEmitBadHealthTime<3e4||(e.msg_up_stream_info.msg_video_status.forEach((function(e){if(e.uint32_video_enc_fps&&e.uint32_video_capture_fps){var n=e.uint32_video_enc_fps/e.uint32_video_capture_fps;2===e.uint32_video_stream_type&&(t.mainFpsHealth=n)}if(e.uint32_video_codec_bitrate&&2===e.uint32_video_stream_type){var r=t.room.localMainVideoTrack;r&&(t.mainBitrateHealth=e.uint32_video_codec_bitrate/1e3/r.profile.bitrate)}})),this.log.debug("mainBitrateHealth: ".concat(this.mainBitrateHealth," mainFpsHealth: ").concat(this.mainFpsHealth)),this.mainBitrateHealth>.5&&(this.badMainBitrateHealthCount=0),this.mainFpsHealth>.9&&this.mainBitrateHealth<.5&&(this.badMainBitrateHealthCount++,this.badMainBitrateHealthCount>3&&(this.badMainBitrateHealthCount=0,this.lastEmitBadHealthTime=Date.now(),this.log.warn("bad main bitrate health: ".concat(this.mainBitrateHealth)),this.emit("1",{isAux:!1}))))}},{key:"destroy",value:function(){HW.off("262",this.onVideoCodecChanged,this),this.room.off("heartbeat-report",this.onHeartbeatReport,this)}}])}(VF(jF()).EventEmitter);FF(C2,"EVENT_BAD_HEALTH","bad_health");var w2=C2;function D2(e){var t=e.seiMessageList,n=e.isAudio,r=e.isMain;return new TransformStream({transform:function(e,i){var o=e;n?audioEncodePipeline.forEach((function(e){o=e({frame:o})})):videoEncodePipeline.forEach((function(e){o=e({frame:o,seiMessageList:t,onDump:function(){self.postMessage({type:"dump",isAudio:n,data:o.data,userId:"",streamType:r?"main":"auxiliary"})}})})),i.enqueue(o)}})}function N2(e,t,n){return new TransformStream({transform:function(r,i){var o=r;videoDecodePipeline.forEach((function(r){o=r({frame:o,onSEI:function(n){n.forEach((function(n){self.postMessage({type:"sei",seiPayloadType:n.seiPayloadType,data:n.seiPayload.buffer,userId:e,streamType:t})}))},onDump:function(){self.postMessage({type:"dump",isAudio:n,data:o.data,userId:e,streamType:t})}})})),i.enqueue(o)}})}var x2=function(e){return e.TRACK="track",e.DATA_CHANNEL_MESSAGE="data_channel_msg",e[e.CONNECTION_STATE_CHANGED="connection-state-changed"]="CONNECTION_STATE_CHANGED",e[e.FIREWALL_RESTRICTION="firewall-restriction"]="FIREWALL_RESTRICTION",e.RECONNECTED="spc-reconnected",e.RECONNECT_FAILED="spc-reconnect-failed",e.ERROR="error",e.SEI_MESSAGE="sei-message",e.DUMP="dump",e}(x2||{}),O2=0,P2=!1,M2=new Set,L2=1,V2=function(e){function t(e){var n,o=e.signalChannel,a=e.room,s=e.enableCustomMessage;return i(this,t),n=r(this,t),FF(n,"stat",{iceStartTime:0,iceEndTime:0,dtlsStartTime:0,dtlsEndTime:0,peerConnectionStartTime:0,peerConnectionEndTime:0}),FF(n,"currentState","DISCONNECTED"),FF(n,"_room"),FF(n,"_signalChannel"),FF(n,"_peerConnection",null),FF(n,"_datachannel",null),FF(n,"_enableCustomMessage"),FF(n,"_log"),FF(n,"_downlinkMIDMap",new Map),FF(n,"_downlinkMIDUserIDMap",new Map),FF(n,"_reconnectionTimer",-1),FF(n,"reconnectionCount",0),FF(n,"clientAbility"),FF(n,"_serverAbility",null),FF(n,"addDownlinkQueue",new Set),FF(n,"removeDownlinkQueue",new Set),FF(n,"_parsedAnswer",null),FF(n,"_updateSDPPromise",null),FF(n,"_waitForPCConnectedPromise"),FF(n,"clearConnectTimeout"),FF(n,"_isSDPLogged",!1),FF(n,"enableInsertableStreams",!1),FF(n,"insertableStreamsAbortMap",new Map),FF(n,"receiverRemoteTrackMap",new WeakMap),FF(n,"scriptTransformWorker"),FF(n,"_isRelayTried",!1),FF(n,"_rttOverCount",0),FF(n,"originOffer",null),n._room=a,n._enableCustomMessage=s,n._signalChannel=o,n._log=qW.createLogger({id:"spc".concat(L2++),userId:n._room.userId,sdkAppId:n._room.sdkAppId}),n._room.enableCodecPipeline&&(XK?n.enableInsertableStreams=!0:n.initScriptTransformWorker()),n._room.healthDetector.on("1",n.onBadHealth,n),n}return d(t,e),s(t,[{key:"isH264EncodeSupported",get:function(){var e=this._room.checkSystemResult.detail.isH264EncodeSupported;return this._serverAbility&&(e=e&&!!this._serverAbility.video.codecs.find((function(e){return"h264"===e.codec.toLowerCase()}))),e}},{key:"addAbortController",value:function(e,t){var n;null==(n=this.insertableStreamsAbortMap.get(e))||n.abort("destory"),this.insertableStreamsAbortMap.set(e,t)}},{key:"isVP8EncodeSupported",get:function(){var e=this._room.checkSystemResult.detail.isVp8EncodeSupported;return this._serverAbility&&(e=e&&this._serverAbility.video.codecs.find((function(e){return"vp8"===e.codec.toLowerCase()}))),e}},{key:"videoCodec",get:function(){var e,t,n=null==(e=this._parsedAnswer)?void 0:e.media[1].rtp.find((function(e){return["h264","vp8"].includes(e.codec.toLowerCase())}));return n?n.codec.toLowerCase():null!=(t=this._serverAbility)&&t.useVp8?"vp8":"h264"}},{key:"downlinkVideoCodec",get:function(){var e;return null!=(e=this._serverAbility)&&e.video.decoders.find((function(e){return"h264"===e.codec.toLowerCase()}))?"h264":"vp8"}},{key:"isUsingH264",get:function(){return"h264"===this.videoCodec}},{key:"is42001fSupported",get:function(){return!!this.clientAbility&&!!this.clientAbility.video.codecs.find((function(e){return e.fmtp.includes("42001f")}))}},{key:"uplinkSSRC",get:function(){return this._peerConnection&&this._peerConnection.localDescription?function(e){var t=P1(e),n={audioSsrc:0,audioRtxSsrc:0,bigVideoSsrc:0,bigVideoRtxSsrc:0,smallVideoSsrc:0,smallVideoRtxSsrc:0,auxVideoSsrc:0,auxVideoRtxSsrc:0};return t.media.forEach((function(e,t){var r;if(e.ssrcs&&!aj(e.ssrcs[0].id)){var i=Number(e.ssrcs[0].id),o=Number(null==(r=e.ssrcs.filter((function(e){return"cname"===e.attribute}))[1])?void 0:r.id);switch(t){case 0:n.audioSsrc=i;break;case 1:n.bigVideoSsrc=i,n.bigVideoRtxSsrc=o;break;case 2:n.smallVideoSsrc=i,n.smallVideoRtxSsrc=o;break;case 3:n.auxVideoSsrc=i,n.auxVideoRtxSsrc=o}}})),n}(this._peerConnection.localDescription.sdp):{audioSsrc:0,audioRtxSsrc:0,bigVideoSsrc:0,bigVideoRtxSsrc:0,smallVideoSsrc:0,smallVideoRtxSsrc:0,auxVideoSsrc:0,auxVideoRtxSsrc:0}}},{key:"onBadHealth",value:function(e){var t=e.isAux;this.useHWEncoder(!1,t?7:2)}},{key:"initScriptTransformWorker",value:function(){var e=this;QK&&(this.scriptTransformWorker=function(e){var t=[_Y],n=[h0,l0,d0,u0,D2,N2],r="const videoEncodePipeline=[".concat(e.videoEncodePipeline.toString(),"];\n const videoDecodePipeline=[").concat(e.videoDecodePipeline.toString(),"];\n const audioEncodePipeline = [").concat(e.audioEncodePipeline.toString(),"];\n const audioDecodePipeline = [").concat(e.audioDecodePipeline.toString(),"];"),i="(()=>{".concat(t.map((function(e){return"const ".concat(e.name,"=(()=>").concat(e.toString(),")()")})).join("\n"),"\n").concat(n.map((function(e){return e.toString()})).join("\n"),";(").concat((function(){var e=[],t=[],n=[];self.onmessage=function(r){"sei"===r.data.type&&(r.data.isMain?(e.push(r.data.data),r.data.small&&n.push(r.data.data)):t.push(r.data.data))},self.onrtctransform=function(r){var i=r.transformer.options,o=i.isReceiver?N2(i.userId,i.streamType,i.isAudio):D2({isAudio:i.isAudio,seiMessageList:i.isMain?i.small?n:e:t,isMain:i.isMain});r.transformer.readable.pipeThrough(o).pipeTo(r.transformer.writable)}}),")();").concat(r,"})()"),o=new Blob([i],{type:"text/javascript"}),a=URL.createObjectURL(o),s=new Worker(a);return URL.revokeObjectURL(a),s}({videoEncodePipeline:this._room.videoManager.encodePipeline,videoDecodePipeline:this._room.videoManager.decodePipeline,audioEncodePipeline:this._room.audioManager.encodePipeline,audioDecodePipeline:this._room.audioManager.decodePipeline}),this.scriptTransformWorker.onmessage=function(t){"sei"===t.data.type&&e.emit("sei-message",t.data),"dump"===t.data.type&&e.emit("dump",t.data)},this.scriptTransformWorker.onerror=function(t){e._log.error("scriptTransformWorker error: ",t)})}},{key:"isReconnecting",get:function(){return"RECONNECTING"===this.currentState||this._reconnectionTimer>0||this.reconnectionCount>0}},{key:"dtlsTransport",get:function(){if(!this._peerConnection)return null;var e=this._peerConnection.getSenders();return 0===e.length?null:e[0].transport}},{key:"getPeerConnectionConfig",value:function(e){var t={encodedInsertableStreams:this.enableInsertableStreams,offerExtmapAllowMixed:!0,iceServers:e,iceTransportPolicy:this._room.getIceTransportPolicy(),sdpSemantics:this._room.sdpSemantics,bundlePolicy:"max-bundle",rtcpMuxPolicy:"require",tcpCandidatePolicy:"disable",IceTransportsType:"nohost"};return this._log.debug("getPeerConnectionConfig",JSON.stringify(t)),t}},{key:"initialize",value:function(e){return HF(this,null,p().mark((function t(){var n,r,i=this;return p().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,this._peerConnection=new RTCPeerConnection(this.getPeerConnectionConfig(e)),this._peerConnection.oniceconnectionstatechange=function(){if(i._peerConnection){var e=i._peerConnection.iceConnectionState;i._log.debug("ice state: ".concat(e)),"checking"===e&&0===i.stat.iceStartTime?i.stat.iceStartTime=Date.now():"connected"===e&&0===i.stat.iceEndTime?(i.stat.iceEndTime=Date.now(),i._signalChannel.clearBakRelayIps(),fK.addSuccessEvent({key:521711,cost:i.stat.iceEndTime-i.stat.iceStartTime})):"failed"===e&&fK.addFailedEvent({key:521711})}},this._peerConnection.onsignalingstatechange=function(){var e,t=(null==(e=i._peerConnection)?void 0:e.signalingState)||"";i._log["closed"===t?"debug":"info"]("signaling state: ".concat(t))},this._peerConnection.onconnectionstatechange=this.onConnectionStateChange.bind(this),this._peerConnection.ontrack=function(e){return i.emit("track",e)},this._enableCustomMessage&&(this._datachannel=this._peerConnection.createDataChannel("".concat(this._room.userId,"dc")),this._datachannel.binaryType="arraybuffer",this._datachannel.onopen=function(){i._log.info("datachannel open")},this._datachannel.onclose=function(){i._log.warn("datachannel close")},this._datachannel.onmessage=function(e){var t=new F2(e.data);i.emit("data_channel_msg",{data:t})},this._datachannel.onerror=function(e){i._log.warn("datachannel error",e)}),this._peerConnection.addTransceiver(UB.AUDIO,{direction:UB.TRANSCEIVER_DIRECTION_SENDONLY}),this._peerConnection.addTransceiver(UB.VIDEO,{direction:UB.TRANSCEIVER_DIRECTION_SENDONLY}),this._peerConnection.addTransceiver(UB.VIDEO,{direction:UB.TRANSCEIVER_DIRECTION_SENDONLY}),this._peerConnection.addTransceiver(UB.VIDEO,{direction:UB.TRANSCEIVER_DIRECTION_SENDONLY}),t.next=13,this._peerConnection.createOffer();case 13:return r=t.sent,t.next=16,S2(r.sdp,(null==(n=this._room.scheduleResult.config)?void 0:n.remove264FromSDP)||!1);case 16:return this.clientAbility=t.sent,this.originOffer=r,this.dtlsTransport&&(this.dtlsTransport.onstatechange=function(){var e=i.dtlsTransport;e&&(i._log.debug("dtls state: ".concat(e.state)),"connecting"===e.state&&0===i.stat.dtlsStartTime?i.stat.dtlsStartTime=Date.now():"connected"===e.state&&0===i.stat.dtlsEndTime&&(i.stat.dtlsEndTime=Date.now()))}),fK.addSuccessEvent({key:521707}),t.abrupt("return",this.clientAbility);case 23:throw t.prev=23,t.t0=t.catch(0),fK.addFailedEvent({key:521707,error:t.t0}),this._log.error("initialize failed ".concat(t.t0," \noffer: ").concat(null==r?void 0:r.sdp)),t.t0;case 26:case"end":return t.stop()}}),t,this,[[0,23]])})))}},{key:"setIceServers",value:function(e){return HF(this,null,p().mark((function t(){var n;return p().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this._peerConnection){t.next=6;break}if(this._log.info("setIceServers",JSON.stringify(e)),this._peerConnection.setConfiguration(this.getPeerConnectionConfig(e)),(null==(n=this._peerConnection)||!n.localDescription)&&this.originOffer){t.next=4;break}return this._log.warn("setIceServers warning, already has localDescription or no origin Offer"),t.abrupt("return");case 4:return t.next=6,this.setOffer(this.originOffer);case 6:case"end":return t.stop()}}),t,this)})))}},{key:"setPriority",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"high";if(this._peerConnection)try{this._peerConnection.getSenders().forEach((function(n){var r=n.getParameters();r.encodings[0]&&(r.encodings[0].priority=t,r.encodings[0].networkPriority=t,n.setParameters(r).catch((function(t){e._log.warn("setPriority error ",t)})))}))}catch(hH){this._log.warn("setPriority error ",hH)}}},{key:"connect",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return HF(this,null,p().mark((function n(){var r,i,o,a,s,c,u;return p().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(n.prev=0,"CONNECTED"!==this.currentState){n.next=3;break}return n.abrupt("return");case 3:if(n.t0=!(null!=(r=this._peerConnection)&&r.localDescription)&&this.originOffer,!n.t0){n.next=7;break}return n.next=7,this.setOffer(this.originOffer);case 7:return a=yj(),s={type:"answer",sdp:I2({serverAbility:e,clientAbility:this.clientAbility,offerSDP:this._peerConnection.localDescription.sdp,enableCustomMessage:this._enableCustomMessage})},this._serverAbility=e,n.next=11,this.setAnswer(s);case 11:return n.next=13,this.waitForPeerConnectionConnected();case 13:(c=(null==(i=this._room.scheduleResult.config)?void 0:i.priority)||(null==(o=this._room.joinParams)?void 0:o.priority)||new URLSearchParams(location.search).get("priority"))&&this.setPriority(c),t||fK.addSuccessEvent({key:521703,cost:yj()-a}),n.next=21;break;case 17:throw n.prev=17,n.t1=n.catch(0),(u=n.t1 instanceof tB&&n.t1.code===ZF.API_CALL_ABORTED)||this._log.error("connect failed: ".concat(n.t1),e),this.reset(),!u&&!this.isReconnecting&&(fK.addFailedEvent({key:521703,error:n.t1}),this.emitConnectionStateChangedEvent("DISCONNECTED"),this.startReconnection()),n.t1;case 21:case"end":return n.stop()}}),n,this,[[0,17]])})))}},{key:"reconnect",value:function(){return HF(this,null,p().mark((function e(){var t,n,r,i,o,a=this;return p().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(-1===this._reconnectionTimer){e.next=3;break}return this._log.warn("reconnect() is reconnecting, ignore current reconnection"),e.abrupt("return");case 3:if(this._signalChannel.isConnected){e.next=6;break}return this._log.warn("reconnect() wait signal channel is connected"),this._signalChannel.once(H0,this.reconnect,this),e.abrupt("return");case 6:return e.prev=6,this.reconnectionCount+=1,this._log.warn("reconnect() trying [".concat(this.reconnectionCount,"]")),this.reset(),t=this._signalChannel.getBackupRelayIpPair(),e.next=11,this.initialize(this._room.getIceServers(null!=t&&t.iceServer?[t.iceServer]:[]));case 11:return n=e.sent,r=xF({ability:n},t),e.next=15,this._signalChannel.sendWaitForResponse({command:_1,responseCommand:z0.REBUILD_PEER_CONNECTION_RES,data:r,enableLog:!1});case 15:if(0===(i=e.sent).data.code){e.next=18;break}throw new tB({code:i.data.code,message:i.data.message});case 18:return e.next=20,this.connect(i.data.data.ability,!0);case 20:fK.addSuccessEvent({key:521704}),this._log.warn("reconnect() success"),this.stopReconnection(),HW.emit(GW.SPC_RECONNECTED,{room:this._room}),this.emit("spc-reconnected"),e.next=42;break;case 27:if(e.prev=27,e.t0=e.catch(6),this.isReconnecting){e.next=31;break}return e.abrupt("return");case 31:if(null==e.t0||!e.t0.message.includes("timeout")){e.next=41;break}return o=rj(this.reconnectionCount),this._log.warn("reconnect() timeout, try again after ".concat(o/1e3,"s")),e.next=36,Fj(o,(function(e){a._reconnectionTimer=e}));case 36:return this.clearReconnectionTimer(),e.next=39,this.reconnect();case 39:e.next=42;break;case 41:this._log.error("reconnect() failed ".concat(null==e.t0?void 0:e.t0.code," ").concat(e.t0)),fK.addFailedEvent({key:521704,error:e.t0}),this.reconnectionCount>=dH()&&this._log.warn("SDK has tried reconnect for ".concat(dH()," times, but all failed, please check your network")),this.stopReconnection(),this.emitConnectionStateChangedEvent("DISCONNECTED"),this.emit("error");case 42:case"end":return e.stop()}}),e,this,[[6,27]])})))}},{key:"getPeerConnection",value:function(){return this._peerConnection}},{key:"startReconnection",value:function(){return HF(this,null,p().mark((function e(){return p().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(e.t0=this.isReconnecting,e.t0){e.next=7;break}return this._log.warn("start reconnect"),this._updateSDPPromise=null,this.emitConnectionStateChangedEvent("RECONNECTING"),e.next=7,this.reconnect();case 7:case"end":return e.stop()}}),e,this)})))}},{key:"stopReconnection",value:function(){var e;this.isReconnecting&&(this._log.info("stop reconnect"),this.reconnectionCount=0,this.clearReconnectionTimer(),null==(e=this.clearConnectTimeout)||e.call(this),this._signalChannel.off(H0,this.reconnect,this),"RECONNECTING"===this.currentState&&this.emitConnectionStateChangedEvent("DISCONNECTED"))}},{key:"checkPeerConnectionToReconnect",value:function(){var e;!this.isReconnecting&&(null==(e=this._peerConnection)?void 0:e.connectionState)===cH.CLOSED&&this.startReconnection()}},{key:"clearReconnectionTimer",value:function(){-1!==this._reconnectionTimer&&(clearTimeout(this._reconnectionTimer),this._reconnectionTimer=-1)}},{key:"onConnectionStateChange",value:function(e){var t,n=(null==(t=this._peerConnection)?void 0:t.iceConnectionState)||"closed",r=this.getDTLSTransportState();this._log.info("connectionState: ".concat(e.target.connectionState," ICE: ").concat(n," DTLS: ").concat(r)),e.target.connectionState===cH.CONNECTING&&(0===this.stat.peerConnectionStartTime&&(this.stat.peerConnectionStartTime=Date.now()),this.emitConnectionStateChangedEvent("CONNECTING")),(e.target.connectionState===cH.FAILED||e.target.connectionState===cH.CLOSED)&&(this.emitConnectionStateChangedEvent("DISCONNECTED"),this._room.forceRelay?this.switchRelay(!1):this.startReconnection()),(e.target.connectionState===cH.CONNECTED||e.target.connectionState===cH.COMPLETED)&&(0===this.stat.peerConnectionEndTime&&(this.stat.peerConnectionEndTime=Date.now()),HW.emit(GW.SINGLE_CONNECTION_STAT,{room:this._room,stat:{ice:this.stat.iceEndTime-this.stat.iceStartTime,dtls:this.stat.dtlsEndTime-this.stat.dtlsStartTime,peerConnection:this.stat.peerConnectionEndTime-this.stat.peerConnectionStartTime}}),this.logSelectedCandidate(),this.emitConnectionStateChangedEvent("CONNECTED"))}},{key:"getDTLSTransportState",value:function(){if(!this._peerConnection)return sH;var e=null;return FK()&&0!==this._peerConnection.getSenders().length?(e=this._peerConnection.getSenders()[0].transport,UK()&&0!==this._peerConnection.getReceivers().length&&e?e.state:sH):sH}},{key:"emitConnectionStateChangedEvent",value:function(e){e!==this.currentState&&("RECONNECTING"===this.currentState&&"CONNECTING"===e||(this.emit(x2.CONNECTION_STATE_CHANGED,{prevState:this.currentState,state:e}),this.currentState=e))}},{key:"logSelectedCandidate",value:function(){return HF(this,null,p().mark((function e(){var t,n,r,i,o,a,s;return p().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._peerConnection){e.next=2;break}return e.abrupt("return");case 2:return e.next=4,this._peerConnection.getStats();case 4:t=e.sent,n=c(t),e.prev=6,n.s();case 8:if((r=n.n()).done){e.next=16;break}if((i=_(r.value,2))[0],o=i[1],!NK(o)){e.next=14;break}return a=t.get(o.localCandidateId),s=t.get(o.remoteCandidateId),a&&(this._log.info("local candidate: ".concat(a.candidateType," ").concat(a.protocol,":").concat(a.ip||a.address,":").concat(a.port," ").concat(a.networkType||""," ").concat("relay"===a.candidateType?"relayProtocol:".concat(a.relayProtocol):"")),a.networkType&&KH(a.networkType)),s&&this._log.info("remote candidate: ".concat(s.candidateType," ").concat(s.protocol,":").concat(s.ip||s.address,":").concat(s.port)),e.abrupt("break",16);case 14:e.next=8;break;case 16:e.next=21;break;case 18:e.prev=18,e.t0=e.catch(6),n.e(e.t0);case 21:return e.prev=21,n.f(),e.finish(21);case 24:case"end":return e.stop()}}),e,this,[[6,18,21,24]])})))}},{key:"waitForPeerConnectionConnected",value:function(){var e=this;return this._waitForPCConnectedPromise||(this._waitForPCConnectedPromise=new Promise((function(t,n){if("CONNECTED"===e.currentState)return t();var r=function(e){"CONNECTED"===e.state&&(clearTimeout(a),o(),t())},i=function(t){t.room===e._room&&(clearTimeout(a),o(),n(new tB({code:ZF.API_CALL_ABORTED,message:rK({key:ZJ.CONNECTION_ABORTED,data:"leave room"})})))},o=function(){HW.off(GW.LEAVE_SUCCESS,i,e),e.off(x2.CONNECTION_STATE_CHANGED,r,e)},a=setTimeout((function(){o();var t=new tB({code:ZF.API_CALL_TIMEOUT,message:"connection timeout"});O2+=1,function(e){return O2>2&&!P2&&0===M2.size&&e}(e._signalChannel.isConnected)&&(e._log.warn("firewall restriction"),P2=!0,e.emit(x2.FIREWALL_RESTRICTION)),n(t)}),AH);e.clearConnectTimeout=function(){o(),clearTimeout(a),delete e.clearConnectTimeout},HW.on(GW.LEAVE_SUCCESS,i,e),e.on(x2.CONNECTION_STATE_CHANGED,r,e)})),this._waitForPCConnectedPromise=this._waitForPCConnectedPromise.finally((function(){e._waitForPCConnectedPromise=null,delete e.clearConnectTimeout}))),this._waitForPCConnectedPromise}},{key:"waitForReconnected",value:function(){var e=this;return this.isReconnecting?new Promise((function(t,n){e.once("spc-reconnected",t),e.once("error",n)})):Promise.resolve()}},{key:"addDownlink",value:function(e){return HF(this,null,p().mark((function t(){return p().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this._log.info("addDownlink(".concat(e.userId,") trying")),t.t0=this.isReconnecting,!t.t0){t.next=5;break}return t.next=5,this.waitForReconnected();case 5:if(t.t1=this._updateSDPPromise,!t.t1){t.next=9;break}return t.next=9,this._updateSDPPromise;case 9:if(this.updateLocalAndRemoteSDPConfig(e),0!==this.addDownlinkQueue.size){t.next=22;break}return t.prev=11,t.next=14,this.updateSDP();case 14:this._log.info("addDownlink(".concat(e.userId,") done")),t.next=22;break;case 17:return t.prev=17,t.t2=t.catch(11),this._log.error("addDownlink(".concat(e.userId,") failed ").concat(t.t2)),t.next=22,this.startReconnection();case 22:case"end":return t.stop()}}),t,this,[[11,17]])})))}},{key:"updateLocalAndRemoteSDPConfig",value:function(e){var t=e.ssrc,n=e.userId,r=e.tinyId;if(this._peerConnection){this._log.info("updateLocalAndRemoteSDPConfig ".concat(n," ").concat(JSON.stringify(t)));var i=this._peerConnection.getTransceivers().slice(4).filter((function(e){return"inactive"===e.direction})).slice(0,3).map((function(e){return e.direction=UB.TRANSCEIVER_DIRECTION_RECVONLY,Number(e.mid)}));this._parsedAnswer||(this._parsedAnswer=P1(this._peerConnection.remoteDescription.sdp));var o,a,s,c=this._parsedAnswer.media.filter((function(e){var t;return null==(t=e.ssrcs)?void 0:t.find((function(e){var t;return null==(t=e.value)?void 0:t.includes(r)}))}));if(3===c.length)o=c[0],a=c[1],s=c[2];else if(3===i.length)o=this._parsedAnswer.media.find((function(e){return Number(e.mid)===Number(i[0])})),a=this._parsedAnswer.media.find((function(e){return Number(e.mid)===Number(i[1])})),s=this._parsedAnswer.media.find((function(e){return Number(e.mid)===Number(i[2])}));else if(0===i.length){this._peerConnection.addTransceiver(UB.AUDIO,{direction:UB.TRANSCEIVER_DIRECTION_RECVONLY}),this._peerConnection.addTransceiver(UB.VIDEO,{direction:UB.TRANSCEIVER_DIRECTION_RECVONLY}),this._peerConnection.addTransceiver(UB.VIDEO,{direction:UB.TRANSCEIVER_DIRECTION_RECVONLY}),o=JSON.parse(JSON.stringify(this._parsedAnswer.media[0]));var u=b2({mid:1,serverAbility:this._serverAbility,clientAbility:this.clientAbility,parsedOffer:P1(this._peerConnection.localDescription.sdp),isDownlink:!0});a=JSON.parse(JSON.stringify(u)),s=JSON.parse(JSON.stringify(u)),o.mid=this._parsedAnswer.media.length,this._parsedAnswer.media.push(o),a.mid=this._parsedAnswer.media.length,this._parsedAnswer.media.push(a),s.mid=this._parsedAnswer.media.length,this._parsedAnswer.media.push(s)}o.direction=UB.TRANSCEIVER_DIRECTION_SENDONLY;var l="".concat(r,"-").concat(t.audio);o.ssrcs=[{id:t.audio,attribute:"cname",value:"".concat(l)},{id:t.audio,attribute:"msid",value:"".concat(l,"-").concat(UB.MAIN," ").concat(l,"-audio")}],a.direction=UB.TRANSCEIVER_DIRECTION_SENDONLY,a.ssrcs=[{id:t.video,attribute:"cname",value:"".concat(l)},{id:t.video,attribute:"msid",value:"".concat(l,"-").concat(UB.MAIN," ").concat(l,"-bigvideo")},{id:t.videoRtx,attribute:"cname",value:"".concat(l)},{id:t.videoRtx,attribute:"msid",value:"".concat(l,"-").concat(UB.MAIN," ").concat(l,"-bigvideo")}],a.ssrcGroups=[{semantics:"FID",ssrcs:"".concat(t.video," ").concat(t.videoRtx)}],s.direction=UB.TRANSCEIVER_DIRECTION_SENDONLY;var d="".concat(l,"-aux");s.ssrcs=[{id:t.auxiliary,attribute:"cname",value:d},{id:t.auxiliary,attribute:"msid",value:"".concat(d," ").concat(l,"-aux").concat(UB.VIDEO)},{id:t.auxiliaryRtx,attribute:"cname",value:"".concat(d," ").concat(l,"-aux").concat(UB.VIDEO)},{id:t.auxiliaryRtx,attribute:"msid",value:"".concat(d," ").concat(l,"-aux").concat(UB.VIDEO)}],s.ssrcGroups=[{semantics:"FID",ssrcs:"".concat(t.auxiliary," ").concat(t.auxiliaryRtx)}],this._parsedAnswer.groups&&(this._parsedAnswer.groups[0].mids=this._parsedAnswer.media.map((function(e){return e.mid})).join(" ")),this._downlinkMIDMap.set(n,[o.mid,a.mid,s.mid]),this._downlinkMIDUserIDMap.set(o.mid,n),this._downlinkMIDUserIDMap.set(a.mid,n),this._downlinkMIDUserIDMap.set(s.mid,n)}}},{key:"removeDownlink",value:function(e){return HF(this,null,p().mark((function t(){var n,r,i=this;return p().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this._downlinkMIDMap.has(e)&&this._peerConnection){t.next=2;break}return t.abrupt("return");case 2:if(this._log.info("removeDownlink(".concat(e,") trying")),t.t0=this.isReconnecting,!t.t0){t.next=7;break}return t.next=7,this.waitForReconnected();case 7:if(t.t1=this._updateSDPPromise,!t.t1){t.next=11;break}return t.next=11,this._updateSDPPromise;case 11:if(n=this._downlinkMIDMap.get(e),r=!1,this._peerConnection.getTransceivers().forEach((function(e){null!=n&&n.includes(Number(e.mid))&&(r=!0,e.direction="inactive")})),this._parsedAnswer||(this._parsedAnswer=P1(this._peerConnection.remoteDescription.sdp)),this._parsedAnswer.media.forEach((function(e){null!=n&&n.includes(Number(e.mid))&&(r=!0,e.direction="inactive",e.ssrcs=[],e.ssrcGroups=[])})),t.t2=0===this.removeDownlinkQueue.size&&r,!t.t2){t.next=19;break}return t.next=19,this.updateSDP();case 19:this._downlinkMIDMap.delete(e),null==n||n.forEach((function(e){return i._downlinkMIDUserIDMap.delete(e)})),this._log.info("removeDownlink(".concat(e,") done"));case 22:case"end":return t.stop()}}),t,this)})))}},{key:"setBandwidth",value:function(e){return HF(this,null,p().mark((function t(){var n,r,i,o,a,s,c,u,l;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(n=e.audio,r=e.bigVideo,i=e.smallVideo,o=e.auxVideo,t.prev=3,!KK()){t.next=26;break}a=this._peerConnection.getSenders().slice(0,4),s=0;case 7:if(!(s<a.length)){t.next=17;break}if(c=a[s],u=void 0,0===s&&n?u=n:1===s&&r?u=r:2===s&&i?u=i:3===s&&o&&(u=o),t.t0=u,!t.t0){t.next=14;break}return t.next=14,this.setSenderMaxBitrate(c,u);case 14:s++,t.next=7;break;case 17:if(l=!1,r&&a[1].track&&(l=this.setStartBitrate(1,r)),o&&a[3].track&&(l=this.setStartBitrate(3,o)||l),t.t1=l,!t.t1){t.next=24;break}return t.next=24,this.updateSDP();case 24:t.next=28;break;case 26:return t.next=28,this.setBandwidthBySDP(e);case 28:this._log.info("setBandwidth ".concat(JSON.stringify(e))),t.next=34;break;case 31:t.prev=31,t.t2=t.catch(3),this._log.error("failed to set bandwidth: ".concat(t.t2));case 34:case"end":return t.stop()}}),t,this,[[3,31]])})))}},{key:"setStartBitrate",value:function(e,t){var n,r;return!(null==(n=this._peerConnection)||!n.remoteDescription||(this._parsedAnswer||(this._parsedAnswer=P1(this._peerConnection.remoteDescription.sdp)),null==(r=this._parsedAnswer.media[e])||!r.fmtp[0]))&&(this._parsedAnswer.media[e].fmtp[0].config+=";x-google-start-bitrate=".concat(t>5e3?5e3:t),!0)}},{key:"setSenderMaxBitrate",value:function(e,t){var n=e.getParameters();return(!n.encodings||0===n.encodings.length)&&(n.encodings=[{}]),"unlimited"===t?delete n.encodings[0].maxBitrate:n.encodings[0].maxBitrate=1e3*t,e.setParameters(n)}},{key:"setBandwidthBySDP",value:function(e){var t=e.audio,n=e.bigVideo,r=e.smallVideo,i=e.auxVideo;if(this._peerConnection&&this._peerConnection.localDescription){var o=P1(this._peerConnection.localDescription.sdp);this._parsedAnswer||(this._parsedAnswer=P1(this._peerConnection.remoteDescription.sdp));var a=fG?"TIAS":"AS";t&&(o.media[0].bandwidth=[{type:a,limit:fG?1e3*t:t}],this._parsedAnswer.media[0].bandwidth=[{type:a,limit:fG?1e3*t:t}]),n&&(o.media[1].bandwidth=[{type:a,limit:fG?1e3*n:n}],this._parsedAnswer.media[1].bandwidth=[{type:a,limit:fG?1e3*n:n}]),r&&(o.media[2].bandwidth=[{type:a,limit:fG?1e3*r:r}],this._parsedAnswer.media[2].bandwidth=[{type:a,limit:fG?1e3*r:r}]),i&&(o.media[3].bandwidth=[{type:a,limit:fG?1e3*i:i}],this._parsedAnswer.media[3].bandwidth=[{type:a,limit:fG?1e3*i:i}]);var s={type:"offer",sdp:M1(o)};return this.updateSDP({localDescription:s})}}},{key:"setScaleResolutionDownBy",value:function(e,t,n){var r=e.getParameters();(!r.encodings||0===r.encodings.length)&&(r.encodings=[{}]);var i=r.encodings[0].scaleResolutionDownBy;if(aj(i)?1!==t:t!==i){var o="setScaleResolutionDownBy ".concat(n," ").concat(t);return i&&(o+=" prevScale: ".concat(i)),this._log.warn(o),r.encodings[0].scaleResolutionDownBy=t,e.setParameters(r)}}},{key:"updateSDP",value:function(){var e=this,t=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}).localDescription;if(!this._parsedAnswer)return Promise.resolve();var n=M1(this._parsedAnswer);return this._updateSDPPromise=new Promise((function(r,i){return HF(e,null,p().mark((function e(){var o,a;return p().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(e.prev=0,e.t0=!t&&this._peerConnection,!e.t0){e.next=7;break}return this._log.info("creating offer"),e.next=6,this._peerConnection.createOffer();case 6:t=e.sent;case 7:if(e.t1=t,!e.t1){e.next=11;break}return e.next=11,this.setOffer(t);case 11:return e.next=13,this.setAnswer({type:"answer",sdp:n});case 13:this._updateSDPPromise=null,r(),e.next=20;break;case 17:e.prev=17,e.t2=e.catch(0),this._log.error(e.t2),!this._isSDPLogged&&this._peerConnection&&(this._log.warn("current offer: ".concat(this.filterSDPDirection(null==(o=this._peerConnection.localDescription)?void 0:o.sdp)," \nnext offer: ").concat(this.filterSDPDirection(null==t?void 0:t.sdp))),this._log.warn("current answer: ".concat(this.filterSDPDirection(null==(a=this._peerConnection.remoteDescription)?void 0:a.sdp)," \nnext answer: ").concat(this.filterSDPDirection(n))),this._log.warn("offer: ".concat(null==t?void 0:t.sdp)),this._log.warn("answer: ".concat(n)),this._log.warn("transceivers: ".concat(JSON.stringify(this._peerConnection.getTransceivers().map((function(e){return{mid:e.mid,currentDirection:e.currentDirection,direction:e.direction,stopped:e.stopped}}))))),this._log.warn("parsedAnswer: ".concat(JSON.stringify(this._parsedAnswer))),this._isSDPLogged=!0),this._updateSDPPromise=null,i(e.t2);case 20:case"end":return e.stop()}}),e,this,[[0,17]])})))})),this._updateSDPPromise}},{key:"setTransceiverDirection",value:function(e,t){return HF(this,null,p().mark((function n(){var r,i,o,a,s;return p().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(fG&&this._peerConnection&&this._parsedAnswer){n.next=2;break}return n.abrupt("return");case 2:this._log.info("setting transceiver ".concat(t.join(",")," direction to ").concat(e)),r=this._peerConnection.getTransceivers(),t.forEach((function(t){r[t].direction!==e&&(r[t].direction=e)})),i=c(t);try{for(i.s();!(o=i.n()).done;)a=o.value,s=this._parsedAnswer.media[a].direction,e===FB.INACTIVE&&s===FB.RECVONLY&&(this._parsedAnswer.media[a].direction=e),e===FB.SENDONLY&&s===FB.INACTIVE&&(this._parsedAnswer.media[a].direction=FB.RECVONLY)}catch(u){i.e(u)}finally{i.f()}return n.next=9,this.updateSDP();case 9:case"end":return n.stop()}}),n,this)})))}},{key:"filterSDPDirection",value:function(){return P1(arguments.length>0&&void 0!==arguments[0]?arguments[0]:"").media.map((function(e){return e.direction}))}},{key:"setOffer",value:function(e){this._log.info("setting offer");var t=R2(e.sdp,this.clientAbility,this._serverAbility);return this._log.debug(t),this._peerConnection.setLocalDescription({type:"offer",sdp:t})}},{key:"setAnswer",value:function(e){return this._log.info("setting answer"),this._log.debug(e.sdp),this._peerConnection.setRemoteDescription(e)}},{key:"switchVideoEncoder",value:function(e){return HF(this,null,p().mark((function t(){var n,r=this;return p().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this._peerConnection&&this._parsedAnswer&&this._serverAbility){t.next=2;break}return t.abrupt("return");case 2:if(n=!1,this._parsedAnswer.media.forEach((function(t){var i;if(t.type===UB.VIDEO){var o=r._serverAbility.video.codecs.find((function(t){return t.codec.toLowerCase()===e}));o&&(null==(i=t.payloads)||!i.includes(String(o.payload)))&&(t.fmtp=[],t.payloads="",t.rtp=[],t.rtcpFb=[],A2(t,o),n=!0)}})),t.t0=n,!t.t0){t.next=9;break}return this._log.warn("switch video encoder to ".concat(e)),t.next=9,this.updateSDP();case 9:case"end":return t.stop()}}),t,this)})))}},{key:"useHWEncoder",value:function(){var e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0],t=arguments.length>1?arguments[1]:void 0;return HF(this,null,p().mark((function n(){var r,i,o=this;return p().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(this._peerConnection&&this._parsedAnswer&&this._serverAbility){n.next=2;break}return n.abrupt("return");case 2:if(r=!1,i=[],aj(t)?i=this._parsedAnswer.media.slice(1,4):2===t?i.push(this._parsedAnswer.media[1]):3===t?i.push(this._parsedAnswer.media[2]):7===t&&i.push(this._parsedAnswer.media[3]),i.forEach((function(t){var n,i;t.type===UB.VIDEO&&(e&&o.is42001fSupported?i=o.clientAbility.video.codecs.find((function(e){return e.fmtp.includes("42001f")})):e||(i=o._serverAbility.video.codecs.find((function(e){return e.codec.toLowerCase()===(o._serverAbility.useVp8?"vp8":"h264")}))),i&&(null==(n=t.payloads)||!n.includes(String(i.payload)))&&(t.fmtp=[],t.payloads="",t.rtp=[],t.rtcpFb=[],A2(t,i),r=!0))})),n.t0=r,!n.t0){n.next=10;break}return this._log.warn("use ".concat(e?"hw":"sw"," encoder")),n.next=10,this.updateSDP();case 10:case"end":return n.stop()}}),n,this)})))}},{key:"sendDataChannelMessage",value:function(e){var t;null==(t=this._datachannel)||t.send(e)}},{key:"reset",value:function(){this._peerConnection&&(this._peerConnection.close(),this._peerConnection.removeEventListener("track",this._peerConnection._onaddstreampoly,this),this._peerConnection._onaddstreampoly=null,this._peerConnection=null),this._waitForPCConnectedPromise=null,this._parsedAnswer=null,this.originOffer=null}},{key:"close",value:function(){this._log.info("close pc"),this.removeRTCListener(),this.insertableStreamsAbortMap.forEach((function(e){return Wj(e.abort)&&e.abort("destroy")})),this.insertableStreamsAbortMap.clear(),this.reset(),this.emitConnectionStateChangedEvent("DISCONNECTED"),this._downlinkMIDMap.clear(),this.stopReconnection(),this.removeAllListeners(),this._room.healthDetector.off("1",this.onBadHealth,this)}},{key:"getReceiversByUserId",value:function(e){if(!this._peerConnection)return[];var t=this._peerConnection.getReceivers();return(this._downlinkMIDMap.get(e)||[]).map((function(e){return t[e]}))}},{key:"isUsingRelay",get:function(){return"relay"===this._room.getIceTransportPolicy()}},{key:"detectTCPAndUDP",value:function(e){var t,n=e.uplinkRTT,r=e.downlinkRTT;if("CONNECTED"===this.currentState&&(!this._isRelayTried||this._room.forceRelay)&&0!==this._room.getIceServers().length){var i=this._signalChannel.rtt,o=Math.max(n,r),a=(null==(t=this._room.scheduleResult.config)?void 0:t.useTurnTcpInfo)||{},s=a.rttRatioThreshold,c=a.rttThreshold;if(s&&c&&i&&o){var u=Math.floor(o/i),l=(this._isRelayTried||u>s)&&o>c;l?++this._rttOverCount<5||(this._log.warn("detectTCPAndUDP ws-rtt: ".concat(i," upRTT: ").concat(n," downRTT: ").concat(r," ratio: ").concat(u," over-count: ").concat(this._rttOverCount," isOver: ").concat(l," isRelayTried: ").concat(this._isRelayTried," force-relay: ").concat(this._room.forceRelay)),this.isUsingRelay||this._isRelayTried?this._room.forceRelay&&this.switchRelay(!1):(this._isRelayTried=!0,this._rttOverCount=0,this.switchRelay(!0))):this._rttOverCount=0}}}},{key:"switchRelay",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return HF(this,null,p().mark((function n(){var r,i,o;return p().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(this.isUsingRelay!==e){n.next=2;break}return n.abrupt("return");case 2:return r=e?"relay":"udp",i=e?521709:521710,n.prev=3,this._room.forceRelay=e,this._log.warn("switchRelay ".concat(r)),o=Date.now(),n.next=8,this.doSwitchRelay(r);case 8:this._log.warn("switchRelay ".concat(r," success")),fK.addSuccessEvent({key:i,cost:Date.now()-o}),n.next=22;break;case 12:if(n.prev=12,n.t0=n.catch(3),this._log.warn("switchRelay ".concat(r," failed"),n.t0),fK.addFailedEvent({key:i,error:n.t0}),!t){n.next=20;break}this._room.reJoin(),n.next=22;break;case 20:return n.next=22,this.switchRelay(!e,!0);case 22:case"end":return n.stop()}}),n,this,[[3,12]])})))}},{key:"doSwitchRelay",value:function(e){var t=this;return new Promise((function(n,r){var i=setTimeout((function(){t.stopReconnection(),r(new Error("switch ".concat(e," timeout")))}),1e4);t.startReconnection().then(n,r).finally((function(){return clearTimeout(i)}))}))}},{key:"removeRTCListener",value:function(){this._peerConnection&&(this._peerConnection.oniceconnectionstatechange=null,this._peerConnection.onconnectionstatechange=null,this._peerConnection.onsignalingstatechange=null,this._peerConnection.ontrack=null),this.dtlsTransport&&(this.dtlsTransport.onstatechange=null)}}])}(y2.default);UF([lY("reconnect")],V2.prototype,"startReconnection",1),UF([dY((function(e){return e.userId}))],V2.prototype,"addDownlink",1),UF([dY((function(e){return e}))],V2.prototype,"removeDownlink",1),UF([uY(!0)],V2.prototype,"updateSDP",1),UF([hY(521712,!1)],V2.prototype,"setOffer",1),UF([hY(521713,!1)],V2.prototype,"setAnswer",1);var U2=s((function e(t){i(this,e),FF(this,"tag"),FF(this,"len"),FF(this,"data");var n=new DataView(t);this.tag=n.getUint16(),this.len=n.getUint16(2),this.data=new Uint8Array(t).slice(4,4+this.len).buffer})),F2=s((function e(t){var n=this;i(this,e),FF(this,"tinyId"),FF(this,"data");for(var r=new DataView(t),o=0,a=[];o<r.byteLength;){var s=r.getUint16(o+2),c=new U2(new Uint8Array(t).slice(o,o+2+2+s).buffer);a.push(c),o+=4+s}a.forEach((function(e){1===e.tag?n.tinyId=(new TextDecoder).decode(e.data):2===e.tag&&(n.data=e.data)}))})),B2=new Set;function H2(){var e=Math.floor(4294967296*Math.random());return B2.has(e)?H2():(B2.add(e),e)}var j2=function(e){function t(e){var n;return i(this,t),n=r(this,t),FF(n,"userId"),FF(n,"tinyId"),FF(n,"_sdpSemantics"),FF(n,"_isUplink"),FF(n,"_room"),FF(n,"_log"),FF(n,"_currentState","DISCONNECTED"),FF(n,"_prevTime",-1),n.userId=e.userId,n.tinyId=e.tinyId,n._room=e.room,n._sdpSemantics=e.room.sdpSemantics,n._isUplink=e.isUplink,n._log=qW.createLogger({id:"n",userId:n._room.userId,remoteUserId:n._isUplink?void 0:n.userId,sdkAppId:n._room.sdkAppId,isLocal:n._isUplink}),n}return d(t,e),s(t,[{key:"_peerConnection",get:function(){var e;return(null==(e=this.singlePC)?void 0:e.getPeerConnection())||null}},{key:"singlePC",get:function(){return this._room.singlePC}},{key:"_signalChannel",get:function(){return this._room.signalChannel}},{key:"close",value:function(e){this._log.info("close connection"),this.emit("closed",e)}},{key:"emitConnectionStateChangedEvent",value:function(e){return e!==this._currentState&&(HW.emit(GW.PEER_CONNECTION_STATE_CHANGED,{room:this._room,prevState:this._currentState,state:e,remoteUserId:this._isUplink?void 0:this.userId}),this.emit("connection-state-changed",{prevState:this._currentState,state:e}),this._currentState=e,!0)}},{key:"getPeerConnection",value:function(){return this._peerConnection}},{key:"getRoom",value:function(){return this._room}},{key:"getUserId",value:function(){return this.userId}},{key:"getTinyId",value:function(){return this.tinyId}},{key:"getCurrentState",value:function(){return this._currentState}},{key:"isH264",get:function(){var e,t;return!(null==(t=null==(e=this._peerConnection)?void 0:e.remoteDescription)||!t.sdp.includes("H264"))}}])}(VF(jF()).default),G2=function(e){function t(e){var n;return i(this,t),n=r(this,t,[OF(xF({},e),{isUplink:!0})]),FF(n,"localMainAudioTrack",null),FF(n,"localMainVideoTrack",null),FF(n,"localAuxAudioTrack",null),FF(n,"localAuxVideoTrack",null),FF(n,"_isPublishingAux",!1),FF(n,"_publishingLocalAudioTrack"),FF(n,"_publishingLocalVideoTrack"),FF(n,"_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}),FF(n,"_flag",0),FF(n,"_checkPublishStateTimeoutId",-1),n.initialize(),n}return d(t,e),s(t,[{key:"videoCodec",get:function(){var e;return(null==(e=this.singlePC)?void 0:e.videoCodec)||"h264"}},{key:"ssrc",get:function(){if(!this.singlePC)return{audio:0,video:0,videoRtx:0,small:0,smallRtx:0,auxiliary:0,auxiliaryRtx:0};var e=this.singlePC.uplinkSSRC;return{audio:e.audioSsrc||0,video:e.bigVideoSsrc||0,videoRtx:e.bigVideoRtxSsrc||0,small:e.smallVideoSsrc||0,smallRtx:e.smallVideoRtxSsrc||0,auxiliary:e.auxVideoSsrc||0,auxiliaryRtx:e.auxVideoRtxSsrc||0}}},{key:"flag",get:function(){return this._flag},set:function(e){this._flag!==e&&(this._flag=e,this.checkPublishState())}},{key:"checkPublishState",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];if(t||!(this._checkPublishStateTimeoutId>0)){var n=this.publishState,r=this.serverPublishState,i=Object.keys(n).find((function(e){return n[e]!==r[e]}));if(i){if(!t)return void(this._checkPublishStateTimeoutId=Iz.run("timeout",(function(){return e.checkPublishState(!0)}),{delay:1e4,count:1}));this._log.warn("publish state not matched, ".concat(i," local:").concat(n[i]," server:").concat(r[i]," ").concat(VW()," ").concat(OW())),fK.addCount({key:521e3})}Iz.clearTask(this._checkPublishStateTimeoutId),this._checkPublishStateTimeoutId=-1}}},{key:"isMainStreamPublished",get:function(){return!(!this.localMainAudioTrack&&!this.localMainVideoTrack)}},{key:"isAuxStreamPublished",get:function(){return!(!this.localAuxVideoTrack&&!this.localAuxAudioTrack)}},{key:"publishState",get:function(){var e,t,n,r,i=this,o={audio:!1,bigVideo:!1,smallVideo:!1,auxVideo:!1};if(this._peerConnection){var a=this._peerConnection.getSenders();a&&(BK()?(o.audio=!(null==(e=a[0])||!e.track),o.bigVideo=!(null==(t=a[1])||!t.track),o.smallVideo=!(null==(n=a[2])||!n.track),o.auxVideo=!(null==(r=a[3])||!r.track)):a.forEach((function(e){e.track&&(e.track.kind===UB.AUDIO?o.audio=!0:(o.bigVideo=!0,i._room.videoManager.hasSmall&&(o.smallVideo=!0)))})))}return o}},{key:"publishingState",get:function(){var e=this.publishState,t=xF({},e);return this._publishingLocalAudioTrack&&(t.audio=!0),this._publishingLocalVideoTrack&&(this._isPublishingAux?t.auxVideo=!0:(t.bigVideo=!0,this._publishingLocalVideoTrack.small&&(t.smallVideo=!0))),t}},{key:"serverPublishState",get:function(){return{audio:!!(this.flag&JB),bigVideo:!!(this.flag&jB),smallVideo:!!(this.flag&GB),auxVideo:!!(this.flag&WB)}}},{key:"muteState",get:function(){var e,t,n;return{audio:!(null==(e=this.localMainAudioTrack)||!e.muted),bigVideo:!(null==(t=this.localMainVideoTrack)||!t.muted),auxVideo:!(null==(n=this.localAuxVideoTrack)||!n.muted)}}},{key:"initialize",value:function(){this.installEvents()}},{key:"close",value:function(e){var n,r,i=c((null==(n=this._peerConnection)?void 0:n.getSenders())||[]);try{for(i.s();!(r=i.n()).done;){r.value.replaceTrack(null)}}catch(o){i.e(o)}finally{i.f()}y(t,"close",this,3)([e]),this.uninstallEvents(),this.uninstallTrackMuteEvents(this.localMainAudioTrack,this.localMainVideoTrack,this.localAuxVideoTrack),this.emitConnectionStateChangedEvent("DISCONNECTED")}},{key:"installEvents",value:function(){this.listeners("connection-state-changed").includes(this.handleConnectionStateChange)||this.on("connection-state-changed",this.handleConnectionStateChange,this),this.installSPCEvents()}},{key:"installSPCEvents",value:function(){var e,t;null!=(e=this.singlePC)&&e.listeners("spc-reconnected").includes(this.onSinglePCReconnected)||null==(t=this.singlePC)||t.on("spc-reconnected",this.onSinglePCReconnected,this)}},{key:"uninstallSPCEvents",value:function(){var e;null==(e=this.singlePC)||e.off("spc-reconnected",this.onSinglePCReconnected,this)}},{key:"uninstallEvents",value:function(){this.off("connection-state-changed",this.handleConnectionStateChange,this),this.uninstallSPCEvents()}},{key:"emitConnectionStateChangedEvent",value:function(e,n){var r,i,o,a=this._currentState,s=y(t,"emitConnectionStateChangedEvent",this,3)([e]);return s&&a!==e&&(n?n.emit("connection-state-changed",{prevState:a,state:e}):(null==(r=this.localMainVideoTrack)||r.emit("connection-state-changed",{prevState:a,state:e}),null==(i=this.localAuxVideoTrack)||i.emit("connection-state-changed",{prevState:a,state:e}),null==(o=this._publishingLocalVideoTrack)||o.emit("connection-state-changed",{prevState:a,state:e}))),s}},{key:"onVideoEncodeFailed",value:function(e){var t;e&&e.isMediaTrackActive&&"h264"===this.videoCodec&&(this._log.warn("h264 encoder not working"),null!=(t=this.singlePC)&&t.isVP8EncodeSupported&&(this._log.warn("switch to vp8"),this.singlePC.switchVideoEncoder("vp8")))}},{key:"publish",value:function(e){return HF(this,arguments,(function(e){var t=this,n=e.localAudioTrack,r=e.localVideoTrack,i=e.isAuxiliary;return p().mark((function e(){var o,a,s,c,u,l,d,h,f,m,v;return p().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t.singlePC){e.next=2;break}return e.abrupt("return");case 2:return t.installEvents(),e.next=5,t.singlePC.waitForPeerConnectionConnected();case 5:if(h=t.publishState,f=t.muteState,n&&(t._publishingLocalAudioTrack=n,h.audio=!0,f.audio=n.muted),!r){e.next=22;break}if(t.singlePC.isH264EncodeSupported||t.singlePC.isVP8EncodeSupported){e.next=9;break}throw new tB({code:ZF.NOT_SUPPORTED_H264,message:rK({key:ZJ.NOT_SUPPORTED_H264ENCODE})});case 9:if(e.t0=t.singlePC.isUsingH264&&!t.singlePC.isH264EncodeSupported&&t.singlePC.isVP8EncodeSupported,!e.t0){e.next=14;break}return t._log.warn("h264 encoder not supported"),e.next=14,t.singlePC.switchVideoEncoder("vp8");case 14:if(e.t1=uG&&115===lW()&&r.profile.width*r.profile.height<=230400,!e.t1){e.next=20;break}return t._log.warn("fallback video to 480p"),r.setProfile(LB["480p_2"]),e.next=20,r.applyProfile();case 20:t._publishingLocalVideoTrack=r,i?(h.auxVideo=!0,f.auxVideo=r.muted):(h.bigVideo=!0,f.bigVideo=r.muted);case 22:return t._isPublishingAux=i,r&&!i&&r.small&&(m=t._room.videoManager.smallTrack,h.smallVideo=!0),e.next=26,t._signalChannel.sendWaitForResponseWithRetry({command:y1,responseCommand:z0.SPC_PUBLISH_RESULT,data:OF(xF({},t.singlePC.uplinkSSRC),{state:h,muteState:f}),retries:3});case 26:return e.next=28,t.publishByTransceiver({localAudioTrack:n,localVideoTrack:r,smallTrack:m,isAuxiliary:i});case 28:if(t._publishingLocalAudioTrack=null,t._publishingLocalVideoTrack=null,t._isPublishingAux=!1,!r){e.next=36;break}return t[i?"localAuxVideoTrack":"localMainVideoTrack"]=r,v=r.scaleResolutionDownBy,e.next=36,t.singlePC.setScaleResolutionDownBy(t._peerConnection.getSenders()[i?3:1],v,r.streamType);case 36:return n&&(t[i?"localAuxAudioTrack":"localMainAudioTrack"]=n),e.next=39,t.singlePC.setBandwidth({audio:(null==(o=t.localMainAudioTrack)?void 0:o.profile.bitrate)||(null==(a=t.localAuxAudioTrack)?void 0:a.profile.bitrate),bigVideo:null==(s=t.localMainVideoTrack)?void 0:s.profile.bitrate,smallVideo:null==(u=null==(c=t.localMainVideoTrack)?void 0:c.small)?void 0:u.bitrate,auxVideo:null==(l=t.localAuxVideoTrack)?void 0:l.profile.bitrate});case 39:t.sendMediaSettings(),t.installTrackMuteEvents(n,r),(t._room.preferHW||null!=(d=t._room.scheduleResult.config)&&d.preferHW)&&r&&r.profile.width*r.profile.height>=921600&&t.singlePC.useHWEncoder(!0,i?7:2);case 42:case"end":return e.stop()}}),e)}))()}))}},{key:"publishByTransceiver",value:function(e){var t=this,n=e.localAudioTrack,r=e.localVideoTrack,i=e.smallTrack,o=e.isAuxiliary;if(HK()){this._log.info("publish by transceiver");var a=null==r?void 0:r.outMediaTrack,s=null==n?void 0:n.outMediaTrack,c=this._peerConnection.getTransceivers(),u=[],l=[],d=function(e,n,r){var i,o,a=c[n].sender.replaceTrack(r);l.push(n),null!=(i=t.singlePC)&&i.enableInsertableStreams&&a.then((function(){return t.createEncodedStreams(c[n].sender,e)})),null!=(o=t.singlePC)&&o.scriptTransformWorker&&t.initSenderTransfrom(c[n].sender,e),u.push(a)};s&&d(n.mediaType,0,s),a&&d(r.mediaType,o?3:1,a),i&&d(8,2,i);var h=this.singlePC.setTransceiverDirection(FB.SENDONLY,l);return u.push(h),Promise.all(u)}}},{key:"getTrackByMediaType",value:function(e){switch(e){case 1:return this.localMainAudioTrack||this._publishingLocalAudioTrack;case 4:case 8:return this.localMainVideoTrack||this._publishingLocalVideoTrack;case 2:return this.localAuxVideoTrack||this._publishingLocalVideoTrack;default:return null}}},{key:"createEncodedStreams",value:function(e,t){var n,r,i=this;if(!this.singlePC.insertableStreamsAbortMap.has(e)){var o=e.createEncodedStreams(),a=new AbortController;null==(n=this.singlePC)||n.addAbortController(e,a),(null!=(r=this.getTrackByMediaType(t))&&r.enableEncodeFrame?o.readable.pipeThrough(new TransformStream({transform:function(e,n){var r,o=i.getTrackByMediaType(t);n.enqueue(null!=(r=i.singlePC)&&r.isUsingH264&&o?o.encodeFrame(e,8===t):e)}}),a):o.readable).pipeTo(o.writable,a).catch((function(e){i._log.debug("encoded stream error",e),"destory"!==e&&i._log.warn(e)}))}}},{key:"initSenderTransfrom",value:function(e,t){if(this._peerConnection&&this.singlePC&&this.singlePC.scriptTransformWorker){var n=2!==t,r=8===t;e.transform||(e.transform=new RTCRtpScriptTransform(this.singlePC.scriptTransformWorker,{isReceiver:!1,isAudio:1===t,isMain:n,isSmall:r}))}}},{key:"enableSmall",value:function(e){return HF(this,null,p().mark((function t(){var n,r,i;return p().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this.singlePC){t.next=2;break}return t.abrupt("return");case 2:if(r=this._peerConnection.getTransceivers(),!e){t.next=13;break}if(!this._room.videoManager.smallTrack){t.next=11;break}return i=r[2].sender,null!=(n=this.singlePC)&&n.enableInsertableStreams&&this.createEncodedStreams(i,8),t.next=9,i.replaceTrack(this._room.videoManager.smallTrack);case 9:return t.next=11,this.singlePC.setTransceiverDirection(FB.SENDONLY,[2]);case 11:t.next=17;break;case 13:return t.next=15,r[2].sender.replaceTrack(null);case 15:return t.next=17,this.singlePC.setTransceiverDirection(FB.INACTIVE,[2]);case 17:return this.updateMediaSettings(),t.next=20,this.doPublishChange();case 20:case"end":return t.stop()}}),t,this)})))}},{key:"installTrackMuteEvents",value:function(){for(var e=this,t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];n.forEach((function(t){t&&(null==t||t.on("mute",e.sendMutedFlag,e),null==t||t.on("unmute",e.sendMutedFlag,e))}))}},{key:"uninstallTrackMuteEvents",value:function(){for(var e=this,t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];n.forEach((function(t){t&&(null==t||t.off("mute",e.sendMutedFlag,e),null==t||t.off("unmute",e.sendMutedFlag,e))}))}},{key:"unpublish",value:function(e){return HF(this,arguments,(function(e){var t=this,n=e.localAudioTrack,r=e.localVideoTrack;return p().mark((function e(){var i,o,a,s;return p().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(i=r&&r===t.localAuxVideoTrack,o=null==r?void 0:r.outMediaTrack,a=t._peerConnection.getSenders(),s=[],e.t0=n,!e.t0){e.next=9;break}if(i?t.localAuxAudioTrack=null:t.localMainAudioTrack=null,e.t1=!t.localMainAudioTrack&&!t.localAuxAudioTrack,!e.t1){e.next=9;break}return e.next=8,a[0].replaceTrack(null);case 8:s.push(0);case 9:if(e.t2=o,!e.t2){e.next=26;break}if(!i){e.next=19;break}return e.next=14,a[3].replaceTrack(null);case 14:t.localAuxVideoTrack=null,t._mediaSettings=OF(xF({},t._mediaSettings),{auxVideoBps:0,auxVideoFps:0,auxVideoWidth:0,auxVideoHeight:0}),s.push(3),e.next=26;break;case 19:return e.next=21,a[1].replaceTrack(null);case 21:return e.next=23,a[2].replaceTrack(null);case 23:t.localMainVideoTrack=null,t._mediaSettings=OF(xF({},t._mediaSettings),{videoWidth:0,videoHeight:0,videoBps:0,videoFps:0,audioFs:0,audioChannel:0,audioBps:0,smallVideoWidth:0,smallVideoHeight:0,smallVideoFps:0,smallVideoBps:0}),s.push(1,2);case 26:if(!t.isMainStreamPublished&&!t.isAuxStreamPublished){e.next=33;break}return e.next=29,t.singlePC.setTransceiverDirection(FB.INACTIVE,s);case 29:return e.next=31,t.doPublishChange(!1);case 31:e.next=35;break;case 33:return e.next=35,t.doUnpublish();case 35:t.uninstallTrackMuteEvents(n,r),null==r||r.emit("connection-state-changed",{prevState:t._currentState,state:"DISCONNECTED"});case 37:case"end":return e.stop()}}),e)}))()}))}},{key:"doPublishChange",value:function(){var e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];return HF(this,null,p().mark((function t(){var n,r;return p().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n={state:this.publishingState,constraintConfig:this._mediaSettings},t.next=3,this._signalChannel.sendWaitForResponseWithRetry({command:e1,data:n,responseCommand:z0.PUBLISH_STATE_CHANGE_RESULT,enableLog:e,retries:3});case 3:r=t.sent,this.checkPublishResultCode(r.data.code,r.data.message);case 5:case"end":return t.stop()}}),t,this)})))}},{key:"doUnpublish",value:function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return this._signalChannel.sendWaitForResponse({command:t1,commandDesc:"unpublish",responseCommand:z0.UNPUBLISH_RESULT,enableLog:e}).catch((function(e){if(e.getCode()===ZF.API_CALL_TIMEOUT)return Promise.resolve();throw e}))}},{key:"updateMediaSettings",value:function(){var e;this._mediaSettings.videoCodec=(null==(e=this.singlePC)?void 0:e.videoCodec)||"h264";var t=this._publishingLocalAudioTrack||this.localMainAudioTrack||this.localAuxAudioTrack,n=this.localMainVideoTrack,r=this.localAuxVideoTrack;if(this._publishingLocalVideoTrack&&(this._isPublishingAux?r=this._publishingLocalVideoTrack:n=this._publishingLocalVideoTrack),qK){if(t&&t.outMediaTrack){var i=t.outMediaTrack.getSettings();this._mediaSettings.audioChannel=i.channelCount||1,this._mediaSettings.audioBps=1e3*t.profile.bitrate,this._mediaSettings.audioFs=i.sampleRate||0}if(n&&n.outMediaTrack){var o=n.outMediaTrack.getSettings(),a=n.scaleResolutionDownBy;this._mediaSettings.videoWidth=o.width/a||0,this._mediaSettings.videoHeight=o.height/a||0,this._mediaSettings.videoFps=o.frameRate||0,this._mediaSettings.videoBps=1e3*n.profile.bitrate,n.small&&(this._mediaSettings.smallVideoWidth=n.small.width,this._mediaSettings.smallVideoHeight=n.small.height,this._mediaSettings.smallVideoFps=n.small.frameRate,this._mediaSettings.smallVideoBps=1e3*n.small.bitrate)}if(r&&r.outMediaTrack){var s=r.outMediaTrack.getSettings(),c=r.scaleResolutionDownBy;this._mediaSettings.auxVideoWidth=s.width/c||0,this._mediaSettings.auxVideoHeight=s.height/c||0,this._mediaSettings.auxVideoFps=s.frameRate||0,this._mediaSettings.auxVideoBps=1e3*r.profile.bitrate}}else t&&t.outMediaTrack&&(this._mediaSettings.audioChannel=t.profile.channelCount,this._mediaSettings.audioBps=1e3*t.profile.bitrate,this._mediaSettings.audioFs=t.profile.sampleRate),n&&n.outMediaTrack&&(this._mediaSettings.videoWidth=n.profile.width,this._mediaSettings.videoHeight=n.profile.height,this._mediaSettings.videoFps=n.profile.frameRate,this._mediaSettings.videoBps=1e3*n.profile.bitrate);this._log.info("updateMediaSettings: ".concat(JSON.stringify(this._mediaSettings)))}},{key:"sendMediaSettings",value:function(){var e=this;this.updateMediaSettings(),this._signalChannel.sendWaitForResponse({command:v1,data:this._mediaSettings,responseCommand:z0.UPDATE_CONSTRAINT_CONFIG_RES}).then((function(t){0!==t.data.code&&e._log.warn(t.data.message)})).catch((function(){}))}},{key:"addTrack",value:function(e){return HF(this,null,p().mark((function t(){var n;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(n=e===this.localAuxAudioTrack||e===this.localAuxVideoTrack,this._log.info("is adding ".concat(e.kind," track to current published local ").concat(n?UB.AUXILIARY:UB.MAIN," stream")),t.t0=BK(),!t.t0){t.next=8;break}return t.next=8,this.addTrackByTransceiver(e,n);case 8:case"end":return t.stop()}}),t,this)})))}},{key:"addTrackByTransceiver",value:function(e,t){return HF(this,null,p().mark((function n(){var r,i,o;return p().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(e.mediaTrack){n.next=2;break}return n.abrupt("return");case 2:if(i=this._peerConnection.getTransceivers(),e.kind!==UB.AUDIO){n.next=8;break}return n.next=6,i[0].sender.replaceTrack(e.outMediaTrack);case 6:n.next=19;break;case 8:return o=t?3:1,n.next=11,i[o].sender.replaceTrack(e.outMediaTrack);case 11:if(n.t0=1===o&&null!=(r=this.localMainVideoTrack)&&r.small,!n.t0){n.next=15;break}return n.next=15,i[2].sender.replaceTrack(this._room.videoManager.smallTrack);case 15:if(n.t1=i[o].direction===FB.INACTIVE,!n.t1){n.next=19;break}return n.next=19,this.singlePC.setTransceiverDirection(FB.SENDONLY,[o]);case 19:return this.updateMediaSettings(),n.next=22,this.doPublishChange();case 22:case"end":return n.stop()}}),n,this)})))}},{key:"removeTrack",value:function(e){return HF(this,null,p().mark((function t(){var n;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(n=e===this.localAuxAudioTrack||e===this.localAuxVideoTrack,this._log.info("is removing ".concat(e.kind," track from current published local ").concat(n?UB.AUXILIARY:UB.MAIN," stream")),t.t0=BK(),!t.t0){t.next=8;break}return t.next=8,this.removeTrackByTransceiver(e,n);case 8:case"end":return t.stop()}}),t,this)})))}},{key:"removeTrackByTransceiver",value:function(e,t){return HF(this,null,p().mark((function n(){var r,i;return p().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(e.mediaTrack){n.next=2;break}return n.abrupt("return");case 2:if(r=this._peerConnection.getTransceivers(),e.kind!==UB.AUDIO){n.next=8;break}return n.next=6,r[0].sender.replaceTrack(null);case 6:n.next=17;break;case 8:return i=t?3:1,n.next=11,r[i].sender.replaceTrack(null);case 11:if(n.t0=1===i&&this._room.videoManager.hasSmall,!n.t0){n.next=15;break}return n.next=15,r[2].sender.replaceTrack(null);case 15:return n.next=17,this.singlePC.setTransceiverDirection(FB.INACTIVE,[i]);case 17:return this.updateMediaSettings(),n.next=20,this.doPublishChange();case 20:case"end":return n.stop()}}),n,this)})))}},{key:"replaceTrack",value:function(e){return HF(this,null,p().mark((function t(){var n,r,i,o;return p().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(r=null==(n=this._peerConnection)?void 0:n.getSenders(),i=e.outMediaTrack||e.mediaTrack,r&&0!==r.length&&i&&!r.find((function(e){return e.track===i}))){t.next=3;break}return t.abrupt("return",!1);case 3:if(o=e===this.localAuxAudioTrack||e===this.localAuxVideoTrack,this._log.info("is replacing ".concat(i.kind," track ").concat(i.id," ").concat(i.label," on ").concat(o?UB.AUXILIARY:UB.MAIN," stream")),t.t0=i.kind===UB.AUDIO&&r[0],!t.t0){t.next=9;break}return t.next=9,r[0].replaceTrack(i);case 9:if(t.t1=i.kind===UB.VIDEO,!t.t1){t.next=19;break}if(t.t2=!o&&r[1],!t.t2){t.next=15;break}return t.next=15,r[1].replaceTrack(i);case 15:if(t.t3=o&&r[3],!t.t3){t.next=19;break}return t.next=19,r[3].replaceTrack(i);case 19:return t.abrupt("return",!0);case 20:case"end":return t.stop()}}),t,this)})))}},{key:"setBandwidth",value:function(e){return HF(this,arguments,(function(e){var t=this,n=e.bandwidth,r=e.type,i=e.videoType;return p().mark((function e(){var o;return p().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!t.singlePC){e.next=5;break}return o={},r===UB.AUDIO?o.audio=n:"big"===i?o.bigVideo=n:"small"===i?o.smallVideo=n:o.auxVideo=n,e.next=5,t.singlePC.setBandwidth(o);case 5:case"end":return e.stop()}}),e)}))()}))}},{key:"sendMutedFlag",value:function(e){e===this.localAuxAudioTrack||e===this.localAuxVideoTrack||(this._log.info("send muted state: ".concat(JSON.stringify(this.muteState))),this._signalChannel.sendWaitForResponseWithRetry({command:$0,responseCommand:z0.MUTE_RESULT,data:this.muteState,retries:3}).catch((function(){})))}},{key:"handleConnectionStateChange",value:function(e){"CONNECTED"===e.state&&(this.localMainVideoTrack||this._publishingLocalVideoTrack&&!this._isPublishingAux)&&HW.emit(GW.SEND_FIRST_VIDEO_FRAME,{room:this._room})}},{key:"getVideoTrackId",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:UB.VIDEO;if(this._peerConnection){var t=this._peerConnection.getSenders();if(e===UB.AUXILIARY&&t[3]&&t[3].track)return t[3].track.id;if(e===UB.VIDEO&&t[1]&&t[1].track)return t[1].track.id}if(this.localMainVideoTrack&&e===UB.VIDEO){var n=this.localMainVideoTrack.mediaTrack;if(n)return n.id}if(this.localAuxVideoTrack&&e===UB.AUXILIARY){var r=this.localAuxVideoTrack.mediaTrack;if(r)return r.id}return""}},{key:"getSSRC",value:function(){return this.ssrc}},{key:"checkPublishResultCode",value:function(e,t){if(0!==e)throw e===EH?(this._log.error(eK.NOT_SUPPORTED_H264ENCODE),new tB({code:ZF.NOT_SUPPORTED_H264,message:rK({key:ZJ.NOT_SUPPORTED_H264ENCODE})})):new tB({code:ZF.UNKNOWN,message:rK({key:ZJ.SIGNAL_RESPONSE_FAILED,data:{signalResponse:z0.PUBLISH_RESULT,code:e,message:t}})})}},{key:"onSinglePCReconnected",value:function(){return HF(this,null,p().mark((function e(){return p().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(e.t0=this.isMainStreamPublished,!e.t0){e.next=5;break}return this._log.warn("republish main stream"),e.next=5,this.publish({localAudioTrack:this.localMainAudioTrack,localVideoTrack:this.localMainVideoTrack,isAuxiliary:!1});case 5:if(e.t1=this.isAuxStreamPublished,!e.t1){e.next=10;break}return this._log.warn("republish aux stream"),e.next=10,this.publish({localAudioTrack:this.localAuxAudioTrack,localVideoTrack:this.localAuxVideoTrack,isAuxiliary:!0});case 10:case"end":return e.stop()}}),e,this)})))}}])}(j2);UF([tY((function(e){var t=e.localVideoTrack;null==t||t.once("6",this.onVideoEncodeFailed,this)}))],G2.prototype,"publish",1),UF([tY((function(e){var t=e.localVideoTrack;null==t||t.off("6",this.onVideoEncodeFailed,this)}))],G2.prototype,"unpublish",1);var W2=G2;function J2(e){return Object.keys(e).filter((function(t){return e[t]}))}var K2=function(e){function t(e){var n;return i(this,t),n=r(this,t,[OF(xF({},e),{isUplink:!1})]),FF(n,"_flag",0),FF(n,"isRobot",!1),FF(n,"role","anchor"),FF(n,"remoteAudioTrack"),FF(n,"remoteVideoTrack"),FF(n,"remoteAuxiliaryTrack"),FF(n,"ssrc",{audio:0,video:0,videoRtx:0,auxiliary:0,auxiliaryRtx:0}),FF(n,"jitterBufferTimeoutId",-1),n.flag=e.flag,n.isRobot=e.isRobot||!1,n.remoteAudioTrack=new g$(n._room,n),n.remoteVideoTrack=new L$(n._room,n),n.remoteAuxiliaryTrack=new V$(n._room,n),n.initialize(),n}return d(t,e),s(t,[{key:"videoCodec",get:function(){var e;return(null==(e=this.singlePC)?void 0:e.downlinkVideoCodec)||"h264"}},{key:"subscribeState",get:function(){return{audio:this.remoteAudioTrack.isSubscribed||this.remoteAudioTrack.isSubscribing,video:this.remoteVideoTrack.isBig&&(this.remoteVideoTrack.isSubscribed||this.remoteVideoTrack.isSubscribing),smallVideo:this.remoteVideoTrack.isSmall&&(this.remoteVideoTrack.isSubscribed||this.remoteVideoTrack.isSubscribing),auxiliary:this.remoteAuxiliaryTrack.isSubscribed||this.remoteAuxiliaryTrack.isSubscribing}}},{key:"muteState",get:function(){return Ij(this.flag,this.userId)}},{key:"flag",get:function(){return this._flag},set:function(e){var t,n,r;e!==this._flag&&(this._flag=e,null==(t=this.remoteAudioTrack)||t.onFlagChanged(),null==(n=this.remoteVideoTrack)||n.onFlagChanged(),null==(r=this.remoteAuxiliaryTrack)||r.onFlagChanged())}},{key:"hasMainStream",get:function(){return this.muteState.hasAudio||this.muteState.hasVideo||this.muteState.hasSmall}},{key:"hasAuxStream",get:function(){return this.muteState.hasAuxiliary}},{key:"isMainStreamSubscribed",get:function(){return(this.subscribeState.audio||this.subscribeState.video||this.subscribeState.smallVideo)&&(this.muteState.hasAudio||this.muteState.hasVideo||this.muteState.hasSmall)}},{key:"isAuxStreamSubscribed",get:function(){return this.subscribeState.auxiliary&&this.muteState.hasAuxiliary}},{key:"isSmallStreamSubscribed",get:function(){return this.subscribeState.smallVideo&&this.muteState.hasSmall}},{key:"isBigStreamSubscribed",get:function(){return this.subscribeState.video&&this.muteState.hasVideo}},{key:"isStreamUnpublished",value:function(e){return e===UB.MAIN?!this.muteState.hasAudio&&!this.muteState.hasVideo:!this.muteState.hasAuxiliary}},{key:"initialize",value:function(){this.installEvents()}},{key:"close",value:function(e){clearTimeout(this.jitterBufferTimeoutId),y(t,"close",this,3)([e]),this.emitConnectionStateChangedEvent("DISCONNECTED"),this.remoteAudioTrack.close(),this.remoteVideoTrack.close(),this.remoteAuxiliaryTrack.close(),this.uninstallEvents(),this.removeDownlink()}},{key:"installEvents",value:function(){this.singlePC&&(this.listeners("track").includes(this.onTrack)||this.singlePC.on("track",this.onTrack,this),this.listeners("spc-reconnected").includes(this.onSinglePCReconnected)||this.singlePC.on("spc-reconnected",this.onSinglePCReconnected,this))}},{key:"uninstallEvents",value:function(){this.singlePC&&(this.singlePC.off("track",this.onTrack,this),this.singlePC.off("spc-reconnected",this.onSinglePCReconnected,this))}},{key:"emitConnectionStateChangedEvent",value:function(e){var n,r,i=this._currentState,o=y(t,"emitConnectionStateChangedEvent",this,3)([e]);return o&&i!==e&&(null==(n=this.remoteVideoTrack)||n.emit("connection-state-changed",{prevState:i,state:e}),null==(r=this.remoteAuxiliaryTrack)||r.emit("connection-state-changed",{prevState:i,state:e})),o}},{key:"onTrack",value:function(e){var t,n,r=e.streams[0],i=e.track,o=e.receiver;if(r.id.includes(this.tinyId)){var a=r.id.includes("aux")?"auxiliary":"main";this._log.debug("ontrack ".concat(a," ").concat(i.kind));var s=UB.AUDIO;i.kind===UB.VIDEO&&(s=a===UB.MAIN?UB.VIDEO:UB.AUXILIARY);var c=this.remoteAudioTrack;s===UB.VIDEO?c=this.remoteVideoTrack:s===UB.AUXILIARY&&(c=this.remoteAuxiliaryTrack),null==(t=this.singlePC)||t.receiverRemoteTrackMap.set(o,c),null!=(n=this.singlePC)&&n.scriptTransformWorker&&this.initReceiverTransform(o,a,i.kind===UB.AUDIO),this.singlePC.enableInsertableStreams&&this.createEncodedStreams(o),c.setInputMediaStreamTrack(i)}}},{key:"createEncodedStreams",value:function(e){var t=this;if(!this.singlePC.insertableStreamsAbortMap.has(e)){var n=e.createEncodedStreams(),r=new AbortController,i={abortController:r,enqueue:function(n){var r,i,o=null==(r=t.singlePC)?void 0:r.receiverRemoteTrackMap.get(e);return o&&("video"!==o.kind||null!=(i=t.singlePC)&&i.isUsingH264)?o.decodeFrame(n):n}};n.readable.pipeThrough(new TransformStream({transform:function(e,t){var n=i.enqueue(e);n&&t.enqueue(n)}})).pipeTo(n.writable,r).catch((function(e){"destory"!==e&&t._log.warn(e)})),this.singlePC.addAbortController(e,r)}}},{key:"initReceiverTransform",value:function(e,t,n){!this._peerConnection||!this.singlePC||!this.singlePC.scriptTransformWorker||e.transform||(e.transform=new RTCRtpScriptTransform(this.singlePC.scriptTransformWorker,{isReceiver:!0,isAudio:n,userId:this.userId,streamType:t}))}},{key:"subscribe",value:function(e,t){return HF(this,null,p().mark((function n(){var r;return p().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(n.prev=0,this._log.info("subscribe ".concat(t," ").concat(J2(e))),!this.hasSSRC){n.next=8;break}return r="subscribe_change",Object.values(e).find((function(e){return!0===e}))||(r="unsubscribe"),n.next=6,this.sendSubscription(r,e);case 6:n.next=11;break;case 8:return n.next=10,this.doSubscribe(e);case 10:this.checkTrackEnded(e);case 11:n.next=16;break;case 13:throw n.prev=13,n.t0=n.catch(0),this._room.isJoined&&this.isStreamUnpublished(t)?(this._log.warn("".concat(n.t0.message," ").concat(JSON.stringify(this.muteState))),new tB({code:ZF.REMOTE_STREAM_NOT_EXIST,message:"remote user ".concat(this.userId," unpublished stream")})):n.t0;case 16:case"end":return n.stop()}}),n,this,[[0,13]])})))}},{key:"checkTrackEnded",value:function(e){var t,n,r;if((e.audio&&"ended"===(null==(t=this.remoteAudioTrack.mediaTrack)?void 0:t.readyState)||e.video&&"ended"===(null==(n=this.remoteVideoTrack.mediaTrack)?void 0:n.readyState)||e.auxiliary&&"ended"===(null==(r=this.remoteAuxiliaryTrack.mediaTrack)?void 0:r.readState))&&this.singlePC&&!this.singlePC.isReconnecting){if(this._log.warn("remote track ended start spc reconnect"),dW&&pW<92)return;this.singlePC.startReconnection()}}},{key:"unsubscribe",value:function(e){return HF(this,arguments,(function(e){var t=this,n=e.remoteTracks,r=e.streamType;return p().mark((function e(){var i,o,a;return p().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(("main"!==r||t.isMainStreamSubscribed)&&("auxiliary"!==r||t.isAuxStreamSubscribed)){e.next=3;break}return t._log.info("".concat(r," stream already unsubscribed")),e.abrupt("return");case 3:return o=xF({},t.subscribeState),n.forEach((function(e){switch(e.mediaType){case 1:o.audio=!1;break;case 4:o.video=!1;break;case 8:o.smallVideo=!1;break;case 2:o.auxiliary=!1}})),a="subscribe_change",Object.values(o).find((function(e){return!0===e}))||(a="unsubscribe"),t._log.info("".concat("unsubscribe"===a?a:"subscribe"," ").concat(r," [").concat(J2(o),"]")),"unsubscribe"===a&&(null==(i=t.singlePC)||i.removeDownlinkQueue.add(t.tinyId)),e.next=11,t.sendSubscription(a,o);case 11:if(e.t0="unsubscribe"===a,!e.t0){e.next=15;break}return e.next=15,t.removeDownlink();case 15:case"end":return e.stop()}}),e)}))()}))}},{key:"sendSubscription",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.subscribeState,r={srcTinyId:this.tinyId,srcUserId:this.userId},i=r1,o=z0.UNSUBSCRIBE_RESULT;return"subscribe_change"===e&&(r={audio:n.audio,bigVideo:n.video,auxVideo:n.auxiliary,smallVideo:n.smallVideo,srcTinyId:this.tinyId},i=i1,o=z0.SUBSCRIBE_CHANGE_RESULT),this._signalChannel.sendWaitForResponseWithRetry({command:i,data:r,responseCommand:o,timeout:1e4,retries:3}).then((function(n){var r=n.data;if(0!==r.code){var i=new tB({code:r.code,message:rK({key:ZJ.ERROR_MESSAGE,data:{type:e,message:r.message}})});throw t._log.error(i),i}}))}},{key:"getMainStreamVideoTrackId",value:function(){return this.remoteVideoTrack&&this.remoteVideoTrack.mediaTrack?this.remoteVideoTrack.mediaTrack.id:""}},{key:"getAuxStreamVideoTrackId",value:function(){return this.remoteAuxiliaryTrack&&this.remoteAuxiliaryTrack.mediaTrack?this.remoteAuxiliaryTrack.mediaTrack.id:""}},{key:"setDelay",value:function(e){var t=e.audioDelay,n=e.videoDelay;this.remoteAudioTrack.stat.end2EndDelay=t,this.remoteVideoTrack.stat.end2EndDelay=n}},{key:"onSinglePCReconnected",value:function(){return HF(this,null,p().mark((function e(){return p().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(e.t0=this.ssrc.audio||this.ssrc.video||this.ssrc.auxiliary,!e.t0){e.next=8;break}return this._log.warn("resubscribe ".concat(JSON.stringify(this.subscribeState))),e.next=5,this.doSubscribe(this.subscribeState);case 5:this.remoteAudioTrack.checkDecodeResult(),this.remoteVideoTrack.checkDecodeResult(),this.remoteAuxiliaryTrack.checkDecodeResult();case 8:case"end":return e.stop()}}),e,this)})))}},{key:"hasSSRC",get:function(){return this.ssrc.audio&&this.ssrc.video&&this.ssrc.auxiliary}},{key:"doSubscribe",value:function(){return HF(this,arguments,(function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.subscribeState,n=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];return p().mark((function r(){var i,o,a,s,c,u,l,d,h,f,m,v,_,g,y;return p().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if(!e.singlePC){r.next=34;break}return e.singlePC.addDownlinkQueue.add(e.tinyId),r.next=4,e.singlePC.waitForPeerConnectionConnected();case 4:if(r.prev=4,!n&&e.hasSSRC){r.next=25;break}return i={audioSsrc:H2(),bigVideoSsrc:H2(),bigVideoRtxSsrc:H2(),auxVideoSsrc:H2(),auxVideoRtxSsrc:H2()},o=i.audioSsrc,a=i.bigVideoSsrc,s=i.bigVideoRtxSsrc,c=i.auxVideoSsrc,u=i.auxVideoRtxSsrc,e.ssrc={audio:o,video:a,videoRtx:s,auxiliary:c,auxiliaryRtx:u},e.singlePC.addDownlinkQueue.delete(e.tinyId),r.next=11,e.singlePC.addDownlink({userId:e.userId,tinyId:e.tinyId,ssrc:e.ssrc});case 11:return r.prev=11,r.next=14,e._signalChannel.sendWaitForResponseWithRetry({command:E1,responseCommand:z0.SPC_SUBSCRIBE_RESULT,data:{srcUserId:e.userId,srcTinyId:e.tinyId,audio:t.audio,bigVideo:t.video,auxVideo:t.auxiliary,smallVideo:t.smallVideo,customData:!1,ssrc:i},retries:3,retryTimeout:0});case 14:if(0===(l=r.sent).data.code){r.next=17;break}throw new tB({code:l.data.code,message:l.data.message});case 17:r.next=24;break;case 19:return r.prev=19,r.t0=r.catch(11),r.next=23,e.removeDownlink();case 23:throw r.t0;case 24:return r.abrupt("return");case 25:return e.singlePC.addDownlinkQueue.delete(e.tinyId),r.next=28,e.singlePC.addDownlink({userId:e.userId,tinyId:e.tinyId,ssrc:e.ssrc});case 28:if(r.prev=28,cz){r.next=31;break}return r.abrupt("return");case 31:return d=e._room.jitterBufferDelay||{},h=d.main,f=d.aux,m=e._room.scheduleResult.config||{},v=m.jitterDelay,_=void 0===v?h:v,g=m.jitterDelayAux,y=void 0===g?f:g,(cj(_)||cj(y))&&e.setJitterBufferDelay({mainDelay:_,auxDelay:y}),r.finish(28);case 34:case"end":return r.stop()}}),r,null,[[4,,28,34],[11,19]])}))()}))}},{key:"removeDownlink",value:function(){return HF(this,null,p().mark((function e(){var t;return p().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.singlePC){e.next=2;break}return e.abrupt("return");case 2:return this.ssrc={audio:0,video:0,videoRtx:0,auxiliary:0,auxiliaryRtx:0},this.singlePC.removeDownlinkQueue.delete(this.tinyId),(null!=(t=this._room.scheduleResult.config)&&t.jitterDelay||null!=t&&t.jitterDelayAux)&&this.setJitterBufferDelay({mainDelay:0,auxDelay:0}),e.next=7,this.singlePC.removeDownlink(this.userId);case 7:case"end":return e.stop()}}),e,this)})))}},{key:"setJitterBufferDelay",value:function(e){var t=this,n=e.mainDelay,r=e.auxDelay;if(!cz||!this.singlePC||!this._peerConnection||Jj(n)&&Jj(r))return Promise.resolve();this._log.info("set jitterBuffer main: ".concat(n," aux: ").concat(r));var i=this.singlePC.getReceiversByUserId(this.userId);return cj(n)&&(this.remoteAudioTrack.jitterBufferDelay=n,this.remoteVideoTrack.jitterBufferDelay=n),cj(r)&&(this.remoteAuxiliaryTrack.jitterBufferDelay=r,Jj(n)&&(this.remoteAudioTrack.jitterBufferDelay=r)),new Promise((function(e){t.doSetJitterBufferDelay({mainDelay:n,auxDelay:r,receivers:i,resolve:e})}))}},{key:"doSetJitterBufferDelay",value:function(e){var t=this,n=e.mainDelay,r=e.auxDelay,i=e.receivers,o=e.resolve;try{if(0===n&&0===r)return i.forEach((function(e){return e.jitterBufferTarget=0})),o();if(i.forEach((function(e){var i,o=e.track===t.remoteAuxiliaryTrack.outMediaTrack||Jj(n)&&e.track===t.remoteAudioTrack.outMediaTrack;if(!(o&&Jj(r)||!o&&Jj(n))){var a=o?r||0:n,s=(e.jitterBufferTarget||0)+100;s>a||(e.jitterBufferTarget=s,t._log.debug("set ".concat(o?"aux ":"").concat(null==(i=null==e?void 0:e.track)?void 0:i.kind," jitterBuffer delay ").concat(s," -> ").concat(a)))}})),!i.find((function(e){var i=e.track===t.remoteAuxiliaryTrack.outMediaTrack?r||0:n;return e.jitterBufferTarget<i})))return this._log.info("set jitterBuffer main: ".concat(n," aux: ").concat(r," done")),o();this.jitterBufferTimeoutId=setTimeout((function(){t.doSetJitterBufferDelay({mainDelay:n,auxDelay:r,receivers:i,resolve:o})}),1e3)}catch(hB){this._log.warn("set jitterBuffer delay error: ".concat(hB)),clearTimeout(this.jitterBufferTimeoutId),o()}}},{key:"audioReceiver",get:function(){var e;return(null==(e=this.singlePC)?void 0:e.getReceiversByUserId(this.userId)[0])||null}}])}(j2);UF([uY(),rY((function(e){return function(){for(var t=this,n=arguments.length,r=new Array(n),i=0;i<n;i++)r[i]=arguments[i];return new Promise((function(n,i){var o=function(e){t.off("closed",o),i(new tB({code:ZF.API_CALL_ABORTED,message:rK({key:ZJ.CONNECTION_ABORTED,data:e})}))};t.on("closed",o),e.apply(t,r).then(n,i).finally((function(){t.off("closed",o)}))}))}}))],K2.prototype,"subscribe",1),UF([uY()],K2.prototype,"unsubscribe",1),UF([dY((function(){return"jitter"}))],K2.prototype,"setJitterBufferDelay",1);var z2=K2;var q2=function(e){function t(e,n){var o;return i(this,t),(o=r(this,t)).room=e,o.signalChannel=n,FF(o,"log"),FF(o,"cmdIdSeqMap",new Map),FF(o,"messageMap",new Map),o.log=qW.createLogger({id:"cmm",userId:e.userId}),o.onReceiveMsg=o.onReceiveMsg.bind(o),n.on(z0.RECEIVE_CUSTOM_MSG,o.onReceiveMsg),o.room.on("peer-leave",(function(e){T(o.messageMap.keys()).forEach((function(t){t.split("_").slice(0,-1).join("_")===e&&o.messageMap.delete(t)}))})),o}return d(t,e),s(t,[{key:"send",value:function(e){var t=e.cmdId,n=e.data,r=this.cmdIdSeqMap.get(t)||Math.floor(16383*Math.random()),i={cmdId:t,msg:btoa(String.fromCharCode.apply(String,T(new Uint8Array(n)))),ordered:!0,reliable:!0,streamSeq:r};this.cmdIdSeqMap.set(t,r+1),this.signalChannel.send(S1,i),this.log.debug("send custom msg: ".concat(JSON.stringify(i)))}},{key:"onReceiveMsg",value:function(e){var n=this,r=e.data.data,i=this.room.tinyIdToUserIdMap.get(r.srcTinyId);if(i){var o={userId:i,cmdId:r.cmdId,seq:r.streamSeq,data:Uint8Array.from(atob(r.msg),(function(e){return e.charCodeAt(0)})).buffer};if(r.ordered){var a="".concat(i,"_").concat(o.cmdId),s=this.messageMap.get(a);if(s&&0!==s.lastSeq)if(Math.abs(s.lastSeq-o.seq)>t.SEQ_INTERVAL)this.messageMap.set(a,{lastSeq:o.seq,cachedMessageMap:new Map}),this.emitMessage(o);else if(o.seq>s.lastSeq){if(o.seq===s.lastSeq+1)this.emitMessage(o);else if(!s.cachedMessageMap.has(o.seq)){var c=setTimeout((function(){return n.emitMessage(o,!0)}),5e3);s.cachedMessageMap.set(o.seq,{message:o,timeoutId:c})}}else this.log.debug("drop message ".concat(o.userId,"-").concat(o.cmdId,"-").concat(o.seq));else s||(s={lastSeq:0,cachedMessageMap:new Map},this.messageMap.set(a,s),setTimeout((function(){return n.emitMessage(o,!0)}),100)),s.cachedMessageMap.set(o.seq,{message:o})}else this.emit("message",o)}else{this.log.warn("receive msg from unknown user, wait peer-join tinyId: ".concat(r.srcTinyId));var u=function(t){t.tinyId===r.srcTinyId&&(n.room.off("peer-join",u),n.onReceiveMsg(e))};this.room.on("peer-join",u),Fj(2e3).then((function(){return n.room.off("peer-join",u)}))}}},{key:"emitMessage",value:function(e){var t,n=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r=this.messageMap.get("".concat(e.userId,"_").concat(e.cmdId)),i=e;if(r){if(n){var o=T(r.cachedMessageMap.values()).sort((function(e,t){return e.message.seq-t.message.seq}));o[0]&&(i=o[0].message)}0!==r.lastSeq&&i.seq-r.lastSeq>1&&this.log.debug("msg lost userId: ".concat(i.userId," seq: ").concat(r.lastSeq," -> ").concat(i.seq)),r.lastSeq=i.seq,clearTimeout(null==(t=r.cachedMessageMap.get(i.seq))?void 0:t.timeoutId),r.cachedMessageMap.delete(i.seq)}this.log.debug("receive custom msg: ".concat(JSON.stringify(i))),this.emit("message",i);var a=null==r?void 0:r.cachedMessageMap.get(i.seq+1);a&&this.emitMessage(a.message)}}])}(VF(jF()).EventEmitter);FF(q2,"SEQ_INTERVAL",300);var Y2=q2,X2=aB.isString,Q2=aB.isUndefined,$2=aB.getNetworkType,Z2=aB.isEmpty,e3=function(e){function t(e){var n;return i(this,t),n=r(this,t,[e]),FF(n,"_businessInfo"),FF(n,"userManager"),FF(n,"_version"),FF(n,"_heartbeat",-1),FF(n,"_lastHeartBeatTime",-1),FF(n,"_stats"),FF(n,"_joinTimeout",-1),FF(n,"_firstPublishedList",null),FF(n,"_joinReject",null),FF(n,"_isRelayChanged",!1),FF(n,"sdpSemantics"),FF(n,"signalChannel",null),FF(n,"uplinkConnection",null),FF(n,"singlePC",null),FF(n,"enableSPC",jK),FF(n,"_changeBigSmallRecords",new Map),FF(n,"networkQuality"),FF(n,"_iceTransportPolicy"),FF(n,"forceRelay",!1),FF(n,"_turnServers",[]),FF(n,"_iceServersFromJoin"),FF(n,"_syncUserListInterval",-1),FF(n,"_smallStreamConfig",{bitrate:100,frameRate:15,height:120,width:160}),FF(n,"enableSEI",!1),FF(n,"_enableAudioVolumeEvaluation",!1),FF(n,"_audioVolumeIntervalId",0),FF(n,"_enableMultiAuxStream",!1),FF(n,"_pureAudioPushMode",!1),FF(n,"_customMessageManager"),FF(n,"preferHW",!1),FF(n,"healthDetector"),FF(n,"playoutDelay"),FF(n,"jitterBufferDelay"),FF(n,"_updateAudioLevelTaskId",-1),n._stats=new W1(n,n._log),n.userManager=new H$(n.userId,n._log),n._version=uB,n.sdpSemantics=yH,Q2(e.sdpSemantics)?$W.isUnifiedPlanDefault()&&(n.sdpSemantics=gH):n.sdpSemantics=e.sdpSemantics,n._log.info("sdpSemantics: ".concat(n.sdpSemantics,", netType: ").concat($2())),e.iceTransportPolicy&&(n._iceTransportPolicy=e.iceTransportPolicy),n._enableMultiAuxStream=!Q2(e.enableMultiAuxStream)&&e.enableMultiAuxStream,n.enableSEI=e.enableSEI&&jK,!Q2(e.enableSPC)&&jK&&(n.enableSPC=e.enableSPC),n.preferHW=!!e.preferHW,n._initBusinessInfo(e),n.healthDetector=new w2(n),n}return d(t,e),s(t,[{key:"isMainStreamPublished",get:function(){var e;return!(null==(e=this.uplinkConnection)||!e.isMainStreamPublished)}},{key:"isMainAudioPublished",get:function(){var e;return!(null==(e=this.uplinkConnection)||!e.localMainAudioTrack)}},{key:"isAuxStreamPublished",get:function(){var e;return!(null==(e=this.uplinkConnection)||!e.isAuxStreamPublished)}},{key:"hasAuxStream",get:function(){return T(this.remotePublishedUserMap.values()).findIndex((function(e){return e.muteState.hasAuxiliary}))>=0}},{key:"userMap",get:function(){return this.userManager.userMap}},{key:"remotePublishedUserMap",get:function(){return this.userManager.remotePublishedUserMap}},{key:"tinyIdToUserIdMap",get:function(){return new Map(T(this.userMap.values()).map((function(e){return[e.tinyId,e.userId]})))}},{key:"join",value:function(e,t,n){return HF(this,null,p().mark((function t(){var n=this;return p().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",(this.userManager.mySelfId=this.userId,this.userManager.on("1",(function(e){n.emit("peer-join",e)})),this.userManager.on("2",(function(e){n.closeDownLinkConnection(e,"remote user exitRoom"),n.emit("peer-leave",e)})),this.userManager.on("3",this.createDownlinkConnection,this),this.userManager.on("5",this.closeDownLinkConnection,this),this.userManager.on("6",(function(e){var t=PF(e,[]);HW.emit(GW.REMOTE_PUBLISH_STATE_CHANGED,xF({room:n},t)),n.emit("remote-publish-state-changed",xF({},t))})),this.joinParams=e,new Promise((function(t,r){return HF(n,null,p().mark((function n(){var i,o,a;return p().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return this._joinReject=r,n.prev=1,this.checkDestroy(),n.prev=3,n.next=6,Promise.all([this.initialize(),this.initSinglePC()]);case 6:n.next=17;break;case 8:if(n.prev=8,n.t0=n.catch(3),!(n.t0 instanceof tB&&n.t0.code===ZF.SPC_INITIALIZED_FAILED)){n.next=16;break}return null==(i=this.signalChannel)||i.destroy(),n.next=14,this.initialize();case 14:n.next=17;break;case 16:return n.abrupt("return",r(n.t0));case 17:return a=yj(),n.next=20,this.doJoin(e,null==(o=this.singlePC)?void 0:o.clientAbility);case 20:fK.addSuccessEvent({key:521708,cost:yj()-a}),t(),this._firstPublishedList&&this.onPublishedUserList({data:{userList:this._firstPublishedList}}),n.next=28;break;case 25:n.prev=25,n.t1=n.catch(1),fK.addFailedEvent({key:521708,error:n.t1}),r(n.t1);case 28:this._joinReject=null;case 29:case"end":return n.stop()}}),n,this,[[1,25],[3,8]])})))}))));case 1:case"end":return t.stop()}}),t,this)})))}},{key:"initSinglePC",value:function(){return HF(this,null,p().mark((function e(){var t=this;return p().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.enableSPC||this.singlePC){e.next=11;break}return this.singlePC=new V2({signalChannel:this.signalChannel,room:this,enableCustomMessage:!1}),this.singlePC.on("sei-message",(function(e){return t.emit("sei-message",e)})),this.singlePC.on("dump",(function(e){return t.emit("dump",e)})),this.singlePC.once("error",(function(){return t.fallbackToMPC()})),e.prev=2,e.next=5,this.singlePC.initialize();case 5:return e.abrupt("return",e.sent);case 8:throw e.prev=8,e.t0=e.catch(2),this.fallbackToMPC(),new tB({code:ZF.SPC_INITIALIZED_FAILED,message:null==e.t0?void 0:e.t0.message});case 11:case"end":return e.stop()}}),e,this,[[2,8]])})))}},{key:"doJoin",value:function(e,t){var n=this;return new Promise((function(r,i){return HF(n,null,p().mark((function n(){var o,a,s,c,u,l=this;return p().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:e.privateMapKey&&(this.privateMapKey=e.privateMapKey),e.latencyLevel&&(this.latencyLevel=e.latencyLevel),this.signalChannel.once(G0,(function(e){l.clearJoinTimeout(),HW.emit(GW.JOIN_SIGNAL_CONNECTION_END,{room:l,error:e}),i(e)})),uj(null==(a=null==(o=this.scheduleResult)?void 0:o.config)?void 0:a.singlePC)&&jK&&(this.enableSPC=this.scheduleResult.config.singlePC),this.keyPointManager.setConnectionType(this.singlePC?1:2),t&&this.playoutDelay&&(t.playoutDelay=this.playoutDelay),c={roomId:String(e.roomId||e.strRoomId),useStringRoomId:this.useStringRoomId,privateMapKey:this.privateMapKey,latencyLevel:this.latencyLevel,trtcRole:e.role,trtcScene:"live"===this.scene?2:1,sdpSemantics:this.sdpSemantics,version:this._version,ua:navigator&&navigator.userAgent||"",terminalType:UW(),netType:zH(),bussinessInfo:this._businessInfo,ability:t,sdkType:this._sdkType,userSig:this.userSig,receiveMix:!0},this._log.debug("join room signal data: ".concat(JSON.stringify(c))),u=5e3,null!=(s=this.scheduleResult.config)&&s.enterRoomTimeout&&this.scheduleResult.config.enterRoomTimeout>=1&&(u=1e3*this.scheduleResult.config.enterRoomTimeout),this._joinTimeout=window.setTimeout((function(){i(new tB({code:ZF.JOIN_ROOM_FAILED,message:rK({key:ZJ.JOIN_ROOM_TIMEOUT})}))}),u),HW.emit(GW.JOIN_SEND_CMD,{room:this}),this.signalChannel.send(this.singlePC?g1:Y0,c),this.signalChannel.once(z0.JOIN_ROOM_RESULT,(function(t){return HF(l,null,p().mark((function n(){var o,a,s,c,u;return p().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(this.clearJoinTimeout(),o=t.data,a=o.code,s=o.message,c=o.data,u=o.tinyId,HW.emit(GW.JOIN_RECEIVED_CMD_RES,{room:this,code:a}),0!==a){n.next=19;break}if(this._log.info("Join room success, start heartbeat"),u&&(this.tinyId=u),this.startHeartbeat(),this.syncUserList(),this.startSyncUserListInterval(),this._firstPublishedList=c.publishers,this._iceServersFromJoin=c.iceServer?[c.iceServer]:[],n.t0=this.singlePC,!n.t0){n.next=16;break}return n.next=15,this.singlePC.setIceServers(this.getIceServers());case 15:this.singlePC.connect(OF(xF({},c.ability),{useVp8:c.ability.useVp8||!!e.useVp8})).catch((function(){}));case 16:r(),n.next=20;break;case 19:this._log.error("Join room failed result: ".concat(a," error: ").concat(s)),i(new tB({code:ZF.JOIN_ROOM_FAILED,extraCode:a,message:rK({key:ZJ.JOIN_ROOM_FAILED,data:{error:s,code:a}})}));case 20:case"end":return n.stop()}}),n,this)})))}));case 5:case"end":return n.stop()}}),n,this)})))}))}},{key:"reJoin",value:function(){var e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];return HF(this,null,p().mark((function t(){var n,r,i,o=this;return p().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this.isJoined){t.next=3;break}return this._log.warn("reJoin abort"),t.abrupt("return");case 3:return t.prev=3,this._log.warn("reJoin pending: ".concat(this.joinParams.roomId)),r=[],this.singlePC&&(this.singlePC.close(),this.singlePC=null,r.push(this.initSinglePC().then((function(e){return n=e,e})))),this.signalChannel&&(this.signalChannel.race=e,this.signalChannel.close(),r.push(this.signalChannel.connect())),t.next=10,Promise.all(r);case 10:return t.next=12,this.doJoin(OF(xF({},this.joinParams),{role:"anchor"===this.role?20:21,privateMapKey:this.privateMapKey,latencyLevel:this.latencyLevel}),n);case 12:if(this._log.warn("reJoin success"),Nz.logSuccessEvent({userId:this.userId,eventType:pH.REJOIN}),!this.singlePC){t.next=17;break}i=function(e){var t;"CONNECTED"===e.state&&(null==(t=o.singlePC)||t.off(x2.CONNECTION_STATE_CHANGED,i),o.uplinkConnection instanceof W2&&(o.uplinkConnection.installEvents(),o.uplinkConnection.onSinglePCReconnected()),o.remotePublishedUserMap.forEach((function(e){e.installEvents(),e.onSinglePCReconnected()})))},this.singlePC.on(x2.CONNECTION_STATE_CHANGED,i),this.checkConnectionsToReconnect(),this.uplinkConnection instanceof G1&&!this.uplinkConnection.getIsReconnecting()&&this.uplinkConnection.startReconnection();case 17:t.next=22;break;case 19:t.prev=19,t.t0=t.catch(3),this._log.warn("reJoin fail ".concat(t.t0)),this.reset(),Nz.logFailedEvent({userId:this.userId,eventType:pH.REJOIN,error:t.t0}),this.emit("error",new tB({code:ZF.JOIN_ROOM_FAILED,message:rK({key:ZJ.REJOIN_ROOM_FAILED,data:{roomId:this.joinParams.roomId}})}));case 22:case"end":return t.stop()}}),t,this,[[3,19]])})))}},{key:"initialize",value:function(){return HF(this,null,p().mark((function e(){var t,n,r,i,o,a,s=this;return p().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=this.getSignalChannelUrl(),n=t.mainUrl,r=t.backupUrl,i=this.signalChannel||b1(this.userId),o=!!(i&&i.isConnected&&i.keepAlive&&i.userId===this.userId),Array.isArray(this.scheduleResult.domains)&&this.scheduleResult.domains.length>0&&(a=this.scheduleResult.domains[0]),this._log.info("".concat(o?"reuse":"setup"," signal channel")),o?(i.url=n,i.backupUrl=r,i.room=this,this.signalChannel=i):(i&&i.close(),this.signalChannel=new A1({sdkAppId:this.sdkAppId,userId:this.userId,userSig:this.userSig,url:n,backupUrl:r,race:this.enableSPC&&!this.proxy_ws,room:this,signalDomainWhenUnifiedProxy:this.proxy_unified?a:void 0}),this._customMessageManager=new Y2(this,this.signalChannel),this._customMessageManager.on("message",(function(e){s.emit("custom-message",e)}))),this.networkQuality||(this.networkQuality=new q1({signalChannel:this.signalChannel,room:this}),this.networkQuality.on(q1.EVENT_NETWORK_QUALITY,(function(e){var t;s.emit("network-quality",e),null==(t=s.singlePC)||t.detectTCPAndUDP(e)}))),Cz(this,this.signalChannel).add(B0,(function(e){HW.emit(GW.SIGNAL_CONNECTION_STATE_CHANGED,xF({room:s},e)),s.emit("signal-connection-state-changed",e)})).add(j0,(function(e){s.reset(),s.emit("error",e)})).add(z0.PEER_JOIN,(function(e){var t=e.data.data,n=t.srcTinyId,r=t.userId,i=t.role;s.userManager.addUser({userId:r,tinyId:n,role:i})})).add(z0.PEER_LEAVE,(function(e){var t=e.data.data,n=t.userId,r=t.reason,i=void 0===r?0:r;s.userManager.deleteUser(n,i)})).add(z0.UPDATE_REMOTE_MUTE_STAT,(function(e){s._lastHeartBeatTime>0&&Date.now()-s._lastHeartBeatTime>=1e4&&s.doHeartbeat(),s.onPublishedUserList(e.data)})).add(z0.CLIENT_BANNED,(function(e){var t=e.data.data.reason;if(Nz.uploadEvent({log:"stat-banned:".concat(t),userId:s.userId}),"user_time_out"===t)return s._log.warn("".concat(t," last heart beat time: ").concat(s._lastHeartBeatTime," interval: ").concat(Date.now()-s._lastHeartBeatTime,", visibility: ").concat(document.visibilityState)),void s.reJoin();s._log["kick"===t?"error":"info"]("user was banned because of [".concat(t,"]")),s.reset(),s.emit("banned",{reason:t})})),this.signalChannel.once(F0,(function(e){s.tinyId=e.signalInfo.tinyId,HW.emit(GW.JOIN_SIGNAL_CONNECTION_END,{room:s})})),HW.emit(GW.JOIN_SIGNAL_CONNECTION_START,{room:this}),e.next=10,this.signalChannel.connect();case 10:return o&&HW.emit(GW.JOIN_SIGNAL_CONNECTION_END,{room:this}),e.abrupt("return",o);case 12:case"end":return e.stop()}}),e,this)})))}},{key:"setSignalChannel",value:function(e){this.signalChannel=e,e||wz(this)}},{key:"leave",value:function(){return HF(this,null,p().mark((function e(){var t;return p().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,this.doHeartbeat();case 3:e.next=7;break;case 5:e.prev=5,e.t0=e.catch(0);case 7:this._log.info("leave() => leaving room"),HW.emit(GW.LEAVE_SEND_CMD,{room:this}),null==(t=this.signalChannel)||t.send(X0);case 8:case"end":return e.stop()}}),e,this,[[0,5]])})))}},{key:"clearNetworkQuality",value:function(){this.networkQuality&&(this.networkQuality.stop(),delete this.networkQuality)}},{key:"closeConnections",value:function(){var e=this;this.remotePublishedUserMap.forEach((function(t){e.closeDownLinkConnection(t.userId,"you exitRoom")}))}},{key:"clearJoinTimeout",value:function(){clearTimeout(this._joinTimeout),this._joinTimeout=-1}},{key:"startHeartbeat",value:function(){-1===this._heartbeat&&(this._heartbeat=Iz.run("ric",this.doHeartbeat.bind(this),{delay:2e3}))}},{key:"stopHeartbeat",value:function(){-1!==this._heartbeat&&(this._log.info("stopHeartbeat"),Iz.clearTask(this._heartbeat),this._heartbeat=-1,this._lastHeartBeatTime=-1)}},{key:"doHeartbeat",value:function(){return HF(this,null,p().mark((function e(){var t,n,r,i,o,a;return p().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=this.badCaseDetector.getMonitorFreeze(),e.next=3,this._stats.getStatsReport({uplinkConnection:this.uplinkConnection,downlinkConnections:this.remotePublishedUserMap,freezeMap:n});case 3:r=e.sent,this.badCaseDetector.resetMonitor(),i=null!=(t=this.signalChannel)&&t.isConnected?B$(this.userId):[],o=OF(xF({str_sdk_version:cB,uint64_datetime:(new Date).getTime(),msg_user_info:{str_identifier:this.userId,uint64_tinyid:this.tinyId},msg_event_msg:i,str_acc_ip:this.getSignalInfo().relayIp,str_client_ip:this.getSignalInfo().clientIp},r),{msg_device_info:xF({uint32_terminal_type:15,str_device_name:navigator.platform,str_os_version:"",uint32_net_type:zH()},r.msg_device_info)}),this.heartbeatReport=o,HW.emit(GW.HEARTBEAT_REPORT,{room:this,report:o}),this.signalChannel&&(this.signalChannel.isConnected&&(this.signalChannel.send(Q0,o),a=Date.now(),this._lastHeartBeatTime>0&&a-this._lastHeartBeatTime>1e4&&this._log.warn("heartbeat took ".concat(a-this._lastHeartBeatTime)),this._lastHeartBeatTime=a,this.signalChannel.isOnline||(this._log.warn("signal channel is not online"),this.signalChannel.startReconnection())),this.emit("heartbeat-report",OF(xF({},o),{bytes_sent:this._stats.totalBytesSent+this.signalChannel.bytesSent,bytes_received:this._stats.totalBytesReceived+this.signalChannel.bytesReceived}))),!this._isRelayChanged&&this.isRelayMaybeFailed()&&(this.reJoin(),this._isRelayChanged=!0);case 8:case"end":return e.stop()}}),e,this)})))}},{key:"onPublishedUserList",value:function(e){var t=this;if(this.isJoined){var n=e.data.userList.filter((function(e){return e.flag!==YB})).map((function(e){var n=e.userId,r=e.srcTinyId,i=e.flag;n===t.userId&&t.uplinkConnection&&(t.uplinkConnection.flag=i);var o=t.remotePublishedUserMap.get(n);return o&&t.checkSubscribeBigSmallVideo(o),{userId:n,tinyId:r,flag:i}}));e.data.mixRobotList.forEach((function(e){var t=e.userId,r=e.srcTinyId,i=e.flag,o=e.mixUserList;n.unshift({userId:t,tinyId:r,flag:i,isRobot:!0,mixUserList:o})})),HW.emit(GW.RECEIVED_PUBLISHED_USER_LIST,{room:this,publishedUserList:n}),this.userManager.setRemotePublishedUserList(n)}}},{key:"closeUplink",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"you unpublished";this.uplinkConnection&&(this.localTracks.size>0&&this.uplinkConnection.doUnpublish(),this.uplinkConnection.close(e),this.uplinkConnection instanceof G1&&(this.uplinkConnection=null)),this.localTracks.forEach((function(e){return e.unpublish()})),this.localTracks.clear()}},{key:"createDownlinkConnection",value:function(e){var t=e.userId,n=e.tinyId,r=e.flag,i=e.isRobot,o=new(this.singlePC?z2:B1)({userId:t,tinyId:n,room:this,signalChannel:this.signalChannel,enableSEI:this.enableSEI,flag:r,isRobot:i});this.userManager.addRemotePublishedUser(o),this.installDownlinkEvents(o,t),this.emit("remote-published",o)}},{key:"closeDownLinkConnection",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"remote user unpublished",n=this.remotePublishedUserMap.get(e);n&&(n.close(t),this.emit("remote-unpublished",n))}},{key:"installDownlinkEvents",value:function(e,t){var n=this;e.on("error",(function(e){var r=e.getCode();r!==ZF.ICE_TRANSPORT_ERROR&&(r===ZF.DOWNLINK_RECONNECTION_FAILED&&n.closeDownLinkConnection(t),n.emit("error",e))})),e.on("connection-state-changed",(function(t){n.emit("media-connection-state-changed",OF(xF({},t),{userId:e.userId}))})),e.on("firewall-restriction",(function(){n.emit("firewall-restriction")}))}},{key:"startSyncUserListInterval",value:function(){-1===this._syncUserListInterval&&(this._syncUserListInterval=Iz.run("ric",this.syncUserList.bind(this)))}},{key:"stopSyncUserListInterval",value:function(){Iz.clearTask(this._syncUserListInterval),this._syncUserListInterval=-1}},{key:"syncUserList",value:function(){var e=this;return this.getUserList().then((function(t){e.userManager.setUserList(t)})).catch((function(t){e._log.debug("sync user list failed: ".concat(t))}))}},{key:"getUserList",value:function(){var e;return null!=(e=this.signalChannel)&&e.isConnected?this.signalChannel.sendWaitForResponse({command:p1,responseCommand:z0.USER_LIST_RES,enableLog:!1,timeout:2e3}).then((function(e){var t=e.data,n=t.code,r=t.message;if(0===n)return(t.data&&t.data.userList||[]).map((function(e){return{userId:e.userId,tinyId:e.srcTinyId,role:e.role}}));throw rK({key:ZJ.SIGNAL_RESPONSE_FAILED,data:{signalResponse:z0.USER_LIST_RES,code:n,message:r}})})):Promise.reject("not connected")}},{key:"getAllConnections",value:function(){var e=T(this.remotePublishedUserMap.values());return this.uplinkConnection&&e.push(this.uplinkConnection),e}},{key:"isRelayMaybeFailed",value:function(){if(this.signalChannel&&!this.signalChannel.isOnline||!N1)return!1;if(this.singlePC)return this.singlePC.reconnectionCount>6;var e=this.getAllConnections();if(0===e.length)return!1;for(var t=0;t<e.length;t++)if(e[t].getReconnectionCount()<6)return!1;return!0}},{key:"checkConnectionsToReconnect",value:function(){var e,t=this;this.singlePC?(null==(e=this.singlePC.getPeerConnection())?void 0:e.connectionState)===cH.CLOSED&&!this.singlePC.isReconnecting&&(this._log.warn("spc pc is closed but not reconnect"),this.singlePC.startReconnection()):this.getAllConnections().forEach((function(e){if(e instanceof x1&&!e.getIsReconnecting()){var n=e.getPeerConnection();n&&n.connectionState===cH.CLOSED&&(t._log.warn("[".concat(e.getUserId(),"] pc is closed but not reconnect")),e.startReconnection())}}))}},{key:"fallbackToMPC",value:function(){return HF(this,null,p().mark((function e(){var t,n,r,i,o,a;return p().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._log.warn("fallback to multi pc"),Nz.uploadEvent({log:"stat-fallback",userId:this.userId}),this.enableSPC=!1,null==(t=this.singlePC)||t.close(),this.singlePC=null,e.t0=this.isJoined,!e.t0){e.next=9;break}return e.next=9,this.reJoin(!1);case 9:if(!this.uplinkConnection){e.next=21;break}if(n=this.uplinkConnection,this.uplinkConnection=new G1({userId:this.userId,tinyId:this.tinyId,room:this,signalChannel:this.signalChannel,enableSEI:this.enableSEI}),e.t1=n.isMainStreamPublished,!e.t1){e.next=16;break}return e.next=16,this.uplinkConnection.publish({localAudioTrack:n.localMainAudioTrack,localVideoTrack:n.localMainVideoTrack,isAuxiliary:!1});case 16:if(e.t2=n.isAuxStreamPublished,!e.t2){e.next=20;break}return e.next=20,this.uplinkConnection.publish({localAudioTrack:n.localAuxAudioTrack,localVideoTrack:n.localAuxVideoTrack,isAuxiliary:!0});case 20:n.close();case 21:r=0,i=T(this.remotePublishedUserMap.values());case 22:if(!(r<i.length)){e.next=38;break}if(o=i[r],a=new B1({userId:o.userId,tinyId:o.tinyId,room:this,signalChannel:this.signalChannel,enableSEI:this.enableSEI,flag:o.flag,remoteAudioTrack:o.remoteAudioTrack,remoteVideoTrack:o.remoteVideoTrack,remoteAuxiliaryTrack:o.remoteAuxiliaryTrack}),this.installDownlinkEvents(a,o.userId),this.remotePublishedUserMap.set(o.userId,a),e.t3=o.isMainStreamSubscribed,!e.t3){e.next=31;break}return e.next=31,a.subscribe(o.subscribeState,"main");case 31:if(e.t4=o.isAuxStreamSubscribed,!e.t4){e.next=35;break}return e.next=35,a.subscribe(o.subscribeState,"auxiliary");case 35:r++,e.next=22;break;case 38:case"end":return e.stop()}}),e,this)})))}},{key:"destroy",value:function(){this.isDestroyed||(this.signalChannel&&(this._log.info("destroying SignalChannel"),this.signalChannel.close(),this.signalChannel=null),y(t,"destroy",this,3)([]),this._joinReject&&(this._joinReject(new tB({code:ZF.INVALID_OPERATION,message:rK({key:ZJ.CLIENT_DESTROYED,data:{funName:"join"}})})),this.clearJoinTimeout(),this.reset()),this.removeAllListeners(),this.healthDetector.destroy(),Iz.clearTask(this._audioVolumeIntervalId))}},{key:"switchRole",value:function(e){return HF(this,null,p().mark((function t(){return p().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(t.t0=this.role!==e,!t.t0){t.next=5;break}return"audience"===e&&this.uplinkConnection&&this.closeUplink("you switch role to audience"),t.next=5,this.doSwitchRole(e);case 5:case"end":return t.stop()}}),t,this)})))}},{key:"doSwitchRole",value:function(e){var t=this,n={command:m1,data:{role:"anchor"===e?20:21,privateMapKey:this.privateMapKey,latencyLevel:this.latencyLevel},responseCommand:z0.SWITCH_ROLE_RES,retries:1};return this._log.info("switchRole signal data: ".concat(JSON.stringify(n.data))),this.signalChannel.sendWaitForResponseWithRetry(n).then((function(n){var r=n.data,i=r.code,o=r.message;if(0!==i)throw new tB({code:ZF.SWITCH_ROLE_FAILED,message:rK({key:ZJ.SWITCH_ROLE_FAILED,data:{message:o,code:i}})});t.role=e})).catch((function(e){throw e instanceof tB&&e.getCode()===ZF.API_CALL_TIMEOUT&&(e=new tB({code:ZF.SWITCH_ROLE_FAILED,message:rK({key:ZJ.SWITCH_ROLE_TIMEOUT})})),t._log.error(e),e}))}},{key:"publish",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return HF(this,null,p().mark((function e(){var n,r,i,o,a,s=this;return p().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n={},r={},t.forEach((function(e){e instanceof vY&&(e instanceof CY?r.audio=e:n.audio=e),e instanceof EY&&(e instanceof AY&&2===e.mediaType?r.video=e:n.video=e)})),i=Z2(n),o=Z2(r),(!i||!o)&&!this.uplinkConnection&&(this.singlePC?this.uplinkConnection=new W2({userId:this.userId,tinyId:this.tinyId,room:this}):this.uplinkConnection=new G1({userId:this.userId,tinyId:this.tinyId,room:this,signalChannel:this.signalChannel,enableSEI:this.enableSEI}),this.uplinkConnection.on("connection-state-changed",(function(e){s.emit("media-connection-state-changed",OF(xF({},e),{userId:s.userId}))})),this.uplinkConnection.on("firewall-restriction",(function(){s.emit("firewall-restriction")})),this.uplinkConnection.on("error",(function(e){var t=e.getCode();t!==ZF.ICE_TRANSPORT_ERROR&&(t===ZF.UPLINK_RECONNECTION_FAILED&&s.closeUplink(),s.emit("error",e))}))),a=t.map((function(e){return e.kind})).join(","),e.t0=i,e.t0){e.next=11;break}return this._log.info("publish() => main ".concat(a)),e.next=10,this.uplinkConnection.publish({localAudioTrack:n.audio,localVideoTrack:n.video,isAuxiliary:!1});case 10:this._log.info("main is published");case 11:if(e.t1=o,e.t1){e.next=17;break}return this._log.info("publish() => aux ".concat(a)),e.next=16,this.uplinkConnection.publish({localAudioTrack:r.audio,localVideoTrack:r.video,isAuxiliary:!0});case 16:this._log.info("aux is published");case 17:case"end":return e.stop()}}),e,this)})))}},{key:"unpublish",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return HF(this,null,p().mark((function e(){var n,r,i;return p().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(("live"!==this.scene||"anchor"===this.role)&&(this.isMainStreamPublished||this.isAuxStreamPublished)&&this.uplinkConnection){e.next=2;break}return e.abrupt("return");case 2:if(n={},r={},t.forEach((function(e){!e.mediaTrack||!e.isPublished||(e instanceof vY&&(e instanceof CY?r.audio=e:n.audio=e),e instanceof EY&&(e instanceof AY&&2===e.mediaType?r.video=e:n.video=e))})),e.prev=4,i=t.map((function(e){return e.kind})).join(","),e.t0=Z2(n),e.t0){e.next=11;break}return this._log.info("unpublish() => main ".concat(i)),e.next=11,this.uplinkConnection.unpublish({localAudioTrack:n.audio,localVideoTrack:n.video});case 11:if(e.t1=Z2(r),e.t1){e.next=16;break}return this._log.info("unpublish() => aux ".concat(i)),e.next=16,this.uplinkConnection.unpublish({localAudioTrack:r.audio,localVideoTrack:r.video});case 16:e.next=20;break;case 18:e.prev=18,e.t2=e.catch(4);case 20:0===this.localTracks.size&&this.closeUplink("you unpublished");case 21:case"end":return e.stop()}}),e,this,[[4,18]])})))}},{key:"addTrack",value:function(e){if(!this.uplinkConnection||!e.mediaTrack)return Promise.resolve();var t=this.uplinkConnection.addTrack(e);return e.publish(this,t),t}},{key:"removeTrack",value:function(e){return this.uplinkConnection&&e.mediaTrack?this.uplinkConnection.removeTrack(e).then((function(t){return e.unpublish(),t})):Promise.resolve()}},{key:"replaceTrack",value:function(e){return this.uplinkConnection&&e.mediaTrack&&JK()?this.uplinkConnection.replaceTrack(e).then((function(t){t&&HW.emit(GW.LOCAL_TRACK_REPLACED,{track:e})})):Promise.resolve()}},{key:"setBandWidth",value:function(e){return HF(this,null,p().mark((function t(){return p().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(t.t0=this.uplinkConnection,!t.t0){t.next=6;break}return t.next=4,this.uplinkConnection.setBandwidth(e);case 4:return t.next=6,this.uplinkConnection.sendMediaSettings();case 6:case"end":return t.stop()}}),t,this)})))}},{key:"enableSmall",value:function(e){return HF(this,null,p().mark((function t(){return p().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this.uplinkConnection&&this.uplinkConnection.localMainVideoTrack){t.next=2;break}return t.abrupt("return",Promise.resolve());case 2:if(t.t0=e&&this.uplinkConnection.localMainVideoTrack.small,!t.t0){t.next=6;break}return t.next=6,this.setBandWidth({type:UB.VIDEO,videoType:UB.SMALL,bandwidth:this.uplinkConnection.localMainVideoTrack.small.bitrate});case 6:return t.next=8,this.uplinkConnection.enableSmall(e);case 8:case"end":return t.stop()}}),t,this)})))}},{key:"subscribe",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return HF(this,null,p().mark((function e(){var n,r,i,o,a,s,u,l,d,h;return p().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=t.filter((function(e){return!e.isSubscribed})),0!==t.length){e.next=2;break}return e.abrupt("return");case 2:if(n=t[0].userId,r=this.remotePublishedUserMap.get(n)){e.next=5;break}return e.abrupt("return");case 5:return i=t.find((function(e){return 2===e.mediaType}))?"auxiliary":"main",e.prev=6,o=xF({},r.subscribeState),t.forEach((function(e){switch(e.mediaType){case 1:o.audio=!0;break;case 4:o.video=!0;break;case 8:o.smallVideo=!0;break;case 2:o.auxiliary=!0}})),(a=this._changeBigSmallRecords.get(n))&&a.options.smallVideo&&r.muteState.hasSmall&&o.video&&(o.video=!1,o.smallVideo=!0),HW.emit(GW.SUBSCRIBE_START,{room:this,streamType:i,remotePublishedUser:r,subscribeState:o}),this._log.info("subscribe() => ".concat(n," ").concat(i," [").concat(U1(o),"] prev: [").concat(U1(r.subscribeState),"]")),e.next=15,r.subscribe(o,i);case 15:this._log.info("subscribe ".concat(n," ").concat(i," done")),s=c(t),e.prev=17,s.s();case 19:if((u=s.n()).done){e.next=27;break}if(l=u.value,e.t0=l.mediaTrack,e.t0){e.next=25;break}return e.next=25,l.waitHasMediaTrack();case 25:e.next=19;break;case 27:e.next=32;break;case 29:e.prev=29,e.t1=e.catch(17),s.e(e.t1);case 32:return e.prev=32,s.f(),e.finish(32);case 35:HW.emit(GW.SUBSCRIBE_SUCCESS,{room:this,streamType:i,remotePublishedUser:r}),e.next=42;break;case 38:throw e.prev=38,e.t2=e.catch(6),d=e.t2 instanceof tB?e.t2.getCode():ZF.UNKNOWN,h=e.t2,e.t2 instanceof tB?d===ZF.REMOTE_STREAM_NOT_EXIST&&(h=new tB({code:ZF.API_CALL_ABORTED,message:rK({key:ZJ.API_CALL_ABORTED,data:{message:e.t2.message,userId:n,streamType:i}})}),this._log.warn(h)):(h=new tB({code:d,message:rK({key:ZJ.SUBSCRIBE_FAILED,data:{message:e.t2.message,userId:n,streamType:i}})}),this._log.error(h)),h;case 42:case"end":return e.stop()}}),e,this,[[6,38],[17,29,32,35]])})))}},{key:"unsubscribe",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return HF(this,null,p().mark((function e(){var n,r,i;return p().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=t[0].userId,r=this.remotePublishedUserMap.get(n)){e.next=3;break}return e.abrupt("return");case 3:return i=t.find((function(e){return 2===e.mediaType}))?"auxiliary":"main",this._log.info("unsubscribe() => ".concat(n," ").concat(i)),e.prev=5,e.next=8,r.unsubscribe({remoteTracks:t,streamType:i});case 8:e.next=13;break;case 10:e.prev=10,e.t0=e.catch(5),this._log.warn("unsubscribe() => failed ".concat(e.t0));case 13:t.forEach((function(e){e.unsubscribe(),8===e.mediaType&&e.setMediaType(4)})),HW.emit(GW.UNSUBSCRIBE_SUCCESS,{room:this,streamType:i,remotePublishedUser:r});case 14:case"end":return e.stop()}}),e,this,[[5,10]])})))}},{key:"setEncodedDataProcessingListener",value:function(e){throw new Error("Method not implemented.")}},{key:"enableAudioVolumeEvaluation",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:2e3,n=arguments.length>1?arguments[1]:void 0;if(t<=0)return this._enableAudioVolumeEvaluation=!1,void Iz.clearTask(this._audioVolumeIntervalId);t=Math.floor(Math.max(t,100)),HW.emit(GW.AUDIO_LEVEL_INTERVAL,{interval:t}),this._audioVolumeIntervalId&&Iz.clearTask(this._audioVolumeIntervalId),this._enableAudioVolumeEvaluation=!0,this._audioVolumeIntervalId=Iz.run("intervalInWorker",(function(){var r;Iq.isRunning?e.stopUpdateAudioLevelFromSenderStat():e.updateAudioLevelFromSenderStat(t,n);var i=[];null==(r=e.remotePublishedUserMap)||r.forEach((function(t){if(t.muteState.hasAudio){!Iq.isRunning&&t.muteState.audioAvailable&&t.remoteAudioTrack.isSubscribed?e.updateDownlinkAudioLevelFromReceiver(t):t.remoteAudioTrack.volume=0;var n=Math.floor(100*t.remoteAudioTrack.getAudioLevel());i.push({userId:t.userId,volume:n})}})),e.emit("audio-volume",i)}),{delay:t,backgroundTask:n})}},{key:"updateAudioLevelFromSenderStat",value:function(e,t){return HF(this,null,p().mark((function n(){var r,i,o,a=this;return p().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(this.uplinkConnection&&this.uplinkConnection.localMainAudioTrack&&-1===this._updateAudioLevelTaskId){n.next=2;break}return n.abrupt("return");case 2:if(i=null==(r=this.uplinkConnection.getPeerConnection())?void 0:r.getSenders()[0]){n.next=5;break}return n.abrupt("return");case 5:o=Math.max(e,500),this._log.warn("updateAudioLevelFromSenderStat ".concat(o)),this._updateAudioLevelTaskId=Iz.run("intervalInWorker",(function(){return HF(a,null,p().mark((function e(){var t,n;return p().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.uplinkConnection&&this.uplinkConnection.localMainAudioTrack){e.next=3;break}return this.stopUpdateAudioLevelFromSenderStat(),e.abrupt("return");case 3:return e.next=5,i.getStats();case 5:if(t=e.sent,!(this._updateAudioLevelTaskId<0)){e.next=8;break}return e.abrupt("return");case 8:n=this.uplinkConnection.localMainAudioTrack,t.forEach((function(e){"media-source"===e.type&&e.audioLevel&&(n.volume=e.audioLevel)}));case 10:case"end":return e.stop()}}),e,this)})))}),{delay:o,backgroundTask:t});case 7:case"end":return n.stop()}}),n,this)})))}},{key:"stopUpdateAudioLevelFromSenderStat",value:function(){var e;-1!==this._updateAudioLevelTaskId&&(this._log.warn("stopUpdateAudioLevelFromSenderStat"),Iz.clearTask(this._updateAudioLevelTaskId),this._updateAudioLevelTaskId=-1,null!=(e=this.uplinkConnection)&&e.localMainAudioTrack&&(this.uplinkConnection.localMainAudioTrack.volume=0))}},{key:"updateDownlinkAudioLevelFromReceiver",value:function(e){var t,n=e.audioReceiver;if(zK&&n){var r=null==(t=n.getSynchronizationSources()[0])?void 0:t.audioLevel;cj(r)?e.remoteAudioTrack.volume=Math.min(2*r,1):n.getStats().then((function(t){t.forEach((function(t){"inbound-rtp"===t.type&&cj(t.audioLevel)&&(e.remoteAudioTrack.volume=t.audioLevel)}))}))}}},{key:"getLocalAudioStats",value:function(){return HF(this,null,p().mark((function e(){var t,n;return p().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n={},e.abrupt("return",(n[this.userId]={bytesSent:0,packetsSent:0,audioLevel:0},null!=(t=this.uplinkConnection)&&t.localMainAudioTrack&&(n[this.userId]=this.uplinkConnection.localMainAudioTrack.stat),n));case 2:case"end":return e.stop()}}),e,this)})))}},{key:"getLocalVideoStats",value:function(){return HF(this,null,p().mark((function e(){var t,n,r;return p().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r={},e.abrupt("return",(r[this.userId]=(null==(n=null==(t=this.uplinkConnection)?void 0:t.localMainVideoTrack)?void 0:n.stat)||{bytesSent:0,packetsSent:0,framesEncoded:0,framesSent:0,frameWidth:0,frameHeight:0,fpsCapture:0},r));case 2:case"end":return e.stop()}}),e,this)})))}},{key:"getTransportStats",value:function(){return HF(this,null,p().mark((function e(){var t,n,r,i,o,a,s;return p().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t={rtt:0,downlinksRTT:{}},!this.uplinkConnection){e.next=6;break}return e.next=4,this._stats.getSenderStats(this.uplinkConnection);case 4:n=e.sent,t.rtt=n.rtt;case 6:r=c(this.remotePublishedUserMap),e.prev=7,r.s();case 9:if((i=r.n()).done){e.next=17;break}return o=_(i.value,2),a=o[1],e.next=13,this._stats.getReceiverStats(a);case 13:s=e.sent,t.downlinksRTT[s.userId]=s.rtt;case 15:e.next=9;break;case 17:e.next=22;break;case 19:e.prev=19,e.t0=e.catch(7),r.e(e.t0);case 22:return e.prev=22,r.f(),e.finish(22);case 25:return e.abrupt("return",t);case 26:case"end":return e.stop()}}),e,this,[[7,19,22,25]])})))}},{key:"getRemoteVideoStats",value:function(e){return HF(this,null,p().mark((function t(){var n,r,i,o,a,s;return p().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:n={},r=c(this.remotePublishedUserMap);try{for(r.s();!(i=r.n()).done;)o=_(i.value,2),a=o[0],s=o[1],"main"===e&&s.muteState.hasVideo&&(n[a]=s.remoteVideoTrack.stat),"auxiliary"===e&&s.muteState.hasAuxiliary&&(n[a]=s.remoteAuxiliaryTrack.stat)}catch(u){r.e(u)}finally{r.f()}return t.abrupt("return",n);case 4:case"end":return t.stop()}}),t,this)})))}},{key:"getRemoteAudioStats",value:function(){return HF(this,null,p().mark((function e(){var t,n,r,i,o,a;return p().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t={},n=c(this.remotePublishedUserMap);try{for(n.s();!(r=n.n()).done;)i=_(r.value,2),o=i[0],(a=i[1]).muteState.hasAudio&&(t[o]=a.remoteAudioTrack.stat)}catch(s){n.e(s)}finally{n.f()}return e.abrupt("return",t);case 4:case"end":return e.stop()}}),e,this)})))}},{key:"setTurnServer",value:function(e,t){this._log.info("set turn server: ".concat(JSON.stringify(e)," ").concat(t||""));var n=[];Array.isArray(e)?e.forEach((function(e){return n.push(aB.getTurnServer(e))})):aB.isPlainObject(e)&&n.push(aB.getTurnServer(e)),this._turnServers=n,t&&(this._iceTransportPolicy=t)}},{key:"sendStartMixTranscode",value:function(e){return this.signalChannel.sendWaitForResponse({command:u1,data:e,timeout:5e3,responseCommand:z0.START_MIX_TRANSCODE_RES,commandDesc:"startMixTranscode"})}},{key:"sendStopMixTranscode",value:function(e){return this.signalChannel.sendWaitForResponse({command:l1,data:e,timeout:5e3,responseCommand:z0.STOP_MIX_TRANSCODE_RES,commandDesc:"stopMixTranscode"})}},{key:"sendStartPublishCDN",value:function(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];return this.signalChannel.sendWaitForResponse({command:t?o1:s1,data:e,timeout:5e3,responseCommand:t?z0.START_PUBLISH_TENCENT_CDN_RES:z0.START_PUBLISH_GIVEN_CDN_RES,commandDesc:"startPublishCDN"})}},{key:"sendStopPublishCDN",value:function(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];return this.signalChannel.sendWaitForResponse({command:t?a1:c1,data:e,timeout:5e3,responseCommand:t?z0.STOP_PUBLISH_TENCENT_CDN_RES:z0.STOP_PUBLISH_GIVEN_CDN_RES,commandDesc:"stopPublishCDN"})}},{key:"sendStartPushStreamToRoom",value:function(e){return this.signalChannel.sendWaitForResponse({command:d1,data:e,timeout:5e3,responseCommand:z0.START_PUBLISH_CDN_STREAM_RES,commandDesc:"startPublishCDNStream"})}},{key:"sendUpdatePushStreamToRoom",value:function(e){return this.signalChannel.sendWaitForResponse({command:h1,data:e,timeout:5e3,responseCommand:z0.UPDATE_PUBLISH_CDN_STREAM_RES,commandDesc:"updatePublishCDNStream"})}},{key:"sendStopPushStreamToRoom",value:function(e){return this.signalChannel.sendWaitForResponse({command:f1,data:e,timeout:5e3,responseCommand:z0.STOP_PUBLISH_CDN_STREAM_RES,commandDesc:"stopPublishCDNStream"})}},{key:"sendAbilityStatus",value:function(e){var t;null==(t=this.signalChannel)||t.sendWaitForResponse({command:T1,data:e,timeout:5e3,responseCommand:z0.ABILITY_STATUS_REPORT_RESULT,commandDesc:"ability status report"}).catch((function(e){}))}},{key:"getIceServers",value:function(e){var t,n;return this._turnServers.length>0?this._turnServers:null!=(t=this.scheduleResult.iceServers)&&t.length?this.scheduleResult.iceServers:null!=e&&e.length?e:null!=(n=this._iceServersFromJoin)&&n.length?this._iceServersFromJoin:[]}},{key:"getIceTransportPolicy",value:function(){return this.forceRelay?"relay":this._iceTransportPolicy||this.scheduleResult.iceTransportPolicy||"all"}},{key:"getLogger",value:function(){return this._log}},{key:"enableAIVoice",value:function(){throw new Error("Method not implemented.")}},{key:"getSignalChannelUrl",value:function(){var e={mainUrl:"",backupUrl:""},t=aB.getEnv();return t?(e.mainUrl="wss://".concat(t,".rtc.qq.com"),e.backupUrl=e.mainUrl):this.proxy_ws?(e.mainUrl=this.proxy_ws,e.backupUrl=e.mainUrl):this.proxy_unified?(e.mainUrl="wss://".concat(this.proxy_unified),e.backupUrl=e.mainUrl):Array.isArray(this.scheduleResult.domains)&&this.scheduleResult.domains.length>0&&(e.mainUrl="wss://".concat(this.scheduleResult.domains[0]),e.backupUrl=e.mainUrl,this.scheduleResult.domains[1]&&(e.backupUrl="wss://".concat(this.scheduleResult.domains[1]))),e}},{key:"getSignalInfo",value:function(){var e;return(null==(e=this.signalChannel)?void 0:e.getSignalInfo())||{clientIp:"",relayIp:""}}},{key:"reset",value:function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];this.stopSyncUserListInterval(),this.stopHeartbeat(),this.closeConnections(),this.clearNetworkQuality(),this.closeUplink("you exitRoom"),this.signalChannel&&(e&&this.signalChannel.keepAlive&&this.signalChannel.isConnected?this.signalChannel.stopKeepAliveIn(3600):(this.signalChannel.close(),this.setSignalChannel(null))),this._stats.reset(),this.userManager.clear(),this.userManager.removeAllListeners(),this.singlePC&&(this.singlePC.close(),this.singlePC=null),this.scheduleResult={domains:null,iceServers:null,iceTransportPolicy:null,trtcAutoConf:null}}},{key:"checkSubscribeBigSmallVideo",value:function(e){return HF(this,null,p().mark((function t(){var n,r,i,o,a,s,c,u,l;return p().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=e.subscribeState,r=e.userId,i=e.muteState,o=i.hasSmall,a=i.hasVideo,(o||a)&&(n.video||n.smallVideo)){t.next=3;break}return t.abrupt("return");case 3:if(!(!(s=this._changeBigSmallRecords.get(r))||s.isSubscribing||s.reSubscribeCount<=0)){t.next=6;break}return t.abrupt("return");case 6:if(c=s.options,u=s.reSubscribeCount,!(c.video&&n.video||c.smallVideo&&n.smallVideo&&o)){t.next=9;break}return t.abrupt("return");case 9:if(l={audio:e.remoteAudioTrack.isSubscribed||e.remoteAudioTrack.isSubscribing,auxiliary:e.remoteAuxiliaryTrack.isSubscribed||e.remoteAuxiliaryTrack.isSubscribing,video:c.video,smallVideo:c.smallVideo},t.prev=10,!o&&l.smallVideo&&(l.video=!0,l.smallVideo=!1),l.smallVideo!==n.smallVideo||l.video!==n.video){t.next=13;break}return t.abrupt("return");case 13:return s.isSubscribing=!0,s.reSubscribeCount=u-1,t.next=17,e.subscribe(l,"main");case 17:e.remoteVideoTrack.setMediaType(l.smallVideo?8:4),this._log.info("change [".concat(r,"] to ").concat(l.smallVideo?"small":"big"," video successfully. count ").concat(LH-s.reSubscribeCount,".")),s.isSubscribing=!1,s.reSubscribeCount=LH,t.next=26;break;case 23:t.prev=23,t.t0=t.catch(10),this._log.info("change [".concat(r,"] to ").concat(l.smallVideo?"small":"big"," video failed. count ").concat(LH-s.reSubscribeCount,".")),s.isSubscribing=!1,0===s.reSubscribeCount&&this._changeBigSmallRecords.delete(r);case 26:case"end":return t.stop()}}),t,this,[[10,23]])})))}},{key:"changeType",value:function(e,t){var n={options:{video:!e,smallVideo:e},isSubscribing:!1,reSubscribeCount:LH};this._changeBigSmallRecords.set(t.userId,n),this._log.info("set [".concat(t.userId,"] video prefer type: ").concat(e?"small":"big"));var r=this.remotePublishedUserMap.get(t.userId);r&&this.checkSubscribeBigSmallVideo(r)}},{key:"smallStreamConfig",get:function(){return this._smallStreamConfig}},{key:"_initBusinessInfo",value:function(e){this._businessInfo=e.businessInfo;var t={};if(X2(e.businessInfo)&&(t=JSON.parse(e.businessInfo)),!Q2(e.pureAudioPushMode)){if(!Number.isInteger(Number(e.pureAudioPushMode)))throw new tB({code:ZF.INVALID_PARAMETER,message:rK({key:ZJ.INVALID_PURE_AUDIO})});this._pureAudioPushMode=e.pureAudioPushMode,t.Str_uc_params||(t.Str_uc_params={}),t.Str_uc_params.pure_audio_push_mod=this._pureAudioPushMode}if(!Q2(e.userDefineRecordId)){if(null===e.userDefineRecordId.match(/^[A-Za-z0-9_-]{1,64}$/gi))throw new tB({code:ZF.INVALID_PARAMETER,message:rK({key:ZJ.INVALID_USER_DEFINE_RECORDID})});t.Str_uc_params||(t.Str_uc_params={}),t.Str_uc_params.userdefine_record_id=e.userDefineRecordId}if(!Q2(e.userDefinePushArgs)){if(!(X2(e.userDefinePushArgs)&&String(e.userDefinePushArgs)&&String(e.userDefinePushArgs).length<=256))throw new tB({code:ZF.INVALID_PARAMETER,message:rK({key:ZJ.INVALID_USER_DEFINE_PUSH_ARGS})});t.Str_uc_params||(t.Str_uc_params={}),t.Str_uc_params.userdefine_push_args=e.userDefinePushArgs}Z2(t)||(this._businessInfo=JSON.stringify(t))}},{key:"sendCustomMessage",value:function(e){var t;null==(t=this._customMessageManager)||t.send(e)}},{key:"enableInsertableStreams",value:function(){return HF(this,null,p().mark((function e(){return p().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.singlePC||this.singlePC.enableInsertableStreams||!XK){e.next=7;break}return this.singlePC.enableInsertableStreams=!0,e.next=4,this.singlePC.waitForPeerConnectionConnected();case 4:return e.next=6,this.singlePC.startReconnection();case 6:return e.abrupt("return",e.sent);case 7:case"end":return e.stop()}}),e,this)})))}},{key:"sendSignalMessage",value:function(e){var t;return this.signalChannel?null==(t=this.signalChannel)?void 0:t.sendWaitForResponseWithRetry(e):Promise.reject(new tB({code:ZF.INVALID_OPERATION,message:"not join"}))}},{key:"enableCodecPipeline",get:function(){return this.videoManager.encodePipeline.length>0||this.videoManager.decodePipeline.length>0||this.audioManager.encodePipeline.length>0||this.audioManager.decodePipeline.length>0}},{key:"scriptTransformWorker",get:function(){var e;return null==(e=this.singlePC)?void 0:e.scriptTransformWorker}}])}(g2);return UF([mz(["left",gz.INIT],"joined"),Oz({settings:{retries:1,timeout:0},onRetrying:function(e){this._log.warn("join retry ".concat(e))},onRetryFailed:function(e){this._log.error("join failed",e)},onError:function(e,t){this._isUsingCachedSchedule&&!this.isDestroyed?(this._log.warn("is using cached schedule, retry join"),AZ(!0),this.reset(),t()):this.signalChannel&&this.signalChannel.isConnected&&this.signalChannel.keepAlive?(this._log.warn("is using keepAlive ws, retry join"),this.signalChannel.close(),this.reset(),t()):(this.reset(),t())}}),rY((function(e){var t=new L0;return function(n,r,i){return HF(this,null,p().mark((function o(){var a,s,c,u=this;return p().wrap((function(o){for(;;)switch(o.prev=o.next){case 0:if(a=String(n.roomId||n.strRoomId),this.userId=n.userId,this.sdkAppId=n.sdkAppId,this.userSig=n.userSig,this._log.setSdkAppId(this.sdkAppId),this._log.setUserId(this.userId),this.scene=r,n.privateMapKey=n.privateMapKey||"",!this.isJoined){o.next=3;break}throw new tB({code:ZF.INVALID_OPERATION,message:rK({key:ZJ.INVALID_JOIN})});case 3:if(this.checkDestroy(),!t.isJoined({userId:this.userId,roomId:a,sdkAppId:this.sdkAppId,room:this})){o.next=5;break}throw new tB({code:ZF.INVALID_OPERATION,message:rK({key:ZJ.REPEAT_JOIN,data:this.userId})});case 5:if(t.add({room:this,roomId:a}),this.role=21===n.role?"audience":"anchor",this._log.info("Join() => joining room: ".concat(a," useStringRoomId: ").concat(this.useStringRoomId," scene: ").concat(this.scene," role: ").concat(this.role)),HW.emit(GW.JOIN_START,{room:this,roomId:a,params:n}),(s=aB.getEnv())||(s=wB.QCLOUD,this.proxy_ws&&(this.proxy_ws.startsWith(BB.OLD_CLOUD_LADDER)?s=wB.OLD_CLOUD_LADDER:this.proxy_ws.startsWith(BB.WEBRTC)&&(s=wB.WEBRTC))),Nz.setConfig({env:s,sdkAppId:String(this.sdkAppId),userId:this.userId,roomId:a}),$W.checkSystemRequirementsInternal().then((function(e){u.checkSystemResult=e,V0.call(u)})),o.prev=8,o.t0=!(this.proxy_ws||this.proxy_wt||this.scheduleResult.domains||aB.getEnv()),!o.t0){o.next=13;break}return o.next=13,this.schedule(n,i);case 13:return o.next=15,e.call(this,n,r,i);case 15:return c=o.sent,o.abrupt("return",(this.roomId=a,this._joinedTimestamp=aB.performanceNow(),HW.emit(GW.JOIN_SUCCESS,{room:this}),30===i&&!n.component&&Nz.uploadEvent({log:"stat-conv-".concat(Number(bW),"-").concat(location.hostname),userId:this.userId}),c));case 19:throw o.prev=19,o.t1=o.catch(8),t.delete({room:this,roomId:a}),HW.emit(GW.JOIN_FAILED,{room:this,error:o.t1}),o.t1;case 22:case"end":return o.stop()}}),o,this,[[8,19]])})))}}))],e3.prototype,"join",1),UF([mz("joined","left",{ignoreError:!0,success:function(){this.reset(!0)}}),rY((function(e){return function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return HF(this,null,p().mark((function t(){return p().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return HW.emit(GW.LEAVE_START,{room:this}),t.next=3,e.call.apply(e,[this].concat(n));case 3:HW.emit(GW.LEAVE_SUCCESS,{room:this,roomId:this.roomId});case 4:case"end":return t.stop()}}),t,this)})))}})),lY("leave room"),Pz({fnName:"publish",validateArgs:!1}),Pz({fnName:"unsubscribe",validateArgs:!1})],e3.prototype,"leave",1),UF([uY(),rY((function(e){return function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return HF(this,null,p().mark((function t(){var r,i=this;return p().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(("live"!==this.scene||"anchor"===this.role)&&(n=n.filter((function(e){return e.outMediaTrack&&"capture"===e.state})),n.length)){t.next=2;break}return t.abrupt("return");case 2:return HW.emit("61",{room:this}),r=e.apply(this,n),t.abrupt("return",(n.forEach((function(e){return e.publish(i,r)})),r));case 5:case"end":return t.stop()}}),t,this)})))}})),Oz({settings:{retries:dH,timeout:function(e){return rj(e)}},onError:function(e,t,n){var r;null!=(r=e.message)&&r.includes("timeout")?(this._log.warn("publish timeout"),t()):(this._log.error("publish failed: ".concat(e)),n(e),HW.emit(GW.PUBLISH_FAILED,{room:this}))}})],e3.prototype,"publish",1),UF([Pz({fnName:"publish"}),function(e){return function(t,n,r){var i=r.value;return r.value=function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];var o=sY.get(this);if(o){var a=o.queue.filter((function(t,r){if(0===r)return!0;var i=!0;return t.args.forEach((function(e){n.find((function(t){return t===e}))||(i=!1)})),!i||(t.reject(new tB({code:ZF.API_CALL_ABORTED,message:e})),!1)}));o.queue=a}return i.apply(this,n)},r}}("api-call"),uY(),rY((function(e){return function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];var i=e.apply(this,n);return n.forEach((function(e){return e.unpublish()})),i}})),tY((function(){var e,t;0===this.localTracks.size&&FK()&&(null==(t=null==(e=this.singlePC)?void 0:e.getPeerConnection())||t.getSenders().forEach((function(e){return e.track&&e.replaceTrack(null)})))}))],e3.prototype,"unpublish",1),UF([nY((function(e){if(e.code!==ZF.API_CALL_ABORTED)throw e})),dY((function(e){return e.userId}))],e3.prototype,"replaceTrack",1),UF([dY((function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return t[0].userId})),NY(),rY((function(e){return function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];var i=e.apply(this,n);return n.forEach((function(e){return!e.isSubscribed&&e.subscribe(i)})),i}})),Oz({settings:{retries:dH,timeout:function(e){return rj(e)}},onError:function(e,t,n,r){e.message.includes("timeout")?(this._log.warn("subscribe timeout"),t()):(this._log.error("subscribe failed: ".concat(e)),n(e),HW.emit(GW.SUBSCRIBE_FAILED,{room:this,remoteTracks:r}))}})],e3.prototype,"subscribe",1),UF([Pz({fnName:"subscribe",callback:function(){for(var e=this,t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];this.singlePC||n.forEach((function(t){var n=e.remotePublishedUserMap.get(t.userId);n&&!n.isMainStreamSubscribed&&!n.isAuxStreamSubscribed&&n.close("you unsubscribed")}))}}),dY((function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return t[0].userId}))],e3.prototype,"unsubscribe",1),M0.create=M0._create.bind(M0,e3),M0}));
|
|
1
|
+
var factory;factory=function(){function e(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function t(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function n(e,n,r){return n=l(n),function(e,n){if(n&&("object"==typeof n||"function"==typeof n))return n;if(void 0!==n)throw new TypeError("Derived constructors may only return object or undefined");return t(e)}(e,h()?Reflect.construct(n,r||[],l(e).constructor):n.apply(e,r))}function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t,n){if(h())return Reflect.construct.apply(null,arguments);var r=[null];r.push.apply(r,t);var i=new(e.bind.apply(e,r));return n&&m(i,n.prototype),i}function a(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,T(r.key),r)}}function o(e,t,n){return t&&a(e.prototype,t),n&&a(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}function s(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=S(e))||t&&e&&"number"==typeof e.length){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(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,o=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return o=e.done,e},e:function(e){s=!0,a=e},f:function(){try{o||null==n.return||n.return()}finally{if(s)throw a}}}}function c(e,t,n){return(t=T(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function u(){return u="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(e,t,n){var r=_(e,t);if(r){var i=Object.getOwnPropertyDescriptor(r,t);return i.get?i.get.call(arguments.length<3?e:n):i.value}},u.apply(null,arguments)}function l(e){return l=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},l(e)}function d(e,t){if("function"!=typeof t&&null!==t)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&&m(e,t)}function h(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return(h=function(){return!!e})()}function f(){f=function(){return t};var e,t={},n=Object.prototype,r=n.hasOwnProperty,i=Object.defineProperty||function(e,t,n){e[t]=n.value},a="function"==typeof Symbol?Symbol:{},o=a.iterator||"@@iterator",s=a.asyncIterator||"@@asyncIterator",c=a.toStringTag||"@@toStringTag";function u(e,t,n){return Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{u({},"")}catch(e){u=function(e,t,n){return e[t]=n}}function l(e,t,n,r){var a=t&&t.prototype instanceof g?t:g,o=Object.create(a.prototype),s=new N(r||[]);return i(o,"_invoke",{value:R(e,n,s)}),o}function d(e,t,n){try{return{type:"normal",arg:e.call(t,n)}}catch(e){return{type:"throw",arg:e}}}t.wrap=l;var h="suspendedStart",p="suspendedYield",m="executing",v="completed",_={};function g(){}function y(){}function E(){}var T={};u(T,o,(function(){return this}));var k=Object.getPrototypeOf,S=k&&k(k(x([])));S&&S!==n&&r.call(S,o)&&(T=S);var I=E.prototype=g.prototype=Object.create(T);function b(e){["next","throw","return"].forEach((function(t){u(e,t,(function(e){return this._invoke(t,e)}))}))}function A(e,t){function n(i,a,o,s){var c=d(e[i],e,a);if("throw"!==c.type){var u=c.arg,l=u.value;return l&&"object"==typeof l&&r.call(l,"__await")?t.resolve(l.__await).then((function(e){n("next",e,o,s)}),(function(e){n("throw",e,o,s)})):t.resolve(l).then((function(e){u.value=e,o(u)}),(function(e){return n("throw",e,o,s)}))}s(c.arg)}var a;i(this,"_invoke",{value:function(e,r){function i(){return new t((function(t,i){n(e,r,t,i)}))}return a=a?a.then(i,i):i()}})}function R(t,n,r){var i=h;return function(a,o){if(i===m)throw Error("Generator is already running");if(i===v){if("throw"===a)throw o;return{value:e,done:!0}}for(r.method=a,r.arg=o;;){var s=r.delegate;if(s){var c=C(s,r);if(c){if(c===_)continue;return c}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if(i===h)throw i=v,r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);i=m;var u=d(t,n,r);if("normal"===u.type){if(i=r.done?v:p,u.arg===_)continue;return{value:u.arg,done:r.done}}"throw"===u.type&&(i=v,r.method="throw",r.arg=u.arg)}}}function C(t,n){var r=n.method,i=t.iterator[r];if(i===e)return n.delegate=null,"throw"===r&&t.iterator.return&&(n.method="return",n.arg=e,C(t,n),"throw"===n.method)||"return"!==r&&(n.method="throw",n.arg=new TypeError("The iterator does not provide a '"+r+"' method")),_;var a=d(i,t.iterator,n.arg);if("throw"===a.type)return n.method="throw",n.arg=a.arg,n.delegate=null,_;var o=a.arg;return o?o.done?(n[t.resultName]=o.value,n.next=t.nextLoc,"return"!==n.method&&(n.method="next",n.arg=e),n.delegate=null,_):o:(n.method="throw",n.arg=new TypeError("iterator result is not an object"),n.delegate=null,_)}function w(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function D(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function N(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(w,this),this.reset(!0)}function x(t){if(t||""===t){var n=t[o];if(n)return n.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var i=-1,a=function n(){for(;++i<t.length;)if(r.call(t,i))return n.value=t[i],n.done=!1,n;return n.value=e,n.done=!0,n};return a.next=a}}throw new TypeError(typeof t+" is not iterable")}return y.prototype=E,i(I,"constructor",{value:E,configurable:!0}),i(E,"constructor",{value:y,configurable:!0}),y.displayName=u(E,c,"GeneratorFunction"),t.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===y||"GeneratorFunction"===(t.displayName||t.name))},t.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,E):(e.__proto__=E,u(e,c,"GeneratorFunction")),e.prototype=Object.create(I),e},t.awrap=function(e){return{__await:e}},b(A.prototype),u(A.prototype,s,(function(){return this})),t.AsyncIterator=A,t.async=function(e,n,r,i,a){void 0===a&&(a=Promise);var o=new A(l(e,n,r,i),a);return t.isGeneratorFunction(n)?o:o.next().then((function(e){return e.done?e.value:o.next()}))},b(I),u(I,c,"Generator"),u(I,o,(function(){return this})),u(I,"toString",(function(){return"[object Generator]"})),t.keys=function(e){var t=Object(e),n=[];for(var r in t)n.push(r);return n.reverse(),function e(){for(;n.length;){var r=n.pop();if(r in t)return e.value=r,e.done=!1,e}return e.done=!0,e}},t.values=x,N.prototype={constructor:N,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=e,this.done=!1,this.delegate=null,this.method="next",this.arg=e,this.tryEntries.forEach(D),!t)for(var n in this)"t"===n.charAt(0)&&r.call(this,n)&&!isNaN(+n.slice(1))&&(this[n]=e)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var n=this;function i(r,i){return s.type="throw",s.arg=t,n.next=r,i&&(n.method="next",n.arg=e),!!i}for(var a=this.tryEntries.length-1;a>=0;--a){var o=this.tryEntries[a],s=o.completion;if("root"===o.tryLoc)return i("end");if(o.tryLoc<=this.prev){var c=r.call(o,"catchLoc"),u=r.call(o,"finallyLoc");if(c&&u){if(this.prev<o.catchLoc)return i(o.catchLoc,!0);if(this.prev<o.finallyLoc)return i(o.finallyLoc)}else if(c){if(this.prev<o.catchLoc)return i(o.catchLoc,!0)}else{if(!u)throw Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return i(o.finallyLoc)}}}},abrupt:function(e,t){for(var n=this.tryEntries.length-1;n>=0;--n){var i=this.tryEntries[n];if(i.tryLoc<=this.prev&&r.call(i,"finallyLoc")&&this.prev<i.finallyLoc){var a=i;break}}a&&("break"===e||"continue"===e)&&a.tryLoc<=t&&t<=a.finallyLoc&&(a=null);var o=a?a.completion:{};return o.type=e,o.arg=t,a?(this.method="next",this.next=a.finallyLoc,_):this.complete(o)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),_},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.finallyLoc===e)return this.complete(n.completion,n.afterLoc),D(n),_}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc===e){var r=n.completion;if("throw"===r.type){var i=r.arg;D(n)}return i}}throw Error("illegal catch attempt")},delegateYield:function(t,n,r){return this.delegate={iterator:x(t),resultName:n,nextLoc:r},"next"===this.method&&(this.arg=e),_}},t}function p(e,t,n,r){return p="undefined"!=typeof Reflect&&Reflect.set?Reflect.set:function(e,t,n,r){var i,a=_(e,t);if(a){if((i=Object.getOwnPropertyDescriptor(a,t)).set)return i.set.call(r,n),!0;if(!i.writable)return!1}if(i=Object.getOwnPropertyDescriptor(r,t)){if(!i.writable)return!1;i.value=n,Object.defineProperty(r,t,i)}else c(r,t,n);return!0},p(e,t,n,r)}function m(e,t){return m=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},m(e,t)}function v(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,i,a,o,s=[],c=!0,u=!1;try{if(a=(n=n.call(e)).next,0===t){if(Object(n)!==n)return;c=!1}else for(;!(c=(r=a.call(n)).done)&&(s.push(r.value),s.length!==t);c=!0);}catch(e){u=!0,i=e}finally{try{if(!c&&null!=n.return&&(o=n.return(),Object(o)!==o))return}finally{if(u)throw i}}return s}}(e,t)||S(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function _(e,t){for(;!{}.hasOwnProperty.call(e,t)&&null!==(e=l(e)););return e}function g(e,t,n,r){var i=u(l(1&r?e.prototype:e),t,n);return 2&r&&"function"==typeof i?function(e){return i.apply(n,e)}:i}function y(e,t,n,r,i,a){return function(e,t,n,r,i){if(!p(e,t,n,r||e)&&i)throw new TypeError("failed to set property");return n}(l(a?e.prototype:e),t,n,r,i)}function E(t){return function(t){if(Array.isArray(t))return e(t)}(t)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(t)||S(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function T(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t||"default");if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}function k(e){return k="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},k(e)}function S(t,n){if(t){if("string"==typeof t)return e(t,n);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?e(t,n):void 0}}function I(e){var t="function"==typeof Map?new Map:void 0;return I=function(e){if(null===e||!function(e){try{return-1!==Function.toString.call(e).indexOf("[native code]")}catch(t){return"function"==typeof e}}(e))return e;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,n)}function n(){return i(e,arguments,l(this).constructor)}return n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),m(n,e)},I(e)}var b,A;b=void 0,A=function(){var e="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},a=function(e){return e&&e.Math===Math&&e},u=a("object"==("undefined"==typeof globalThis?"undefined":k(globalThis))&&globalThis)||a("object"==("undefined"==typeof window?"undefined":k(window))&&window)||a("object"==("undefined"==typeof self?"undefined":k(self))&&self)||a("object"==k(e)&&e)||a("object"==k(e)&&e)||function(){return this}()||Function("return this")(),l={},h=function(t){try{return!!t()}catch(e){return!0}},p=!h((function(){return 7!==Object.defineProperty({},1,{get:function(){return 7}})[1]})),m=!h((function(){var e=function(){}.bind();return"function"!=typeof e||e.hasOwnProperty("prototype")})),_=m,T=Function.prototype.call,S=_?T.bind(T):function(){return T.apply(T,arguments)},b={},A={}.propertyIsEnumerable,R=Object.getOwnPropertyDescriptor,C=R&&!A.call({1:2},1);b.f=C?function(e){var t=R(this,e);return!!t&&t.enumerable}:A;var w,D,N=function(e,t){return{enumerable:!(1&e),configurable:!(2&e),writable:!(4&e),value:t}},x=m,O=Function.prototype,P=O.call,M=x&&O.bind.bind(P,P),L=x?M:function(e){return function(){return P.apply(e,arguments)}},V=L,U=V({}.toString),F=V("".slice),B=function(e){return F(U(e),8,-1)},j=h,H=B,G=Object,W=L("".split),J=j((function(){return!G("z").propertyIsEnumerable(0)}))?function(e){return"String"===H(e)?W(e,""):G(e)}:G,K=function(e){return null==e},z=K,Y=TypeError,q=function(e){if(z(e))throw new Y("Can't call method on "+e);return e},X=J,Q=q,$=function(e){return X(Q(e))},Z="object"==("undefined"==typeof document?"undefined":k(document))&&document.all,ee=void 0===Z&&void 0!==Z?function(e){return"function"==typeof e||e===Z}:function(e){return"function"==typeof e},te=ee,ne=function(e){return"object"==k(e)?null!==e:te(e)},re=u,ie=ee,ae=function(e,t){return arguments.length<2?(n=re[e],ie(n)?n:void 0):re[e]&&re[e][t];var n},oe=L({}.isPrototypeOf),se=u.navigator,ce=se&&se.userAgent,ue=ce?String(ce):"",le=u,de=ue,he=le.process,fe=le.Deno,pe=he&&he.versions||fe&&fe.version,me=pe&&pe.v8;me&&(D=(w=me.split("."))[0]>0&&w[0]<4?1:+(w[0]+w[1])),!D&&de&&(!(w=de.match(/Edge\/(\d+)/))||w[1]>=74)&&(w=de.match(/Chrome\/(\d+)/))&&(D=+w[1]);var ve=D,_e=ve,ge=h,ye=u.String,Ee=!!Object.getOwnPropertySymbols&&!ge((function(){var e=Symbol("symbol detection");return!ye(e)||!(Object(e)instanceof Symbol)||!Symbol.sham&&_e&&_e<41})),Te=Ee&&!Symbol.sham&&"symbol"==k(Symbol.iterator),ke=ae,Se=ee,Ie=oe,be=Object,Ae=Te?function(e){return"symbol"==k(e)}:function(e){var t=ke("Symbol");return Se(t)&&Ie(t.prototype,be(e))},Re=String,Ce=function(t){try{return Re(t)}catch(e){return"Object"}},we=ee,De=Ce,Ne=TypeError,xe=function(e){if(we(e))return e;throw new Ne(De(e)+" is not a function")},Oe=xe,Pe=K,Me=function(e,t){var n=e[t];return Pe(n)?void 0:Oe(n)},Le=S,Ve=ee,Ue=ne,Fe=TypeError,Be={},je={get exports(){return Be},set exports(e){Be=e}},He=u,Ge=Object.defineProperty,We=function(e,t){try{Ge(He,e,{value:t,configurable:!0,writable:!0})}catch(a){He[e]=t}return t},Je=u,Ke=We,ze="__core-js_shared__",Ye=je.exports=Je[ze]||Ke(ze,{});(Ye.versions||(Ye.versions=[])).push({version:"3.38.1",mode:"global",copyright:"© 2014-2024 Denis Pushkarev (zloirock.ru)",license:"https://github.com/zloirock/core-js/blob/v3.38.1/LICENSE",source:"https://github.com/zloirock/core-js"});var qe=Be,Xe=function(e,t){return qe[e]||(qe[e]=t||{})},Qe=q,$e=Object,Ze=function(e){return $e(Qe(e))},et=Ze,tt=L({}.hasOwnProperty),nt=Object.hasOwn||function(e,t){return tt(et(e),t)},rt=L,it=0,at=Math.random(),ot=rt(1..toString),st=function(e){return"Symbol("+(void 0===e?"":e)+")_"+ot(++it+at,36)},ct=Xe,ut=nt,lt=st,dt=Ee,ht=Te,ft=u.Symbol,pt=ct("wks"),mt=ht?ft.for||ft:ft&&ft.withoutSetter||lt,vt=function(e){return ut(pt,e)||(pt[e]=dt&&ut(ft,e)?ft[e]:mt("Symbol."+e)),pt[e]},_t=S,gt=ne,yt=Ae,Et=Me,Tt=TypeError,kt=vt("toPrimitive"),St=function(e,t){if(!gt(e)||yt(e))return e;var n,r=Et(e,kt);if(r){if(void 0===t&&(t="default"),n=_t(r,e,t),!gt(n)||yt(n))return n;throw new Tt("Can't convert object to primitive value")}return void 0===t&&(t="number"),function(e,t){var n,r;if("string"===t&&Ve(n=e.toString)&&!Ue(r=Le(n,e)))return r;if(Ve(n=e.valueOf)&&!Ue(r=Le(n,e)))return r;if("string"!==t&&Ve(n=e.toString)&&!Ue(r=Le(n,e)))return r;throw new Fe("Can't convert object to primitive value")}(e,t)},It=St,bt=Ae,At=function(e){var t=It(e,"string");return bt(t)?t:t+""},Rt=ne,Ct=u.document,wt=Rt(Ct)&&Rt(Ct.createElement),Dt=function(e){return wt?Ct.createElement(e):{}},Nt=Dt,xt=!p&&!h((function(){return 7!==Object.defineProperty(Nt("div"),"a",{get:function(){return 7}}).a})),Ot=p,Pt=S,Mt=b,Lt=N,Vt=$,Ut=At,Ft=nt,Bt=xt,jt=Object.getOwnPropertyDescriptor;l.f=Ot?jt:function(e,t){if(e=Vt(e),t=Ut(t),Bt)try{return jt(e,t)}catch(a){}if(Ft(e,t))return Lt(!Pt(Mt.f,e,t),e[t])};var Ht={},Gt=p&&h((function(){return 42!==Object.defineProperty((function(){}),"prototype",{value:42,writable:!1}).prototype})),Wt=ne,Jt=String,Kt=TypeError,zt=function(e){if(Wt(e))return e;throw new Kt(Jt(e)+" is not an object")},Yt=p,qt=xt,Xt=Gt,Qt=zt,$t=At,Zt=TypeError,en=Object.defineProperty,tn=Object.getOwnPropertyDescriptor,nn="enumerable",rn="configurable",an="writable";Ht.f=Yt?Xt?function(e,t,n){if(Qt(e),t=$t(t),Qt(n),"function"==typeof e&&"prototype"===t&&"value"in n&&an in n&&!n[an]){var r=tn(e,t);r&&r[an]&&(e[t]=n.value,n={configurable:rn in n?n[rn]:r[rn],enumerable:nn in n?n[nn]:r[nn],writable:!1})}return en(e,t,n)}:en:function(e,t,n){if(Qt(e),t=$t(t),Qt(n),qt)try{return en(e,t,n)}catch(u){}if("get"in n||"set"in n)throw new Zt("Accessors not supported");return"value"in n&&(e[t]=n.value),e};var on=Ht,sn=N,cn=p?function(e,t,n){return on.f(e,t,sn(1,n))}:function(e,t,n){return e[t]=n,e},un={},ln={get exports(){return un},set exports(e){un=e}},dn=p,hn=nt,fn=Function.prototype,pn=dn&&Object.getOwnPropertyDescriptor,mn=hn(fn,"name"),vn={EXISTS:mn,PROPER:mn&&"something"===function(){}.name,CONFIGURABLE:mn&&(!dn||dn&&pn(fn,"name").configurable)},_n=ee,gn=Be,yn=L(Function.toString);_n(gn.inspectSource)||(gn.inspectSource=function(e){return yn(e)});var En,Tn,kn,Sn=gn.inspectSource,In=ee,bn=u.WeakMap,An=In(bn)&&/native code/.test(String(bn)),Rn=st,Cn=Xe("keys"),wn=function(e){return Cn[e]||(Cn[e]=Rn(e))},Dn={},Nn=An,xn=u,On=ne,Pn=cn,Mn=nt,Ln=Be,Vn=wn,Un=Dn,Fn="Object already initialized",Bn=xn.TypeError,jn=xn.WeakMap;if(Nn||Ln.state){var Hn=Ln.state||(Ln.state=new jn);Hn.get=Hn.get,Hn.has=Hn.has,Hn.set=Hn.set,En=function(e,t){if(Hn.has(e))throw new Bn(Fn);return t.facade=e,Hn.set(e,t),t},Tn=function(e){return Hn.get(e)||{}},kn=function(e){return Hn.has(e)}}else{var Gn=Vn("state");Un[Gn]=!0,En=function(e,t){if(Mn(e,Gn))throw new Bn(Fn);return t.facade=e,Pn(e,Gn,t),t},Tn=function(e){return Mn(e,Gn)?e[Gn]:{}},kn=function(e){return Mn(e,Gn)}}var Wn={set:En,get:Tn,has:kn,enforce:function(e){return kn(e)?Tn(e):En(e,{})},getterFor:function(e){return function(t){var n;if(!On(t)||(n=Tn(t)).type!==e)throw new Bn("Incompatible receiver, "+e+" required");return n}}},Jn=L,Kn=h,zn=ee,Yn=nt,qn=p,Xn=vn.CONFIGURABLE,Qn=Sn,$n=Wn.enforce,Zn=Wn.get,er=String,tr=Object.defineProperty,nr=Jn("".slice),rr=Jn("".replace),ir=Jn([].join),ar=qn&&!Kn((function(){return 8!==tr((function(){}),"length",{value:8}).length})),or=String(String).split("String"),sr=ln.exports=function(e,t,n){"Symbol("===nr(er(t),0,7)&&(t="["+rr(er(t),/^Symbol\(([^)]*)\).*$/,"$1")+"]"),n&&n.getter&&(t="get "+t),n&&n.setter&&(t="set "+t),(!Yn(e,"name")||Xn&&e.name!==t)&&(qn?tr(e,"name",{value:t,configurable:!0}):e.name=t),ar&&n&&Yn(n,"arity")&&e.length!==n.arity&&tr(e,"length",{value:n.arity});try{n&&Yn(n,"constructor")&&n.constructor?qn&&tr(e,"prototype",{writable:!1}):e.prototype&&(e.prototype=void 0)}catch(l){}var r=$n(e);return Yn(r,"source")||(r.source=ir(or,"string"==typeof t?t:"")),e};Function.prototype.toString=sr((function(){return zn(this)&&Zn(this).source||Qn(this)}),"toString");var cr=ee,ur=Ht,lr=un,dr=We,hr=function(e,t,n,r){r||(r={});var i=r.enumerable,a=void 0!==r.name?r.name:t;if(cr(n)&&lr(n,a,r),r.global)i?e[t]=n:dr(t,n);else{try{r.unsafe?e[t]&&(i=!0):delete e[t]}catch(p){}i?e[t]=n:ur.f(e,t,{value:n,enumerable:!1,configurable:!r.nonConfigurable,writable:!r.nonWritable})}return e},fr={},pr=Math.ceil,mr=Math.floor,vr=Math.trunc||function(e){var t=+e;return(t>0?mr:pr)(t)},_r=vr,gr=function(e){var t=+e;return t!=t||0===t?0:_r(t)},yr=gr,Er=Math.max,Tr=Math.min,kr=function(e,t){var n=yr(e);return n<0?Er(n+t,0):Tr(n,t)},Sr=gr,Ir=Math.min,br=function(e){var t=Sr(e);return t>0?Ir(t,9007199254740991):0},Ar=br,Rr=function(e){return Ar(e.length)},Cr=$,wr=kr,Dr=Rr,Nr=function(e){return function(t,n,r){var i=Cr(t),a=Dr(i);if(0===a)return!e&&-1;var o,s=wr(r,a);if(e&&n!=n){for(;a>s;)if((o=i[s++])!=o)return!0}else for(;a>s;s++)if((e||s in i)&&i[s]===n)return e||s||0;return!e&&-1}},xr={includes:Nr(!0),indexOf:Nr(!1)},Or=nt,Pr=$,Mr=xr.indexOf,Lr=Dn,Vr=L([].push),Ur=function(e,t){var n,r=Pr(e),i=0,a=[];for(n in r)!Or(Lr,n)&&Or(r,n)&&Vr(a,n);for(;t.length>i;)Or(r,n=t[i++])&&(~Mr(a,n)||Vr(a,n));return a},Fr=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"],Br=Ur,jr=Fr.concat("length","prototype");fr.f=Object.getOwnPropertyNames||function(e){return Br(e,jr)};var Hr={};Hr.f=Object.getOwnPropertySymbols;var Gr=ae,Wr=fr,Jr=Hr,Kr=zt,zr=L([].concat),Yr=Gr("Reflect","ownKeys")||function(e){var t=Wr.f(Kr(e)),n=Jr.f;return n?zr(t,n(e)):t},qr=nt,Xr=Yr,Qr=l,$r=Ht,Zr=function(e,t,n){for(var r=Xr(t),i=$r.f,a=Qr.f,o=0;o<r.length;o++){var s=r[o];qr(e,s)||n&&qr(n,s)||i(e,s,a(t,s))}},ei=h,ti=ee,ni=/#|\.prototype\./,ri=function(e,t){var n=ai[ii(e)];return n===si||n!==oi&&(ti(t)?ei(t):!!t)},ii=ri.normalize=function(e){return String(e).replace(ni,".").toLowerCase()},ai=ri.data={},oi=ri.NATIVE="N",si=ri.POLYFILL="P",ci=ri,ui=u,li=l.f,di=cn,hi=hr,fi=We,pi=Zr,mi=ci,vi=function(e,t){var n,r,i,a,o,s=e.target,c=e.global,u=e.stat;if(n=c?ui:u?ui[s]||fi(s,{}):ui[s]&&ui[s].prototype)for(r in t){if(a=t[r],i=e.dontCallGetSet?(o=li(n,r))&&o.value:n[r],!mi(c?r:s+(u?".":"#")+r,e.forced)&&void 0!==i){if(k(a)==k(i))continue;pi(a,i)}(e.sham||i&&i.sham)&&di(a,"sham",!0),hi(n,r,a,e)}},_i={};_i[vt("toStringTag")]="z";var gi="[object z]"===String(_i),yi=ee,Ei=B,Ti=vt("toStringTag"),ki=Object,Si="Arguments"===Ei(function(){return arguments}()),Ii=gi?Ei:function(e){var t,n,r;return void 0===e?"Undefined":null===e?"Null":"string"==typeof(n=function(e,t){try{return e[t]}catch(n){}}(t=ki(e),Ti))?n:Si?Ei(t):"Object"===(r=Ei(t))&&yi(t.callee)?"Arguments":r},bi=Ii,Ai=String,Ri=function(e){if("Symbol"===bi(e))throw new TypeError("Cannot convert a Symbol value to a string");return Ai(e)},Ci=un,wi=Ht,Di=function(e,t,n){return n.get&&Ci(n.get,t,{getter:!0}),n.set&&Ci(n.set,t,{setter:!0}),wi.f(e,t,n)},Ni=vi,xi=p,Oi=L,Pi=nt,Mi=ee,Li=oe,Vi=Ri,Ui=Di,Fi=Zr,Bi=u.Symbol,ji=Bi&&Bi.prototype;if(xi&&Mi(Bi)&&(!("description"in ji)||void 0!==Bi().description)){var Hi={},Gi=function(){var e=arguments.length<1||void 0===arguments[0]?void 0:Vi(arguments[0]),t=Li(ji,this)?new Bi(e):void 0===e?Bi():Bi(e);return""===e&&(Hi[t]=!0),t};Fi(Gi,Bi),Gi.prototype=ji,ji.constructor=Gi;var Wi="Symbol(description detection)"===String(Bi("description detection")),Ji=Oi(ji.valueOf),Ki=Oi(ji.toString),zi=/^Symbol\((.*)\)[^)]+$/,Yi=Oi("".replace),qi=Oi("".slice);Ui(ji,"description",{configurable:!0,get:function(){var e=Ji(this);if(Pi(Hi,e))return"";var t=Ki(e),n=Wi?qi(t,7,-1):Yi(t,zi,"$1");return""===n?void 0:n}}),Ni({global:!0,constructor:!0,forced:!0},{Symbol:Gi})}var Xi={},Qi=Ur,$i=Fr,Zi=Object.keys||function(e){return Qi(e,$i)},ea=p,ta=Gt,na=Ht,ra=zt,ia=$,aa=Zi;Xi.f=ea&&!ta?Object.defineProperties:function(e,t){ra(e);for(var n,r=ia(t),i=aa(t),a=i.length,o=0;a>o;)na.f(e,n=i[o++],r[n]);return e};var oa,sa=ae("document","documentElement"),ca=zt,ua=Xi,la=Fr,da=Dn,ha=sa,fa=Dt,pa="prototype",ma="script",va=wn("IE_PROTO"),_a=function(){},ga=function(e){return"<"+ma+">"+e+"</"+ma+">"},ya=function(e){e.write(ga("")),e.close();var t=e.parentWindow.Object;return e=null,t},Ea=function(){try{oa=new ActiveXObject("htmlfile")}catch(l){}var e,t,n;Ea="undefined"!=typeof document?document.domain&&oa?ya(oa):(t=fa("iframe"),n="java"+ma+":",t.style.display="none",ha.appendChild(t),t.src=String(n),(e=t.contentWindow.document).open(),e.write(ga("document.F=Object")),e.close(),e.F):ya(oa);for(var r=la.length;r--;)delete Ea[pa][la[r]];return Ea()};da[va]=!0;var Ta=Object.create||function(e,t){var n;return null!==e?(_a[pa]=ca(e),n=new _a,_a[pa]=null,n[va]=e):n=Ea(),void 0===t?n:ua.f(n,t)},ka=vt,Sa=Ta,Ia=Ht.f,ba=ka("unscopables"),Aa=Array.prototype;void 0===Aa[ba]&&Ia(Aa,ba,{configurable:!0,value:Sa(null)});var Ra=function(e){Aa[ba][e]=!0},Ca=xr.includes,wa=Ra;vi({target:"Array",proto:!0,forced:h((function(){return!Array(1).includes()}))},{includes:function(e){return Ca(this,e,arguments.length>1?arguments[1]:void 0)}}),wa("includes");var Da,Na,xa,Oa={},Pa=!h((function(){function e(){}return e.prototype.constructor=null,Object.getPrototypeOf(new e)!==e.prototype})),Ma=nt,La=ee,Va=Ze,Ua=Pa,Fa=wn("IE_PROTO"),Ba=Object,ja=Ba.prototype,Ha=Ua?Ba.getPrototypeOf:function(e){var t=Va(e);if(Ma(t,Fa))return t[Fa];var n=t.constructor;return La(n)&&t instanceof n?n.prototype:t instanceof Ba?ja:null},Ga=h,Wa=ee,Ja=ne,Ka=Ha,za=hr,Ya=vt("iterator"),qa=!1;[].keys&&("next"in(xa=[].keys())?(Na=Ka(Ka(xa)))!==Object.prototype&&(Da=Na):qa=!0);var Xa=!Ja(Da)||Ga((function(){var e={};return Da[Ya].call(e)!==e}));Xa&&(Da={}),Wa(Da[Ya])||za(Da,Ya,(function(){return this}));var Qa={IteratorPrototype:Da,BUGGY_SAFARI_ITERATORS:qa},$a=Ht.f,Za=nt,eo=vt("toStringTag"),to=function(e,t,n){e&&!n&&(e=e.prototype),e&&!Za(e,eo)&&$a(e,eo,{configurable:!0,value:t})},no=Qa.IteratorPrototype,ro=Ta,io=N,ao=to,oo=Oa,so=function(){return this},co=function(e,t,n,r){var i=t+" Iterator";return e.prototype=ro(no,{next:io(+!r,n)}),ao(e,i,!1),oo[i]=so,e},uo=L,lo=xe,ho=ne,fo=String,po=TypeError,mo=ne,vo=q,_o=function(e){if(function(e){return ho(e)||null===e}(e))return e;throw new po("Can't set "+fo(e)+" as a prototype")},go=Object.setPrototypeOf||("__proto__"in{}?function(){var e,t=!1,n={};try{(e=function(e,t,n){try{return uo(lo(Object.getOwnPropertyDescriptor(e,t)[n]))}catch(u){}}(Object.prototype,"__proto__","set"))(n,[]),t=n instanceof Array}catch(u){}return function(n,r){return vo(n),_o(r),mo(n)?(t?e(n,r):n.__proto__=r,n):n}}():void 0),yo=vi,Eo=S,To=ee,ko=co,So=Ha,Io=go,bo=to,Ao=cn,Ro=hr,Co=Oa,wo=vn.PROPER,Do=vn.CONFIGURABLE,No=Qa.IteratorPrototype,xo=Qa.BUGGY_SAFARI_ITERATORS,Oo=vt("iterator"),Po="keys",Mo="values",Lo="entries",Vo=function(){return this},Uo=function(e,t,n,r,i,a,o){ko(n,t,r);var s,c,u,l=function(e){if(e===i&&m)return m;if(!xo&&e&&e in f)return f[e];switch(e){case Po:case Mo:case Lo:return function(){return new n(this,e)}}return function(){return new n(this)}},d=t+" Iterator",h=!1,f=e.prototype,p=f[Oo]||f["@@iterator"]||i&&f[i],m=!xo&&p||l(i),v="Array"===t&&f.entries||p;if(v&&(s=So(v.call(new e)))!==Object.prototype&&s.next&&(So(s)!==No&&(Io?Io(s,No):To(s[Oo])||Ro(s,Oo,Vo)),bo(s,d,!0)),wo&&i===Mo&&p&&p.name!==Mo&&(Do?Ao(f,"name",Mo):(h=!0,m=function(){return Eo(p,this)})),i)if(c={values:l(Mo),keys:a?m:l(Po),entries:l(Lo)},o)for(u in c)(xo||h||!(u in f))&&Ro(f,u,c[u]);else yo({target:t,proto:!0,forced:xo||h},c);return f[Oo]!==m&&Ro(f,Oo,m,{name:i}),Co[t]=m,c},Fo=function(e,t){return{value:e,done:t}},Bo=$,jo=Ra,Ho=Oa,Go=Wn,Wo=Ht.f,Jo=Uo,Ko=Fo,zo=p,Yo="Array Iterator",qo=Go.set,Xo=Go.getterFor(Yo),Qo=Jo(Array,"Array",(function(e,t){qo(this,{type:Yo,target:Bo(e),index:0,kind:t})}),(function(){var e=Xo(this),t=e.target,n=e.index++;if(!t||n>=t.length)return e.target=null,Ko(void 0,!0);switch(e.kind){case"keys":return Ko(n,!1);case"values":return Ko(t[n],!1)}return Ko([n,t[n]],!1)}),"values"),$o=Ho.Arguments=Ho.Array;if(jo("keys"),jo("values"),jo("entries"),zo&&"values"!==$o.name)try{Wo($o,"name",{value:"values"})}catch(HH){}var Zo=xe,es=Ze,ts=J,ns=Rr,rs=TypeError,is="Reduce of empty array with no initial value",as=function(e){return function(t,n,r,i){var a=es(t),o=ts(a),s=ns(a);if(Zo(n),0===s&&r<2)throw new rs(is);var c=e?s-1:0,u=e?-1:1;if(r<2)for(;;){if(c in o){i=o[c],c+=u;break}if(c+=u,e?c<0:s<=c)throw new rs(is)}for(;e?c>=0:s>c;c+=u)c in o&&(i=n(i,o[c],c,a));return i}},os={left:as(!1),right:as(!0)},ss=h,cs=function(e,t){var n=[][e];return!!n&&ss((function(){n.call(null,t||function(){return 1},1)}))},us=u,ls=ue,ds=B,hs=function(e){return ls.slice(0,e.length)===e},fs=hs("Bun/")?"BUN":hs("Cloudflare-Workers")?"CLOUDFLARE":hs("Deno/")?"DENO":hs("Node.js/")?"NODE":us.Bun&&"string"==typeof Bun.version?"BUN":us.Deno&&"object"==k(Deno.version)?"DENO":"process"===ds(us.process)?"NODE":us.window&&us.document?"BROWSER":"REST",ps="NODE"===fs,ms=os.left;vi({target:"Array",proto:!0,forced:!ps&&ve>79&&ve<83||!cs("reduce")},{reduce:function(e){var t=arguments.length;return ms(this,e,t,t>1?arguments[1]:void 0)}});var vs=os.right;vi({target:"Array",proto:!0,forced:!ps&&ve>79&&ve<83||!cs("reduceRight")},{reduceRight:function(e){return vs(this,e,arguments.length,arguments.length>1?arguments[1]:void 0)}});var _s=B,gs=Array.isArray||function(e){return"Array"===_s(e)},ys=vi,Es=gs,Ts=L([].reverse),ks=[1,2];ys({target:"Array",proto:!0,forced:String(ks)===String(ks.reverse())},{reverse:function(){return Es(this)&&(this.length=this.length),Ts(this)}});var Ss=Ce,Is=TypeError,bs=L([].slice),As=bs,Rs=Math.floor,Cs=function(e,t){var n=e.length;if(n<8)for(var r,i,a=1;a<n;){for(i=a,r=e[a];i&&t(e[i-1],r)>0;)e[i]=e[--i];i!==a++&&(e[i]=r)}else for(var o=Rs(n/2),s=Cs(As(e,0,o),t),c=Cs(As(e,o),t),u=s.length,l=c.length,d=0,h=0;d<u||h<l;)e[d+h]=d<u&&h<l?t(s[d],c[h])<=0?s[d++]:c[h++]:d<u?s[d++]:c[h++];return e},ws=Cs,Ds=ue.match(/firefox\/(\d+)/i),Ns=!!Ds&&+Ds[1],xs=/MSIE|Trident/.test(ue),Os=ue.match(/AppleWebKit\/(\d+)\./),Ps=!!Os&&+Os[1],Ms=vi,Ls=L,Vs=xe,Us=Ze,Fs=Rr,Bs=function(e,t){if(!delete e[t])throw new Is("Cannot delete property "+Ss(t)+" of "+Ss(e))},js=Ri,Hs=h,Gs=ws,Ws=cs,Js=Ns,Ks=xs,zs=ve,Ys=Ps,qs=[],Xs=Ls(qs.sort),Qs=Ls(qs.push),$s=Hs((function(){qs.sort(void 0)})),Zs=Hs((function(){qs.sort(null)})),ec=Ws("sort"),tc=!Hs((function(){if(zs)return zs<70;if(!(Js&&Js>3)){if(Ks)return!0;if(Ys)return Ys<603;var e,t,n,r,i="";for(e=65;e<76;e++){switch(t=String.fromCharCode(e),e){case 66:case 69:case 70:case 72:n=3;break;case 68:case 71:n=4;break;default:n=2}for(r=0;r<47;r++)qs.push({k:t+r,v:n})}for(qs.sort((function(e,t){return t.v-e.v})),r=0;r<qs.length;r++)t=qs[r].k.charAt(0),i.charAt(i.length-1)!==t&&(i+=t);return"DGBEFHACIJK"!==i}}));Ms({target:"Array",proto:!0,forced:$s||!Zs||!ec||!tc},{sort:function(e){void 0!==e&&Vs(e);var t=Us(this);if(tc)return void 0===e?Xs(t):Xs(t,e);var n,r,i=[],a=Fs(t);for(r=0;r<a;r++)r in t&&Qs(i,t[r]);for(Gs(i,function(e){return function(t,n){return void 0===n?-1:void 0===t?1:void 0!==e?+e(t,n)||0:js(t)>js(n)?1:-1}}(e)),n=Fs(i),r=0;r<n;)t[r]=i[r++];for(;r<a;)Bs(t,r++);return t}});var nc="undefined"!=typeof ArrayBuffer&&"undefined"!=typeof DataView,rc=hr,ic=function(e,t,n){for(var r in t)rc(e,r,t[r],n);return e},ac=oe,oc=TypeError,sc=function(e,t){if(ac(t,e))return e;throw new oc("Incorrect invocation")},cc=gr,uc=br,lc=RangeError,dc=function(e){if(void 0===e)return 0;var t=cc(e),n=uc(t);if(t!==n)throw new lc("Wrong length or index");return n},hc=Math.sign||function(e){var t=+e;return 0===t||t!=t?t:t<0?-1:1},fc=hc,pc=Math.abs,mc=2220446049250313e-31,vc=1/mc,_c=Math.fround||function(e){return function(e,t,n,r){var i=+e,a=pc(i),o=fc(i);if(a<r)return o*function(e){return e+vc-vc}(a/r/t)*r*t;var s=(1+t/mc)*a,c=s-(s-a);return c>n||c!=c?Infinity*o:o*c}(e,1.1920928955078125e-7,34028234663852886e22,11754943508222875e-54)},gc=Array,yc=Math.abs,Ec=Math.pow,Tc=Math.floor,kc=Math.log,Sc=Math.LN2,Ic={pack:function(e,t,n){var r,i,a,o=gc(n),s=8*n-t-1,c=(1<<s)-1,u=c>>1,l=23===t?Ec(2,-24)-Ec(2,-77):0,d=e<0||0===e&&1/e<0?1:0,h=0;for((e=yc(e))!=e||Infinity===e?(i=e!=e?1:0,r=c):(r=Tc(kc(e)/Sc),e*(a=Ec(2,-r))<1&&(r--,a*=2),(e+=r+u>=1?l/a:l*Ec(2,1-u))*a>=2&&(r++,a/=2),r+u>=c?(i=0,r=c):r+u>=1?(i=(e*a-1)*Ec(2,t),r+=u):(i=e*Ec(2,u-1)*Ec(2,t),r=0));t>=8;)o[h++]=255&i,i/=256,t-=8;for(r=r<<t|i,s+=t;s>0;)o[h++]=255&r,r/=256,s-=8;return o[h-1]|=128*d,o},unpack:function(e,t){var n,r=e.length,i=8*r-t-1,a=(1<<i)-1,o=a>>1,s=i-7,c=r-1,u=e[c--],l=127&u;for(u>>=7;s>0;)l=256*l+e[c--],s-=8;for(n=l&(1<<-s)-1,l>>=-s,s+=t;s>0;)n=256*n+e[c--],s-=8;if(0===l)l=1-o;else{if(l===a)return n?NaN:u?-Infinity:Infinity;n+=Ec(2,t),l-=o}return(u?-1:1)*n*Ec(2,l-t)}},bc=Ze,Ac=kr,Rc=Rr,Cc=function(e){for(var t=bc(this),n=Rc(t),r=arguments.length,i=Ac(r>1?arguments[1]:void 0,n),a=r>2?arguments[2]:void 0,o=void 0===a?n:Ac(a,n);o>i;)t[i++]=e;return t},wc=ee,Dc=ne,Nc=go,xc=function(e,t,n){var r,i;return Nc&&wc(r=t.constructor)&&r!==n&&Dc(i=r.prototype)&&i!==n.prototype&&Nc(e,i),e},Oc=u,Pc=L,Mc=p,Lc=nc,Vc=cn,Uc=Di,Fc=ic,Bc=h,jc=sc,Hc=gr,Gc=br,Wc=dc,Jc=_c,Kc=Ic,zc=Ha,Yc=go,qc=Cc,Xc=bs,Qc=xc,$c=Zr,Zc=to,eu=Wn,tu=vn.PROPER,nu=vn.CONFIGURABLE,ru="ArrayBuffer",iu="DataView",au="prototype",ou="Wrong index",su=eu.getterFor(ru),cu=eu.getterFor(iu),uu=eu.set,lu=Oc[ru],du=lu,hu=du&&du[au],fu=Oc[iu],pu=fu&&fu[au],mu=Object.prototype,vu=Oc.Array,_u=Oc.RangeError,gu=Pc(qc),yu=Pc([].reverse),Eu=Kc.pack,Tu=Kc.unpack,ku=function(e){return[255&e]},Su=function(e){return[255&e,e>>8&255]},Iu=function(e){return[255&e,e>>8&255,e>>16&255,e>>24&255]},bu=function(e){return e[3]<<24|e[2]<<16|e[1]<<8|e[0]},Au=function(e){return Eu(Jc(e),23,4)},Ru=function(e){return Eu(e,52,8)},Cu=function(e,t,n){Uc(e[au],t,{configurable:!0,get:function(){return n(this)[t]}})},wu=function(e,t,n,r){var i=cu(e),a=Wc(n),o=!!r;if(a+t>i.byteLength)throw new _u(ou);var s=i.bytes,c=a+i.byteOffset,u=Xc(s,c,c+t);return o?u:yu(u)},Du=function(e,t,n,r,i,a){var o=cu(e),s=Wc(n),c=r(+i),u=!!a;if(s+t>o.byteLength)throw new _u(ou);for(var l=o.bytes,d=s+o.byteOffset,h=0;h<t;h++)l[d+h]=c[u?h:t-h-1]};if(Lc){var Nu=tu&&lu.name!==ru;Bc((function(){lu(1)}))&&Bc((function(){new lu(-1)}))&&!Bc((function(){return new lu,new lu(1.5),new lu(NaN),1!==lu.length||Nu&&!nu}))?Nu&&nu&&Vc(lu,"name",ru):((du=function(e){return jc(this,hu),Qc(new lu(Wc(e)),this,du)})[au]=hu,hu.constructor=du,$c(du,lu)),Yc&&zc(pu)!==mu&&Yc(pu,mu);var xu=new fu(new du(2)),Ou=Pc(pu.setInt8);xu.setInt8(0,2147483648),xu.setInt8(1,2147483649),!xu.getInt8(0)&&xu.getInt8(1)||Fc(pu,{setInt8:function(e,t){Ou(this,e,t<<24>>24)},setUint8:function(e,t){Ou(this,e,t<<24>>24)}},{unsafe:!0})}else hu=(du=function(e){jc(this,hu);var t=Wc(e);uu(this,{type:ru,bytes:gu(vu(t),0),byteLength:t}),Mc||(this.byteLength=t,this.detached=!1)})[au],pu=(fu=function(e,t,n){jc(this,pu),jc(e,hu);var r=su(e),i=r.byteLength,a=Hc(t);if(a<0||a>i)throw new _u("Wrong offset");if(a+(n=void 0===n?i-a:Gc(n))>i)throw new _u("Wrong length");uu(this,{type:iu,buffer:e,byteLength:n,byteOffset:a,bytes:r.bytes}),Mc||(this.buffer=e,this.byteLength=n,this.byteOffset=a)})[au],Mc&&(Cu(du,"byteLength",su),Cu(fu,"buffer",cu),Cu(fu,"byteLength",cu),Cu(fu,"byteOffset",cu)),Fc(pu,{getInt8:function(e){return wu(this,1,e)[0]<<24>>24},getUint8:function(e){return wu(this,1,e)[0]},getInt16:function(e){var t=wu(this,2,e,arguments.length>1&&arguments[1]);return(t[1]<<8|t[0])<<16>>16},getUint16:function(e){var t=wu(this,2,e,arguments.length>1&&arguments[1]);return t[1]<<8|t[0]},getInt32:function(e){return bu(wu(this,4,e,arguments.length>1&&arguments[1]))},getUint32:function(e){return bu(wu(this,4,e,arguments.length>1&&arguments[1]))>>>0},getFloat32:function(e){return Tu(wu(this,4,e,arguments.length>1&&arguments[1]),23)},getFloat64:function(e){return Tu(wu(this,8,e,arguments.length>1&&arguments[1]),52)},setInt8:function(e,t){Du(this,1,e,ku,t)},setUint8:function(e,t){Du(this,1,e,ku,t)},setInt16:function(e,t){Du(this,2,e,Su,t,arguments.length>2&&arguments[2])},setUint16:function(e,t){Du(this,2,e,Su,t,arguments.length>2&&arguments[2])},setInt32:function(e,t){Du(this,4,e,Iu,t,arguments.length>2&&arguments[2])},setUint32:function(e,t){Du(this,4,e,Iu,t,arguments.length>2&&arguments[2])},setFloat32:function(e,t){Du(this,4,e,Au,t,arguments.length>2&&arguments[2])},setFloat64:function(e,t){Du(this,8,e,Ru,t,arguments.length>2&&arguments[2])}});Zc(du,ru),Zc(fu,iu);var Pu={ArrayBuffer:du,DataView:fu},Mu=ae,Lu=Di,Vu=p,Uu=vt("species"),Fu=function(e){var t=Mu(e);Vu&&t&&!t[Uu]&&Lu(t,Uu,{configurable:!0,get:function(){return this}})},Bu=Fu,ju="ArrayBuffer",Hu=Pu[ju];vi({global:!0,constructor:!0,forced:u[ju]!==Hu},{ArrayBuffer:Hu}),Bu(ju);var Gu=B,Wu=L,Ju=function(e){if("Function"===Gu(e))return Wu(e)},Ku=L,zu=h,Yu=ee,qu=Ii,Xu=Sn,Qu=function(){},$u=ae("Reflect","construct"),Zu=/^\s*(?:class|function)\b/,el=Ku(Zu.exec),tl=!Zu.test(Qu),nl=function(e){if(!Yu(e))return!1;try{return $u(Qu,[],e),!0}catch(HH){return!1}},rl=function(e){if(!Yu(e))return!1;switch(qu(e)){case"AsyncFunction":case"GeneratorFunction":case"AsyncGeneratorFunction":return!1}try{return tl||!!el(Zu,Xu(e))}catch(HH){return!0}};rl.sham=!0;var il=!$u||zu((function(){var e;return nl(nl.call)||!nl(Object)||!nl((function(){e=!0}))||e}))?rl:nl,al=il,ol=Ce,sl=TypeError,cl=function(e){if(al(e))return e;throw new sl(ol(e)+" is not a constructor")},ul=zt,ll=cl,dl=K,hl=vt("species"),fl=function(e,t){var n,r=ul(e).constructor;return void 0===r||dl(n=ul(r)[hl])?t:ll(n)},pl=vi,ml=Ju,vl=h,_l=zt,gl=kr,yl=br,El=fl,Tl=Pu.ArrayBuffer,kl=Pu.DataView,Sl=kl.prototype,Il=ml(Tl.prototype.slice),bl=ml(Sl.getUint8),Al=ml(Sl.setUint8);pl({target:"ArrayBuffer",proto:!0,unsafe:!0,forced:vl((function(){return!new Tl(2).slice(1,void 0).byteLength}))},{slice:function(e,t){if(Il&&void 0===t)return Il(_l(this),e);for(var n=_l(this).byteLength,r=gl(e,n),i=gl(void 0===t?n:t,n),a=new(El(this,Tl))(yl(i-r)),o=new kl(this),s=new kl(a),c=0;r<i;)Al(s,c++,bl(o,r++));return a}});var Rl,Cl,wl,Dl,Nl=m,xl=Function.prototype,Ol=xl.apply,Pl=xl.call,Ml="object"==("undefined"==typeof Reflect?"undefined":k(Reflect))&&Reflect.apply||(Nl?Pl.bind(Ol):function(){return Pl.apply(Ol,arguments)}),Ll=xe,Vl=m,Ul=Ju(Ju.bind),Fl=function(e,t){return Ll(e),void 0===t?e:Vl?Ul(e,t):function(){return e.apply(t,arguments)}},Bl=TypeError,jl=function(e,t){if(e<t)throw new Bl("Not enough arguments");return e},Hl=/(?:ipad|iphone|ipod).*applewebkit/i.test(ue),Gl=u,Wl=Ml,Jl=Fl,Kl=ee,zl=nt,Yl=h,ql=sa,Xl=bs,Ql=Dt,$l=jl,Zl=Hl,ed=ps,td=Gl.setImmediate,nd=Gl.clearImmediate,rd=Gl.process,id=Gl.Dispatch,ad=Gl.Function,od=Gl.MessageChannel,sd=Gl.String,cd=0,ud={},ld="onreadystatechange";Yl((function(){Rl=Gl.location}));var dd=function(e){if(zl(ud,e)){var t=ud[e];delete ud[e],t()}},hd=function(e){return function(){dd(e)}},fd=function(e){dd(e.data)},pd=function(e){Gl.postMessage(sd(e),Rl.protocol+"//"+Rl.host)};td&&nd||(td=function(e){$l(arguments.length,1);var t=Kl(e)?e:ad(e),n=Xl(arguments,1);return ud[++cd]=function(){Wl(t,void 0,n)},Cl(cd),cd},nd=function(e){delete ud[e]},ed?Cl=function(e){rd.nextTick(hd(e))}:id&&id.now?Cl=function(e){id.now(hd(e))}:od&&!Zl?(Dl=(wl=new od).port2,wl.port1.onmessage=fd,Cl=Jl(Dl.postMessage,Dl)):Gl.addEventListener&&Kl(Gl.postMessage)&&!Gl.importScripts&&Rl&&"file:"!==Rl.protocol&&!Yl(pd)?(Cl=pd,Gl.addEventListener("message",fd,!1)):Cl=ld in Ql("script")?function(e){ql.appendChild(Ql("script"))[ld]=function(){ql.removeChild(this),dd(e)}}:function(e){setTimeout(hd(e),0)});var md={set:td,clear:nd},vd=u,_d=p,gd=Object.getOwnPropertyDescriptor,yd=function(e){if(!_d)return vd[e];var t=gd(vd,e);return t&&t.value},Ed=function(){this.head=null,this.tail=null};Ed.prototype={add:function(e){var t={item:e,next:null},n=this.tail;n?n.next=t:this.head=t,this.tail=t},get:function(){var e=this.head;if(e)return null===(this.head=e.next)&&(this.tail=null),e.item}};var Td,kd,Sd,Id,bd,Ad=Ed,Rd=/ipad|iphone|ipod/i.test(ue)&&"undefined"!=typeof Pebble,Cd=/web0s(?!.*chrome)/i.test(ue),wd=u,Dd=yd,Nd=Fl,xd=md.set,Od=Ad,Pd=Hl,Md=Rd,Ld=Cd,Vd=ps,Ud=wd.MutationObserver||wd.WebKitMutationObserver,Fd=wd.document,Bd=wd.process,jd=wd.Promise,Hd=Dd("queueMicrotask");if(!Hd){var Gd=new Od,Wd=function(){var e,t;for(Vd&&(e=Bd.domain)&&e.exit();t=Gd.get();)try{t()}catch(HH){throw Gd.head&&Td(),HH}e&&e.enter()};Pd||Vd||Ld||!Ud||!Fd?!Md&&jd&&jd.resolve?((Id=jd.resolve(void 0)).constructor=jd,bd=Nd(Id.then,Id),Td=function(){bd(Wd)}):Vd?Td=function(){Bd.nextTick(Wd)}:(xd=Nd(xd,wd),Td=function(){xd(Wd)}):(kd=!0,Sd=Fd.createTextNode(""),new Ud(Wd).observe(Sd,{characterData:!0}),Td=function(){Sd.data=kd=!kd}),Hd=function(e){Gd.head||Td(),Gd.add(e)}}var Jd=Hd,Kd=function(e){try{return{error:!1,value:e()}}catch(HH){return{error:!0,value:HH}}},zd=u.Promise,Yd=u,qd=zd,Xd=ee,Qd=ci,$d=Sn,Zd=vt,eh=fs,th=ve;qd&&qd.prototype;var nh=Zd("species"),rh=!1,ih=Xd(Yd.PromiseRejectionEvent),ah=Qd("Promise",(function(){var e=$d(qd),t=e!==String(qd);if(!t&&66===th)return!0;if(!th||th<51||!/native code/.test(e)){var n=new qd((function(e){e(1)})),r=function(e){e((function(){}),(function(){}))};if((n.constructor={})[nh]=r,!(rh=n.then((function(){}))instanceof r))return!0}return!(t||"BROWSER"!==eh&&"DENO"!==eh||ih)})),oh={CONSTRUCTOR:ah,REJECTION_EVENT:ih,SUBCLASSING:rh},sh={},ch=xe,uh=TypeError,lh=function(e){var t,n;this.promise=new e((function(e,r){if(void 0!==t||void 0!==n)throw new uh("Bad Promise constructor");t=e,n=r})),this.resolve=ch(t),this.reject=ch(n)};sh.f=function(e){return new lh(e)};var dh,hh,fh,ph=vi,mh=ps,vh=u,_h=S,gh=hr,yh=go,Eh=to,Th=Fu,kh=xe,Sh=ee,Ih=ne,bh=sc,Ah=fl,Rh=md.set,Ch=Jd,wh=Kd,Dh=Ad,Nh=Wn,xh=zd,Oh=sh,Ph="Promise",Mh=oh.CONSTRUCTOR,Lh=oh.REJECTION_EVENT,Vh=oh.SUBCLASSING,Uh=Nh.getterFor(Ph),Fh=Nh.set,Bh=xh&&xh.prototype,jh=xh,Hh=Bh,Gh=vh.TypeError,Wh=vh.document,Jh=vh.process,Kh=Oh.f,zh=Kh,Yh=!!(Wh&&Wh.createEvent&&vh.dispatchEvent),qh="unhandledrejection",Xh=function(e){var t;return!(!Ih(e)||!Sh(t=e.then))&&t},Qh=function(e,t){var n,r,i,a=t.value,o=1===t.state,s=o?e.ok:e.fail,c=e.resolve,u=e.reject,l=e.domain;try{s?(o||(2===t.rejection&&nf(t),t.rejection=1),!0===s?n=a:(l&&l.enter(),n=s(a),l&&(l.exit(),i=!0)),n===e.promise?u(new Gh("Promise-chain cycle")):(r=Xh(n))?_h(r,n,c,u):c(n)):u(a)}catch(HH){l&&!i&&l.exit(),u(HH)}},$h=function(e,t){e.notified||(e.notified=!0,Ch((function(){for(var n,r=e.reactions;n=r.get();)Qh(n,e);e.notified=!1,t&&!e.rejection&&ef(e)})))},Zh=function(e,t,n){var r,i;Yh?((r=Wh.createEvent("Event")).promise=t,r.reason=n,r.initEvent(e,!1,!0),vh.dispatchEvent(r)):r={promise:t,reason:n},!Lh&&(i=vh["on"+e])?i(r):e===qh&&function(e,t){try{1===arguments.length?console.error(e):console.error(e,t)}catch(HH){}}("Unhandled promise rejection",n)},ef=function(e){_h(Rh,vh,(function(){var t,n=e.facade,r=e.value;if(tf(e)&&(t=wh((function(){mh?Jh.emit("unhandledRejection",r,n):Zh(qh,n,r)})),e.rejection=mh||tf(e)?2:1,t.error))throw t.value}))},tf=function(e){return 1!==e.rejection&&!e.parent},nf=function(e){_h(Rh,vh,(function(){var t=e.facade;mh?Jh.emit("rejectionHandled",t):Zh("rejectionhandled",t,e.value)}))},rf=function(e,t,n){return function(r){e(t,r,n)}},af=function(e,t,n){e.done||(e.done=!0,n&&(e=n),e.value=t,e.state=2,$h(e,!0))},of=function(e,t,n){if(!e.done){e.done=!0,n&&(e=n);try{if(e.facade===t)throw new Gh("Promise can't be resolved itself");var r=Xh(t);r?Ch((function(){var n={done:!1};try{_h(r,t,rf(of,n,e),rf(af,n,e))}catch(HH){af(n,HH,e)}})):(e.value=t,e.state=1,$h(e,!1))}catch(HH){af({done:!1},HH,e)}}};if(Mh&&(Hh=(jh=function(e){bh(this,Hh),kh(e),_h(dh,this);var t=Uh(this);try{e(rf(of,t),rf(af,t))}catch(HH){af(t,HH)}}).prototype,(dh=function(e){Fh(this,{type:Ph,done:!1,notified:!1,parent:!1,reactions:new Dh,rejection:!1,state:0,value:null})}).prototype=gh(Hh,"then",(function(e,t){var n=Uh(this),r=Kh(Ah(this,jh));return n.parent=!0,r.ok=!Sh(e)||e,r.fail=Sh(t)&&t,r.domain=mh?Jh.domain:void 0,0===n.state?n.reactions.add(r):Ch((function(){Qh(r,n)})),r.promise})),hh=function(){var e=new dh,t=Uh(e);this.promise=e,this.resolve=rf(of,t),this.reject=rf(af,t)},Oh.f=Kh=function(e){return e===jh||void 0===e?new hh(e):zh(e)},Sh(xh)&&Bh!==Object.prototype)){fh=Bh.then,Vh||gh(Bh,"then",(function(e,t){var n=this;return new jh((function(e,t){_h(fh,n,e,t)})).then(e,t)}),{unsafe:!0});try{delete Bh.constructor}catch(HH){}yh&&yh(Bh,Hh)}ph({global:!0,constructor:!0,wrap:!0,forced:Mh},{Promise:jh}),Eh(jh,Ph,!1),Th(Ph);var sf=Oa,cf=vt("iterator"),uf=Array.prototype,lf=function(e){return void 0!==e&&(sf.Array===e||uf[cf]===e)},df=Ii,hf=Me,ff=K,pf=Oa,mf=vt("iterator"),vf=function(e){if(!ff(e))return hf(e,mf)||hf(e,"@@iterator")||pf[df(e)]},_f=S,gf=xe,yf=zt,Ef=Ce,Tf=vf,kf=TypeError,Sf=function(e,t){var n=arguments.length<2?Tf(e):t;if(gf(n))return yf(_f(n,e));throw new kf(Ef(e)+" is not iterable")},If=S,bf=zt,Af=Me,Rf=function(e,t,n){var r,i;bf(e);try{if(!(r=Af(e,"return"))){if("throw"===t)throw n;return n}r=If(r,e)}catch(HH){i=!0,r=HH}if("throw"===t)throw n;if(i)throw r;return bf(r),n},Cf=Fl,wf=S,Df=zt,Nf=Ce,xf=lf,Of=Rr,Pf=oe,Mf=Sf,Lf=vf,Vf=Rf,Uf=TypeError,Ff=function(e,t){this.stopped=e,this.result=t},Bf=Ff.prototype,jf=function(e,t,n){var r,i,a,o,s,c,u,l=n&&n.that,d=!(!n||!n.AS_ENTRIES),h=!(!n||!n.IS_RECORD),f=!(!n||!n.IS_ITERATOR),p=!(!n||!n.INTERRUPTED),m=Cf(t,l),v=function(e){return r&&Vf(r,"normal",e),new Ff(!0,e)},_=function(e){return d?(Df(e),p?m(e[0],e[1],v):m(e[0],e[1])):p?m(e,v):m(e)};if(h)r=e.iterator;else if(f)r=e;else{if(!(i=Lf(e)))throw new Uf(Nf(e)+" is not iterable");if(xf(i)){for(a=0,o=Of(e);o>a;a++)if((s=_(e[a]))&&Pf(Bf,s))return s;return new Ff(!1)}r=Mf(e,i)}for(c=h?e.next:r.next;!(u=wf(c,r)).done;){try{s=_(u.value)}catch(HH){Vf(r,"throw",HH)}if("object"==k(s)&&s&&Pf(Bf,s))return s}return new Ff(!1)},Hf=vt("iterator"),Gf=!1;try{var Wf=0,Jf={next:function(){return{done:!!Wf++}},return:function(){Gf=!0}};Jf[Hf]=function(){return this},Array.from(Jf,(function(){throw 2}))}catch(HH){}var Kf=function(e,t){try{if(!t&&!Gf)return!1}catch(HH){return!1}var n=!1;try{var r={};r[Hf]=function(){return{next:function(){return{done:n=!0}}}},e(r)}catch(HH){}return n},zf=zd,Yf=oh.CONSTRUCTOR||!Kf((function(e){zf.all(e).then(void 0,(function(){}))})),qf=S,Xf=xe,Qf=sh,$f=Kd,Zf=jf;vi({target:"Promise",stat:!0,forced:Yf},{all:function(e){var t=this,n=Qf.f(t),r=n.resolve,i=n.reject,a=$f((function(){var n=Xf(t.resolve),a=[],o=0,s=1;Zf(e,(function(e){var c=o++,u=!1;s++,qf(n,t,e).then((function(e){u||(u=!0,a[c]=e,--s||r(a))}),i)})),--s||r(a)}));return a.error&&i(a.value),n.promise}});var ep=vi,tp=oh.CONSTRUCTOR,np=zd,rp=ae,ip=ee,ap=hr,op=np&&np.prototype;if(ep({target:"Promise",proto:!0,forced:tp,real:!0},{catch:function(e){return this.then(void 0,e)}}),ip(np)){var sp=rp("Promise").prototype.catch;op.catch!==sp&&ap(op,"catch",sp,{unsafe:!0})}var cp=S,up=xe,lp=sh,dp=Kd,hp=jf;vi({target:"Promise",stat:!0,forced:Yf},{race:function(e){var t=this,n=lp.f(t),r=n.reject,i=dp((function(){var i=up(t.resolve);hp(e,(function(e){cp(i,t,e).then(n.resolve,r)}))}));return i.error&&r(i.value),n.promise}});var fp=sh;vi({target:"Promise",stat:!0,forced:oh.CONSTRUCTOR},{reject:function(e){var t=fp.f(this);return(0,t.reject)(e),t.promise}});var pp=zt,mp=ne,vp=sh,_p=function(e,t){if(pp(e),mp(t)&&t.constructor===e)return t;var n=vp.f(e);return(0,n.resolve)(t),n.promise},gp=vi,yp=oh.CONSTRUCTOR,Ep=_p;ae("Promise"),gp({target:"Promise",stat:!0,forced:yp},{resolve:function(e){return Ep(this,e)}});var Tp=vi,kp=zd,Sp=h,Ip=ae,bp=ee,Ap=fl,Rp=_p,Cp=hr,wp=kp&&kp.prototype;if(Tp({target:"Promise",proto:!0,real:!0,forced:!!kp&&Sp((function(){wp.finally.call({then:function(){}},(function(){}))}))},{finally:function(e){var t=Ap(this,Ip("Promise")),n=bp(e);return this.then(n?function(n){return Rp(t,e()).then((function(){return n}))}:e,n?function(n){return Rp(t,e()).then((function(){throw n}))}:e)}}),bp(kp)){var Dp=Ip("Promise").prototype.finally;wp.finally!==Dp&&Cp(wp,"finally",Dp,{unsafe:!0})}var Np=ne,xp=B,Op=vt("match"),Pp=zt,Mp=function(){var e=Pp(this),t="";return e.hasIndices&&(t+="d"),e.global&&(t+="g"),e.ignoreCase&&(t+="i"),e.multiline&&(t+="m"),e.dotAll&&(t+="s"),e.unicode&&(t+="u"),e.unicodeSets&&(t+="v"),e.sticky&&(t+="y"),t},Lp=S,Vp=nt,Up=oe,Fp=Mp,Bp=RegExp.prototype,jp=h,Hp=u.RegExp,Gp=jp((function(){var e=Hp("a","y");return e.lastIndex=2,null!==e.exec("abcd")})),Wp=Gp||jp((function(){return!Hp("a","y").sticky})),Jp=Gp||jp((function(){var e=Hp("^r","gy");return e.lastIndex=2,null!==e.exec("str")})),Kp={BROKEN_CARET:Jp,MISSED_STICKY:Wp,UNSUPPORTED_Y:Gp},zp=Ht.f,Yp=h,qp=u.RegExp,Xp=Yp((function(){var e=qp(".","s");return!(e.dotAll&&e.test("\n")&&"s"===e.flags)})),Qp=h,$p=u.RegExp,Zp=Qp((function(){var e=$p("(?<a>b)","g");return"b"!==e.exec("b").groups.a||"bc"!=="b".replace(e,"$<a>c")})),em=p,tm=u,nm=L,rm=ci,im=xc,am=cn,om=Ta,sm=fr.f,cm=oe,um=Ri,lm=Kp,dm=function(e,t,n){n in e||zp(e,n,{configurable:!0,get:function(){return t[n]},set:function(e){t[n]=e}})},hm=hr,fm=h,pm=nt,mm=Wn.enforce,vm=Fu,_m=Xp,gm=Zp,ym=vt("match"),Em=tm.RegExp,Tm=Em.prototype,km=tm.SyntaxError,Sm=nm(Tm.exec),Im=nm("".charAt),bm=nm("".replace),Am=nm("".indexOf),Rm=nm("".slice),Cm=/^\?<[^\s\d!#%&*+<=>@^][^\s!#%&*+<=>@^]*>/,wm=/a/g,Dm=/a/g,Nm=new Em(wm)!==wm,xm=lm.MISSED_STICKY,Om=lm.UNSUPPORTED_Y;if(rm("RegExp",em&&(!Nm||xm||_m||gm||fm((function(){return Dm[ym]=!1,Em(wm)!==wm||Em(Dm)===Dm||"/a/i"!==String(Em(wm,"i"))}))))){for(var Pm=function(e,t){var n,r,i,a,o,s,c=cm(Tm,this),u=function(e){var t;return Np(e)&&(void 0!==(t=e[Op])?!!t:"RegExp"===xp(e))}(e),l=void 0===t,d=[],h=e;if(!c&&u&&l&&e.constructor===Pm)return e;if((u||cm(Tm,e))&&(e=e.source,l&&(t=function(e){var t=e.flags;return void 0!==t||"flags"in Bp||Vp(e,"flags")||!Up(Bp,e)?t:Lp(Fp,e)}(h))),e=void 0===e?"":um(e),t=void 0===t?"":um(t),h=e,_m&&"dotAll"in wm&&(r=!!t&&Am(t,"s")>-1)&&(t=bm(t,/s/g,"")),n=t,xm&&"sticky"in wm&&(i=!!t&&Am(t,"y")>-1)&&Om&&(t=bm(t,/y/g,"")),gm&&(a=function(e){for(var t,n=e.length,r=0,i="",a=[],o=om(null),s=!1,c=!1,u=0,l="";r<=n;r++){if("\\"===(t=Im(e,r)))t+=Im(e,++r);else if("]"===t)s=!1;else if(!s)switch(!0){case"["===t:s=!0;break;case"("===t:if(i+=t,"?:"===Rm(e,r+1,r+3))continue;Sm(Cm,Rm(e,r+1))&&(r+=2,c=!0),u++;continue;case">"===t&&c:if(""===l||pm(o,l))throw new km("Invalid capture group name");o[l]=!0,a[a.length]=[l,u],c=!1,l="";continue}c?l+=t:i+=t}return[i,a]}(e),e=a[0],d=a[1]),o=im(Em(e,t),c?this:Tm,Pm),(r||i||d.length)&&(s=mm(o),r&&(s.dotAll=!0,s.raw=Pm(function(e){for(var t,n=e.length,r=0,i="",a=!1;r<=n;r++)"\\"!==(t=Im(e,r))?a||"."!==t?("["===t?a=!0:"]"===t&&(a=!1),i+=t):i+="[\\s\\S]":i+=t+Im(e,++r);return i}(e),n)),i&&(s.sticky=!0),d.length&&(s.groups=d)),e!==h)try{am(o,"source",""===h?"(?:)":h)}catch(HH){}return o},Mm=sm(Em),Lm=0;Mm.length>Lm;)dm(Pm,Em,Mm[Lm++]);Tm.constructor=Pm,Pm.prototype=Tm,hm(tm,"RegExp",Pm,{constructor:!0})}vm("RegExp");var Vm=S,Um=L,Fm=Ri,Bm=Mp,jm=Kp,Hm=Ta,Gm=Wn.get,Wm=Xp,Jm=Zp,Km=Xe("native-string-replace",String.prototype.replace),zm=RegExp.prototype.exec,Ym=zm,qm=Um("".charAt),Xm=Um("".indexOf),Qm=Um("".replace),$m=Um("".slice),Zm=function(){var e=/a/,t=/b*/g;return Vm(zm,e,"a"),Vm(zm,t,"a"),0!==e.lastIndex||0!==t.lastIndex}(),ev=jm.BROKEN_CARET,tv=void 0!==/()??/.exec("")[1];(Zm||tv||ev||Wm||Jm)&&(Ym=function(e){var t,n,r,i,a,o,s,c=this,u=Gm(c),l=Fm(e),d=u.raw;if(d)return d.lastIndex=c.lastIndex,t=Vm(Ym,d,l),c.lastIndex=d.lastIndex,t;var h=u.groups,f=ev&&c.sticky,p=Vm(Bm,c),m=c.source,v=0,_=l;if(f&&(p=Qm(p,"y",""),-1===Xm(p,"g")&&(p+="g"),_=$m(l,c.lastIndex),c.lastIndex>0&&(!c.multiline||c.multiline&&"\n"!==qm(l,c.lastIndex-1))&&(m="(?: "+m+")",_=" "+_,v++),n=new RegExp("^(?:"+m+")",p)),tv&&(n=new RegExp("^"+m+"$(?!\\s)",p)),Zm&&(r=c.lastIndex),i=Vm(zm,f?n:c,_),f?i?(i.input=$m(i.input,v),i[0]=$m(i[0],v),i.index=c.lastIndex,c.lastIndex+=i[0].length):c.lastIndex=0:Zm&&i&&(c.lastIndex=c.global?i.index+i[0].length:r),tv&&i&&i.length>1&&Vm(Km,i[0],n,(function(){for(a=1;a<arguments.length-2;a++)void 0===arguments[a]&&(i[a]=void 0)})),i&&h)for(i.groups=o=Hm(null),a=0;a<h.length;a++)o[(s=h[a])[0]]=i[s[1]];return i});var nv=Ym;vi({target:"RegExp",proto:!0,forced:/./.exec!==nv},{exec:nv});var rv=gr,iv=Ri,av=q,ov=RangeError,sv=L,cv=br,uv=Ri,lv=q,dv=sv((function(e){var t=iv(av(this)),n="",r=rv(e);if(r<0||Infinity===r)throw new ov("Wrong number of repetitions");for(;r>0;(r>>>=1)&&(t+=t))1&r&&(n+=t);return n})),hv=sv("".slice),fv=Math.ceil,pv=function(e){return function(t,n,r){var i,a,o=uv(lv(t)),s=cv(n),c=o.length,u=void 0===r?" ":uv(r);return s<=c||""===u?o:((a=dv(u,fv((i=s-c)/u.length))).length>i&&(a=hv(a,0,i)),e?o+a:a+o)}},mv={start:pv(!1),end:pv(!0)},vv=/Version\/10(?:\.\d+){1,2}(?: [\w./]+)?(?: Mobile\/\w+)? Safari\//.test(ue),_v=mv.start;vi({target:"String",proto:!0,forced:vv},{padStart:function(e){return _v(this,e,arguments.length>1?arguments[1]:void 0)}});var gv=S,yv=hr,Ev=nv,Tv=h,kv=vt,Sv=cn,Iv=kv("species"),bv=RegExp.prototype,Av=L,Rv=gr,Cv=Ri,wv=q,Dv=Av("".charAt),Nv=Av("".charCodeAt),xv=Av("".slice),Ov=function(e){return function(t,n){var r,i,a=Cv(wv(t)),o=Rv(n),s=a.length;return o<0||o>=s?e?"":void 0:(r=Nv(a,o))<55296||r>56319||o+1===s||(i=Nv(a,o+1))<56320||i>57343?e?Dv(a,o):r:e?xv(a,o,o+2):i-56320+(r-55296<<10)+65536}},Pv={codeAt:Ov(!1),charAt:Ov(!0)},Mv=Pv.charAt,Lv=L,Vv=Ze,Uv=Math.floor,Fv=Lv("".charAt),Bv=Lv("".replace),jv=Lv("".slice),Hv=/\$([$&'`]|\d{1,2}|<[^>]*>)/g,Gv=/\$([$&'`]|\d{1,2})/g,Wv=S,Jv=zt,Kv=ee,zv=B,Yv=nv,qv=TypeError,Xv=Ml,Qv=S,$v=L,Zv=h,e_=zt,t_=ee,n_=K,r_=gr,i_=br,a_=Ri,o_=q,s_=function(e,t,n){return t+(n?Mv(e,t).length:1)},c_=Me,u_=function(e,t,n,r,i,a){var o=n+e.length,s=r.length,c=Gv;return void 0!==i&&(i=Vv(i),c=Hv),Bv(a,c,(function(a,c){var u;switch(Fv(c,0)){case"$":return"$";case"&":return e;case"`":return jv(t,0,n);case"'":return jv(t,o);case"<":u=i[jv(c,1,-1)];break;default:var l=+c;if(0===l)return a;if(l>s){var d=Uv(l/10);return 0===d?a:d<=s?void 0===r[d-1]?Fv(c,1):r[d-1]+Fv(c,1):a}u=r[l-1]}return void 0===u?"":u}))},l_=function(e,t){var n=e.exec;if(Kv(n)){var r=Wv(n,e,t);return null!==r&&Jv(r),r}if("RegExp"===zv(e))return Wv(Yv,e,t);throw new qv("RegExp#exec called on incompatible receiver")},d_=vt("replace"),h_=Math.max,f_=Math.min,p_=$v([].concat),m_=$v([].push),v_=$v("".indexOf),__=$v("".slice),g_=function(e){return void 0===e?e:String(e)},y_="$0"==="a".replace(/./,"$0"),E_=!!/./[d_]&&""===/./[d_]("a","$0"),T_=!Zv((function(){var e=/./;return e.exec=function(){var e=[];return e.groups={a:"7"},e},"7"!=="".replace(e,"$<a>")}));!function(e,t,n,r){var i=kv(e),a=!Tv((function(){var t={};return t[i]=function(){return 7},7!==""[e](t)})),o=a&&!Tv((function(){var t=!1,n=/a/;return"split"===e&&((n={}).constructor={},n.constructor[Iv]=function(){return n},n.flags="",n[i]=/./[i]),n.exec=function(){return t=!0,null},n[i](""),!t}));if(!a||!o||n){var s=/./[i],c=t(i,""[e],(function(e,t,n,r,i){var o=t.exec;return o===Ev||o===bv.exec?a&&!i?{done:!0,value:gv(s,t,n,r)}:{done:!0,value:gv(e,n,t,r)}:{done:!1}}));yv(String.prototype,e,c[0]),yv(bv,i,c[1])}r&&Sv(bv[i],"sham",!0)}("replace",(function(e,t,n){var r=E_?"$":"$0";return[function(e,n){var r=o_(this),i=n_(e)?void 0:c_(e,d_);return i?Qv(i,e,r,n):Qv(t,a_(r),e,n)},function(e,i){var a=e_(this),o=a_(e);if("string"==typeof i&&-1===v_(i,r)&&-1===v_(i,"$<")){var s=n(t,a,o,i);if(s.done)return s.value}var c=t_(i);c||(i=a_(i));var u,l=a.global;l&&(u=a.unicode,a.lastIndex=0);for(var d,h=[];null!==(d=l_(a,o))&&(m_(h,d),l);)""===a_(d[0])&&(a.lastIndex=s_(o,i_(a.lastIndex),u));for(var f="",p=0,m=0;m<h.length;m++){for(var v,_=a_((d=h[m])[0]),g=h_(f_(r_(d.index),o.length),0),y=[],E=1;E<d.length;E++)m_(y,g_(d[E]));var T=d.groups;if(c){var k=p_([_],y,g,o);void 0!==T&&m_(k,T),v=a_(Xv(i,void 0,k))}else v=u_(_,o,g,y,T,i);g>=p&&(f+=__(o,p,g)+v,p=g+_.length)}return f+__(o,p)}]}),!T_||!y_||E_);var k_="\t\n\v\f\r \u2028\u2029\ufeff",S_=q,I_=Ri,b_=k_,A_=L("".replace),R_=RegExp("^["+b_+"]+"),C_=RegExp("(^|[^"+b_+"])["+b_+"]+$"),w_=function(e){return function(t){var n=I_(S_(t));return 1&e&&(n=A_(n,R_,"")),2&e&&(n=A_(n,C_,"$1")),n}},D_={start:w_(1),end:w_(2),trim:w_(3)},N_=vn.PROPER,x_=h,O_=k_,P_=D_.trim;vi({target:"String",proto:!0,forced:function(e){return x_((function(){return!!O_[e]()||"
"!=="
"[e]()||N_&&O_[e].name!==e}))}("trim")},{trim:function(){return P_(this)}});var M_,L_,V_,U_={},F_={get exports(){return U_},set exports(e){U_=e}},B_=nc,j_=p,H_=u,G_=ee,W_=ne,J_=nt,K_=Ii,z_=Ce,Y_=cn,q_=hr,X_=Di,Q_=oe,$_=Ha,Z_=go,eg=vt,tg=st,ng=Wn.enforce,rg=Wn.get,ig=H_.Int8Array,ag=ig&&ig.prototype,og=H_.Uint8ClampedArray,sg=og&&og.prototype,cg=ig&&$_(ig),ug=ag&&$_(ag),lg=Object.prototype,dg=H_.TypeError,hg=eg("toStringTag"),fg=tg("TYPED_ARRAY_TAG"),pg="TypedArrayConstructor",mg=B_&&!!Z_&&"Opera"!==K_(H_.opera),vg=!1,_g={Int8Array:1,Uint8Array:1,Uint8ClampedArray:1,Int16Array:2,Uint16Array:2,Int32Array:4,Uint32Array:4,Float32Array:4,Float64Array:8},gg={BigInt64Array:8,BigUint64Array:8},yg=function(e){var t=$_(e);if(W_(t)){var n=rg(t);return n&&J_(n,pg)?n[pg]:yg(t)}},Eg=function(e){if(!W_(e))return!1;var t=K_(e);return J_(_g,t)||J_(gg,t)};for(M_ in _g)(V_=(L_=H_[M_])&&L_.prototype)?ng(V_)[pg]=L_:mg=!1;for(M_ in gg)(V_=(L_=H_[M_])&&L_.prototype)&&(ng(V_)[pg]=L_);if((!mg||!G_(cg)||cg===Function.prototype)&&(cg=function(){throw new dg("Incorrect invocation")},mg))for(M_ in _g)H_[M_]&&Z_(H_[M_],cg);if((!mg||!ug||ug===lg)&&(ug=cg.prototype,mg))for(M_ in _g)H_[M_]&&Z_(H_[M_].prototype,ug);if(mg&&$_(sg)!==ug&&Z_(sg,ug),j_&&!J_(ug,hg))for(M_ in vg=!0,X_(ug,hg,{configurable:!0,get:function(){return W_(this)?this[fg]:void 0}}),_g)H_[M_]&&Y_(H_[M_],fg,M_);var Tg={NATIVE_ARRAY_BUFFER_VIEWS:mg,TYPED_ARRAY_TAG:vg&&fg,aTypedArray:function(e){if(Eg(e))return e;throw new dg("Target is not a typed array")},aTypedArrayConstructor:function(e){if(G_(e)&&(!Z_||Q_(cg,e)))return e;throw new dg(z_(e)+" is not a typed array constructor")},exportTypedArrayMethod:function(e,t,n,r){if(j_){if(n)for(var i in _g){var a=H_[i];if(a&&J_(a.prototype,e))try{delete a.prototype[e]}catch(HH){try{a.prototype[e]=t}catch(p){}}}ug[e]&&!n||q_(ug,e,n?t:mg&&ag[e]||t,r)}},exportTypedArrayStaticMethod:function(e,t,n){var r,i;if(j_){if(Z_){if(n)for(r in _g)if((i=H_[r])&&J_(i,e))try{delete i[e]}catch(HH){}if(cg[e]&&!n)return;try{return q_(cg,e,n?t:mg&&cg[e]||t)}catch(HH){}}for(r in _g)!(i=H_[r])||i[e]&&!n||q_(i,e,t)}},getTypedArrayConstructor:yg,isView:function(e){if(!W_(e))return!1;var t=K_(e);return"DataView"===t||J_(_g,t)||J_(gg,t)},isTypedArray:Eg,TypedArray:cg,TypedArrayPrototype:ug},kg=u,Sg=h,Ig=Kf,bg=Tg.NATIVE_ARRAY_BUFFER_VIEWS,Ag=kg.ArrayBuffer,Rg=kg.Int8Array,Cg=!bg||!Sg((function(){Rg(1)}))||!Sg((function(){new Rg(-1)}))||!Ig((function(e){new Rg,new Rg(null),new Rg(1.5),new Rg(e)}),!0)||Sg((function(){return 1!==new Rg(new Ag(2),1,void 0).length})),wg=ne,Dg=Math.floor,Ng=Number.isInteger||function(e){return!wg(e)&&isFinite(e)&&Dg(e)===e},xg=gr,Og=RangeError,Pg=RangeError,Mg=function(e,t){var n=function(e){var t=xg(e);if(t<0)throw new Og("The argument can't be less than 0");return t}(e);if(n%t)throw new Pg("Wrong offset");return n},Lg=Math.round,Vg=Ii,Ug=St,Fg=TypeError,Bg=function(e){var t=Ug(e,"number");if("number"==typeof t)throw new Fg("Can't convert number to bigint");return BigInt(t)},jg=Fl,Hg=S,Gg=cl,Wg=Ze,Jg=Rr,Kg=Sf,zg=vf,Yg=lf,qg=Tg.aTypedArrayConstructor,Xg=Bg,Qg=function(e){var t,n,r,i,a,o,s,c,u=Gg(this),l=Wg(e),d=arguments.length,h=d>1?arguments[1]:void 0,f=void 0!==h,p=zg(l);if(p&&!Yg(p))for(c=(s=Kg(l,p)).next,l=[];!(o=Hg(c,s)).done;)l.push(o.value);for(f&&d>2&&(h=jg(h,arguments[2])),n=Jg(l),i=function(e){var t=Vg(e);return"BigInt64Array"===t||"BigUint64Array"===t}(r=new(qg(u))(n)),t=0;n>t;t++)a=f?h(l[t],t):l[t],r[t]=i?Xg(a):+a;return r},$g=gs,Zg=il,ey=ne,ty=vt("species"),ny=Array,ry=Fl,iy=J,ay=Ze,oy=Rr,sy=function(e,t){return new(function(e){var t;return $g(e)&&(t=e.constructor,(Zg(t)&&(t===ny||$g(t.prototype))||ey(t)&&null===(t=t[ty]))&&(t=void 0)),void 0===t?ny:t}(e))(0===t?0:t)},cy=L([].push),uy=function(e){var t=1===e,n=2===e,r=3===e,i=4===e,a=6===e,o=7===e,s=5===e||a;return function(c,u,l,d){for(var h,f,p=ay(c),m=iy(p),v=oy(m),_=ry(u,l),g=0,y=d||sy,E=t?y(c,v):n||o?y(c,0):void 0;v>g;g++)if((s||g in m)&&(f=_(h=m[g],g,p),e))if(t)E[g]=f;else if(f)switch(e){case 3:return!0;case 5:return h;case 6:return g;case 2:cy(E,h)}else switch(e){case 4:return!1;case 7:cy(E,h)}return a?-1:r||i?i:E}},ly={forEach:uy(0),map:uy(1),filter:uy(2),some:uy(3),every:uy(4),find:uy(5),findIndex:uy(6),filterReject:uy(7)},dy=Rr,hy=vi,fy=u,py=S,my=p,vy=Cg,_y=Tg,gy=Pu,yy=sc,Ey=N,Ty=cn,ky=Ng,Sy=br,Iy=dc,by=Mg,Ay=At,Ry=nt,Cy=Ii,wy=ne,Dy=Ae,Ny=Ta,xy=oe,Oy=go,Py=fr.f,My=Qg,Ly=ly.forEach,Vy=Fu,Uy=Di,Fy=Ht,By=l,jy=function(e,t,n){for(var r=0,i=arguments.length>2?n:dy(t),a=new e(i);i>r;)a[r]=t[r++];return a},Hy=xc,Gy=Wn.get,Wy=Wn.set,Jy=Wn.enforce,Ky=Fy.f,zy=By.f,Yy=fy.RangeError,qy=gy.ArrayBuffer,Xy=qy.prototype,Qy=gy.DataView,$y=_y.NATIVE_ARRAY_BUFFER_VIEWS,Zy=_y.TYPED_ARRAY_TAG,eE=_y.TypedArray,tE=_y.TypedArrayPrototype,nE=_y.isTypedArray,rE="BYTES_PER_ELEMENT",iE="Wrong length",aE=function(e,t){Uy(e,t,{configurable:!0,get:function(){return Gy(this)[t]}})},oE=function(e){var t;return xy(Xy,e)||"ArrayBuffer"===(t=Cy(e))||"SharedArrayBuffer"===t},sE=function(e,t){return nE(e)&&!Dy(t)&&t in e&&ky(+t)&&t>=0},cE=function(e,t){return t=Ay(t),sE(e,t)?Ey(2,e[t]):zy(e,t)},uE=function(e,t,n){return t=Ay(t),!(sE(e,t)&&wy(n)&&Ry(n,"value"))||Ry(n,"get")||Ry(n,"set")||n.configurable||Ry(n,"writable")&&!n.writable||Ry(n,"enumerable")&&!n.enumerable?Ky(e,t,n):(e[t]=n.value,e)};my?($y||(By.f=cE,Fy.f=uE,aE(tE,"buffer"),aE(tE,"byteOffset"),aE(tE,"byteLength"),aE(tE,"length")),hy({target:"Object",stat:!0,forced:!$y},{getOwnPropertyDescriptor:cE,defineProperty:uE}),F_.exports=function(e,t,n){var r=e.match(/\d+/)[0]/8,i=e+(n?"Clamped":"")+"Array",a="get"+e,o="set"+e,s=fy[i],c=s,u=c&&c.prototype,l={},d=function(e,t){Ky(e,t,{get:function(){return function(e,t){var n=Gy(e);return n.view[a](t*r+n.byteOffset,!0)}(this,t)},set:function(e){return function(e,t,i){var a=Gy(e);a.view[o](t*r+a.byteOffset,n?function(e){var t=Lg(e);return t<0?0:t>255?255:255&t}(i):i,!0)}(this,t,e)},enumerable:!0})};$y?vy&&(c=t((function(e,t,n,i){return yy(e,u),Hy(wy(t)?oE(t)?void 0!==i?new s(t,by(n,r),i):void 0!==n?new s(t,by(n,r)):new s(t):nE(t)?jy(c,t):py(My,c,t):new s(Iy(t)),e,c)})),Oy&&Oy(c,eE),Ly(Py(s),(function(e){e in c||Ty(c,e,s[e])})),c.prototype=u):(c=t((function(e,t,n,i){yy(e,u);var a,o,s,l=0,h=0;if(wy(t)){if(!oE(t))return nE(t)?jy(c,t):py(My,c,t);a=t,h=by(n,r);var f=t.byteLength;if(void 0===i){if(f%r)throw new Yy(iE);if((o=f-h)<0)throw new Yy(iE)}else if((o=Sy(i)*r)+h>f)throw new Yy(iE);s=o/r}else s=Iy(t),a=new qy(o=s*r);for(Wy(e,{buffer:a,byteOffset:h,byteLength:o,length:s,view:new Qy(a)});l<s;)d(e,l++)})),Oy&&Oy(c,eE),u=c.prototype=Ny(tE)),u.constructor!==c&&Ty(u,"constructor",c),Jy(u).TypedArrayConstructor=c,Zy&&Ty(u,Zy,i);var h=c!==s;l[i]=c,hy({global:!0,constructor:!0,forced:h,sham:!$y},l),rE in c||Ty(c,rE,r),rE in u||Ty(u,rE,r),Vy(i)}):F_.exports=function(){},U_("Float32",(function(e){return function(t,n,r){return e(this,t,n,r)}})),U_("Uint8",(function(e){return function(t,n,r){return e(this,t,n,r)}}));var lE=Cc,dE=Bg,hE=Ii,fE=S,pE=h,mE=Tg.aTypedArray,vE=Tg.exportTypedArrayMethod,_E=L("".slice);vE("fill",(function(e){var t=arguments.length;mE(this);var n="Big"===_E(hE(this),0,3)?dE(e):+e;return fE(lE,this,n,t>1?arguments[1]:void 0,t>2?arguments[2]:void 0)}),pE((function(){var e=0;return new Int8Array(2).fill({valueOf:function(){return e++}}),1!==e}))),(0,Tg.exportTypedArrayStaticMethod)("from",Qg,Cg);var gE=u,yE=S,EE=Tg,TE=Rr,kE=Mg,SE=Ze,IE=h,bE=gE.RangeError,AE=gE.Int8Array,RE=AE&&AE.prototype,CE=RE&&RE.set,wE=EE.aTypedArray,DE=EE.exportTypedArrayMethod,NE=!IE((function(){var e=new Uint8ClampedArray(2);return yE(CE,e,{length:1,0:3},1),3!==e[1]})),xE=NE&&EE.NATIVE_ARRAY_BUFFER_VIEWS&&IE((function(){var e=new AE(2);return e.set(1),e.set("2",1),0!==e[0]||2!==e[1]}));DE("set",(function(e){wE(this);var t=kE(arguments.length>1?arguments[1]:void 0,1),n=SE(e);if(NE)return yE(CE,this,n,t);var r=this.length,i=TE(n),a=0;if(i+t>r)throw new bE("Wrong length");for(;a<i;)this[t+a]=n[a++]}),!NE||xE);var OE=Ju,PE=h,ME=xe,LE=ws,VE=Ns,UE=xs,FE=ve,BE=Ps,jE=Tg.aTypedArray,HE=Tg.exportTypedArrayMethod,GE=u.Uint16Array,WE=GE&&OE(GE.prototype.sort),JE=!(!WE||PE((function(){WE(new GE(2),null)}))&&PE((function(){WE(new GE(2),{})}))),KE=!!WE&&!PE((function(){if(FE)return FE<74;if(VE)return VE<67;if(UE)return!0;if(BE)return BE<602;var e,t,n=new GE(516),r=Array(516);for(e=0;e<516;e++)t=e%4,n[e]=515-e,r[e]=e-2*t+3;for(WE(n,(function(e,t){return(e/4|0)-(t/4|0)})),e=0;e<516;e++)if(n[e]!==r[e])return!0}));HE("sort",(function(e){return void 0!==e&&ME(e),KE?WE(this,e):LE(jE(this),function(e){return function(t,n){return void 0!==e?+e(t,n)||0:n!=n?-1:t!=t?1:0===t&&0===n?1/t>0&&1/n<0?1:-1:t>n}}(e))}),!KE||JE);var zE={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},YE=Dt("span").classList,qE=YE&&YE.constructor&&YE.constructor.prototype,XE=qE===Object.prototype?void 0:qE,QE=ly.forEach,$E=cs("forEach")?[].forEach:function(e){return QE(this,e,arguments.length>1?arguments[1]:void 0)},ZE=u,eT=zE,tT=XE,nT=$E,rT=cn,iT=function(e){if(e&&e.forEach!==nT)try{rT(e,"forEach",nT)}catch(HH){e.forEach=nT}};for(var aT in eT)eT[aT]&&iT(ZE[aT]&&ZE[aT].prototype);iT(tT);var oT=u,sT=zE,cT=XE,uT=Qo,lT=cn,dT=to,hT=vt("iterator"),fT=uT.values,pT=function(e,t){if(e){if(e[hT]!==fT)try{lT(e,hT,fT)}catch(HH){e[hT]=fT}if(dT(e,t,!0),sT[t])for(var n in uT)if(e[n]!==uT[n])try{lT(e,n,uT[n])}catch(HH){e[n]=uT[n]}}};for(var mT in sT)pT(oT[mT]&&oT[mT].prototype,mT);pT(cT,"DOMTokenList");var vT=Pv.charAt,_T=Ri,gT=Wn,yT=Uo,ET=Fo,TT="String Iterator",kT=gT.set,ST=gT.getterFor(TT);yT(String,"String",(function(e){kT(this,{type:TT,string:_T(e),index:0})}),(function(){var e,t=ST(this),n=t.string,r=t.index;return r>=n.length?ET(void 0,!0):(e=vT(n,r),t.index+=e.length,ET(e,!1))}));var IT=h,bT=p,AT=vt("iterator"),RT=!IT((function(){var e=new URL("b?a=1&b=2&c=3","https://a"),t=e.searchParams,n=new URLSearchParams("a=1&a=2&b=3"),r="";return e.pathname="c%20d",t.forEach((function(e,n){t.delete("b"),r+=n+e})),n.delete("a",2),n.delete("b",void 0),!t.size&&!bT||!t.sort||"https://a/c%20d?a=1&c=3"!==e.href||"3"!==t.get("c")||"a=1"!==String(new URLSearchParams("?a=1"))||!t[AT]||"a"!==new URL("https://a@b").username||"b"!==new URLSearchParams(new URLSearchParams("a=b")).get("a")||"xn--e1aybc"!==new URL("https://тест").host||"#%D0%B1"!==new URL("https://a#б").hash||"a1c3"!==r||"x"!==new URL("https://x",void 0).host})),CT=p,wT=L,DT=S,NT=h,xT=Zi,OT=Hr,PT=b,MT=Ze,LT=J,VT=Object.assign,UT=Object.defineProperty,FT=wT([].concat),BT=!VT||NT((function(){if(CT&&1!==VT({b:1},VT(UT({},"a",{enumerable:!0,get:function(){UT(this,"b",{value:3,enumerable:!1})}}),{b:2})).b)return!0;var e={},t={},n=Symbol("assign detection"),r="abcdefghijklmnopqrst";return e[n]=7,r.split("").forEach((function(e){t[e]=e})),7!==VT({},e)[n]||xT(VT({},t)).join("")!==r}))?function(e,t){for(var n=MT(e),r=arguments.length,i=1,a=OT.f,o=PT.f;r>i;)for(var s,c=LT(arguments[i++]),u=a?FT(xT(c),a(c)):xT(c),l=u.length,d=0;l>d;)s=u[d++],CT&&!DT(o,c,s)||(n[s]=c[s]);return n}:VT,jT=zt,HT=Rf,GT=p,WT=Ht,JT=N,KT=Fl,zT=S,YT=Ze,qT=function(e,t,n,r){try{return r?t(jT(n)[0],n[1]):t(n)}catch(HH){HT(e,"throw",HH)}},XT=lf,QT=il,$T=Rr,ZT=function(e,t,n){GT?WT.f(e,t,JT(0,n)):e[t]=n},ek=Sf,tk=vf,nk=Array,rk=L,ik=2147483647,ak=/[^\0-\u007E]/,ok=/[.\u3002\uFF0E\uFF61]/g,sk="Overflow: input needs wider integers to process",ck=RangeError,uk=rk(ok.exec),lk=Math.floor,dk=String.fromCharCode,hk=rk("".charCodeAt),fk=rk([].join),pk=rk([].push),mk=rk("".replace),vk=rk("".split),_k=rk("".toLowerCase),gk=function(e){return e+22+75*(e<26)},yk=function(e,t,n){var r=0;for(e=n?lk(e/700):e>>1,e+=lk(e/t);e>455;)e=lk(e/35),r+=36;return lk(r+36*e/(e+38))},Ek=function(e){var t=[];e=function(e){for(var t=[],n=0,r=e.length;n<r;){var i=hk(e,n++);if(i>=55296&&i<=56319&&n<r){var a=hk(e,n++);56320==(64512&a)?pk(t,((1023&i)<<10)+(1023&a)+65536):(pk(t,i),n--)}else pk(t,i)}return t}(e);var n,r,i=e.length,a=128,o=0,s=72;for(n=0;n<e.length;n++)(r=e[n])<128&&pk(t,dk(r));var c=t.length,u=c;for(c&&pk(t,"-");u<i;){var l=ik;for(n=0;n<e.length;n++)(r=e[n])>=a&&r<l&&(l=r);var d=u+1;if(l-a>lk((ik-o)/d))throw new ck(sk);for(o+=(l-a)*d,a=l,n=0;n<e.length;n++){if((r=e[n])<a&&++o>ik)throw new ck(sk);if(r===a){for(var h=o,f=36;;){var p=f<=s?1:f>=s+26?26:f-s;if(h<p)break;var m=h-p,v=36-p;pk(t,dk(gk(p+m%v))),h=lk(m/v),f+=36}pk(t,dk(gk(h))),s=yk(o,d,u===c),o=0,u++}}o++,a++}return fk(t,"")},Tk=vi,kk=L,Sk=kr,Ik=RangeError,bk=String.fromCharCode,Ak=String.fromCodePoint,Rk=kk([].join);Tk({target:"String",stat:!0,arity:1,forced:!!Ak&&1!==Ak.length},{fromCodePoint:function(e){for(var t,n=[],r=arguments.length,i=0;r>i;){if(t=+arguments[i++],Sk(t,1114111)!==t)throw new Ik(t+" is not a valid code point");n[i]=t<65536?bk(t):bk(55296+((t-=65536)>>10),t%1024+56320)}return Rk(n,"")}});var Ck=vi,wk=u,Dk=yd,Nk=ae,xk=S,Ok=L,Pk=p,Mk=RT,Lk=hr,Vk=Di,Uk=ic,Fk=to,Bk=co,jk=Wn,Hk=sc,Gk=ee,Wk=nt,Jk=Fl,Kk=Ii,zk=zt,Yk=ne,qk=Ri,Xk=Ta,Qk=N,$k=Sf,Zk=vf,eS=Fo,tS=jl,nS=ws,rS=vt("iterator"),iS="URLSearchParams",aS=iS+"Iterator",oS=jk.set,sS=jk.getterFor(iS),cS=jk.getterFor(aS),uS=Dk("fetch"),lS=Dk("Request"),dS=Dk("Headers"),hS=lS&&lS.prototype,fS=dS&&dS.prototype,pS=wk.TypeError,mS=wk.encodeURIComponent,vS=String.fromCharCode,_S=Nk("String","fromCodePoint"),gS=parseInt,yS=Ok("".charAt),ES=Ok([].join),TS=Ok([].push),kS=Ok("".replace),SS=Ok([].shift),IS=Ok([].splice),bS=Ok("".split),AS=Ok("".slice),RS=Ok(/./.exec),CS=/\+/g,wS=/^[0-9a-f]+$/i,DS=function(e,t){var n=AS(e,t,t+2);return RS(wS,n)?gS(n,16):NaN},NS=function(e){for(var t=0,n=128;n>0&&e&n;n>>=1)t++;return t},xS=function(e){var t=null;switch(e.length){case 1:t=e[0];break;case 2:t=(31&e[0])<<6|63&e[1];break;case 3:t=(15&e[0])<<12|(63&e[1])<<6|63&e[2];break;case 4:t=(7&e[0])<<18|(63&e[1])<<12|(63&e[2])<<6|63&e[3]}return t>1114111?null:t},OS=function(e){for(var t=(e=kS(e,CS," ")).length,n="",r=0;r<t;){var i=yS(e,r);if("%"===i){if("%"===yS(e,r+1)||r+3>t){n+="%",r++;continue}var a=DS(e,r+1);if(a!=a){n+=i,r++;continue}r+=2;var o=NS(a);if(0===o)i=vS(a);else{if(1===o||o>4){n+="�",r++;continue}for(var s=[a],c=1;c<o&&!(3+ ++r>t||"%"!==yS(e,r));){var u=DS(e,r+1);if(u!=u){r+=3;break}if(u>191||u<128)break;TS(s,u),r+=2,c++}if(s.length!==o){n+="�";continue}var l=xS(s);null===l?n+="�":i=_S(l)}}n+=i,r++}return n},PS=/[!'()~]|%20/g,MS={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+"},LS=function(e){return MS[e]},VS=function(e){return kS(mS(e),PS,LS)},US=Bk((function(e,t){oS(this,{type:aS,target:sS(e).entries,index:0,kind:t})}),iS,(function(){var e=cS(this),t=e.target,n=e.index++;if(!t||n>=t.length)return e.target=null,eS(void 0,!0);var r=t[n];switch(e.kind){case"keys":return eS(r.key,!1);case"values":return eS(r.value,!1)}return eS([r.key,r.value],!1)}),!0),FS=function(e){this.entries=[],this.url=null,void 0!==e&&(Yk(e)?this.parseObject(e):this.parseQuery("string"==typeof e?"?"===yS(e,0)?AS(e,1):e:qk(e)))};FS.prototype={type:iS,bindURL:function(e){this.url=e,this.update()},parseObject:function(e){var t,n,r,i,a,o,s,c=this.entries,u=Zk(e);if(u)for(n=(t=$k(e,u)).next;!(r=xk(n,t)).done;){if(a=(i=$k(zk(r.value))).next,(o=xk(a,i)).done||(s=xk(a,i)).done||!xk(a,i).done)throw new pS("Expected sequence with length 2");TS(c,{key:qk(o.value),value:qk(s.value)})}else for(var l in e)Wk(e,l)&&TS(c,{key:l,value:qk(e[l])})},parseQuery:function(e){if(e)for(var t,n,r=this.entries,i=bS(e,"&"),a=0;a<i.length;)(t=i[a++]).length&&(n=bS(t,"="),TS(r,{key:OS(SS(n)),value:OS(ES(n,"="))}))},serialize:function(){for(var e,t=this.entries,n=[],r=0;r<t.length;)e=t[r++],TS(n,VS(e.key)+"="+VS(e.value));return ES(n,"&")},update:function(){this.entries.length=0,this.parseQuery(this.url.query)},updateURL:function(){this.url&&this.url.update()}};var BS=function(){Hk(this,jS);var e=oS(this,new FS(arguments.length>0?arguments[0]:void 0));Pk||(this.size=e.entries.length)},jS=BS.prototype;if(Uk(jS,{append:function(e,t){var n=sS(this);tS(arguments.length,2),TS(n.entries,{key:qk(e),value:qk(t)}),Pk||this.length++,n.updateURL()},delete:function(e){for(var t=sS(this),n=tS(arguments.length,1),r=t.entries,i=qk(e),a=n<2?void 0:arguments[1],o=void 0===a?a:qk(a),s=0;s<r.length;){var c=r[s];if(c.key!==i||void 0!==o&&c.value!==o)s++;else if(IS(r,s,1),void 0!==o)break}Pk||(this.size=r.length),t.updateURL()},get:function(e){var t=sS(this).entries;tS(arguments.length,1);for(var n=qk(e),r=0;r<t.length;r++)if(t[r].key===n)return t[r].value;return null},getAll:function(e){var t=sS(this).entries;tS(arguments.length,1);for(var n=qk(e),r=[],i=0;i<t.length;i++)t[i].key===n&&TS(r,t[i].value);return r},has:function(e){for(var t=sS(this).entries,n=tS(arguments.length,1),r=qk(e),i=n<2?void 0:arguments[1],a=void 0===i?i:qk(i),o=0;o<t.length;){var s=t[o++];if(s.key===r&&(void 0===a||s.value===a))return!0}return!1},set:function(e,t){var n=sS(this);tS(arguments.length,1);for(var r,i=n.entries,a=!1,o=qk(e),s=qk(t),c=0;c<i.length;c++)(r=i[c]).key===o&&(a?IS(i,c--,1):(a=!0,r.value=s));a||TS(i,{key:o,value:s}),Pk||(this.size=i.length),n.updateURL()},sort:function(){var e=sS(this);nS(e.entries,(function(e,t){return e.key>t.key?1:-1})),e.updateURL()},forEach:function(e){for(var t,n=sS(this).entries,r=Jk(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 US(this,"keys")},values:function(){return new US(this,"values")},entries:function(){return new US(this,"entries")}},{enumerable:!0}),Lk(jS,rS,jS.entries,{name:"entries"}),Lk(jS,"toString",(function(){return sS(this).serialize()}),{enumerable:!0}),Pk&&Vk(jS,"size",{get:function(){return sS(this).entries.length},configurable:!0,enumerable:!0}),Fk(BS,iS),Ck({global:!0,constructor:!0,forced:!Mk},{URLSearchParams:BS}),!Mk&&Gk(dS)){var HS=Ok(fS.has),GS=Ok(fS.set),WS=function(e){if(Yk(e)){var t,n=e.body;if(Kk(n)===iS)return t=e.headers?new dS(e.headers):new dS,HS(t,"content-type")||GS(t,"content-type","application/x-www-form-urlencoded;charset=UTF-8"),Xk(e,{body:Qk(0,qk(n)),headers:Qk(0,t)})}return e};if(Gk(uS)&&Ck({global:!0,enumerable:!0,dontCallGetSet:!0,forced:!0},{fetch:function(e){return uS(e,arguments.length>1?WS(arguments[1]):{})}}),Gk(lS)){var JS=function(e){return Hk(this,hS),new lS(e,arguments.length>1?WS(arguments[1]):{})};hS.constructor=JS,JS.prototype=hS,Ck({global:!0,constructor:!0,dontCallGetSet:!0,forced:!0},{Request:JS})}}var KS,zS=vi,YS=p,qS=RT,XS=u,QS=Fl,$S=L,ZS=hr,eI=Di,tI=sc,nI=nt,rI=BT,iI=function(e){var t=YT(e),n=QT(this),r=arguments.length,i=r>1?arguments[1]:void 0,a=void 0!==i;a&&(i=KT(i,r>2?arguments[2]:void 0));var o,s,c,u,l,d,h=tk(t),f=0;if(!h||this===nk&&XT(h))for(o=$T(t),s=n?new this(o):nk(o);o>f;f++)d=a?i(t[f],f):t[f],ZT(s,f,d);else for(s=n?new this:[],l=(u=ek(t,h)).next;!(c=zT(l,u)).done;f++)d=a?qT(u,i,[c.value,f],!0):c.value,ZT(s,f,d);return s.length=f,s},aI=bs,oI=Pv.codeAt,sI=Ri,cI=to,uI=jl,lI={URLSearchParams:BS,getState:sS},dI=Wn,hI=dI.set,fI=dI.getterFor("URL"),pI=lI.URLSearchParams,mI=lI.getState,vI=XS.URL,_I=XS.TypeError,gI=XS.parseInt,yI=Math.floor,EI=Math.pow,TI=$S("".charAt),kI=$S(/./.exec),SI=$S([].join),II=$S(1..toString),bI=$S([].pop),AI=$S([].push),RI=$S("".replace),CI=$S([].shift),wI=$S("".split),DI=$S("".slice),NI=$S("".toLowerCase),xI=$S([].unshift),OI="Invalid scheme",PI="Invalid host",MI="Invalid port",LI=/[a-z]/i,VI=/[\d+-.a-z]/i,UI=/\d/,FI=/^0x/i,BI=/^[0-7]+$/,jI=/^\d+$/,HI=/^[\da-f]+$/i,GI=/[\0\t\n\r #%/:<>?@[\\\]^|]/,WI=/[\0\t\n\r #/:<>?@[\\\]^|]/,JI=/^[\u0000-\u0020]+/,KI=/(^|[^\u0000-\u0020])[\u0000-\u0020]+$/,zI=/[\t\n\r]/g,YI=function(e){var t,n,r,i;if("number"==typeof e){for(t=[],n=0;n<4;n++)xI(t,e%256),e=yI(e/256);return SI(t,".")}if("object"==k(e)){for(t="",r=function(e){for(var t=null,n=1,r=null,i=0,a=0;a<8;a++)0!==e[a]?(i>n&&(t=r,n=i),r=null,i=0):(null===r&&(r=a),++i);return i>n?r:t}(e),n=0;n<8;n++)i&&0===e[n]||(i&&(i=!1),r===n?(t+=n?":":"::",i=!0):(t+=II(e[n],16),n<7&&(t+=":")));return"["+t+"]"}return e},qI={},XI=rI({},qI,{" ":1,'"':1,"<":1,">":1,"`":1}),QI=rI({},XI,{"#":1,"?":1,"{":1,"}":1}),$I=rI({},QI,{"/":1,":":1,";":1,"=":1,"@":1,"[":1,"\\":1,"]":1,"^":1,"|":1}),ZI=function(e,t){var n=oI(e,0);return n>32&&n<127&&!nI(t,e)?e:encodeURIComponent(e)},eb={ftp:21,file:null,http:80,https:443,ws:80,wss:443},tb=function(e,t){var n;return 2===e.length&&kI(LI,TI(e,0))&&(":"===(n=TI(e,1))||!t&&"|"===n)},nb=function(e){var t;return e.length>1&&tb(DI(e,0,2))&&(2===e.length||"/"===(t=TI(e,2))||"\\"===t||"?"===t||"#"===t)},rb=function(e){return"."===e||"%2e"===NI(e)},ib={},ab={},ob={},sb={},cb={},ub={},lb={},db={},hb={},fb={},pb={},mb={},vb={},_b={},gb={},yb={},Eb={},Tb={},kb={},Sb={},Ib={},bb=function(e,t,n){var r,i,a,o=sI(e);if(t){if(i=this.parse(o))throw new _I(i);this.searchParams=null}else{if(void 0!==n&&(r=new bb(n,!0)),i=this.parse(o,null,r))throw new _I(i);(a=mI(new pI)).bindURL(this),this.searchParams=a}};bb.prototype={type:"URL",parse:function(e,t,n){var r,i,a,o,s,c=this,u=t||ib,l=0,d="",h=!1,f=!1,p=!1;for(e=sI(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=RI(e,JI,""),e=RI(e,KI,"$1")),e=RI(e,zI,""),r=iI(e);l<=r.length;){switch(i=r[l],u){case ib:if(!i||!kI(LI,i)){if(t)return OI;u=ob;continue}d+=NI(i),u=ab;break;case ab:if(i&&(kI(VI,i)||"+"===i||"-"===i||"."===i))d+=NI(i);else{if(":"!==i){if(t)return OI;d="",u=ob,l=0;continue}if(t&&(c.isSpecial()!==nI(eb,d)||"file"===d&&(c.includesCredentials()||null!==c.port)||"file"===c.scheme&&!c.host))return;if(c.scheme=d,t)return void(c.isSpecial()&&eb[c.scheme]===c.port&&(c.port=null));d="","file"===c.scheme?u=_b:c.isSpecial()&&n&&n.scheme===c.scheme?u=sb:c.isSpecial()?u=db:"/"===r[l+1]?(u=cb,l++):(c.cannotBeABaseURL=!0,AI(c.path,""),u=kb)}break;case ob:if(!n||n.cannotBeABaseURL&&"#"!==i)return OI;if(n.cannotBeABaseURL&&"#"===i){c.scheme=n.scheme,c.path=aI(n.path),c.query=n.query,c.fragment="",c.cannotBeABaseURL=!0,u=Ib;break}u="file"===n.scheme?_b:ub;continue;case sb:if("/"!==i||"/"!==r[l+1]){u=ub;continue}u=hb,l++;break;case cb:if("/"===i){u=fb;break}u=Tb;continue;case ub:if(c.scheme=n.scheme,i===KS)c.username=n.username,c.password=n.password,c.host=n.host,c.port=n.port,c.path=aI(n.path),c.query=n.query;else if("/"===i||"\\"===i&&c.isSpecial())u=lb;else if("?"===i)c.username=n.username,c.password=n.password,c.host=n.host,c.port=n.port,c.path=aI(n.path),c.query="",u=Sb;else{if("#"!==i){c.username=n.username,c.password=n.password,c.host=n.host,c.port=n.port,c.path=aI(n.path),c.path.length--,u=Tb;continue}c.username=n.username,c.password=n.password,c.host=n.host,c.port=n.port,c.path=aI(n.path),c.query=n.query,c.fragment="",u=Ib}break;case lb:if(!c.isSpecial()||"/"!==i&&"\\"!==i){if("/"!==i){c.username=n.username,c.password=n.password,c.host=n.host,c.port=n.port,u=Tb;continue}u=fb}else u=hb;break;case db:if(u=hb,"/"!==i||"/"!==TI(d,l+1))continue;l++;break;case hb:if("/"!==i&&"\\"!==i){u=fb;continue}break;case fb:if("@"===i){h&&(d="%40"+d),h=!0,a=iI(d);for(var m=0;m<a.length;m++){var v=a[m];if(":"!==v||p){var _=ZI(v,$I);p?c.password+=_:c.username+=_}else p=!0}d=""}else if(i===KS||"/"===i||"?"===i||"#"===i||"\\"===i&&c.isSpecial()){if(h&&""===d)return"Invalid authority";l-=iI(d).length+1,d="",u=pb}else d+=i;break;case pb:case mb:if(t&&"file"===c.scheme){u=yb;continue}if(":"!==i||f){if(i===KS||"/"===i||"?"===i||"#"===i||"\\"===i&&c.isSpecial()){if(c.isSpecial()&&""===d)return PI;if(t&&""===d&&(c.includesCredentials()||null!==c.port))return;if(o=c.parseHost(d))return o;if(d="",u=Eb,t)return;continue}"["===i?f=!0:"]"===i&&(f=!1),d+=i}else{if(""===d)return PI;if(o=c.parseHost(d))return o;if(d="",u=vb,t===mb)return}break;case vb:if(!kI(UI,i)){if(i===KS||"/"===i||"?"===i||"#"===i||"\\"===i&&c.isSpecial()||t){if(""!==d){var g=gI(d,10);if(g>65535)return MI;c.port=c.isSpecial()&&g===eb[c.scheme]?null:g,d=""}if(t)return;u=Eb;continue}return MI}d+=i;break;case _b:if(c.scheme="file","/"===i||"\\"===i)u=gb;else{if(!n||"file"!==n.scheme){u=Tb;continue}switch(i){case KS:c.host=n.host,c.path=aI(n.path),c.query=n.query;break;case"?":c.host=n.host,c.path=aI(n.path),c.query="",u=Sb;break;case"#":c.host=n.host,c.path=aI(n.path),c.query=n.query,c.fragment="",u=Ib;break;default:nb(SI(aI(r,l),""))||(c.host=n.host,c.path=aI(n.path),c.shortenPath()),u=Tb;continue}}break;case gb:if("/"===i||"\\"===i){u=yb;break}n&&"file"===n.scheme&&!nb(SI(aI(r,l),""))&&(tb(n.path[0],!0)?AI(c.path,n.path[0]):c.host=n.host),u=Tb;continue;case yb:if(i===KS||"/"===i||"\\"===i||"?"===i||"#"===i){if(!t&&tb(d))u=Tb;else if(""===d){if(c.host="",t)return;u=Eb}else{if(o=c.parseHost(d))return o;if("localhost"===c.host&&(c.host=""),t)return;d="",u=Eb}continue}d+=i;break;case Eb:if(c.isSpecial()){if(u=Tb,"/"!==i&&"\\"!==i)continue}else if(t||"?"!==i)if(t||"#"!==i){if(i!==KS&&(u=Tb,"/"!==i))continue}else c.fragment="",u=Ib;else c.query="",u=Sb;break;case Tb:if(i===KS||"/"===i||"\\"===i&&c.isSpecial()||!t&&("?"===i||"#"===i)){if(".."===(s=NI(s=d))||"%2e."===s||".%2e"===s||"%2e%2e"===s?(c.shortenPath(),"/"===i||"\\"===i&&c.isSpecial()||AI(c.path,"")):rb(d)?"/"===i||"\\"===i&&c.isSpecial()||AI(c.path,""):("file"===c.scheme&&!c.path.length&&tb(d)&&(c.host&&(c.host=""),d=TI(d,0)+":"),AI(c.path,d)),d="","file"===c.scheme&&(i===KS||"?"===i||"#"===i))for(;c.path.length>1&&""===c.path[0];)CI(c.path);"?"===i?(c.query="",u=Sb):"#"===i&&(c.fragment="",u=Ib)}else d+=ZI(i,QI);break;case kb:"?"===i?(c.query="",u=Sb):"#"===i?(c.fragment="",u=Ib):i!==KS&&(c.path[0]+=ZI(i,qI));break;case Sb:t||"#"!==i?i!==KS&&("'"===i&&c.isSpecial()?c.query+="%27":c.query+="#"===i?"%23":ZI(i,qI)):(c.fragment="",u=Ib);break;case Ib:i!==KS&&(c.fragment+=ZI(i,XI))}l++}},parseHost:function(e){var t,n,r;if("["===TI(e,0)){if("]"!==TI(e,e.length-1))return PI;if(t=function(e){var t,n,r,i,a,o,s,c=[0,0,0,0,0,0,0,0],u=0,l=null,d=0,h=function(){return TI(e,d)};if(":"===h()){if(":"!==TI(e,1))return;d+=2,l=++u}for(;h();){if(8===u)return;if(":"!==h()){for(t=n=0;n<4&&kI(HI,h());)t=16*t+gI(h(),16),d++,n++;if("."===h()){if(0===n)return;if(d-=n,u>6)return;for(r=0;h();){if(i=null,r>0){if(!("."===h()&&r<4))return;d++}if(!kI(UI,h()))return;for(;kI(UI,h());){if(a=gI(h(),10),null===i)i=a;else{if(0===i)return;i=10*i+a}if(i>255)return;d++}c[u]=256*c[u]+i,2!=++r&&4!==r||u++}if(4!==r)return;break}if(":"===h()){if(d++,!h())return}else if(h())return;c[u++]=t}else{if(null!==l)return;d++,l=++u}}if(null!==l)for(o=u-l,u=7;0!==u&&o>0;)s=c[u],c[u--]=c[l+o-1],c[l+--o]=s;else if(8!==u)return;return c}(DI(e,1,-1)),!t)return PI;this.host=t}else if(this.isSpecial()){if(e=function(e){var t,n,r=[],i=vk(mk(_k(e),ok,"."),".");for(t=0;t<i.length;t++)n=i[t],pk(r,uk(ak,n)?"xn--"+Ek(n):n);return fk(r,".")}(e),kI(GI,e))return PI;if(t=function(e){var t,n,r,i,a,o,s,c=wI(e,".");if(c.length&&""===c[c.length-1]&&c.length--,(t=c.length)>4)return e;for(n=[],r=0;r<t;r++){if(""===(i=c[r]))return e;if(a=10,i.length>1&&"0"===TI(i,0)&&(a=kI(FI,i)?16:8,i=DI(i,8===a?1:2)),""===i)o=0;else{if(!kI(10===a?jI:8===a?BI:HI,i))return e;o=gI(i,a)}AI(n,o)}for(r=0;r<t;r++)if(o=n[r],r===t-1){if(o>=EI(256,5-t))return null}else if(o>255)return null;for(s=bI(n),r=0;r<n.length;r++)s+=n[r]*EI(256,3-r);return s}(e),null===t)return PI;this.host=t}else{if(kI(WI,e))return PI;for(t="",n=iI(e),r=0;r<n.length;r++)t+=ZI(n[r],qI);this.host=t}},cannotHaveUsernamePasswordPort:function(){return!this.host||this.cannotBeABaseURL||"file"===this.scheme},includesCredentials:function(){return""!==this.username||""!==this.password},isSpecial:function(){return nI(eb,this.scheme)},shortenPath:function(){var e=this.path,t=e.length;!t||"file"===this.scheme&&1===t&&tb(e[0],!0)||e.length--},serialize:function(){var e=this,t=e.scheme,n=e.username,r=e.password,i=e.host,a=e.port,o=e.path,s=e.query,c=e.fragment,u=t+":";return null!==i?(u+="//",e.includesCredentials()&&(u+=n+(r?":"+r:"")+"@"),u+=YI(i),null!==a&&(u+=":"+a)):"file"===t&&(u+="//"),u+=e.cannotBeABaseURL?o[0]:o.length?"/"+SI(o,"/"):"",null!==s&&(u+="?"+s),null!==c&&(u+="#"+c),u},setHref:function(e){var t=this.parse(e);if(t)throw new _I(t);this.searchParams.update()},getOrigin:function(){var e=this.scheme,t=this.port;if("blob"===e)try{return new Ab(e.path[0]).origin}catch(HH){return"null"}return"file"!==e&&this.isSpecial()?e+"://"+YI(this.host)+(null!==t?":"+t:""):"null"},getProtocol:function(){return this.scheme+":"},setProtocol:function(e){this.parse(sI(e)+":",ib)},getUsername:function(){return this.username},setUsername:function(e){var t=iI(sI(e));if(!this.cannotHaveUsernamePasswordPort()){this.username="";for(var n=0;n<t.length;n++)this.username+=ZI(t[n],$I)}},getPassword:function(){return this.password},setPassword:function(e){var t=iI(sI(e));if(!this.cannotHaveUsernamePasswordPort()){this.password="";for(var n=0;n<t.length;n++)this.password+=ZI(t[n],$I)}},getHost:function(){var e=this.host,t=this.port;return null===e?"":null===t?YI(e):YI(e)+":"+t},setHost:function(e){this.cannotBeABaseURL||this.parse(e,pb)},getHostname:function(){var e=this.host;return null===e?"":YI(e)},setHostname:function(e){this.cannotBeABaseURL||this.parse(e,mb)},getPort:function(){var e=this.port;return null===e?"":sI(e)},setPort:function(e){this.cannotHaveUsernamePasswordPort()||(""===(e=sI(e))?this.port=null:this.parse(e,vb))},getPathname:function(){var e=this.path;return this.cannotBeABaseURL?e[0]:e.length?"/"+SI(e,"/"):""},setPathname:function(e){this.cannotBeABaseURL||(this.path=[],this.parse(e,Eb))},getSearch:function(){var e=this.query;return e?"?"+e:""},setSearch:function(e){""===(e=sI(e))?this.query=null:("?"===TI(e,0)&&(e=DI(e,1)),this.query="",this.parse(e,Sb)),this.searchParams.update()},getSearchParams:function(){return this.searchParams.facade},getHash:function(){var e=this.fragment;return e?"#"+e:""},setHash:function(e){""!==(e=sI(e))?("#"===TI(e,0)&&(e=DI(e,1)),this.fragment="",this.parse(e,Ib)):this.fragment=null},update:function(){this.query=this.searchParams.serialize()||null}};var Ab=function(e){var t=tI(this,Rb),n=uI(arguments.length,1)>1?arguments[1]:void 0,r=hI(t,new bb(e,!1,n));YS||(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())},Rb=Ab.prototype,Cb=function(e,t){return{get:function(){return fI(this)[e]()},set:t&&function(e){return fI(this)[t](e)},configurable:!0,enumerable:!0}};if(YS&&(eI(Rb,"href",Cb("serialize","setHref")),eI(Rb,"origin",Cb("getOrigin")),eI(Rb,"protocol",Cb("getProtocol","setProtocol")),eI(Rb,"username",Cb("getUsername","setUsername")),eI(Rb,"password",Cb("getPassword","setPassword")),eI(Rb,"host",Cb("getHost","setHost")),eI(Rb,"hostname",Cb("getHostname","setHostname")),eI(Rb,"port",Cb("getPort","setPort")),eI(Rb,"pathname",Cb("getPathname","setPathname")),eI(Rb,"search",Cb("getSearch","setSearch")),eI(Rb,"searchParams",Cb("getSearchParams")),eI(Rb,"hash",Cb("getHash","setHash"))),ZS(Rb,"toJSON",(function(){return fI(this).serialize()}),{enumerable:!0}),ZS(Rb,"toString",(function(){return fI(this).serialize()}),{enumerable:!0}),vI){var wb=vI.createObjectURL,Db=vI.revokeObjectURL;wb&&ZS(Ab,"createObjectURL",QS(wb,vI)),Db&&ZS(Ab,"revokeObjectURL",QS(Db,vI))}cI(Ab,"URL"),zS({global:!0,constructor:!0,forced:!qS,sham:!YS},{URL:Ab});var Nb=S;vi({target:"URL",proto:!0,enumerable:!0},{toJSON:function(){return Nb(URL.prototype.toString,this)}});var xb=!0,Ob=!0;function Pb(e,t,n){var r=e.match(t);return r&&r.length>=n&&parseInt(r[n],10)}function Mb(e,t,n){if(e.RTCPeerConnection){var r=e.RTCPeerConnection.prototype,i=r.addEventListener;r.addEventListener=function(e,r){if(e!==t)return i.apply(this,arguments);var a=function(e){var t=n(e);t&&(r.handleEvent?r.handleEvent(t):r(t))};return this._eventMap=this._eventMap||{},this._eventMap[t]||(this._eventMap[t]=new Map),this._eventMap[t].set(r,a),i.apply(this,[e,a])};var a=r.removeEventListener;r.removeEventListener=function(e,n){if(e!==t||!this._eventMap||!this._eventMap[t])return a.apply(this,arguments);if(!this._eventMap[t].has(n))return a.apply(this,arguments);var r=this._eventMap[t].get(n);return this._eventMap[t].delete(n),0===this._eventMap[t].size&&delete this._eventMap[t],0===Object.keys(this._eventMap).length&&delete this._eventMap,a.apply(this,[e,r])},Object.defineProperty(r,"on"+t,{get:function(){return this["_on"+t]},set:function(e){this["_on"+t]&&(this.removeEventListener(t,this["_on"+t]),delete this["_on"+t]),e&&this.addEventListener(t,this["_on"+t]=e)},enumerable:!0,configurable:!0})}}function Lb(e){return"boolean"!=typeof e?new Error("Argument type: "+k(e)+". Please use a boolean."):(xb=e,e?"adapter.js logging disabled":"adapter.js logging enabled")}function Vb(e){return"boolean"!=typeof e?new Error("Argument type: "+k(e)+". Please use a boolean."):(Ob=!e,"adapter.js deprecation warnings "+(e?"disabled":"enabled"))}function Ub(){if("object"==("undefined"==typeof window?"undefined":k(window))){if(xb)return;"undefined"!=typeof console&&"function"==typeof console.log&&console.log.apply(console,arguments)}}function Fb(e,t){Ob&&console.warn(e+" is deprecated, please use "+t+" instead.")}function Bb(e){return"[object Object]"===Object.prototype.toString.call(e)}function jb(e){return Bb(e)?Object.keys(e).reduce((function(t,n){var r=Bb(e[n]),i=r?jb(e[n]):e[n],a=r&&!Object.keys(i).length;return void 0===i||a?t:Object.assign(t,c({},n,i))}),{}):e}function Hb(e,t,n){t&&!n.has(t.id)&&(n.set(t.id,t),Object.keys(t).forEach((function(r){r.endsWith("Id")?Hb(e,e.get(t[r]),n):r.endsWith("Ids")&&t[r].forEach((function(t){Hb(e,e.get(t),n)}))})))}function Gb(e,t,n){var r=n?"outbound-rtp":"inbound-rtp",i=new Map;if(null===t)return i;var a=[];return e.forEach((function(e){"track"===e.type&&e.trackIdentifier===t.id&&a.push(e)})),a.forEach((function(t){e.forEach((function(n){n.type===r&&n.trackId===t.id&&Hb(e,n,i)}))})),i}var Wb=Ub;function Jb(e,t){var n=e&&e.navigator;if(n.mediaDevices){var r=function(e){if("object"!=k(e)||e.mandatory||e.optional)return e;var t={};return Object.keys(e).forEach((function(n){if("require"!==n&&"advanced"!==n&&"mediaSource"!==n){var r="object"==k(e[n])?e[n]:{ideal:e[n]};void 0!==r.exact&&"number"==typeof r.exact&&(r.min=r.max=r.exact);var i=function(e,t){return e?e+t.charAt(0).toUpperCase()+t.slice(1):"deviceId"===t?"sourceId":t};if(void 0!==r.ideal){t.optional=t.optional||[];var a={};"number"==typeof r.ideal?(a[i("min",n)]=r.ideal,t.optional.push(a),(a={})[i("max",n)]=r.ideal,t.optional.push(a)):(a[i("",n)]=r.ideal,t.optional.push(a))}void 0!==r.exact&&"number"!=typeof r.exact?(t.mandatory=t.mandatory||{},t.mandatory[i("",n)]=r.exact):["min","max"].forEach((function(e){void 0!==r[e]&&(t.mandatory=t.mandatory||{},t.mandatory[i(e,n)]=r[e])}))}})),e.advanced&&(t.optional=(t.optional||[]).concat(e.advanced)),t},i=function(e,i){if(t.version>=61)return i(e);if((e=JSON.parse(JSON.stringify(e)))&&"object"==k(e.audio)){var a=function(e,t,n){t in e&&!(n in e)&&(e[n]=e[t],delete e[t])};a((e=JSON.parse(JSON.stringify(e))).audio,"autoGainControl","googAutoGainControl"),a(e.audio,"noiseSuppression","googNoiseSuppression"),e.audio=r(e.audio)}if(e&&"object"==k(e.video)){var o=e.video.facingMode;o=o&&("object"==k(o)?o:{ideal:o});var s,c=t.version<66;if(o&&("user"===o.exact||"environment"===o.exact||"user"===o.ideal||"environment"===o.ideal)&&(!n.mediaDevices.getSupportedConstraints||!n.mediaDevices.getSupportedConstraints().facingMode||c)&&(delete e.video.facingMode,"environment"===o.exact||"environment"===o.ideal?s=["back","rear"]:"user"!==o.exact&&"user"!==o.ideal||(s=["front"]),s))return n.mediaDevices.enumerateDevices().then((function(t){var n=(t=t.filter((function(e){return"videoinput"===e.kind}))).find((function(e){return s.some((function(t){return e.label.toLowerCase().includes(t)}))}));return!n&&t.length&&s.includes("back")&&(n=t[t.length-1]),n&&(e.video.deviceId=o.exact?{exact:n.deviceId}:{ideal:n.deviceId}),e.video=r(e.video),Wb("chrome: "+JSON.stringify(e)),i(e)}));e.video=r(e.video)}return Wb("chrome: "+JSON.stringify(e)),i(e)},a=function(e){return t.version>=64?e:{name:{PermissionDeniedError:"NotAllowedError",PermissionDismissedError:"NotAllowedError",InvalidStateError:"NotAllowedError",DevicesNotFoundError:"NotFoundError",ConstraintNotSatisfiedError:"OverconstrainedError",TrackStartError:"NotReadableError",MediaDeviceFailedDueToShutdown:"NotAllowedError",MediaDeviceKillSwitchOn:"NotAllowedError",TabCaptureError:"AbortError",ScreenCaptureError:"AbortError",DeviceCaptureError:"AbortError"}[e.name]||e.name,message:e.message,constraint:e.constraint||e.constraintName,toString:function(){return this.name+(this.message&&": ")+this.message}}};if(n.getUserMedia=function(e,t,r){i(e,(function(e){n.webkitGetUserMedia(e,t,(function(e){r&&r(a(e))}))}))}.bind(n),n.mediaDevices.getUserMedia){var o=n.mediaDevices.getUserMedia.bind(n.mediaDevices);n.mediaDevices.getUserMedia=function(e){return i(e,(function(e){return o(e).then((function(t){if(e.audio&&!t.getAudioTracks().length||e.video&&!t.getVideoTracks().length)throw t.getTracks().forEach((function(e){e.stop()})),new DOMException("","NotFoundError");return t}),(function(e){return Promise.reject(a(e))}))}))}}}}function Kb(e){e.MediaStream=e.MediaStream||e.webkitMediaStream}function zb(e){if("object"==k(e)&&e.RTCPeerConnection&&!("ontrack"in e.RTCPeerConnection.prototype)){Object.defineProperty(e.RTCPeerConnection.prototype,"ontrack",{get:function(){return this._ontrack},set:function(e){this._ontrack&&this.removeEventListener("track",this._ontrack),this.addEventListener("track",this._ontrack=e)},enumerable:!0,configurable:!0});var t=e.RTCPeerConnection.prototype.setRemoteDescription;e.RTCPeerConnection.prototype.setRemoteDescription=function(){var n=this;return this._ontrackpoly||(this._ontrackpoly=function(t){t.stream.addEventListener("addtrack",(function(r){var i;i=e.RTCPeerConnection.prototype.getReceivers?n.getReceivers().find((function(e){return e.track&&e.track.id===r.track.id})):{track:r.track};var a=new Event("track");a.track=r.track,a.receiver=i,a.transceiver={receiver:i},a.streams=[t.stream],n.dispatchEvent(a)})),t.stream.getTracks().forEach((function(r){var i;i=e.RTCPeerConnection.prototype.getReceivers?n.getReceivers().find((function(e){return e.track&&e.track.id===r.id})):{track:r};var a=new Event("track");a.track=r,a.receiver=i,a.transceiver={receiver:i},a.streams=[t.stream],n.dispatchEvent(a)}))},this.addEventListener("addstream",this._ontrackpoly)),t.apply(this,arguments)}}else Mb(e,"track",(function(e){return e.transceiver||Object.defineProperty(e,"transceiver",{value:{receiver:e.receiver}}),e}))}function Yb(e){if("object"==k(e)&&e.RTCPeerConnection&&!("getSenders"in e.RTCPeerConnection.prototype)&&"createDTMFSender"in e.RTCPeerConnection.prototype){var t=function(e,t){return{track:t,get dtmf(){return void 0===this._dtmf&&("audio"===t.kind?this._dtmf=e.createDTMFSender(t):this._dtmf=null),this._dtmf},_pc:e}};if(!e.RTCPeerConnection.prototype.getSenders){e.RTCPeerConnection.prototype.getSenders=function(){return this._senders=this._senders||[],this._senders.slice()};var n=e.RTCPeerConnection.prototype.addTrack;e.RTCPeerConnection.prototype.addTrack=function(e,r){var i=n.apply(this,arguments);return i||(i=t(this,e),this._senders.push(i)),i};var r=e.RTCPeerConnection.prototype.removeTrack;e.RTCPeerConnection.prototype.removeTrack=function(e){r.apply(this,arguments);var t=this._senders.indexOf(e);-1!==t&&this._senders.splice(t,1)}}var i=e.RTCPeerConnection.prototype.addStream;e.RTCPeerConnection.prototype.addStream=function(e){var n=this;this._senders=this._senders||[],i.apply(this,[e]),e.getTracks().forEach((function(e){n._senders.push(t(n,e))}))};var a=e.RTCPeerConnection.prototype.removeStream;e.RTCPeerConnection.prototype.removeStream=function(e){var t=this;this._senders=this._senders||[],a.apply(this,[e]),e.getTracks().forEach((function(e){var n=t._senders.find((function(t){return t.track===e}));n&&t._senders.splice(t._senders.indexOf(n),1)}))}}else if("object"==k(e)&&e.RTCPeerConnection&&"getSenders"in e.RTCPeerConnection.prototype&&"createDTMFSender"in e.RTCPeerConnection.prototype&&e.RTCRtpSender&&!("dtmf"in e.RTCRtpSender.prototype)){var o=e.RTCPeerConnection.prototype.getSenders;e.RTCPeerConnection.prototype.getSenders=function(){var e=this,t=o.apply(this,[]);return t.forEach((function(t){return t._pc=e})),t},Object.defineProperty(e.RTCRtpSender.prototype,"dtmf",{get:function(){return void 0===this._dtmf&&("audio"===this.track.kind?this._dtmf=this._pc.createDTMFSender(this.track):this._dtmf=null),this._dtmf}})}}function qb(e){if(e.RTCPeerConnection){var t=e.RTCPeerConnection.prototype.getStats;e.RTCPeerConnection.prototype.getStats=function(){var e=this,n=Array.prototype.slice.call(arguments),r=n[0],i=n[1],a=n[2];if(arguments.length>0&&"function"==typeof r)return t.apply(this,arguments);if(0===t.length&&(0===arguments.length||"function"!=typeof r))return t.apply(this,[]);var o=function(e){var t={};return e.result().forEach((function(e){var n={id:e.id,timestamp:e.timestamp,type:{localcandidate:"local-candidate",remotecandidate:"remote-candidate"}[e.type]||e.type};e.names().forEach((function(t){n[t]=e.stat(t)})),t[n.id]=n})),t},s=function(e){return new Map(Object.keys(e).map((function(t){return[t,e[t]]})))};return arguments.length>=2?t.apply(this,[function(e){i(s(o(e)))},r]):new Promise((function(n,r){t.apply(e,[function(e){n(s(o(e)))},r])})).then(i,a)}}}function Xb(e){if("object"==k(e)&&e.RTCPeerConnection&&e.RTCRtpSender&&e.RTCRtpReceiver){if(!("getStats"in e.RTCRtpSender.prototype)){var t=e.RTCPeerConnection.prototype.getSenders;t&&(e.RTCPeerConnection.prototype.getSenders=function(){var e=this,n=t.apply(this,[]);return n.forEach((function(t){return t._pc=e})),n});var n=e.RTCPeerConnection.prototype.addTrack;n&&(e.RTCPeerConnection.prototype.addTrack=function(){var e=n.apply(this,arguments);return e._pc=this,e}),e.RTCRtpSender.prototype.getStats=function(){var e=this;return this._pc.getStats().then((function(t){return Gb(t,e.track,!0)}))}}if(!("getStats"in e.RTCRtpReceiver.prototype)){var r=e.RTCPeerConnection.prototype.getReceivers;r&&(e.RTCPeerConnection.prototype.getReceivers=function(){var e=this,t=r.apply(this,[]);return t.forEach((function(t){return t._pc=e})),t}),Mb(e,"track",(function(e){return e.receiver._pc=e.srcElement,e})),e.RTCRtpReceiver.prototype.getStats=function(){var e=this;return this._pc.getStats().then((function(t){return Gb(t,e.track,!1)}))}}if("getStats"in e.RTCRtpSender.prototype&&"getStats"in e.RTCRtpReceiver.prototype){var i=e.RTCPeerConnection.prototype.getStats;e.RTCPeerConnection.prototype.getStats=function(){if(arguments.length>0&&arguments[0]instanceof e.MediaStreamTrack){var t,n,r,a=arguments[0];return this.getSenders().forEach((function(e){e.track===a&&(t?r=!0:t=e)})),this.getReceivers().forEach((function(e){return e.track===a&&(n?r=!0:n=e),e.track===a})),r||t&&n?Promise.reject(new DOMException("There are more than one sender or receiver for the track.","InvalidAccessError")):t?t.getStats():n?n.getStats():Promise.reject(new DOMException("There is no sender or receiver for the track.","InvalidAccessError"))}return i.apply(this,arguments)}}}}function Qb(e){e.RTCPeerConnection.prototype.getLocalStreams=function(){var e=this;return this._shimmedLocalStreams=this._shimmedLocalStreams||{},Object.keys(this._shimmedLocalStreams).map((function(t){return e._shimmedLocalStreams[t][0]}))};var t=e.RTCPeerConnection.prototype.addTrack;e.RTCPeerConnection.prototype.addTrack=function(e,n){if(!n)return t.apply(this,arguments);this._shimmedLocalStreams=this._shimmedLocalStreams||{};var r=t.apply(this,arguments);return this._shimmedLocalStreams[n.id]?-1===this._shimmedLocalStreams[n.id].indexOf(r)&&this._shimmedLocalStreams[n.id].push(r):this._shimmedLocalStreams[n.id]=[n,r],r};var n=e.RTCPeerConnection.prototype.addStream;e.RTCPeerConnection.prototype.addStream=function(e){var t=this;this._shimmedLocalStreams=this._shimmedLocalStreams||{},e.getTracks().forEach((function(e){if(t.getSenders().find((function(t){return t.track===e})))throw new DOMException("Track already exists.","InvalidAccessError")}));var r=this.getSenders();n.apply(this,arguments);var i=this.getSenders().filter((function(e){return-1===r.indexOf(e)}));this._shimmedLocalStreams[e.id]=[e].concat(i)};var r=e.RTCPeerConnection.prototype.removeStream;e.RTCPeerConnection.prototype.removeStream=function(e){return this._shimmedLocalStreams=this._shimmedLocalStreams||{},delete this._shimmedLocalStreams[e.id],r.apply(this,arguments)};var i=e.RTCPeerConnection.prototype.removeTrack;e.RTCPeerConnection.prototype.removeTrack=function(e){var t=this;return this._shimmedLocalStreams=this._shimmedLocalStreams||{},e&&Object.keys(this._shimmedLocalStreams).forEach((function(n){var r=t._shimmedLocalStreams[n].indexOf(e);-1!==r&&t._shimmedLocalStreams[n].splice(r,1),1===t._shimmedLocalStreams[n].length&&delete t._shimmedLocalStreams[n]})),i.apply(this,arguments)}}function $b(e,t){if(e.RTCPeerConnection){if(e.RTCPeerConnection.prototype.addTrack&&t.version>=65)return Qb(e);var n=e.RTCPeerConnection.prototype.getLocalStreams;e.RTCPeerConnection.prototype.getLocalStreams=function(){var e=this,t=n.apply(this);return this._reverseStreams=this._reverseStreams||{},t.map((function(t){return e._reverseStreams[t.id]}))};var r=e.RTCPeerConnection.prototype.addStream;e.RTCPeerConnection.prototype.addStream=function(t){var n=this;if(this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{},t.getTracks().forEach((function(e){if(n.getSenders().find((function(t){return t.track===e})))throw new DOMException("Track already exists.","InvalidAccessError")})),!this._reverseStreams[t.id]){var i=new e.MediaStream(t.getTracks());this._streams[t.id]=i,this._reverseStreams[i.id]=t,t=i}r.apply(this,[t])};var i=e.RTCPeerConnection.prototype.removeStream;e.RTCPeerConnection.prototype.removeStream=function(e){this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{},i.apply(this,[this._streams[e.id]||e]),delete this._reverseStreams[this._streams[e.id]?this._streams[e.id].id:e.id],delete this._streams[e.id]},e.RTCPeerConnection.prototype.addTrack=function(t,n){var r=this;if("closed"===this.signalingState)throw new DOMException("The RTCPeerConnection's signalingState is 'closed'.","InvalidStateError");var i=[].slice.call(arguments,1);if(1!==i.length||!i[0].getTracks().find((function(e){return e===t})))throw new DOMException("The adapter.js addTrack polyfill only supports a single stream which is associated with the specified track.","NotSupportedError");if(this.getSenders().find((function(e){return e.track===t})))throw new DOMException("Track already exists.","InvalidAccessError");this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{};var a=this._streams[n.id];if(a)a.addTrack(t),Promise.resolve().then((function(){r.dispatchEvent(new Event("negotiationneeded"))}));else{var o=new e.MediaStream([t]);this._streams[n.id]=o,this._reverseStreams[o.id]=n,this.addStream(o)}return this.getSenders().find((function(e){return e.track===t}))},["createOffer","createAnswer"].forEach((function(t){var n=e.RTCPeerConnection.prototype[t],r=c({},t,(function(){var e=this,t=arguments;return arguments.length&&"function"==typeof arguments[0]?n.apply(this,[function(n){var r=s(e,n);t[0].apply(null,[r])},function(e){t[1]&&t[1].apply(null,e)},arguments[2]]):n.apply(this,arguments).then((function(t){return s(e,t)}))}));e.RTCPeerConnection.prototype[t]=r[t]}));var a=e.RTCPeerConnection.prototype.setLocalDescription;e.RTCPeerConnection.prototype.setLocalDescription=function(){return arguments.length&&arguments[0].type?(arguments[0]=function(e,t){var n=t.sdp;return Object.keys(e._reverseStreams||[]).forEach((function(t){var r=e._reverseStreams[t],i=e._streams[r.id];n=n.replace(new RegExp(r.id,"g"),i.id)})),new RTCSessionDescription({type:t.type,sdp:n})}(this,arguments[0]),a.apply(this,arguments)):a.apply(this,arguments)};var o=Object.getOwnPropertyDescriptor(e.RTCPeerConnection.prototype,"localDescription");Object.defineProperty(e.RTCPeerConnection.prototype,"localDescription",{get:function(){var e=o.get.apply(this);return""===e.type?e:s(this,e)}}),e.RTCPeerConnection.prototype.removeTrack=function(e){var t,n=this;if("closed"===this.signalingState)throw new DOMException("The RTCPeerConnection's signalingState is 'closed'.","InvalidStateError");if(!e._pc)throw new DOMException("Argument 1 of RTCPeerConnection.removeTrack does not implement interface RTCRtpSender.","TypeError");if(e._pc!==this)throw new DOMException("Sender was not created by this connection.","InvalidAccessError");this._streams=this._streams||{},Object.keys(this._streams).forEach((function(r){n._streams[r].getTracks().find((function(t){return e.track===t}))&&(t=n._streams[r])})),t&&(1===t.getTracks().length?this.removeStream(this._reverseStreams[t.id]):t.removeTrack(e.track),this.dispatchEvent(new Event("negotiationneeded")))}}function s(e,t){var n=t.sdp;return Object.keys(e._reverseStreams||[]).forEach((function(t){var r=e._reverseStreams[t],i=e._streams[r.id];n=n.replace(new RegExp(i.id,"g"),r.id)})),new RTCSessionDescription({type:t.type,sdp:n})}}function Zb(e,t){!e.RTCPeerConnection&&e.webkitRTCPeerConnection&&(e.RTCPeerConnection=e.webkitRTCPeerConnection),e.RTCPeerConnection&&t.version<53&&["setLocalDescription","setRemoteDescription","addIceCandidate"].forEach((function(t){var n=e.RTCPeerConnection.prototype[t],r=c({},t,(function(){return arguments[0]=new("addIceCandidate"===t?e.RTCIceCandidate:e.RTCSessionDescription)(arguments[0]),n.apply(this,arguments)}));e.RTCPeerConnection.prototype[t]=r[t]}))}function eA(e,t){Mb(e,"negotiationneeded",(function(e){var n=e.target;if(!(t.version<72||n.getConfiguration&&"plan-b"===n.getConfiguration().sdpSemantics)||"stable"===n.signalingState)return e}))}var tA=Object.freeze({__proto__:null,shimMediaStream:Kb,shimOnTrack:zb,shimGetSendersWithDtmf:Yb,shimGetStats:qb,shimSenderReceiverGetStats:Xb,shimAddTrackRemoveTrackWithNative:Qb,shimAddTrackRemoveTrack:$b,shimPeerConnection:Zb,fixNegotiationNeeded:eA,shimGetUserMedia:Jb,shimGetDisplayMedia:function(e,t){e.navigator.mediaDevices&&"getDisplayMedia"in e.navigator.mediaDevices||e.navigator.mediaDevices&&("function"==typeof t?e.navigator.mediaDevices.getDisplayMedia=function(n){return t(n).then((function(t){var r=n.video&&n.video.width,i=n.video&&n.video.height,a=n.video&&n.video.frameRate;return n.video={mandatory:{chromeMediaSource:"desktop",chromeMediaSourceId:t,maxFrameRate:a||3}},r&&(n.video.mandatory.maxWidth=r),i&&(n.video.mandatory.maxHeight=i),e.navigator.mediaDevices.getUserMedia(n)}))}:console.error("shimGetDisplayMedia: getSourceId argument is not a function"))}});function nA(e,t){var n=e&&e.navigator,r=e&&e.MediaStreamTrack;if(n.getUserMedia=function(e,t,r){Fb("navigator.getUserMedia","navigator.mediaDevices.getUserMedia"),n.mediaDevices.getUserMedia(e).then(t,r)},!(t.version>55&&"autoGainControl"in n.mediaDevices.getSupportedConstraints())){var i=function(e,t,n){t in e&&!(n in e)&&(e[n]=e[t],delete e[t])},a=n.mediaDevices.getUserMedia.bind(n.mediaDevices);if(n.mediaDevices.getUserMedia=function(e){return"object"==k(e)&&"object"==k(e.audio)&&(e=JSON.parse(JSON.stringify(e)),i(e.audio,"autoGainControl","mozAutoGainControl"),i(e.audio,"noiseSuppression","mozNoiseSuppression")),a(e)},r&&r.prototype.getSettings){var o=r.prototype.getSettings;r.prototype.getSettings=function(){var e=o.apply(this,arguments);return i(e,"mozAutoGainControl","autoGainControl"),i(e,"mozNoiseSuppression","noiseSuppression"),e}}if(r&&r.prototype.applyConstraints){var s=r.prototype.applyConstraints;r.prototype.applyConstraints=function(e){return"audio"===this.kind&&"object"==k(e)&&(e=JSON.parse(JSON.stringify(e)),i(e,"autoGainControl","mozAutoGainControl"),i(e,"noiseSuppression","mozNoiseSuppression")),s.apply(this,[e])}}}}function rA(e){"object"==k(e)&&e.RTCTrackEvent&&"receiver"in e.RTCTrackEvent.prototype&&!("transceiver"in e.RTCTrackEvent.prototype)&&Object.defineProperty(e.RTCTrackEvent.prototype,"transceiver",{get:function(){return{receiver:this.receiver}}})}function iA(e,t){if("object"==k(e)&&(e.RTCPeerConnection||e.mozRTCPeerConnection)){!e.RTCPeerConnection&&e.mozRTCPeerConnection&&(e.RTCPeerConnection=e.mozRTCPeerConnection),t.version<53&&["setLocalDescription","setRemoteDescription","addIceCandidate"].forEach((function(t){var n=e.RTCPeerConnection.prototype[t],r=c({},t,(function(){return arguments[0]=new("addIceCandidate"===t?e.RTCIceCandidate:e.RTCSessionDescription)(arguments[0]),n.apply(this,arguments)}));e.RTCPeerConnection.prototype[t]=r[t]}));var 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(){var e=Array.prototype.slice.call(arguments),i=e[0],a=e[1],o=e[2];return r.apply(this,[i||null]).then((function(e){if(t.version<53&&!a)try{e.forEach((function(e){e.type=n[e.type]||e.type}))}catch(wR){if("TypeError"!==wR.name)throw wR;e.forEach((function(t,r){e.set(r,Object.assign({},t,{type:n[t.type]||t.type}))}))}return e})).then(a,o)}}}function aA(e){if("object"==k(e)&&e.RTCPeerConnection&&e.RTCRtpSender&&(!e.RTCRtpSender||!("getStats"in e.RTCRtpSender.prototype))){var t=e.RTCPeerConnection.prototype.getSenders;t&&(e.RTCPeerConnection.prototype.getSenders=function(){var e=this,n=t.apply(this,[]);return n.forEach((function(t){return t._pc=e})),n});var n=e.RTCPeerConnection.prototype.addTrack;n&&(e.RTCPeerConnection.prototype.addTrack=function(){var e=n.apply(this,arguments);return e._pc=this,e}),e.RTCRtpSender.prototype.getStats=function(){return this.track?this._pc.getStats(this.track):Promise.resolve(new Map)}}}function oA(e){if("object"==k(e)&&e.RTCPeerConnection&&e.RTCRtpSender&&(!e.RTCRtpSender||!("getStats"in e.RTCRtpReceiver.prototype))){var t=e.RTCPeerConnection.prototype.getReceivers;t&&(e.RTCPeerConnection.prototype.getReceivers=function(){var e=this,n=t.apply(this,[]);return n.forEach((function(t){return t._pc=e})),n}),Mb(e,"track",(function(e){return e.receiver._pc=e.srcElement,e})),e.RTCRtpReceiver.prototype.getStats=function(){return this._pc.getStats(this.track)}}}function sA(e){e.RTCPeerConnection&&!("removeStream"in e.RTCPeerConnection.prototype)&&(e.RTCPeerConnection.prototype.removeStream=function(e){var t=this;Fb("removeStream","removeTrack"),this.getSenders().forEach((function(n){n.track&&e.getTracks().includes(n.track)&&t.removeTrack(n)}))})}function cA(e){e.DataChannel&&!e.RTCDataChannel&&(e.RTCDataChannel=e.DataChannel)}function uA(e){if("object"==k(e)&&e.RTCPeerConnection){var t=e.RTCPeerConnection.prototype.addTransceiver;t&&(e.RTCPeerConnection.prototype.addTransceiver=function(){this.setParametersPromises=[];var e=arguments[1]&&arguments[1].sendEncodings;void 0===e&&(e=[]);var n=(e=E(e)).length>0;n&&e.forEach((function(e){if("rid"in e&&!/^[a-z0-9]{0,16}$/i.test(e.rid))throw new TypeError("Invalid RID value provided.");if("scaleResolutionDownBy"in e&&!(parseFloat(e.scaleResolutionDownBy)>=1))throw new RangeError("scale_resolution_down_by must be >= 1.0");if("maxFramerate"in e&&!(parseFloat(e.maxFramerate)>=0))throw new RangeError("max_framerate must be >= 0.0")}));var r=t.apply(this,arguments);if(n){var i=r.sender,a=i.getParameters();(!("encodings"in a)||1===a.encodings.length&&0===Object.keys(a.encodings[0]).length)&&(a.encodings=e,i.sendEncodings=e,this.setParametersPromises.push(i.setParameters(a).then((function(){delete i.sendEncodings})).catch((function(){delete i.sendEncodings}))))}return r})}}function lA(e){if("object"==k(e)&&e.RTCRtpSender){var t=e.RTCRtpSender.prototype.getParameters;t&&(e.RTCRtpSender.prototype.getParameters=function(){var e=t.apply(this,arguments);return"encodings"in e||(e.encodings=[].concat(this.sendEncodings||[{}])),e})}}function dA(e){if("object"==k(e)&&e.RTCPeerConnection){var t=e.RTCPeerConnection.prototype.createOffer;e.RTCPeerConnection.prototype.createOffer=function(){var e=arguments,n=this;return this.setParametersPromises&&this.setParametersPromises.length?Promise.all(this.setParametersPromises).then((function(){return t.apply(n,e)})).finally((function(){n.setParametersPromises=[]})):t.apply(this,arguments)}}}function hA(e){if("object"==k(e)&&e.RTCPeerConnection){var t=e.RTCPeerConnection.prototype.createAnswer;e.RTCPeerConnection.prototype.createAnswer=function(){var e=arguments,n=this;return this.setParametersPromises&&this.setParametersPromises.length?Promise.all(this.setParametersPromises).then((function(){return t.apply(n,e)})).finally((function(){n.setParametersPromises=[]})):t.apply(this,arguments)}}}var fA=Object.freeze({__proto__:null,shimOnTrack:rA,shimPeerConnection:iA,shimSenderGetStats:aA,shimReceiverGetStats:oA,shimRemoveStream:sA,shimRTCDataChannel:cA,shimAddTransceiver:uA,shimGetParameters:lA,shimCreateOffer:dA,shimCreateAnswer:hA,shimGetUserMedia:nA,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){var r=new DOMException("getDisplayMedia without video constraints is undefined");return r.name="NotFoundError",r.code=8,Promise.reject(r)}return!0===n.video?n.video={mediaSource:t}:n.video.mediaSource=t,e.navigator.mediaDevices.getUserMedia(n)})}});function pA(e){if("object"==k(e)&&e.RTCPeerConnection){if("getLocalStreams"in e.RTCPeerConnection.prototype||(e.RTCPeerConnection.prototype.getLocalStreams=function(){return this._localStreams||(this._localStreams=[]),this._localStreams}),!("addStream"in e.RTCPeerConnection.prototype)){var t=e.RTCPeerConnection.prototype.addTrack;e.RTCPeerConnection.prototype.addStream=function(e){var n=this;this._localStreams||(this._localStreams=[]),this._localStreams.includes(e)||this._localStreams.push(e),e.getAudioTracks().forEach((function(r){return t.call(n,r,e)})),e.getVideoTracks().forEach((function(r){return t.call(n,r,e)}))},e.RTCPeerConnection.prototype.addTrack=function(e){for(var n=this,r=arguments.length,i=new Array(r>1?r-1:0),a=1;a<r;a++)i[a-1]=arguments[a];return i&&i.forEach((function(e){n._localStreams?n._localStreams.includes(e)||n._localStreams.push(e):n._localStreams=[e]})),t.apply(this,arguments)}}"removeStream"in e.RTCPeerConnection.prototype||(e.RTCPeerConnection.prototype.removeStream=function(e){var t=this;this._localStreams||(this._localStreams=[]);var n=this._localStreams.indexOf(e);if(-1!==n){this._localStreams.splice(n,1);var r=e.getTracks();this.getSenders().forEach((function(e){r.includes(e.track)&&t.removeTrack(e)}))}})}}function mA(e){if("object"==k(e)&&e.RTCPeerConnection&&("getRemoteStreams"in e.RTCPeerConnection.prototype||(e.RTCPeerConnection.prototype.getRemoteStreams=function(){return this._remoteStreams?this._remoteStreams:[]}),!("onaddstream"in e.RTCPeerConnection.prototype))){Object.defineProperty(e.RTCPeerConnection.prototype,"onaddstream",{get:function(){return this._onaddstream},set:function(e){var t=this;this._onaddstream&&(this.removeEventListener("addstream",this._onaddstream),this.removeEventListener("track",this._onaddstreampoly)),this.addEventListener("addstream",this._onaddstream=e),this.addEventListener("track",this._onaddstreampoly=function(e){e.streams.forEach((function(e){if(t._remoteStreams||(t._remoteStreams=[]),!t._remoteStreams.includes(e)){t._remoteStreams.push(e);var n=new Event("addstream");n.stream=e,t.dispatchEvent(n)}}))})}});var t=e.RTCPeerConnection.prototype.setRemoteDescription;e.RTCPeerConnection.prototype.setRemoteDescription=function(){var e=this;return this._onaddstreampoly||this.addEventListener("track",this._onaddstreampoly=function(t){t.streams.forEach((function(t){if(e._remoteStreams||(e._remoteStreams=[]),!(e._remoteStreams.indexOf(t)>=0)){e._remoteStreams.push(t);var n=new Event("addstream");n.stream=t,e.dispatchEvent(n)}}))}),t.apply(e,arguments)}}}function vA(e){if("object"==k(e)&&e.RTCPeerConnection){var t=e.RTCPeerConnection.prototype,n=t.createOffer,r=t.createAnswer,i=t.setLocalDescription,a=t.setRemoteDescription,o=t.addIceCandidate;t.createOffer=function(e,t){var r=arguments.length>=2?arguments[2]:arguments[0],i=n.apply(this,[r]);return t?(i.then(e,t),Promise.resolve()):i},t.createAnswer=function(e,t){var n=arguments.length>=2?arguments[2]:arguments[0],i=r.apply(this,[n]);return t?(i.then(e,t),Promise.resolve()):i};var s=function(e,t,n){var r=i.apply(this,[e]);return n?(r.then(t,n),Promise.resolve()):r};t.setLocalDescription=s,s=function(e,t,n){var r=a.apply(this,[e]);return n?(r.then(t,n),Promise.resolve()):r},t.setRemoteDescription=s,s=function(e,t,n){var r=o.apply(this,[e]);return n?(r.then(t,n),Promise.resolve()):r},t.addIceCandidate=s}}function _A(e){var t=e&&e.navigator;if(t.mediaDevices&&t.mediaDevices.getUserMedia){var n=t.mediaDevices,r=n.getUserMedia.bind(n);t.mediaDevices.getUserMedia=function(e){return r(gA(e))}}!t.getUserMedia&&t.mediaDevices&&t.mediaDevices.getUserMedia&&(t.getUserMedia=function(e,n,r){t.mediaDevices.getUserMedia(e).then(n,r)}.bind(t))}function gA(e){return e&&void 0!==e.video?Object.assign({},e,{video:jb(e.video)}):e}function yA(e){if(e.RTCPeerConnection){var t=e.RTCPeerConnection;e.RTCPeerConnection=function(e,n){if(e&&e.iceServers){for(var r=[],i=0;i<e.iceServers.length;i++){var a=e.iceServers[i];void 0===a.urls&&a.url?(Fb("RTCIceServer.url","RTCIceServer.urls"),(a=JSON.parse(JSON.stringify(a))).urls=a.url,delete a.url,r.push(a)):r.push(e.iceServers[i])}e.iceServers=r}return new t(e,n)},e.RTCPeerConnection.prototype=t.prototype,"generateCertificate"in t&&Object.defineProperty(e.RTCPeerConnection,"generateCertificate",{get:function(){return t.generateCertificate}})}}function EA(e){"object"==k(e)&&e.RTCTrackEvent&&"receiver"in e.RTCTrackEvent.prototype&&!("transceiver"in e.RTCTrackEvent.prototype)&&Object.defineProperty(e.RTCTrackEvent.prototype,"transceiver",{get:function(){return{receiver:this.receiver}}})}function TA(e){var t=e.RTCPeerConnection.prototype.createOffer;e.RTCPeerConnection.prototype.createOffer=function(e){if(e){void 0!==e.offerToReceiveAudio&&(e.offerToReceiveAudio=!!e.offerToReceiveAudio);var n=this.getTransceivers().find((function(e){return"audio"===e.receiver.track.kind}));!1===e.offerToReceiveAudio&&n?"sendrecv"===n.direction?n.setDirection?n.setDirection("sendonly"):n.direction="sendonly":"recvonly"===n.direction&&(n.setDirection?n.setDirection("inactive"):n.direction="inactive"):!0!==e.offerToReceiveAudio||n||this.addTransceiver("audio",{direction:"recvonly"}),void 0!==e.offerToReceiveVideo&&(e.offerToReceiveVideo=!!e.offerToReceiveVideo);var r=this.getTransceivers().find((function(e){return"video"===e.receiver.track.kind}));!1===e.offerToReceiveVideo&&r?"sendrecv"===r.direction?r.setDirection?r.setDirection("sendonly"):r.direction="sendonly":"recvonly"===r.direction&&(r.setDirection?r.setDirection("inactive"):r.direction="inactive"):!0!==e.offerToReceiveVideo||r||this.addTransceiver("video",{direction:"recvonly"})}return t.apply(this,arguments)}}function kA(e){"object"!=k(e)||e.AudioContext||(e.AudioContext=e.webkitAudioContext)}var SA=Object.freeze({__proto__:null,shimLocalStreamsAPI:pA,shimRemoteStreamsAPI:mA,shimCallbacksAPI:vA,shimGetUserMedia:_A,shimConstraints:gA,shimRTCIceServerUrls:yA,shimTrackEventTransceiver:EA,shimCreateOfferLegacy:TA,shimAudioContext:kA}),IA={},bA={get exports(){return IA},set exports(e){IA=e}};!function(e){var t={generateIdentifier:function(){return Math.random().toString(36).substring(2,12)}};t.localCName=t.generateIdentifier(),t.splitLines=function(e){return e.trim().split("\n").map((function(e){return e.trim()}))},t.splitSections=function(e){return e.split("\nm=").map((function(e,t){return(t>0?"m="+e:e).trim()+"\r\n"}))},t.getDescription=function(e){var n=t.splitSections(e);return n&&n[0]},t.getMediaSections=function(e){var n=t.splitSections(e);return n.shift(),n},t.matchPrefix=function(e,n){return t.splitLines(e).filter((function(e){return 0===e.indexOf(n)}))},t.parseCandidate=function(e){for(var t,n={foundation:(t=0===e.indexOf("a=candidate:")?e.substring(12).split(" "):e.substring(10).split(" "))[0],component:{1:"rtp",2:"rtcp"}[t[1]]||t[1],protocol:t[2].toLowerCase(),priority:parseInt(t[3],10),ip:t[4],address:t[4],port:parseInt(t[5],10),type:t[7]},r=8;r<t.length;r+=2)switch(t[r]){case"raddr":n.relatedAddress=t[r+1];break;case"rport":n.relatedPort=parseInt(t[r+1],10);break;case"tcptype":n.tcpType=t[r+1];break;case"ufrag":n.ufrag=t[r+1],n.usernameFragment=t[r+1];break;default:void 0===n[t[r]]&&(n[t[r]]=t[r+1])}return n},t.writeCandidate=function(e){var t=[];t.push(e.foundation);var n=e.component;"rtp"===n?t.push(1):"rtcp"===n?t.push(2):t.push(n),t.push(e.protocol.toUpperCase()),t.push(e.priority),t.push(e.address||e.ip),t.push(e.port);var r=e.type;return t.push("typ"),t.push(r),"host"!==r&&e.relatedAddress&&e.relatedPort&&(t.push("raddr"),t.push(e.relatedAddress),t.push("rport"),t.push(e.relatedPort)),e.tcpType&&"tcp"===e.protocol.toLowerCase()&&(t.push("tcptype"),t.push(e.tcpType)),(e.usernameFragment||e.ufrag)&&(t.push("ufrag"),t.push(e.usernameFragment||e.ufrag)),"candidate:"+t.join(" ")},t.parseIceOptions=function(e){return e.substring(14).split(" ")},t.parseRtpMap=function(e){var t=e.substring(9).split(" "),n={payloadType:parseInt(t.shift(),10)};return t=t[0].split("/"),n.name=t[0],n.clockRate=parseInt(t[1],10),n.channels=3===t.length?parseInt(t[2],10):1,n.numChannels=n.channels,n},t.writeRtpMap=function(e){var t=e.payloadType;void 0!==e.preferredPayloadType&&(t=e.preferredPayloadType);var n=e.channels||e.numChannels||1;return"a=rtpmap:"+t+" "+e.name+"/"+e.clockRate+(1!==n?"/"+n:"")+"\r\n"},t.parseExtmap=function(e){var t=e.substring(9).split(" ");return{id:parseInt(t[0],10),direction:t[0].indexOf("/")>0?t[0].split("/")[1]:"sendrecv",uri:t[1],attributes:t.slice(2).join(" ")}},t.writeExtmap=function(e){return"a=extmap:"+(e.id||e.preferredId)+(e.direction&&"sendrecv"!==e.direction?"/"+e.direction:"")+" "+e.uri+(e.attributes?" "+e.attributes:"")+"\r\n"},t.parseFmtp=function(e){for(var t,n={},r=e.substring(e.indexOf(" ")+1).split(";"),i=0;i<r.length;i++)n[(t=r[i].trim().split("="))[0].trim()]=t[1];return n},t.writeFmtp=function(e){var t="",n=e.payloadType;if(void 0!==e.preferredPayloadType&&(n=e.preferredPayloadType),e.parameters&&Object.keys(e.parameters).length){var r=[];Object.keys(e.parameters).forEach((function(t){void 0!==e.parameters[t]?r.push(t+"="+e.parameters[t]):r.push(t)})),t+="a=fmtp:"+n+" "+r.join(";")+"\r\n"}return t},t.parseRtcpFb=function(e){var t=e.substring(e.indexOf(" ")+1).split(" ");return{type:t.shift(),parameter:t.join(" ")}},t.writeRtcpFb=function(e){var t="",n=e.payloadType;return void 0!==e.preferredPayloadType&&(n=e.preferredPayloadType),e.rtcpFeedback&&e.rtcpFeedback.length&&e.rtcpFeedback.forEach((function(e){t+="a=rtcp-fb:"+n+" "+e.type+(e.parameter&&e.parameter.length?" "+e.parameter:"")+"\r\n"})),t},t.parseSsrcMedia=function(e){var t=e.indexOf(" "),n={ssrc:parseInt(e.substring(7,t),10)},r=e.indexOf(":",t);return r>-1?(n.attribute=e.substring(t+1,r),n.value=e.substring(r+1)):n.attribute=e.substring(t+1),n},t.parseSsrcGroup=function(e){var t=e.substring(13).split(" ");return{semantics:t.shift(),ssrcs:t.map((function(e){return parseInt(e,10)}))}},t.getMid=function(e){var n=t.matchPrefix(e,"a=mid:")[0];if(n)return n.substring(6)},t.parseFingerprint=function(e){var t=e.substring(14).split(" ");return{algorithm:t[0].toLowerCase(),value:t[1].toUpperCase()}},t.getDtlsParameters=function(e,n){return{role:"auto",fingerprints:t.matchPrefix(e+n,"a=fingerprint:").map(t.parseFingerprint)}},t.writeDtlsParameters=function(e,t){var n="a=setup:"+t+"\r\n";return e.fingerprints.forEach((function(e){n+="a=fingerprint:"+e.algorithm+" "+e.value+"\r\n"})),n},t.parseCryptoLine=function(e){var t=e.substring(9).split(" ");return{tag:parseInt(t[0],10),cryptoSuite:t[1],keyParams:t[2],sessionParams:t.slice(3)}},t.writeCryptoLine=function(e){return"a=crypto:"+e.tag+" "+e.cryptoSuite+" "+("object"==k(e.keyParams)?t.writeCryptoKeyParams(e.keyParams):e.keyParams)+(e.sessionParams?" "+e.sessionParams.join(" "):"")+"\r\n"},t.parseCryptoKeyParams=function(e){if(0!==e.indexOf("inline:"))return null;var t=e.substring(7).split("|");return{keyMethod:"inline",keySalt:t[0],lifeTime:t[1],mkiValue:t[2]?t[2].split(":")[0]:void 0,mkiLength:t[2]?t[2].split(":")[1]:void 0}},t.writeCryptoKeyParams=function(e){return e.keyMethod+":"+e.keySalt+(e.lifeTime?"|"+e.lifeTime:"")+(e.mkiValue&&e.mkiLength?"|"+e.mkiValue+":"+e.mkiLength:"")},t.getCryptoParameters=function(e,n){return t.matchPrefix(e+n,"a=crypto:").map(t.parseCryptoLine)},t.getIceParameters=function(e,n){var r=t.matchPrefix(e+n,"a=ice-ufrag:")[0],i=t.matchPrefix(e+n,"a=ice-pwd:")[0];return r&&i?{usernameFragment:r.substring(12),password:i.substring(10)}:null},t.writeIceParameters=function(e){var t="a=ice-ufrag:"+e.usernameFragment+"\r\na=ice-pwd:"+e.password+"\r\n";return e.iceLite&&(t+="a=ice-lite\r\n"),t},t.parseRtpParameters=function(e){var n={codecs:[],headerExtensions:[],fecMechanisms:[],rtcp:[]},r=t.splitLines(e)[0].split(" ");n.profile=r[2];for(var i=3;i<r.length;i++){var a=r[i],o=t.matchPrefix(e,"a=rtpmap:"+a+" ")[0];if(o){var s=t.parseRtpMap(o),c=t.matchPrefix(e,"a=fmtp:"+a+" ");switch(s.parameters=c.length?t.parseFmtp(c[0]):{},s.rtcpFeedback=t.matchPrefix(e,"a=rtcp-fb:"+a+" ").map(t.parseRtcpFb),n.codecs.push(s),s.name.toUpperCase()){case"RED":case"ULPFEC":n.fecMechanisms.push(s.name.toUpperCase())}}}t.matchPrefix(e,"a=extmap:").forEach((function(e){n.headerExtensions.push(t.parseExtmap(e))}));var u=t.matchPrefix(e,"a=rtcp-fb:* ").map(t.parseRtcpFb);return n.codecs.forEach((function(e){u.forEach((function(t){e.rtcpFeedback.find((function(e){return e.type===t.type&&e.parameter===t.parameter}))||e.rtcpFeedback.push(t)}))})),n},t.writeRtpDescription=function(e,n){var r="";r+="m="+e+" ",r+=n.codecs.length>0?"9":"0",r+=" "+(n.profile||"UDP/TLS/RTP/SAVPF")+" ",r+=n.codecs.map((function(e){return void 0!==e.preferredPayloadType?e.preferredPayloadType:e.payloadType})).join(" ")+"\r\n",r+="c=IN IP4 0.0.0.0\r\n",r+="a=rtcp:9 IN IP4 0.0.0.0\r\n",n.codecs.forEach((function(e){r+=t.writeRtpMap(e),r+=t.writeFmtp(e),r+=t.writeRtcpFb(e)}));var i=0;return n.codecs.forEach((function(e){e.maxptime>i&&(i=e.maxptime)})),i>0&&(r+="a=maxptime:"+i+"\r\n"),n.headerExtensions&&n.headerExtensions.forEach((function(e){r+=t.writeExtmap(e)})),r},t.parseRtpEncodingParameters=function(e){var n,r=[],i=t.parseRtpParameters(e),a=-1!==i.fecMechanisms.indexOf("RED"),o=-1!==i.fecMechanisms.indexOf("ULPFEC"),s=t.matchPrefix(e,"a=ssrc:").map((function(e){return t.parseSsrcMedia(e)})).filter((function(e){return"cname"===e.attribute})),c=s.length>0&&s[0].ssrc,u=t.matchPrefix(e,"a=ssrc-group:FID").map((function(e){return e.substring(17).split(" ").map((function(e){return parseInt(e,10)}))}));u.length>0&&u[0].length>1&&u[0][0]===c&&(n=u[0][1]),i.codecs.forEach((function(e){if("RTX"===e.name.toUpperCase()&&e.parameters.apt){var t={ssrc:c,codecPayloadType:parseInt(e.parameters.apt,10)};c&&n&&(t.rtx={ssrc:n}),r.push(t),a&&((t=JSON.parse(JSON.stringify(t))).fec={ssrc:c,mechanism:o?"red+ulpfec":"red"},r.push(t))}})),0===r.length&&c&&r.push({ssrc:c});var l=t.matchPrefix(e,"b=");return l.length&&(l=0===l[0].indexOf("b=TIAS:")?parseInt(l[0].substring(7),10):0===l[0].indexOf("b=AS:")?1e3*parseInt(l[0].substring(5),10)*.95-16e3:void 0,r.forEach((function(e){e.maxBitrate=l}))),r},t.parseRtcpParameters=function(e){var n={},r=t.matchPrefix(e,"a=ssrc:").map((function(e){return t.parseSsrcMedia(e)})).filter((function(e){return"cname"===e.attribute}))[0];r&&(n.cname=r.value,n.ssrc=r.ssrc);var i=t.matchPrefix(e,"a=rtcp-rsize");n.reducedSize=i.length>0,n.compound=0===i.length;var a=t.matchPrefix(e,"a=rtcp-mux");return n.mux=a.length>0,n},t.writeRtcpParameters=function(e){var t="";return e.reducedSize&&(t+="a=rtcp-rsize\r\n"),e.mux&&(t+="a=rtcp-mux\r\n"),void 0!==e.ssrc&&e.cname&&(t+="a=ssrc:"+e.ssrc+" cname:"+e.cname+"\r\n"),t},t.parseMsid=function(e){var n,r=t.matchPrefix(e,"a=msid:");if(1===r.length)return{stream:(n=r[0].substring(7).split(" "))[0],track:n[1]};var i=t.matchPrefix(e,"a=ssrc:").map((function(e){return t.parseSsrcMedia(e)})).filter((function(e){return"msid"===e.attribute}));return i.length>0?{stream:(n=i[0].value.split(" "))[0],track:n[1]}:void 0},t.parseSctpDescription=function(e){var n,r=t.parseMLine(e),i=t.matchPrefix(e,"a=max-message-size:");i.length>0&&(n=parseInt(i[0].substring(19),10)),isNaN(n)&&(n=65536);var a=t.matchPrefix(e,"a=sctp-port:");if(a.length>0)return{port:parseInt(a[0].substring(12),10),protocol:r.fmt,maxMessageSize:n};var o=t.matchPrefix(e,"a=sctpmap:");if(o.length>0){var s=o[0].substring(10).split(" ");return{port:parseInt(s[0],10),protocol:s[1],maxMessageSize:n}}},t.writeSctpDescription=function(e,t){var n=[];return n="DTLS/SCTP"!==e.protocol?["m="+e.kind+" 9 "+e.protocol+" "+t.protocol+"\r\n","c=IN IP4 0.0.0.0\r\n","a=sctp-port:"+t.port+"\r\n"]:["m="+e.kind+" 9 "+e.protocol+" "+t.port+"\r\n","c=IN IP4 0.0.0.0\r\n","a=sctpmap:"+t.port+" "+t.protocol+" 65535\r\n"],void 0!==t.maxMessageSize&&n.push("a=max-message-size:"+t.maxMessageSize+"\r\n"),n.join("")},t.generateSessionId=function(){return Math.random().toString().substr(2,22)},t.writeSessionBoilerplate=function(e,n,r){var i=void 0!==n?n:2;return"v=0\r\no="+(r||"thisisadapterortc")+" "+(e||t.generateSessionId())+" "+i+" IN IP4 127.0.0.1\r\ns=-\r\nt=0 0\r\n"},t.getDirection=function(e,n){for(var r=t.splitLines(e),i=0;i<r.length;i++)switch(r[i]){case"a=sendrecv":case"a=sendonly":case"a=recvonly":case"a=inactive":return r[i].substring(2)}return n?t.getDirection(n):"sendrecv"},t.getKind=function(e){return t.splitLines(e)[0].split(" ")[0].substring(2)},t.isRejected=function(e){return"0"===e.split(" ",2)[1]},t.parseMLine=function(e){var n=t.splitLines(e)[0].substring(2).split(" ");return{kind:n[0],port:parseInt(n[1],10),protocol:n[2],fmt:n.slice(3).join(" ")}},t.parseOLine=function(e){var n=t.matchPrefix(e,"o=")[0].substring(2).split(" ");return{username:n[0],sessionId:n[1],sessionVersion:parseInt(n[2],10),netType:n[3],addressType:n[4],address:n[5]}},t.isValidSDP=function(e){if("string"!=typeof e||0===e.length)return!1;for(var n=t.splitLines(e),r=0;r<n.length;r++)if(n[r].length<2||"="!==n[r].charAt(1))return!1;return!0},e.exports=t}(bA);var AA=IA,RA=function(e,t){return t.forEach((function(t){t&&"string"!=typeof t&&!Array.isArray(t)&&Object.keys(t).forEach((function(n){if("default"!==n&&!(n in e)){var r=Object.getOwnPropertyDescriptor(t,n);Object.defineProperty(e,n,r.get?r:{enumerable:!0,get:function(){return t[n]}})}}))})),Object.freeze(e)}({__proto__:null,default:AA},[IA]);function CA(e){if(!(!e.RTCIceCandidate||e.RTCIceCandidate&&"foundation"in e.RTCIceCandidate.prototype)){var t=e.RTCIceCandidate;e.RTCIceCandidate=function(e){if("object"==k(e)&&e.candidate&&0===e.candidate.indexOf("a=")&&((e=JSON.parse(JSON.stringify(e))).candidate=e.candidate.substring(2)),e.candidate&&e.candidate.length){var n=new t(e),r=AA.parseCandidate(e.candidate);for(var i in r)i in n||Object.defineProperty(n,i,{value:r[i]});return n.toJSON=function(){return{candidate:n.candidate,sdpMid:n.sdpMid,sdpMLineIndex:n.sdpMLineIndex,usernameFragment:n.usernameFragment}},n}return new t(e)},e.RTCIceCandidate.prototype=t.prototype,Mb(e,"icecandidate",(function(t){return t.candidate&&Object.defineProperty(t,"candidate",{value:new e.RTCIceCandidate(t.candidate),writable:"false"}),t}))}}function wA(e){!e.RTCIceCandidate||e.RTCIceCandidate&&"relayProtocol"in e.RTCIceCandidate.prototype||Mb(e,"icecandidate",(function(e){if(e.candidate){var t=AA.parseCandidate(e.candidate.candidate);"relay"===t.type&&(e.candidate.relayProtocol={0:"tls",1:"tcp",2:"udp"}[t.priority>>24])}return e}))}function DA(e,t){if(e.RTCPeerConnection){"sctp"in e.RTCPeerConnection.prototype||Object.defineProperty(e.RTCPeerConnection.prototype,"sctp",{get:function(){return void 0===this._sctp?null:this._sctp}});var n=e.RTCPeerConnection.prototype.setRemoteDescription;e.RTCPeerConnection.prototype.setRemoteDescription=function(){if(this._sctp=null,"chrome"===t.browser&&t.version>=76&&"plan-b"===this.getConfiguration().sdpSemantics&&Object.defineProperty(this,"sctp",{get:function(){return void 0===this._sctp?null:this._sctp},enumerable:!0,configurable:!0}),function(e){if(!e||!e.sdp)return!1;var t=AA.splitSections(e.sdp);return t.shift(),t.some((function(e){var t=AA.parseMLine(e);return t&&"application"===t.kind&&-1!==t.protocol.indexOf("SCTP")}))}(arguments[0])){var e,r=function(e){var t=e.sdp.match(/mozilla...THIS_IS_SDPARTA-(\d+)/);if(null===t||t.length<2)return-1;var n=parseInt(t[1],10);return n!=n?-1:n}(arguments[0]),i=function(e){var n=65536;return"firefox"===t.browser&&(n=t.version<57?-1===e?16384:2147483637:t.version<60?57===t.version?65535:65536:2147483637),n}(r),a=function(e,n){var r=65536;"firefox"===t.browser&&57===t.version&&(r=65535);var i=AA.matchPrefix(e.sdp,"a=max-message-size:");return i.length>0?r=parseInt(i[0].substring(19),10):"firefox"===t.browser&&-1!==n&&(r=2147483637),r}(arguments[0],r);e=0===i&&0===a?Number.POSITIVE_INFINITY:0===i||0===a?Math.max(i,a):Math.min(i,a);var o={};Object.defineProperty(o,"maxMessageSize",{get:function(){return e}}),this._sctp=o}return n.apply(this,arguments)}}}function NA(e){if(e.RTCPeerConnection&&"createDataChannel"in e.RTCPeerConnection.prototype){var t=e.RTCPeerConnection.prototype.createDataChannel;e.RTCPeerConnection.prototype.createDataChannel=function(){var e=t.apply(this,arguments);return n(e,this),e},Mb(e,"datachannel",(function(e){return n(e.channel,e.target),e}))}function n(e,t){var n=e.send;e.send=function(){var r=arguments[0],i=r.length||r.size||r.byteLength;if("open"===e.readyState&&t.sctp&&i>t.sctp.maxMessageSize)throw new TypeError("Message too large (can send a maximum of "+t.sctp.maxMessageSize+" bytes)");return n.apply(e,arguments)}}}function xA(e){if(e.RTCPeerConnection&&!("connectionState"in e.RTCPeerConnection.prototype)){var t=e.RTCPeerConnection.prototype;Object.defineProperty(t,"connectionState",{get:function(){return{completed:"connected",checking:"connecting"}[this.iceConnectionState]||this.iceConnectionState},enumerable:!0,configurable:!0}),Object.defineProperty(t,"onconnectionstatechange",{get:function(){return this._onconnectionstatechange||null},set:function(e){this._onconnectionstatechange&&(this.removeEventListener("connectionstatechange",this._onconnectionstatechange),delete this._onconnectionstatechange),e&&this.addEventListener("connectionstatechange",this._onconnectionstatechange=e)},enumerable:!0,configurable:!0}),["setLocalDescription","setRemoteDescription"].forEach((function(e){var n=t[e];t[e]=function(){return this._connectionstatechangepoly||(this._connectionstatechangepoly=function(e){var t=e.target;if(t._lastConnectionState!==t.connectionState){t._lastConnectionState=t.connectionState;var n=new Event("connectionstatechange",e);t.dispatchEvent(n)}return e},this.addEventListener("iceconnectionstatechange",this._connectionstatechangepoly)),n.apply(this,arguments)}}))}}function OA(e,t){if(e.RTCPeerConnection&&!("chrome"===t.browser&&t.version>=71||"safari"===t.browser&&t.version>=605)){var n=e.RTCPeerConnection.prototype.setRemoteDescription;e.RTCPeerConnection.prototype.setRemoteDescription=function(t){if(t&&t.sdp&&-1!==t.sdp.indexOf("\na=extmap-allow-mixed")){var r=t.sdp.split("\n").filter((function(e){return"a=extmap-allow-mixed"!==e.trim()})).join("\n");e.RTCSessionDescription&&t instanceof e.RTCSessionDescription?arguments[0]=new e.RTCSessionDescription({type:t.type,sdp:r}):t.sdp=r}return n.apply(this,arguments)}}}function PA(e,t){if(e.RTCPeerConnection&&e.RTCPeerConnection.prototype){var n=e.RTCPeerConnection.prototype.addIceCandidate;n&&0!==n.length&&(e.RTCPeerConnection.prototype.addIceCandidate=function(){return arguments[0]?("chrome"===t.browser&&t.version<78||"firefox"===t.browser&&t.version<68||"safari"===t.browser)&&arguments[0]&&""===arguments[0].candidate?Promise.resolve():n.apply(this,arguments):(arguments[1]&&arguments[1].apply(null),Promise.resolve())})}}function MA(e,t){if(e.RTCPeerConnection&&e.RTCPeerConnection.prototype){var n=e.RTCPeerConnection.prototype.setLocalDescription;n&&0!==n.length&&(e.RTCPeerConnection.prototype.setLocalDescription=function(){var e=this,t=arguments[0]||{};if("object"!=k(t)||t.type&&t.sdp)return n.apply(this,arguments);if(!(t={type:t.type,sdp:t.sdp}).type)switch(this.signalingState){case"stable":case"have-local-offer":case"have-remote-pranswer":t.type="offer";break;default:t.type="answer"}return t.sdp||"offer"!==t.type&&"answer"!==t.type?n.apply(this,[t]):("offer"===t.type?this.createOffer:this.createAnswer).apply(this).then((function(t){return n.apply(e,[t])}))})}}var LA=Object.freeze({__proto__:null,shimRTCIceCandidate:CA,shimRTCIceCandidateRelayProtocol:wA,shimMaxMessageSize:DA,shimSendThrowTypeError:NA,shimConnectionState:xA,removeExtmapAllowMixed:OA,shimAddIceCandidateNullOrEmpty:PA,shimParameterlessSetLocalDescription:MA});!function(){var e=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}).window,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{shimChrome:!0,shimFirefox:!0,shimSafari:!0},n=Ub,r=function(e){var t={browser:null,version:null};if(void 0===e||!e.navigator||!e.navigator.userAgent)return t.browser="Not a browser.",t;var n=e.navigator;if(n.mozGetUserMedia)t.browser="firefox",t.version=Pb(n.userAgent,/Firefox\/(\d+)\./,1);else if(n.webkitGetUserMedia||!1===e.isSecureContext&&e.webkitRTCPeerConnection)t.browser="chrome",t.version=Pb(n.userAgent,/Chrom(e|ium)\/(\d+)\./,2);else{if(!e.RTCPeerConnection||!n.userAgent.match(/AppleWebKit\/(\d+)\./))return t.browser="Not a supported browser.",t;t.browser="safari",t.version=Pb(n.userAgent,/AppleWebKit\/(\d+)\./,1),t.supportsUnifiedPlan=e.RTCRtpTransceiver&&"currentDirection"in e.RTCRtpTransceiver.prototype}return t}(e),i={browserDetails:r,commonShim:LA,extractVersion:Pb,disableLog:Lb,disableWarnings:Vb,sdp:RA};switch(r.browser){case"chrome":if(!tA||!Zb||!t.shimChrome)return n("Chrome shim is not included in this adapter release."),i;if(null===r.version)return n("Chrome shim can not determine version, not shimming."),i;n("adapter.js shimming chrome."),i.browserShim=tA,PA(e,r),MA(e),Jb(e,r),Kb(e),Zb(e,r),zb(e),$b(e,r),Yb(e),qb(e),Xb(e),eA(e,r),CA(e),wA(e),xA(e),DA(e,r),NA(e),OA(e,r);break;case"firefox":if(!fA||!iA||!t.shimFirefox)return n("Firefox shim is not included in this adapter release."),i;n("adapter.js shimming firefox."),i.browserShim=fA,PA(e,r),MA(e),nA(e,r),iA(e,r),rA(e),sA(e),aA(e),oA(e),cA(e),uA(e),lA(e),dA(e),hA(e),CA(e),xA(e),DA(e,r),NA(e);break;case"safari":if(!SA||!t.shimSafari)return n("Safari shim is not included in this adapter release."),i;n("adapter.js shimming safari."),i.browserShim=SA,PA(e,r),MA(e),yA(e),TA(e),vA(e),pA(e),mA(e),EA(e),_A(e),kA(e),CA(e),wA(e),DA(e,r),NA(e),OA(e,r);break;default:n("Unsupported browser!")}}({window:"undefined"==typeof window?void 0:window});var VA,UA=Object.create,FA=Object.defineProperty,BA=Object.defineProperties,jA=Object.getOwnPropertyDescriptor,HA=Object.getOwnPropertyDescriptors,GA=Object.getOwnPropertyNames,WA=Object.getOwnPropertySymbols,JA=Object.getPrototypeOf,KA=Object.prototype.hasOwnProperty,zA=Object.prototype.propertyIsEnumerable,YA=Reflect.get,qA=Math.pow,XA=function(e,t,n){return t in e?FA(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n},QA=function(e,t){for(var n in t||(t={}))KA.call(t,n)&&XA(e,n,t[n]);if(WA){var r,i=s(WA(t));try{for(i.s();!(r=i.n()).done;)n=r.value,zA.call(t,n)&&XA(e,n,t[n])}catch(a){i.e(a)}finally{i.f()}}return e},$A=function(e,t){return BA(e,HA(t))},ZA=function(e,t){return function(){return t||e((t={exports:{}}).exports,t),t.exports}},eR=function(e,t){for(var n in t)FA(e,n,{get:t[n],enumerable:!0})},tR=function(e,t,n){return n=null!=e?UA(JA(e)):{},function(e,t,n,r){if(t&&"object"==k(t)||"function"==typeof t){var i,a=s(GA(t));try{var o=function(){var n=i.value;!KA.call(e,n)&&void 0!==n&&FA(e,n,{get:function(){return t[n]},enumerable:!(r=jA(t,n))||r.enumerable})};for(a.s();!(i=a.n()).done;)o()}catch(c){a.e(c)}finally{a.f()}}return e}(!t&&e&&e.__esModule?n:FA(n,"default",{value:e,enumerable:!0}),e)},nR=function(e,t,n,r){for(var i,a=r>1?void 0:r?jA(t,n):t,o=e.length-1;o>=0;o--)(i=e[o])&&(a=(r?i(t,n,a):i(a))||a);return r&&a&&FA(t,n,a),a},rR=function(e,t,n){return XA(e,"symbol"!=k(t)?t+"":t,n)},iR=function(e,t,n){return YA(JA(e),n,t)},aR=function(e,t,n){return new Promise((function(r,i){var a=function(e){try{s(n.next(e))}catch(fx){i(fx)}},o=function(e){try{s(n.throw(e))}catch(fx){i(fx)}},s=function(e){return e.done?r(e.value):Promise.resolve(e.value).then(a,o)};s((n=n.apply(e,t)).next())}))},oR=ZA((function(e,t){var n=Object.prototype.hasOwnProperty,r="~";function i(){}function a(e,t,n){this.fn=e,this.context=t,this.once=n||!1}function o(e,t,n,i,o){if("function"!=typeof n)throw new TypeError("The listener must be a function");var s=new a(n,i||e,o),c=r?r+t:t;return e._events[c]?e._events[c].fn?e._events[c]=[e._events[c],s]:e._events[c].push(s):(e._events[c]=s,e._eventsCount++),e}function s(e,t){0==--e._eventsCount?e._events=new i:delete e._events[t]}function c(){this._events=new i,this._eventsCount=0}Object.create&&(i.prototype=Object.create(null),(new i).__proto__||(r=!1)),c.prototype.eventNames=function(){var e,t,i=[];if(0===this._eventsCount)return i;for(t in e=this._events)n.call(e,t)&&i.push(r?t.slice(1):t);return Object.getOwnPropertySymbols?i.concat(Object.getOwnPropertySymbols(e)):i},c.prototype.listeners=function(e){var t=r?r+e:e,n=this._events[t];if(!n)return[];if(n.fn)return[n.fn];for(var i=0,a=n.length,o=new Array(a);i<a;i++)o[i]=n[i].fn;return o},c.prototype.listenerCount=function(e){var t=r?r+e:e,n=this._events[t];return n?n.fn?1:n.length:0},c.prototype.emit=function(e,t,n,i,a,o){var s=r?r+e:e;if(!this._events[s])return!1;var c,u,l=this._events[s],d=arguments.length;if(l.fn){switch(l.once&&this.removeListener(e,l.fn,void 0,!0),d){case 1:return l.fn.call(l.context),!0;case 2:return l.fn.call(l.context,t),!0;case 3:return l.fn.call(l.context,t,n),!0;case 4:return l.fn.call(l.context,t,n,i),!0;case 5:return l.fn.call(l.context,t,n,i,a),!0;case 6:return l.fn.call(l.context,t,n,i,a,o),!0}for(u=1,c=new Array(d-1);u<d;u++)c[u-1]=arguments[u];l.fn.apply(l.context,c)}else{var h,f=l.length;for(u=0;u<f;u++)switch(l[u].once&&this.removeListener(e,l[u].fn,void 0,!0),d){case 1:l[u].fn.call(l[u].context);break;case 2:l[u].fn.call(l[u].context,t);break;case 3:l[u].fn.call(l[u].context,t,n);break;case 4:l[u].fn.call(l[u].context,t,n,i);break;default:if(!c)for(h=1,c=new Array(d-1);h<d;h++)c[h-1]=arguments[h];l[u].fn.apply(l[u].context,c)}}return!0},c.prototype.on=function(e,t,n){return o(this,e,t,n,!1)},c.prototype.once=function(e,t,n){return o(this,e,t,n,!0)},c.prototype.removeListener=function(e,t,n,i){var a=r?r+e:e;if(!this._events[a])return this;if(!t)return s(this,a),this;var o=this._events[a];if(o.fn)o.fn===t&&(!i||o.once)&&(!n||o.context===n)&&s(this,a);else{for(var c=0,u=[],l=o.length;c<l;c++)(o[c].fn!==t||i&&!o[c].once||n&&o[c].context!==n)&&u.push(o[c]);u.length?this._events[a]=1===u.length?u[0]:u:s(this,a)}return this},c.prototype.removeAllListeners=function(e){var t;return e?(t=r?r+e:e,this._events[t]&&s(this,t)):(this._events=new i,this._eventsCount=0),this},c.prototype.off=c.prototype.removeListener,c.prototype.addListener=c.prototype.on,c.prefixed=r,c.EventEmitter=c,void 0!==t&&(t.exports=c)})),sR=ZA((function(e,t){var n=t.exports={v:[{name:"version",reg:/^(\d*)$/}],o:[{name:"origin",reg:/^(\S*) (\d*) (\d*) (\S*) IP(\d) (\S*)/,names:["username","sessionId","sessionVersion","netType","ipVer","address"],format:"%s %s %d %s IP%d %s"}],s:[{name:"name"}],i:[{name:"description"}],u:[{name:"uri"}],e:[{name:"email"}],p:[{name:"phone"}],z:[{name:"timezones"}],r:[{name:"repeats"}],t:[{name:"timing",reg:/^(\d*) (\d*)/,names:["start","stop"],format:"%d %d"}],c:[{name:"connection",reg:/^IN IP(\d) (\S*)/,names:["version","ip"],format:"IN IP%d %s"}],b:[{push:"bandwidth",reg:/^(TIAS|AS|CT|RR|RS):(\d*)/,names:["type","limit"],format:"%s:%s"}],m:[{reg:/^(\w*) (\d*) ([\w/]*)(?: (.*))?/,names:["type","port","protocol","payloads"],format:"%s %d %s %s"}],a:[{push:"rtp",reg:/^rtpmap:(\d*) ([\w\-.]*)(?:\s*\/(\d*)(?:\s*\/(\S*))?)?/,names:["payload","codec","rate","encoding"],format:function(e){return e.encoding?"rtpmap:%d %s/%s/%s":e.rate?"rtpmap:%d %s/%s":"rtpmap:%d %s"}},{push:"fmtp",reg:/^fmtp:(\d*) ([\S| ]*)/,names:["payload","config"],format:"fmtp:%d %s"},{name:"control",reg:/^control:(.*)/,format:"control:%s"},{name:"rtcp",reg:/^rtcp:(\d*)(?: (\S*) IP(\d) (\S*))?/,names:["port","netType","ipVer","address"],format:function(e){return null!=e.address?"rtcp:%d %s IP%d %s":"rtcp:%d"}},{push:"rtcpFbTrrInt",reg:/^rtcp-fb:(\*|\d*) trr-int (\d*)/,names:["payload","value"],format:"rtcp-fb:%s trr-int %d"},{push:"rtcpFb",reg:/^rtcp-fb:(\*|\d*) ([\w-_]*)(?: ([\w-_]*))?/,names:["payload","type","subtype"],format:function(e){return null!=e.subtype?"rtcp-fb:%s %s %s":"rtcp-fb:%s %s"}},{push:"ext",reg:/^extmap:(\d+)(?:\/(\w+))?(?: (urn:ietf:params:rtp-hdrext:encrypt))? (\S*)(?: (\S*))?/,names:["value","direction","encrypt-uri","uri","config"],format:function(e){return"extmap:%d"+(e.direction?"/%s":"%v")+(e["encrypt-uri"]?" %s":"%v")+" %s"+(e.config?" %s":"")}},{name:"extmapAllowMixed",reg:/^(extmap-allow-mixed)/},{push:"crypto",reg:/^crypto:(\d*) ([\w_]*) (\S*)(?: (\S*))?/,names:["id","suite","config","sessionConfig"],format:function(e){return null!=e.sessionConfig?"crypto:%d %s %s %s":"crypto:%d %s %s"}},{name:"setup",reg:/^setup:(\w*)/,format:"setup:%s"},{name:"connectionType",reg:/^connection:(new|existing)/,format:"connection:%s"},{name:"mid",reg:/^mid:([^\s]*)/,format:"mid:%s"},{name:"msid",reg:/^msid:(.*)/,format:"msid:%s"},{name:"ptime",reg:/^ptime:(\d*(?:\.\d*)*)/,format:"ptime:%d"},{name:"maxptime",reg:/^maxptime:(\d*(?:\.\d*)*)/,format:"maxptime:%d"},{name:"direction",reg:/^(sendrecv|recvonly|sendonly|inactive)/},{name:"icelite",reg:/^(ice-lite)/},{name:"iceUfrag",reg:/^ice-ufrag:(\S*)/,format:"ice-ufrag:%s"},{name:"icePwd",reg:/^ice-pwd:(\S*)/,format:"ice-pwd:%s"},{name:"fingerprint",reg:/^fingerprint:(\S*) (\S*)/,names:["type","hash"],format:"fingerprint:%s %s"},{push:"candidates",reg:/^candidate:(\S*) (\d*) (\S*) (\d*) (\S*) (\d*) typ (\S*)(?: raddr (\S*) rport (\d*))?(?: tcptype (\S*))?(?: generation (\d*))?(?: network-id (\d*))?(?: network-cost (\d*))?/,names:["foundation","component","transport","priority","ip","port","type","raddr","rport","tcptype","generation","network-id","network-cost"],format:function(e){var t="candidate:%s %d %s %d %s %d typ %s";return t+=null!=e.raddr?" raddr %s rport %d":"%v%v",t+=null!=e.tcptype?" tcptype %s":"%v",null!=e.generation&&(t+=" generation %d"),(t+=null!=e["network-id"]?" network-id %d":"%v")+(null!=e["network-cost"]?" network-cost %d":"%v")}},{name:"endOfCandidates",reg:/^(end-of-candidates)/},{name:"remoteCandidates",reg:/^remote-candidates:(.*)/,format:"remote-candidates:%s"},{name:"iceOptions",reg:/^ice-options:(\S*)/,format:"ice-options:%s"},{push:"ssrcs",reg:/^ssrc:(\d*) ([\w_-]*)(?::(.*))?/,names:["id","attribute","value"],format:function(e){var t="ssrc:%d";return null!=e.attribute&&(t+=" %s",null!=e.value&&(t+=":%s")),t}},{push:"ssrcGroups",reg:/^ssrc-group:([\x21\x23\x24\x25\x26\x27\x2A\x2B\x2D\x2E\w]*) (.*)/,names:["semantics","ssrcs"],format:"ssrc-group:%s %s"},{name:"msidSemantic",reg:/^msid-semantic:\s?(\w*) (\S*)/,names:["semantic","token"],format:"msid-semantic: %s %s"},{push:"groups",reg:/^group:(\w*) (.*)/,names:["type","mids"],format:"group:%s %s"},{name:"rtcpMux",reg:/^(rtcp-mux)/},{name:"rtcpRsize",reg:/^(rtcp-rsize)/},{name:"sctpmap",reg:/^sctpmap:([\w_/]*) (\S*)(?: (\S*))?/,names:["sctpmapNumber","app","maxMessageSize"],format:function(e){return null!=e.maxMessageSize?"sctpmap:%s %s %s":"sctpmap:%s %s"}},{name:"xGoogleFlag",reg:/^x-google-flag:([^\s]*)/,format:"x-google-flag:%s"},{push:"rids",reg:/^rid:([\d\w]+) (\w+)(?: ([\S| ]*))?/,names:["id","direction","params"],format:function(e){return e.params?"rid:%s %s %s":"rid:%s %s"}},{push:"imageattrs",reg:new RegExp("^imageattr:(\\d+|\\*)[\\s\\t]+(send|recv)[\\s\\t]+(\\*|\\[\\S+\\](?:[\\s\\t]+\\[\\S+\\])*)(?:[\\s\\t]+(recv|send)[\\s\\t]+(\\*|\\[\\S+\\](?:[\\s\\t]+\\[\\S+\\])*))?"),names:["pt","dir1","attrs1","dir2","attrs2"],format:function(e){return"imageattr:%s %s %s"+(e.dir2?" %s %s":"")}},{name:"simulcast",reg:new RegExp("^simulcast:(send|recv) ([a-zA-Z0-9\\-_~;,]+)(?:\\s?(send|recv) ([a-zA-Z0-9\\-_~;,]+))?$"),names:["dir1","list1","dir2","list2"],format:function(e){return"simulcast:%s %s"+(e.dir2?" %s %s":"")}},{name:"simulcast_03",reg:/^simulcast:[\s\t]+([\S+\s\t]+)$/,names:["value"],format:"simulcast: %s"},{name:"framerate",reg:/^framerate:(\d+(?:$|\.\d+))/,format:"framerate:%s"},{name:"sourceFilter",reg:/^source-filter: *(excl|incl) (\S*) (IP4|IP6|\*) (\S*) (.*)/,names:["filterMode","netType","addressTypes","destAddress","srcList"],format:"source-filter: %s %s %s %s %s"},{name:"bundleOnly",reg:/^(bundle-only)/},{name:"label",reg:/^label:(.+)/,format:"label:%s"},{name:"sctpPort",reg:/^sctp-port:(\d+)$/,format:"sctp-port:%s"},{name:"maxMessageSize",reg:/^max-message-size:(\d+)$/,format:"max-message-size:%s"},{push:"tsRefClocks",reg:/^ts-refclk:([^\s=]*)(?:=(\S*))?/,names:["clksrc","clksrcExt"],format:function(e){return"ts-refclk:%s"+(null!=e.clksrcExt?"=%s":"")}},{name:"mediaClk",reg:/^mediaclk:(?:id=(\S*))? *([^\s=]*)(?:=(\S*))?(?: *rate=(\d+)\/(\d+))?/,names:["id","mediaClockName","mediaClockValue","rateNumerator","rateDenominator"],format:function(e){var t="mediaclk:";return t+=null!=e.id?"id=%s %s":"%v%s",t+=null!=e.mediaClockValue?"=%s":"",(t+=null!=e.rateNumerator?" rate=%s":"")+(null!=e.rateDenominator?"/%s":"")}},{name:"keywords",reg:/^keywds:(.+)$/,format:"keywds:%s"},{name:"content",reg:/^content:(.+)/,format:"content:%s"},{name:"bfcpFloorCtrl",reg:/^floorctrl:(c-only|s-only|c-s)/,format:"floorctrl:%s"},{name:"bfcpConfId",reg:/^confid:(\d+)/,format:"confid:%s"},{name:"bfcpUserId",reg:/^userid:(\d+)/,format:"userid:%s"},{name:"bfcpFloorId",reg:/^floorid:(.+) (?:m-stream|mstrm):(.+)/,names:["id","mStream"],format:"floorid:%s mstrm:%s"},{push:"invalid",names:["value"]}]};Object.keys(n).forEach((function(e){n[e].forEach((function(e){e.reg||(e.reg=/(.*)/),e.format||(e.format="%s")}))}))})),cR=ZA((function(e){var t=function(e){return String(Number(e))===e?Number(e):e},n=function(e,n,r){var i=e.name&&e.names;e.push&&!n[e.push]?n[e.push]=[]:i&&!n[e.name]&&(n[e.name]={});var a=e.push?{}:i?n[e.name]:n;(function(e,n,r,i){if(i&&!r)n[i]=t(e[1]);else for(var a=0;a<r.length;a+=1)null!=e[a+1]&&(n[r[a]]=t(e[a+1]))})(r.match(e.reg),a,e.names,e.name),e.push&&n[e.push].push(a)},r=sR(),i=RegExp.prototype.test.bind(/^([a-z])=(.*)/);e.parse=function(e){var t={},a=[],o=t;return e.split(/(\r\n|\r|\n)/).filter(i).forEach((function(e){var t=e[0],i=e.slice(2);"m"===t&&(a.push({rtp:[],fmtp:[]}),o=a[a.length-1]);for(var s=0;s<(r[t]||[]).length;s+=1){var c=r[t][s];if(c.reg.test(i))return n(c,o,i)}})),t.media=a,t};var a=function(e,n){var r=n.split(/=(.+)/,2);return 2===r.length?e[r[0]]=t(r[1]):1===r.length&&n.length>1&&(e[r[0]]=void 0),e};e.parseParams=function(e){return e.split(/;\s?/).reduce(a,{})},e.parseFmtpConfig=e.parseParams,e.parsePayloads=function(e){return e.toString().split(" ").map(Number)},e.parseRemoteCandidates=function(e){for(var n=[],r=e.split(" ").map(t),i=0;i<r.length;i+=3)n.push({component:r[i],ip:r[i+1],port:r[i+2]});return n},e.parseImageAttributes=function(e){return e.split(" ").map((function(e){return e.substring(1,e.length-1).split(",").reduce(a,{})}))},e.parseSimulcastStreamList=function(e){return e.split(";").map((function(e){return e.split(",").map((function(e){var n,r=!1;return"~"!==e[0]?n=t(e):(n=t(e.substring(1,e.length)),r=!0),{scid:n,paused:r}}))}))}})),uR=ZA((function(e,t){var n=sR(),r=/%[sdv%]/g,i=function(e){var t=1,n=arguments,i=n.length;return e.replace(r,(function(e){if(t>=i)return e;var r=n[t];switch(t+=1,e){case"%%":return"%";case"%s":return String(r);case"%d":return Number(r);case"%v":return""}}))},a=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 a=0;a<t.names.length;a+=1){var o=t.names[a];t.name?r.push(n[t.name][o]):r.push(n[t.names[a]])}else r.push(n[t.name]);return i.apply(null,r)},o=["v","o","s","i","u","e","p","c","b","t","r","z","a"],s=["i","c","b","a"];t.exports=function(e,t){t=t||{},null==e.version&&(e.version=0),null==e.name&&(e.name=" "),e.media.forEach((function(e){null==e.payloads&&(e.payloads="")}));var r=t.outerOrder||o,i=t.innerOrder||s,c=[];return r.forEach((function(t){n[t].forEach((function(n){n.name in e&&null!=e[n.name]?c.push(a(t,n,e)):n.push in e&&null!=e[n.push]&&e[n.push].forEach((function(e){c.push(a(t,n,e))}))}))})),e.media.forEach((function(e){c.push(a("m",n.m[0],e)),i.forEach((function(t){n[t].forEach((function(n){n.name in e&&null!=e[n.name]?c.push(a(t,n,e)):n.push in e&&null!=e[n.push]&&e[n.push].forEach((function(e){c.push(a(t,n,e))}))}))}))})),c.join("\r\n")+"\r\n"}})),lR=ZA((function(e){var t=cR(),n=uR();e.write=n,e.parse=t.parse,e.parseParams=t.parseParams,e.parseFmtpConfig=t.parseFmtpConfig,e.parsePayloads=t.parsePayloads,e.parseRemoteCandidates=t.parseRemoteCandidates,e.parseImageAttributes=t.parseImageAttributes,e.parseSimulcastStreamList=t.parseSimulcastStreamList})),dR=ZA((function(e,t){var n=t.exports={v:[{name:"version",reg:/^(\d*)$/}],o:[{name:"origin",reg:/^(\S*) (\d*) (\d*) (\S*) IP(\d) (\S*)/,names:["username","sessionId","sessionVersion","netType","ipVer","address"],format:"%s %s %d %s IP%d %s"}],s:[{name:"name"}],i:[{name:"description"}],u:[{name:"uri"}],e:[{name:"email"}],p:[{name:"phone"}],z:[{name:"timezones"}],r:[{name:"repeats"}],t:[{name:"timing",reg:/^(\d*) (\d*)/,names:["start","stop"],format:"%d %d"}],c:[{name:"connection",reg:/^IN IP(\d) (\S*)/,names:["version","ip"],format:"IN IP%d %s"}],b:[{push:"bandwidth",reg:/^(TIAS|AS|CT|RR|RS):(\d*)/,names:["type","limit"],format:"%s:%s"}],m:[{reg:/^(\w*) (\d*) ([\w/]*)(?: (.*))?/,names:["type","port","protocol","payloads"],format:"%s %d %s %s"}],a:[{push:"rtp",reg:/^rtpmap:(\d*) ([\w\-.]*)(?:\s*\/(\d*)(?:\s*\/(\S*))?)?/,names:["payload","codec","rate","encoding"],format:function(e){return e.encoding?"rtpmap:%d %s/%s/%s":e.rate?"rtpmap:%d %s/%s":"rtpmap:%d %s"}},{push:"fmtp",reg:/^fmtp:(\d*) ([\S| ]*)/,names:["payload","config"],format:"fmtp:%d %s"},{name:"control",reg:/^control:(.*)/,format:"control:%s"},{name:"rtcp",reg:/^rtcp:(\d*)(?: (\S*) IP(\d) (\S*))?/,names:["port","netType","ipVer","address"],format:function(e){return null!=e.address?"rtcp:%d %s IP%d %s":"rtcp:%d"}},{push:"rtcpFbTrrInt",reg:/^rtcp-fb:(\*|\d*) trr-int (\d*)/,names:["payload","value"],format:"rtcp-fb:%s trr-int %d"},{push:"rtcpFb",reg:/^rtcp-fb:(\*|\d*) ([\w-_]*)(?: ([\w-_]*))?/,names:["payload","type","subtype"],format:function(e){return null!=e.subtype?"rtcp-fb:%s %s %s":"rtcp-fb:%s %s"}},{push:"ext",reg:/^extmap:(\d+)(?:\/(\w+))?(?: (urn:ietf:params:rtp-hdrext:encrypt))? (\S*)(?: (\S*))?/,names:["value","direction","encrypt-uri","uri","config"],format:function(e){return"extmap:%d"+(e.direction?"/%s":"%v")+(e["encrypt-uri"]?" %s":"%v")+" %s"+(e.config?" %s":"")}},{name:"extmapAllowMixed",reg:/^(extmap-allow-mixed)/},{push:"crypto",reg:/^crypto:(\d*) ([\w_]*) (\S*)(?: (\S*))?/,names:["id","suite","config","sessionConfig"],format:function(e){return null!=e.sessionConfig?"crypto:%d %s %s %s":"crypto:%d %s %s"}},{name:"setup",reg:/^setup:(\w*)/,format:"setup:%s"},{name:"connectionType",reg:/^connection:(new|existing)/,format:"connection:%s"},{name:"mid",reg:/^mid:([^\s]*)/,format:"mid:%s"},{name:"msid",reg:/^msid:(.*)/,format:"msid:%s"},{name:"ptime",reg:/^ptime:(\d*(?:\.\d*)*)/,format:"ptime:%d"},{name:"maxptime",reg:/^maxptime:(\d*(?:\.\d*)*)/,format:"maxptime:%d"},{name:"direction",reg:/^(sendrecv|recvonly|sendonly|inactive)/},{name:"icelite",reg:/^(ice-lite)/},{name:"iceUfrag",reg:/^ice-ufrag:(\S*)/,format:"ice-ufrag:%s"},{name:"icePwd",reg:/^ice-pwd:(\S*)/,format:"ice-pwd:%s"},{name:"fingerprint",reg:/^fingerprint:(\S*) (\S*)/,names:["type","hash"],format:"fingerprint:%s %s"},{push:"candidates",reg:/^candidate:(\S*) (\d*) (\S*) (\d*) (\S*) (\d*) typ (\S*)(?: raddr (\S*) rport (\d*))?(?: tcptype (\S*))?(?: generation (\d*))?(?: network-id (\d*))?(?: network-cost (\d*))?/,names:["foundation","component","transport","priority","ip","port","type","raddr","rport","tcptype","generation","network-id","network-cost"],format:function(e){var t="candidate:%s %d %s %d %s %d typ %s";return t+=null!=e.raddr?" raddr %s rport %d":"%v%v",t+=null!=e.tcptype?" tcptype %s":"%v",null!=e.generation&&(t+=" generation %d"),(t+=null!=e["network-id"]?" network-id %d":"%v")+(null!=e["network-cost"]?" network-cost %d":"%v")}},{name:"endOfCandidates",reg:/^(end-of-candidates)/},{name:"remoteCandidates",reg:/^remote-candidates:(.*)/,format:"remote-candidates:%s"},{name:"iceOptions",reg:/^ice-options:(\S*)/,format:"ice-options:%s"},{push:"ssrcs",reg:/^ssrc:(\d*) ([\w_-]*)(?::(.*))?/,names:["id","attribute","value"],format:function(e){var t="ssrc:%d";return null!=e.attribute&&(t+=" %s",null!=e.value&&(t+=":%s")),t}},{push:"ssrcGroups",reg:/^ssrc-group:([\x21\x23\x24\x25\x26\x27\x2A\x2B\x2D\x2E\w]*) (.*)/,names:["semantics","ssrcs"],format:"ssrc-group:%s %s"},{name:"msidSemantic",reg:/^msid-semantic:\s?(\w*) (\S*)/,names:["semantic","token"],format:"msid-semantic: %s %s"},{push:"groups",reg:/^group:(\w*) (.*)/,names:["type","mids"],format:"group:%s %s"},{name:"rtcpMux",reg:/^(rtcp-mux)/},{name:"rtcpRsize",reg:/^(rtcp-rsize)/},{name:"sctpmap",reg:/^sctpmap:([\w_/]*) (\S*)(?: (\S*))?/,names:["sctpmapNumber","app","maxMessageSize"],format:function(e){return null!=e.maxMessageSize?"sctpmap:%s %s %s":"sctpmap:%s %s"}},{name:"xGoogleFlag",reg:/^x-google-flag:([^\s]*)/,format:"x-google-flag:%s"},{push:"rids",reg:/^rid:([\d\w]+) (\w+)(?: ([\S| ]*))?/,names:["id","direction","params"],format:function(e){return e.params?"rid:%s %s %s":"rid:%s %s"}},{push:"imageattrs",reg:new RegExp("^imageattr:(\\d+|\\*)[\\s\\t]+(send|recv)[\\s\\t]+(\\*|\\[\\S+\\](?:[\\s\\t]+\\[\\S+\\])*)(?:[\\s\\t]+(recv|send)[\\s\\t]+(\\*|\\[\\S+\\](?:[\\s\\t]+\\[\\S+\\])*))?"),names:["pt","dir1","attrs1","dir2","attrs2"],format:function(e){return"imageattr:%s %s %s"+(e.dir2?" %s %s":"")}},{name:"simulcast",reg:new RegExp("^simulcast:(send|recv) ([a-zA-Z0-9\\-_~;,]+)(?:\\s?(send|recv) ([a-zA-Z0-9\\-_~;,]+))?$"),names:["dir1","list1","dir2","list2"],format:function(e){return"simulcast:%s %s"+(e.dir2?" %s %s":"")}},{name:"simulcast_03",reg:/^simulcast:[\s\t]+([\S+\s\t]+)$/,names:["value"],format:"simulcast: %s"},{name:"framerate",reg:/^framerate:(\d+(?:$|\.\d+))/,format:"framerate:%s"},{name:"sourceFilter",reg:/^source-filter: *(excl|incl) (\S*) (IP4|IP6|\*) (\S*) (.*)/,names:["filterMode","netType","addressTypes","destAddress","srcList"],format:"source-filter: %s %s %s %s %s"},{name:"bundleOnly",reg:/^(bundle-only)/},{name:"label",reg:/^label:(.+)/,format:"label:%s"},{name:"sctpPort",reg:/^sctp-port:(\d+)$/,format:"sctp-port:%s"},{name:"maxMessageSize",reg:/^max-message-size:(\d+)$/,format:"max-message-size:%s"},{push:"tsRefClocks",reg:/^ts-refclk:([^\s=]*)(?:=(\S*))?/,names:["clksrc","clksrcExt"],format:function(e){return"ts-refclk:%s"+(null!=e.clksrcExt?"=%s":"")}},{name:"mediaClk",reg:/^mediaclk:(?:id=(\S*))? *([^\s=]*)(?:=(\S*))?(?: *rate=(\d+)\/(\d+))?/,names:["id","mediaClockName","mediaClockValue","rateNumerator","rateDenominator"],format:function(e){var t="mediaclk:";return t+=null!=e.id?"id=%s %s":"%v%s",t+=null!=e.mediaClockValue?"=%s":"",(t+=null!=e.rateNumerator?" rate=%s":"")+(null!=e.rateDenominator?"/%s":"")}},{name:"keywords",reg:/^keywds:(.+)$/,format:"keywds:%s"},{name:"content",reg:/^content:(.+)/,format:"content:%s"},{name:"bfcpFloorCtrl",reg:/^floorctrl:(c-only|s-only|c-s)/,format:"floorctrl:%s"},{name:"bfcpConfId",reg:/^confid:(\d+)/,format:"confid:%s"},{name:"bfcpUserId",reg:/^userid:(\d+)/,format:"userid:%s"},{name:"bfcpFloorId",reg:/^floorid:(.+) (?:m-stream|mstrm):(.+)/,names:["id","mStream"],format:"floorid:%s mstrm:%s"},{push:"invalid",names:["value"]}]};Object.keys(n).forEach((function(e){n[e].forEach((function(e){e.reg||(e.reg=/(.*)/),e.format||(e.format="%s")}))}))})),hR=ZA((function(e){var t=function(e){return String(Number(e))===e?Number(e):e},n=function(e,n,r){var i=e.name&&e.names;e.push&&!n[e.push]?n[e.push]=[]:i&&!n[e.name]&&(n[e.name]={});var a=e.push?{}:i?n[e.name]:n;(function(e,n,r,i){if(i&&!r)n[i]=t(e[1]);else for(var a=0;a<r.length;a+=1)null!=e[a+1]&&(n[r[a]]=t(e[a+1]))})(r.match(e.reg),a,e.names,e.name),e.push&&n[e.push].push(a)},r=dR(),i=RegExp.prototype.test.bind(/^([a-z])=(.*)/);e.parse=function(e){var t={},a=[],o=t;return e.split(/(\r\n|\r|\n)/).filter(i).forEach((function(e){var t=e[0],i=e.slice(2);"m"===t&&(a.push({rtp:[],fmtp:[]}),o=a[a.length-1]);for(var s=0;s<(r[t]||[]).length;s+=1){var c=r[t][s];if(c.reg.test(i))return n(c,o,i)}})),t.media=a,t};var a=function(e,n){var r=n.split(/=(.+)/,2);return 2===r.length?e[r[0]]=t(r[1]):1===r.length&&n.length>1&&(e[r[0]]=void 0),e};e.parseParams=function(e){return e.split(/;\s?/).reduce(a,{})},e.parseFmtpConfig=e.parseParams,e.parsePayloads=function(e){return e.toString().split(" ").map(Number)},e.parseRemoteCandidates=function(e){for(var n=[],r=e.split(" ").map(t),i=0;i<r.length;i+=3)n.push({component:r[i],ip:r[i+1],port:r[i+2]});return n},e.parseImageAttributes=function(e){return e.split(" ").map((function(e){return e.substring(1,e.length-1).split(",").reduce(a,{})}))},e.parseSimulcastStreamList=function(e){return e.split(";").map((function(e){return e.split(",").map((function(e){var n,r=!1;return"~"!==e[0]?n=t(e):(n=t(e.substring(1,e.length)),r=!0),{scid:n,paused:r}}))}))}})),fR=ZA((function(e,t){var n=dR(),r=/%[sdv%]/g,i=function(e){var t=1,n=arguments,i=n.length;return e.replace(r,(function(e){if(t>=i)return e;var r=n[t];switch(t+=1,e){case"%%":return"%";case"%s":return String(r);case"%d":return Number(r);case"%v":return""}}))},a=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 a=0;a<t.names.length;a+=1){var o=t.names[a];t.name?r.push(n[t.name][o]):r.push(n[t.names[a]])}else r.push(n[t.name]);return i.apply(null,r)},o=["v","o","s","i","u","e","p","c","b","t","r","z","a"],s=["i","c","b","a"];t.exports=function(e,t){t=t||{},null==e.version&&(e.version=0),null==e.name&&(e.name=" "),e.media.forEach((function(e){null==e.payloads&&(e.payloads="")}));var r=t.outerOrder||o,i=t.innerOrder||s,c=[];return r.forEach((function(t){n[t].forEach((function(n){n.name in e&&null!=e[n.name]?c.push(a(t,n,e)):n.push in e&&null!=e[n.push]&&e[n.push].forEach((function(e){c.push(a(t,n,e))}))}))})),e.media.forEach((function(e){c.push(a("m",n.m[0],e)),i.forEach((function(t){n[t].forEach((function(n){n.name in e&&null!=e[n.name]?c.push(a(t,n,e)):n.push in e&&null!=e[n.push]&&e[n.push].forEach((function(e){c.push(a(t,n,e))}))}))}))})),c.join("\r\n")+"\r\n"}})),pR=ZA((function(e){var t=hR(),n=fR();e.write=n,e.parse=t.parse,e.parseParams=t.parseParams,e.parseFmtpConfig=t.parseFmtpConfig,e.parsePayloads=t.parsePayloads,e.parseRemoteCandidates=t.parseRemoteCandidates,e.parseImageAttributes=t.parseImageAttributes,e.parseSimulcastStreamList=t.parseSimulcastStreamList})),mR=tR(oR()),vR=((VA=vR||{})[VA.INVALID_PARAMETER=4096]="INVALID_PARAMETER",VA[VA.INVALID_OPERATION=4097]="INVALID_OPERATION",VA[VA.NOT_SUPPORTED=4098]="NOT_SUPPORTED",VA[VA.DEVICE_NOT_FOUND=4099]="DEVICE_NOT_FOUND",VA[VA.INITIALIZE_FAILED=4100]="INITIALIZE_FAILED",VA[VA.SIGNAL_CHANNEL_SETUP_FAILED=16385]="SIGNAL_CHANNEL_SETUP_FAILED",VA[VA.SIGNAL_CHANNEL_ERROR=16386]="SIGNAL_CHANNEL_ERROR",VA[VA.ICE_TRANSPORT_ERROR=16387]="ICE_TRANSPORT_ERROR",VA[VA.JOIN_ROOM_FAILED=16388]="JOIN_ROOM_FAILED",VA[VA.CREATE_OFFER_FAILED=16389]="CREATE_OFFER_FAILED",VA[VA.SIGNAL_CHANNEL_RECONNECTION_FAILED=16390]="SIGNAL_CHANNEL_RECONNECTION_FAILED",VA[VA.UPLINK_RECONNECTION_FAILED=16391]="UPLINK_RECONNECTION_FAILED",VA[VA.DOWNLINK_RECONNECTION_FAILED=16392]="DOWNLINK_RECONNECTION_FAILED",VA[VA.REMOTE_STREAM_NOT_EXIST=16400]="REMOTE_STREAM_NOT_EXIST",VA[VA.CLIENT_BANNED=16448]="CLIENT_BANNED",VA[VA.SERVER_TIMEOUT=16449]="SERVER_TIMEOUT",VA[VA.SUBSCRIPTION_TIMEOUT=16450]="SUBSCRIPTION_TIMEOUT",VA[VA.PLAY_NOT_ALLOWED=16451]="PLAY_NOT_ALLOWED",VA[VA.DEVICE_AUTO_RECOVER_FAILED=16452]="DEVICE_AUTO_RECOVER_FAILED",VA[VA.START_PUBLISH_CDN_FAILED=16453]="START_PUBLISH_CDN_FAILED",VA[VA.STOP_PUBLISH_CDN_FAILED=16454]="STOP_PUBLISH_CDN_FAILED",VA[VA.START_MIX_TRANSCODE_FAILED=16455]="START_MIX_TRANSCODE_FAILED",VA[VA.STOP_MIX_TRANSCODE_FAILED=16456]="STOP_MIX_TRANSCODE_FAILED",VA[VA.NOT_SUPPORTED_H264=16457]="NOT_SUPPORTED_H264",VA[VA.SWITCH_ROLE_FAILED=16458]="SWITCH_ROLE_FAILED",VA[VA.API_CALL_TIMEOUT=16459]="API_CALL_TIMEOUT",VA[VA.SCHEDULE_FAILED=16460]="SCHEDULE_FAILED",VA[VA.API_CALL_ABORTED=16461]="API_CALL_ABORTED",VA[VA.SPC_INITIALIZED_FAILED=16462]="SPC_INITIALIZED_FAILED",VA[VA.VIDEO_MANAGER_ERROR=16463]="VIDEO_MANAGER_ERROR",VA[VA.UNKNOWN=65535]="UNKNOWN",VA),_R=vR,gR=function(e){function i(e){var a;r(this,i);var o=e.name,s=void 0===o?"RtcError":o,c=e.message,u=e.code,l=void 0===u?_R.UNKNOWN:u,d=e.extraCode,h=void 0===d?0:d,f=e.constraint,p="<".concat(function(e){for(var t in _R)if(_R[t]===e)return t;return"UNKNOWN"}(l)," 0x").concat(l.toString(16),">"),m="".concat(c).concat(f?" constraint: ".concat(f):"").concat(null!=c&&c.includes(p)?"":" ".concat(p));return a=n(this,i,[m]),rR(t(a),"code"),rR(t(a),"extraCode"),rR(t(a),"message"),rR(t(a),"originMessage"),rR(t(a),"name"),rR(t(a),"constraint"),a.code=l,a.extraCode=h,a.name=s,a.message=m,a.constraint=f,a.originMessage=c,a}return d(i,e),o(i,[{key:"getCode",value:function(){return this.code}},{key:"getExtraCode",value:function(){return this.extraCode}},{key:"toString",value:function(){return this.originMessage}}])}(I(Error)),yR=gR,ER=((new Date).getTime(),0),TR=function(){return(new Date).getTime()+ER},kR=function(){var e=new Date;return e.setTime(TR()),e.toLocaleString()},SR=function(e){var t=String(e.getMilliseconds());return"padStart"in String.prototype&&(t=t.toString().padStart(3,"0")),"".concat(e.toTimeString().replace(/.*(\d{2}:\d{2}:\d{2}).*/,"$1"),":").concat(t)},IR={};eR(IR,{bytes2ms:function(){return fw},convertObjectNumberToInt:function(){return nD},copyProperties:function(){return hw},deepClone:function(){return Kw},deepMerge:function(){return Jw},delay:function(){return rD},fibonacci:function(){return Ew},formatedTime:function(){return qw},getConstructorName:function(){return Pw},getContainerFromElement:function(){return Yw},getEnv:function(){return iw},getInternalVersion:function(){return Fw},getLoggerUrl:function(){return ow},getMuteStateFromFlag:function(){return Hw},getNetworkType:function(){return cw},getNumNetworkType:function(){return dw},getReconnectionTimeout:function(){return Tw},getStringByteLength:function(){return $w},getTurnServer:function(){return Gw},getUint32Version:function(){return tD},getValueType:function(){return kw},getViewListFromView:function(){return zw},glog:function(){return _w},ipv4ToUint32:function(){return Ww},isArray:function(){return ww},isAudioWorkletSupported:function(){return Mw},isBoolean:function(){return Rw},isConstructor:function(){return Ow},isEmpty:function(){return jw},isFunction:function(){return Sw},isLangChinese:function(){return gw},isMediaStreamTrack:function(){return Dw},isNumber:function(){return Aw},isObject:function(){return Cw},isOverseaSdkAppId:function(){return aw},isPlainObject:function(){return yw},isPortrait:function(){return Zw},isPromise:function(){return xw},isRemoteTrack:function(){return Nw},isString:function(){return bw},isUndefined:function(){return Iw},loadImage:function(){return eD},ms2bytes:function(){return mw},ms2samples:function(){return vw},performanceNow:function(){return Vw},promiseAny:function(){return Lw},samples2ms:function(){return pw},setNetworkType:function(){return lw},stringify:function(){return Xw},stringifyIncludeValue:function(){return Qw},throttlePromise:function(){return iD}});var bR={};eR(bR,{AUDIO_MUTE_BIT:function(){return lC},AUDIO_STAT_BIT:function(){return uC},AUX_STAT_BIT:function(){return cC},AUX_STREAM_MSID:function(){return mC},BACKEND_ENV:function(){return iC},BASE_DOC_URL:function(){return BR},BASE_HOST:function(){return LR},CAPABILITIES_KEYS:function(){return nw},CLASS_NAME:function(){return zC},CLOUD_CONSOLE_URL:function(){return FR},CROSS_ROOM_BIT:function(){return fC},DATA_FREEZE_TIMING:function(){return BC},DEFAULT_ASSETS_URL:function(){return jR},DOC_URL:function(){return HR},DTLS_STATE_UNKNOWN:function(){return bC},ENV_NAME:function(){return zR},EXCHANGE_SDP_TIMEOUT:function(){return MC},IS_WORKER:function(){return NR},IS_WORKLET:function(){return xR},KIBANA_EVENT:function(){return xC},LOCAL_STREAM_PUBLISH_STATE:function(){return FC},LOGGER_CMD_TYPE:function(){return KR},LOGGER_DOMAIN:function(){return GR},LOGGER_DOMAIN_OVERSEA:function(){return WR},LOG_LEVEL:function(){return YR},LOG_LEVEL_NAME:function(){return $C},MAIN_STREAM_MSID:function(){return pC},MAX_RTT:function(){return rw},MICROPHONE_COMMUNICATIONS:function(){return QC},MICROPHONE_DEFAULT:function(){return qC},MUTE_ALL_BIT:function(){return hC},NAME:function(){return nC},NETWORK_TYPE:function(){return QR},NOT_SUPPORTED_H264:function(){return UC},PAUSED_RETRY_COUNT:function(){return YC},PEERCONNECTION_CONNECTING_TIMEOUT:function(){return WC},PEER_CONNECTION_STATE:function(){return AC},PEER_LEAVE_REASON:function(){return ZC},RECOVER_CAPTURE_INTERVAL:function(){return tw},REMOTE_STREAM_TYPE_AUX:function(){return _C},REMOTE_STREAM_TYPE_MAIN:function(){return vC},RENDER_FREEZE_TIMING:function(){return jC},SCHEDULE_DOMAIN:function(){return JC},SCHEDULE_TIMEOUT:function(){return KC},SDP_SEMANTICS_PLAN_B:function(){return VC},SDP_SEMANTICS_UNIFIED_PLAN:function(){return LC},SECOND_HOST:function(){return VR},SIGNAL_PING_PONG_INTERVAL:function(){return XR},SIGNAL_PING_TIMEOUT:function(){return qR},SIGNAL_RECONNECTION_COUNT:function(){return NC},SMALL_STAT_BIT:function(){return sC},SPEAKER_DEFAULT:function(){return XC},STORAGE_EXPIRES_TIME:function(){return $R},STREAM_TYPE_BIG:function(){return HC},STREAM_TYPE_SMALL:function(){return GC},SUBSCRIBE_SMALL_RETRY_COUNT:function(){return ew},SYNC_USER_LIST_INTERVAL:function(){return OC},Scene:function(){return aC},THIRD_HOST:function(){return UR},TRANSPORT_DIRECTION:function(){return rC},TRTC_ERROR_ASSISTANCE:function(){return JR},TRTC_QUALITY_BAD:function(){return kC},TRTC_QUALITY_DISCONNECTED:function(){return IC},TRTC_QUALITY_EXCELLENT:function(){return yC},TRTC_QUALITY_GOOD:function(){return EC},TRTC_QUALITY_POOR:function(){return TC},TRTC_QUALITY_UNKNOWN:function(){return gC},TRTC_QUALITY_VERY_BAD:function(){return SC},UPDATE_OFFER_TIMEOUT:function(){return PC},VIDEO_MUTE_BIT:function(){return dC},VIDEO_STAT_BIT:function(){return oC},audioProfileMap:function(){return ZR},getRetryCount:function(){return wC},getScriptDir:function(){return OR},innerVersion:function(){return AR},loggerProxy:function(){return PR},screenProfileMap:function(){return tC},setLoggerProxy:function(){return MR},setRetryCount:function(){return CC},setVersion:function(){return CR},version:function(){return RR},videoProfileMap:function(){return eC}});var AR="4.15.00.1600",RR="5.0.0";function CR(e){RR=e;var t=v(e.split(".").map((function(e){return parseInt(e,10)})),3),n=t[0],r=t[1],i=t[2];AR="".concat(n,".").concat(Math.min(15,r),".").concat(Math.min(15,i),".").concat(r.toString().padStart(2,"0")).concat(i.toString().padStart(2,"0"))}var wR,DR,NR="undefined"!=typeof importScripts,xR="undefined"!=typeof registerProcessor,OR=function(){var e=NR?self.location.href:document.currentScript.src;return e.substring(0,e.lastIndexOf("/")+1)},PR="",MR=function(e){return PR=e},LR="web.sdk.qcloud.com",VR="web.sdk.tencent.cn",UR="web.sdk.cloud.tencent.cn",FR="https://console.cloud.tencent.com/trtc",BR="https://".concat(LR,"/trtc/webrtc/v5/doc"),jR="https://web.sdk.qcloud.com/trtc/webrtc/v5/assets/",HR="".concat(BR,"/zh-cn/"),GR="https://yun.tim.qq.com",WR="https://apisgp.my-imcloud.com",JR="trtc_error_assistance",KR={LOG:"jssdk_log",EVENT:"jssdk_event",KEY_POINT:"jssdk_new_endreport",KV_STAT:"jssdk_key_metrics_report"},zR={QCLOUD:"qcloud",OLD_CLOUD_LADDER:"trtc",WEBRTC:"webrtc"},YR=((DR=YR||{})[DR.TRACE=0]="TRACE",DR[DR.DEBUG=1]="DEBUG",DR[DR.INFO=2]="INFO",DR[DR.WARN=3]="WARN",DR[DR.ERROR=4]="ERROR",DR[DR.NONE=5]="NONE",DR),qR=18e3,XR=2e3,QR={unknown:0,wifi:1,"3g":2,"2g":3,"4g":4,wired:5,"5g":6},$R=6048e5,ZR={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}},eC={"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}},tC={"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}},nC={CANVAS:"canvas",AUDIO:"audio",VIDEO:"video",SCREEN:"screen",SMALL:"small",BIG:"big",AUXILIARY:"auxiliary",SMALL_VIDEO:"smallVideo",FACING_MODE_USER:"user",FACING_MODE_ENVIRONMENT:"environment",MUTE:"mute",UNMUTE:"unmute",ENDED:"ended",PLAYING:"playing",PAUSE:"pause",ERROR:"error",LOADEDDATA:"loadeddata",LOADEDMETADATA:"loadedmetadata",AUDIO_INPUT:"audioinput",VIDEO_INPUT:"videoinput",DETAIL:"detail",TEXT:"text",MAIN:"main",BACKUP:"backup",BANNED:"banned",KICK:"kick",USER_TIME_OUT:"user_time_out",ROOM_DISBAND:"room_disband",SEI_MESSAGE:"sei-message",ADD:"add",REMOVE:"remove",REPLACE:"replace",TRACK:"track",SUBSCRIBE:"subscribe",UNSUBSCRIBE:"unsubscribe",TRANSCEIVER_DIRECTION_SENDONLY:"sendonly",TRANSCEIVER_DIRECTION_RECVONLY:"recvonly",ENTER_PICTURE_IN_PICTURE:"enterpictureinpicture",LEAVE_PICTURE_IN_PICTURE:"leavepictureinpicture"},rC={INACTIVE:"inactive",SENDONLY:"sendonly",RECVONLY:"recvonly"},iC={OLD_CLOUD_LADDER:"wss://trtc.rtc.qq.com",WEBRTC:"wss://webrtc.qq.com"},aC=((wR=aC||{}).LIVE="live",wR.RTC="rtc",wR),oC=1,sC=2,cC=4,uC=8,lC=64,dC=16,hC=112,fC=128,pC="5Y2wZK8nANNAoVw6dSAHVjNxrD1ObBM2kBPV",mC="224d130c-7b5c-415b-aaa2-79c2eb5a6df2",vC=nC.MAIN,_C=nC.AUXILIARY,gC=0,yC=1,EC=2,TC=3,kC=4,SC=5,IC=6,bC="unknown",AC={NEW:"new",CONNECTING:"connecting",FAILED:"failed",CLOSED:"closed",DISCONNECTED:"disconnected",CONNECTED:"connected",COMPLETED:"completed"},RC=1/0;function CC(e){RC=e}function wC(){return RC}var DC,NC=30,xC={JOIN:"join",DELTA_JOIN:"delta-join",REJOIN:"rejoin",LEAVE:"leave",DELTA_LEAVE:"delta-leave",PUBLISH:"publish",DELTA_PUBLISH:"delta-publish",UNPUBLISH:"unpublish",SUBSCRIBE:"subscribe",UNSUBSCRIBE:"unsubscribe",UPLINK_CONNECTION:"uplink-connection",UPLINK_RECONNECTION:"uplink-reconnection",DOWNLINK_CONNECTION:"downlink-connection",DOWNLINK_RECONNECTION:"downlink-reconnection",ON_TRACK:"ontrack",ICE_CONNECTION_STATE:"iceConnectionState",LOCAL_STREAM_INITIALIZE:"stream-initialize",SIGNAL_CONNECTION:"websocketConnectionState",SIGNAL_RECONNECTION:"websocketReconnectionState",UPDATE_STREAM:"update-stream",RECOVER_LOCAL_AUDIO_TRACK:"recover-local-audio-track",RECOVER_LOCAL_VIDEO_TRACK:"recover-local-video-track",RECOVER_SUBSCRIPTION:"recover-subscription",START_MIX_TRANSCODE:"start-mix-transcode",STOP_MIX_TRANSCODE:"stop-mix-transcode",PLAYER_ERROR:"player-error",SCHEDULE:"schedule",LOAD_WORKLET:"load-worklet",VIDEO_FROZEN_COUNT:"videoFrozenCount",GET_USER_MEDIA_RETRY:"getUserMedia-retry"},OC=1e4,PC=1e4,MC=1e4,LC="unified-plan",VC="plan-b",UC=1028,FC=((DC=FC||{})[DC.UNPUBLISH=-1]="UNPUBLISH",DC[DC.PUBLISHING=0]="PUBLISHING",DC[DC.PUBLISHED=1]="PUBLISHED",DC),BC=500,jC=1e3,HC=nC.BIG,GC=nC.SMALL,WC=1e4,JC={MAIN:"schedule.cloud-rtc.com",BACKUP:"schedule.cloud-rtc.net",MAIN_OVERSEA:"schedule.rtc-web.com",BACKUP_OVERSEA:"schedule.rtc-web.io",MAIN_OVERSEA_BACKUP:"intl-schedule.cloud-rtc.com"},KC=2e3,zC={TRTC:"TRTC",CLIENT:"Client",LOCAL_STREAM:"LocalStream",REMOTE_STREAM:"RemoteStream",STREAM:"Stream"},YC=5,qC="default",XC=qC,QC="communications",$C=Object.keys(YR),ZC=["normal leave","timeout leave","kick","role change"],ew=10,tw=2e3,nw=["width","height","frameRate","facingMode","sampleRate","sampleSize","channelCount","deviceId","min","max"],rw=1e4,iw=function(){return new URLSearchParams(location.search).get("trtc_env")||""},aw=function(e){return Number(e)<14e8},ow=function(e,t){var n;n=PR||(aw(e)?WR:GR);var r=Math.floor(Math.random()*qA(2,31));return"".concat(n,"/v5/AVQualityReportSvc/C2S?random=").concat(r,"&sdkappid=").concat(e,"&cmdtype=").concat(t)},sw="unknown";function cw(){if("unknown"!==sw)return sw;var e=navigator,t=e.userAgent,n=e.connection,r=(t.match(/NetType\/\S+/)||[])[0]||"";"3gnet"===(r=r.toLowerCase().replace("nettype/",""))&&(r="3g");var i=n&&n.type&&n.type.toLowerCase(),a=n&&n.effectiveType&&n.effectiveType.toLowerCase();return"slow-2"===a&&(a="2g"),i&&(sw=uw(i,a)),sw}function uw(e,t){if(QR[e])return e;switch(e){case"cellular":case"wimax":return t||"unknown";case"ethernet":return"wired";default:return"unknown"}}function lw(e){sw=uw(e)}function dw(){return QR[cw()]}function hw(e,t){var n,r=s(Reflect.ownKeys(t));try{for(r.s();!(n=r.n()).done;){var i=n.value;if("constructor"!==i&&"prototype"!==i&&"name"!==i){var a=Object.getOwnPropertyDescriptor(t,i)||"";Object.defineProperty(e,i,a)}}}catch(o){r.e(o)}finally{r.f()}return e}function fw(e){return pw(e/4,arguments.length>1&&void 0!==arguments[1]?arguments[1]:48e3)}function pw(e){return 1e3*e/(arguments.length>1&&void 0!==arguments[1]?arguments[1]:48e3)}function mw(e){return 4*vw(e,arguments.length>1&&void 0!==arguments[1]?arguments[1]:48e3)}function vw(e){return e*(arguments.length>1&&void 0!==arguments[1]?arguments[1]:48e3)/1e3}var _w="undefined"!=typeof window&&"function"==typeof window.glog?window.glog:function(){},gw=function(){var e=navigator.language;return"zh"===(e=e.substring(0,2))},yw=function(e){if(!e||"object"!=k(e)||"[object Object]"!=Object.prototype.toString.call(e))return!1;var t=Object.getPrototypeOf(e);if(null===t)return!0;var n=Object.prototype.hasOwnProperty.call(t,"constructor")&&t.constructor;return"function"==typeof n&&n instanceof n&&Function.prototype.toString.call(n)===Function.prototype.toString.call(Object)};function Ew(e){var t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1;return e<=1?t:Ew(e-1,t,(arguments.length>1&&void 0!==arguments[1]?arguments[1]:1)+t)}function Tw(e){return e>8?3e4:1e3*Ew(e)}function kw(e){return Reflect.apply(Object.prototype.toString,e,[]).replace(/^\[object\s(\w+)\]$/,"$1").toLowerCase()}var Sw=function(e){return"function"==typeof e},Iw=function(e){return void 0===e},bw=function(e){return"string"==typeof e},Aw=function(e){return"number"==typeof e},Rw=function(e){return"boolean"==typeof e},Cw=function(e){return"object"===kw(e)},ww=function(e){return"array"===kw(e)},Dw=function(e){return kw(e)==="MediaStreamTrack".toLowerCase()},Nw=function(e){return e.isRemote},xw=function(e){return"promise"===kw(e)},Ow=function(e){return Sw(e)&&e.prototype.constructor===e},Pw=function(e){return Ow(e)?e.prototype.constructor.name:""},Mw="undefined"!=typeof AudioWorkletNode;function Lw(e){return new Promise((function(t,n){var r=[];e.forEach((function(i){i.then(t).catch((function(t){r.push(t),r.length===e.length&&n(r)}))}))}))}function Vw(){return performance&&performance.now?Math.floor(performance.now()):Date.now()}var Uw=function(e){return+e<10?"0".concat(e):e},Fw=function(e){var t=e.match(/^\d+\.\d+\.\d+/)[0];if(!t)return e;var n=t.split("."),r=Uw(n[1])+Uw(n[2]);return n[1]-15>0&&(n[1]="15"),n[2]-15>0&&(n[2]="15"),"".concat(n.join("."),".").concat(r)},Bw=Object.prototype.hasOwnProperty;function jw(e){if(null==e)return!0;if("boolean"==typeof e)return!1;if("number"==typeof e)return 0===e;if("string"==typeof e||"function"==typeof e||Array.isArray(e))return 0===e.length;if(e instanceof Error)return""===e.message;if(yw(e))switch(Object.prototype.toString.call(e)){case"[object File]":case"[object Map]":case"[object Set]":return 0===e.size;case"[object Object]":for(var t in e)if(Bw.call(e,t))return!1;return!0}return!1}function Hw(e,t){return{userId:t,hasAudio:!!(e&uC),hasVideo:!!(e&oC),hasAuxiliary:!!(e&cC),hasSmall:!!(e&sC),audioMuted:!!(e&lC),videoMuted:!!(e&dC),audioAvailable:!(!(e&uC)||e&lC),videoAvailable:!(!(e&oC)||e&dC)}}function Gw(e){var t={urls:e.url.startsWith("turn:")||e.url.startsWith("turns:")?e.url:"turn:".concat(e.url)};return!Iw(e.username)&&!Iw(e.credential)&&(t.username=e.username,t.credential=e.credential,t.credentialType="password",Iw(e.credentialType)||(t.credentialType=e.credentialType)),t}function Ww(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];if(!bw(e))return 0;var n=e.split(".");return t?(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 Jw=function(e,t,n,r){if(!Cw(e)||!Cw(t))return 0;for(var i,a=0,o=Object.keys(t),s=0,c=o.length;s<c;s++)if(i=o[s],!(Iw(t[i])||n&&n.includes(i)))if(Cw(e[i])&&Cw(t[i]))a+=Jw(e[i],t[i],n,r);else{if(r&&r.includes(t[i]))continue;e[i]!==t[i]&&(e[i]=Kw(t[i]),a+=1)}return a};function Kw(e){if(ww(e)){var t=[];return e.forEach((function(e,n){t[n]=Kw(e)})),t}if(Cw(e)){var n={};return Object.keys(e).forEach((function(t){n[t]=Kw(e[t])})),n}return e}var zw=function(e){var t=[];if(ww(e))t=E(e);else if(bw(e)){var n=document.getElementById(e);n&&t.push(n)}else e&&t.push(e);return t},Yw=function(e){return bw(e)?document.getElementById(e):e},qw=function(){return function(e){var t=function(e){return e<10?"0".concat(e):"".concat(e)},n=e.getFullYear(),r=e.getMonth()+1,i=e.getDate(),a=t(e.getHours()),o=t(e.getMinutes()),s=t(e.getSeconds());return"".concat(n,"/").concat(r,"/").concat(i," ").concat(a,":").concat(o,":").concat(s)}(new Date)};function Xw(e,t){var n=t.keysToInclude,r=t.keysToExclude;try{if(ww(e))return"[".concat(e.map((function(e){return Xw(e,{keysToInclude:n,keysToExclude:r})})).join(","),"]");if(!yw(e)||!ww(n)&&!ww(r))return JSON.stringify(e);var i={},a=new Set(n),o=new Set(r);return Object.keys(e).forEach((function(t){(0===o.size&&a.has(t)||0===a.size&&!o.has(t))&&(i[t]=yw(e[t])||ww(e[t])?JSON.parse(Xw(e[t],{keysToExclude:r,keysToInclude:n})):e[t])})),JSON.stringify(i)}catch(DC){return"{}"}}function Qw(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=[];return Object.keys(e).forEach((function(r){t===e[r]&&n.push(r)})),Xw(e,{keysToInclude:n})}function $w(e){return e.replace(/[\u4e00-\u9fa5]/g,"aa").length}var Zw=function(){var e,t,n,r;return null!=(e=window.screen)&&e.orientation?!(null==(r=null==(n=null==(t=window.screen)?void 0:t.orientation)?void 0:n.type)||!r.includes("portrait")):0===window.orientation||180===window.orientation},eD=function(e){return aR(void 0,null,f().mark((function t(){return f().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",new Promise((function(t,n){var r;if(bw(e))(r=new Image).crossOrigin="anonymous",r.src=e;else if((r=e).complete)return void t(r);r.onload=function(){return t(r)},r.onerror=function(){n(new yR({code:_R.INVALID_PARAMETER,message:"load image failed, url: ".concat(e)}))}})));case 1:case"end":return t.stop()}}),t)})))},tD=function(e){var t=e.split(".");return+t[0]<<24|+t[1]<<16|+t[2]<<8|+t[3]},nD=function(e){return Object.keys(e).forEach((function(t){Aw(e[t])&&(t.startsWith("uint")||t.startsWith("int"))?e[t]=Math.floor(e[t]):(yw(e[t])||ww(e[t]))&&nD(e[t])})),e};function rD(e,t){return new Promise((function(n){var r=setTimeout(n,e);t&&t(r)}))}function iD(e,t){var n=null;return function(){for(var r=arguments.length,i=new Array(r),a=0;a<r;a++)i[a]=arguments[a];return n||((n=e.apply(t||this,i)).finally((function(){return n=null})),n)}}function aD(e){var t=e.url,n=e.body,r=e.method,i=void 0===r?"POST":r,a=e.timeout,o=e.priority;return new Promise((function(e,r){if("fetch"in window)return fetch(t,{method:i,body:n,priority:o}).then((function(e){return e.text()})).then((function(t){try{e({data:JSON.parse(t)})}catch(fx){e({data:t})}}),r);var s=new XMLHttpRequest;s.onreadystatechange=function(){if(4===s.readyState)if(s.status>=200&&s.status<300)try{var n=JSON.parse(s.response);e({data:n})}catch(t){e({data:s.response})}else r({status:s.status,statusText:s.statusText||"request failed!"})},s.timeout=a||5e3,s.open(i,t,!0),s.send(n)}))}function oD(e){return aR(this,null,f().mark((function t(){var n,r,i,a;return f().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=Vw(),r=JSON.stringify(e),t.prev=1,CompressionStream&&!(r.length<=2800)){t.next=4;break}return t.abrupt("return",r);case 4:return i=new Blob([r],{type:"application/json"}).stream().pipeThrough(new CompressionStream("gzip")),t.next=7,new Response(i);case 7:return t.next=9,t.sent.blob();case 9:return t.next=11,t.sent.arrayBuffer();case 11:return a=t.sent,t.abrupt("return",(sx.debug("compressJSON ".concat(r.length," -> ").concat(a.byteLength," ").concat(Vw()-n,"ms")),a));case 15:return t.prev=15,t.t0=t.catch(1),t.abrupt("return",r);case 18:case"end":return t.stop()}}),t,null,[[1,15]])})))}var sD=Object.prototype.hasOwnProperty,cD=function(e){return"function"==typeof e},uD=function(e){return void 0===e},lD=function(e){return e.isRemote},dD=function(e){var t=e.retryFunction,n=e.settings,r=e.onError,i=e.onRetrying,a=e.onRetryFailed,o=e.onRetrySuccess,s=e.context;return function(){for(var e=this,c=arguments.length,u=new Array(c),l=0;l<c;l++)u[l]=arguments[l];var d=n.retries,h=void 0===d?5:d,p=n.timeout,m=void 0===p?1e3:p,v=0,_=-1,g=0,y=function(n,c){return aR(e,null,f().mark((function e(){var l,d,p,E,T=this;return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return l=s||this,e.prev=1,e.next=4,t.apply(l,u);case 4:d=e.sent,v>0&&o&&o.call(this,v),v=0,n(d),e.next=12;break;case 8:e.prev=8,e.t0=e.catch(1),p=function(){clearTimeout(_),v=0,g=2,c(e.t0)},E=function(){2!==g&&v<(cD(h)?h():h)?(v++,g=1,cD(i)&&i.call(T,v,p),_=window.setTimeout((function(){_=-1,y(n,c)}),cD(m)?m(v):m)):(p(),cD(a)&&a.call(T,e.t0))},cD(r)?r.call(this,{error:e.t0,retry:E,reject:c,retryFuncArgs:u,retriedCount:v}):E();case 12:case"end":return e.stop()}}),e,this,[[1,8]])})))};return new Promise(y)}},hD=function(){return o((function e(t){r(this,e),rR(this,"userId"),rR(this,"remoteUserId"),rR(this,"id"),rR(this,"sdkAppId"),rR(this,"type"),rR(this,"isLocal"),this.id=t.id,this.userId=t.userId,this.sdkAppId=t.sdkAppId,this.remoteUserId=t.remoteUserId,this.isLocal="boolean"!=typeof t.isLocal||t.isLocal,this.type=this.isLocal?"":t.type}),[{key:"createChild",value:function(e){return Object.setPrototypeOf(e,this)}},{key:"setUserId",value:function(e){this.userId=e}},{key:"setSdkAppId",value:function(e){this.sdkAppId=e}},{key:"log",value:function(e,t){var n=this.isLocal?this.userId:this.remoteUserId;t.unshift("[".concat(this.isLocal?"↑":"↓").concat(this.type&&"main"!==this.type?"*":"").concat(this.id).concat(n?"|".concat(n):"","]")),sx.log(e,t,uD(this.userId)||function(e){if(null==e)return!0;if("boolean"==typeof e)return!1;if("number"==typeof e)return 0===e;if("string"==typeof e||"function"==typeof e||Array.isArray(e))return 0===e.length;if(e instanceof Error)return""===e.message;if(function(e){if(!e||"object"!=k(e)||"[object Object]"!=Object.prototype.toString.call(e))return!1;var t=Object.getPrototypeOf(e);if(null===t)return!0;var n=Object.prototype.hasOwnProperty.call(t,"constructor")&&t.constructor;return"function"==typeof n&&n instanceof n&&Function.prototype.toString.call(n)===Function.prototype.toString.call(Object)}(e))switch(Object.prototype.toString.call(e)){case"[object File]":case"[object Map]":case"[object Set]":return 0===e.size;case"[object Object]":for(var t in e)if(sD.call(e,t))return!1;return!0}return!1}(this.userId),this.userId,this.sdkAppId)}},{key:"info",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];this.log(2,t)}},{key:"debug",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];this.log(1,t)}},{key:"warn",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];this.log(3,t)}},{key:"error",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];this.log(4,t)}}])}(),fD={};eR(fD,{ANDROID_VERSION:function(){return AD},CHROME_MAJOR_VERSION:function(){return DN},CHROME_VERSION:function(){return NN},EDGE_VERSION:function(){return OD},EDG_MAJOR_VERSION:function(){return LD},EDG_VERSION:function(){return MD},FIREFOX_MAJOR_VERSION:function(){return ND},FIREFOX_VERSION:function(){return DD},HUAWEI_VERSION:function(){return _N},IE_VERSION:function(){return zD},IOS_MAIN_VERSION:function(){return VN},IOS_VERSION:function(){return LN},IPADQQB_VERSION:function(){return iN},IS_ANDROID:function(){return bD},IS_ANDROID_WEBVIEW:function(){return MN},IS_ANY_SAFARI:function(){return ON},IS_CHROME:function(){return CN},IS_CHROME_OS:function(){return cN},IS_CHROMIUM_BASE:function(){return RN},IS_EDG:function(){return PD},IS_EDGE:function(){return xD},IS_ELECTRON:function(){return dN},IS_FIREFOX:function(){return wD},IS_HEADLESS_CHROME:function(){return wN},IS_HONOR:function(){return vN},IS_HUAWEI:function(){return mN},IS_HUAWEIBROWSER:function(){return pN},IS_IE:function(){return KD},IS_IE8:function(){return JD},IS_IOS:function(){return ID},IS_IOS_13_OR_14:function(){return BN},IS_IOS_15_1:function(){return FN},IS_IPAD:function(){return ED},IS_IPADQQB:function(){return rN},IS_IPAD_PRO:function(){return TD},IS_IPHONE:function(){return kD},IS_IPOD:function(){return SD},IS_LINUX:function(){return sN},IS_LOCAL:function(){return jN},IS_MAC:function(){return oN},IS_MACQQB:function(){return tN},IS_MIBROWSER:function(){return hN},IS_MQQB:function(){return QD},IS_NATIVE_ANDROID:function(){return CD},IS_OLD_ANDROID:function(){return RD},IS_OPENHARMONY:function(){return IN},IS_OPPOBROWSER:function(){return EN},IS_SAFARI:function(){return xN},IS_SAFARI_15_1:function(){return UN},IS_SAMSUNGBROWSER:function(){return gN},IS_SOGOU:function(){return FD},IS_SOGOUM:function(){return VD},IS_TBS:function(){return jD},IS_UCBROWSER:function(){return lN},IS_VIVOBROWSER:function(){return kN},IS_WECHAT:function(){return YD},IS_WIN:function(){return aN},IS_WQQB:function(){return ZD},IS_WX:function(){return uN},IS_X5MQQB:function(){return XD},IS_XWEB:function(){return GD},MACQQB_VERSION:function(){return nN},MI_VERSION:function(){return fN},MQQB_VERSION:function(){return $D},OPENHARMONY_VERSION:function(){return bN},OPPO_VERSION:function(){return TN},SAFARI_VERSION:function(){return PN},SAMSUNG_VERSION:function(){return yN},SOGOUM_VERSION:function(){return UD},SOGOU_VERSION:function(){return BD},TBS_VERSION:function(){return HD},UA_DATA_STRING:function(){return zN},USER_AGENT:function(){return pD},VIVO_VERSION:function(){return SN},WECHAT_VERSION:function(){return qD},WQQB_VERSION:function(){return eN},XWEB_VERSION:function(){return WD},browserInfo:function(){return GN},getBrowserInfo:function(){return WN},getChromeMajorVersion:function(){return AN},getDeviceModel:function(){return qN},getOSName:function(){return QN},getOSNumber:function(){return $N},getOSString:function(){return ZN},getOSType:function(){return tx},getTerminalType:function(){return ex},getUserAgentData:function(){return YN},isLocalStorageEnabled:function(){return HN},isMobile:function(){return KN}});var pD="undefined"==typeof navigator?"":navigator.userAgent,mD=function(e){return new RegExp(e,"i").test(pD)},vD=function(e){if(mD(e)){var t=new RegExp("".concat(e,"\\/([\\d.]+)")),n=pD.match(t);if(n&&n[1])return n[1]}return""},_D=function(e){if(mD(e)){var t=new RegExp("".concat(e,"\\/(\\d+)")),n=pD.match(t);if(n&&n[1])return parseFloat(n[1])}return NaN},gD=/AppleWebKit\/([\d.]+)/i.exec(pD),yD=gD?parseFloat(gD[1]):NaN,ED=mD("iPad"),TD="undefined"!=typeof navigator&&navigator.maxTouchPoints&&navigator.maxTouchPoints>2&&mD("Macintosh"),kD=mD("iPhone")&&!ED,SD=mD("iPod"),ID=kD||ED||SD||TD,bD=mD("Android"),AD=function(){if(bD){var e=pD.match(/Android (\d+)(?:\.(\d+))?(?:\.(\d+))*/i);if(e){var t=e[1]&&parseFloat(e[1]),n=e[2]&&parseFloat(e[2]);if(t&&n)return parseFloat("".concat(e[1],".").concat(e[2]));if(t)return t}}return NaN}(),RD=bD&&mD("webkit")&&AD<2.3,CD=bD&&AD<5&&yD<537,wD=mD("Firefox"),DD=vD("Firefox"),ND=_D("Firefox"),xD=mD("Edge"),OD=vD("Edge"),PD=mD("Edg"),MD=vD("Edg"),LD=_D("Edg"),VD=mD("SogouMobileBrowser"),UD=vD("SogouMobileBrowser"),FD=mD("MetaSr\\s"),BD=vD("MetaSr\\s"),jD=mD("TBS"),HD=vD("TBS"),GD=mD("XWEB"),WD=vD("XWEB"),JD=mD("MSIE\\s8\\.0"),KD=mD("MSIE\\/\\d+"),zD=function(){if(KD){var e=/MSIE\s(\d+)\.\d/.exec(pD),t=e&&parseFloat(e[1]);return!t&&/Trident\/7.0/i.test(pD)&&/rv:11.0/.test(pD)&&(t=11),t}return NaN}(),YD=mD("(micromessenger|webbrowser)"),qD=vD("MicroMessenger"),XD=!jD&&mD("MQQBrowser")&&mD("COVC"),QD=!jD&&mD("MQQBrowser")&&!mD("COVC"),$D=QD||XD?vD("MQQBrowser"):"",ZD=!jD&&mD(" QQBrowser"),eN=vD(" QQBrowser"),tN=!jD&&mD("QQBrowserLite"),nN=vD("QQBrowserLite"),rN=!jD&&mD("MQBHD"),iN=vD("MQBHD"),aN=mD("Windows"),oN=!ID&&mD("MAC OS X"),sN=!bD&&mD("Linux"),cN=mD("CrOS"),uN=mD("MicroMessenger"),lN=mD("UCBrowser"),dN=mD("Electron"),hN=mD("MiuiBrowser"),fN=vD("MiuiBrowser"),pN=mD("HuaweiBrowser"),mN=mD("Huawei")||mD("HUAWEI"),vN=mD("Honor")||mD("HONOR"),_N=vD("HuaweiBrowser"),gN=mD("SamsungBrowser"),yN=vD("SamsungBrowser"),EN=mD("HeyTapBrowser"),TN=vD("HeyTapBrowser"),kN=mD("VivoBrowser"),SN=vD("VivoBrowser"),IN=mD("OpenHarmony"),bN=vD("OpenHarmony"),AN=function(){return _D("Chrome")},RN=mD("Chrome"),CN=!xD&&!FD&&!VD&&!jD&&!GD&&!PD&&!ZD&&!hN&&!pN&&!gN&&!EN&&!kN&&RN,wN=mD("HeadlessChrome"),DN=AN(),NN=vD("Chrome"),xN=!RN&&!QD&&!XD&&!tN&&!rN&&mD("Safari"),ON=xN||ID,PN=vD("Version"),MN=/Android.*(wv|.0.0.0)/.test(pD),LN=function(){if(TD)return PN;if(ID){var e=pD.match(/OS (\d+)_(\d+)/i);if(e&&e[1]){var t=e[1];return e[2]&&(t+=".".concat(e[2])),t}}return""}(),VN=Number(LN.split(".")[0]),UN="15.1"===PN,FN="15.1"===LN,BN=function(){var e=Number(LN.split(".")[0]);return 14===e||13===e}(),jN="undefined"!=typeof location&&("file:"===location.protocol||"localhost"===location.hostname||"127.0.0.1"===location.hostname),HN=function(){var e;return function(){if(void 0===e)try{e=!!window.localStorage}catch(mx){e=!1}return e}}(),GN=WN();function WN(){var e,t=new Map([[wD,["Firefox",DD]],[PD,["Edg",MD]],[CN,["Chrome",NN]],[xN,["Safari",PN]],[jD,["TBS",HD]],[GD,["XWEB",WD]],[YD&&kD,["WeChat",qD]],[ZD,["QQ(Win)",eN]],[QD,["QQ(Mobile)",$D]],[XD,["QQ(Mobile X5)",$D]],[tN,["QQ(Mac)",nN]],[rN,["QQ(iPad)",iN]],[hN,["MI",fN]],[pN,["HW",_N]],[gN,["Samsung",yN]],[EN,["OPPO",TN]],[kN,["VIVO",SN]],[xD,["EDGE",OD]],[VD,["SogouMobile",UD]],[FD,["Sogou",BD]]]),n="unknown",r="unknown";return t.has(!0)&&(n=(e=v(t.get(!0),2))[0],r=e[1]),{name:n,version:r}}var JN=null;function KN(){return JN&&"boolean"==typeof JN.mobile?JN.mobile:bD||ID||kD||ED||IN}var zN="";function YN(){return aR(this,null,f().mark((function e(){return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!JN){e.next=2;break}return e.abrupt("return",JN);case 2:if(navigator.userAgentData&&"function"==typeof navigator.userAgentData.getHighEntropyValues){e.next=4;break}return e.abrupt("return",null);case 4:return e.prev=4,e.next=7,navigator.userAgentData.getHighEntropyValues(["architecture","bitness","model","platformVersion","fullVersionList"]);case 7:if(e.t0=JN=e.sent,!e.t0){e.next=10;break}e.t0=!zN;case 10:if(e.t1=e.t0,!e.t1){e.next=13;break}zN="UAData: ".concat(JN.platform,"/").concat(JN.platformVersion),JN.architecture&&JN.bitness&&(zN+=" ".concat(JN.architecture,"/").concat(JN.bitness)),JN.mobile&&(zN+=" mobile"),JN.model&&(zN+=" model: ".concat(JN.model)),JN.fullVersionList&&(zN+=" ".concat(JN.fullVersionList.filter((function(e){return"Not/A)Brand"!==e.brand})).map((function(e){return"".concat(e.brand,"/").concat(e.version)})).join(",")));case 13:return e.abrupt("return",JN);case 16:return e.prev=16,e.t2=e.catch(4),e.abrupt("return",null);case 19:case"end":return e.stop()}}),e,null,[[4,16]])})))}function qN(){return(null==JN?void 0:JN.model)||""}var XN=new Map([[bD,"Android"],[ID,"iOS"],[aN,"Windows"],[oN,"MacOS"],[sN,"Linux"],[cN,"ChromeOS"]]),QN=function(){return XN.get(!0)?XN.get(!0):JN?JN.platform:"unknown"};function $N(){return aN?1:bD?2:oN?3:ID?4:sN?5:cN?6:0}var ZN=function(){var e=QN();return e+="/".concat(GN.name,"/").concat(xN?GN.version:GN.version.split(".")[0]),null!=JN&&JN.platformVersion&&(e+="/".concat(JN.platformVersion)),null!=JN&&JN.architecture&&(e+="/".concat(JN.architecture)),e};function ex(){return bD?4:kD?2:ED?3:oN?12:aN?5:sN?13:IN?22:1}function tx(){return bD?"Android":kD?"iPhone":ED?"iPad":oN?"Mac":aN?"Windows":sN?"Linux":"unknown"}var nx,rx=new(tR(oR(),1).default),ix=((nx=ix||{}).ROOM_DESTROY="1",nx.JOIN_START="21",nx.JOIN_SCHEDULE_SUCCESS="22",nx.JOIN_SIGNAL_CONNECTION_START="23",nx.JOIN_SIGNAL_CONNECTION_END="24",nx.JOIN_SEND_CMD="25",nx.JOIN_RECEIVED_CMD_RES="26",nx.JOIN_SUCCESS="27",nx.JOIN_FAILED="28",nx.LEAVE_START="51",nx.LEAVE_SEND_CMD="52",nx.LEAVE_SUCCESS="53",nx.PUBLISH_START="61",nx.SEND_FIRST_VIDEO_FRAME="62",nx.PUBLISH_FAILED="63",nx.SUBSCRIBE_START="81",nx.SUBSCRIBE_SUCCESS="82",nx.SUBSCRIBE_FAILED="84",nx.UNSUBSCRIBE_SUCCESS="83",nx.LOCAL_TRACK_CAPTURE_START="101",nx.LOCAL_TRACK_CAPTURE_SUCCESS="102",nx.LOCAL_TRACK_CAPTURE_FAILED="103",nx.LOCAL_TRACK_PUBLISHED="104",nx.LOCAL_TRACK_UNPUBLISHED="105",nx.LOCAL_TRACK_REPLACED="106",nx.SWITCH_DEVICE_SUCCESS="107",nx.TRACK_MUTED="108",nx.TRACK_UNMUTED="109",nx.REMOTE_TRACK_SUBSCRIBED="110",nx.REMOTE_TRACK_UNSUBSCRIBED="111",nx.LOCAL_TRACK_RECAPTURE="112",nx.PLAY_TRACK_START="151",nx.PLAYER_STATE_CHANGED="152",nx.VIDEO_LOADED_DATA="153",nx.AUTOPLAY_DIALOG_CLICK_CONFIRM="154",nx.SIGNAL_CONNECTION_STATE_CHANGED="201",nx.PEER_CONNECTION_STATE_CHANGED="202",nx.SINGLE_CONNECTION_STAT="203",nx.SPC_RECONNECTED="204",nx.HEARTBEAT_REPORT="251",nx.RECEIVED_PUBLISHED_USER_LIST="252",nx.REMOTE_PUBLISH_STATE_CHANGED="253",nx.AUDIO_LEVEL_INTERVAL="260",nx.NETWORK_QUALITY="261",nx.VIDEO_CODEC_IMPLEMENTATION_CHANGED="262",nx.QUALITY_LIMITATION_CHANGED="263",nx.LOG="264",nx),ax=ix,ox=function(){function e(){r(this,e),rR(this,"_isEnableUploadLog",!0),rR(this,"_localJoinedUser",new Map),rR(this,"_queue",[]),rR(this,"_timeoutId",-1),rR(this,"_logLevel",1),rR(this,"_logLevelToUpload",2),!NR&&!xR&&(this.checkURLParam(),this.installEvents())}return o(e,[{key:"isAbleToUpload",get:function(){return this._isEnableUploadLog&&-1!==this._timeoutId}},{key:"installEvents",value:function(){var e=this;rx.on(ax.JOIN_SCHEDULE_SUCCESS,(function(t){var n,r=t.schedule;null!=(n=null==r?void 0:r.config)&&n.logLevelToUpload&&YR[r.config.logLevelToUpload]&&(e._logLevelToUpload=r.config.logLevelToUpload)})),rx.on(ax.JOIN_SUCCESS,(function(t){var n=t.room;e.addJoinedUser({userId:n.userId,sdkAppId:n.sdkAppId}),e.startUpload()})),rx.once(ax.JOIN_FAILED,(function(){e.startUpload()})),rx.on(ax.LEAVE_SUCCESS,(function(t){var n=t.room;e.deleteJoinedUser(n.userId)}))}},{key:"startUpload",value:function(){-1===this._timeoutId&&this.uploadInterval()}},{key:"addJoinedUser",value:function(e){this._localJoinedUser.set(e.userId,e),this.startUpload()}},{key:"deleteJoinedUser",value:function(e){this._localJoinedUser.delete(e)}},{key:"uploadInterval",value:function(){var e=this;this.upload().catch((function(){})),this._timeoutId=window.setTimeout((function(){return e.uploadInterval()}),5e3)}},{key:"getLogsToUpload",value:function(){var e=this,t={map:new Map,splicedQueue:[]};if(this._queue[0].forAllJoinedClients&&0===this._localJoinedUser.size)return t;for(var n=0,r=function(){var r=e._queue[n];if(r.forAllJoinedClients)e._localJoinedUser.forEach((function(e){var n=e.userId,i=e.sdkAppId;t.map.has(n)?t.map.get(n).logs.push(r):t.map.set(n,{userId:n,sdkAppId:i,logs:[r]})}));else if(bw(r.userId)&&Aw(r.sdkAppId)){var i=r.userId,a=r.sdkAppId;t.map.has(i)?t.map.get(i).logs.push(r):t.map.set(i,{userId:i,sdkAppId:a,logs:[r]})}};n<this._queue.length&&50!==n;n++)r();return t.map.size>0&&(t.splicedQueue=this._queue.splice(0,n)),t}},{key:"upload",value:function(){return aR(this,null,f().mark((function e(){var t,n,r,i,a,o,s,c,u,l;return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(0!==this._queue.length&&this._isEnableUploadLog){e.next=2;break}return e.abrupt("return");case 2:if(t=this.getLogsToUpload(),n=t.map,r=t.splicedQueue,0!==n.size){e.next=5;break}return e.abrupt("return");case 5:e.prev=5,i=E(n.values()),a=0;case 8:if(!(a<i.length)){e.next=16;break}return o=i[a],s=o.userId,c=o.sdkAppId,u=o.logs,e.next=12,this.uploadLogWithRetry(JSON.stringify({timestamp:kR(),sdkAppId:String(c),userId:s,version:RR,log:u.map((function(e){return e.log})).join("\n")}),c);case 12:u.forEach((function(e){return e.uploaded=!0}));case 13:a++,e.next=8;break;case 16:e.next=20;break;case 18:e.prev=18,e.t0=e.catch(5);case 20:l=r.filter((function(e){return!e.uploaded})),l.length>0&&(this._queue=l.concat(this._queue));case 22:case"end":return e.stop()}}),e,this,[[5,18]])})))}},{key:"uploadLogWithRetry",value:function(e,t){return dD({retryFunction:function(){return aD({url:ow(t,KR.LOG),body:e,timeout:5e3,priority:"low"})},settings:{retries:3,timeout:2e3},onError:function(e){(0,e.retry)()}})()}},{key:"getPrefix",value:function(e){var t=new Date;return t.setTime(TR()),"[".concat(SR(t),"] <").concat(YR[e],">")}},{key:"getLogLevel",value:function(){return this._logLevel}},{key:"setLogLevel",value:function(e){Iw(YR[e])||(this._logLevel!==e&&this.info("setLogLevel",e),this._logLevel=e)}},{key:"enableUploadLog",value:function(){this._isEnableUploadLog=!0}},{key:"disableUploadLog",value:function(){this.warn("disableUploadLog"),this._isEnableUploadLog=!1}},{key:"logChunkToString",value:function(e){if(bw(e))return e;try{return e instanceof Error?e.toString():JSON.stringify(e)}catch(wR){return""}}},{key:"log",value:function(t,n){var r,i,a,o=this,s=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],c=arguments.length>3?arguments[3]:void 0,u=arguments.length>4?arguments[4]:void 0;n.unshift(this.getPrefix(t));var l={log:n.reduce((function(e,t){return"".concat(e," ").concat(o.logChunkToString(t)).trim()}),""),level:t,userId:c,sdkAppId:u,forAllJoinedClients:s};if(rx.emit(ax.LOG,{log:l}),this._isEnableUploadLog&&t>=this._logLevelToUpload&&this._queue.push(l),!(t<this._logLevel)){var d=(null==(a=YR[t])?void 0:a.toLowerCase())||"info";e.PRINT_LOG_TAG?(r=console)[d].apply(r,["%cTRTC%c%s","padding: 1px 4px;border-radius: 3px;color: #fff;background: #1E88E5;","display: inline"].concat(E(n))):(i=console)[d].apply(i,E(n))}}},{key:"debug",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];this.log(1,t)}},{key:"info",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];this.log(2,t)}},{key:"warn",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];this.log(3,t)}},{key:"error",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];this.log(4,t)}},{key:"createLogger",value:function(e){return new hD(e)}},{key:"checkURLParam",value:function(){var e=new URLSearchParams(location.search).get("logLevelToUpload"),t=e?Number(e):-1;YR[t]&&(this._logLevelToUpload=t)}},{key:"getQueue",value:function(){return this._queue}}])}();rR(ox,"PRINT_LOG_TAG",!(ID||bD||wN));var sx=new ox,cx=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(function(e){var t=16*Math.random()|0;return("x"==e?t:3&t|8).toString(16)}))},ux=new(function(){return o((function e(){r(this,e),rR(this,"_prefix","TRTC"),rR(this,"_queue",new Map)}),[{key:"getRealKey",value:function(e){return"".concat(this._prefix,"_").concat(e)}},{key:"checkStorage",value:function(){var e=this;HN()&&(setInterval(this.doFlush.bind(this),2e4),Object.keys(localStorage).filter((function(t){if(t.startsWith(e._prefix))try{var n=localStorage.getItem(t);if(!n)return!1;var r=JSON.parse(n);if(r&&r.expiresIn<Date.now())return!0}catch(vx){return!1}return!1})).forEach((function(e){return localStorage.removeItem(e)})))}},{key:"doFlush",value:function(){if(HN())try{var e,t=s(this._queue);try{for(t.s();!(e=t.n()).done;){var n=v(e.value,2),r=n[0],i=n[1];localStorage.setItem(r,JSON.stringify(i))}}catch(a){t.e(a)}finally{t.f()}}catch(mx){sx.warn(mx)}}},{key:"getItem",value:function(e){if(!HN())return null;try{var t=localStorage.getItem(this.getRealKey(e));if(!t)return null;var n=JSON.parse(t);return n&&n.expiresIn>=Date.now()?n.value:null}catch(wR){sx.warn(wR)}}},{key:"setItem",value:function(e,t){if(HN())try{var n={expiresIn:Date.now()+$R,value:t};this._queue.set(this.getRealKey(e),n)}catch(DC){sx.warn(DC)}}},{key:"deleteItem",value:function(e){if(!HN())return!1;try{return e=this.getRealKey(e),this._queue.delete(e),localStorage.removeItem(e),!0}catch(wR){return sx.warn(wR),!1}}},{key:"clear",value:function(){if(HN())try{localStorage.clear()}catch(mx){sx.warn(mx)}}}])}()),lx={};eR(lx,{HTTPS_API:function(){return jO},IS_GET_CAPABILITIES_SUPPORTED:function(){return oP},IS_GET_SETTINGS_SUPPORTED:function(){return aP},IS_GET_SYNCHRONIZATION_SOURCES_SUPPORTED:function(){return iP},IS_INSERTABLE_STREAM_SUPPORTED:function(){return sP},IS_JITTER_BUFFER_TARGET_SUPPORTED:function(){return yP},IS_RTC_RTP_SENDER_SUPPORTED:function(){return tP},IS_SCRIPT_TRANSFORM_SUPPORTED:function(){return cP},IS_SEI_SUPPORTED:function(){return uP},IS_SPC_SUPPORTED:function(){return ZO},basis:function(){return mP},capabilityCheck:function(){return _P},checkSystemRequirementsInternal:function(){return VO},decodeSupportStatus:function(){return LO},encodeSupportStatus:function(){return MO},getBrowserInfo:function(){return CO},getDisplayResolution:function(){return GO},isAddTransceiverSupported:function(){return $O},isBrowserSupported:function(){return wO},isGetReceiversSupported:function(){return qO},isGetSendersSupported:function(){return XO},isGetTransceiversSupported:function(){return QO},isGetUserMediaSupported:function(){return WO},isMediaDevicesSupported:function(){return NO},isMediaSessionSupported:function(){return hP},isMediaStreamTrackProcessorSupported:function(){return PO},isReplaceTrackSupported:function(){return nP},isRequestVideoFrameCallbackSupported:function(){return gP},isSIMDSupported:function(){return pP},isScreenCaptureApiAvailable:function(){return FO},isSelectedCandidatePair:function(){return HO},isSetParametersSupported:function(){return rP},isSmallStreamAPISupported:function(){return KO},isSmallStreamSupported:function(){return zO},isStopTransceiverSupported:function(){return eP},isTRTCSupported:function(){return UO},isUnifiedPlanDefault:function(){return YO},isUsedInHttpProtocol:function(){return OO},isWebAudioSupported:function(){return JO},isWebCodecSupported:function(){return dP},isWebCodecsSupported:function(){return DO},isWebRTCSupported:function(){return lP},isWebTransportSupported:function(){return fP}});var dx={};eR(dx,{AUDIO_LEVEL_SCALE:function(){return tO},AudioCodecPipelineType:function(){return oO},AudioDecoderDowngradeState:function(){return Lx},AudioPlayerMode:function(){return $x},AudioType:function(){return Hx},BASIC_TYPE:function(){return rO},BannedReason:function(){return Zx},CONNECTION_CLOSED_REASON:function(){return Sx},ClientEvent:function(){return Ix},CodecType:function(){return sO},ConnectionEvent:function(){return kx},ConnectionState:function(){return Mx},DECODE_FAILED_ERROR_CODE:function(){return cO},FacingMode:function(){return Xx},LeaveReason:function(){return eO},LocalTrackEvent:function(){return Ax},MULTI_VIDEO_DATA_TYPE:function(){return Kx},MediaType:function(){return Bx},MediaTypeLabel:function(){return jx},MonitorEventId:function(){return zx},MutedFlag:function(){return Nx},NetworkQualityValue:function(){return Yx},PlayerState:function(){return Rx},ReceiveMode:function(){return qx},RemoteStreamType:function(){return Jx},RemoteTrackEvent:function(){return Dx},RoomEvent:function(){return Cx},SceneNumber:function(){return xx},StreamEvent:function(){return bx},StreamType:function(){return Wx},SubscribeMediaType:function(){return nO},TIMER_TYPE:function(){return lO},TRACK_ACTION:function(){return Fx},TRACK_KIND:function(){return Ux},TrackEvent:function(){return wx},UserRole:function(){return Px},UserRoleNumber:function(){return Ox},VideoCodec:function(){return iO},VideoCodecPipelineType:function(){return aO},VideoContentHint:function(){return uO},VideoDecoderDowngradeState:function(){return Vx},VideoPlayerMode:function(){return Qx},VideoType:function(){return Gx}});var hx,fx,px,mx,vx,_x,gx,yx,Ex,Tx,kx=((Tx=kx||{}).TRACK_ADDED="track-added",Tx.TRACK_UPDATED="track-updated",Tx.TRACK_SUBSCRIBED="track-subscribed",Tx.STREAM_ADDED="stream-added",Tx.STREAM_REMOVED="stream-removed",Tx.STREAM_UPDATED="stream-updated",Tx.STREAM_PUBLISHED="stream-published",Tx.STREAM_SUBSCRIBED="stream-subscribed",Tx.STREAM_UNSUBSCRIBED="stream-unsubscribed",Tx.STATE_CHANGED="state-changed",Tx.ERROR="error",Tx.CONNECTION_STATE_CHANGED="connection-state-changed",Tx.FIREWALL_RESTRICTION="firewall-restriction",Tx.SEI_MESSAGE="sei-message",Tx.CLOSED="closed",Tx),Sx=function(e){return e.REMOTE_LEAVE="remote user exitRoom",e.REMOTE_UNPUBLISH="remote user unpublished",e.LOCAL_LEAVE="you exitRoom",e.LOCAL_UNPUBLISH="you unpublished",e.LOCAL_UNSUBSCRIBE="you unsubscribed",e.SWITCH_ROLE="you switch role to audience",e}(Sx||{}),Ix=((Ex=Ix||{}).STREAM_ADDED="stream-added",Ex.STREAM_REMOVED="stream-removed",Ex.STREAM_UPDATED="stream-updated",Ex.STREAM_SUBSCRIBED="stream-subscribed",Ex.CONNECTION_STATE_CHANGED="connection-state-changed",Ex.PEER_JOIN="peer-join",Ex.PEER_LEAVE="peer-leave",Ex.MUTE_AUDIO="mute-audio",Ex.MUTE_VIDEO="mute-video",Ex.UNMUTE_AUDIO="unmute-audio",Ex.UNMUTE_VIDEO="unmute-video",Ex.CLIENT_BANNED="client-banned",Ex.NETWORK_QUALITY="network-quality",Ex.AUDIO_VOLUME="audio-volume",Ex.SEI_MESSAGE="sei-message",Ex.ERROR="error",Ex),bx=((yx=bx||{}).PLAYER_STATE_CHANGED="player-state-changed",yx.SCREEN_SHARING_STOPPED="screen-sharing-stopped",yx.CONNECTION_STATE_CHANGED="connection-state-changed",yx.DEVICE_AUTO_RECOVERED="device-auto-recovered",yx.ERROR="error",yx),Ax=function(e){return e.DEVICE_AUTO_RECOVERED="1",e.DEVICE_RECOVER_FAILED="5",e.DEVICE_CHANGED="2",e.ERROR="3",e.PUBLISH_STATE_CHANGED="4",e.ENCODE_FAILED="6",e}(Ax||{}),Rx=function(e){return e.PAUSED="PAUSED",e.PLAYING="PLAYING",e.STOPPED="STOPPED",e}(Rx||{}),Cx=((gx=Cx||{}).PEER_JOIN="peer-join",gx.PEER_LEAVE="peer-leave",gx.SIGNAL_CONNECTION_STATE_CHANGED="signal-connection-state-changed",gx.MEDIA_CONNECTION_STATE_CHANGED="media-connection-state-changed",gx.BANNED="banned",gx.NETWORK_QUALITY="network-quality",gx.AUDIO_VOLUME="audio-volume",gx.SEI_MESSAGE="sei-message",gx.ERROR="error",gx.REMOTE_PUBLISH_STATE_CHANGED="remote-publish-state-changed",gx.REMOTE_PUBLISHED="remote-published",gx.REMOTE_UNPUBLISHED="remote-unpublished",gx.FIREWALL_RESTRICTION="firewall-restriction",gx.HEARTBEAT_REPORT="heartbeat-report",gx.CUSTOM_MESSAGE="custom-message",gx.LAYER_DATA="layerData",gx.FIRST_VIDEO_FRAME="first-video-frame",gx.DUMP="dump",gx),wx=((_x=wx||{}).PLAYER_STATE_CHANGED="player-state-changed",_x.MUTE="mute",_x.UNMUTE="unmute",_x.ERROR="error",_x.INPUT_MEDIA_TRACK_CHANGED="input-media-track-changed",_x.OUTPUT_MEDIA_TRACK_CHANGED="output-media-track-changed",_x.FIRST_VIDEO_FRAME="first-video-frame",_x),Dx=function(e){return e.DECODE_FAILED="decode-failed",e.DECODE_DOWNGRADE_STATE_CHANGED="decode-downgrade-state-changed",e}(Dx||{}),Nx=function(e){return e[e.VIDEO=1]="VIDEO",e[e.SMALL=2]="SMALL",e[e.AUX=4]="AUX",e[e.AUDIO=8]="AUDIO",e[e.VIDEO_MUTE=16]="VIDEO_MUTE",e[e.AUX_MUTE=32]="AUX_MUTE",e[e.AUDIO_MUTE=64]="AUDIO_MUTE",e}(Nx||{}),xx=function(e){return e[e.RTC=1]="RTC",e[e.LIVE=2]="LIVE",e}(xx||{}),Ox=function(e){return e[e.ANCHOR=20]="ANCHOR",e[e.AUDIENCE=21]="AUDIENCE",e}(Ox||{}),Px=function(e){return e.ANCHOR="anchor",e.AUDIENCE="audience",e}(Px||{}),Mx=function(e){return e.CONNECTED="CONNECTED",e.DISCONNECTED="DISCONNECTED",e.CONNECTING="CONNECTING",e.RECONNECTED="RECONNECTED",e.RECONNECTING="RECONNECTING",e}(Mx||{}),Lx=((vx=Lx||{}).INITIALIZED="INITIALIZED",vx.STARTING="STARTING",vx.STARTED="STARTED",vx.FAILED="FAILED",vx),Vx=function(e){return e.INITIALIZED="INITIALIZED",e.STARTING="STARTING",e.STARTED="STARTED",e.FAILED="FAILED",e}(Vx||{}),Ux=function(e){return e.AUDIO="audio",e.VIDEO="video",e.AUXILIARY="auxVideo",e}(Ux||{}),Fx=function(e){return e.ADD="add",e.REMOVE="remove",e}(Fx||{}),Bx=function(e){return e[e.NULL=0]="NULL",e[e.AUDIO=1]="AUDIO",e[e.AUX_VIDEO=2]="AUX_VIDEO",e[e.BIG_VIDEO=4]="BIG_VIDEO",e[e.SMALL_VIDEO=8]="SMALL_VIDEO",e}(Bx||{}),jx={1:"audio",2:"auxVideo",4:"video"},Hx=((mx=Hx||{})[mx.opus=111]="opus",mx),Gx=function(e){return e[e.h264=100]="h264",e[e.vp8=101]="vp8",e}(Gx||{}),Wx=function(e){return e.Big="big",e.Small="small",e}(Wx||{}),Jx=function(e){return e.Main="main",e.Aux="auxiliary",e}(Jx||{}),Kx=function(e){return e[e.MULTI_DATA_AUDIO=1]="MULTI_DATA_AUDIO",e[e.MULTI_DATA_BIG_IMG=2]="MULTI_DATA_BIG_IMG",e[e.MULTI_DATA_SMALL_IMG=3]="MULTI_DATA_SMALL_IMG",e[e.MULTI_DATA_AUX_IMG=7]="MULTI_DATA_AUX_IMG",e[e.MULTI_DATA_TYPE_BUTT=12]="MULTI_DATA_TYPE_BUTT",e}(Kx||{}),zx=((px=zx||{})[px.PUBLISH_VIDEO=32768]="PUBLISH_VIDEO",px[px.PUBLISH_AUDIO=32769]="PUBLISH_AUDIO",px[px.UNPUBLISH_VIDEO=32770]="UNPUBLISH_VIDEO",px[px.UNPUBLISH_AUDIO=32771]="UNPUBLISH_AUDIO",px[px.MUTE_AUDIO=32772]="MUTE_AUDIO",px[px.MUTE_VIDEO=32773]="MUTE_VIDEO",px[px.UNMUTE_AUDIO=32774]="UNMUTE_AUDIO",px[px.UNMUTE_VIDEO=32775]="UNMUTE_VIDEO",px[px.SUBSCRIBE_VIDEO=32776]="SUBSCRIBE_VIDEO",px[px.SUBSCRIBE_AUDIO=32777]="SUBSCRIBE_AUDIO",px[px.UNSUBSCRIBE_VIDEO=32778]="UNSUBSCRIBE_VIDEO",px[px.UNSUBSCRIBE_AUDIO=32779]="UNSUBSCRIBE_AUDIO",px[px.SWITCH_CAMERA=32780]="SWITCH_CAMERA",px[px.SWITCH_MICROPHONE=32781]="SWITCH_MICROPHONE",px[px.REPLACE_VIDEO=32782]="REPLACE_VIDEO",px[px.REPLACE_AUDIO=32783]="REPLACE_AUDIO",px[px.MUTE_REMOTE_VIDEO=32784]="MUTE_REMOTE_VIDEO",px[px.MUTE_REMOTE_AUDIO=32785]="MUTE_REMOTE_AUDIO",px[px.UNMUTE_REMOTE_VIDEO=32786]="UNMUTE_REMOTE_VIDEO",px[px.UNMUTE_REMOTE_AUDIO=32787]="UNMUTE_REMOTE_AUDIO",px[px.JOIN=32788]="JOIN",px[px.LEAVE=32789]="LEAVE",px[px.SIGNAL_DISCONNECTED=32790]="SIGNAL_DISCONNECTED",px[px.SIGNAL_CONNECTED=32791]="SIGNAL_CONNECTED",px[px.TRANSPORT_UPLINK_CONNECTED=32792]="TRANSPORT_UPLINK_CONNECTED",px[px.TRANSPORT_DOWNLINK_CONNECTED=32793]="TRANSPORT_DOWNLINK_CONNECTED",px[px.SIGNAl_RECONNECTING=32794]="SIGNAl_RECONNECTING",px[px.SIGNAL_RECONNECT_SUCCESS=32795]="SIGNAL_RECONNECT_SUCCESS",px[px.SIGNAL_RECONNECT_FAIL=32796]="SIGNAL_RECONNECT_FAIL",px[px.TRANSPORT_UPLINK_RECONNECTING=32797]="TRANSPORT_UPLINK_RECONNECTING",px[px.TRANSPORT_UPLINK_RECONNECT_SUCCESS=32798]="TRANSPORT_UPLINK_RECONNECT_SUCCESS",px[px.TRANSPORT_UPLINK_RECONNECT_FAIL=32799]="TRANSPORT_UPLINK_RECONNECT_FAIL",px[px.TRANSPORT_DOWNLINK_RECONNECTING=32800]="TRANSPORT_DOWNLINK_RECONNECTING",px[px.TRANSPORT_DOWNLINK_RECONNECT_SUCCESS=32801]="TRANSPORT_DOWNLINK_RECONNECT_SUCCESS",px[px.TRANSPORT_DOWNLINK_RECONNECT_FAIL=32802]="TRANSPORT_DOWNLINK_RECONNECT_FAIL",px[px.SUBSCRIBE_SMALL_VIDEO=32803]="SUBSCRIBE_SMALL_VIDEO",px[px.UNSUBSCRIBE_SMALL_VIDEO=32804]="UNSUBSCRIBE_SMALL_VIDEO",px[px.PUBLISH_AUX=32805]="PUBLISH_AUX",px[px.UNPUBLISH_AUX=32806]="UNPUBLISH_AUX",px[px.DEVICE_CAPTURE=2003]="DEVICE_CAPTURE",px[px.VIDEO_ENCODER=4004]="VIDEO_ENCODER",px[px.VIDEO_DECODER=4005]="VIDEO_DECODER",px),Yx=function(e){return e[e.UNKNOWN=0]="UNKNOWN",e[e.EXCELLENT=1]="EXCELLENT",e[e.GOOD=2]="GOOD",e[e.POOR=3]="POOR",e[e.BAD=4]="BAD",e[e.VERY_BAD=5]="VERY_BAD",e[e.DISCONNECTED=6]="DISCONNECTED",e}(Yx||{}),qx=function(e){return e[e.MANUAL=0]="MANUAL",e[e.AUTO_AUDIO=1]="AUTO_AUDIO",e[e.AUTO_VIDEO=2]="AUTO_VIDEO",e[e.AUTO_ALL=3]="AUTO_ALL",e}(qx||{}),Xx=function(e){return e.user="user",e.environment="environment",e}(Xx||{}),Qx=function(e){return e[e.ELEMENT=0]="ELEMENT",e[e.CANVAS_FROM_ELEMENT=1]="CANVAS_FROM_ELEMENT",e[e.CANVAS_WITHOUT_ELEMENT=2]="CANVAS_WITHOUT_ELEMENT",e}(Qx||{}),$x=function(e){return e[e.ELEMENT=0]="ELEMENT",e[e.CONTEXT=1]="CONTEXT",e}($x||{}),Zx=function(e){return e.BANNED="banned",e.KICK="kick",e.USER_TIME_OUT="user_time_out",e.ROOM_DISBAND="room_disband",e}(Zx||{}),eO=((fx=eO||{})[fx.USER_EXIT_REASON_TC_USER_EXIT_NORMAL=0]="USER_EXIT_REASON_TC_USER_EXIT_NORMAL",fx[fx.USER_EXIT_REASON_TC_USER_EXIT_TIMEOUT=1]="USER_EXIT_REASON_TC_USER_EXIT_TIMEOUT",fx[fx.USER_EXIT_REASON_TC_USER_EXIT_KICKED=2]="USER_EXIT_REASON_TC_USER_EXIT_KICKED",fx[fx.USER_EXIT_REASON_TC_USER_EXIT_CHANGED=3]="USER_EXIT_REASON_TC_USER_EXIT_CHANGED",fx[fx.USER_KICK_OUT_CODE_BUSINESS_USER=4]="USER_KICK_OUT_CODE_BUSINESS_USER",fx[fx.USER_KICK_OUT_CODE_BUSINESS_ROOM=5]="USER_KICK_OUT_CODE_BUSINESS_ROOM",fx[fx.USER_KICK_OUT_CODE_SERVER_USER=6]="USER_KICK_OUT_CODE_SERVER_USER",fx[fx.USER_KICK_OUT_CODE_SERVER_ROOM=7]="USER_KICK_OUT_CODE_SERVER_ROOM",fx[fx.USER_KICK_SESS_EXSIT=8]="USER_KICK_SESS_EXSIT",fx),tO=1e8,nO=function(){return o((function e(){r(this,e),rR(this,"mediaType",0)}),[{key:"audio",get:function(){return!!(1&this.mediaType)},set:function(e){e?this.mediaType|=1:this.mediaType&=-2}},{key:"video",get:function(){return!!(4&this.mediaType)},set:function(e){e?this.mediaType|=4:this.mediaType&=-5}},{key:"auxiliary",get:function(){return!!(2&this.mediaType)},set:function(e){e?this.mediaType|=2:this.mediaType&=-3}},{key:"smallVideo",get:function(){return!!(8&this.mediaType)},set:function(e){e?this.mediaType|=8:this.mediaType&=-9}}])}(),rO=function(e){return e.String="string",e.Number="number",e.Boolean="boolean",e.Array="array",e.Object="object",e}(rO||{}),iO=function(e){return e.H264="h264",e.H265="h265",e.VP8="vp8",e}(iO||{}),aO=function(e){return e[e.ENCRYPT_AND_DECRYPT=0]="ENCRYPT_AND_DECRYPT",e[e.DUMP=1]="DUMP",e[e.SEI=2]="SEI",e[e.ENCODE_AND_DECODE=3]="ENCODE_AND_DECODE",e}(aO||{}),oO=function(e){return e[e.ENCRYPT_AND_DECRYPT=0]="ENCRYPT_AND_DECRYPT",e[e.NTP_TO_AUDIO_FRAME=1]="NTP_TO_AUDIO_FRAME",e[e.DUMP=2]="DUMP",e[e.ENCODE_AND_DECODE=3]="ENCODE_AND_DECODE",e}(oO||{}),sO=function(e){return e.WebRTC="webrtc",e.WebCodecs="webcodecs",e.WebAssembly="webassembly",e}(sO||{}),cO=((hx=cO||{})[hx.SUCCESS=0]="SUCCESS",hx[hx.FAILED=1]="FAILED",hx[hx.WEBCODEC_INIT=2]="WEBCODEC_INIT",hx[hx.WEBCODEC_CONFIG_NOT_SUPPORT=3]="WEBCODEC_CONFIG_NOT_SUPPORT",hx[hx.WEBCODEC_DECODER_ERROR=4]="WEBCODEC_DECODER_ERROR",hx[hx.WEBCODEC_TRACK_MUTE=5]="WEBCODEC_TRACK_MUTE",hx[hx.WASM_INIT=6]="WASM_INIT",hx[hx.WASM_WEBGL_UNAVALIABLE=7]="WASM_WEBGL_UNAVALIABLE",hx[hx.WASM_DECODER_ERROR=8]="WASM_DECODER_ERROR",hx[hx.WASM_TRACK_MUTE=9]="WASM_TRACK_MUTE",hx[hx.TEST=10]="TEST",hx),uO=function(e){return e.NONE="",e.DETAIL="detail",e.MOTION="motion",e.TEXT="text",e}(uO||{}),lO=function(e){return e.INTERVAL="interval",e.TIMEOUT="timeout",e.RAF="raf",e.RIC="ric",e.INTERVAL_IN_WORKER="intervalInWorker",e}(lO||{}),dO={AVOID_REPEATED_CALL:"AVOID_REPEATED_CALL",INVALID_PARAMETER_REQUIRED:"INVALID_PARAMETER_REQUIRED",INVALID_PARAMETER_TYPE:"INVALID_PARAMETER_TYPE",INVALID_PARAMETER_EMPTY:"INVALID_PARAMETER_EMPTY",INVALID_PARAMETER_INSTANCE:"INVALID_PARAMETER_INSTANCE",INVALID_PARAMETER_RANGE:"INVALID_PARAMETER_RANGE",INVALID_PARAMETER_MIN:"INVALID_PARAMETER_MIN",INVALID_PARAMETER_MAX:"INVALID_PARAMETER_MAX",INVALID_PARAMETER_STREAMTYPE:"INVALID_PARAMETER_STREAMTYPE",API_CALL_TIMEOUT:"API_CALL_TIMEOUT",SIGNAL_CHANNEL_RECONNECTION_FAILED:"SIGNAL_CHANNEL_RECONNECTION_FAILED",SIGNAL_CHANNEL_SETUP_FAILED:"SIGNAL_CHANNEL_SETUP_FAILED",ERROR_MESSAGE:"ERROR_MESSAGE",EXCHANGE_SDP_TIMEOUT:"EXCHANGE_SDP_TIMEOUT",DOWNLINK_RECONNECTION_FAILED:"DOWNLINK_RECONNECTION_FAILED",EXCHANGE_SDP_FAILED:"EXCHANGE_SDP_FAILED",UPDATE_OFFER_TIMEOUT:"UPDATE_OFFER_TIMEOUT",UPLINK_RECONNECTION_FAILED:"UPLINK_RECONNECTION_FAILED",INVALID_RECORDID:"INVALID_RECORDID",INVALID_PURE_AUDIO:"INVALID_PURE_AUDIO",INVALID_STREAMID:"INVALID_STREAMID",INVALID_USER_DEFINE_RECORDID:"INVALID_USER_DEFINE_RECORDID",INVALID_USER_DEFINE_PUSH_ARGS:"INVALID_USER_DEFINE_PUSH_ARGS",INVALID_PROXY:"INVALID_PROXY",INVALID_JOIN:"INVALID_JOIN",INVALID_ROOMID_STRING:"INVALID_ROOMID_STRING",INVALID_ROOMID_INTEGER:"INVALID_ROOMID_INTEGER",INVALID_SIGNAL_CHANNEL:"INVALID_SIGNAL_CHANNEL",JOIN_ROOM_TIMEOUT:"JOIN_ROOM_TIMEOUT",JOIN_ROOM_FAILED:"JOIN_ROOM_FAILED",REJOIN_ROOM_FAILED:"REJOIN_ROOM_FAILED",INVALID_DESTROY:"INVALID_DESTROY",INVALID_PUBLISH:"INVALID_PUBLISH",INVALID_UNPUBLISH:"INVALID_UNPUBLISH",INVALID_AUDIENCE:"INVALID_AUDIENCE",INVALID_INITIALIZE:"INVALID_INITIALIZE",INVALID_DUPLICATE_PUBLISHING:"INVALID_DUPLICATE_PUBLISHING",INVALID_SUBSCRIBE_UNDEFINED:"INVALID_SUBSCRIBE_UNDEFINED",INVALID_SUBSCRIBE_LOCAL:"INVALID_SUBSCRIBE_LOCAL",INVALID_REMOTE_STREAM:"INVALID_REMOTE_STREAM",SUBSCRIBE_FAILED:"SUBSCRIBE_FAILED",INVALID_ROLE:"INVALID_ROLE",INVALID_PARAMETER_SWITCH_ROLE:"INVALID_PARAMETER_SWITCH_ROLE",INVALID_OPERATION_SWITCH_ROLE:"INVALID_OPERATION_SWITCH_ROLE",SWITCH_ROLE_TIMEOUT:"SWITCH_ROLE_TIMEOUT",SWITCH_ROLE_FAILED:"SWITCH_ROLE_FAILED",CLIENT_BANNED:"CLIENT_BANNED",INVALID_OPERATION_START_PUBLISH_CDN:"INVALID_OPERATION_START_PUBLISH_CDN",INVALID_OPERATION_STOP_PUBLISH_CDN:"INVALID_OPERATION_STOP_PUBLISH_CDN",INVALID_STREAM_ID:"INVALID_STREAM_ID",START_PUBLISH_CDN_FAILED:"START_PUBLISH_CDN_FAILED",STOP_PUBLISH_CDN_FAILED:"STOP_PUBLISH_CDN_FAILED",START_MIX_TRANSCODE:"START_MIX_TRANSCODE",STOP_MIX_TRANSCODE:"STOP_MIX_TRANSCODE",INVALID_AUDIO_VOLUME:"INVALID_AUDIO_VOLUME",ENABLE_SMALL_STREAM_PUBLISHED:"ENABLE_SMALL_STREAM_PUBLISHED",DISABLE_SMALL_STREAM_PUBLISHED:"DISABLE_SMALL_STREAM_PUBLISHED",NOT_SUPPORTED_SMALL_STREAM:"NOT_SUPPORTED_SMALL_STREAM",INVALID_SMALL_STREAM_PROFILE:"INVALID_SMALL_STREAM_PROFILE",INVALID_PARAMETER_REMOTE_STREAM:"INVALID_PARAMETER_REMOTE_STREAM",INVALID_OPERATION_CHANGE_SMALL:"INVALID_OPERATION_CHANGE_SMALL",REMOTE_NOT_PUBLISH_SMALL_STREAM:"REMOTE_NOT_PUBLISH_SMALL_STREAM",INVALID_SWITCH_DEVICE:"INVALID_SWITCH_DEVICE",INVALID_SWITCH_DEVICE_PUBLISHING:"INVALID_SWITCH_DEVICE_PUBLISHING",INVALID_REPLACE_TRACK:"INVALID_REPLACE_TRACK",INVALID_INITIALIZE_LOCAL_STREAM:"INVALID_INITIALIZE_LOCAL_STREAM",INVALID_ADD_TRACK_REPETITIVE:"INVALID_ADD_TRACK_REPETITIVE",INVALID_ADD_TRACK_REMOVING:"INVALID_ADD_TRACK_REMOVING",INVALID_ADD_TRACK_PUBLISHING:"INVALID_ADD_TRACK_PUBLISHING",INVALID_STREAM_INITIALIZED:"INVALID_STREAM_INITIALIZED",INVALID_ADD_TRACK_NUMBER:"INVALID_ADD_TRACK_NUMBER",INVALID_REMOVE_AUDIO_TRACK:"INVALID_REMOVE_AUDIO_TRACK",INVALID_REMOVE_AUDIO_ADDING:"INVALID_REMOVE_AUDIO_ADDING",INVALID_REMOVE_AUDIO_ON:"INVALID_REMOVE_AUDIO_ON",INVALID_REMOVE_TRACK_PUBLISHING:"INVALID_REMOVE_TRACK_PUBLISHING",INVALID_REMOVE_TRACK_NOT_TRACK:"INVALID_REMOVE_TRACK_NOT_TRACK",INVALID_REMOVE_TRACK_NUMBER:"INVALID_REMOVE_TRACK_NUMBER",INVALID_REPLACE_TRACK_NO_TRACK:"INVALID_REPLACE_TRACK_NO_TRACK",REPEAT_JOIN:"REPEAT_JOIN",CLIENT_DESTROYED:"CLIENT_DESTROYED",NOT_BUG_PACKAGE:"NOT_BUG_PACKAGE",START_MIX_TRANSCODE_FAILED:"START_MIX_TRANSCODE_FAILED",STOP_MIX_TRANSCODE_FAILED:"STOP_MIX_TRANSCODE_FAILED",MIX_TRANSCODE_NOT_STARTED:"MIX_TRANSCODE_NOT_STARTED",CANNOT_LESS_THAN_ZERO:"CANNOT_LESS_THAN_ZERO",MIX_PARAMS_VIDEO_FRAMERATE:"MIX_PARAMS_VIDEO_FRAMERATE",MIX_PARAMS_VIDEO_GOP:"MIX_PARAMS_VIDEO_GOP",MIX_PARAMS_AUDIO_BITRATE:"MIX_PARAMS_AUDIO_BITRATE",MIX_PARAMS_USER_Z_ORDER:"MIX_PARAMS_USER_Z_ORDER",MIX_PARAMS_NOT_SELF:"MIX_PARAMS_NOT_SELF",MIX_PARAMS_USER_STREAM:"MIX_PARAMS_USER_STREAM",INVALID_PLAY:"INVALID_PLAY",INVALID_ELEMENT_ID:"INVALID_ELEMENT_ID",INVALID_ELEMENT_ID_TYPE:"INVALID_ELEMENT_ID_TYPE",PLAY_FAILED:"PLAY_FAILED",INVALID_USERID:"INVALID_USERID",INVALID_CREATE_STREAM_SOURCE:"INVALID_CREATE_STREAM_SOURCE",INVALID_CREATE_STREAM_SCREEN:"INVALID_CREATE_STREAM_SCREEN",INVALID_CREATE_STREAM_AUDIO:"INVALID_CREATE_STREAM_AUDIO",INVALID_CREATE_STREAM_SCREEN_AUDIO:"INVALID_CREATE_STREAM_SCREEN_AUDIO",NOT_SUPPORTED_HTTP:"NOT_SUPPORTED_HTTP",NOT_SUPPORTED_WEBRTC:"NOT_SUPPORTED_WEBRTC",NOT_SUPPORTED_PROFILE:"NOT_SUPPORTED_PROFILE",NOT_SUPPORTED_MEDIA:"NOT_SUPPORTED_MEDIA",NOT_SUPPORTED_H264ENCODE:"NOT_SUPPORTED_H264ENCODE",NOT_SUPPORTED_H264DECODE:"NOT_SUPPORTED_H264DECODE",NOT_SUPPORTED_TRACK:"NOT_SUPPORTED_TRACK",NOT_SUPPORTED_SWITCH_DEVICE:"NOT_SUPPORTED_SWITCH_DEVICE",NOT_SUPPORTED_CAPTURE:"NOT_SUPPORTED_CAPTURE",NOT_SUPPORTED_AUX:"NOT_SUPPORTED_AUX",MICROPHONE_NOT_FOUND:"MICROPHONE_NOT_FOUND",CAMERA_NOT_FOUND:"CAMERA_NOT_FOUND",SIGNAL_RESPONSE_FAILED:"SIGNAL_RESPONSE_FAILED",CATCH_HANDLER_ERROR:"CATCH_HANDLER_ERROR",API_NOT_EXIST:"API_NOT_EXIST",CONNECTION_CLOSED:"CONNECTION_CLOSED",SUBSCRIBE_ALL_FALSE:"SUBSCRIBE_ALL_FALSE",SEI_NOT_SUPPORT:"SEI_NOT_SUPPORT",SEI_DISABLED:"SEI_DISABLED",SEI_BEFORE_PUBLISH:"SEI_BEFORE_PUBLISH",SEI_NOT_VIDEO:"SEI_NOT_VIDEO",CALL_FREQUENCY_LIMIT:"CALL_FREQUENCY_LIMIT",CONNECTION_ABORTED:"CONNECTION_ABORTED",API_CALL_ABORTED:"API_CALL_ABORTED",DUPLICATE_AUX:"DUPLICATE_AUX"},hO={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,n=e.key,r=e.rule,i=e.fnName,a=e.value,o="".concat(n||r.name);return t=Array.isArray(r.type)?r.type.join("|"):r.type,"'".concat(o,"' must be type of ").concat(t," when calling ").concat(i,"(), received type: ").concat(kw(a),".")},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,a="".concat(t||n.name),o="".concat(n.instanceOf.name||n.instanceOf);return"'".concat(a,"' must be instanceof ").concat(o," when calling ").concat(r,"(), received type: ").concat(kw(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,".")},INVALID_PARAMETER_MIN:function(e){var t=e.key,n=e.rule;e.fnName;var r=e.value;return"the min value of ".concat(t||n.name," is ").concat(n.min,", received: ").concat(r,".")},INVALID_PARAMETER_MAX:function(e){var t=e.key,n=e.rule;e.fnName;var r=e.value;return"the max value of ".concat(t||n.name," is ").concat(n.max,", 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/audience, please call switchRole("anchor") firstly before publish().',INVALID_INITIALIZE:"cannot publish stream because stream is not initialized, is switching device, or has been closed.",INVALID_DUPLICATE_PUBLISHING: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.userId,r=e.streamType;return"failed to subscribe ".concat(n," ").concat(r," 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 anchor or audience.",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 ".concat(e.message,".")},INVALID_OPERATION_START_PUBLISH_CDN:"please call startPublishCDNStream() after join room and publish the local stream.",INVALID_OPERATION_STOP_PUBLISH_CDN:"please call startPublishCDNStream() before stopPublishCDNStream().",START_PUBLISH_CDN_FAILED: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_TRACK:"localStream has not this track.",INVALID_REMOVE_TRACK_NUMBER:"remove the only video track is not supported, please use replaceTrack or muteVideo.",INVALID_REPLACE_TRACK_NO_TRACK:function(e){return"cannot replace ".concat(e.kind," track because stream has not ").concat(e.kind," track")},NOT_BUG_PACKAGE:"You need to buy packages, refer to tencent console.",START_MIX_TRANSCODE_FAILED: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 HTMLElement when calling ").concat(n,"(), received: ").concat(r,".")},PLAY_FAILED:function(e){return"".concat(e.media," play failed, browser exception: ").concat(e.error.toString())},INVALID_USERID:"userId cannot be all spaces.",INVALID_CREATE_STREAM_SOURCE:"LocalStream must be created by createStream() with either audio/video or audioSource/videoSource, but can not be mixed with audio/video and audioSource/videoSource.",INVALID_CREATE_STREAM_SCREEN:"screen/video cannot be both true.",INVALID_CREATE_STREAM_AUDIO:"audio/screenAudio cannot be both true.",INVALID_CREATE_STREAM_SCREEN_AUDIO:"when screen is true, screenAudio can be configured.",NOT_SUPPORTED_HTTP:"http protocol does not support the ability to capture microphone, camera and screen. please use https to deploy your page.",NOT_SUPPORTED_WEBRTC:"your browser or environment does not support full WebRTC capabilities.",NOT_SUPPORTED_PROFILE:"your browser does not support setVideoProfile.",NOT_SUPPORTED_MEDIA:"your browser or environment does not support navigator.mediaDevices.",NOT_SUPPORTED_H264ENCODE:"your device does not support H.264 encoding.",NOT_SUPPORTED_H264DECODE:"your device does not support H.264 decoding.",NOT_SUPPORTED_TRACK: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.",CAMERA_NOT_FOUND:"no camera detected, please check your camera.",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 in ".concat(t,".on('").concat(n,"', handler), please check your code in 'handler'.")},API_NOT_EXIST:function(e){var t=e.name;return"experimental api ".concat(t," does not exist.")},REPEAT_JOIN:function(e){return"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(!1===e?" without using h264 codec":"")},SEI_DISABLED:"SEI is disabled",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?"".concat(i," bytes"):r," in a second.")},CONNECTION_ABORTED:function(e){return"connection aborted due to: ".concat(e)},API_CALL_ABORTED:function(e){return e.message.includes("REMOTE_STREAM_NOT_EXIST")?"Subscribe ".concat(e.userId," ").concat(e.streamType," stream aborted, reason: remote user ").concat(e.userId," unpublished stream."):"API aborted, reason: ".concat(e.message)},DUPLICATE_AUX:"only one auxiliary stream can be published in a room.",NOT_SUPPORTED_AUX:"publish auxiliary stream is not supported on your browser.",INVALID_PARAMETER_STREAMTYPE:function(e){return"'streamType' is required when 'userId' is not '*', calling ".concat(e,"()")}},fO=function(e,t){return t?"".concat(BR,"/").concat(e,"/").concat(t):"".concat(BR,"/").concat(e,"/index.html")},pO=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 e=null==localStorage?void 0:localStorage.getItem(JR);if(e){e=JSON.parse(e);var t=document.createElement("script");t.type="text/javascript",t.text=e.message,document.body.appendChild(t);var n=window.TRTC_ERROR_INFO,r=window.TRTC_ERROR_LINK;return document.body.removeChild(t),{TRTC_ERROR_INFO:n,TRTC_ERROR_LINK:r}}return{}};function mO(e){var t=e.key,n=e.data,r=e.link,i=e.addDocLink,a=void 0===i||i,o="",s="",c="";Sw(hO[t])?o=hO[t](n):bw(hO[t])&&(o=hO[t]);var u=pO(),l=u.TRTC_ERROR_INFO,d=u.TRTC_ERROR_LINK;r?c="".concat(r.className,".html#").concat(r.fnName):d&&d[t]&&(Sw(d[t])?c=d[t](n):bw(d[t])&&(c=d[t]));var h=o;return gw()&&(l&&l[t]&&(Sw(l[t])?s=l[t](n):bw(l[t])&&(s=l[t])),s&&(h=a?"".concat(s,"\n请查看文档: ").concat(fO("zh-cn",c),"\n\n"):"".concat(s,"\n\n"),h+=o)),a&&(h+=" \nRefer to: ".concat(fO("en",c),"\n")),h}var vO,_O=tR(lR(),1),gO=function(){return o((function e(){var t=this;r(this,e);var n=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];rR(this,"countMap",new Map),rR(this,"distributionMap",new Map),rR(this,"version"),rR(this,"log",sx.createLogger({id:"kv"})),n&&(rx.on("102",(function(e){var n=e.track,r=e.cost;t.addSuccessEvent({key:n.kind===nC.AUDIO?501700:511700,cost:r})})),rx.on("103",(function(e){var n=e.track,r=e.error;t.addFailedEvent({key:n.kind===nC.AUDIO?501700:511700,error:r})})))}),[{key:"getReportData",value:function(){var e={msg_sdk_basic_info:{uint32_sdk_version:tD(this.version||RR),uint32_terminal_type:15,bytes_device_name:"",bytes_os_version:"",uint32_framework:30,uint32_network_type:0},stats_count:E(this.countMap.entries()).map((function(e){var t=v(e,2);return{uint32_key:t[0],uint32_count:t[1]}})),stats_distribution:E(this.distributionMap.entries()).map((function(e){var t=v(e,2);return{uint32_key:t[0],distribution_items:E(t[1].entries()).map((function(e){var t=v(e,2);return{uint32_item_key:t[0],uint32_item_value:t[1]}}))}}))};return this.countMap.clear(),this.distributionMap.clear(),e}},{key:"clear",value:function(){this.countMap.clear(),this.distributionMap.clear()}},{key:"isEnumKey",value:function(e){var t=+String(e).slice(-3);return t>=700&&t<799}},{key:"isErrorCodeKey",value:function(e){var t=+String(e).slice(-3);return t>=600&&t<699}},{key:"isCountKey",value:function(e){var t=+String(e).slice(-3);return t>=0&&t<599}},{key:"isNumberKey",value:function(e){var t=+String(e).slice(-3);return t>=800&&t<899}},{key:"addCount",value:function(e){var t=e.key,n=e.useUV,r=void 0!==n&&n;this.isCountKey(t)?r&&this.countMap.has(t)||this.countMap.set(t,(this.countMap.get(t)||0)+1):this.log.debug("".concat(t," is not count key, last 3 number should be 0~599"))}},{key:"addEnum",value:function(e){var t,n=e.key,r=e.value,i=e.useUV,a=void 0===i||i;if(!this.isEnumKey(n))return this.log.debug("".concat(n," is not enum key, last 3 number should be 700~799"));if(!a||!this.countMap.has(n)){this.countMap.set(n,(this.countMap.get(n)||0)+1);var o=(null==(t=this.distributionMap)?void 0:t.get(n))||new Map;o.set(r,(o.get(r)||0)+1),this.distributionMap.set(n,o)}}},{key:"addNumber",value:function(e){var t,n=e.key,r=e.value,i=e.split,a=void 0===i?100:i,o=e.useUV,s=void 0!==o&&o;if(!this.isNumberKey(n))return this.log.debug("".concat(n," is not number key, last 3 number should be 800~899"));if(!s||!this.countMap.has(n)){this.countMap.set(n,(this.countMap.get(n)||0)+1);var c=(null==(t=this.distributionMap)?void 0:t.get(n))||new Map,u=0;if(Aw(a))u=Math.floor(r/a);else for(var l=a.length-1;l>0;l--)if(r>a[l]){u=l;break}c.set(u,(c.get(u)||0)+1),this.distributionMap.set(n,c)}}},{key:"addSuccessEvent",value:function(e){var t=e.key,n=e.cost,r=e.timeKey,i=e.split;if(t&&(this.addEnum({key:t,value:1,useUV:!1}),n)){var a=+String(t).slice(-3);a<800&&a>=700?this.addNumber({key:r||t+100,value:n,split:i}):r||this.log.debug("time stat ignored, ".concat(t))}}},{key:"addFailedEvent",value:function(e){var t=e.key,n=e.error;if(t){var r=_R.UNKNOWN;n&&(Aw(n)?r=n:(!Iw(n.extraCode)||!Iw(n.code))&&(r=n.extraCode||n.code)),this.addEnum({key:t,value:0,useUV:!1}),this.addEnum({key:t,value:Math.abs(r),useUV:!1})}}}])}(),yO=((vO=yO||{})[vO.enterRoom=500700]="enterRoom",vO[vO.exitRoom=500701]="exitRoom",vO[vO.switchRole=500702]="switchRole",vO[vO.destroy=500703]="destroy",vO[vO.startLocalAudio=500704]="startLocalAudio",vO[vO.updateLocalAudio=500705]="updateLocalAudio",vO[vO.stopLocalAudio=500706]="stopLocalAudio",vO[vO.startLocalVideo=500707]="startLocalVideo",vO[vO.updateLocalVideo=500708]="updateLocalVideo",vO[vO.stopLocalVideo=500709]="stopLocalVideo",vO[vO.startScreenShare=500710]="startScreenShare",vO[vO.updateScreenShare=500711]="updateScreenShare",vO[vO.stopScreenShare=500712]="stopScreenShare",vO[vO.startRemoteVideo=500713]="startRemoteVideo",vO[vO.updateRemoteVideo=500714]="updateRemoteVideo",vO[vO.stopRemoteVideo=500715]="stopRemoteVideo",vO[vO.muteRemoteAudio=500716]="muteRemoteAudio",vO[vO.setRemoteAudioVolume=500717]="setRemoteAudioVolume",vO[vO.use=500718]="use",vO[vO.sendSEIMessage=5e5]="sendSEIMessage",vO[vO.sendCustomMessage=500001]="sendCustomMessage",vO),EO=function(e){return e[e.AudioMixer=550700]="AudioMixer",e[e.AIDenoiser=551700]="AIDenoiser",e[e.VirtualBackground=570700]="VirtualBackground",e[e.Beauty=571700]="Beauty",e[e.Watermark=572700]="Watermark",e[e.BasicBeauty=574700]="BasicBeauty",e[e.CDNStreaming=590700]="CDNStreaming",e[e.DeviceDetector=591700]="DeviceDetector",e[e.Debug=592700]="Debug",e}(EO||{}),TO=function(e){return e[e.AudioMixer=550701]="AudioMixer",e[e.AIDenoiser=551701]="AIDenoiser",e[e.VirtualBackground=570701]="VirtualBackground",e[e.Beauty=571701]="Beauty",e[e.Watermark=572701]="Watermark",e[e.BasicBeauty=574701]="BasicBeauty",e[e.CDNStreaming=590701]="CDNStreaming",e[e.DeviceDetector=591701]="DeviceDetector",e[e.Debug=592701]="Debug",e}(TO||{}),kO=function(e){return e[e.AudioMixer=550702]="AudioMixer",e[e.AIDenoiser=551702]="AIDenoiser",e[e.VirtualBackground=570702]="VirtualBackground",e[e.Beauty=571702]="Beauty",e[e.Watermark=572702]="Watermark",e[e.BasicBeauty=574702]="BasicBeauty",e[e.CDNStreaming=590702]="CDNStreaming",e[e.DeviceDetector=591702]="DeviceDetector",e[e.Debug=592702]="Debug",e}(kO||{}),SO=new gO(!0),IO=new gO(!1),bO=SO,AO={result:!1,detail:{isBrowserSupported:!1,isWebRTCSupported:!1,isWebCodecsSupported:!1,isMediaDevicesSupported:!1,isScreenShareSupported:!1,isSmallStreamSupported:!1,isH264EncodeSupported:!1,isVp8EncodeSupported:!1,isH264DecodeSupported:!1,isVp8DecodeSupported:!1}},RO=new Map([[wD,["Firefox",DD]],[PD,["Edg",MD]],[CN,["Chrome",NN]],[xN,["Safari",PN]],[jD,["TBS",HD]],[GD,["XWEB",WD]],[YD&&kD,["WeChat",qD]],[ZD,["QQ(Win)",eN]],[QD,["QQ(Mobile)",$D]],[XD,["QQ(Mobile X5)",$D]],[tN,["QQ(Mac)",nN]],[rN,["QQ(iPad)",iN]],[hN,["MI",fN]],[pN,["HW",_N]],[gN,["Samsung",yN]],[EN,["OPPO",TN]],[kN,["VIVO",SN]],[xD,["EDGE",OD]],[VD,["SogouMobile",UD]],[FD,["Sogou",BD]]]);function CO(){var e=RO.get(!0);return{browserName:e?e[0]:"unknown",browserVersion:e?e[1]:"unknown"}}var wO=function(){return!(lN||xD||PD&&LD<80||wD&&ND<56)},DO=function(){return["VideoDecoder","VideoEncoder","AudioEncoder","AudioDecoder","MediaStreamTrackGenerator"].every((function(e){return e in window}))},NO=function(){if(!navigator.mediaDevices)return OO()||sx.error(hO.NOT_SUPPORTED_MEDIA),!1;var e=["getUserMedia","enumerateDevices"];return e.filter((function(e){return e in navigator.mediaDevices})).length===e.length},xO=!1;function OO(){return"http:"===location.protocol&&!jN&&(xO||sx.error(mO({key:dO.NOT_SUPPORTED_HTTP})),xO=!0,!0)}var PO=function(){return(null==window?void 0:window.OffscreenCanvas)&&(null==window?void 0:window.MediaStreamTrackProcessor)&&(null==window?void 0:window.MediaStreamTrackGenerator)},MO=function(){return aR(this,null,f().mark((function e(){var t,n,r,i,a,o;return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!AO.detail.isH264EncodeSupported||!AO.detail.isVp8EncodeSupported){e.next=2;break}return e.abrupt("return",{isH264EncodeSupported:AO.detail.isH264EncodeSupported,isVp8EncodeSupported:AO.detail.isVp8EncodeSupported});case 2:return n=!1,r=!1,e.prev=3,i=new RTCPeerConnection,(a=document.createElement(nC.CANVAS)).getContext("2d"),o=a.captureStream(0),i.addTrack(o.getVideoTracks()[0],o),e.next=10,i.createOffer();case 10:return-1!==(t=e.sent).sdp.toLowerCase().indexOf("h264")&&(n=!0),-1!==t.sdp.toLowerCase().indexOf("vp8")&&(r=!0),i.close(),AO.detail.isH264EncodeSupported=n,AO.detail.isVp8EncodeSupported=r,e.abrupt("return",{isH264EncodeSupported:AO.detail.isH264EncodeSupported,isVp8EncodeSupported:AO.detail.isVp8EncodeSupported});case 19:return e.prev=19,e.t0=e.catch(3),e.abrupt("return",{isH264EncodeSupported:!1,isVp8EncodeSupported:!1});case 22:case"end":return e.stop()}}),e,null,[[3,19]])})))},LO=function(){return aR(this,null,f().mark((function e(){var t,n,r,i;return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!AO.detail.isH264DecodeSupported||!AO.detail.isVp8DecodeSupported){e.next=2;break}return e.abrupt("return",{isH264DecodeSupported:AO.detail.isH264DecodeSupported,isVp8DecodeSupported:AO.detail.isVp8DecodeSupported});case 2:return n=!1,r=!1,e.prev=3,i=new RTCPeerConnection,e.next=7,i.createOffer({offerToReceiveAudio:!0,offerToReceiveVideo:!0});case 7:return-1!==(t=e.sent).sdp.toLowerCase().indexOf("h264")&&(n=!0),-1!==t.sdp.toLowerCase().indexOf("vp8")&&(r=!0),i.close(),e.abrupt("return",{isH264DecodeSupported:n,isVp8DecodeSupported:r});case 14:return e.prev=14,e.t0=e.catch(3),e.abrupt("return",{isH264DecodeSupported:!1,isVp8DecodeSupported:!1});case 17:case"end":return e.stop()}}),e,null,[[3,14]])})))},VO=iD((function(){return aR(void 0,null,f().mark((function e(){var t,n,r,i,a,o,s,c,u,l,d,h,p,m,_;return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(AO.result&&AO.detail.isH264EncodeSupported&&AO.detail.isVp8EncodeSupported&&AO.detail.isH264DecodeSupported&&AO.detail.isVp8DecodeSupported)){e.next=2;break}return e.abrupt("return",AO);case 2:return t=Date.now(),n=wO(),r=lP(),i=DO(),a=NO(),e.next=9,MO();case 9:return o=e.sent,s=o.isH264EncodeSupported,c=o.isVp8EncodeSupported,e.next=14,LO();case 14:if(u=e.sent,l=u.isH264DecodeSupported,d=u.isVp8DecodeSupported,s&&c){e.next=22;break}return e.next=20,MO();case 20:h=e.sent,sx.warn("detect encode again h264:".concat(s," vp8:").concat(c," result: ").concat(JSON.stringify(h))),s=h.isH264EncodeSupported,c=h.isVp8EncodeSupported;case 22:if(!(s&&l&&bD&&RN)||GD||jD){e.next=29;break}return e.next=25,function(){return aR(this,null,f().mark((function e(){var t=this;return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",BO||(BO=new Promise((function(e){return aR(t,null,f().mark((function t(){var n,r,i,a,o,s,c,u,l,d,h,p,m,_,g=this;return f().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n={encode:!1,decode:!1},r=function(){},t.prev=1,i=document.createElement("canvas"),a=i.getContext("2d"),i.width=320,i.height=240,o=setInterval((function(){a.fillText("test",Math.floor(320*Math.random()),Math.floor(240*Math.random()))}),66),s=-1,c=-1,r=function(){clearInterval(s),clearInterval(o),clearTimeout(c),l.close(),d.close(),u.getTracks().forEach((function(e){return e.stop()}))},c=setTimeout((function(){r(),e(n)}),2e3),u=i.captureStream(),l=new RTCPeerConnection({}),d=new RTCPeerConnection({offerToReceiveAudio:!0,offerToReceiveVideo:!0}),l.addEventListener("icecandidate",(function(e){return d.addIceCandidate(e.candidate)})),d.addEventListener("icecandidate",(function(e){return l.addIceCandidate(e.candidate)})),l.addTrack(u.getVideoTracks()[0],u),t.next=10,l.createOffer();case 10:return h=t.sent,t.next=13,l.setLocalDescription(h);case 13:return t.next=15,d.setRemoteDescription(h);case 15:return t.next=17,d.createAnswer();case 17:return p=t.sent,m=_O.default.parse(p.sdp),_=m.media[0].rtp.findIndex((function(e){return"H264"===e.codec})),m.media[0].rtp=[m.media[0].rtp[_]],m.media[0].fmtp=m.media[0].fmtp.filter((function(e){return e.payload===m.media[0].rtp[0].payload})),m.media[0].rtcpFb&&(m.media[0].rtcpFb=m.media[0].rtcpFb.filter((function(e){return e.payload===m.media[0].rtp[0].payload}))),p.sdp=_O.default.write(m),t.next=26,d.setLocalDescription(p);case 26:return t.next=28,l.setRemoteDescription(p);case 28:s=setInterval((function(){return aR(g,null,f().mark((function t(){var i,a,o,s;return f().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n.encode&&n.decode&&(r(),e(n)),t.next=3,Promise.all([l.getSenders()[0].getStats(),d.getReceivers()[0].getStats()]);case 3:i=t.sent,a=v(i,2),o=a[0],s=a[1],n.encode||o.forEach((function(e){"outbound-rtp"===e.type&&e.mediaType===nC.VIDEO&&e.bytesSent>0&&(n.encode=!0)})),n.decode||s.forEach((function(e){"inbound-rtp"===e.type&&e.mediaType===nC.VIDEO&&e.bytesReceived>0&&(n.decode=!0)}));case 8:case"end":return t.stop()}}),t)})))}),100),t.next=34;break;case 31:t.prev=31,t.t0=t.catch(1),r(),sx.warn("detectH264Supported failed",t.t0),e({encode:!0,decode:!0});case 34:case"end":return t.stop()}}),t,null,[[1,31]])})))})).then((function(e){return e.encode||(e.decode=!0),(!e.encode||!e.decode)&&sx.warn("detectH264Supported encode: ".concat(e.encode," decode: ").concat(e.decode," ").concat(zN)),e})),BO));case 1:case"end":return e.stop()}}),e)})))}();case 25:p=e.sent,m=p.encode,_=p.decode,s=m,l=_;case 29:return e.abrupt("return",(AO.result=n&&r&&a&&(s||c)&&(l||d),AO.detail.isBrowserSupported=n,AO.detail.isWebRTCSupported=r,AO.detail.isWebCodecsSupported=i,AO.detail.isMediaDevicesSupported=a,AO.detail.isScreenShareSupported=FO(),AO.detail.isSmallStreamSupported=zO(),AO.detail.isH264EncodeSupported=s,AO.detail.isVp8EncodeSupported=c,AO.detail.isH264DecodeSupported=l,AO.detail.isVp8DecodeSupported=d,AO.result||sx.error("".concat(navigator.userAgent," ").concat(Qw(AO.detail,!1))),ux.setItem(vP,{ua:navigator.userAgent,checkResult:AO}),bO.addNumber({key:523800,value:Date.now()-t}),AO));case 30:case"end":return e.stop()}}),e)})))})),UO=function(){return AO.result},FO=function(){return!(!navigator.mediaDevices||!navigator.mediaDevices.getDisplayMedia)},BO=null,jO=function(e,t,n){"http:"===location.protocol&&!jN&&(e[t]=function(){throw new yR({code:_R.INVALID_OPERATION,message:hO.NOT_SUPPORTED_HTTP})})},HO=function(e){return!("candidate-pair"!==e.type||!e.nominated||"in-progress"!==e.state&&"succeeded"!==e.state||Rw(e.selected)&&!e.selected)};function GO(){var e="";if(screen.width){var t=screen.width?screen.width*window.devicePixelRatio:"",n=screen.height?screen.height*window.devicePixelRatio:"";e+="".concat(t," * ").concat(n)}return e}function WO(){return navigator.getUserMedia||navigator.mediaDevices&&navigator.mediaDevices.getUserMedia}function JO(){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 KO(){return"captureStream"in HTMLCanvasElement.prototype}function zO(){return!(YD||ID||DN&&DN<63||!wO()||!KO())}var YO=function(){if(Iw(window.RTCRtpTransceiver)||!("currentDirection"in RTCRtpTransceiver.prototype))return!1;var e=null,t=!1;try{(e=new RTCPeerConnection({sdpSemantics:LC})).addTransceiver(nC.AUDIO),t=!0}catch(wR){}return null==e||e.close(),t};function qO(){return"RTCPeerConnection"in window&&"getReceivers"in window.RTCPeerConnection.prototype}function XO(){return"RTCPeerConnection"in window&&"getSenders"in window.RTCPeerConnection.prototype}function QO(){return"RTCPeerConnection"in window&&"getTransceivers"in window.RTCPeerConnection.prototype}function $O(){return 11!==VN&&"RTCPeerConnection"in window&&"addTransceiver"in window.RTCPeerConnection.prototype}var ZO=!(!$O()||RN&&DN<86);function eP(){return"RTCRtpTransceiver"in window&&"stop"in window.RTCRtpTransceiver.prototype}var tP="RTCRtpSender"in window;function nP(){return tP&&"replaceTrack"in window.RTCRtpSender.prototype}function rP(){return tP&&"setParameters"in window.RTCRtpSender.prototype&&XO()}var iP="RTCRtpReceiver"in window&&"getSynchronizationSources"in window.RTCRtpReceiver.prototype,aP=window.MediaStreamTrack&&"getSettings"in MediaStreamTrack.prototype,oP=window.MediaStreamTrack&&"getCapabilities"in MediaStreamTrack.prototype,sP=tP&&"createEncodedStreams"in window.RTCRtpSender.prototype&&AN()>=86,cP="RTCRtpScriptTransform"in window,uP=tP&&(sP||cP),lP=function(){return["RTCPeerConnection","webkitRTCPeerConnection","RTCIceGatherer"].filter((function(e){return e in window})).length>0};function dP(){var e={AudioDecoder:!1,AudioEncoder:!1,VideoDecoder:!1,VideoEncoder:!1,ImageDecoder:!1};return Iw(window.AudioDecoder)||(e.AudioDecoder=!0),Iw(window.AudioEncoder)||(e.AudioEncoder=!0),Iw(window.VideoDecoder)||(e.VideoDecoder=!0),Iw(window.VideoEncoder)||(e.VideoEncoder=!0),Iw(window.ImageDecoder)||(e.ImageDecoder=!0),e}function hP(){return"mediaSession"in navigator&&!Iw(navigator.mediaSession.setActionHandler)}function fP(){return!Iw(window.WebTransport)}function pP(){return"undefined"!=typeof WebAssembly&&WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,5,1,96,0,1,123,3,2,1,0,10,10,1,8,0,65,0,253,15,253,98,11]))}function mP(){var e={browser:"".concat(GN.name,"/").concat(GN.version),os:QN(),displayResolution:GO(),isScreenShareSupported:FO(),isWebRTCSupported:lP(),isGetUserMediaSupported:WO(),isWebAudioSupported:JO(),isWebSocketsSupported:"WebSocket"in window&&2===window.WebSocket.CLOSING,isWebCodecSupported:dP(),isMediaSessionSupported:hP(),isWebTransportSupported:fP()};return navigator.userAgent.includes("miniProgram")&&(e.browser="mini/".concat(e.browser)),e}var vP="checkResult";function _P(){OO();var e=ux.getItem(vP);e&&e.ua===navigator.userAgent&&(AO=e.checkResult),VO()}function gP(){return"requestVideoFrameCallback"in HTMLVideoElement.prototype}var yP="RTCRtpReceiver"in window&&"jitterBufferTarget"in window.RTCRtpReceiver.prototype,EP=tR(oR(),1),TP=Symbol("instance"),kP=Symbol("cacheResult"),SP=function(){return o((function e(t,n,i){r(this,e),this.oldState=t,this.newState=n,this.action=i,this.aborted=!1}),[{key:"abort",value:function(e){this.aborted=!0,CP.call(e,this.oldState,new Error("action '".concat(this.action,"' aborted")))}},{key:"toString",value:function(){return"".concat(this.action,"ing")}}])}(),IP=function(e){function t(e,i,a){var o;return r(this,t),(o=n(this,t,[i])).state=e,o.message=i,o.cause=a,o}return d(t,e),o(t)}(I(Error)),bP=new Map;function AP(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return function(r,i,a){var o=n.action||i;if(!n.context){var s=bP.get(r)||[];bP.has(r)||bP.set(r,s),s.push({from:e,to:t,action:o})}var c=a.value;a.value=function(){for(var r,i=this,a=this,s=arguments.length,u=new Array(s),l=0;l<s;l++)u[l]=arguments[l];if(n.context&&(a=wP.get("function"==typeof n.context?(r=n.context).call.apply(r,[this].concat(u)):n.context)),a.state===t)return n.sync?a[kP]:Promise.resolve(a[kP]);a.state instanceof SP&&a.state.action==n.abortAction&&a.state.abort(a);var d=null;Array.isArray(e)?0==e.length?a.state instanceof SP&&a.state.abort(a):("string"!=typeof a.state||!e.includes(a.state))&&(d=new IP(a._state,"".concat(a.name," ").concat(o," to ").concat(t," failed: current state ").concat(a._state," not from ").concat(e.join("|")))):e!==a.state&&(d=new IP(a._state,"".concat(a.name," ").concat(o," to ").concat(t," failed: current state ").concat(a._state," not from ").concat(e)));var h=function(e){if(n.fail&&n.fail.call(i,e),n.sync){if(n.ignoreError)return e;throw e}return n.ignoreError?Promise.resolve(e):Promise.reject(e)};if(d)return h(d);var f=a.state,p=new SP(f,t,o);CP.call(a,p);var m=function(e){var r;return a[kP]=e,p.aborted||(CP.call(a,t),null===(r=n.success)||void 0===r||r.call(i,a[kP])),e},v=function(e){return CP.call(a,f,e),h(e)};try{var _=c.apply(this,u);return function(e){return"object"==k(e)&&e&&"then"in e}(_)?_.then(m).catch(v):n.sync?m(_):Promise.resolve(m(_))}catch(Ex){return v(new IP(a._state,"".concat(a.name," ").concat(o," from ").concat(e," to ").concat(t," failed: ").concat(Ex),Ex instanceof Error?Ex:new Error(String(Ex))))}}}}var RP="undefined"!=typeof window&&window.__AFSM__?function(e,t){window.dispatchEvent(new CustomEvent(e,{detail:t}))}:"undefined"!=typeof importScripts?function(e,t){postMessage({type:e,payload:t})}:function(){};function CP(e,t){var n=this._state;this._state=e;var r=e.toString();e&&this.emit(r,n),this.emit(wP.STATECHANGED,e,n,t),this.updateDevTools({value:e,old:n,err:t instanceof Error?t.message:String(t)})}var wP=function(e){function i(e,a,o){var s;r(this,i),(s=n(this,i)).name=e,s.groupName=a,s._state=i.INIT,e||(e=Date.now().toString(36)),o?Object.setPrototypeOf(t(s),o):o=Object.getPrototypeOf(t(s)),a||(s.groupName=s.constructor.name);var c=o[TP];return c?s.name=c.name+"-"+c.count++:o[TP]={name:s.name,count:0},s.updateDevTools({diagram:s.stateDiagram}),s}return d(i,e),o(i,[{key:"stateDiagram",get:function(){var e=Object.getPrototypeOf(this),t=bP.get(e)||[],n=new Set,r=[],i=[],a=new Set,o=Object.getPrototypeOf(e);bP.has(o)&&(o.stateDiagram.forEach((function(e){return n.add(e)})),o.allStates.forEach((function(e){return a.add(e)}))),t.forEach((function(e){var t=e.from,n=e.to,a=e.action;"string"==typeof t?r.push({from:t,to:n,action:a}):t.length?t.forEach((function(e){r.push({from:e,to:n,action:a})})):i.push({to:n,action:a})})),r.forEach((function(e){var t=e.from,r=e.to,i=e.action;a.add(t),a.add(r),a.add(i+"ing"),n.add("".concat(t," --\x3e ").concat(i,"ing : ").concat(i)),n.add("".concat(i,"ing --\x3e ").concat(r," : ").concat(i," 🟢")),n.add("".concat(i,"ing --\x3e ").concat(t," : ").concat(i," 🔴"))})),i.forEach((function(e){var t=e.to,r=e.action;n.add("".concat(r,"ing --\x3e ").concat(t," : ").concat(r," 🟢")),a.forEach((function(e){e!==t&&n.add("".concat(e," --\x3e ").concat(r,"ing : ").concat(r))}))}));var s=E(n);return Object.defineProperties(e,{stateDiagram:{value:s},allStates:{value:a}}),s}},{key:"updateDevTools",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};RP(i.UPDATEAFSM,Object.assign({name:this.name,group:this.groupName},e))}},{key:"state",get:function(){return this._state},set:function(e){CP.call(this,e)}}],[{key:"get",value:function(e){var t;return"string"==typeof e?(t=i.instances.get(e))||i.instances.set(e,t=new i(e,void 0,Object.create(i.prototype))):(t=i.instances2.get(e))||i.instances2.set(e,t=new i(e.constructor.name,void 0,Object.create(i.prototype))),t}},{key:"getState",value:function(e){var t;return null===(t=i.get(e))||void 0===t?void 0:t.state}}])}(EP.default);wP.STATECHANGED="stateChanged",wP.UPDATEAFSM="updateAFSM",wP.INIT="[*]",wP.ON="on",wP.OFF="off",wP.instances=new Map,wP.instances2=new WeakMap;var DP="undefined"!=typeof window,NP=DP&&window.requestIdleCallback||function(e){var t=Date.now();return setTimeout((function(){e({didTimeout:!1,timeRemaining:function(){return Math.max(0,50-(Date.now()-t))}})}),1e3)},xP=DP&&window.cancelIdleCallback||function(e){clearTimeout(e)},OP=DP&&(window.cancelAnimationFrame||window.mozCancelAnimationFrame),PP=function(){function e(){r(this,e)}return o(e,null,[{key:"generateTaskID",value:function(){return this.currentTaskID++}},{key:"run",value:function(e,t,n){null!=n&&n.fps&&(n.delay=n.delay||Number((1e3/n.fps).toFixed(2))),n=QA("interval"===e?{delay:2e3,count:0,backgroundTask:!0}:"ric"===e?{delay:1e4,count:0}:"raf"===e?{fps:60,delay:16.6,count:0,backgroundTask:!0}:{delay:2e3,count:0,backgroundTask:!0},n);var r=$A(QA({taskID:this.generateTaskID(),loopCount:0,intervalID:null,timeoutID:null,rafID:null,ricID:null,taskName:e,callback:t},n),{delay:n.delay});return this.taskMap.set(r.taskID,r),this[e](r),r.taskID}},{key:"interval",value:function(t){return t.intervalID=setInterval((function(){t.callback(),t.loopCount+=1,e.isBreakLoop(t)}),t.delay)}},{key:"intervalInWorker",value:function(t){e.sharedWorker||(e.sharedWorker=new Worker(URL.createObjectURL(new Blob(["\n const timers = new Map();\n self.onmessage = function(e) {\n const { taskId, delay, type } = e.data;\n if (type === 'start') {\n timers.set(taskId, setInterval(() => {\n self.postMessage({ type: 'tick', taskId });\n }, delay));\n } else if (type === 'stop') {\n clearInterval(timers.get(taskId));\n timers.delete(taskId);\n }\n };\n "],{type:"application/javascript"}))),e.sharedWorker.onmessage=function(t){var n;if("tick"===t.data.type){var r=e.workerTasks.get(t.data.taskId);r&&(r.callback(),r.loopCount+=1,e.isBreakLoop(r)&&(null==(n=e.sharedWorker)||n.postMessage({type:"stop",taskId:r.taskID}),e.workerTasks.delete(r.taskID)))}}),e.workerTasks.set(t.taskID,t),e.sharedWorker.postMessage({taskId:t.taskID,delay:t.delay,type:"start"})}},{key:"timeout",value:function(t){var n=function(){if(t.callback(),t.loopCount+=1,!e.isBreakLoop(t))return t.timeoutID=setTimeout(n,t.delay)};return t.timeoutID=setTimeout(n,t.delay)}},{key:"ric",value:function(t){var n,r=Vw(),i=function(){if((n=Vw()-r)>=t.delay&&(r=Vw()-Math.floor(n%t.delay),t.callback(),t.loopCount+=1),!e.isBreakLoop(t))return t.ricID=NP(i,{timeout:t.delay})};return t.ricID=NP(i,{timeout:t.delay})}},{key:"raf",value:function(t){var n,r=Vw(),i=function(){return document.hidden&&t.backgroundTask?(n=Vw()-r,r=Vw(),t.callback(),t.loopCount+=1,e.isBreakLoop(t)?void 0:t.timeoutID=setTimeout(i,t.delay-Math.floor(n%t.delay))):((n=Vw()-r)>=t.delay&&(r=Vw()-Math.floor(n%t.delay),t.callback(),t.loopCount+=1),e.isBreakLoop(t)?void 0:t.rafID=requestAnimationFrame(i))};if(t.rafID=requestAnimationFrame(i),t.backgroundTask){var a=function(){if(document.hidden){var e=Vw()-r;e>=t.delay?i():t.timeoutID=setTimeout(i,t.delay-e)}};document.addEventListener("visibilitychange",a),t.onVisibilitychange=a,document.hidden&&a()}return t.taskID}},{key:"hasTask",value:function(e){return this.taskMap.has(e)}},{key:"clearTask",value:function(e){if(!this.taskMap.has(e))return!0;var t=this.taskMap.get(e),n=t.intervalID,r=t.timeoutID,i=t.rafID,a=t.ricID,o=t.onVisibilitychange,s=t.worker;return s&&s.terminate(),n&&clearInterval(n),r&&clearTimeout(r),i&&OP&&OP(i),a&&xP(a),o&&document.removeEventListener("visibilitychange",o),this.taskMap.delete(e),!0}},{key:"isBreakLoop",value:function(e){return!this.taskMap.has(e.taskID)||0!==e.count&&e.loopCount>=e.count&&(this.clearTask(e.taskID),!0)}}])}();rR(PP,"taskMap",new Map),rR(PP,"currentTaskID",1),rR(PP,"sharedWorker",null),rR(PP,"workerTasks",new Map);var MP=PP;nC.SEI_MESSAGE;var LP={LOADED_DATA:nC.LOADEDDATA,LOADED_META_DATA:nC.LOADEDMETADATA,MEDIA_TRACK_CHANGED:"media-track-changed",PLAYER_STATE_CHANGED:"player-state-changed",ERROR:"error"},VP={};eR(VP,{create:function(){return FP},remove:function(){return BP}});var UP=new WeakMap;function FP(e,t){UP.has(e)||UP.set(e,[]);var n=UP.get(e),r={add:function(e,i){return"addEventListener"in t?(n.push(t.removeEventListener.bind(t,e,i)),t.addEventListener(e,i)):(n.push(t.off.bind(t,e,i)),t.on(e,i)),r}};return r}function BP(e){var t=UP.get(e);t&&(t.forEach((function(e){return e()})),UP.delete(e))}var jP=new(function(){return o((function e(){r(this,e),rR(this,"_roomIdMap",new Map),rR(this,"_configs"),"undefined"==typeof registerProcessor&&(this._configs={sdkAppId:"",userId:"",version:RR,env:zR.QCLOUD,browserVersion:GN.name+GN.version,ua:navigator.userAgent})}),[{key:"setConfig",value:function(e){var t=e.sdkAppId,n=e.env,r=e.userId,i=e.roomId;t!==this._configs.sdkAppId&&(this._configs.sdkAppId=String(t)),this._configs.env=n,this._configs.userId=r,this._roomIdMap.set(r,String(i))}},{key:"logSuccessEvent",value:function(e){jN||!sx.isAbleToUpload||this._configs.env===zR.QCLOUD&&this.uploadEventToKibana($A(QA({},e),{result:"success"}))}},{key:"logFailedEvent",value:function(e){if(!jN&&sx.isAbleToUpload){var t=e.eventType,n=e.code,r=e.error,i=e.userId,a={roomId:this._roomIdMap.get(i||this._configs.userId),userId:i,eventType:t,result:"failed",code:n||(null==r?void 0:r.extraCode)||(null==r?void 0:r.code)||_R.UNKNOWN};this._configs.env===zR.QCLOUD&&this.uploadEventToKibana($A(QA({},a),{error:r}))}}},{key:"uploadEventToKibana",value:function(e){var t="stat-".concat(e.eventType,"-").concat(e.result);("delta-join"===e.eventType||"delta-leave"===e.eventType||"delta-publish"===e.eventType)&&(t="".concat(e.eventType,":").concat(e.delta)),this.uploadEvent({log:t,userId:e.userId}),"failed"===e.result&&(t="stat-".concat(e.eventType,"-").concat(e.result,"-").concat(e.code),this.uploadEvent({log:t,userId:e.userId,error:e.error}))}},{key:"uploadEvent",value:function(e){var t=e.log,n=e.userId,r=e.error,i={timestamp:kR(),sdkAppId:this._configs.sdkAppId,userId:n||this._configs.userId,version:RR,log:t};r&&(i.errorInfo=r.message,r.stack&&(i.errorInfo+="\n".concat(r.stack))),this.sendRequest(ow(this._configs.sdkAppId,KR.LOG),i)}},{key:"sendRequest",value:function(e,t){setTimeout((function(){return aD({url:e,body:JSON.stringify(t),priority:"low"}).catch((function(){}))}),2e3)}}])}()),HP=new WeakMap;function GP(e){var t=e.settings,n=void 0===t?{retries:5,timeout:2e3}:t,r=e.onError,i=e.onRetrying,a=e.onRetryFailed;return function(e,t,o){var s=dD({retryFunction:o.value,settings:n,onError:function(n){var i,a=n.error,o=n.retry,s=n.reject,c=n.retryFuncArgs;r?r.call(this,a,(function(){var n;null!=(n=HP.get(e))&&n.has(t)?o():s(a)}),s,c):null!=(i=HP.get(e))&&i.has(t)?o():s(a)},onRetrying:function(n,r){var a;cD(i)&&i.call(this,n,r),null!=(a=HP.get(e))&&a.has(t)&&(HP.get(e).get(t).stopRetry=r)},onRetryFailed:a});return o.value=function(){for(var n=HP.get(e),r=arguments.length,i=new Array(r),a=0;a<r;a++)i[a]=arguments[a];return n?n.set(t,{args:i}):HP.set(e,new Map([[t,{args:i}]])),s.apply(this,i).finally((function(){var n;return null==(n=HP.get(e))?void 0:n.delete(t)}))},o}}function WP(e){var t=e.fnName,n=e.callback,r=e.validateArgs,i=void 0===r||r;return function(e,r,a){var o=a.value;return a.value=function(){for(var r,a,c=arguments.length,u=new Array(c),l=0;l<c;l++)u[l]=arguments[l];if(null!=(r=HP.get(e))&&r.has(t)){var d=HP.get(e).get(t),h=d.stopRetry,f=d.args,p=!0;if(i){var m,v=s(f);try{var _=function(){var e=m.value;if(!u.find((function(t){return t===e})))return p=!1,1};for(v.s();!(m=v.n()).done&&!_(););}catch(g){v.e(g)}finally{v.f()}}p&&(n&&n.apply(this,u),h&&h(),null==(a=HP.get(e))||a.delete(t))}return o.apply(this,u)},a}}var JP=function(e){function i(e,a){var o;return r(this,i),(o=n(this,i,[e.id,"".concat(a,"-player")])).kind=a,rR(t(o),"id"),rR(t(o),"element",null),rR(t(o),"track"),rR(t(o),"url"),rR(t(o),"attr"),rR(t(o),"mode"),rR(t(o),"muted"),rR(t(o),"_log"),rR(t(o),"_pausedRetryCount"),rR(t(o),"_isElementPlayingFired",!1),rR(t(o),"_interval"),rR(t(o),"_delayDestroyTimeoutId",0),rR(t(o),"_playSuccessResolve"),rR(t(o),"_isReplayByRecreateMediaStreamCalled",!1),rR(t(o),"isInAutoPlayFailedState",!1),o.id=e.id,o._log=e.log,o.track=e.track,o.muted=e.muted,o._pausedRetryCount=YC,o._state="STOPPED",o.bindTrackEvents(),o._log.info("create ".concat(a,"-player ").concat(o.id)),o}return d(i,e),o(i,[{key:"isPlaying",get:function(){var e;return"PLAYING"===this._state&&(!1===(null==(e=this.element)?void 0:e.paused)||this.track&&"live"===this.track.readyState&&!this.track.muted)}},{key:"isStopped",get:function(){return"STOPPED"===this._state}},{key:"setAttr",value:function(e){this.attr=e}},{key:"setUrl",value:function(e){this.track&&(this.unbindTrackEvents(),this.element&&(this.element.srcObject=null),this.track=null),e!==this.url&&(this.url=e,null!==e&&this.element&&(this.element.crossOrigin="anonymous",this.element.src=e))}},{key:"play",value:function(){return aR(this,null,f().mark((function e(){var t,n=this;return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.isPlaying){e.next=13;break}return e.prev=1,this._delayDestroyTimeoutId&&(clearTimeout(this._delayDestroyTimeoutId),this._delayDestroyTimeoutId=0,this.bindTrackEvents(),this.bindElementEvents()),this.bindAutoPlayEvent(),e.next=6,new Promise((function(e,t){n._playSuccessResolve=e,n.element.play().then(e,t)}));case 6:e.next=13;break;case 8:if(e.prev=8,e.t0=e.catch(1),t=mO({key:dO.PLAY_FAILED,data:{media:this.kind,error:e.t0}}),this.track&&!this.track.muted&&this._log.warn(e.t0),!t.includes("NotAllowedError")){e.next=13;break}throw this.isInAutoPlayFailedState=!0,new yR({code:_R.PLAY_NOT_ALLOWED,message:t});case 13:case"end":return e.stop()}}),e,this,[[1,8]])})))}},{key:"stop",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;this._isElementPlayingFired=!1,this.unbindEvents(),t>0&&!ON?this._delayDestroyTimeoutId||(this._log.info("destroy element after 3 * ".concat(t)),this._delayDestroyTimeoutId=setTimeout((function(){return e.destroyElement()}),3*t)):this.destroyElement(),this.handleStopped(nC.ENDED),this._interval>0&&MP.clearTask(this._interval)}},{key:"destroyElement",value:function(){this.element&&(this._log.debug("destroy element"),this.element.remove(),this.element.srcObject=null,this.element=null),clearTimeout(this._delayDestroyTimeoutId),this._delayDestroyTimeoutId=0}},{key:"pause",value:function(){var e;this.isPlaying&&(null==(e=this.element)||e.pause())}},{key:"resume",value:function(){return this._log.info("resume"),this.isPlaying?Promise.resolve():FN?this.replay():this.play().catch((function(){}))}},{key:"setMuted",value:function(e){this.element&&(this.element.muted=e),this.muted=e}},{key:"replay",value:function(){return this.stop(),this.play().catch((function(){}))}},{key:"bindElementEvents",value:function(){if(this.element){var e=this.handleElementEvent.bind(this);return FP(this.element,this.element).add(nC.PLAYING,e).add(nC.ENDED,e).add(nC.PAUSE,e).add(nC.ERROR,e).add(nC.LOADEDDATA,e).add(nC.LOADEDMETADATA,e)}}},{key:"bindTrackEvents",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.track;if(e){var t=this.handleTrackEvent.bind(this);null==VP||VP.create(e,e).add(nC.ENDED,t).add(nC.MUTE,t).add(nC.UNMUTE,t),e.readyState===nC.ENDED&&this.handleTrackEvent({type:nC.ENDED}),e.muted&&this.handleTrackEvent({type:nC.MUTE})}}},{key:"bindAutoPlayEvent",value:function(){rx.on(ax.AUTOPLAY_DIALOG_CLICK_CONFIRM,this.resume,this)}},{key:"unbindTrackEvents",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.track;e&&BP(e)}},{key:"unbindEvents",value:function(){this.element&&BP(this.element),this.unbindTrackEvents(),rx.off(ax.AUTOPLAY_DIALOG_CLICK_CONFIRM,this.resume,this)}},{key:"handleElementEvent",value:function(e){var t=this;switch(e.type){case nC.PLAYING:this.isInAutoPlayFailedState=!1,this._isElementPlayingFired=!0,this._log.info("".concat(this.kind," player is playing")),this.handlePlaying(nC.PLAYING),this._interval&&(MP.clearTask(this._interval),this._interval=-1);break;case nC.ENDED:this._log.info("".concat(this.kind," player is ended")),this.handleStopped(nC.ENDED);break;case nC.PAUSE:this._log.info("".concat(this.kind," player is paused")),this.handlePaused(nC.PAUSE),ID&&(this._interval=MP.run("timeout",(function(){t.element&&"PAUSED"===t._state&&t.resume()}),{delay:3e3}));break;case nC.ERROR:if(this.element&&this.element.error){this.handlePaused(nC.ERROR);var n=this.element.error,r=n.code,i=n.message;this._log.error("".concat(this.kind," ").concat(this._log.isLocal?"local":"remote"," MediaError code: ").concat(r," message: ").concat(i," userAgent: ").concat(navigator.userAgent)),jP.uploadEvent({log:"stat-".concat(this.kind,"-").concat(xC.PLAYER_ERROR,"-").concat(r,"-").concat(navigator.userAgent),error:this.element.error}),vN||mN?this.emit(LP.ERROR,this.element.error):this.replayByRecreateMediaStream(this.element.error)}break;case nC.LOADEDDATA:this.kind===nC.VIDEO&&this.emit(LP.LOADED_DATA);break;case nC.LOADEDMETADATA:this.kind===nC.VIDEO&&this.emit(LP.LOADED_META_DATA)}}},{key:"replayByRecreateMediaStream",value:function(e){var t=this;if(!this._isReplayByRecreateMediaStreamCalled)return this._isReplayByRecreateMediaStreamCalled=!0,this.doReplayByRecreateMediaStream(1e3).then((function(){t._log.warn("replayByRecreateMediaStream success"),jP.uploadEvent({log:"stat-replayByRecreateMediaStream-success"}),bO.addSuccessEvent({key:t.kind===nC.AUDIO?506700:516700})})).catch((function(){var n;t._log.error("replayByRecreateMediaStream failed"),jP.uploadEvent({log:"stat-replayByRecreateMediaStream-failed"}),bO.addFailedEvent({key:t.kind===nC.AUDIO?506700:516700,error:null==(n=t.element)?void 0:n.error}),t.emit(LP.ERROR,e)}))}},{key:"doReplayByRecreateMediaStream",value:function(e){var t=this;return this._log.warn("delay ".concat(e,"ms to recreate mediaStream")),new Promise((function(n,r){rD(e).then((function(){t.element&&(t.element.srcObject=null,t.element.srcObject=new MediaStream([t.track]),t._log.warn("recreated mediaStream"),t.element.onerror=function(){var e,n,i;t._log.warn("element onerror ".concat(null==(n=null==(e=t.element)?void 0:e.error)?void 0:n.code," fired after recreated mediaStream")),r(null==(i=t.element)?void 0:i.error)}),rD(5e3).then((function(){var e,i;(!t.isPlaying||null!=(e=t.element)&&e.error)&&r(null==(i=t.element)?void 0:i.error),n()}))}))})).finally((function(){t.element&&(t.element.onerror=null)}))}},{key:"handleTrackEvent",value:function(e){switch(e.type){case nC.ENDED:this.handleStopped(nC.ENDED);break;case nC.MUTE:this.handlePaused(nC.MUTE);break;case nC.UNMUTE:this._isElementPlayingFired?this.handlePlaying(nC.UNMUTE):this.mode>0&&this.handlePlaying(this.mode.toString())}}},{key:"handlePlaying",value:function(e){var t;null==(t=this._playSuccessResolve)||t.call(this,e),this.emit(LP.PLAYER_STATE_CHANGED,{type:this.kind,state:"PLAYING",reason:e})}},{key:"handlePaused",value:function(e){this.emit(LP.PLAYER_STATE_CHANGED,{type:this.kind,state:"PAUSED",reason:e})}},{key:"handleStopped",value:function(e){this.emit(LP.PLAYER_STATE_CHANGED,{type:this.kind,state:"STOPPED",reason:e})}},{key:"getElement",value:function(){return this.element}}])}(wP);nR([GP({settings:{retries:2,timeout:0},onError:function(e,t,n,r){r[0]=(r[0]||1e3)+1e3,t()}})],JP.prototype,"doReplayByRecreateMediaStream",1),nR([AP([],"PLAYING",{sync:!0})],JP.prototype,"handlePlaying",1),nR([AP("PLAYING","PAUSED",{ignoreError:!0,sync:!0})],JP.prototype,"handlePaused",1),nR([AP([],"STOPPED",{sync:!0})],JP.prototype,"handleStopped",1);var KP,zP="trtc_autoplay",YP="".concat(zP,"_mask"),qP="".concat(zP,"_wrapper"),XP="".concat(zP,"_header"),QP="".concat(zP,"_content"),$P="".concat(zP,"_action_wrapper"),ZP="".concat(zP,"_question"),eM="".concat(zP,"_collapse"),tM="".concat(zP,"_action_confirm"),nM="".concat(zP,"_detail"),rM="#2473E8",iM="dialog",aM="".concat(iM,"-show"),oM="".concat(iM,"-1"),sM="".concat(iM,"-2"),cM=!1,uM=function(){return!!document.querySelector(".".concat(qP))},lM="".concat(BR,"/").concat(gw()?"zh-cn":"en","/tutorial-21-advanced-auto-play-policy.html"),dM="<br><a href='".concat(lM,"' target='_blank'>").concat(gw()?"其他方案?":"Any other solution?","</a>"),hM="".concat(gw()?"浏览器自动播放策略:在用户与页面产生交互(点击、触摸)之前,浏览器禁止播放有声媒体。该弹窗用于帮助用户恢复音视频播放。".concat(dM):"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(dM)),fM=function(){return o((function e(){if(r(this,e),rR(this,"content","音视频播放被浏览器拦截,请点击“恢复播放”。"),rR(this,"_dialogNode",null),rR(this,"_bodyPosition",""),rR(this,"_showDetail",!1),rR(this,"_isCollapseClicked",!1),rR(this,"_isQuestionClicked",!1),gw()||(this.content='Media playback failed. Click the "Resume" to resume playback.'),!cM){var t=document.createElement("style");t.innerHTML=".".concat(YP,"{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(YP," div:not(.").concat($P,"){display:block !important;}.").concat(qP,"{padding:14px;background:#fff;border-radius:3px;box-shadow:0px 3px 15px #434343;border:1px solid #d1cfcf;max-width:500px;}.").concat(qP," a{color:").concat(rM,";}.").concat(XP,"{overflow:hidden;text-overflow:ellipsis;font-size:16px;font-weight:600;}.").concat(QP,"{margin:8px 0;}.").concat($P,"{width:100%;display:flex !important;align-items:center;justify-content:right;float:right;}.").concat(eM,"{margin-right:auto;cursor:pointer}.").concat(ZP,"{height:100%;line-height:16px;cursor:pointer;}.").concat(tM,"{margin-left:8px;color:#fff;background:").concat(rM,";padding:4px 12px;outline:none;border:1px solid;border-radius:3px;font-weight:bold;}.").concat(tM,":hover{opacity:0.9;}.").concat(eM,",.").concat(tM,",.").concat(QP,",.").concat(ZP,"{font-size:14px;}@media screen and (max-width:750px){.").concat(qP,"{width:80vw;}}"),document.head.appendChild(t),cM=!0}this.addDiaLog()}),[{key:"createDiaLog",value:function(){var e=document.createElement("template");e.innerHTML='<div class="'.concat(YP,"\"><div class='").concat(qP,"'><div class='").concat(XP,"'>").concat(location.host,"</div><div class='").concat(QP,"'>").concat(this.content,"</div><div class='").concat(nM,'\' style="visibility:hidden;width:100%;height:0;font-size:12px;color:gray;">').concat(hM,"</div><div class='").concat($P,"'></div></div></div>").trim();var t=document.createElement("button");t.className=tM,t.innerText=gw()?"恢复播放":"Resume",t.onclick=this.onConfirm.bind(this);var n=document.createElement("div");n.className=ZP,n.innerHTML='<?xml version="1.0" encoding="UTF-8"?>\n <svg class="icon" width="18" height="18" p-id="2030" t="1639646523624" version="1.1" viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg">\n <path d="m464 784.35c0 26.51 21.49 48 48 48s48-21.49 48-48-21.49-48-48-48-48 21.49-48 48z" p-id="2031"/>\n <path d="m512 960c-247.04 0-448-200.96-448-448s200.96-448 448-448 448 200.96 448 448-200.96 448-448 448zm0-831.71c-211.58 0-383.71 172.13-383.71 383.71 0 211.55 172.13 383.71 383.71 383.71 211.55 0 383.71-172.16 383.71-383.71 0-211.58-172.16-383.71-383.71-383.71z" p-id="2032"/>\n <path d="m512 673.7c-17.665 0-32.001-14.336-32.001-31.999v-54.112c0-52.353 40-92.352 75.328-127.65 25.887-25.92 52.672-52.672 52.672-74.017 0-53.343-43.072-96.735-95.999-96.735-53.823 0-95.999 41.536-95.999 94.559 0 17.665-14.336 31.999-32.001 31.999s-32.001-14.336-32.001-31.999c0-87.424 71.775-158.56 160-158.56s160 72.095 160 160.74c0 47.904-36.32 84.192-71.424 119.3-27.84 27.776-56.576 56.512-56.576 82.336v54.112c0 17.665-14.336 32.032-32.001 32.032z" p-id="2033"/>\n </svg>\n ',n.onclick=this.onQuestionClick.bind(this);var r=document.createElement("div");r.className=eM,r.innerText="".concat(gw()?"详情 >":"Detail >"),r.onclick=this.onCollapseClick.bind(this);var i=e.content.firstChild,a=i.querySelector(".".concat($P));return a.appendChild(r),a.appendChild(n),a.appendChild(t),i}},{key:"addDiaLog",value:function(){uM()||(this._dialogNode=this.createDiaLog(),document.body.appendChild(this._dialogNode),this._dialogNode.onclick=this.onConfirm.bind(this),this._dialogNode.querySelector(".".concat(qP)).onclick=function(e){return e.stopPropagation()},this._bodyPosition=document.body.style.position,document.body.style.position="fixed",sx.info("show autoplay dialog"),jP.uploadEvent({log:aM}))}},{key:"deleteDiaLog",value:function(){this._dialogNode&&(document.body.removeChild(this._dialogNode),document.body.style.position=this._bodyPosition,this._dialogNode=null)}},{key:"onConfirm",value:function(){sx.warn("confirm clicked, try resume stream"),rx.emit(ax.AUTOPLAY_DIALOG_CLICK_CONFIRM),this.deleteDiaLog()}},{key:"onCollapseClick",value:function(){var e=this._dialogNode.querySelector(".".concat(nM));e.style.visibility="".concat(this._showDetail?"hidden":"visible"),e.style.height="".concat(this._showDetail?0:"fit-content"),this._showDetail=!this._showDetail,this._isCollapseClicked||jP.uploadEvent({log:oM}),this._isCollapseClicked=!0}},{key:"onQuestionClick",value:function(){window.open(lM,"_blank"),this._isQuestionClicked||jP.uploadEvent({log:sM}),this._isQuestionClicked=!0}}])}(),pM=function(e){function i(e){var a;return r(this,i),a=n(this,i,[e,nC.VIDEO]),rR(t(a),"stat",{}),rR(t(a),"_calculateTimeout",-1),rR(t(a),"viewMirror",!1),rR(t(a),"objectFit"),rR(t(a),"container"),rR(t(a),"canvas"),rR(t(a),"canvasTrack"),a.mode=e.canvas?1:0,a.container=e.container,a.canvas=e.canvas,Iw(e.viewMirror)||(a.viewMirror=e.viewMirror),Iw(e.objectFit)||(a.objectFit=e.objectFit),a.initializeElement(),a}return d(i,e),o(i,[{key:"initializeElement",value:function(){var e,t=document.createElement(nC.VIDEO);this.track&&2!==this.mode&&(t.srcObject=new MediaStream([this.track])),t.muted=!0,t.setAttribute("id","video_".concat(this.id)),t.setAttribute("style",this.styleAttribute),this.canvas&&this.canvas.setAttribute("style",this.styleAttribute),t.setAttribute("autoplay","autoplay"),t.setAttribute("playsinline","playsinline"),this.element=t,null==(e=this.container)||e.appendChild(this.elementToRender),this.bindElementEvents(),this.calculateStat()}},{key:"styleAttribute",get:function(){var e="width: 100%; height: 100%; object-fit: ".concat(this.objectFit,";background-color: black;");return this.viewMirror&&(e+="transform: scaleX(-1);"),e}},{key:"setContainer",value:function(e){var t;this.container=e,(this.track||this.canvasTrack)&&this.elementToRender&&(null==(t=this.container)||t.appendChild(this.elementToRender))}},{key:"bindElementEvents",value:function(){var e=g(i,"bindElementEvents",this,3)([]);this.handleElementEvent=this.handleElementEvent.bind(this),e&&e.add(nC.ENTER_PICTURE_IN_PICTURE,this.handleElementEvent).add(nC.LEAVE_PICTURE_IN_PICTURE,this.handleElementEvent)}},{key:"handleTrackEvent",value:function(e){var t;g(i,"handleTrackEvent",this,3)([e]),e.type===nC.MUTE&&null!=(t=this.stat)&&t.fps&&(this.stat.fps=0)}},{key:"handleElementEvent",value:function(e){var t;if(2!==this.mode){g(i,"handleElementEvent",this,3)([e]);var n=e.type;if(n===nC.PAUSE&&(this.container&&document.getElementById(this.container.id)||this._log.warn("".concat(this.kind," player has been remove, element ID: ").concat(null==(t=this.container)?void 0:t.id)),this._pausedRetryCount>0&&!uM()&&(this._log.info("".concat(this.kind," player auto resume when paused")),this.resume(),this._pausedRetryCount--),this.stat.fps&&(this.stat.fps=0)),this.viewMirror&&this.element){var r=this.element.style.transform;n===nC.ENTER_PICTURE_IN_PICTURE?this.element.style.transform=r.replace("scaleX(-1)",""):n===nC.LEAVE_PICTURE_IN_PICTURE&&!r.includes("scaleX")&&(this.element.style.transform="".concat(r," scaleX(-1)"))}}}},{key:"setCanvas",value:function(e){var t,n,r,i,a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;this.canvas!==e&&(null==(t=this.canvas)||t.remove(),null==e||e.setAttribute("style",this.styleAttribute),this.canvas=e,this.mode=e?a:0,2===this.mode&&this.setTrack(e.captureStream().getVideoTracks()[0]),e?(null==(n=this.element)||n.remove(),null==(r=this.container)||r.appendChild(e)):this.element&&(null==(i=this.container)||i.appendChild(this.element)))}},{key:"setAttr",value:function(e){var t=Object.assign({autoplay:"autoplay",playsinline:"playsinline",muted:!0},e);t.style=Object.assign({width:"100%",height:"100%"},t.style),g(i,"setAttr",this,3)([t])}},{key:"mirror",get:function(){return this.viewMirror}},{key:"setRect",value:function(e,t){this.elementToRender&&(this.elementToRender.style.width="".concat(e,"px"),this.elementToRender.style.height="".concat(t,"px"))}},{key:"setViewMirror",value:function(e){this.elementToRender&&(this.elementToRender.style.transform=e?"scaleX(-1)":""),this.viewMirror=e}},{key:"setObjectFit",value:function(e){this.elementToRender&&(this.elementToRender.style.objectFit="".concat(e)),this.objectFit=e}},{key:"setPoster",value:function(e){this.element&&(this.element.poster=e)}},{key:"stop",value:function(){var e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;g(i,"stop",this,3)([t]),null==(e=this.canvas)||e.remove()}},{key:"play",value:function(){return this.element?this.elementToRender&&this.elementToRender.parentElement!==this.container&&this.container&&this.container.append(this.elementToRender):this.initializeElement(),2===this.mode?Promise.resolve():g(i,"play",this,3)([])}},{key:"elementToRender",get:function(){return this.canvas||this.element}},{key:"setTrack",value:function(e){e!==this.track&&(this.unbindTrackEvents(),this.track=e,this.emit(LP.MEDIA_TRACK_CHANGED,e),null!==e&&(this.bindTrackEvents(),this.element&&2!==this.mode&&(this.element.srcObject=new MediaStream([e]),this.element.remove()),this.elementToRender&&this.elementToRender.parentElement!==this.container&&this.container&&this.container.append(this.elementToRender)))}},{key:"getVideoFrame",value:function(){if(this.canvas)return this.canvas.toDataURL("image/png");if(!this.element)return"";var e=document.createElement("canvas");return e.width=this.element.videoWidth,e.height=this.element.videoHeight,e.getContext("2d").drawImage(this.element,0,0),e.toDataURL("image/png")}},{key:"getElement",value:function(){return this.element}},{key:"calculateStat",value:function(){var e=this;try{if(gP()&&this.element&&this._calculateTimeout<0){var t=0,n=null,r=function(i,a){e.stat.width=a.width,e.stat.height=a.height,n&&(e.stat.fps=Math.round((a.presentedFrames-n.presentedFrames)/(i-t)*1e3)),t=i,n=a,e._calculateTimeout=-1,e.element&&(e._calculateTimeout=setTimeout((function(){var t;return null==(t=e.element)?void 0:t.requestVideoFrameCallback(r)}),2e3))};this.element.requestVideoFrameCallback(r)}}catch(wR){this._log.warn("init stat failed",wR)}}}])}(JP);function mM(e,t){return aR(this,null,f().mark((function n(){return f().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(e.audioWorklet){n.next=2;break}return n.abrupt("return",Promise.reject("audioWorklet is not supported"));case 2:return n.prev=2,n.next=5,e.audioWorklet.addModule(t);case 5:sx.info("worklet addModule success"),n.next=11;break;case 8:throw n.prev=8,n.t0=n.catch(2),sx.info("worklet addModule catch error. ".concat(n.t0.message)),n.t0;case 11:case"end":return n.stop()}}),n,null,[[2,8]])})))}"undefined"!=typeof AudioContext?KP=AudioContext:"undefined"!=typeof webkitAudioContext?KP=webkitAudioContext:"undefined"!=typeof mozAudioContext&&(KP=mozAudioContext);var vM,_M=-1;!function e(){try{if(vM)return;(vM=new KP({sampleRate:48e3})).onstatechange=function(){sx.info("context state: ".concat(vM.state).concat("running"!==vM.state?" visibilityState: ".concat(document.visibilityState):"")),gM()},clearTimeout(_M)}catch(t){sx.error("initAudioContext failed: ".concat(t," typeof AudioContextClass: ").concat(k(KP))),_M=setTimeout(e,1e3)}}();var gM=function(){"suspended"===vM.state?(TM(),document.addEventListener("click",gM)):"interrupted"===vM.state?TM():(document.removeEventListener("visibilitychange",gM),document.removeEventListener("click",gM))},yM=0,EM=-1;function TM(){return new Promise((function(e,t){if("running"===vM.state)return e();Date.now()-yM<1e3?(clearTimeout(EM),EM=setTimeout((function(){yM=Date.now(),vM.resume().then(e,t)}),1e3)):(clearTimeout(EM),yM=Date.now(),vM.resume().then(e,t))})).catch((function(e){sx.warn("context resume failed: ".concat(e)),document.addEventListener("visibilitychange",gM)}))}document.addEventListener("click",gM);var kM=function(e){return vM},SM=function(){return o((function e(){r(this,e),rR(this,"node"),rR(this,"node2"),rR(this,"pre",new Set),rR(this,"next",new Set),rR(this,"context"),rR(this,"connectedNodes",new Set)}),[{key:"setContext",value:function(e){this.context=e,this.node&&e.addMixWeight()}},{key:"removeContext",value:function(){var e;this.node&&(null==(e=this.context)||e.reduceMixWeight()),delete this.context}},{key:"replaceNode",value:function(e){var t;if(e!==this.node)try{this.node?this._disconnect():null==(t=this.context)||t.addMixWeight(),this.node=e,this.preNodeReconnect(),this.reconnect()}catch(DC){sx.error(DC)}}},{key:"setNode",value:function(e,t){var n;if(!this.node)try{null==(n=this.context)||n.addMixWeight(),this.node=e,t&&(this.node2=t),this.preNodeReconnect(),this.reconnect(),bO.addSuccessEvent({key:502701})}catch(vx){sx.error(vx),bO.addFailedEvent({key:502701,error:vx})}}},{key:"deleteNode",value:function(){var e;if(this.node)try{this._disconnect(),delete this.node,delete this.node2,null==(e=this.context)||e.reduceMixWeight(),this.preNodeReconnect(),bO.addSuccessEvent({key:502702})}catch(wR){sx.error(wR),bO.addFailedEvent({key:502702,error:wR})}}},{key:"preNodeReconnect",value:function(){this.pre.forEach((function(e){e.node?e.reconnect():e.preNodeReconnect()}))}},{key:"connectNext",value:function(e){this.next.forEach((function(t){e._connect(t.node)||t.connectNext(e)}))}},{key:"_connect",value:function(e){return!(!this.node||!e||((this.node2||this.node).connect(e),this.connectedNodes.add(e),0))}},{key:"_disconnect",value:function(){var e=this;this.connectedNodes.forEach((function(t){var n;return null==(n=e.node2||e.node)?void 0:n.disconnect(t)})),this.connectedNodes.clear()}},{key:"reconnect",value:function(){this._disconnect(),this.connectNext(this)}},{key:"pipeTo",value:function(){for(var e=this,t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return n.forEach((function(t){e.next.add(t),t.pre.add(e)})),this}}])}(),IM=function(e){function i(){var e;r(this,i);var a=arguments.length>0&&void 0!==arguments[0]?arguments[0]:256;return(e=n(this,i)).fftSize=a,rR(t(e),"dataArray",new Uint8Array(0)),e}return d(i,e),o(i,[{key:"setNode",value:function(e){e.fftSize=this.fftSize,this.dataArray=new Uint8Array(e.frequencyBinCount),g(i,"setNode",this,3)([e])}},{key:"getByteTimeDomainData",value:function(){var e;return null==(e=this.node)||e.getByteTimeDomainData(this.dataArray),this.dataArray}},{key:"level",get:function(){var e;return null==(e=this.node)||e.getByteTimeDomainData(this.dataArray),Math.max.apply(Math,E(this.dataArray))/128-1}},{key:"timeDomainPathData",get:function(){for(var e=this.getByteTimeDomainData(),t=0,n=0,r="M".concat(t,",").concat(n),i=0;i<e.length;i++)n=e[i]/128*100/2,r+="L".concat(t,",").concat(n),t+=1;return r}}])}(SM),bM=function(){return o((function e(){r(this,e),rR(this,"source",new SM),rR(this,"gain",new SM),rR(this,"destination",new SM)}),[{key:"volume",get:function(){var e;return(null==(e=this.gain.node)?void 0:e.gain.value)||1}},{key:"setVolume",value:function(e){1!==e?(this.gain.node||this.gain.setNode(kM().createGain()),this.gain.node.gain.value=e):this.gain.node&&this.gain.deleteNode()}},{key:"replaceSource",value:function(e){this.source.replaceNode(wM(e))}},{key:"track",get:function(){var e;return null==(e=this.stream)?void 0:e.getAudioTracks()[0]}},{key:"stream",get:function(){var e;return null==(e=this.destination.node)?void 0:e.stream}}])}(),AM=function(e){function i(e){var a;return r(this,i),(a=n(this,i)).context=e,rR(t(a),"denoiser",new SM),rR(t(a),"voiceChanger",new SM),a.source.pipeTo(a.denoiser.pipeTo(a.voiceChanger.pipeTo(a.gain.pipeTo(a.destination)))),a}return d(i,e),o(i,[{key:"connect",value:function(){this.context.inputs.has(this)||(this.destination.setNode(this.context.destination),this.source.setContext(this.context),this.denoiser.setContext(this.context),this.voiceChanger.setContext(this.context),this.gain.setContext(this.context),this.context.inputs.add(this))}},{key:"disconnect",value:function(){this.context.inputs.has(this)&&(this.destination.deleteNode(),this.source.removeContext(),this.denoiser.removeContext(),this.voiceChanger.removeContext(),this.gain.removeContext(),this.context.inputs.delete(this))}},{key:"remove",value:function(){this.gain.deleteNode(),this.denoiser.deleteNode(),this.voiceChanger.deleteNode(),this.source.deleteNode(),this.disconnect()}},{key:"setVolume",value:function(e){1!==e?(this.gain.node||this.gain.setNode(this.context.audioContext.createGain()),this.gain.node.gain.value=e):this.gain.node&&this.gain.deleteNode()}}])}(bM),RM=function(){return o((function e(){r(this,e),rR(this,"audioContext",kM()),rR(this,"destination",this.audioContext.createMediaStreamDestination()),rR(this,"inputs",new Set),rR(this,"mixWeight",0),this.destination.channelCount=1}),[{key:"addMixWeight",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1;this.mixWeight+=e,this.mixWeight-1==e+1>>1&&this.mixOnChange()}},{key:"reduceMixWeight",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1;this.addMixWeight(-e)}},{key:"close",value:function(){this.inputs.forEach((function(e){return e.remove()}))}},{key:"mixTrack",get:function(){return this.destination.stream.getAudioTracks()[0]}}])}(),CM=new WeakMap;function wM(e){var t=CM.get(e);if(t)return t;var n=kM();if(e instanceof HTMLAudioElement)t=n.createMediaElementSource(e);else{if(!(e instanceof MediaStreamTrack))return e;t=n.createMediaStreamSource(new MediaStream([e]))}return CM.set(e,t),t}var DM=function(){function e(t){r(this,e),rR(this,"_volume",0),rR(this,"_volumeDb",0),rR(this,"_log"),rR(this,"_scriptProcessorNode",null),rR(this,"_audioWorkletNode",null),rR(this,"_interval",200),rR(this,"ready",this.preload());var n=t.log;this._log=n,rx.on(ax.AUDIO_LEVEL_INTERVAL,this.handleAudioLevelInterval,this)}return o(e,[{key:"node",get:function(){return this._audioWorkletNode||this._scriptProcessorNode}},{key:"preload",value:function(){var t=this;return e.workletReady||(e.workletReady=mM(e.audioContext,URL.createObjectURL(new Blob(['class VolumeMeterWorklet extends AudioWorkletProcessor{constructor(){super(),this.volume=0,this.intervalTime=200,this.tick=200,this.isStop=!1,this.cache=[],this.sentFirstInfo1=!1,this.unmute=!1,this.port.onmessage=t=>{var e=t.data;switch(e.name){case"chunk":this.cache.push(...e.data),this.sentFirstInfo1||(this.port.postMessage({cl:e.data.length}),this.sentFirstInfo1=!0);break;case"setIntervalTime":this.intervalTime=e.intervalTime;break;case"unmute":this.unmute=!0;break;case"stop":this.isStop=!0}}}process(t,s){t=t[0],s=s[0];if(t||s){if(this.isStop)return!1;var i=s&&s[0]?s[0].length:0,h=this.cache.length,a=(i<h?(s[0].set(this.cache.slice(0,i)),this.cache=this.cache.slice(i)):this.unmute&&s[0].set(t[0]),(i<h?s:t)[0]);if(a){let e=0;for(let t=0;t<a.length;++t)e=Math.max(Math.abs(a[t]),e);s=a.reduce((t,e)=>t+e*e,0)/a.length;this.volume=e,this.tick-=a.length,this.tick<0&&(this.tick+=this.intervalTime/1e3*sampleRate,this.port.postMessage({volume:this.volume,volumeDb:Math.max(10*Math.log10(s)+100,0)/100,cacheLen:h,outputLen:i}))}}return!0}}registerProcessor("volume-meter",VolumeMeterWorklet);'],{type:"application/javascript"})))),e.workletReady.then((function(){return t.initAudioWorklet()})).catch((function(e){return t._log.error("volumeMeter preload error: ".concat(e)),t.initScriptProcessor()}))}},{key:"initAudioWorklet",value:function(){var t=this;if(!this._audioWorkletNode)try{this._audioWorkletNode=new AudioWorkletNode(e.audioContext,"volume-meter");var n=!1;this._audioWorkletNode.port.onmessage=function(r){e.lastMessageTime=Date.now(),t._volume=r.data.volume||0,t._volumeDb=r.data.volumeDb||0,!n&&r.data.cacheLen&&r.data.outputLen&&(t._log.warn("worklet play success"),n=!0)},this.handleAudioLevelInterval({interval:this._interval})}catch(mx){this._log.error("volumeMeter init audio worklet error: ".concat(mx)),jP.logFailedEvent({userId:this._log.userId,eventType:xC.LOAD_WORKLET,error:mx}),this.initScriptProcessor()}}},{key:"initScriptProcessor",value:function(){var t=this;if(!this._scriptProcessorNode)try{this._scriptProcessorNode=kM().createScriptProcessor(2048,1,1),this._scriptProcessorNode.onaudioprocess=function(n){e.lastMessageTime=Date.now();for(var r=n.inputBuffer.getChannelData(0),i=0,a=0;a<r.length;++a)i+=r[a]*r[a];t._volume=Math.sqrt(i/r.length)||0}}catch(mx){this._log.error("volumeMeter init script processor error: ".concat(mx))}}},{key:"destroy",value:function(){this._scriptProcessorNode&&(this._scriptProcessorNode.onaudioprocess=null),this._audioWorkletNode&&(this._audioWorkletNode.port.postMessage({name:"stop"}),this._audioWorkletNode.port.onmessage=null),this._audioWorkletNode=null,this._scriptProcessorNode=null,rx.off(ax.AUDIO_LEVEL_INTERVAL,this.handleAudioLevelInterval,this)}},{key:"getInternalAudioLevel",value:function(){return this._volume}},{key:"getCalculatedVolume",value:function(){return parseFloat(this._volume.toFixed(2))}},{key:"getVolumeDb",value:function(){return Math.floor(100*this._volumeDb)}},{key:"handleAudioLevelInterval",value:function(e){var t,n=e.interval;this._interval=n,null==(t=this._audioWorkletNode)||t.port.postMessage({name:"setIntervalTime",intervalTime:n})}}],[{key:"isRunning",get:function(){return Date.now()-e.lastMessageTime<2e3}}])}();rR(DM,"lastMessageTime",0),rR(DM,"audioContext",kM()),rR(DM,"workletReady");var NM=DM,xM=function(e){function i(e){var a;return r(this,i),a=n(this,i),rR(t(a),"_volumeMeter"),a._volumeMeter=new NM(e),a}return d(i,e),o(i,[{key:"deleteNode",value:function(){g(i,"deleteNode",this,3)([]),this._volumeMeter.destroy()}},{key:"init",value:function(){return aR(this,null,f().mark((function e(){return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._volumeMeter.preload();case 2:this.setNode(this._volumeMeter.node);case 3:case"end":return e.stop()}}),e,this)})))}},{key:"getCalculatedVolume",value:function(){return this._volumeMeter.getCalculatedVolume()}},{key:"getInternalAudioLevel",value:function(){return this._volumeMeter.getInternalAudioLevel()}},{key:"getVolumeDb",value:function(){return this._volumeMeter.getVolumeDb()}},{key:"write",value:function(e){if(this.node){var t=e.allocationSize({planeIndex:0}),n=new Float32Array(t>>2);e.copyTo(n,{planeIndex:0}),this.node.port.postMessage({name:"chunk",data:n},[n.buffer]),e.close()}}}])}(SM),OM=NM,PM=tR(oR(),1),MM=function(e){return function(t){return t.deviceId===e}},LM=function(){return o((function e(t){r(this,e);var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"Input";rR(this,"kind"),rR(this,"type"),rR(this,"devices",[]),this.kind=t,this.type=n}),[{key:"update",value:function(e,t){var n=this,r=e.filter((function(e){return e.kind==="".concat(n.kind).concat(n.type.toLocaleLowerCase())}));1===this.devices.length&&FM(this.devices[0])||t&&(r.forEach((function(e){if(e.deviceId&&!n.devices.find(MM(e.deviceId))){var r="".concat(n.kind).concat(n.type,"Added");sx.warn("".concat(r,": ").concat(JSON.stringify(e))),t.emit(r,e)}})),this.devices.forEach((function(e){if(e.deviceId&&!r.find(MM(e.deviceId))){var i="".concat(n.kind).concat(n.type,"Removed");sx.warn("".concat(i,": ").concat(JSON.stringify(e))),t.emit(i,e)}}))),this.devices=r}},{key:"hasDevice",value:function(e){return!!this.devices.find((function(t){return t.deviceId===e}))}}])}(),VM=function(e){function i(){var e;return r(this,i),e=n(this,i),rR(t(e),"audioInputs",new LM(nC.AUDIO)),rR(t(e),"videoInputs",new LM(nC.VIDEO)),rR(t(e),"audioOutputs",new LM(nC.AUDIO,"Output")),e.init(),navigator.mediaDevices&&(navigator.mediaDevices.addEventListener&&navigator.mediaDevices.addEventListener("devicechange",(function(){return e.update()})),"ondevicechange"in navigator.mediaDevices||MP.run("interval",(function(){e.update()}),{delay:1e4})),e}return d(i,e),o(i,[{key:"init",value:function(){var e=this;BM().then((function(t){e.audioInputs.update(t),e.videoInputs.update(t),e.audioOutputs.update(t)}))}},{key:"update",value:function(){return aR(this,arguments,(function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;return f().mark((function n(){var r;return f().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,BM(t);case 2:return r=n.sent,n.abrupt("return",(e.audioInputs.update(r,e),e.videoInputs.update(r,e),e.audioOutputs.update(r,e),e));case 4:case"end":return n.stop()}}),n)}))()}))}}])}(PM.EventEmitter),UM=xR||NR?null:new VM;function FM(e){return e.deviceId===e.groupId&&""===e.groupId}function BM(){return aR(this,arguments,(function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;return f().mark((function t(){var n,r,i;return f().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!OO()&&NO()){t.next=2;break}return t.abrupt("return",[]);case 2:return t.next=4,navigator.mediaDevices.enumerateDevices();case 4:if(n=t.sent,0===e){t.next=22;break}if(r={audio:!1,video:!1},n.forEach((function(e){FM(e)&&(e.kind===nC.AUDIO_INPUT?r.audio=!0:e.kind===nC.VIDEO_INPUT&&(r.video=!0))})),2===e&&(r.audio=!1),1===e&&(r.video=!1),!r.audio&&!r.video){t.next=22;break}return t.prev=8,t.next=11,navigator.mediaDevices.getUserMedia(r);case 11:i=t.sent,r.audio&&TM(),t.next=18;break;case 15:t.prev=15,t.t0=t.catch(8),sx.debug("capture before getDevices failed: ",t.t0);case 18:return t.next=20,navigator.mediaDevices.enumerateDevices();case 20:n=t.sent,null==i||i.getTracks().forEach((function(e){return e.stop()}));case 22:return t.abrupt("return",n.map((function(e,t){var n={kind:e.kind,deviceId:e.deviceId,groupId:e.groupId,label:e.label||"".concat(e.kind,"_").concat(t)};return e.deviceId.length>0&&JM.add("".concat(e.deviceId,"_").concat(e.kind)),e.getCapabilities&&(n.getCapabilities=function(){return e.getCapabilities()}),n})));case 23:case"end":return t.stop()}}),t,null,[[8,15]])}))()}))}function jM(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return UM.update(e?1:0).then((function(e){return e.audioInputs.devices}))}function HM(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return UM.update(e?2:0).then((function(e){return e.videoInputs.devices}))}var GM=!1;function WM(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return aR(this,null,f().mark((function t(){return f().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",((ID||xN)&&(e=!1),UM.update(e?1:0).then((function(e){return e.audioOutputs.devices}))));case 1:case"end":return t.stop()}}),t)})))}var JM=new Set;function KM(e,t){return aR(this,null,f().mark((function n(){var r;return f().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,jM();case 2:return r=n.sent.find((function(e){return e.deviceId===qC})),n.abrupt("return",!t&&(null==r?void 0:r.groupId)===e||(null==r?void 0:r.groupId)===e&&r.label===t);case 4:case"end":return n.stop()}}),n)})))}var zM,YM=function(e){function i(e){var a;return r(this,i),(a=n(this,i)).log=e,rR(t(a),"volumeMeter"),rR(t(a),"volumeDestination"),rR(t(a),"analyser",new IM),a.volumeMeter=new xM({log:a.log}),a.volumeDestination=new SM,a.volumeMeter.pipeTo(a.volumeDestination),a}return d(i,e),o(i,[{key:"destroy",value:function(){this.gain.deleteNode(),this.volumeMeter.deleteNode(),this.analyser.deleteNode(),this.source.deleteNode(),this.destination.deleteNode(),this.volumeDestination.deleteNode()}}])}(bM),qM=function(e){function i(e){var a;return r(this,i),a=n(this,i,[e,nC.AUDIO]),rR(t(a),"_outputDeviceId"),rR(t(a),"_volume",1),rR(t(a),"_destination",kM().createMediaStreamDestination()),rR(t(a),"pipeline"),rR(t(a),"volumeMeterMode","worklet"),a.mode=0,a.pipeline=new YM(a._log),a}return d(i,e),o(i,[{key:"getMediaStream",value:function(){return this.pipeline.stream||(this.track?new MediaStream([this.track]):null)}},{key:"initializeElement",value:function(e){if("15.2"!==LN&&"15.3"!==LN&&"15.4"!==LN||!this.muted){var t=zM||new Audio;t.setAttribute("autoplay","autoplay"),t.srcObject=this.getMediaStream(),t.muted=this.muted,this.element=t,Aw(e)&&(this.element.volume=Math.min(Math.max(e,0),1)),t===zM&&(zM=void 0),this.bindElementEvents()}else this._log.info("audioElement is muted.")}},{key:"play",value:function(e){return aR(this,null,f().mark((function t(){return f().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.track){t.next=10;break}if(this.pipeline.source.node||this.pipeline.replaceSource(this.track),this.element||this.initializeElement(null==e?void 0:e.volume),t.t0=this._outputDeviceId,!t.t0){t.next=7;break}return t.next=7,this.setSinkId(this._outputDeviceId);case 7:return"worklet"===this.volumeMeterMode?this.pipeline.volumeMeter.init():"analyser"===this.volumeMeterMode&&this.pipeline.analyser.setNode(kM().createAnalyser()),function(){aR(this,null,f().mark((function e(){return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(e.prev=0,e.t0=GM,e.t0){e.next=11;break}return GM=!0,e.t1=sx,e.t2="speakers:",e.next=8,WM();case 8:e.t3=e.sent.map((function(e){return" ".concat(e.deviceId.slice(0,8),": ").concat(e.label)})),e.t4=e.t2.concat.call(e.t2,e.t3),e.t1.info.call(e.t1,e.t4);case 11:e.next=15;break;case 13:e.prev=13,e.t5=e.catch(0);case 15:case"end":return e.stop()}}),e,null,[[0,13]])})))}(),t.abrupt("return",iR(i.prototype,this,"play").call(this));case 10:case"end":return t.stop()}}),t,this)})))}},{key:"stop",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;this.pipeline.destroy(),g(i,"stop",this,3)([e])}},{key:"setSinkId",value:function(e){return aR(this,null,f().mark((function t(){var n,r;return f().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this._outputDeviceId!==e&&(this._outputDeviceId=e),t.t0=this.element&&this.element.sinkId!==e,!t.t0){t.next=5;break}return t.next=5,null==(r=(n=this.element).setSinkId)?void 0:r.call(n,e);case 5:case"end":return t.stop()}}),t,this)})))}},{key:"useDestination",get:function(){return!!this.pipeline.stream}},{key:"setLoop",value:function(e){this.element&&(this.element.loop=e)}},{key:"getAudioLevel",value:function(){return this.pipeline.volumeMeter.getCalculatedVolume()}},{key:"getInternalAudioLevel",value:function(){return this.pipeline.volumeMeter.getInternalAudioLevel()}}])}(JP),XM=function(e){function t(){return r(this,t),n(this,t,arguments)}return d(t,e),o(t,[{key:"setTrack",value:function(e){this.track!==e&&(this.unbindTrackEvents(),this.track=e,this.emit(LP.MEDIA_TRACK_CHANGED,e),e&&(this.bindTrackEvents(),this.element&&(this.element.srcObject=new MediaStream([e]))))}},{key:"setVolume",value:function(e){this._volume=e,this.element&&(this.element.volume=e)}}])}(qM),QM=function(e){function i(e){var a;return r(this,i),a=n(this,i,[e]),rR(t(a),"_sourceElement"),rR(t(a),"_output",new SM),a.pipeline.source.pipeTo(a.pipeline.gain.pipeTo(a.pipeline.volumeMeter.pipeTo(a._output),a.pipeline.destination)),a}return d(i,e),o(i,[{key:"setOutput",value:function(){this.mode=1,this._output.setNode(kM().destination)}},{key:"write",value:function(e){this.pipeline.volumeMeter.write(e)}},{key:"setTrack",value:function(e){var t,n;(null==(n=null==(t=this.element)?void 0:t.error)?void 0:n.code)!==MediaError.MEDIA_ERR_DECODE&&this.track!==e&&(this.unbindTrackEvents(),this.track=e,this.emit(LP.MEDIA_TRACK_CHANGED,e),e?(this.bindTrackEvents(),this._sourceElement?this._sourceElement.srcObject=new MediaStream([e]):!this.useDestination&&this.element&&(this.element.srcObject=new MediaStream([e])),this.pipeline.replaceSource(e)):this.pipeline.source.deleteNode())}},{key:"setVolume",value:function(e){this._volume=e,this.useDestination?(this.pipeline.setVolume(e),this._log.info("set pipeline volume: ".concat(e))):e<=1?this.element?(this._log.info("set element volume: ".concat(e)),this.element.volume=e):this._log.info("set element volume: no element"):ID||(this._log.info("start set pipeline volume: ".concat(e)),this.pipeline.setVolume(e),this.element&&!this._sourceElement&&(this.pipeline.destination.setNode(this._destination),BP(this.element),this._sourceElement=this.element,this._sourceElement.muted=!0,this.element=null,this.play()))}},{key:"stop",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;this.pipeline.destroy();var t=this._sourceElement||this.element;t&&ON&&(zM=t),this._sourceElement&&(this._sourceElement.srcObject=null,delete this._sourceElement),g(i,"stop",this,3)([e])}}])}(qM),$M=function(e){function i(e){var a;r(this,i);var o,s=e.userId,c=e.sdkAppId,u=e.mediaType,l=e.room,d=e.PlayerClass,h=void 0===d?1===u?QM:pM:d;return a=n(this,i),rR(t(a),"id",cx()),rR(t(a),"userId",""),rR(t(a),"isRemote"),rR(t(a),"mediaType"),rR(t(a),"room"),rR(t(a),"user"),rR(t(a),"_log"),rR(t(a),"_inputTrack"),rR(t(a),"_outputTrack"),rR(t(a),"isPlayCalled"),rR(t(a),"container",null),rR(t(a),"player"),rR(t(a),"subVideoPlayerMap"),rR(t(a),"muted",!1),rR(t(a),"abortCtrl"),rR(t(a),"objectFit","cover"),rR(t(a),"mirror"),rR(t(a),"isScreen",!1),rR(t(a),"manager"),rR(t(a),"trackSettings"),rR(t(a),"isFirstVideoFrameEmitted",!1),a.userId=s||"",a.mediaType=u,a._log=sx.createLogger({id:"".concat(a.kind[0],"t"),userId:null==(o=l||a.room)?void 0:o.userId,remoteUserId:t(a)instanceof EL?void 0:a.userId,sdkAppId:c,type:2===a.mediaType?"auxiliary":"main",isLocal:t(a)instanceof EL}),a.player=new h({id:a.userId||a.id,track:null,muted:!1,container:null,log:a._log}),a.player.on(LP.PLAYER_STATE_CHANGED,(function(e){rx.emit(ax.PLAYER_STATE_CHANGED,QA({track:t(a)},e)),a.emit("player-state-changed",e)})),a.kind===nC.VIDEO&&(a.player.on(LP.LOADED_DATA,(function(){a.emitFirstVideoFrameEvent(LP.LOADED_DATA),rx.emit(ax.VIDEO_LOADED_DATA,{track:t(a)})})),a.player.on(LP.LOADED_META_DATA,(function(){a.emitFirstVideoFrameEvent(LP.LOADED_META_DATA)})),a.player.on(LP.MEDIA_TRACK_CHANGED,(function(e){var t;null==(t=a.subVideoPlayerMap)||t.forEach((function(t){return t.setTrack(e)}))}))),a.onTrackMuted=a.onTrackMuted.bind(t(a)),a.onTrackUnmuted=a.onTrackUnmuted.bind(t(a)),a.onTrackEnded=a.onTrackEnded.bind(t(a)),a.onPlayerError&&a.player.on(LP.ERROR,a.onPlayerError.bind(t(a))),a}return d(i,e),o(i,[{key:"log",get:function(){return this._log||sx}},{key:"kind",get:function(){return 1===this.mediaType?nC.AUDIO:nC.VIDEO}},{key:"strMediaType",get:function(){return 4===this.mediaType?nC.VIDEO:2===this.mediaType?nC.SCREEN:nC.AUDIO}},{key:"streamType",get:function(){return 2&this.mediaType?"auxiliary":"main"}},{key:"isMediaTrackActive",get:function(){return!!this.mediaTrack&&!this.mediaTrack.muted&&"live"===this.mediaTrack.readyState&&this.mediaTrack.enabled}},{key:"play",value:function(e,t){return aR(this,null,f().mark((function n(){var r;return f().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(r=ww(e)?e[0]:e,!this.isPlayCalled){n.next=16;break}if(this.log.info("play update options: ".concat(JSON.stringify(t))),t&&!Iw(t.muted)&&this.setPlayerMute(t.muted),t&&!Iw(t.objectFit)&&(this.objectFit=t.objectFit),n.t0=this.player instanceof pM,!n.t0){n.next=15;break}if(this.player.setObjectFit(this.objectFit),this.container!==r&&r&&(this.container=r,this.player.setContainer(r)),n.t1=ww(e)&&e.length>=1,!n.t1){n.next=14;break}return n.next=13,this.playSubContainer(e.slice(1),t);case 13:n.t1=n.sent;case 14:n.t0=n.t1;case 15:return n.abrupt("return",void n.t0);case 16:if(t&&!Iw(t.muted)?this.setPlayerMute(t.muted):(!this.isRemote||this.kind===nC.VIDEO)&&this.setPlayerMute(!0),t&&!Iw(t.objectFit)&&(this.objectFit=t.objectFit),this.player instanceof pM&&(this.player.setObjectFit(this.objectFit),t&&!Iw(t.poster)&&this.player.setPoster(t.poster)),this.isPlayCalled=!0,r&&(this.container=r,this.player instanceof pM&&this.player.setContainer(r)),rx.emit(ax.PLAY_TRACK_START,{track:this}),!this._outputTrack){n.next=33;break}return this._log.info("play with options: ".concat(JSON.stringify(t))),n.prev=18,this.player.setTrack(this.playerMediaTrack),n.next=22,this.player.play(t);case 22:if(n.t2=ww(e)&&e.length>1,!n.t2){n.next=26;break}return n.next=26,this.playSubContainer(e.slice(1),t);case 26:n.next=31;break;case 28:throw n.prev=28,n.t3=n.catch(18),this.handleAutoPlayFailed(n.t3),n.t3;case 31:n.next=34;break;case 33:this.log.info("play has not mediaTrack, abort");case 34:case"end":return n.stop()}}),n,this,[[18,28]])})))}},{key:"setMirror",value:function(e,t){if(!this.isScreen&&this.kind===nC.VIDEO&&!Iw(e)&&e!==this.mirror){this.mirror=e;var n=this.player;t&&(n=t);var r=this.manager;if(Rw(this.mirror))return n.setViewMirror(this.mirror),void(r&&(r.mirror=!1));switch(this.mirror){case"view":r&&(r.mirror=!1),n.setViewMirror(!0);break;case"publish":r&&(r.mirror=!0),n.setViewMirror(!0);break;case"both":r&&(r.mirror=!0),n.setViewMirror(!1)}}}},{key:"playSubContainer",value:function(e,t){return aR(this,null,f().mark((function n(){var r,i,a,o,c,u,l,d,h,p,m=this;return f().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(this._outputTrack&&this.kind!==nC.AUDIO){n.next=2;break}return n.abrupt("return");case 2:this.subVideoPlayerMap||(this.subVideoPlayerMap=new Map),this.subVideoPlayerMap.forEach((function(t,n){var r;e.find((function(e){return n===e}))||(t.stop(),null==(r=m.subVideoPlayerMap)||r.delete(n))})),r=s(e.entries());try{for(r.s();!(i=r.n()).done;)a=v(i.value,2),o=a[0],c=a[1],(u=this.subVideoPlayerMap.get(c))?t&&(Iw(t.objectFit)||u.setObjectFit(t.objectFit)):this.subVideoPlayerMap.set(c,new pM({id:this.userId||this.id,track:this.playerMediaTrack,container:c,muted:this.player.muted,objectFit:this.objectFit,log:this.log.createChild({id:"vp-sub".concat(o+1)})}))}catch(f){r.e(f)}finally{r.f()}l=E(this.subVideoPlayerMap.values()),d=s(l),n.prev=7,d.s();case 9:if((h=d.n()).done){n.next=16;break}return(p=h.value).setViewMirror(this.player.mirror),n.next=14,p.play();case 14:n.next=9;break;case 16:n.next=21;break;case 18:n.prev=18,n.t0=n.catch(7),d.e(n.t0);case 21:return n.prev=21,d.f(),n.finish(21);case 24:case"end":return n.stop()}}),n,this,[[7,18,21,24]])})))}},{key:"setAudioOutput",value:function(e){return this.player.setSinkId(e)}},{key:"setAudioVolume",value:function(e){this.player.setVolume(e)}},{key:"getAudioLevel",value:function(){return this.player.getAudioLevel()||0}},{key:"getInternalAudioLevel",value:function(){var e;return(null==(e=this.player)?void 0:e.getInternalAudioLevel())||0}},{key:"stop",value:function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];this.isPlayCalled&&(this.isPlayCalled=!1,this.player&&(this.log.info("stop ".concat(this.kind," player")),this.player.stop(lD(this)&&!e?this.jitterBufferDelay:0)),this.subVideoPlayerMap&&this.subVideoPlayerMap.size>0&&this.subVideoPlayerMap.forEach((function(e){e.stop()})),this.container=null)}},{key:"resume",value:function(){return aR(this,null,f().mark((function e(){var t;return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(e.t0=this.isPlayCalled,!e.t0){e.next=4;break}return e.next=4,null==(t=this.player)?void 0:t.resume();case 4:case"end":return e.stop()}}),e,this)})))}},{key:"close",value:function(){this.log.info("close"),this.isPlayCalled&&this.stop(!0)}},{key:"setMute",value:function(e){this.muted=e,this._inputTrack&&(this._inputTrack.enabled=!e),this._outputTrack&&(this._outputTrack.enabled=!e),this.emit(e?"mute":"unmute",this),rx.emit(e?ax.TRACK_MUTED:ax.TRACK_UNMUTED,{track:this})}},{key:"setPlayerMute",value:function(e){this.player.setMuted(e)}},{key:"mediaTrack",get:function(){return this._inputTrack||null}},{key:"outMediaTrack",get:function(){return this._outputTrack||null}},{key:"playerMediaTrack",get:function(){return this.outMediaTrack}},{key:"installTrackEvent",value:function(e){FP(e,e).add(nC.MUTE,this.onTrackMuted).add(nC.UNMUTE,this.onTrackUnmuted).add(nC.ENDED,this.onTrackEnded),e.muted&&this.onTrackMuted(),e.readyState===nC.ENDED&&this.onTrackEnded()}},{key:"uninstallTrackEvent",value:function(e){BP(e)}},{key:"setInputMediaStreamTrack",value:function(e){var t,n=this._inputTrack;if(e!==n)return this._inputTrack=e,this.trackSettings=null==(t=e.getSettings)?void 0:t.call(e),e.enabled=!this.muted,n&&this.uninstallTrackEvent(n),this.installTrackEvent(e),this.emit("input-media-track-changed",e||null,n||null),this.manager?this.manager.changeInput(this):this.setOutputMediaStreamTrack(e)}},{key:"setOutputMediaStreamTrack",value:function(e){var t;e!==this._outputTrack&&(this.isRemote?this.log.debug("setOutputMediaStreamTrack",e.label):this.log.info("setOutputMediaStreamTrack",null==(t=e.getSettings)?void 0:t.call(e).deviceId,e.label),this._outputTrack=e,this._inputTrack&&(this._outputTrack.contentHint=this._inputTrack.contentHint,this._outputTrack.enabled=this._inputTrack.enabled),this.updatePlayingState(!!e),this.emit("output-media-track-changed",e))}},{key:"setMediaType",value:function(e){this.mediaType=e}},{key:"updatePlayingState",value:function(e){var t=this;if(this.isPlayCalled)if(e){if(this.player.setTrack(this.playerMediaTrack),this.player.isStopped)return this.player.play().catch((function(e){return t.handleAutoPlayFailed(e)})),void this.log.info("playing state updated, play ".concat(this.kind))}else if(!this.player.isStopped)return this.player.stop(lD(this)?this.jitterBufferDelay:0),void this.log.info("playing state updated, stop ".concat(this.kind));this.log.debug("updatePlayingState abort ".concat(this.isPlayCalled," ").concat(e," ").concat(this.player.isStopped))}},{key:"handleAutoPlayFailed",value:function(e){var t=this;if(this.room&&this.room.enableAutoPlayDialog)new fM;else{var n=function(){t.resume().then((function(){document.removeEventListener("click",n,!0)}))};document.addEventListener("click",n,!0)}this.emit("error",e)}},{key:"getVideoFrame",value:function(){return this.player instanceof pM?this.player.getVideoFrame():""}},{key:"emitFirstVideoFrameEvent",value:function(e){var t,n,r;if(!this.isFirstVideoFrameEmitted){var i=null==(t=this.mediaTrack)?void 0:t.getSettings(),a=(null==i?void 0:i.width)||(null==(n=this.player.element)?void 0:n.videoWidth)||0,o=(null==i?void 0:i.height)||(null==(r=this.player.element)?void 0:r.videoHeight)||0;e===LP.LOADED_META_DATA&&!a&&!o||(e===LP.LOADED_DATA&&!a&&!o&&this._log.warn("the dimension of video is 0x0 in first-video-frame event"),this.isFirstVideoFrameEmitted=!0,this.emit("first-video-frame",{width:a,height:o,streamType:this.streamType,userId:this.isRemote?this.userId:""}))}}},{key:"onTrackMuted",value:function(){this._log.warn("".concat(this.kind," track is unable to provide media output"))}},{key:"onTrackUnmuted",value:function(){this._log.info("".concat(this.kind," track is able to provide media output"))}},{key:"onTrackEnded",value:function(){this._log.warn("".concat(this.kind," track ended"))}}])}(wP);nR([AP([],wP.INIT,{sync:!0})],$M.prototype,"close",1);var ZM=Object.prototype.hasOwnProperty,eL=function(e){if(null==e)return!0;if("boolean"==typeof e)return!1;if("number"==typeof e)return 0===e;if("string"==typeof e||"function"==typeof e||Array.isArray(e))return 0===e.length;if(e instanceof Error)return""===e.message;if(yw(e))switch(Object.prototype.toString.call(e)){case"[object File]":case"[object Map]":case"[object Set]":return 0===e.size;case"[object Object]":for(var t in e)if(ZM.call(e,t))return!1;return!0}return!1},tL=dD({retryFunction:function(e){return aR(this,null,f().mark((function t(){var n,r,i,a,o,s;return f().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=function(e){return{audio:rL(e),video:iL(e)}}(e),sx.info("getUserMedia with constraints: ".concat(JSON.stringify(n))),r=[],i=[],a=["label","deviceId","groupId"],t.t0=n.audio,!t.t0){t.next=9;break}return t.next=7,jM();case 7:r=t.sent,sx.info("microphones: ".concat(Xw(r.map((function(e){return $A(QA({},e),{groupId:e.groupId.substring(0,8)})})),{keysToInclude:a})));case 9:if(t.t1=n.video,!t.t1){t.next=15;break}return t.next=13,HM();case 13:i=t.sent,sx.info("cameras: ".concat(Xw(i,{keysToInclude:a})));case 15:return t.prev=15,t.next=18,navigator.mediaDevices.getUserMedia(n);case 18:return o=t.sent,t.abrupt("return",(oP&&o.getTracks().forEach((function(e){sx.info("".concat(e.kind," capabilities: ").concat(Xw(e.getCapabilities(),{keysToInclude:nw})))})),n.audio&&TM(),o));case 22:throw t.prev=22,t.t2=t.catch(15),s=t.t2.message,"NotFoundError"===t.t2.name&&(e.video&&i&&0===i.length&&(s=mO({key:dO.CAMERA_NOT_FOUND})),e.audio&&r&&0===r.length&&(s=mO({key:dO.MICROPHONE_NOT_FOUND}))),new yR({code:_R.INITIALIZE_FAILED,name:t.t2.name,message:s,constraint:t.t2.constraint});case 26:case"end":return t.stop()}}),t,null,[[15,22]])})))},settings:{retries:3,timeout:500},onError:function(e){var t=e.error,n=e.retry,r=e.reject,i=e.retryFuncArgs,a=e.retriedCount+1;"NotReadableError"===t.name||"OverconstrainedError"===t.name?(1===a?(i[0].video&&(i[0].maxResolution=!1,(!xN||i[0].width*i[0].height<=2073600)&&i[0].frameRate&&(i[0].frameRate=i[0].frameRate>10?10:5)),i[0].retryWhenExactFailed&&i[0].useExactDeviceId&&(i[0].useExactDeviceId=!1)):2===a?i[0].useDeviceIdOnly=!0:3===a&&!i[0].useExactDeviceId&&(i[0].useTrueAsConstraint=!0),n()):r(t),i[0].microphoneId&&nL(i[0].microphoneId,!1),i[0].cameraId&&nL(i[0].cameraId,!0)},onRetrying:function(e){sx.warn("getUserMedia NotReadableError observed, retrying [".concat(e,"/3]"))},onRetryFailed:function(e){jP.logFailedEvent({eventType:xC.GET_USER_MEDIA_RETRY,error:e})},onRetrySuccess:function(e){jP.logSuccessEvent({eventType:xC.GET_USER_MEDIA_RETRY}),jP.uploadEvent({log:"stat-".concat(xC.GET_USER_MEDIA_RETRY,"-success-").concat(e)})}});function nL(e,t){return aR(this,null,f().mark((function n(){var r;return f().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(!t){n.next=6;break}return n.next=3,HM();case 3:n.t0=n.sent,n.next=9;break;case 6:return n.next=8,jM();case 8:n.t0=n.sent;case 9:r=n.t0.find((function(t){return t.deviceId===e})),r&&Sw(r.getCapabilities)&&sx.warn(Xw(r.getCapabilities(),{keysToInclude:nw}));case 11:case"end":return n.stop()}}),n)})))}function rL(e){if(!e.audio)return!1;if(e.useTrueAsConstraint)return!0;var t={echoCancellation:!0,noiseSuppression:!0,autoGainControl:!0,sampleRate:e.sampleRate};return!eL(e.microphoneId)&&(t.deviceId=e.useExactDeviceId?{exact:e.microphoneId}:e.microphoneId,e.useDeviceIdOnly)?t:(Aw(e.channelCount)&&(t.channelCount=e.channelCount),Rw(e.echoCancellation)&&!e.echoCancellation&&(t.echoCancellation=!1),Rw(e.noiseSuppression)&&!e.noiseSuppression&&(t.noiseSuppression=!1),Rw(e.autoGainControl)&&!e.autoGainControl&&(t.autoGainControl=!1),!!eL(t)||t)}function iL(e){if(!e.video)return!1;if(e.useTrueAsConstraint)return!0;var t=e.maxResolution,n=void 0===t||t,r={};return e.cameraId?r.deviceId=e.useExactDeviceId?{exact:e.cameraId}:e.cameraId:e.facingMode&&(r.facingMode=e.facingMode),e.useDeviceIdOnly&&!eL(r)?r:(e.width&&(r.width={ideal:e.width},n&&!wD&&(r.width.max=e.width)),e.height&&(r.height={ideal:e.height},n&&!wD&&(r.height.max=e.height)),wD&&oN&&e.width&&e.height&&e.width*e.height<101376&&(r.width=e.width,r.height=e.height),e.frameRate&&(r.frameRate=e.frameRate),!!eL(r)||r)}var aL=tL;function oL(e){return uL((function(t,n){return function(){for(var n=arguments.length,r=new Array(n),i=0;i<n;i++)r[i]=arguments[i];return aR(this,null,f().mark((function n(){return f().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,e.apply(this,r);case 2:return n.abrupt("return",t.apply(this,r));case 3:case"end":return n.stop()}}),n,this)})))}}))}function sL(e){return uL((function(t,n){return function(){for(var n=arguments.length,r=new Array(n),i=0;i<n;i++)r[i]=arguments[i];return aR(this,null,f().mark((function n(){var i;return f().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,t.apply(this,r);case 2:return i=n.sent,n.next=5,e.call.apply(e,[this].concat(r));case 5:return n.abrupt("return",i);case 6:case"end":return n.stop()}}),n,this)})))}}))}function cL(e){return uL((function(t,n){return function(){for(var n=arguments.length,r=new Array(n),i=0;i<n;i++)r[i]=arguments[i];return aR(this,null,f().mark((function n(){return f().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.prev=0,n.next=3,t.apply(this,r);case 3:return n.abrupt("return",n.sent);case 6:n.prev=6,n.t0=n.catch(0),e.call(this,n.t0);case 9:case"end":return n.stop()}}),n,this,[[0,6]])})))}}))}function uL(e){return function(t,n,r){return r.value=e(r.value,n),r}}var lL=function(){var e=!1,t=document.visibilityState;return function(){document.visibilityState!==t&&sx.info("visibility change: ".concat(document.visibilityState)),!e&&(document.addEventListener("visibilitychange",(function(){sx.info("visibility change: ".concat(document.visibilityState)),t=document.visibilityState})),e=!0)}}(),dL=0,hL=function(){return o((function e(){r(this,e),rR(this,"log",sx.createLogger({id:"fq".concat(++dL)})),rR(this,"isRunning",!1),rR(this,"queue",[])}),[{key:"length",get:function(){return this.queue.length}},{key:"lastQueueItem",get:function(){return 0===this.length?null:this.queue[this.length-1]}},{key:"push",value:function(e){var t,n,r=arguments.length>1&&void 0!==arguments[1]&&arguments[1],i=QA({},e),a=new Promise((function(e,t){i.resolve=e,i.reject=t}));return i.promise=a,r?this.length<=1?this.queue.push(i):null==(n=null==(t=this.lastQueueItem)?void 0:t.promise)||n.then(i.resolve,i.reject):this.queue.push(i),this.log.debug("push ".concat(this.length)),this.isRunning||this.callNext(),a}},{key:"shift",value:function(){var e=this.queue.shift();return this.log.debug("shift ".concat(this.length)),e}},{key:"callNext",value:function(){var e=this;if(!this.isRunning&&0!==this.length){this.log.debug("callNext ",this.length);var t=this.queue[0],n=t.fn,r=t.args,i=t.context,a=t.resolve,o=t.reject;this.isRunning=!0,n.apply(i,r).then(a,o).finally((function(){e.isRunning=!1,e.shift(),e.callNext()}))}}}])}(),fL=new WeakMap,pL=new WeakMap;function mL(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return function(t,n,r){var i=r.value;return r.value=function(){for(var t=fL.get(this)||new hL,n=arguments.length,r=new Array(n),a=0;a<n;a++)r[a]=arguments[a];return fL.set(this,t),t.push({fn:i,args:r,context:this},e)},r}}function vL(e){return function(t,n,r){var i=r.value;return r.value=function(){for(var t,n,r,a=[],o=arguments.length,s=new Array(o),c=0;c<o;c++)s[c]=arguments[c];return null==(n=null==(t=fL.get(this))?void 0:t.queue)||n.forEach((function(e){return a.push(e)})),null==(r=pL.get(this))||r.forEach((function(e){return null==e?void 0:e.queue.forEach((function(e){return a.push(e)}))})),a.forEach((function(t){t.reject(new yR({code:_R.API_CALL_ABORTED,message:e}))})),fL.delete(this),pL.delete(this),i.apply(this,s)},r}}function _L(e){return function(t,n,r){var i=r.value,a=function(t){return e.apply(void 0,E(t))};return r.value=function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];var r=pL.get(this)||new Map,o=r.get(a(t))||new hL;return r.set(a(t),o),pL.set(this,r),o.push({fn:i,args:t,context:this})},r}}function gL(e,t){return uL((function(n,r){return function(){var r=e;try{for(var i=arguments.length,a=new Array(i),o=0;o<i;o++)a[o]=arguments[o];var s=n.apply(this,a),c=Vw();return xw(s)?s.then((function(e){return t?bO.addSuccessEvent({key:r,cost:Vw()-c}):bO.addSuccessEvent({key:r}),e})).catch((function(e){throw bO.addFailedEvent({key:r,error:e}),e})):(bO.addSuccessEvent({key:r}),s)}catch(DR){throw bO.addFailedEvent({key:r,error:DR}),DR}}}))}var yL=function(e){function i(e,a){var o;return r(this,i),o=n(this,i,[{mediaType:e,PlayerClass:a}]),rR(t(o),"isRemote",!1),rR(t(o),"deviceId"),rR(t(o),"groupId",""),rR(t(o),"label",""),rR(t(o),"_isRecapturing",!1),rR(t(o),"_lastRecaptureTime",0),rR(t(o),"_onMuteTimeoutId",-1),rR(t(o),"_encodeCheckTimeoutId",-1),rR(t(o),"profile"),o}return d(i,e),o(i,[{key:"enableEncodeFrame",get:function(){return!1}},{key:"isPublishing",get:function(){return"publishing"===this.state.toString()}},{key:"isPublished",get:function(){return"publish"===this.state}},{key:"encodeFrame",value:function(e,t){throw new Error("Method not implemented.")}},{key:"installTrackEvent",value:function(e){FP(e,e).add(nC.MUTE,this.onTrackMuted).add(nC.UNMUTE,this.onTrackUnmuted).add(nC.ENDED,this.onTrackEnded),e.muted&&this.onTrackMuted(),e.readyState===nC.ENDED&&this.onTrackEnded()}},{key:"uninstallTrackEvent",value:function(e){BP(e)}},{key:"setStateToCapture",value:function(){}},{key:"capture",value:function(e){return aR(this,null,f().mark((function t(){var n,r,i,a;return f().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(t.prev=0,i=Vw(),rx.emit(ax.LOCAL_TRACK_CAPTURE_START,{track:this}),!e.customSource){t.next=7;break}(r=new MediaStream).addTrack(e.customSource),t.next=11;break;case 7:return null==(n=this.mediaTrack)||n.stop(),t.next=10,aL(e);case 10:r=t.sent;case 11:return a=r.getTracks()[0],t.next=14,this.setInputMediaStreamTrack(a);case 14:return e.customSource||(this.updateDeviceIdInUse(),this.listenDeviceChange()),rx.emit(ax.LOCAL_TRACK_CAPTURE_SUCCESS,{track:this,cost:Vw()-i}),t.abrupt("return",r);case 19:throw t.prev=19,t.t0=t.catch(0),rx.emit(ax.LOCAL_TRACK_CAPTURE_FAILED,{track:this,error:t.t0}),this.log.error("getUserMedia error observed ".concat(t.t0)),t.t0;case 22:case"end":return t.stop()}}),t,this,[[0,19]])})))}},{key:"setInputMediaStreamTrack",value:function(e){return this.state===wP.INIT&&this.setStateToCapture(),g(i,"setInputMediaStreamTrack",this,3)([e])}},{key:"setOutputMediaStreamTrack",value:function(e){var t;if(g(i,"setOutputMediaStreamTrack",this,3)([e]),this.isPublishing||this.isPublished)return null==(t=this.room)?void 0:t.replaceTrack(this)}},{key:"publish",value:function(e,t){return this.room=e,this.emit("4",{mediaType:this.strMediaType,state:"starting",prevState:"stopped"}),this.userId=e.userId,this._log.setUserId(e.userId),this._log.setSdkAppId(e.sdkAppId),t}},{key:"unpublish",value:function(){this.room&&this.room.localTracks.delete(this),rx.emit(ax.LOCAL_TRACK_UNPUBLISHED,{track:this})}},{key:"updateDeviceIdInUse",value:function(){return aR(this,null,f().mark((function e(){var t,n,r,i,a=this;return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.mediaTrack||!aP){e.next=7;break}return t=this.mediaTrack.getSettings(),n=t.deviceId,r=t.groupId,i=this.mediaTrack.label,e.next=4,function(e){return aR(this,arguments,(function(e){var t=e.newDeviceId,n=e.oldDeviceId,r=e.oldGroupId,i=e.oldLabel,a=e.kind;return f().mark((function e(){return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(e.t0=t===n,!e.t0){e.next=8;break}if(e.t1=a!==nC.AUDIO||t!==qC,e.t1){e.next=7;break}return e.next=6,KM(r,i);case 6:e.t1=e.sent;case 7:e.t0=e.t1;case 8:return e.abrupt("return",e.t0);case 9:case"end":return e.stop()}}),e)}))()}))}({newDeviceId:n,oldDeviceId:this.deviceId,oldGroupId:this.groupId,oldLabel:this.label,kind:this.kind});case 4:if(e.t0=e.sent,e.t0){e.next=7;break}this.deviceId=n,this.label=i,r&&(this.groupId=r),BM().then((function(e){var t=e.find((function(e){return e.deviceId===n}));t&&a.emit("2",t)}));case 7:case"end":return e.stop()}}),e,this)})))}},{key:"setProfile",value:function(e){this.log.info("setProfile",e),Object.assign(this.profile,e)}},{key:"isNeedToRecapture",value:function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return!(!this.deviceId||!this.mediaTrack||this.kind===nC.AUDIO&&!function(e){if(e instanceof CanvasCaptureMediaStreamTrack||!(e instanceof MediaStreamTrack))return!1;var t=e.label.toLocaleLowerCase();if(t.includes("mic")||t.includes("麦克风"))return!0;var n="".concat(((null==e?void 0:e.getSettings())||{}).deviceId,"_").concat(nC.AUDIO_INPUT);return!!JM.has(n)}(this.mediaTrack)||this.kind===nC.VIDEO&&!function(e){if(e instanceof CanvasCaptureMediaStreamTrack||!(e instanceof MediaStreamTrack))return!1;var t=e.label.toLocaleLowerCase();if(t.includes("camera")||t.includes("webcam"))return!0;var n="".concat(((null==e?void 0:e.getSettings())||{}).deviceId,"_").concat(nC.VIDEO_INPUT);return!!JM.has(n)}(this.mediaTrack)||this._isRecapturing||e&&oN&&xN)}},{key:"onTrackMuted",value:function(){var e=this;if(g(i,"onTrackMuted",this,3)([]),lL(),this.isNeedToRecapture(!0)){if(Date.now()-this._lastRecaptureTime<tw)return void setTimeout((function(){return e.onTrackMuted()}),tw);this._onMuteTimeoutId=setTimeout((function(){return aR(e,null,f().mark((function e(){var t;return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(null==(t=this.mediaTrack)||!t.muted){e.next=8;break}if(!ID&&!bD||"visible"===document.visibilityState){e.next=3;break}return e.abrupt("return");case 3:return e.t0=this,e.next=6,this.getRecoverCaptureDeviceId();case 6:e.t1=e.sent,e.t0.recapture.call(e.t0,e.t1);case 8:case"end":return e.stop()}}),e,this)})))}),5e3)}}},{key:"onTrackUnmuted",value:function(){g(i,"onTrackUnmuted",this,3)([]),this._onMuteTimeoutId>0&&clearTimeout(this._onMuteTimeoutId)}},{key:"onTrackEnded",value:function(){return aR(this,null,f().mark((function e(){var t=this;return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(iR(i.prototype,this,"onTrackEnded").call(this),!this.isNeedToRecapture()){e.next=8;break}if(!(Date.now()-this._lastRecaptureTime<tw)){e.next=3;break}return e.abrupt("return",void setTimeout((function(){return t.onTrackEnded()}),tw));case 3:return e.t0=this,e.next=6,this.getRecoverCaptureDeviceId();case 6:e.t1=e.sent,e.t0.recapture.call(e.t0,e.t1);case 8:case"end":return e.stop()}}),e,this)})))}},{key:"recapture",value:function(e){return aR(this,null,f().mark((function t(){var n,r,i,a=this;return f().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this._isRecapturing&&this._inputTrack){t.next=2;break}return t.abrupt("return");case 2:if(this.log.warn("recapture trying"),null==(n=this._inputTrack)||n.stop(),this._isRecapturing=!0,this._lastRecaptureTime=Date.now(),r={useExactDeviceId:!0},"user"!==e&&"environment"!==e){t.next=8;break}r.facingMode=e,t.next=21;break;case 8:if("audio"!==this.kind){t.next=14;break}return t.next=11,jM();case 11:t.t0=t.sent,t.next=17;break;case 14:return t.next=16,HM();case 16:t.t0=t.sent;case 17:if(t.t1=t.t0.find((function(t){return t.deviceId===e})),!t.t1){t.next=20;break}i=e;case 20:r.deviceId=i;case 21:return t.abrupt("return",this.capture(r).then((function(){a._isRecapturing=!1,a.log.warn("recapture success"),a.emit("1",{deviceId:a.deviceId}),rx.emit(ax.LOCAL_TRACK_RECAPTURE,{track:a})})).catch((function(e){a._isRecapturing=!1,a.log.warn("recapture failed ".concat(e.message)),a.emit("5",e),rx.emit(ax.LOCAL_TRACK_RECAPTURE,{track:a,error:e})})));case 22:case"end":return t.stop()}}),t,this)})))}},{key:"getRecoverCaptureDeviceId",value:function(){return aR(this,null,f().mark((function e(){var t,n,r,i;return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(t=this instanceof AL)||!this.facingMode){e.next=3;break}return e.abrupt("return",this.facingMode);case 3:if(!(n=this.deviceId)){e.next=18;break}if(r=(TL.get(n)||0)+1,TL.set(n,r),!(r>=3)){e.next=18;break}if(!t){e.next=13;break}return e.next=10,HM();case 10:e.t0=e.sent.find((function(e){return!TL.has(e.deviceId)})),e.next=16;break;case 13:return e.next=15,jM();case 15:e.t0=e.sent.find((function(e){return!TL.has(e.deviceId)}));case 16:(i=e.t0)&&(this.log.warn("".concat(n," capture fail ").concat(r," times, change new ").concat(i.deviceId)),n=i.deviceId);case 18:return e.abrupt("return",n);case 19:case"end":return e.stop()}}),e,this)})))}},{key:"close",value:function(){var e;g(i,"close",this,3)([]),this._inputTrack&&(this._inputTrack.stop(),this.uninstallTrackEvent(this._inputTrack)),null==(e=this.manager)||e.removeInput(this)}}])}($M);nR([AP(wP.INIT,"capture",{ignoreError:!0,sync:!0})],yL.prototype,"setStateToCapture",1),nR([mL()],yL.prototype,"capture",1),nR([AP("capture","publish",{ignoreError:!0,success:function(){var e,t,n=this;this.room.localTracks.add(this),rx.emit(ax.LOCAL_TRACK_PUBLISHED,{track:this}),this.emit("4",{mediaType:this.strMediaType,state:"started",prevState:"starting"}),!(((null==(t=null==(e=this.room)?void 0:e.networkQuality)?void 0:t.uplinkNetworkQuality)||0)>3)&&(this._encodeCheckTimeoutId=setTimeout((function(){var e,t;if(!(((null==(t=null==(e=n.room)?void 0:e.networkQuality)?void 0:t.uplinkNetworkQuality)||0)>3)&&n.isPublished&&n.isMediaTrackActive){var r=n.kind===nC.AUDIO,i=n.stat.bytesSent>0;bO[i?"addSuccessEvent":"addFailedEvent"]({key:r?503700:513702}),i||(bO.addEnum({key:r?503701:513703,value:$N()}),jP.uploadEvent({log:"stat-encode-failed-".concat(n.kind,"-").concat(qN()||ZN()),userId:n.userId}),n.log.warn("encode failed"),n.emit("6",n))}}),5e3))},fail:function(e){var t="error";if(e.cause instanceof RTCError){var n=e.cause;n.message.includes("timeout")?t="timeout":n.code===_R.API_CALL_ABORTED&&(t="api-call")}this.emit("4",{mediaType:this.strMediaType,state:"stopped",prevState:"starting",reason:t,error:e.cause||e})}}),gL(521714,!1)],yL.prototype,"publish",1),nR([uL((function(e){return function(){return aR(this,null,f().mark((function t(){var n;return f().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:n="publish"===this.state?"started":"starting",e.call(this),this.emit("4",{mediaType:this.strMediaType,state:"stopped",prevState:n,reason:"api-call"}),clearTimeout(this._encodeCheckTimeoutId);case 2:case"end":return t.stop()}}),t,this)})))}})),AP([],"capture",{sync:!0})],yL.prototype,"unpublish",1);var EL=yL,TL=new Map;rx.on(ax.SWITCH_DEVICE_SUCCESS,(function(e){e.track.deviceId&&TL.delete(e.track.deviceId)}));var kL=function(e){function i(e){var a;return r(this,i),a=n(this,i,[1,XM]),rR(t(a),"mediaType",1),rR(t(a),"volume",0),rR(t(a),"profile",{echoCancellation:!0,autoGainControl:!0,noiseSuppression:!0,sampleRate:48e3,channelCount:1,bitrate:40}),rR(t(a),"playerMuted",!0),rR(t(a),"pipeline"),rR(t(a),"earMonitorGainNode",new SM),rR(t(a),"_output",new SM),rR(t(a),"stat",{bytesSent:0,packetsSent:0,audioLevel:0,totalAudioEnergy:0}),a.manager=e,a.pipeline=new AM(e),a.pipeline.gain.pipeTo(a.earMonitorGainNode.pipeTo(a._output),a.player.pipeline.volumeMeter),a.handleMicrophoneAdded=a.handleMicrophoneAdded.bind(t(a)),a.handleMicrophoneRemoved=a.handleMicrophoneRemoved.bind(t(a)),a}return d(i,e),o(i,[{key:"dbVolume",get:function(){return OM.isRunning?this.player.pipeline.volumeMeter.getVolumeDb():Math.floor(Math.max(10*Math.log10(this.volume)+100,0))}},{key:"getAudioLevel",value:function(){var e=(this.volume||g(i,"getAudioLevel",this,3)([]))*this.captureVolume;return e>1?1:e}},{key:"setInputMediaStreamTrack",value:function(e){return aR(this,null,f().mark((function t(){var n,r,a;return f().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=this.trackSettings||{},bO.addEnum({key:501701,value:n.channelCount||0,useUV:!1}),bO.addEnum({key:501702,value:n.sampleRate||0,useUV:!1}),bO.addEnum({key:502700,value:0}),r=n.sampleRate,a=n.channelCount,this._log.info("local audio track input ".concat(JSON.stringify({sampleRate:r,channelCount:a}))),this.pipeline.replaceSource(e),t.next=7,iR(i.prototype,this,"setInputMediaStreamTrack").call(this,e);case 7:this.updatePlayingState(!!e);case 8:case"end":return t.stop()}}),t,this)})))}},{key:"capture",value:function(e){var t=e.deviceId,n=e.customSource,r=e.useExactDeviceId,a=void 0===r||r,o=e.retryWhenExactFailed,s=void 0===o||o;return g(i,"capture",this,3)([{video:!1,audio:!0,microphoneId:t,echoCancellation:this.profile.echoCancellation,autoGainControl:this.profile.autoGainControl,noiseSuppression:this.profile.noiseSuppression,sampleRate:this.profile.sampleRate,channelCount:this.profile.channelCount,useExactDeviceId:a,retryWhenExactFailed:s,customSource:n}])}},{key:"switchDevice",value:function(e){return aR(this,null,f().mark((function t(){return f().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.mediaTrack){t.next=20;break}if(this.deviceId!==e){t.next=8;break}if(e===qC){t.next=4;break}return t.abrupt("return");case 4:return t.next=6,KM(this.groupId,this.label);case 6:if(!t.sent){t.next=8;break}return t.abrupt("return");case 8:return t.prev=8,this.log.info("switchDevice audio to: ".concat(e)),this.mediaTrack&&this.mediaTrack.stop(),t.next=13,this.capture({deviceId:e,useExactDeviceId:!0,retryWhenExactFailed:!1});case 13:rx.emit(ax.SWITCH_DEVICE_SUCCESS,{track:this}),this.log.info("switch microphone success"),t.next=20;break;case 17:throw t.prev=17,t.t0=t.catch(8),this.log.error("switch microphone failed ".concat(t.t0)),this.deviceId&&this.recapture(this.deviceId),t.t0;case 20:case"end":return t.stop()}}),t,this,[[8,17]])})))}},{key:"listenDeviceChange",value:function(){UM&&!UM.listeners("audioInputRemoved").includes(this.handleMicrophoneRemoved)&&UM.on("audioInputRemoved",this.handleMicrophoneRemoved,this)}},{key:"handleMicrophoneRemoved",value:function(e){return aR(this,null,f().mark((function t(){var n;return f().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(e.deviceId!==this.deviceId){t.next=6;break}return this.log.warn("current microphone is lost: ".concat(JSON.stringify(e))),_F(this.userId,{eventId:2003,param1:6,streamType:1}),t.next=4,jM();case 4:(n=t.sent)[0]?this.recapture(n[0].deviceId):UM.on("audioInputAdded",this.handleMicrophoneAdded,this);case 6:case"end":return t.stop()}}),t,this)})))}},{key:"handleMicrophoneAdded",value:function(e){this.log.warn("microphone added: ".concat(JSON.stringify(e))),this.recapture(e.deviceId)}},{key:"update3A",value:function(e){return aR(this,arguments,(function(e){var t=this,n=e.echoCancellation,r=e.noiseSuppression,i=e.autoGainControl;return f().mark((function e(){var a;return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(a=!1,!Iw(n)&&n!==t.profile.echoCancellation&&(t.profile.echoCancellation=n,a=!0),!Iw(r)&&r!==t.profile.noiseSuppression&&(t.profile.noiseSuppression=r,a=!0),!Iw(i)&&i!==t.profile.autoGainControl&&(t.profile.autoGainControl=i,a=!0),e.t0=a&&t.deviceId,!e.t0){e.next=8;break}return e.next=8,t.recapture(t.deviceId);case 8:case"end":return e.stop()}}),e)}))()}))}},{key:"captureVolume",get:function(){return this.pipeline.volume}},{key:"setCaptureVolume",value:function(e){this.pipeline.setVolume(e/100),this.pipeline.gain.node&&bO.addEnum({key:502700,value:2})}},{key:"setAudioVolume",value:function(e){g(i,"setAudioVolume",this,3)([0]),ID&&this.player.setMuted(!0),this.earMonitorGainNode.node||(this.earMonitorGainNode.setNode(kM().createGain()),this._output.setNode(kM().destination)),this.earMonitorGainNode.node.gain.value=e}},{key:"enableTrackANS",value:function(e){var t=this;if(this._inputTrack){var n=this._inputTrack.getConstraints();return n.noiseSuppression=e,this._inputTrack.applyConstraints(n).catch((function(n){return t._log.warn("".concat(e?"enable":"disable"," ANS failed "),n)}))}}},{key:"addDenoiser",value:function(e){var t;DN<=92&&48e3!==(null==(t=this.trackSettings)?void 0:t.sampleRate)?this._log.warn("denoiser only support sampleRate 48000 before chrome 93"):(bO.addEnum({key:502700,value:1}),this.pipeline.denoiser.setNode(e),this.enableTrackANS(!1))}},{key:"removeDenoiser",value:function(e){this.pipeline.denoiser.node===e&&(this.pipeline.denoiser.deleteNode(),this.enableTrackANS(!0))}},{key:"close",value:function(){this.pipeline.remove(),this.earMonitorGainNode.deleteNode(),this._output.deleteNode(),UM.off("audioInputAdded",this.handleMicrophoneAdded,this),UM.off("audioInputRemoved",this.handleMicrophoneRemoved,this),g(i,"close",this,3)([])}},{key:"recapture",value:function(e){return aR(this,null,f().mark((function t(){var n;return f().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,iR(i.prototype,this,"recapture").call(this,e);case 3:t.next=14;break;case 5:return t.prev=5,t.t0=t.catch(0),t.next=9,jM();case 9:if(n=t.sent.find((function(t){return t.deviceId!==e})),n){t.next=12;break}throw t.t0;case 12:return t.next=14,iR(i.prototype,this,"recapture").call(this,n.deviceId);case 14:case"end":return t.stop()}}),t,this,[[0,5]])})))}},{key:"encodeFrame",value:function(e){return this.manager?this.manager.encodePipeline.reduceRight((function(e,t){return t?t({frame:e}):e}),e):e}},{key:"enableEncodeFrame",get:function(){return!!this.manager&&this.manager.encodePipeline.some((function(e){return e}))}}])}(EL),SL=function(){return o((function e(t){r(this,e);var n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];this.dataView=t,this.isSEI&&(n?this.addPreventionByte():this.removePreventionByte())}),[{key:"addPreventionByte",value:function(){for(var e=this.seiPayloadStartIndex,t=this.dataView.byteLength-2,n=[],r=0,i=e;i<=t;i++){var a=this.dataView.getInt8(i);switch(a){case 0:case 1:case 2:case 3:2===r&&(n.push(3),r=0),0==a?r++:r=0,n.push(a);break;default:r=0,n.push(a)}}n.push(this.dataView.getInt8(this.dataView.byteLength-1));var o=new DataView(new Uint8Array([].concat(E(new Uint8Array(this.dataView.buffer).slice(0,e)),n)).buffer);this.dataView=o}},{key:"removePreventionByte",value:function(){for(var e=this.seiPayloadStartIndex,t=this.dataView.byteLength-1,n=[],r=0,i=e;i<=t;i++)switch(this.dataView.getInt8(i)){case 0:r++,n.push(this.dataView.getInt8(i));break;case 3:2!==r&&n.push(this.dataView.getInt8(i)),r=0;break;default:n.push(this.dataView.getInt8(i)),r=0}var a=new DataView(new Uint8Array([].concat(E(new Uint8Array(this.dataView.buffer).slice(0,e)),n)).buffer);this.dataView=a}},{key:"isSEI",get:function(){return 6===this.dataView.getUint8(4)}},{key:"seiPayloadStartIndex",get:function(){for(var e=6,t=6;t<this.dataView.buffer.byteLength&&(e++,255===this.dataView.getUint8(t));t++);return e}},{key:"seiPayloadType",get:function(){return this.isSEI?this.dataView.getUint8(5):null}},{key:"seiPayload",get:function(){if(!this.isSEI)return null;for(var e=0,t=6,n=6;n<this.dataView.buffer.byteLength;n++){var r=this.dataView.getUint8(n);if(t++,255!==r){e+=r;break}e+=255}for(var i=new ArrayBuffer(e),a=new DataView(i),o=0;o<i.byteLength;o++,t++)a.setInt8(o,this.dataView.getInt8(t));return a}}])}(),IL=function(){return o((function e(){r(this,e),rR(this,"_seiMessageList",[]),rR(this,"_smallSeiMessageList",[]),rR(this,"_seiPayloadType",243)}),[{key:"encodeSEINalu",value:function(e){var t=e.byteLength,n=parseInt(String(t/255),10),r=t%255,i=[];i.push(0,0,0,1,6,this._seiPayloadType);for(var a=0;a<n;a++)i.push(255);i.push(r);var o=new DataView(e);return i.push.apply(i,E(new Uint8Array(o.buffer))),i.push(128),new SL(new DataView(new Uint8Array(i).buffer),!0)}},{key:"sendSEI",value:function(e,t){null!=t&&t.seiPayloadType&&(this._seiPayloadType=t.seiPayloadType),this._seiMessageList.push(e),null!=t&&t.small&&this._smallSeiMessageList.push(e)}},{key:"isEmpty",value:function(){return!this._seiMessageList.length}},{key:"getNaluCount",value:function(e){for(var t=0,n=0,r=new DataView(e),i=0;i<e.byteLength;i++)switch(r.getUint8(i)){case 0:t++;break;case 1:(2===t||3===t)&&n++,t=0;break;default:t=0}return n}},{key:"encode",value:function(e,t){var n=t?this._smallSeiMessageList:this._seiMessageList;if(n.length>0&&e.data.byteLength>0){var r=9-this.getNaluCount(e.data);if(r<=0)return 0;for(var i=n.splice(0,r).reverse().map(this.encodeSEINalu.bind(this)),a=i.reduce((function(e,t){return e+t.dataView.byteLength}),0),o=new ArrayBuffer(a+e.data.byteLength),s=new DataView(o),c=new DataView(e.data),u=0,l=0;l<i.length;l++)for(var d=0;d<i[l].dataView.byteLength;d++)s.setInt8(u++,i[l].dataView.getInt8(d));for(var h=0;h<e.data.byteLength;h++)s.setInt8(u++,c.getInt8(h));return e.data=o,i.length}return 0}}])}(),bL=function(e){function i(e){var a;r(this,i),a=n(this,i,[arguments.length>1&&void 0!==arguments[1]?arguments[1]:4,pM]),rR(t(a),"profile",{width:640,height:480,frameRate:15,bitrate:500}),rR(t(a),"avoidCropping",!1),rR(t(a),"_scaleResolutionDownBy"),rR(t(a),"stat",{bytesSent:0,packetsSent:0,framesEncoded:0,framesSent:0,frameWidth:0,frameHeight:0,fpsCapture:0}),rR(t(a),"small"),rR(t(a),"isNeedToSetBandwidth"),rR(t(a),"muteImage"),rR(t(a),"manager"),rR(t(a),"_seiCodec",new IL),a.manager=e;var o=function(){a.isAllowed2k4k(a.profile)?a.room&&a.settings.height>=1440&&"publish"===a.state&&a.room.sendAbilityStatus({"2k4k":1}):(a.log.warn("Resolution is reset to 1080p, need to upgrade ability here https://cloud.tencent.com/document/product/647/85386"),a.setProfile($A(QA({},a.profile),{width:1920,height:1080})),a.applyProfile())};return a.on("input-media-track-changed",o),a.on("publish",o),a.handleCameraAdded=a.handleCameraAdded.bind(a),a.handleCameraRemoved=a.handleCameraRemoved.bind(a),a}return d(i,e),o(i,[{key:"facingMode",get:function(){if(aP&&this.mediaTrack)return this.mediaTrack.getSettings().facingMode}},{key:"isQosClearFirst",get:function(){var e;return"detail"===(null==(e=this._inputTrack)?void 0:e.contentHint)}},{key:"setMute",value:function(e){return aR(this,null,f().mark((function t(){var n,r,a;return f().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!bw(e)){t.next=11;break}if(this.muteImage!==e){t.next=3;break}return t.abrupt("return");case 3:return t.next=5,null==(n=this.manager)?void 0:n.deleteWatermark("mute");case 5:return t.next=7,null==(r=this.manager)?void 0:r.setWatermark({x:0,y:0,width:this.settings.width,height:this.settings.height,type:"mute",zIndex:999,imageUrl:e});case 7:this.muteImage=e,iR(i.prototype,this,"setMute").call(this,!1),t.next=15;break;case 11:return t.next=13,null==(a=this.manager)?void 0:a.deleteWatermark("mute");case 13:this.muteImage=void 0,iR(i.prototype,this,"setMute").call(this,e);case 15:case"end":return t.stop()}}),t,this)})))}},{key:"capture",value:function(e){var t=e.deviceId,n=e.facingMode,r=e.useExactDeviceId,a=void 0===r||r,o=e.customSource,s=e.retryWhenExactFailed,c=void 0===s||s;return g(i,"capture",this,3)([{audio:!1,video:!0,facingMode:n||this.facingMode,cameraId:t,width:this.profile.width,height:this.profile.height,frameRate:this.profile.frameRate,useExactDeviceId:a,retryWhenExactFailed:c,customSource:o}])}},{key:"setProfile",value:function(e){var t=QA({},e),n=t.width>t.height;t.width*t.height<=19200&&bD&&RN&&(this.log.warn("resolution is ".concat(t.width,"*").concat(t.height,", fallback to 240*180")),t.width=n?240:180,t.height=n?180:240,t.bitrate=Math.max(t.bitrate,150)),t.width*t.height>921600&&BN&&(t.width=n?1280:720,t.height=n?720:1280,this.log.warn("reset to 1280 * 720 on iOS 13~14")),this.avoidCropping&&(RN||wD)&&!KN()&&t.width*t.height<=230400&&t.width/t.height==16/9&&(this._scaleResolutionDownBy=1280/t.width,t.width=1280,t.height=720,this.log.warn("capture 720p, scale: ".concat(this._scaleResolutionDownBy))),t.bitrate&&(this.isNeedToSetBandwidth=t.bitrate!==this.profile.bitrate),this.isAllowed2k4k(this.profile)?g(i,"setProfile",this,3)([t]):(this.log.warn("Resolution is reset to 1080p, need to upgrade ability here https://cloud.tencent.com/document/product/647/85386"),g(i,"setProfile",this,3)([$A(QA({},this.profile),{width:1920,height:1080})]))}},{key:"applyProfile",value:function(){return aR(this,null,f().mark((function e(){var t,n;return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.mediaTrack){e.next=2;break}return e.abrupt("return");case 2:if(n=this.settings,e.t0=(n.height!==this.profile.height||n.width!==this.profile.width||n.frameRate!==this.profile.frameRate)&&this.deviceId,!e.t0){e.next=15;break}if(16!==VN){e.next=10;break}return e.next=8,this.recapture(this.deviceId);case 8:e.next=13;break;case 10:return e.next=12,null==(t=this.mediaTrack)?void 0:t.applyConstraints({width:this.profile.width,height:this.profile.height,frameRate:this.profile.frameRate});case 12:this.manager&&this.manager.changeInput(this);case 13:this.room&&this.settings.height>=1440&&"publish"===this.state&&this.room.sendAbilityStatus({"2k4k":1}),e.t0=this.isNeedToSetBandwidth&&this.room&&this.room.setBandWidth;case 15:if(!e.t0){e.next=19;break}e.t1=(this.isNeedToSetBandwidth=!1,this.room.setBandWidth({bandwidth:this.profile.bitrate,type:nC.VIDEO,videoType:nC.BIG})),e.next=20;break;case 19:e.t1=void 0;case 20:return e.abrupt("return",e.t1);case 21:case"end":return e.stop()}}),e,this)})))}},{key:"settings",get:function(){var e={width:this.profile.width,height:this.profile.height,frameRate:this.profile.frameRate};return aP&&this.mediaTrack&&Object.assign(e,this.mediaTrack.getSettings()),e}},{key:"scaleResolutionDownBy",get:function(){if(this._scaleResolutionDownBy)return this._scaleResolutionDownBy;var e=this.settings;return e.width===this.profile.width&&e.height===this.profile.height?1:Zw()&&this.profile.width>this.profile.height&&e.height>e.width?Math.max(e.width/this.profile.height,e.height/this.profile.width,1):Math.max(e.width/this.profile.width,e.height/this.profile.height,1)}},{key:"isAllowed2k4k",value:function(e){var t;return!(this.room&&this.room.scheduleResult&&!this.isScreen&&!(e.height*e.width<3686400))||1===(null==(t=this.room.scheduleResult.trtcAutoConf)?void 0:t["2k4k"])}},{key:"isNeedToSwitchDevice",value:function(e){return!(!this.mediaTrack||this.deviceId===e||this.facingMode===e)}},{key:"switchDevice",value:function(e){return aR(this,null,f().mark((function t(){var n;return f().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(t.prev=0,this.isNeedToSwitchDevice(e)){t.next=3;break}return t.abrupt("return");case 3:return n={useExactDeviceId:!0,retryWhenExactFailed:!1},"user"===e||"environment"===e?n.facingMode=e:n.deviceId=e,this.mediaTrack.stop(),t.next=8,this.capture(n);case 8:rx.emit(ax.SWITCH_DEVICE_SUCCESS,{track:this}),this.log.info("switch camera success"),t.next=15;break;case 12:throw t.prev=12,t.t0=t.catch(0),this.log.error("switch camera failed ".concat(t.t0)),this.deviceId&&this.recapture(this.deviceId),t.t0;case 15:case"end":return t.stop()}}),t,this,[[0,12]])})))}},{key:"listenDeviceChange",value:function(){UM&&!UM.listeners("videoInputRemoved").includes(this.handleCameraRemoved)&&UM.on("videoInputRemoved",this.handleCameraRemoved,this)}},{key:"handleCameraRemoved",value:function(e){return aR(this,null,f().mark((function t(){var n;return f().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(e.deviceId!==this.deviceId){t.next=6;break}return this.log.warn("current camera is lost: ".concat(JSON.stringify(e))),_F(this.userId,{eventId:2003,param1:7,streamType:2}),t.next=4,HM();case 4:(n=t.sent)[0]?this.recapture(n[0].deviceId):UM.on("videoInputAdded",this.handleCameraAdded,this);case 6:case"end":return t.stop()}}),t,this)})))}},{key:"handleCameraAdded",value:function(e){return aR(this,null,f().mark((function t(){return f().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:this.log.warn("camera added: ".concat(JSON.stringify(e))),this.recapture(e.deviceId);case 1:case"end":return t.stop()}}),t,this)})))}},{key:"encodeFrame",value:function(e,t){if(!this.manager)return e;var n=t?8:this.mediaType;return this.manager.encodePipeline.reduceRight((function(e,t){return t?t({frame:e,mediaType:n}):e}),e)}},{key:"enableEncodeFrame",get:function(){return!!this.manager&&this.manager.encodePipeline.some((function(e){return e}))}},{key:"play",value:function(e,t){return Iw(this.mirror)&&!this.isScreen&&this.setMirror("view"),g(i,"play",this,3)([e,t])}},{key:"close",value:function(){UM.off("videoInputAdded",this.handleCameraAdded,this),UM.off("videoInputRemoved",this.handleCameraRemoved,this),g(i,"close",this,3)([])}},{key:"recapture",value:function(e){return aR(this,null,f().mark((function t(){var n;return f().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,iR(i.prototype,this,"recapture").call(this,e);case 3:t.next=14;break;case 5:return t.prev=5,t.t0=t.catch(0),t.next=9,HM();case 9:if(n=t.sent.find((function(t){return t.deviceId!==e})),n){t.next=12;break}throw t.t0;case 12:return t.next=14,iR(i.prototype,this,"recapture").call(this,n.deviceId);case 14:case"end":return t.stop()}}),t,this,[[0,5]])})))}},{key:"setContentHint",value:function(e){this.mediaTrack&&"contentHint"in this.mediaTrack&&(this.mediaTrack.contentHint!==e&&(this.log.info("setContentHint ".concat(e)),this.mediaTrack.contentHint=e),this.outMediaTrack&&this.outMediaTrack.contentHint!==e&&(this.outMediaTrack.contentHint=e))}}])}(EL);nR([sL((function(e){this.setContentHint(e.contentHint||"motion")}))],bL.prototype,"capture",1);var AL=bL,RL=cx();if("undefined"!=typeof navigator&&navigator.mediaDevices&&"setCaptureHandleConfig"in navigator.mediaDevices)try{navigator.mediaDevices.setCaptureHandleConfig({handle:RL,exposeOrigin:!0,permittedOrigins:["*"]})}catch(GH){}var CL=function(e){return aR(this,null,f().mark((function t(){var n,r,i,a;return f().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=null,r=function(e){var t={preferCurrentTab:"current-tab"===e.preferDisplaySurface||!!e.captureElement,systemAudio:"include",selfBrowserSurface:"include",surfaceSwitching:"include"},n={width:xN?{max:e.width}:{ideal:e.width,max:e.width},height:xN?{max:e.height}:{ideal:e.height,max:e.height},frameRate:e.frameRate,displaySurface:e.preferDisplaySurface||"monitor"};if(t.video=n,e.systemAudio){var r=e.echoCancellation,i=void 0===r||r,a=e.noiseSuppression,o=void 0!==a&&a,s=e.autoGainControl,c=void 0!==s&&s;t.audio={echoCancellation:i,noiseSuppression:o,autoGainControl:c,sampleRate:48e3}}return t}(e),sx.info("getDisplayMedia with constraints: ".concat(JSON.stringify(r))),t.next=4,navigator.mediaDevices.getDisplayMedia(r);case 4:if(i=t.sent,e.systemAudio&&0===i.getAudioTracks().length&&(CN&&DN<74||xN||wD)&&sx.warn("Your browser not support capture system audio"),!(a=i.getVideoTracks()[0])){t.next=21;break}if(!e.frameRate){t.next=17;break}return t.prev=9,t.next=12,a.applyConstraints({frameRate:{min:e.frameRate,ideal:e.frameRate},width:e.width,height:e.height});case 12:t.next=17;break;case 14:t.prev=14,t.t0=t.catch(9),sx.warn("screen applyConstraints failed: ".concat(t.t0));case 17:if(t.t1=e.captureElement,!t.t1){t.next=21;break}return t.next=21,function(e,t){return aR(this,null,f().mark((function n(){var r,i;return f().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(!("CropTarget"in window&&"fromElement"in CropTarget&&Sw(e.cropTo))){n.next=14;break}if(n.prev=1,(null==(r=e.getCaptureHandle())?void 0:r.handle)===RL){n.next=4;break}return n.abrupt("return");case 4:return n.next=6,CropTarget.fromElement(t);case 6:return i=n.sent,n.next=9,e.cropTo(i);case 9:n.next=14;break;case 11:n.prev=11,n.t0=n.catch(1),sx.warn("cropTo target failed ".concat(n.t0));case 14:case"end":return n.stop()}}),n,null,[[1,11]])})))}(a,e.captureElement);case 21:if(!e.audio){t.next=28;break}return r=function(e){var t={echoCancellation:e.echoCancellation,autoGainControl:e.autoGainControl,noiseSuppression:e.noiseSuppression,sampleRate:e.sampleRate,channelCount:e.channelCount};return Iw(e.microphoneId)||(t.deviceId=e.microphoneId),{audio:t,video:!1}}(e),sx.info("getUserMedia with constraints: ".concat(JSON.stringify(r))),t.next=26,navigator.mediaDevices.getUserMedia(r);case 26:n=t.sent,i.addTrack(n.getAudioTracks()[0]);case 28:return t.abrupt("return",i);case 29:case"end":return t.stop()}}),t,null,[[9,14]])})))},wL=function(e){function i(e){var a;return r(this,i),a=n(this,i,[e,2]),rR(t(a),"profile",{width:1920,height:1080,frameRate:5,bitrate:1600}),rR(t(a),"objectFit","contain"),rR(t(a),"isScreen",!0),a._log.id="s-".concat(a._log.id),a}return d(i,e),o(i,[{key:"capture",value:function(e){return aR(this,arguments,(function(e){var t=this,n=e.systemAudio,r=void 0!==n&&n,i=e.autoGainControl,a=e.echoCancellation,o=e.noiseSuppression,s=e.audioTrack,c=e.videoTrack,u=e.captureElement,l=e.preferDisplaySurface;return f().mark((function e(){var n;return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(e.prev=0,!c&&!s){e.next=5;break}n=new MediaStream,c&&n.addTrack(c),s&&n.addTrack(s),e.next=8;break;case 5:return e.next=7,CL({audio:!1,systemAudio:r,width:t.profile.width,height:t.profile.height,frameRate:t.profile.frameRate,autoGainControl:i,echoCancellation:a,noiseSuppression:o,captureElement:u,preferDisplaySurface:l});case 7:n=e.sent;case 8:return e.next=10,t.setInputMediaStreamTrack(n.getVideoTracks()[0]);case 10:return e.abrupt("return",n);case 13:throw e.prev=13,e.t0=e.catch(0),t.log.error("getDisplayMedia error observed ".concat(e.t0)),e.t0 instanceof yR?e.t0:new yR({code:_R.INITIALIZE_FAILED,name:e.t0.name,message:e.t0.message});case 16:case"end":return e.stop()}}),e,null,[[0,13]])}))()}))}},{key:"switchDevice",value:function(e){return aR(this,null,f().mark((function e(){return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:throw new Error("Method not implemented.");case 1:case"end":return e.stop()}}),e)})))}}])}(AL);nR([sL((function(e){this.setContentHint(e.contentHint||"detail")}))],wL.prototype,"capture",1);var DL,NL=function(e){function t(e){var i;return r(this,t),(i=n(this,t,[e]))._log.id="s-".concat(i._log.id),i}return d(t,e),o(t)}(kL);function xL(e){return aR(this,null,f().mark((function t(){var n,r;return f().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=kM(),DL||(DL=mM(n,URL.createObjectURL(new Blob(["registerProcessor('dumper', class extends AudioWorkletProcessor {process(inputs) {this.port.postMessage(inputs);return true;}});"],{type:"application/javascript"})))),t.next=4,DL;case 4:return r=new AudioWorkletNode(n,"dumper",{numberOfInputs:e.length,numberOfOutputs:0}),t.abrupt("return",(e.forEach((function(e,t){return e.connect(r,0,t)})),new ReadableStream({start:function(e){r.port.onmessage=function(t){e.enqueue(t.data)}},cancel:function(){e.forEach((function(e){return e.disconnect(r)})),r.port.close()}})));case 6:case"end":return t.stop()}}),t)})))}var OL=function(e){function i(e){var a;return r(this,i),(a=n(this,i)).room=e,rR(t(a),"_localAudioTrack"),rR(t(a),"_localScreenAudioTrack"),rR(t(a),"log",sx.createLogger({id:"am"})),rR(t(a),"denoiser"),rR(t(a),"voiceChanger"),rR(t(a),"mixChangedDebounce"),rR(t(a),"encodePipeline",[]),rR(t(a),"decodePipeline",[]),e&&(a.log.setUserId(e.userId),a.log.setSdkAppId(e.sdkAppId)),a}return d(i,e),o(i,[{key:"_localAudioPipline",get:function(){var e;return null==(e=this._localAudioTrack)?void 0:e.pipeline}},{key:"dump",value:function(e){var t,n,r=this;if(this._localAudioTrack){var i=[],a=[];null!=(t=this._localAudioPipline)&&t.source.node&&(i.push(this._localAudioPipline.source.node),a.push("mic")),null!=(n=this._localAudioPipline)&&n.denoiser.node&&(i.push(this._localAudioPipline.denoiser.node),a.push("mic-processed")),this.mixWeight>1&&(i.push(this.audioContext.createMediaStreamSource(this._localAudioPipline.stream)),a.push("mix")),this.log.info("dump audio track ".concat(a,", duration: ").concat(e));var o=new AbortController,s=[],c=setTimeout((function(){r.log.info('dump audio track complete please input "download()" to download.'),o.abort("timeout")}),1e3*e),u=function(){for(var e=0;e<a.length;e++){var t=URL.createObjectURL(new Blob(s[e])),n=document.createElement("a");n.href=t,n.download="".concat(a[e],".pcm"),n.style.display="none",document.body.appendChild(n),n.click(),URL.revokeObjectURL(t),n.remove()}clearTimeout(c),o.abort("download")},l=xL(i).then((function(e){return e.pipeTo(new WritableStream({write:function(e){e.forEach((function(e,t){return s[t]=s[t]?s[t].concat(e[0]):[e[0]]}))}}),o).catch((function(e){return u}))}));return{then:l.then.bind(l),download:u}}}},{key:"getPCM",value:function(e){var t,n=this;if(Iw(WritableStream))this.log.warn("getPCM failed: browser not support WritableStream");else{if(null!=(t=this._localAudioPipline)&&t.source.node){this.log.warn("getPCM");var r=new Float32Array(1920),i=0,a=new AbortController;return xL([this._localAudioPipline.source.node]).then((function(t){return t.pipeTo(new WritableStream({write:function(t){t[0][0]&&(r.set(t[0][0],i),(i+=t[0][0].length)>=1920&&(i=0,e(r),r=new Float32Array(1920)))}}),a).catch((function(e){return n.log.warn("stop getPCM reason:".concat(e))}))})),a}this.log.warn("getPCM failed: no local audio track")}}},{key:"hasScreenAudioTrack",get:function(){return null!==this._localScreenAudioTrack}},{key:"hasAudioTrack",get:function(){return!Iw(this._localAudioTrack)}},{key:"changeInput",value:function(e){return e instanceof NL?(this._localScreenAudioTrack=e,e.pipeline.connect(),this.mixOnChange()):e instanceof kL?(this._localAudioTrack=e,this.denoiser&&e.addDenoiser(this.denoiser),e.pipeline.connect(),this.mixOnChange()):e instanceof XU?e.setOutputMediaStreamTrack(e.mediaTrack):void 0}},{key:"mixOnChange",value:function(){var e=this;return this.mixChangedDebounce||(this.mixChangedDebounce=Promise.resolve().then((function(){var t,n;return delete e.mixChangedDebounce,Promise.all([null==(t=e._localAudioTrack)?void 0:t.setOutputMediaStreamTrack(e.mixWeight>1?e.mixTrack:e._localAudioTrack.mediaTrack),null==(n=e._localScreenAudioTrack)?void 0:n.setOutputMediaStreamTrack(e.mixWeight>1?e.mixTrack:e._localScreenAudioTrack.mediaTrack)])}))),this.mixChangedDebounce}},{key:"removeInput",value:function(e){e instanceof NL?delete this._localScreenAudioTrack:e instanceof kL&&delete this._localAudioTrack}},{key:"addDenoiser",value:function(e){var t;this.denoiser=e,null==(t=this._localAudioTrack)||t.addDenoiser(e)}},{key:"removeDenoiser",value:function(e){var t;delete this.denoiser,null==(t=this._localAudioTrack)||t.removeDenoiser(e)}},{key:"addVoiceChanger",value:function(e,t){var n;this.voiceChanger=[e,t],null==(n=this._localAudioTrack)||n.pipeline.voiceChanger.setNode(e,t)}},{key:"removeVoiceChanger",value:function(){var e;delete this.voiceChanger,null==(e=this._localAudioTrack)||e.pipeline.voiceChanger.deleteNode()}},{key:"destroy",value:function(){this.close()}},{key:"addEncodeProcessor",value:function(e){var t,n=e.processor,r=e.type;this.encodePipeline.includes(n)||(this.encodePipeline[r]=n,null==(t=this.room)||t.enableInsertableStreams())}},{key:"addDecodeProcessor",value:function(e){var t,n=e.processor,r=e.type;this.decodePipeline.includes(n)||(this.decodePipeline[r]=n,null==(t=this.room)||t.enableInsertableStreams())}},{key:"removeEncodeProcessor",value:function(e){var t=e.type;this.encodePipeline[t]=void 0}},{key:"removeDecodeProcessor",value:function(e){var t=e.type;this.decodePipeline[t]=void 0}}])}(RM);function PL(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:30,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:2;return uL((function(n,r){return function(){for(var i=this,a=arguments.length,o=new Array(a),s=0;s<a;s++)o[s]=arguments[s];return new Promise((function(a,s){var c=setTimeout((function(){var n=new yR({code:_R.API_CALL_TIMEOUT,message:"checkPendingPromise ".concat(r,"() timeout ").concat(e,"s")});sx.warn(n),2===t?s(n):1===t&&a()}),1e3*e);n.apply(i,o).then(a,s).finally((function(){clearTimeout(c)}))}))}}))}var ML={};function LL(){}eR(ML,{Events:function(){return QL},Inspect:function(){return HL},LastSink:function(){return GL},Sink:function(){return WL},Subscribe:function(){return JL},TimeoutError:function(){return $L},audit:function(){return nU},bindCallback:function(){return NV},bindNodeCallback:function(){return xV},buffer:function(){return dV},bufferCount:function(){return lV},bufferTime:function(){return FU},call:function(){return VL},catchError:function(){return jU},combineLatest:function(){return oV},concat:function(){return rV},concatMap:function(){return RU},concatMapTo:function(){return CU},count:function(){return UV},create:function(){return zL},debounce:function(){return aU},debounceTime:function(){return oU},defer:function(){return pV},delay:function(){return BU},deliver:function(){return YL},dispose:function(){return FL},elementAt:function(){return sU},empty:function(){return MV},every:function(){return hU},exhaustMap:function(){return MU},exhaustMapTo:function(){return LU},filter:function(){return HV},find:function(){return cU},findIndex:function(){return uU},first:function(){return lU},fromAnimationFrame:function(){return wV},fromArray:function(){return gV},fromEvent:function(){return SV},fromEventPattern:function(){return kV},fromFetch:function(){return bV},fromIterable:function(){return AV},fromPromise:function(){return IV},fromReadableStream:function(){return CV},fromReader:function(){return RV},groupBy:function(){return VU},identity:function(){return UL},ignoreElements:function(){return GV},iif:function(){return aV},inspect:function(){return BL},interval:function(){return yV},last:function(){return dU},map:function(){return vU},mapTo:function(){return _U},max:function(){return FV},merge:function(){return tV},mergeMap:function(){return NU},mergeMapTo:function(){return xU},min:function(){return BV},never:function(){return OV},nothing:function(){return LL},of:function(){return _V},pairwise:function(){return pU},pipe:function(){return KL},race:function(){return nV},range:function(){return DV},reduce:function(){return VV},retry:function(){return zU},scan:function(){return fU},share:function(){return eV},shareReplay:function(){return iV},skip:function(){return YV},skipUntil:function(){return qV},skipWhile:function(){return XV},startWith:function(){return cV},subject:function(){return fV},subscribe:function(){return WU},sum:function(){return jV},switchMap:function(){return kU},switchMapTo:function(){return IU},take:function(){return WV},takeLast:function(){return zV},takeUntil:function(){return JV},takeWhile:function(){return KV},tap:function(){return JU},throttle:function(){return eU},throwError:function(){return PV},timeInterval:function(){return UU},timeout:function(){return KU},timer:function(){return EV},toPromise:function(){return HU},toReadableStream:function(){return GU},withLatestFrom:function(){return uV},zip:function(){return sV}});var VL=function(e){return e()},UL=function(e){return e};function FL(){this.dispose()}var BL=function(){return"undefined"!=typeof __FASTRX_DEVTOOLS__},jL=1,HL=function(e){function t(){return r(this,t),n(this,t,arguments)}return d(t,e),o(t,[{key:"toString",value:function(){return"".concat(this.name,"(").concat(this.args.length?E(this.args).join(", "):"",")")}},{key:"subscribe",value:function(e){var t=new XL(e,this,this.streamId++);return QL.subscribe({id:this.id,end:!1},{nodeId:t.sourceId,streamId:t.id}),this(t),t}}])}(I(Function)),GL=function(){return o((function e(){r(this,e),this.defers=new Set,this.disposed=!1}),[{key:"next",value:function(e){}},{key:"complete",value:function(){this.dispose()}},{key:"error",value:function(e){this.dispose()}},{key:"bindDispose",get:function(){var e=this;return function(){return e.dispose()}}},{key:"dispose",value:function(){this.disposed=!0,this.complete=LL,this.error=LL,this.next=LL,this.dispose=LL,this.subscribe=LL,this.doDefer()}},{key:"subscribe",value:function(e){return e instanceof HL?e.subscribe(this):e(this),this}},{key:"bindSubscribe",get:function(){var e=this;return function(t){return e.subscribe(t)}}},{key:"doDefer",value:function(){this.defers.forEach(VL),this.defers.clear()}},{key:"defer",value:function(e){this.defers.add(e)}},{key:"removeDefer",value:function(e){this.defers.delete(e)}},{key:"reset",value:function(){this.disposed=!1,delete this.complete,delete this.next,delete this.dispose,delete this.next,delete this.subscribe}},{key:"resetNext",value:function(){delete this.next}},{key:"resetComplete",value:function(){delete this.complete}},{key:"resetError",value:function(){delete this.error}}])}(),WL=function(e){function t(e){var i;return r(this,t),(i=n(this,t)).sink=e,e.defer(i.bindDispose),i}return d(t,e),o(t,[{key:"next",value:function(e){this.sink.next(e)}},{key:"complete",value:function(){this.sink.complete()}},{key:"error",value:function(e){this.sink.error(e)}}])}(GL),JL=function(e){function t(e){var i;r(this,t);var a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:LL,o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:LL,s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:LL;if((i=n(this,t))._next=a,i._error=o,i._complete=s,i.then=LL,e instanceof HL){var c={toString:function(){return"subscribe"},id:0,source:e};i.defer((function(){QL.defer(c,0)})),QL.create(c),QL.pipe(c),i.sourceId=c.id,i.subscribe(e),QL.subscribe({id:c.id,end:!0}),a==LL?i._next=function(e){return QL.next(c,0,e)}:i.next=function(e){QL.next(c,0,e),a(e)},s==LL?i._complete=function(){return QL.complete(c,0)}:i.complete=function(){i.dispose(),QL.complete(c,0),s()},o==LL?i._error=function(e){return QL.complete(c,0,e)}:i.error=function(e){i.dispose(),QL.complete(c,0,e),o()}}else i.subscribe(e);return i}return d(t,e),o(t,[{key:"next",value:function(e){this._next(e)}},{key:"complete",value:function(){this.dispose(),this._complete()}},{key:"error",value:function(e){this.dispose(),this._error(e)}}])}(GL);function KL(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r];return n.reduce((function(e,t){return t(e)}),e)}function zL(e,t,n){if(BL()){var r=Object.defineProperties(Object.setPrototypeOf(e,HL.prototype),{streamId:{value:0,writable:!0,configurable:!0},name:{value:t,writable:!0,configurable:!0},args:{value:n,writable:!0,configurable:!0},id:{value:0,writable:!0,configurable:!0}});QL.create(r);for(var i=0;i<n.length;i++){var a=n[i];"function"==typeof a&&a instanceof HL&&QL.addSource(r,a)}return r}return e}function YL(e,t){return function(){for(var n=arguments,r=arguments.length,a=new Array(r),o=0;o<r;o++)a[o]=arguments[o];return function(r){if(r instanceof HL){var o=zL((function(t){var n=i(e,[t].concat(a));n.sourceId=o.id,n.subscribe(r)}),t,n);return o.source=r,QL.pipe(o),o}return function(t){return r(i(e,[t].concat(a)))}}}}function qL(e,t){window.postMessage({source:"fastrx-devtools-backend",payload:{event:e,payload:t}})}var XL=function(e){function t(e,i,a){var o;return r(this,t),(o=n(this,t,[e])).source=i,o.id=a,o.sourceId=e.sourceId,o.defer((function(){QL.defer(o.source,o.id)})),o}return d(t,e),o(t,[{key:"next",value:function(e){QL.next(this.source,this.id,e),this.sink.next(e)}},{key:"complete",value:function(){QL.complete(this.source,this.id),this.sink.complete()}},{key:"error",value:function(e){QL.complete(this.source,this.id,e),this.sink.error(e)}}])}(WL),QL={addSource:function(e,t){qL("addSource",{id:e.id,name:e.toString(),source:{id:t.id,name:t.toString()}})},next:function(e,t,n){qL("next",{id:e.id,streamId:t,data:n&&n.toString()})},subscribe:function(e,t){qL("subscribe",{id:e.id,end:e.end,sink:{nodeId:t&&t.nodeId,streamId:t&&t.streamId}})},complete:function(e,t,n){qL("complete",{id:e.id,streamId:t,err:n?n.toString():null})},defer:function(e,t){qL("defer",{id:e.id,streamId:t})},pipe:function(e){qL("pipe",{name:e.toString(),id:e.id,source:{id:e.source.id,name:e.source.toString()}})},update:function(e){qL("update",{id:e.id,name:e.toString()})},create:function(e){e.id||(e.id=jL++),qL("create",{name:e.toString(),id:e.id})}},$L=function(e){function t(e){var i;return r(this,t),(i=n(this,t,["timeout after ".concat(e,"ms")])).timeout=e,i}return d(t,e),o(t)}(I(Error)),ZL=function(e){function t(e){var i;return r(this,t),(i=n(this,t)).source=e,i.sinks=new Set,i}return d(t,e),o(t,[{key:"add",value:function(e){var t=this;e.defer((function(){return t.remove(e)})),1===this.sinks.add(e).size&&(this.reset(),this.subscribe(this.source))}},{key:"remove",value:function(e){this.sinks.delete(e),0===this.sinks.size&&this.dispose()}},{key:"next",value:function(e){this.sinks.forEach((function(t){return t.next(e)}))}},{key:"complete",value:function(){this.sinks.forEach((function(e){return e.complete()})),this.sinks.clear()}},{key:"error",value:function(e){this.sinks.forEach((function(t){return t.error(e)})),this.sinks.clear()}}])}(GL);function eV(){var e=arguments;return function(t){var n=new ZL(t);if(t instanceof HL){var r=zL((function(e){n.add(e)}),"share",e);return n.sourceId=r.id,r.source=t,QL.pipe(r),r}return zL(n.add.bind(n),"share",e)}}function tV(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return zL((function(e){var n=new WL(e),r=t.length;n.complete=function(){0==--r&&e.complete()},t.forEach(n.bindSubscribe)}),"merge",arguments)}function nV(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return zL((function(e){var n=new Map;t.forEach((function(t){var r=new WL(e);n.set(t,r),r.complete=function(){n.delete(t),0===n.size?e.complete():r.dispose()},r.next=function(e){n.delete(t),n.forEach((function(e){return e.dispose()})),r.resetNext(),r.resetComplete(),r.next(e)}})),t.forEach((function(e){return n.get(e).subscribe(e)}))}),"race",arguments)}function rV(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return zL((function(e){var n=0,r=t.length,i=new WL(e);i.complete=function(){n<r&&!i.disposed?(i.doDefer(),i.subscribe(t[n++])):e.complete()},i.complete()}),"concat",arguments)}function iV(e){var t=arguments;return function(n){var r=new ZL(n),i=[];return r.next=function(t){i.push(t),i.length>e&&i.shift(),this.sinks.forEach((function(e){return e.next(t)}))},zL((function(e){e.defer((function(){return r.remove(e)})),i.forEach((function(t){return e.next(t)})),r.add(e)}),"shareReplay",t)}}function aV(e,t,n){return zL((function(r){return e()?t(r):n(r)}),"iif",arguments)}function oV(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return zL((function(e){var n=t.length,r=n,i=n,a=new Array(n),o=function(){0==--i&&e.complete()};t.forEach((function(t,n){var i=new WL(e);i.next=function(t){0==--r?(i.next=function(t){a[n]=t,e.next(a)},i.next(t)):a[n]=t},i.complete=o,i.subscribe(t)}))}),"combineLatest",arguments)}function sV(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return zL((function(e){var n=t.length,r=n,i=new Array(n),a=function(){0==--r&&e.complete()};t.forEach((function(t,n){var r=new WL(e),o=[];i[n]=o,r.next=function(t){o.push(t),i.every((function(e){return e.length}))&&e.next(i.map((function(e){return e.shift()})))},r.complete=a,r.subscribe(t)}))}),"zip",arguments)}function cV(){for(var e=arguments,t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return function(t){return zL((function(e){for(var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:n.length;r<i&&!e.disposed;)e.next(n[r++]);e.disposed||e.subscribe(t)}),"startWith",e)}}var uV=YL(function(e){function t(e){var i;r(this,t),i=n(this,t,[e]);for(var a=new WL(i.sink),o=arguments.length,s=new Array(o>1?o-1:0),c=1;c<o;c++)s[c-1]=arguments[c];return a.next=function(e){return i.buffer=e},a.complete=LL,a.subscribe(oV.apply(void 0,s)),i}return d(t,e),o(t,[{key:"next",value:function(e){this.buffer&&this.sink.next([e].concat(E(this.buffer)))}}])}(WL),"withLatestFrom"),lV=YL(function(e){function t(e,i,a){var o;return r(this,t),(o=n(this,t,[e])).bufferSize=i,o.startBufferEvery=a,o.buffer=[],o.count=0,o.startBufferEvery&&(o.buffers=[[]]),o}return d(t,e),o(t,[{key:"next",value:function(e){this.startBufferEvery?(this.count++===this.startBufferEvery&&(this.buffers.push([]),this.count=1),this.buffers.forEach((function(t){t.push(e)})),this.buffers[0].length===this.bufferSize&&this.sink.next(this.buffers.shift())):(this.buffer.push(e),this.buffer.length===this.bufferSize&&(this.sink.next(this.buffer),this.buffer=[]))}},{key:"complete",value:function(){var e=this;this.buffer.length?this.sink.next(this.buffer):this.buffers.length&&this.buffers.forEach((function(t){return e.sink.next(t)})),g(t,"complete",this,3)([])}}])}(WL),"bufferCount"),dV=YL(function(e){function t(e,i){var a;r(this,t),(a=n(this,t,[e])).buffer=[];var o=new WL(e);return o.next=function(t){e.next(a.buffer),a.buffer=[]},o.complete=LL,o.subscribe(i),a}return d(t,e),o(t,[{key:"next",value:function(e){this.buffer.push(e)}},{key:"complete",value:function(){this.buffer.length&&this.sink.next(this.buffer),g(t,"complete",this,3)([])}}])}(WL),"buffer"),hV=function(e,t,n,r){return new(n||(n=Promise))((function(i,a){function o(e){try{c(r.next(e))}catch(hx){a(hx)}}function s(e){try{c(r.throw(e))}catch(hx){a(hx)}}function c(e){e.done?i(e.value):function(e){return e instanceof n?e:new n((function(t){t(e)}))}(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())}))};function fV(e){var t=arguments,n=eV()(zL((function(t){n.next=function(e){return t.next(e)},n.complete=function(){return t.complete()},n.error=function(e){return t.error(e)},e&&t.subscribe(e)}),"subject",t));return n.next=LL,n.complete=LL,n.error=LL,n}function pV(e){return zL((function(t){return t.subscribe(e())}),"defer",arguments)}var mV=function(e){return function(t){setTimeout((function(){return e(t)}))}},vV=function(e){return mV((function(t){for(var n=0;!t.disposed&&n<e.length;n++)t.next(e[n]);t.complete()}))};function _V(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return zL(vV(t),"of",arguments)}function gV(e){return zL(vV(e),"fromArray",arguments)}function yV(e){return zL((function(t){var n=0,r=setInterval((function(){return t.next(n++)}),e);return t.defer((function(){clearInterval(r)})),"interval"}),"interval",arguments)}function EV(e,t){return zL((function(n){var r=0,i=setTimeout((function(){if(n.removeDefer(a),n.next(r++),t){var e=setInterval((function(){return n.next(r++)}),t);n.defer((function(){clearInterval(e)}))}else n.complete()}),e),a=function(){clearTimeout(i)};n.defer(a)}),"timer",arguments)}function TV(e,t){return function(n){var r=function(e){return n.next(e)};n.defer((function(){return t(r)})),e(r)}}function kV(e,t){return zL(TV(e,t),"fromEventPattern",arguments)}function SV(e,t){if("on"in e&&"off"in e)return zL(TV((function(n){return e.on(t,n)}),(function(n){return e.off(t,n)})),"fromEvent",arguments);if("addListener"in e&&"removeListener"in e)return zL(TV((function(n){return e.addListener(t,n)}),(function(n){return e.removeListener(t,n)})),"fromEvent",arguments);if("addEventListener"in e)return zL(TV((function(n){return e.addEventListener(t,n)}),(function(n){return e.removeEventListener(t,n)})),"fromEvent",arguments);throw"target is not a EventDispachter"}function IV(e){return zL((function(t){e.then(t.next.bind(t),t.error.bind(t))}),"fromPromise",arguments)}function bV(e,t){return zL(pV((function(){return IV(fetch(e,t))})),"fromFetch",arguments)}function AV(e){return zL(mV((function(t){try{var n,r=s(e);try{for(r.s();!(n=r.n()).done;){var i=n.value;if(t.disposed)return;t.next(i)}}catch(a){r.e(a)}finally{r.f()}t.complete()}catch(wR){t.error(wR)}})),"fromIterable",arguments)}function RV(e){var t=this,n=function(r){return hV(t,void 0,void 0,f().mark((function t(){var i,a,o;return f().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!r.disposed){t.next=2;break}return t.abrupt("return");case 2:return t.next=4,e.read();case 4:i=t.sent,a=i.done,o=i.value,a?r.complete():(r.next(o),n(r));case 8:case"end":return t.stop()}}),t)})))};return zL((function(e){n(e)}),"fromReader",arguments)}function CV(e){return zL((function(t){var n=new AbortController,r=n.signal;t.defer((function(){return n.abort("cancelled")})),e.pipeTo(new WritableStream({write:function(e){t.next(e)},close:function(){t.complete()},abort:function(e){t.error(e)}}),{signal:r}).then((function(){return t.complete()}),(function(e){return t.error(e)}))}),"fromReadableStream",arguments)}function wV(){return zL((function(e){var t=requestAnimationFrame((function n(r){e.disposed||(e.next(r),t=requestAnimationFrame(n))}));e.defer((function(){return cancelAnimationFrame(t)}))}),"fromAnimationFrame",arguments)}function DV(e,t){return zL((function(n){for(var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:e,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:t+e;r<i&&!n.disposed;)n.next(r++);return n.complete(),"range"}),"range",arguments)}function NV(e,t){for(var n=arguments.length,r=new Array(n>2?n-2:0),i=2;i<n;i++)r[i-2]=arguments[i];return zL((function(n){var i=r.concat((function(e){return n.next(e),n.complete()}));e.apply(t,i)}),"bindCallback",arguments)}function xV(e,t){for(var n=arguments.length,r=new Array(n>2?n-2:0),i=2;i<n;i++)r[i-2]=arguments[i];return zL((function(n){var i=r.concat((function(e,t){return e?n.error(e):(n.next(t),n.complete())}));e.apply(t,i)}),"bindNodeCallback",arguments)}function OV(){return zL((function(){}),"never",arguments)}function PV(e){return zL((function(t){return t.error(e)}),"throwError",arguments)}function MV(){return zL((function(e){return e.complete()}),"empty",arguments)}var LV=function(e){function t(e,i,a){var o;r(this,t),(o=n(this,t,[e])).f=i;var s=function(){o.sink.next(o.acc),o.sink.complete()};return void 0===a?o.next=function(e){o.acc=e,o.complete=s,o.resetNext()}:(o.acc=a,o.complete=s),o}return d(t,e),o(t,[{key:"next",value:function(e){this.acc=this.f(this.acc,e)}}])}(WL),VV=YL(LV,"reduce"),UV=function(e){return YL(LV,"count")((function(t,n){return e(n)?t+1:t}),0)},FV=function(){return YL(LV,"max")(Math.max)},BV=function(){return YL(LV,"min")(Math.min)},jV=function(){return YL(LV,"sum")((function(e,t){return e+t}),0)},HV=YL(function(e){function t(e,i,a){var o;return r(this,t),(o=n(this,t,[e])).filter=i,o.thisArg=a,o}return d(t,e),o(t,[{key:"next",value:function(e){this.filter.call(this.thisArg,e)&&this.sink.next(e)}}])}(WL),"filter"),GV=YL(function(e){function t(){return r(this,t),n(this,t,arguments)}return d(t,e),o(t,[{key:"next",value:function(e){}}])}(WL),"ignoreElements"),WV=YL(function(e){function t(e,i){var a;return r(this,t),(a=n(this,t,[e])).count=i,a}return d(t,e),o(t,[{key:"next",value:function(e){this.sink.next(e),0==--this.count&&this.complete()}}])}(WL),"take"),JV=YL(function(e){function t(e,i){var a;r(this,t),a=n(this,t,[e]);var o=new WL(e);return o.next=function(){return e.complete()},o.complete=FL,o.subscribe(i),a}return d(t,e),o(t)}(WL),"takeUntil"),KV=YL(function(e){function t(e,i){var a;return r(this,t),(a=n(this,t,[e])).f=i,a}return d(t,e),o(t,[{key:"next",value:function(e){this.f(e)?this.sink.next(e):this.complete()}}])}(WL),"takeWhile"),zV=function(e){return VV((function(t,n){return t.push(n),t.length>e&&t.shift(),t}),[])},YV=YL(function(e){function t(e,i){var a;return r(this,t),(a=n(this,t,[e])).count=i,a}return d(t,e),o(t,[{key:"next",value:function(e){0==--this.count&&(this.next=g(t,"next",this,1))}}])}(WL),"skip"),qV=YL(function(e){function t(e,i){var a;r(this,t),a=n(this,t,[e]),e.next=LL;var o=new WL(e);return o.next=function(){o.dispose(),e.resetNext()},o.complete=FL,o.subscribe(i),a}return d(t,e),o(t)}(WL),"skipUntil"),XV=YL(function(e){function t(e,i){var a;return r(this,t),(a=n(this,t,[e])).f=i,a}return d(t,e),o(t,[{key:"next",value:function(e){this.f(e)||(this.next=g(t,"next",this,1),this.next(e))}}])}(WL),"skipWhile"),QV={leading:!0,trailing:!1},$V=function(e){function t(e,i,a){var o;return r(this,t),(o=n(this,t,[e])).durationSelector=i,o.trailing=a,o}return d(t,e),o(t,[{key:"cacheValue",value:function(e){this.last=e,this.disposed&&this.throttle(e)}},{key:"send",value:function(e){this.sink.next(e),this.throttle(e)}},{key:"throttle",value:function(e){this.reset(),this.subscribe(this.durationSelector(e))}},{key:"next",value:function(){this.complete()}},{key:"complete",value:function(){this.dispose(),this.trailing&&this.send(this.last)}}])}(WL),ZV=function(e){function t(e,i){var a;r(this,t);var o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:QV;return(a=n(this,t,[e])).durationSelector=i,a.config=o,a._throttle=new $V(a.sink,a.durationSelector,a.config.trailing),a._throttle.dispose(),a}return d(t,e),o(t,[{key:"next",value:function(e){this._throttle.disposed&&this.config.leading?this._throttle.send(e):this._throttle.cacheValue(e)}},{key:"complete",value:function(){this._throttle.throttle=LL,this._throttle.complete(),g(t,"complete",this,3)([])}}])}(WL),eU=YL(ZV,"throttle"),tU={leading:!1,trailing:!0},nU=function(e){return YL(ZV,"audit")(e,tU)},rU=function(e){function t(){return r(this,t),n(this,t,arguments)}return d(t,e),o(t,[{key:"next",value:function(){this.complete()}},{key:"complete",value:function(){this.dispose(),this.sink.next(this.last)}}])}(WL),iU=function(e){function t(e,i){var a;return r(this,t),(a=n(this,t,[e])).durationSelector=i,a._debounce=new rU(a.sink),a._debounce.dispose(),a}return d(t,e),o(t,[{key:"next",value:function(e){this._debounce.dispose(),this._debounce.reset(),this._debounce.last=e,this._debounce.subscribe(this.durationSelector(e))}},{key:"complete",value:function(){this._debounce.complete(),g(t,"complete",this,3)([])}}])}(WL),aU=YL(iU,"debounce"),oU=function(e){return YL(iU,"debounceTime")((function(t){return EV(e)}))},sU=YL(function(e){function t(e,i,a){var o;return r(this,t),(o=n(this,t,[e])).count=i,o.defaultValue=a,o}return d(t,e),o(t,[{key:"next",value:function(e){0==this.count--&&(this.defaultValue=e,this.complete())}},{key:"complete",value:function(){void 0!==this.defaultValue?(this.sink.next(this.defaultValue),g(t,"complete",this,3)([])):this.error(new Error("not enough elements in sequence"))}}])}(WL),"elementAt"),cU=function(e){return function(t){return WV(1)(XV((function(t){return!e(t)}))(t))}},uU=YL(function(e){function t(e,i){var a;return r(this,t),(a=n(this,t,[e])).f=i,a.i=0,a}return d(t,e),o(t,[{key:"next",value:function(e){this.f(e)?(this.sink.next(this.i++),this.complete()):++this.i}}])}(WL),"findIndex"),lU=YL(function(e){function t(e,i,a){var o;return r(this,t),(o=n(this,t,[e])).f=i,o.defaultValue=a,o.index=0,o}return d(t,e),o(t,[{key:"next",value:function(e){(!this.f||this.f(e,this.index++))&&(this.defaultValue=e,this.complete())}},{key:"complete",value:function(){void 0!==this.defaultValue?(this.sink.next(this.defaultValue),g(t,"complete",this,3)([])):this.error(new Error("no elements in sequence"))}}])}(WL),"first"),dU=YL(function(e){function t(e,i,a){var o;return r(this,t),(o=n(this,t,[e])).f=i,o.defaultValue=a,o.index=0,o}return d(t,e),o(t,[{key:"next",value:function(e){(!this.f||this.f(e,this.index++))&&(this.defaultValue=e)}},{key:"complete",value:function(){void 0!==this.defaultValue?(this.sink.next(this.defaultValue),g(t,"complete",this,3)([])):this.error(new Error("no elements in sequence"))}}])}(WL),"last"),hU=YL(function(e){function t(e,i){var a;return r(this,t),(a=n(this,t,[e])).predicate=i,a.index=0,a}return d(t,e),o(t,[{key:"next",value:function(e){this.predicate(e,this.index++)?this.result=!0:(this.result=!1,this.complete())}},{key:"complete",value:function(){void 0!==this.result?(this.sink.next(this.result),g(t,"complete",this,3)([])):this.error(new Error("no elements in sequence"))}}])}(WL),"every"),fU=YL(function(e){function t(e,i,a){var o;return r(this,t),(o=n(this,t,[e])).f=i,void 0===a?o.next=function(e){o.acc=e,o.resetNext(),o.sink.next(o.acc)}:o.acc=a,o}return d(t,e),o(t,[{key:"next",value:function(e){this.sink.next(this.acc=this.f(this.acc,e))}}])}(WL),"scan"),pU=YL(function(e){function t(){var e;return r(this,t),(e=n(this,t,arguments)).hasLast=!1,e}return d(t,e),o(t,[{key:"next",value:function(e){this.hasLast?this.sink.next([this.last,e]):this.hasLast=!0,this.last=e}}])}(WL),"pairwise"),mU=function(e){function t(e,i,a){var o;return r(this,t),(o=n(this,t,[e])).mapper=i,o.thisArg=a,o}return d(t,e),o(t,[{key:"next",value:function(e){g(t,"next",this,3)([this.mapper.call(this.thisArg,e)])}}])}(WL),vU=YL(mU,"map"),_U=function(e){return YL(mU,"mapTo")((function(t){return e}))},gU=function(e){function t(e,i,a){var o;return r(this,t),(o=n(this,t,[e])).data=i,o.context=a,o}return d(t,e),o(t,[{key:"next",value:function(e){var t=this.context.combineResults;t?this.sink.next(t(this.data,e)):this.sink.next(e)}},{key:"tryComplete",value:function(){this.context.resetComplete(),this.dispose()}}])}(WL),yU=function(e){function t(e,i,a){var o;return r(this,t),(o=n(this,t,[e])).makeSource=i,o.combineResults=a,o.index=0,o}return d(t,e),o(t,[{key:"subInner",value:function(e,t){var n=this.currentSink=new t(this.sink,e,this);this.complete=this.tryComplete,n.complete=n.tryComplete,n.subscribe(this.makeSource(e,this.index++))}},{key:"tryComplete",value:function(){this.currentSink.resetComplete(),this.dispose()}}])}(WL),EU=function(e){function t(){return r(this,t),n(this,t,arguments)}return d(t,e),o(t)}(gU),TU=function(e){function t(){return r(this,t),n(this,t,arguments)}return d(t,e),o(t,[{key:"next",value:function(e){var t=this;this.subInner(e,EU),this.next=function(e){t.currentSink.dispose(),t.subInner(e,EU)}}}])}(yU),kU=YL(TU,"switchMap");function SU(e){return function(t,n){return e((function(){return t}),n)}}var IU=SU(YL(TU,"switchMapTo")),bU=function(e){function t(){return r(this,t),n(this,t,arguments)}return d(t,e),o(t,[{key:"tryComplete",value:function(){this.dispose(),this.context.sources.length?this.context.subNext():(this.context.resetNext(),this.context.resetComplete())}}])}(gU),AU=function(e){function t(){var e;return r(this,t),(e=n(this,t,arguments)).sources=[],e.next2=e.sources.push.bind(e.sources),e}return d(t,e),o(t,[{key:"next",value:function(e){this.next2(e),this.subNext()}},{key:"subNext",value:function(){this.next=this.next2,this.subInner(this.sources.shift(),bU),this.disposed&&0===this.sources.length&&this.currentSink.resetComplete()}},{key:"tryComplete",value:function(){0===this.sources.length&&this.currentSink.resetComplete(),this.dispose()}}])}(yU),RU=YL(AU,"concatMap"),CU=SU(YL(AU,"concatMapTo")),wU=function(e){function t(){return r(this,t),n(this,t,arguments)}return d(t,e),o(t,[{key:"tryComplete",value:function(){this.context.inners.delete(this),g(t,"dispose",this,3)([]),0===this.context.inners.size&&this.context.resetComplete()}}])}(gU),DU=function(e){function t(){var e;return r(this,t),(e=n(this,t,arguments)).inners=new Set,e}return d(t,e),o(t,[{key:"next",value:function(e){this.subInner(e,wU),this.inners.add(this.currentSink)}},{key:"tryComplete",value:function(){1===this.inners.size?this.inners.forEach((function(e){return e.resetComplete()})):this.dispose()}}])}(yU),NU=YL(DU,"mergeMap"),xU=SU(YL(DU,"mergeMapTo")),OU=function(e){function t(){return r(this,t),n(this,t,arguments)}return d(t,e),o(t,[{key:"dispose",value:function(){this.context.resetNext(),g(t,"dispose",this,3)([])}}])}(gU),PU=function(e){function t(){return r(this,t),n(this,t,arguments)}return d(t,e),o(t,[{key:"next",value:function(e){this.next=LL,this.subInner(e,OU)}}])}(yU),MU=YL(PU,"exhaustMap"),LU=SU(YL(PU,"exhaustMapTo")),VU=YL(function(e){function t(e,i){var a;return r(this,t),(a=n(this,t,[e])).f=i,a.groups=new Map,a}return d(t,e),o(t,[{key:"next",value:function(e){var n=this.f(e),r=this.groups.get(n);void 0===r&&((r=fV()).key=n,this.groups.set(n,r),g(t,"next",this,3)([r])),r.next(e)}},{key:"complete",value:function(){this.groups.forEach((function(e){return e.complete()})),g(t,"complete",this,3)([])}},{key:"error",value:function(e){this.groups.forEach((function(t){return t.error(e)})),g(t,"error",this,3)([e])}}])}(WL),"groupBy"),UU=YL(function(e){function t(){var e;return r(this,t),(e=n(this,t,arguments)).start=new Date,e}return d(t,e),o(t,[{key:"next",value:function(e){this.sink.next({value:e,interval:Number(new Date)-Number(this.start)}),this.start=new Date}}])}(WL),"timeInterval"),FU=YL(function(e){function t(e,i){var a;return r(this,t),(a=n(this,t,[e])).miniseconds=i,a.buffer=[],a.id=setInterval((function(){a.sink.next(a.buffer.concat()),a.buffer.length=0}),a.miniseconds),a}return d(t,e),o(t,[{key:"next",value:function(e){this.buffer.push(e)}},{key:"complete",value:function(){this.sink.next(this.buffer),g(t,"complete",this,3)([])}},{key:"dispose",value:function(){clearInterval(this.id),g(t,"dispose",this,3)([])}}])}(WL),"bufferTime"),BU=YL(function(e){function t(e,i){var a;return r(this,t),(a=n(this,t,[e])).buffer=[],a.delayTime=i,a}return d(t,e),o(t,[{key:"dispose",value:function(){clearTimeout(this.timeoutId),g(t,"dispose",this,3)([])}},{key:"delay",value:function(e){var n=this;this.timeoutId=setTimeout((function(){var e=n.buffer.shift();if(e){var r=e.time,i=e.data;g(t,"next",n,3)([i]),n.buffer.length&&n.delay(Number(n.buffer[0].time)-Number(r))}}),e)}},{key:"next",value:function(e){this.buffer.length||this.delay(this.delayTime),this.buffer.push({time:new Date,data:e})}},{key:"complete",value:function(){var e=this;this.timeoutId=setTimeout((function(){return g(t,"complete",e,3)([])}),this.delayTime)}}])}(WL),"delay"),jU=YL(function(e){function t(e,i){var a;return r(this,t),(a=n(this,t,[e])).selector=i,a}return d(t,e),o(t,[{key:"error",value:function(e){this.dispose(),this.selector(e)(this.sink)}}])}(WL),"catchError"),HU=function(){return function(e){return new Promise((function(t,n){var r;new JL(e,(function(e){return r=e}),n,(function(){return t(r)}))}))}},GU=function(){return function(e){var t;return new ReadableStream({start:function(n){t=new JL(e,n.enqueue.bind(n),n.error.bind(n),n.close.bind(n))},cancel:function(){t.dispose()}})}},WU=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:LL,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:LL,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:LL;return function(r){return new JL(r,e,t,n)}},JU=YL(function(e){function t(e,i){var a;return r(this,t),a=n(this,t,[e]),i instanceof Function?a.next=function(t){i(t),e.next(t)}:(i.next&&(a.next=function(t){i.next(t),e.next(t)}),i.complete&&(a.complete=function(){i.complete(),e.complete()}),i.error&&(a.error=function(t){i.error(t),e.error(t)})),a}return d(t,e),o(t)}(WL),"tap"),KU=YL(function(e){function t(e,i){var a;return r(this,t),(a=n(this,t,[e])).timeout=i,a.id=setTimeout((function(){return a.error(new $L(a.timeout))}),a.timeout),a}return d(t,e),o(t,[{key:"next",value:function(e){g(t,"next",this,3)([e]),clearTimeout(this.id),this.next=g(t,"next",this,1)}},{key:"dispose",value:function(){clearTimeout(this.id),g(t,"dispose",this,3)([])}}])}(WL),"timeout"),zU=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1/0;return function(t){if(t instanceof HL){var n=zL((function(r){var i=e,a=new WL(r);a.error=function(e){i-- >0?a.subscribe(t):r.error(e)},a.sourceId=n.id,a.subscribe(t)}),"retry",[e]);return n.source=t,QL.pipe(n),n}return function(n){var r=e,i=new WL(n);i.error=function(e){r-- >0?t(i):n.error(e)},t(i)}}},YU=function(e){function i(e,a,o){var s;r(this,i),(s=n(this,i,[{userId:a.userId,sdkAppId:e.sdkAppId,mediaType:o,room:e}])).room=e,s.user=a,rR(t(s),"tinyId"),rR(t(s),"isRemote",!0),rR(t(s),"jitterBufferDelay",0),rR(t(s),"availableState"),rR(t(s),"remotePublishState"),rR(t(s),"_triggerCheckDecodeSubject",fV(SV(t(s),i.STATE_SUBSCRIBE))),s.tinyId=a.tinyId,s.availableState=new wP("".concat(a.userId,"-").concat(s.mediaType,"-available"),"remote-track-available"),s.remotePublishState=new wP("".concat(a.userId,"-").concat(s.mediaType,"-remote-publish"),"remote-track-publish"),KL(tV(SV(t(s),wP.STATECHANGED),SV(s.remotePublishState,wP.STATECHANGED)),vU((function(){return s.isRemotePublished&&(s.isSubscribed||s.isSubscribing)})),WU((function(e){s.availableState.state!==(e?wP.ON:wP.OFF)&&(s.availableState.state=e?wP.ON:wP.OFF),s.updatePlayingState(e)})));var c=KL(SV(s.player,LP.ERROR),HV((function(e){return e.code===MediaError.MEDIA_ERR_DECODE}))),u=KL(EV(5e3),HV((function(){return!(s.ignoreDecodeError||!s.isSubscribed||!s.isPlayCalled||!s.stat.bytesReceived||(s.player.isPlaying||(s.kind===nC.AUDIO?s.getAudioLevel()>0:s.stat.framesDecoded>0))&&(s.reportDecodeResult(!0),1))}))),l=KL(nV(c,u),JV(SV(s,wP.INIT)));return KL(s._triggerCheckDecodeSubject,HV((function(){return!s.ignoreDecodeError})),IU(l),WU((function(e){s.reportDecodeResult(!1,e)}))),s}return d(i,e),o(i,[{key:"setMute",value:function(e){this.isRemotePublished&&g(i,"setMute",this,3)([e])}},{key:"setInputMediaStreamTrack",value:function(e){g(i,"setInputMediaStreamTrack",this,3)([e]),this.isRemotePublished&&this.isSubscribed&&this.player.setTrack(this.outMediaTrack)}},{key:"checkDecodeResult",value:function(){this._triggerCheckDecodeSubject.next(!0)}},{key:"waitHasMediaTrack",value:function(){var e=this;return new Promise((function(t){e.mediaTrack?t():e.once("input-media-track-changed",t)}))}},{key:"ignoreDecodeError",get:function(){var e,t;return((null==(t=null==(e=this.room)?void 0:e.networkQuality)?void 0:t.downlinkNetworkQuality)||0)>3||this.player.isInAutoPlayFailedState}},{key:"isSubscribing",get:function(){return"subscribeing"===this.state.toString()}},{key:"isSubscribed",get:function(){return this.state===i.STATE_SUBSCRIBE}},{key:"isAvailable",get:function(){return this.availableState.state===wP.ON}},{key:"isNeedPlay",get:function(){return this.isAvailable&&this.isPlayCalled}},{key:"subscribe",value:function(e){return e}},{key:"unsubscribe",value:function(){this.player.setTrack(null),"main"===this.streamType&&"video"===this.kind&&this.room.changeType(!1,this.user)}},{key:"reportDecodeResult",value:function(e,t){var n=this.kind===nC.AUDIO;bO[e?"addSuccessEvent":"addFailedEvent"]({key:n?504700:514702}),e||(bO.addEnum({key:n?504701:514703,value:$N()}),jP.uploadEvent({log:"stat-decode-failed-".concat(this.kind,"-").concat(qN()||ZN()),userId:this.room.userId}),this._log.warn("decode failed: isPlaying: ".concat(this.player.isPlaying," ").concat(this.kind===nC.AUDIO?"audioLevel: ".concat(this.getAudioLevel()):"framesDecoded: ".concat(this.stat.framesDecoded>0))),this.emit("decode-failed",{error:t}))}},{key:"updatePlayingState",value:function(e){if(this.isPlayCalled&&this.player.isStopped===e){if(e&&(!this.isSubscribed||!this.isRemotePublished||!this.outMediaTrack))return void this.log.info("abort play, isSubscribed: ".concat(this.isSubscribed," isAvailable: ").concat(this.isRemotePublished," hasTrack: ").concat(!!this.outMediaTrack," "));g(i,"updatePlayingState",this,3)([e])}}},{key:"close",value:function(){g(i,"close",this,3)([]),this.outMediaTrack&&this.uninstallTrackEvent(this.outMediaTrack)}},{key:"onFlagChanged",value:function(){this.remotePublishState.state=this.isRemotePublished?wP.ON:wP.OFF}},{key:"onTrackMuted",value:function(){this.isNeedPlay&&g(i,"onTrackMuted",this,3)([])}},{key:"onTrackUnmuted",value:function(){this.isNeedPlay&&g(i,"onTrackUnmuted",this,3)([])}},{key:"onTrackEnded",value:function(){this.isNeedPlay&&g(i,"onTrackEnded",this,3)([])}}])}($M);rR(YU,"STATE_SUBSCRIBE","subscribe"),nR([PL(5,1)],YU.prototype,"waitHasMediaTrack",1),nR([AP(wP.INIT,YU.STATE_SUBSCRIBE,{success:function(){this.log.info("subscribed"),rx.emit(ax.REMOTE_TRACK_SUBSCRIBED,{track:this})},ignoreError:!0}),gL(521716,!1)],YU.prototype,"subscribe",1),nR([AP(YU.STATE_SUBSCRIBE,wP.INIT,{sync:!0,success:function(){this.log.info("unsubscribed"),rx.emit(ax.REMOTE_TRACK_UNSUBSCRIBED,{track:this})}})],YU.prototype,"unsubscribe",1);var qU=YU,XU=function(e){function i(e,a){var o;return r(this,i),o=n(this,i,[e,a,1]),rR(t(o),"volume",0),rR(t(o),"mediaType",1),rR(t(o),"stat",{bytesReceived:0,packetsReceived:0,packetsLost:0,end2EndDelay:0,jitterBufferDelay:0}),o.manager=e.audioManager,o}return d(i,e),o(i,[{key:"dbVolume",get:function(){return OM.isRunning?this.player.pipeline.volumeMeter.getVolumeDb():Math.floor(Math.max(10*Math.log10(this.volume)+100,0))}},{key:"decodeFrame",value:function(e){if(!this.manager)return e;var t,n=e,r=s(this.manager.decodePipeline);try{for(r.s();!(t=r.n()).done;){var i=t.value;if(i&&!(n=i({frame:n,track:this})))return}}catch(a){r.e(a)}finally{r.f()}return n}},{key:"getAudioLevel",value:function(){var e=this.volume||g(i,"getAudioLevel",this,3)([]);return e>1?1:e}},{key:"isRemotePublished",get:function(){return this.user.muteState.audioAvailable}}])}(qU),QU=[-1,-1,1,-1,-1,1,1,1],$U=[0,0,1,0,0,1,1,1],ZU=function(e){function i(e,a){var o;if(r(this,i),(o=n(this,i)).context=e,rR(t(o),"name"),rR(t(o),"input"),rR(t(o),"output"),rR(t(o),"texture"),rR(t(o),"ctx2d",null),rR(t(o),"fbo"),rR(t(o),"width",0),rR(t(o),"height",0),rR(t(o),"x",0),rR(t(o),"y",0),rR(t(o),"program"),rR(t(o),"vertexShader"),rR(t(o),"fragmentShader"),rR(t(o),"totalFrames",0),rR(t(o),"dropFrames",0),rR(t(o),"matchInputSize",!0),rR(t(o),"texCoordBuffer"),rR(t(o),"positionBuffer"),rR(t(o),"lastInfo",{name:"",timestamp:0,totalFrames:0,x:0,y:0,width:0,height:0,fps:0}),rR(t(o),"cost",0),rR(t(o),"_canvas",null),rR(t(o),"_image"),rR(t(o),"log"),o.context.on("disconnect",o.close,t(o)),o.name=a.name,o.log=a.logger,o.matchInputSize=!1!==a.matchInputSize,o.width=a.width||e.width,o.height=a.height||e.height,o._image=a.image,e instanceof fF)e.ctx&&a.create2d&&("function"==typeof OffscreenCanvas&&16!==VN?o._canvas=new OffscreenCanvas(o.width,o.height):(o._canvas=document.createElement("canvas"),o._canvas.width=o.width,o._canvas.height=o.height),o.ctx2d=o._canvas.getContext("2d"),o._image=o._canvas);else try{var s=e.ctx;o.texCoordBuffer=o.createBuffer($U),o.positionBuffer=o.createBuffer(QU),!1!==a.createTexture&&(o.texture=s.createTexture(),o.useTexture(),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_MIN_FILTER,s.LINEAR),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_MAG_FILTER,s.LINEAR),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_WRAP_S,s.CLAMP_TO_EDGE),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_WRAP_T,s.CLAMP_TO_EDGE),s.pixelStorei(s.PACK_ALIGNMENT,1),s.pixelStorei(s.UNPACK_ALIGNMENT,1)),a.useFbo&&(o.fbo=s.createFramebuffer(),o.useBufferFrame(),o.useTexture(),s.texImage2D(s.TEXTURE_2D,0,s.RGBA,o.width,o.height,0,s.RGBA,s.UNSIGNED_BYTE,null),s.framebufferTexture2D(s.FRAMEBUFFER,s.COLOR_ATTACHMENT0,s.TEXTURE_2D,o.texture,0)),a.useDefaultProgram?o.program=e.defaultProgam:(a.vertexShaderSource||a.fragmentShaderSource)&&(o.vertexShader=a.vertexShaderSource?e.createShader(s.VERTEX_SHADER,a.vertexShaderSource):e.defaultVShader,o.fragmentShader=a.fragmentShaderSource?e.createShader(s.FRAGMENT_SHADER,a.fragmentShaderSource):e.defaultFShader,o.program=e.createProgram(o.vertexShader,o.fragmentShader))}catch(vx){o.context.destroy(new yR({code:_R.VIDEO_MANAGER_ERROR,extraCode:3,message:"create video node ".concat(o.name," error ").concat(vx.message||vx)}))}return o}return d(i,e),o(i,[{key:"image",get:function(){return this._image},set:function(e){this._image=e}},{key:"createFramebuffer",value:function(e){var t=this.context.ctx,n=t.createFramebuffer();return t.bindFramebuffer(t.FRAMEBUFFER,n),t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,e,0),n}},{key:"connect",value:function(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r];return e.addInput.apply(e,[this].concat(n)),this.output=e,e}},{key:"addInput",value:function(e){this.input=e,this.matchInputSize&&e.width&&e.height&&this.resize(e.width,e.height)}},{key:"requestFrame",value:function(e){var t=Date.now();return!!(this.context instanceof hF&&this.render(e)||this.context instanceof fF&&this.render2d(e))&&(this.totalFrames++,this.cost=Date.now()-t,!0)}},{key:"render2d",value:function(e){var t;return!(null==(t=this.input)||!t.requestFrame(e))&&this.draw2d(this.input.image,0,0,this.width,this.height)}},{key:"update",value:function(){var e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;null==(e=this.output)||e.update(t)}},{key:"disconnect",value:function(){for(var e,t,n=arguments.length,r=new Array(n),i=0;i<n;i++)r[i]=arguments[i];null==(t=this.output)||(e=t).removeInput.apply(e,[this].concat(r)),delete this.output}},{key:"removeInput",value:function(e){delete this.input}},{key:"close",value:function(){var e,t;if(this.context.off("disconnect",this.close,this),null==(e=this.output)||e.removeInput(this),delete this.output,null==(t=this.input)||t.disconnect(),this.context instanceof hF){var n=this.context.ctx;n.deleteBuffer(this.texCoordBuffer),n.deleteBuffer(this.positionBuffer),this.fbo&&n.deleteFramebuffer(this.fbo),this.texture&&n.deleteTexture(this.texture),this.vertexShader&&this.vertexShader!==this.context.defaultVShader&&n.deleteShader(this.vertexShader),this.fragmentShader&&this.fragmentShader!==this.context.defaultFShader&&n.deleteShader(this.fragmentShader),this.program&&this.program!==this.context.defaultProgam&&n.deleteProgram(this.program)}this._canvas&&(this._canvas.width=0,this._canvas.height=0,this.ctx2d=null),this.removeAllListeners()}},{key:"useTexture",value:function(){this.useTextures(this.texture)}},{key:"useInputTexture",value:function(){var e;this.useTextures(null==(e=this.input)?void 0:e.texture)}},{key:"useTextures",value:function(){for(var e=this.context.ctx,t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];n.forEach((function(t,n){t&&(e.activeTexture(e.TEXTURE0+n),e.bindTexture(e.TEXTURE_2D,t))}))}},{key:"useProgram",value:function(){this.context.ctx.useProgram(this.program)}},{key:"useBufferFrame",value:function(){var e=this.context.ctx;e.bindFramebuffer(e.FRAMEBUFFER,this.fbo||null)}},{key:"createBuffer",value:function(e){var t=this.context.ctx,n=t.createBuffer();return t.bindBuffer(t.ARRAY_BUFFER,n),t.bufferData(t.ARRAY_BUFFER,new Float32Array(e),t.STATIC_DRAW),n}},{key:"setTexBuffer",value:function(e){var t=this.context.ctx;t.bindBuffer(t.ARRAY_BUFFER,this.texCoordBuffer),t.bufferData(t.ARRAY_BUFFER,new Float32Array(e),t.STATIC_DRAW)}},{key:"setPosBuffer",value:function(e){var t=this.context.ctx;t.bindBuffer(t.ARRAY_BUFFER,this.positionBuffer),t.bufferData(t.ARRAY_BUFFER,new Float32Array(e),t.STATIC_DRAW)}},{key:"changeBufferData",value:function(e,t){var n=this.context.ctx;n.bindBuffer(n.ARRAY_BUFFER,e),n.bufferData(n.ARRAY_BUFFER,new Float32Array(t),n.STATIC_DRAW)}},{key:"setAttributes",value:function(){for(var e=this.context.ctx,t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];n.forEach((function(t,n){e.enableVertexAttribArray(n),e.bindBuffer(e.ARRAY_BUFFER,t),e.vertexAttribPointer(n,2,e.FLOAT,!1,0,0)}))}},{key:"getVertexPoint",value:function(e,t){return[e/this.width*2-1,t/this.height*2-1]}},{key:"layout2texCoords",value:function(e){return[].concat(E(this.getVertexPoint(e.x,e.y)),E(this.getVertexPoint(e.x+e.width,e.y)),E(this.getVertexPoint(e.x,e.y+e.height)),E(this.getVertexPoint(e.x+e.width,e.y+e.height)))}},{key:"resize",value:function(e,t){if(this.width!==e||this.height!==t){if(this.width=e,this.height=t,this._canvas&&(this._canvas.width=e,this._canvas.height=t),this.texture&&this.fbo){this.useTexture();var n=this.context.ctx;n.texImage2D(n.TEXTURE_2D,0,n.RGBA,e,t,0,n.RGBA,n.UNSIGNED_BYTE,null)}this.output&&this.output.matchInputSize&&this.output.resize(e,t)}}},{key:"draw",value:function(e,t){this.setAttributes(e||this.positionBuffer,t||this.texCoordBuffer);var n=this.context.ctx;n.drawArrays(n.TRIANGLE_STRIP,0,4)}},{key:"draw2d",value:function(e,t,n,r,i){return!(!this.ctx2d||!e||(e instanceof ImageData?this.ctx2d.putImageData(e,t,n):(this.ctx2d.drawImage(e,t,n,r,i),"undefined"!=typeof VideoFrame&&e instanceof VideoFrame&&e.close()),0))}},{key:"getInfo",value:function(){var e,t=this.totalFrames,n=this.x,r=this.y,i=this.width,a=this.height,o=this.name,s=this.cost,c=Date.now(),u=(t-this.lastInfo.totalFrames)/((c-this.lastInfo.timestamp)/1e3)|0;return this.lastInfo={totalFrames:t,x:n,y:r,width:i,height:a,timestamp:c,fps:u,name:o,cost:s},QA({parent:null==(e=this.input)?void 0:e.getInfo()},this.lastInfo)}},{key:"createTexture",value:function(e){var t=this.context.ctx,n=t.createTexture();return this.useTextures(n),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,t.LINEAR),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MAG_FILTER,t.LINEAR),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE),t.pixelStorei(t.PACK_ALIGNMENT,1),t.pixelStorei(t.UNPACK_ALIGNMENT,1),t.texImage2D(t.TEXTURE_2D,0,t.RGBA,t.RGBA,t.UNSIGNED_BYTE,e),n}}])}(wP);nR([AP(wP.INIT,"connected",{sync:!0})],ZU.prototype,"connect",1),nR([AP("connected",wP.INIT,{ignoreError:!0,sync:!0})],ZU.prototype,"disconnect",1),nR([AP([],"closed",{sync:!0})],ZU.prototype,"close",1);var eF=KL(yV(250),vU((function(){return performance.now()})),eV()),tF=[0,1,1,1,0,0,1,0],nF=function(e){function i(e,a){var o;return r(this,i),o=n(this,i,[e,Object.assign({useDefaultProgram:!0,createTexture:!1,name:"destination"},a)]),rR(t(o),"_intervalId",0),rR(t(o),"_sequence",0),rR(t(o),"checkGLError",!1),rR(t(o),"checkVisibilityChange"),e instanceof fF?o.ctx2d=e.ctx||null:e.available&&null!=a&&a.mirrorUpAndDown&&o.setTexBuffer(tF),o}return d(i,e),o(i,[{key:"start",value:function(e){var t=this;this.log.info("".concat(this.name," start render ").concat(e," fps")),MP.clearTask(this._intervalId),this._intervalId=MP.run("intervalInWorker",(function(){if(e!==t.context.frameRate&&(MP.clearTask(t._intervalId),t.start(t.context.frameRate)),t.requestFrame(t._sequence++),t.checkGLError&&t.context instanceof hF){var n=t.context.ctx.getError();n&&t.context.destroy(new yR({code:_R.VIDEO_MANAGER_ERROR,extraCode:5,message:"".concat(t.name," req ").concat(t._sequence," render ").concat(t.totalFrames," faild ").concat(n)}))}}),{fps:this.context.frameRate})}},{key:"render",value:function(e){var t;return!(null==(t=this.input)||!t.requestFrame(e)||(this.useProgram(),this.useBufferFrame(),this.useInputTexture(),this.draw(),0))}},{key:"addInput",value:function(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r];g(i,"addInput",this,3)([e].concat(n)),this.start(this.context.frameRate)}},{key:"update",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;if(this._intervalId&&(MP.clearTask(this._intervalId),this._intervalId=0,1===t)){this.log.info("".concat(this.name," use requestVideoFrameCallback"));var n=function(){document.hidden&&(e.start(e.context.frameRate),e.log.info("".concat(e.name," use timer")),document.removeEventListener("visibilitychange",n))};document.addEventListener("visibilitychange",n)}this.requestFrame(this._sequence++)}},{key:"removeInput",value:function(e){g(i,"removeInput",this,3)([e]),MP.clearTask(this._intervalId)}},{key:"resize",value:function(e,t){g(i,"resize",this,3)([e,t]),this.context.setSize(e,t)}},{key:"close",value:function(){g(i,"close",this,3)([]),MP.clearTask(this._intervalId),document.removeEventListener("visibilitychange",this.checkVisibilityChange)}}])}(ZU),rF=function(e){function i(e,a){var o,s;return r(this,i),s=n(this,i,[e,a]),rR(t(s),"_videoTrack"),rR(t(s),"_muteOb"),rR(t(s),"_closedOb",SV(t(s),"closed")),rR(t(s),"_subscription"),rR(t(s),"_canvasContainer"),Number(PN)<17&&(s._canvasContainer=document.createElement("div"),s._canvasContainer.style.display="none"),o=v(e._canvas.captureStream().getVideoTracks(),1),s._videoTrack=o[0],s._muteOb=SV(s._videoTrack,"mute"),KL(SV(s._videoTrack,"ended"),JV(s._closedOb),WU((function(){s.context.destroy(new yR({code:_R.VIDEO_MANAGER_ERROR,extraCode:8,message:"video track ended"}))}))),s}return d(i,e),o(i,[{key:"enableCheckMute",value:function(){var e=this;this._subscription=KL(this._muteOb,JV(this._closedOb),IU((function(e){var t=performance.now();KL(eF,XV((function(e){return e-t<5e3})),WV(1))(e)})),WU((function(){var t;null!=(t=e._videoTrack)&&t.muted&&e.context.destroy(new yR({code:_R.VIDEO_MANAGER_ERROR,extraCode:7,message:"video track muted"}))})))}},{key:"disableCheckMute",value:function(){var e;null==(e=this._subscription)||e.dispose()}},{key:"videoTrack",get:function(){return this._videoTrack}},{key:"putCanvasIntoDom",value:function(){!this.context._canvas||!this._canvasContainer||document.getElementById(this.context._canvas.id)||(this.log.info("".concat(this.name," put canvas to body")),document.body.appendChild(this._canvasContainer),this._canvasContainer.appendChild(this.context._canvas))}},{key:"render",value:function(e){return this.putCanvasIntoDom(),g(i,"render",this,3)([e])}},{key:"render2d",value:function(e){return this.putCanvasIntoDom(),g(i,"render2d",this,3)([e])}},{key:"close",value:function(){var e,t;g(i,"close",this,3)([]),null==(e=this._videoTrack)||e.stop(),delete this._videoTrack,null==(t=this._canvasContainer)||t.remove()}}])}(nF),iF=function(e){function t(){return r(this,t),n(this,t,arguments)}return d(t,e),o(t,[{key:"render",value:function(e){var t;return!(null==(t=this.input)||!t.requestFrame(e))}}])}(rF),aF=function(e){function t(e,i,a){var o;return r(this,t),(o=n(this,t,[e,{name:"smallDestination",logger:a}])).resolution=i,o}return d(t,e),o(t,[{key:"resize",value:function(e,n){var r,i=e*n,a=this.resolution.width*this.resolution.height;this.log.info("big res: ".concat(e,"*").concat(n," small res: ").concat(this.resolution.width,"*").concat(this.resolution.height," ")),i>a?r=i/a:(this.log.warn("Small stream resolution is not smaller than big stream, which is invalid. big: ".concat(e," * ").concat(n," small: ").concat(this.resolution.width," * ").concat(this.resolution.height)),r=i/19200),g(t,"resize",this,3)([e/Math.sqrt(r),n/Math.sqrt(r)])}}])}(rF),oF=function(e){function i(e,a){var o;return r(this,i),o=n(this,i,[e,QA({name:"imageSource"},a)]),rR(t(o),"_lastImage"),rR(t(o),"_totalFrames",0),rR(t(o),"_autoResize",!1),rR(t(o),"_canvasRendered"),rR(t(o),"_videoCallbackId",0),o._autoResize=!1!==(null==a?void 0:a.autoResize),16===VN&&(o._canvasRendered=fV(),KL(o._canvasRendered,cV(o._image),kU((function(e){return e instanceof HTMLCanvasElement?SV(e,"rendered"):MV()})),JV(SV(t(o),"closed")),WU((function(){o.update()})))),o}return d(i,e),o(i,[{key:"tryVideoFrameCallback",value:function(e){var t=this;this._videoCallbackId&&e.cancelVideoFrameCallback(this._videoCallbackId),gP()&&!document.hidden&&(this._videoCallbackId=e.requestVideoFrameCallback((function(e,n){document.hidden||(t._totalFrames=n.presentedFrames,t.update(1))})))}},{key:"_render",value:function(e,t){var n,r=this.width,i=this.height,a=this.image;if(a instanceof HTMLVideoElement){if(this.tryVideoFrameCallback(a),r=a.videoWidth,i=a.videoHeight,!r||!i)return!1;a.width=r,a.height=i}else if(a instanceof HTMLImageElement||a instanceof ImageData||a instanceof ImageBitmap){if(r=a.width,i=a.height,a!==this._lastImage)this._lastImage=a;else if(r===this.width&&i===this.height)return!1}else a instanceof HTMLCanvasElement||a instanceof OffscreenCanvas?(r=a.width,i=a.height,this._lastImage=a):"undefined"!=typeof VideoFrame&&a instanceof VideoFrame&&(r=a.displayWidth,i=a.displayHeight,null==(n=this._lastImage)||n.close(),this._lastImage=a);if(!this._autoResize)return!0;if(this.width===r&&this.height===i&&this.totalFrames){if(t){this.useTexture();var o=this.context.ctx;o.texSubImage2D(o.TEXTURE_2D,0,0,0,o.RGBA,o.UNSIGNED_BYTE,a)}}else{if(t){this.useTexture();var s=this.context.ctx;s.texImage2D(s.TEXTURE_2D,0,s.RGBA,s.RGBA,s.UNSIGNED_BYTE,a)}this.resize(r,i)}return!0}},{key:"image",get:function(){return this._image},set:function(e){var t;null==(t=this._canvasRendered)||t.next(e),this._image=e}},{key:"render",value:function(e){return this._render(e,!0)}},{key:"render2d",value:function(e){return this._render(e,!1)}}])}(ZU),sF=function(e){function i(e,a,o){var s;return r(this,i),(s=n(this,i,[e,o]))._player=a,s.name="videoPlayerSource",KL(SV(s._player,LP.PLAYER_STATE_CHANGED),JV(SV(t(s),"closed")),HV((function(e){return"PLAYING"===e.state})),WU((function(){s.tryVideoFrameCallback(s._player.element)}))),s}return d(i,e),o(i,[{key:"image",get:function(){return this._player.element}}])}(oF),cF=function(e){function t(e,i,a){var o;return r(this,t),(o=n(this,t,[e,new pM({id:a.name,track:i,muted:!0,container:null,objectFit:"contain",log:a.logger}),a])).name="videoTrackSource",o._player.play(),o}return d(t,e),o(t,[{key:"replaceTrack",value:function(e){this._player.setTrack(e),this._player.play()}},{key:"close",value:function(){g(t,"close",this,3)([]),this._player.stop()}}])}(sF),uF=function(e){function i(e){var a;return r(this,i),a=n(this,i),rR(t(a),"frameRate"),rR(t(a),"_canvas"),rR(t(a),"log"),rR(t(a),"hasAlpha",!1),rR(t(a),"name"),rR(t(a),"error"),a.name=e.name,a.log=e.logger.createChild({id:"vc-".concat(a.name)}),a.frameRate=e.frameRate,a}return d(i,e),o(i,[{key:"width",get:function(){var e;return(null==(e=this._canvas)?void 0:e.width)||0},set:function(e){this._canvas&&(this._canvas.width=e)}},{key:"height",get:function(){var e;return(null==(e=this._canvas)?void 0:e.height)||0},set:function(e){this._canvas&&(this._canvas.height=e)}},{key:"setSize",value:function(e,t){this._canvas&&(this._canvas.width=e,this._canvas.height=t)}},{key:"createVideoTrackSource",value:function(e,t){return new cF(this,e,{logger:this.log,name:t})}},{key:"createVideoTrackDestination",value:function(e){return new rF(this,e)}},{key:"createVideoImageSource",value:function(e,t){return new oF(this,t?Object.assign(t,{logger:this.log,image:e}):{logger:this.log,image:e})}},{key:"createVideoPlayerSource",value:function(e,t){return new sF(this,e,t?Object.assign(t,{logger:this.log}):{logger:this.log})}},{key:"available",get:function(){return"created"===this.state}},{key:"disconnect",value:function(){this.emit("disconnect")}}])}(wP);rR(uF,"_ids",0);var lF={alpha:!0,antialias:!1,premultipliedAlpha:!1,preserveDrawingBuffer:!1,depth:!1,stencil:!1,failIfMajorPerformanceCaveat:!0,powerPreference:"low-power"},dF=function(e){function i(){var e;return r(this,i),e=n(this,i,arguments),rR(t(e),"defaultProgam"),rR(t(e),"defaultVShader"),rR(t(e),"defaultFShader"),rR(t(e),"ctx"),e}return d(i,e),o(i,[{key:"create",value:function(){var e=this;if(this._canvas||(this._canvas=document.createElement("canvas"),this._canvas.id="trtc_".concat(this.name,"_").concat(uF._ids++)),this.ctx=this._canvas.getContext("webgl2",lF),!this.ctx)throw new yR({code:_R.VIDEO_MANAGER_ERROR,extraCode:2,message:"webgl2 not supported"});this.defaultVShader=this.createShader(this.ctx.VERTEX_SHADER,"\n// 顶点着色器\nattribute vec4 a_position;\nattribute vec2 a_texCoord;\nvarying vec2 v_texCoord;\n\nvoid main() {\n gl_Position = a_position;\n v_texCoord = a_texCoord;\n}\n"),this.defaultFShader=this.createShader(this.ctx.FRAGMENT_SHADER,"\n// 片元着色器\nprecision mediump float;\nvarying vec2 v_texCoord;\nuniform sampler2D u_texture;\n\nvoid main() {\n gl_FragColor = texture2D(u_texture, v_texCoord);\n} "),this.defaultProgam=this.createProgram(this.defaultVShader,this.defaultFShader),this._canvas.addEventListener("webglcontextlost",(function(){e.destroy(new yR({code:_R.VIDEO_MANAGER_ERROR,extraCode:4,message:"webgl context lost"}))}))}},{key:"destroy",value:function(e){var t="";return e&&(t=e.message,this.error=e,bO.addFailedEvent({key:512702,error:e})),this.disconnect(),this.log.info("video context destroy".concat(t)?": ".concat(t):""),this.ctx&&(this.ctx.deleteShader(this.defaultVShader),this.ctx.deleteShader(this.defaultFShader),this.ctx.deleteProgram(this.defaultProgam),delete this.ctx),e}},{key:"width",set:function(e){var t;null==(t=this.ctx)||t.viewport(0,0,e,this.height),y(i,"width",e,this,1,1)}},{key:"height",set:function(e){var t;null==(t=this.ctx)||t.viewport(0,0,this.width,e),y(i,"height",e,this,1,1)}},{key:"setSize",value:function(e,t){var n;null==(n=this.ctx)||n.viewport(0,0,e,t),g(i,"setSize",this,3)([e,t])}},{key:"createShader",value:function(e,t){var n=this.ctx,r=n.createShader(e);return n.shaderSource(r,t),n.compileShader(r),r}},{key:"createProgram",value:function(e,t){var n=this.ctx,r=n.createProgram();return n.attachShader(r,e),n.attachShader(r,t),n.linkProgram(r),n.getProgramParameter(r,n.LINK_STATUS)||this.log.error(n.getProgramInfoLog(r)),r}}])}(uF);rR(dF,"UNAVAILABLE","unavailable"),nR([AP(wP.INIT,"created",{sync:!0,fail:function(e){this.log.error("video gl context create failed",e.cause),bO.addFailedEvent({key:512700,error:e.cause||e})},success:function(){this.log.info("video context created use webgl"),bO.addSuccessEvent({key:512700})}})],dF.prototype,"create",1),nR([AP("created",wP.INIT,{ignoreError:!0,sync:!0,success:function(e){e&&this.emit(dF.UNAVAILABLE,e),this.removeAllListeners()}})],dF.prototype,"destroy",1);var hF=dF,fF=function(e){function i(){var e;return r(this,i),e=n(this,i,arguments),rR(t(e),"ctx"),e}return d(i,e),o(i,[{key:"create",value:function(e){var t=this;if(this.hasAlpha=e.alpha,this._canvas=document.createElement("canvas"),this._canvas.id="trtc_".concat(this.name,"_").concat(uF._ids++),this.ctx=this._canvas.getContext("2d",{alpha:e.alpha}),!this.ctx)throw new yR({code:_R.VIDEO_MANAGER_ERROR,extraCode:2,message:"2d context not supported"});this._canvas.addEventListener("contextlost",(function(){t.log.error("2d context lost")})),this._canvas.addEventListener("contextrestored",(function(){t.log.warn("2d context restored")}))}},{key:"destroy",value:function(e){var t="";e&&(t=e.message,this.error=e,bO.addFailedEvent({key:512703,error:e})),this.disconnect(),this.log.info("video context destroy ".concat(t?": ".concat(t):"")),delete this.ctx,this._canvas&&(this._canvas.remove(),this._canvas.width=0,this._canvas.height=0,delete this._canvas),this.removeAllListeners(),bO.addSuccessEvent({key:512703})}}])}(uF);nR([AP(wP.INIT,"created",{sync:!0,fail:function(e){this.log.error("video 2d context create failed",e.cause),bO.addFailedEvent({key:512701,error:e.cause||e})},success:function(){this.log.info("video context created use 2d"),bO.addSuccessEvent({key:512701})}})],fF.prototype,"create",1),nR([AP("created",wP.INIT,{ignoreError:!0,sync:!0})],fF.prototype,"destroy",1);var pF=function(e){function i(e,a){var o;return r(this,i),o=n(this,i,[e,a,arguments.length>2&&void 0!==arguments[2]?arguments[2]:4]),rR(t(o),"mediaType",4),rR(t(o),"source"),rR(t(o),"stat",{bytesReceived:0,packetsReceived:0,packetsLost:0,framesReceived:0,framesDecoded:0,frameWidth:0,frameHeight:0,end2EndDelay:0,jitterBufferDelay:0}),o.manager=e.videoManager,o.once("first-video-frame",(function(e){o.room.emit("first-video-frame",e)})),o}return d(i,e),o(i,[{key:"play",value:function(e,t){var n=this;return(Rw(null==t?void 0:t.canvasRender)?t.canvasRender:17===VN)&&!this.source&&this.useCanvasPlayer(),g(i,"play",this,3)([e,t]).then((function(){n.player.calculateStat()}))}},{key:"useCanvasPlayer",value:function(){if(this.log.info("useCanvasPlayer(), has element:".concat(!!this.player.element)),this.player.element){var e=new fF({frameRate:15,logger:this.log,name:this.userId});e.create({alpha:!1});var t=new nF(e,{name:"remotePlayer",logger:this.log});this.source=e.createVideoPlayerSource(this.player),this.source.connect(t),this.player.setCanvas(e._canvas),gP()||(this.updateCanvasPlayerFPS=this.updateCanvasPlayerFPS.bind(this,e),this.room.on("heartbeat-report",this.updateCanvasPlayerFPS,this))}}},{key:"updateCanvasPlayerFPS",value:function(e){var t,n=this.decodeFPS,r=(t=n,[15,30,45,60].reduce((function(e,n){return Math.abs(n-t)<Math.abs(e-t)?n:e})));!Aw(n)||n<=0?this.log.debug("updateCanvasPlayerFPS() ignore decoder: ".concat(n," ")):r!==e.frameRate?(this.log.info("updateCanvasPlayerFPS() decoder: ".concat(n,", closest: ").concat(r,", current: ").concat(e.frameRate)),e.frameRate=r):this.log.debug("updateCanvasPlayerFPS() ignore ClosestFPS ".concat(r," == ").concat(e.frameRate))}},{key:"decodeFPS",get:function(){var e,t=this,n=((null==(e=this.room.heartbeatReport)?void 0:e.msg_down_stream_info.find((function(e){return e.msg_user_info.str_identifier===t.userId})))||{}).msg_video_status,r=2===this.mediaType?7:this.isSmall?3:2;if(!n||0===n.length)return 0;var i=n.find((function(e){return e.uint32_video_stream_type===r}));return(null==i?void 0:i.uint32_video_dec_fps)||0}},{key:"stop",value:function(){return this.room.off("heartbeat-report",this.updateCanvasPlayerFPS,this),g(i,"stop",this,3)([])}},{key:"decodeFrame",value:function(e){if(!this.manager)return e;var t,n=s(this.manager.decodePipeline);try{for(n.s();!(t=n.n()).done;){var r=t.value;if(r&&!(e=r({frame:e,track:this})))return}}catch(i){n.e(i)}finally{n.f()}return e}},{key:"isBig",get:function(){return 4===this.mediaType}},{key:"isSmall",get:function(){return 8===this.mediaType}},{key:"changeType",value:function(e){this.room.changeType(e,this.user)}},{key:"isRemotePublished",get:function(){return this.user.muteState.videoAvailable}},{key:"setMirror",value:function(e){"publish"===e||"both"===e||g(i,"setMirror",this,3)([e])}},{key:"onDecodeDowngradeStateChanged",value:function(e){this.emit("decode-downgrade-state-changed",e)}}])}(qU),mF=function(e){function i(e,a){var o;return r(this,i),o=n(this,i,[e,a,2]),rR(t(o),"mediaType",2),rR(t(o),"objectFit","contain"),o}return d(i,e),o(i,[{key:"isRemotePublished",get:function(){return this.user.muteState.hasAuxiliary}}])}(pF),vF=new Map;function _F(e,t){var n=$A(QA({},t),{timestamp:TR()});vF.has(e)?vF.get(e).push(n):vF.set(e,[n])}rx.on(ax.JOIN_SUCCESS,(function(e){_F(e.room.userId,{eventId:32788})})),rx.on(ax.LEAVE_START,(function(e){_F(e.room.userId,{eventId:32789})})),rx.on(ax.LOCAL_TRACK_PUBLISHED,(function(e){var t=e.track;if(t.room){var n=32769;4===t.mediaType?n=32768:2===t.mediaType&&(n=32805),_F(t.room.userId,{eventId:n})}})),rx.on(ax.LOCAL_TRACK_UNPUBLISHED,(function(e){var t=e.track;if(t.room){var n=32771;4===t.mediaType?n=32770:2===t.mediaType&&(n=32806),_F(t.room.userId,{eventId:n})}})),rx.on(ax.TRACK_MUTED,(function(e){var t=e.track;t.room&&(t.kind===nC.AUDIO?_F(t.room.userId,{eventId:t.isRemote?32785:32772,remoteUserId:t.isRemote?t.userId:void 0}):_F(t.room.userId,{eventId:t.isRemote?32784:32773,remoteUserId:t.isRemote?t.userId:void 0}))})),rx.on(ax.TRACK_UNMUTED,(function(e){var t=e.track;t.room&&(t.kind===nC.AUDIO?_F(t.room.userId,{eventId:t.isRemote?32787:32774,remoteUserId:t.isRemote?t.userId:void 0}):_F(t.room.userId,{eventId:t.isRemote?32786:32775,remoteUserId:t.isRemote?t.userId:void 0}))})),rx.on(ax.REMOTE_TRACK_SUBSCRIBED,(function(e){var t=e.track;t.room&&(1===t.mediaType&&_F(t.room.userId,{eventId:32777,remoteUserId:t.userId}),4===t.mediaType&&_F(t.room.userId,{eventId:32776,remoteUserId:t.userId}),8===t.mediaType&&_F(t.room.userId,{eventId:32803,remoteUserId:t.userId}))})),rx.on(ax.REMOTE_TRACK_UNSUBSCRIBED,(function(e){var t=e.track;t.room&&(1===t.mediaType&&_F(t.room.userId,{eventId:32779,remoteUserId:t.userId}),4===t.mediaType&&_F(t.room.userId,{eventId:32778,remoteUserId:t.userId}),8===t.mediaType&&_F(t.room.userId,{eventId:32804,remoteUserId:t.userId}))})),rx.on(ax.SWITCH_DEVICE_SUCCESS,(function(e){var t=e.track;t.room&&_F(t.room.userId,{eventId:t.kind===nC.VIDEO?32780:32781})})),rx.on(ax.LOCAL_TRACK_REPLACED,(function(e){var t=e.track;t.room&&_F(t.room.userId,{eventId:t.kind===nC.VIDEO?32782:32783})})),rx.on(ax.SIGNAL_CONNECTION_STATE_CHANGED,(function(e){var t,n=e.room,r=e.prevState;switch(e.state){case"CONNECTED":t="RECONNECTING"===r?32795:32791;break;case"DISCONNECTED":t="RECONNECTING"===r?32796:32790;break;case"RECONNECTING":t=32794}t&&_F(n.userId,{eventId:t})})),rx.on(ax.PEER_CONNECTION_STATE_CHANGED,(function(e){var t,n=e.room,r=e.prevState,i=e.state,a=e.remoteUserId,o=!!a;switch(i){case"CONNECTED":t="RECONNECTING"===r?o?32801:32798:o?32793:32792;break;case"DISCONNECTED":"RECONNECTING"===r&&(t=o?32802:32799);break;case"RECONNECTING":t=o?32800:32797}t&&_F(n.userId,{eventId:t,remoteUserId:a})})),rx.on(ax.VIDEO_CODEC_IMPLEMENTATION_CHANGED,(function(e){e.implementation;var t=e.userId,n=e.remoteUserId,r=e.codec,i=e.isHWCodec,a=i?1:0;e.prevImplementation||(a=i?3:2);var o="h264"===r?0:2,s={eventId:4004,param1:a,param2:o,streamType:e.streamType||2};n&&(s.remoteUserId=n,s.eventId=4005),_F(t,s),bO.addEnum({key:n?514701:513701,value:a}),bO.addEnum({key:n?514700:513700,value:o})})),rx.on(ax.LOCAL_TRACK_RECAPTURE,(function(e){var t=e.track,n=e.error;if(t.userId){var r={eventId:2003,param1:0};t.kind===nC.AUDIO?(r.streamType=1,n&&(r.param1=2)):(r.streamType="auxiliary"===t.streamType?7:2,n&&(r.param1=8)),_F(t.userId,r)}}));var gF=function(e){function i(e,a){var o;r(this,i);var s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"userId";return(o=n(this,i)).mySelfId=e,o._log=a,o.key=s,rR(t(o),"userMap",new Map),rR(t(o),"remotePublishedUserMap",new Map),o}return d(i,e),o(i,[{key:"hasRobotUser",get:function(){return!!E(this.remotePublishedUserMap.values()).find((function(e){return e.isRobot}))}},{key:"getPublishedUser",value:function(e){return this.remotePublishedUserMap.get(e)}},{key:"addUser",value:function(e){var t=e[this.key],n=e.userId,r=e.tinyId,i=e.role;if(!this.userMap.has(t)){var a={userId:n,tinyId:r,role:20===i?"anchor":"audience"};this.userMap.set(t,a),this.emit("1",a)}}},{key:"deleteUser",value:function(e,t){var n=this.userMap.get(e);if(n){var r="peer leave [".concat(e,"]");Iw(t)||(r+=":".concat(ZC[t])),this._log.info(r);var i=this.remotePublishedUserMap.get(e);if(i){var a=i.muteState;i.flag=0,this.emit("5",i.userId),this.deleteRemotePublishedUser(e),this.emit("6",{prevMuteState:a,muteState:i.muteState,flag:0})}this.userMap.delete(e),this.emit("2",n.userId)}}},{key:"setUserList",value:function(e){var t=this;this.userMap.forEach((function(n){e.findIndex((function(e){return e[t.key]===n[t.key]}))<0&&t.deleteUser(n[t.key],0)})),e.forEach((function(e){!t.userMap.has(e[t.key])&&e[t.key]!==t.mySelfId&&t.addUser(e)}))}},{key:"addRemotePublishedUser",value:function(e){this.remotePublishedUserMap.has(e[this.key])||this.remotePublishedUserMap.set(e[this.key],e)}},{key:"deleteRemotePublishedUser",value:function(e){this.remotePublishedUserMap.has(e)&&this.remotePublishedUserMap.delete(e)}},{key:"setRemotePublishedUserList",value:function(e){var t=this;this.remotePublishedUserMap.forEach((function(n){var r=n[t.key];if(e.findIndex((function(e){return e[t.key]===n[t.key]}))<0){t._log.info("remote [".concat(r,"] unpublish"));var i=n.muteState;n.flag=0,t.emit("5",n.userId),t.deleteRemotePublishedUser(r),t.emit("6",{prevMuteState:i,muteState:n.muteState,flag:0})}})),e.forEach((function(e){var n,r=e[t.key];if(r!==t.mySelfId){var i=e.flag,a=e.userId,o=e.tinyId,s=Hw(i,a),c=null==(n=t.remotePublishedUserMap.get(r))?void 0:n.muteState;if(c){var u=t.remotePublishedUserMap.get(r);u&&u.flag!==i&&(u.flag=i,t._log.info("remote publish updated: ".concat(JSON.stringify(u.muteState))),t.emit("6",{prevMuteState:c,muteState:s,flag:i}))}else t._log.info("remote publish. state: ".concat(JSON.stringify(s))),t.addUser({userId:a,tinyId:o,role:20}),t.emit("3",e),t.emit("6",{prevMuteState:Hw(0,a),muteState:s,flag:i})}}))}},{key:"clear",value:function(){this.userMap.clear(),this.remotePublishedUserMap.clear()}}])}(tR(oR(),1).EventEmitter);function yF(e){var t=e.timesInSecond,n=e.maxSizeInSecond,r=e.getSize;return uL((function(e,i){var a=new WeakMap;return rx.on(ax.ROOM_DESTROY,(function(e){var t=e.room;return a.delete(t)})),function(){for(var o=a.get(this),s=arguments.length,c=new Array(s),u=0;u<s;u++)c[u]=arguments[u];if(o||(o={callCountInSecond:0,timestamp:0,totalSizeInSecond:0},a.set(this,o)),0===o.timestamp?o.timestamp=Date.now():Date.now()-o.timestamp>1e3&&(o.timestamp=Date.now(),o.callCountInSecond=0,o.totalSizeInSecond=0),r&&(o.totalSizeInSecond+=r.apply(void 0,c)),0!==o.timestamp&&Date.now()-o.timestamp<1e3&&(o.callCountInSecond>=t||o.totalSizeInSecond>n))throw new yR({code:_R.INVALID_OPERATION,message:mO({key:dO.CALL_FREQUENCY_LIMIT,data:{isTimes:o.callCountInSecond>=t,isSize:o.totalSizeInSecond>n,name:i,timesInSecond:t,maxSizeInSecond:n}})});o.callCountInSecond++,e.call.apply(e,[this].concat(c))}}))}var EF,TF=!0,kF={SCENE_LIVE:"live",SCENE_RTC:"rtc",ROLE_ANCHOR:"anchor",ROLE_AUDIENCE:"audience",STREAM_TYPE_MAIN:"main",STREAM_TYPE_SUB:"sub",AUDIO_PROFILE_STANDARD:"standard",AUDIO_PROFILE_STANDARD_STEREO:"standard-stereo",AUDIO_PROFILE_HIGH:"high",AUDIO_PROFILE_HIGH_STEREO:"high-stereo",QOS_PREFERENCE_SMOOTH:"smooth",QOS_PREFERENCE_CLEAR:"clear",SPEAKER:"Speakerphone",HEADSET:"Headset earpiece"},SF={INVALID_PARAMETER:5e3,INVALID_OPERATION:5100,ENV_NOT_SUPPORTED:5200,DEVICE_ERROR:5300,SERVER_ERROR:5400,OPERATION_FAILED:5500,OPERATION_ABORT:5998,UNKNOWN_ERROR:5999},IF=((EF=IF||{})[EF.INVALID_PARAMETER=5e3]="INVALID_PARAMETER",EF[EF.INVALID_PARAMETER_REQUIRED=5001]="INVALID_PARAMETER_REQUIRED",EF[EF.INVALID_PARAMETER_TYPE=5002]="INVALID_PARAMETER_TYPE",EF[EF.INVALID_PARAMETER_EMPTY=5003]="INVALID_PARAMETER_EMPTY",EF[EF.INVALID_PARAMETER_INSTANCE=5004]="INVALID_PARAMETER_INSTANCE",EF[EF.INVALID_PARAMETER_RANGE=5005]="INVALID_PARAMETER_RANGE",EF[EF.INVALID_PARAMETER_LESS_THAN_ZERO=5006]="INVALID_PARAMETER_LESS_THAN_ZERO",EF[EF.INVALID_PARAMETER_MIN=5007]="INVALID_PARAMETER_MIN",EF[EF.INVALID_PARAMETER_MAX=5008]="INVALID_PARAMETER_MAX",EF[EF.INVALID_ELEMENT_ID=5009]="INVALID_ELEMENT_ID",EF[EF.INVALID_ELEMENT_ID_TYPE=5010]="INVALID_ELEMENT_ID_TYPE",EF[EF.INVALID_STREAM_ID=5011]="INVALID_STREAM_ID",EF[EF.INVALID_ROOM_ID_STRING=5012]="INVALID_ROOM_ID_STRING",EF[EF.INVALID_ROOM_ID_INTEGER=5013]="INVALID_ROOM_ID_INTEGER",EF[EF.INVALID_STREAM_TYPE=5014]="INVALID_STREAM_TYPE",EF[EF.INVALID_ROOM_ID_REQUIED=5015]="INVALID_ROOM_ID_REQUIED",EF[EF.INVALID_ROOM_ID_INTEGER_STRING=5016]="INVALID_ROOM_ID_INTEGER_STRING",EF[EF.INVALID_BUFFER_EMPTY=5017]="INVALID_BUFFER_EMPTY",EF[EF.INVALID_BUFFER_OVERSIZE=5018]="INVALID_BUFFER_OVERSIZE",EF[EF.INVALID_OPERATION=5100]="INVALID_OPERATION",EF[EF.INVALID_OPERATION_NOT_JOINED=5101]="INVALID_OPERATION_NOT_JOINED",EF[EF.INVALID_OPERATION_REMOTE_USER_NOT_EXIST=5102]="INVALID_OPERATION_REMOTE_USER_NOT_EXIST",EF[EF.INVALID_OPERATION_STREAM_TYPE_NOT_EXIST=5103]="INVALID_OPERATION_STREAM_TYPE_NOT_EXIST",EF[EF.INVALID_OPERATION_REPEAT_CALL=5104]="INVALID_OPERATION_REPEAT_CALL",EF[EF.INVALID_OPERATION_NEED_VIDEO=5105]="INVALID_OPERATION_NEED_VIDEO",EF[EF.INVALID_OPERATION_NEED_AUDIO=5106]="INVALID_OPERATION_NEED_AUDIO",EF[EF.INVALID_ROLE_AUDIENCE=5107]="INVALID_ROLE_AUDIENCE",EF[EF.INVALID_NOT_ENABLE_SEI=5108]="INVALID_NOT_ENABLE_SEI",EF[EF.INVALID_NEED_CALL_PUBLISHED=5109]="INVALID_NEED_CALL_PUBLISHED",EF[EF.ENV_NOT_SUPPORTED=5200]="ENV_NOT_SUPPORTED",EF[EF.NOT_SUPPORTED_HTTP=5201]="NOT_SUPPORTED_HTTP",EF[EF.NOT_SUPPORTED_WEBRTC=5202]="NOT_SUPPORTED_WEBRTC",EF[EF.NOT_SUPPORTED_H264_ENCODE=5203]="NOT_SUPPORTED_H264_ENCODE",EF[EF.NOT_SUPPORTED_H264_DECODE=5204]="NOT_SUPPORTED_H264_DECODE",EF[EF.NOT_SUPPORTED_SCREEN_SHARE=5205]="NOT_SUPPORTED_SCREEN_SHARE",EF[EF.NOT_SUPPORTED_SMALL_VIDEO=5206]="NOT_SUPPORTED_SMALL_VIDEO",EF[EF.NOT_SUPPORTED_SEI=5207]="NOT_SUPPORTED_SEI",EF[EF.NOT_SUPPORTED_WEBGL=5208]="NOT_SUPPORTED_WEBGL",EF[EF.NOT_SUPPORTED_CHROME_VERSION=5209]="NOT_SUPPORTED_CHROME_VERSION",EF[EF.NOT_SUPPORTED_PLUGIN=5210]="NOT_SUPPORTED_PLUGIN",EF[EF.DEVICE_ERROR=5300]="DEVICE_ERROR",EF[EF.DEVICE_NOT_FOUND_ERROR=5301]="DEVICE_NOT_FOUND_ERROR",EF[EF.DEVICE_NOT_ALLOWED_ERROR=5302]="DEVICE_NOT_ALLOWED_ERROR",EF[EF.DEVICE_NOT_READABLE_ERROR=5303]="DEVICE_NOT_READABLE_ERROR",EF[EF.DEVICE_OVERCONSTRAINED_ERROR=5304]="DEVICE_OVERCONSTRAINED_ERROR",EF[EF.DEVICE_INVALID_STATE_ERROR=5305]="DEVICE_INVALID_STATE_ERROR",EF[EF.DEVICE_SECURITY_ERROR=5306]="DEVICE_SECURITY_ERROR",EF[EF.DEVICE_ABORT_ERROR=5307]="DEVICE_ABORT_ERROR",EF[EF.CAMERA_RECOVER_FAILED=5308]="CAMERA_RECOVER_FAILED",EF[EF.MICROPHONE_RECOVER_FAILED=5309]="MICROPHONE_RECOVER_FAILED",EF[EF.SERVER_ERROR=5400]="SERVER_ERROR",EF[EF.NEED_TO_BUY=5401]="NEED_TO_BUY",EF[EF.ACCOUNT_NO_MONEY=-100013]="ACCOUNT_NO_MONEY",EF[EF.OPERATION_FAILED=5500]="OPERATION_FAILED",EF[EF.FIREWALL_RESTRICTION=5501]="FIREWALL_RESTRICTION",EF[EF.REJOIN_FAILED=5502]="REJOIN_FAILED",EF[EF.EVENT_HANDLER_ERROR=5503]="EVENT_HANDLER_ERROR",EF[EF.VIDEO_CONTEXT_ERROR=5504]="VIDEO_CONTEXT_ERROR",EF[EF.VIDEO_DECODE_ERROR=5505]="VIDEO_DECODE_ERROR",EF[EF.OPERATION_ABORT=5998]="OPERATION_ABORT",EF[EF.UNKNOWN_ERROR=5999]="UNKNOWN_ERROR",EF),bF=$A(QA({},hO),{INVALID_PARAMETER:function(e){var t=e.fnName;return"the parameters of the '".concat(t,"' you called does not meet the requirements, please check the API documentation.")},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,n=e.key,r=e.rule,i=e.fnName,a=e.value,o="".concat(n||r.name);return t=Array.isArray(r.type)?r.type.join("|"):r.type,"'".concat(o,"' must be type of ").concat(t," when calling ").concat(i,"(), received type: ").concat(kw(a),".")},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,a="".concat(t||n.name),o="".concat(n.instanceOf.name||n.instanceOf);return"'".concat(a,"' must be instanceof ").concat(o," when calling ").concat(r,"(), received type: ").concat(kw(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,".")},INVALID_PARAMETER_LESS_THAN_ZERO:function(e){var t=e.key,n=e.rule,r=e.fnName;return"'".concat(t||n.name,"' cannot be less than 0 when calling ").concat(r,"().")},INVALID_PARAMETER_MIN:function(e){var t=e.key,n=e.rule,r=e.value;return"the min value of ".concat(t||n.name," is ").concat(n.min,", received: ").concat(r,".")},INVALID_PARAMETER_MAX:function(e){var t=e.key,n=e.rule,r=e.value;return"the max value of ".concat(t||n.name," is ").concat(n.max,", received: ").concat(r,".")},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 HTMLElement when calling ").concat(n,"(), received: ").concat(r,".")},INVALID_STREAM_ID:function(e){var t=e.key;return"'".concat(t,"' can only consist of uppercase and lowercase english letters (a-zA-Z), numbers (0-9), hyphens and underscores.")},INVALID_ROOM_ID_STRING:function(e){var t=e.key;return"'".concat(t,"' must be a valid string.")},INVALID_ROOM_ID_INTEGER:function(e){var t=e.key;return"'".concat(t,"' must be an integer between [1, 4294967294].")},INVALID_ROOM_ID_INTEGER_STRING:function(e){var t=e.key;return"'".concat(t,"' must be an integer but go a string, use 'parseInt' to convert it or use 'strRoomId' instead.")},INVALID_ROOM_ID_REQUIED:function(){return"at least one of 'roomId'(between [1, 4294967294]) and 'strRoomId'(not empty) is required."},INVALID_STREAM_TYPE:function(e){var t=e.fnName;return"'streamType' is required when 'userId' is not '*', calling ".concat(t,"()")},INVALID_IMAGE_URL:"The 'src' param must be filled in when the background type is image.",INVALID_OPERATION:function(e){var t=e.fnName;return"the API '".concat(t,"' you called does not meet the requirements, please check the API documentation.")},INVALID_OPERATION_NOT_JOINED:function(e){var t=e.fnName;return"cannot ".concat(t," because you are not enter room yet.")},INVALID_OPERATION_REMOTE_USER_NOT_EXIST:function(e){var t=e.fnName,n=e.value;return"cannot ".concat(t," because remote user(userId: ").concat(n.userId,") does not publishing stream.")},INVALID_OPERATION_STREAM_TYPE_NOT_EXIST:function(e){var t=e.fnName,n=e.value;return"cannot ".concat(t," because remote user(userId: ").concat(n.userId,") does not publishing ").concat(n.streamType," video.")},INVALID_OPERATION_REPEAT_CALL:function(e){var t=e.fnName;return"you are already ".concat(t,"(), cannot repeated call '").concat(t,"'.")},INVALID_OPERATION_NEED_VIDEO:function(e){var t=e.fnName;return"cannot call '".concat(t,"' because the camera is not turned on.")},INVALID_OPERATION_NEED_AUDIO:function(e){var t=e.fnName;return"cannot call '".concat(t,"' because the microphone is not turned on.")},INVALID_BUFFER_EMPTY:function(e){var t=e.key;return"the buffer size of paramerter '".concat(t,"' cannot be empty")},INVALID_BUFFER_OVERSIZE:function(){return"buffer size is over 1000 Bytes"},INVALID_ROLE_AUDIENCE:function(){return"role: 'audience' cannot call this api."},INVALID_NOT_ENABLE_SEI:function(){return"you need to enable SEI in TRTC.create({ enableSEI: true })"},INVALID_NEED_CALL_PUBLISHED:function(e){var t=e.fnName;return"you need to call ".concat(t,"() after publish stream.")},ENV_NOT_SUPPORTED:function(e){var t=e.fnName;return"the current browser does not support the capability of the function '".concat(t,"' you are calling, please check the API documentation.")},NOT_SUPPORTED_WEBRTC:"the current browser does not support WebRTC capability, please check the SDK documentation.",NOT_SUPPORTED_H264_ENCODE:"this browser does not support H264 encode.",NOT_SUPPORTED_H264_DECODE:"this browser does not support H264 decode.",NOT_SUPPORTED_SCREEN_SHARE:"this browser does not support screen share, please check the browser version.",NOT_SUPPORTED_SMALL_VIDEO:"this browser does not support small video, please check the browser version.",NOT_SUPPORTED_SEI:"this browser does not support SEI, please check the browser version.",NOT_SUPPORTED_WEBGL:"this browser does not support WebGL, please check the browser version.",NOT_SUPPORTED_CHROME_VERSION:function(e){var t=e.fnName;return"cannot call ".concat(t," because the browser version is too low, please upgrade to the latest version")},DEVICE_ERROR:function(e){var t=e.fnName,n=e.error;return"'".concat(t,"' got device exception").concat(n?", error: ".concat(n.toString(),"."):".")},DEVICE_NOT_FOUND_ERROR:function(e){var t=e.fnName,n=e.deviceType,r=void 0===n?AF(t):n,i=e.error;return"NotFoundError, no ".concat(r," detected, please check your device and the configuration on '").concat(t,"'").concat(i?", error: ".concat(i.toString(),"."):".")},DEVICE_NOT_ALLOWED_ERROR:function(e){var t=e.fnName,n=e.deviceType,r=void 0===n?AF(t):n,i=e.error;return"NotAllowedError, you have disabled ".concat(r," access, please allow the current application to use the ").concat(r).concat(i?", error: ".concat(i.toString(),"."):".")},DEVICE_NOT_READABLE_ERROR:function(e){var t=e.fnName,n=e.deviceType,r=void 0===n?AF(t):n;return e.error,"NotReadableError, the ".concat(r," maybe in use by another APP, please check if the device is pre-occupied by another APP.")},DEVICE_OVERCONSTRAINED_ERROR:function(e){var t=e.fnName,n=e.deviceType;void 0===n&&AF(t);var r=e.error;return"OverconstrainedError, the device ID is incorrect, please check whether the device ID passed in is correct".concat(r?", error: ".concat(r.toString(),"."):".")},DEVICE_INVALID_STATE_ERROR:function(e){var t=e.fnName,n=e.deviceType,r=void 0===n?AF(t):n,i=e.error;return"InvalidStateError, after the user clicks and interacts with the page, turn on the ".concat(r).concat(i?", error: ".concat(i.toString(),"."):".")},DEVICE_SECURITY_ERROR:function(e){var t=e.fnName,n=e.deviceType,r=void 0===n?AF(t):n,i=e.error;return"SecurityError, check whether the system security policy restricts the use of the ".concat(r,", and it is recommended to turn on the ").concat(r," after the user interacts with the page").concat(i?", error: ".concat(i.toString(),"."):".")},DEVICE_ABORT_ERROR:function(e){var t=e.fnName,n=e.deviceType;void 0===n&&AF(t);var r=e.error;return"AbortError, an unknown exception in the system makes the device unusable, recommended to change the device or browser and re-check whether the device is normal".concat(r?" error: ".concat(r.toString(),"."):".")},CAMERA_RECOVER_FAILED:function(e){var t=e.error;return"camera recover capture failed ".concat((null==t?void 0:t.name)||"",": ").concat((null==t?void 0:t.originMessage)||(null==t?void 0:t.message))},MICROPHONE_RECOVER_FAILED:function(e){var t=e.error;return"microphone recover capture failed ".concat((null==t?void 0:t.name)||"",": ").concat((null==t?void 0:t.originMessage)||(null==t?void 0:t.message))},OPERATION_FAILED:function(e){var t=e.fnName,n=e.error;return"'".concat(t,"' failed, reason: ").concat(null==n?void 0:n.toString())},FIREWALL_RESTRICTION:function(){return"media connection failure due to firewall restrictions, please try to change your network."},EVENT_HANDLER_ERROR:function(e){var t=e.eventName;return"an error was caught on trtc.on('".concat(t,"', handler), please check your code on 'handler'.")},VIDEO_CONTEXT_ERROR:function(e){var t=e.reason,n=e.error;return"video context error ".concat(t," ").concat((null==n?void 0:n.name)||""," ").concat((null==n?void 0:n.message)||"")},SERVER_ERROR:function(e){var t=e.fnName,n=e.error;return"'".concat(t,"' got server error: ").concat(null==n?void 0:n.toString(),", please check the SDK documentation.")},NEED_TO_BUY:function(e){var t=e.value,n=e.url;return"You need to buy packages for ".concat(t,". Refer to: ").concat(n)},ACCOUNT_NO_MONEY:function(e){var t=e.fnParams;return"your TRTC account run out of credit, please recharge.".concat(t.sdkAppId?" SDKAppId: ".concat(t.sdkAppId):"")},OPERATION_ABORT:function(e){var t=e.fnName;return"'".concat(t,"' abort")},UNKNOWN_ERROR:function(e){var t=e.fnName,n=e.error;return"'".concat(t,"' throw unknown exception").concat(n?", error: ".concat(n.toString(),"."):".")}});function AF(e){if(!e)return"camera";var t=e.toLowerCase();return t.includes("screen")?"screen share":t.includes("audio")?"microphone":"camera"}var RF=function(e){function i(e){var a;r(this,i);var o,s,c=e.code,u=e.extraCode,l=e.message,d=void 0===l?"":l,h=e.messageParams,f=e.fnName,p=void 0===f?"":f,m=e.originError;return s=d||function(e){var t,n=e.params,r=e.enableDocLink,i=void 0!==r&&r,a="",o=IF[e.code];try{t=bF[o]}catch(p){t=bF.UNKNOWN_ERROR}return Sw(t)?a=t(n):bw(t)&&(a=t),n.fnName&&!a.includes(n.fnName)&&("."!==a[a.length-1]&&(a+="."),a+=" thrown from ".concat(n.fnName,"()")),i&&(a+=" doc:"),a}({code:c===SF.SERVER_ERROR?c:u||c,params:QA({fnName:p,error:m},h)}),a=n(this,i,[s]),rR(t(a),"name","RtcError"),rR(t(a),"code"),rR(t(a),"extraCode"),rR(t(a),"functionName"),rR(t(a),"message"),rR(t(a),"handler"),rR(t(a),"originError"),a.name=IF[c],a.code=c,a.extraCode=u,a.functionName=p,a.originError=m,a.message=s,5302===a.extraCode&&null!=(o=a.originError)&&o.message.includes("system")&&(a.handler=function(){var e=document.createElement("a");aN?e.href="ms-settings:privacy-".concat({startLocalVideo:"webcam",startLocalAudio:"microphone"}[a.functionName]):oN&&(e.href="x-apple.systempreferences:com.apple.preference.security?Privacy_".concat({startLocalVideo:"Camera",startLocalAudio:"Microphone",startScreenShare:"ScreenCapture"}[a.functionName])),e.href.length>0&&e.click()}),a}return d(i,e),o(i,null,[{key:"convertFrom",value:function(e,t,n){var r=e;if(e instanceof yR){var a=e.stack,o={code:SF.UNKNOWN_ERROR,fnName:t,originError:e};switch(e.getCode()){case _R.INVALID_PARAMETER:o.code=SF.INVALID_PARAMETER,o.message=e.message;break;case _R.INVALID_OPERATION:o.code=SF.INVALID_OPERATION;break;case _R.NOT_SUPPORTED:case _R.NOT_SUPPORTED_H264:o.code=SF.ENV_NOT_SUPPORTED,e.getCode()===_R.NOT_SUPPORTED_H264&&(o.extraCode=e.message.includes(hO.NOT_SUPPORTED_H264ENCODE)?5203:5204);break;case _R.JOIN_ROOM_FAILED:o.messageParams={fnParams:n};case _R.SERVER_TIMEOUT:case _R.SWITCH_ROLE_FAILED:o.code=SF.SERVER_ERROR,o.extraCode=e.getExtraCode();break;case _R.API_CALL_ABORTED:o.code=SF.OPERATION_ABORT;break;case _R.DEVICE_NOT_FOUND:case _R.DEVICE_AUTO_RECOVER_FAILED:case _R.INITIALIZE_FAILED:o.code=5300,e.name&&(o.extraCode=function(e){var t;switch(e){case"NotFoundError":t=5301;break;case"NotAllowedError":t=5302;break;case"NotReadableError":t=5303;break;case"OverconstrainedError":t=5304;break;case"InvalidStateError":t=5305;break;case"SecurityError":t=5306;break;case"AbortError":t=5307;break;default:t=5300}return t}(e.name));break;case _R.UNKNOWN:break;default:o.code=SF.OPERATION_FAILED}r=new i(o),a&&(r.stack+=a.substr(a.indexOf("\n")))}else{if(e instanceof i)return e;r=new i({code:SF.UNKNOWN_ERROR,fnName:t,originError:e})}return r}}])}(I(Error)),CF=RF,wF={type:"object",properties:{cameraId:{type:"string"},useFrontCamera:{type:"boolean"},fillMode:{type:"string",values:["contain","cover","fill"]},mirror:{type:["string","boolean"],values:[!0,!1,"view","publish","both"]},small:{properties:{width:{type:"number"},height:{type:"number"},frameRate:{type:"number"},bitrate:{type:"number"}}},videoTrack:{instanceOf:MediaStreamTrack}}},DF={type:"object",properties:{systemAudio:{type:"boolean"},fillMode:{type:"string",values:["contain","cover","fill"]},profile:{type:["string","object"],properties:{width:{type:"number"},height:{type:"number"},frameRate:{type:"number"},bitrate:{type:"number"}}},videoTrack:{instanceOf:MediaStreamTrack},audioTrack:{instanceOf:MediaStreamTrack}}},NF={type:["string",HTMLElement,null,"array"],arrayItem:{instanceOf:HTMLElement},validate:function(e,t,n){if(bw(e)&&!document.getElementById(e))throw new CF({code:SF.INVALID_PARAMETER,extraCode:5009,fnName:n,messageParams:{key:t}})}},xF={name:"userId",required:!0,type:"string"},OF={type:"object",properties:{microphoneId:{type:"string"},audioTrack:{instanceOf:MediaStreamTrack},captureVolume:{type:"number",min:0},earMonitorVolume:{type:"number",min:0,max:100},profile:{values:[kF.AUDIO_PROFILE_STANDARD,kF.AUDIO_PROFILE_STANDARD_STEREO,kF.AUDIO_PROFILE_HIGH,kF.AUDIO_PROFILE_HIGH_STEREO]},echoCancellation:{type:"boolean"},autoGainControl:{type:"boolean"},noiseSuppression:{type:"boolean"}}};function PF(e,t){if(!e)throw new CF({code:SF.INVALID_OPERATION,extraCode:5101,fnName:t})}function MF(e,t,n){if(!e)throw new CF({code:SF.INVALID_OPERATION,extraCode:5102,fnName:t,messageParams:{value:n}})}var LF={create:[{name:"RoomConfig",instanceOf:Function},{name:"CreateConfig",type:"object",properties:{plugins:{type:"array",arrayItem:{instanceOf:Function}}}}],enterRoom:{name:"EnterRoomConfig",type:"object",required:!0,validate:function(e,t,n){if(this._room.isJoined)throw new CF({code:SF.INVALID_OPERATION,extraCode:5104,fnName:n});if(e.roomId){if(bw(e.roomId))throw new CF({code:SF.INVALID_PARAMETER,extraCode:5016,fnName:n,messageParams:{key:t}});if(!(/^[1-9]\d*$/.test(String(e.roomId))&&e.roomId<4294967295))throw new CF({code:SF.INVALID_PARAMETER,extraCode:5013,fnName:n,messageParams:{key:t}})}else{if(!e.strRoomId)throw new CF({code:SF.INVALID_PARAMETER,extraCode:5015,fnName:n});if(!/^[A-Za-z\d\s!#$%&()+\-:;<=.>?@[\]^_{}|~,]{1,64}$/.test(e.strRoomId))throw new CF({code:SF.INVALID_PARAMETER,extraCode:5012,fnName:n,messageParams:{key:t}})}},properties:{sdkAppId:{required:!0,type:"number",allowEmpty:!1},userId:{required:!0,type:"string",allowEmpty:!1},userSig:{required:!0,type:"string",allowEmpty:!1},scene:{type:"string",values:["live","rtc"]},role:{type:"string",values:["audience","anchor"]},roomId:{type:["string","number"]},strRoomId:{type:"string"},proxy:{type:["object","string"],properties:{websocketProxy:{type:"string"},turnServer:{type:["object","array"],properties:{url:{required:!0,type:"string"},username:{type:"string"},credential:{type:"string"},credentialType:{type:"string",values:["password"]}}},loggerProxy:{type:"string"},webtransportProxy:{type:"string"}}},enableAutoPlayDialog:{type:"boolean"},userDefineRecordId:{type:"string"},latencyLevel:{type:"number"},playoutDelay:{type:"object",properties:{min:{type:"number",min:0,max:1e3},max:{type:"number",min:0,max:1e4}}}}},startLocalVideo:{name:"LocalVideoConfig",type:"object",properties:{view:NF,mute:{type:["boolean","string"]},publish:{type:"boolean"},option:wF},validate:function(e){var t;if((null==(t=null==e?void 0:e.option)||!t.videoTrack)&&OO())throw new CF({code:SF.ENV_NOT_SUPPORTED,extraCode:5201})}},updateLocalVideo:{name:"updateLocalVideoConfig",type:"object",required:!0,properties:{view:$A(QA({},NF),{required:!1}),publish:{type:"boolean"},mute:{type:["boolean","string"]},option:wF}},startLocalAudio:{name:"LocalAudioConfig",type:"object",properties:{publish:{type:"boolean"},option:OF},validate:function(e){var t;if((null==(t=null==e?void 0:e.option)||!t.audioTrack)&&OO())throw new CF({code:SF.ENV_NOT_SUPPORTED,extraCode:5201})}},updateLocalAudio:{name:"updateLocalAudioConfig",type:"object",required:!0,properties:{publish:{type:"boolean"},mute:{type:"boolean"},option:OF}},startScreenShare:{name:"ScreenShareConfig",type:"object",properties:{view:NF,publish:{type:"boolean"},option:DF},validate:function(e,t,n,r,i){var a;if(null==(a=null==e?void 0:e.option)||!a.videoTrack){if(OO())throw new CF({code:SF.ENV_NOT_SUPPORTED,extraCode:5201});if(!FO())throw new CF({code:SF.ENV_NOT_SUPPORTED,fnName:n,extraCode:5205})}}},updateScreenShare:{name:"updateScreenShareConfig",type:"object",required:!0,properties:{view:NF,publish:{type:"boolean"},option:DF}},muteRemoteAudio:[xF,{name:"mute",required:!0,type:"boolean"}],setRemoteAudioVolume:[xF,{name:"volume",required:!0,type:"number",min:0}],startRemoteVideo:{name:"startRemoteVideoConfig",type:"object",required:!0,properties:{view:NF,userId:{type:"string",required:!0},streamType:{values:["main","sub"],required:!0},option:{type:"object",properties:{fillMode:{type:"string",values:["contain","cover","fill"]},mirror:{type:"boolean"}}}},validate:function(e,t,n){PF(this._room.isJoined,n);var r=this._room.remotePublishedUserMap.get(e.userId);if(MF(!!r,n,e),r&&("main"===e.streamType&&!r.muteState.videoAvailable||"sub"===e.streamType&&!r.muteState.hasAuxiliary))throw new CF({code:SF.INVALID_OPERATION,extraCode:5103,fnName:n,messageParams:{value:e}})}},updateRemoteVideo:{name:"updateRemoteVideoConfig",type:"object",required:!0,properties:{view:$A(QA({},NF),{required:!1}),userId:{type:"string",required:!0},streamType:{values:["main","sub"],required:!0},option:{type:"object",properties:{fillMode:{type:"string",values:["contain","cover","fill"]},mirror:{type:"boolean"}}}},validate:function(e,t,n){PF(this._room.isJoined,n);var r=this._room.remotePublishedUserMap.get(e.userId);if(MF(!!r,n,e),r&&("main"===e.streamType&&!r.muteState.videoAvailable||"sub"===e.streamType&&!r.muteState.hasAuxiliary))throw new CF({code:SF.INVALID_OPERATION,extraCode:5103,fnName:n,messageParams:{value:e}})}},stopRemoteVideo:{name:"stopRemoteVideoConfig",type:"object",required:!0,properties:{userId:{type:"string",required:!0},streamType:{values:["main","sub"]}},validate:function(e,t,n){if("*"!==e.userId&&Iw(e.streamType))throw new CF({code:SF.INVALID_PARAMETER,extraCode:5014,fnName:n})}},switchRole:{name:"role",required:!0,values:["anchor","audience"],validate:function(e,t,n){PF(this._room.isJoining||this._room.isJoined,n)}},enableAudioVolumeEvaluation:[{name:"interval",type:"number"},{name:"enableInBackground",type:"boolean"}],sendSEIMessage:[{name:"buffer",required:!0,instanceOf:ArrayBuffer,validate:function(e,t,n,r){if(!uP)throw new CF({code:SF.ENV_NOT_SUPPORTED,fnName:n,extraCode:5207});if(!this._room.enableSEI)throw new CF({code:SF.INVALID_OPERATION,fnName:n,extraCode:5108});if(e.byteLength>1e3)throw new CF({code:SF.INVALID_PARAMETER,extraCode:5018,fnName:n});if(0===e.byteLength)throw new CF({code:SF.INVALID_PARAMETER,extraCode:5017,messageParams:{key:t},fnName:n});PF(this._room.isJoined,n)}},{name:"options",type:"object",properties:{seiPayloadType:{type:"number",values:[5,243]},toSubStream:{type:"boolean",validate:function(e,t,n){if(!e&&!this._room.isMainStreamPublished||e&&!this._room.isAuxStreamPublished)throw new CF({code:SF.INVALID_OPERATION,extraCode:5109,messageParams:{key:t},fnName:n})}}}}],sendCustomMessage:{name:"message",required:!0,type:"object",properties:{cmdId:{type:"number",required:!0,min:1,max:10},data:{instanceOf:ArrayBuffer,required:!0,validate:function(e,t,n,r){if(e.byteLength>1e3)throw new CF({code:SF.INVALID_PARAMETER,extraCode:5018,fnName:n});if(0===e.byteLength)throw new CF({code:SF.INVALID_PARAMETER,extraCode:5017,fnName:n,messageParams:{key:t}})}}},validate:function(e,t,n){if(PF(this._room.isJoined,n),"live"===this._room.scene&&"audience"===this._room.role)throw new CF({code:SF.INVALID_OPERATION,extraCode:5107,fnName:n,messageParams:{key:t}})}}},VF={TRTC:LF},UF=function(e){function t(){return r(this,t),n(this,t,arguments)}return d(t,e),o(t)}(I(Error));function FF(e,t){for(var n=Kw(e),r=0;r<t.length;r++)Jw(n[r],t[r]);return n}function BF(e){this._resolve=Promise.resolve(e)}function jF(e){this._reject=Promise.reject(e)}var HF=function(){function e(t,n){r(this,e),this.instance=t,this.group=n,rR(this,"started",!1),rR(this,"ops",[]),rR(this,"startSame",(function(){return!0})),rR(this,"mergeUpdate",FF);var i=e.instances.get(t);i?i.set(n,this):e.instances.set(t,new Map([[n,this]]))}return o(e,[{key:"action",value:function(e,t,n){var r=this,i=function(t){var n;return 0===e?r.started=!0:3===e&&(r.started=!1),r.ops.shift(),null==(n=r.currentOp)||n.action(),t},a=function(t){var n,i;throw r.ops.shift(),0===e&&2===(null==(n=r.currentOp)?void 0:n.type)&&r.ops.shift().reject(new UF("start failed")),null==(i=r.currentOp)||i.action(),t},o={type:e,action:function(){return t.apply(void 0,E(o.args)).then(i,a)},args:n,resolve:BF,reject:jF};try{switch(this.state){case 1:if(0===e)throw new UF("already started");break;case 4:if(2===e)throw new UF("not started");break;default:return this.cacheOp(o)}}catch(_x){return Promise.reject(_x)}return this.ops.push(o),o.promise=t.apply(void 0,E(o.args)).then(i,a)}},{key:"cacheOp",value:function(e){if(1===this.ops.length)switch(this.state){case 0:case 2:if(0===e.type)throw new UF("already start");break;case 3:switch(e.type){case 2:throw new UF("update not allowed when stopping");case 3:return this.currentOp.promise}break;default:throw new UF("unknown state")}else switch(e.type){case 3:if(3===this.lastOpType)return this.lastOp.promise;var t=new UF("keep stop");if(this.ops.slice(1).forEach((function(e){return e.reject(t)})),this.ops=this.ops.slice(0,1),3===this.state)return this.currentOp.promise;break;case 2:switch(this.lastOpType){case 2:return this.lastOp.args=this.mergeUpdate(this.lastOp.args,e.args),this.lastOp.promise;case 3:throw new UF("update not allowed after stop")}break;case 0:switch(this.lastOpType){case 2:throw new UF("start not allowed after update");case 0:throw new UF("duplicate start");case 3:if(this.startSame(this.currentOp.args,e.args))throw this.ops.pop().reject(new UF("keep start")),new UF("already start")}}e.promise=new Promise((function(t,n){e._resolve?e._resolve.then(t):e.resolve=t,e._reject?e._reject.catch(n):e.reject=n}));var n=e.action;return e.action=function(){return n().then(e.resolve,e.reject)},this.ops.push(e),e.promise}},{key:"lastOp",get:function(){return this.ops[this.ops.length-1]}},{key:"lastOpType",get:function(){return this.lastOp.type}},{key:"currentOp",get:function(){return this.ops[0]}},{key:"state",get:function(){return this.currentOp?this.currentOp.type:this.started?1:4}}],[{key:"get",value:function(t,n){if(n){var r=e.instances.get(t);return r&&r.get(n)||new e(t,n)}}},{key:"gets",value:function(t,n){var r=e.instances.get(t),i=[];return r&&r.forEach((function(e,t){n.test(t)&&i.push(e)})),i}}])}();rR(HF,"instances",new WeakMap);var GF=HF,WF=new WeakMap,JF=function(e,t){if(t instanceof UF){var n=t.stack;t=new CF({code:SF.OPERATION_ABORT,message:"".concat(e," abort: ").concat(t.message),fnName:e}),n&&(t.stack+=n.substr(n.indexOf("\n")))}throw t};function KF(e,t){return uL((function(n,r){return function(){for(var i=arguments.length,a=new Array(i),o=0;o<i;o++)a[o]=arguments[o];var s=GF.get(this,"string"==typeof e?e:e.call.apply(e,[this].concat(a)));return s?(t&&(s.startSame=t.bind(this)),s.action(0,n.bind(this),a).catch(JF.bind(null,r))):n.apply(this,a)}}))}function zF(e,t){var n=t||{},r=n.merge,i=n.debounce;return uL((function(t,n){return function(){for(var a=this,o=arguments.length,s=new Array(o),c=0;c<o;c++)s[c]=arguments[c];var u=GF.get(this,"string"==typeof e?e:e.call.apply(e,[this].concat(s)));if(!u)return t.apply(this,s);if(r&&(u.mergeUpdate=r.bind(this)),i&&i.isNeedToDebounce.apply(this,s)){var l=i.delay,d=i.getKey;return new Promise((function(e,r){var i,o,c=null==(i=WF.get(a))?void 0:i.get(d.apply(void 0,s));if(c){var h=c.timeoutId,f=c.resolve;clearTimeout(h),f()}var p=setTimeout((function(){if(3===u.state||4===u.state)return e();u.action(2,t.bind(a),s).catch(JF.bind(null,n)).then(e,r)}),l);WF.has(a)?null==(o=WF.get(a))||o.set(d.apply(void 0,s),{timeoutId:p,resolve:e}):WF.set(a,new Map([[d.apply(void 0,s),{timeoutId:p,resolve:e}]]))}))}return u.action(2,t.bind(this),s).catch(JF.bind(null,n))}}))}function YF(e){return uL((function(t,n){return function(){for(var r=this,i=arguments.length,a=new Array(i),o=0;o<i;o++)a[o]=arguments[o];var s="function"==typeof e?e.call.apply(e,[this].concat(a)):e;if(s instanceof RegExp)return Promise.all(GF.gets(this,s).map((function(e){return e.action(3,(function(){return Promise.resolve()}),a)}))).then((function(){return t.call.apply(t,[r].concat(a))}));var c=GF.get(this,s);return c?c.action(3,t.bind(this),a).catch(JF.bind(null,n)):t.apply(this,a)}}))}var qF={ERROR:"error",AUTOPLAY_FAILED:"autoplay-failed",KICKED_OUT:"kicked-out",REMOTE_USER_ENTER:"remote-user-enter",REMOTE_USER_EXIT:"remote-user-exit",REMOTE_AUDIO_AVAILABLE:"remote-audio-available",REMOTE_AUDIO_UNAVAILABLE:"remote-audio-unavailable",REMOTE_VIDEO_AVAILABLE:"remote-video-available",REMOTE_VIDEO_UNAVAILABLE:"remote-video-unavailable",AUDIO_VOLUME:"audio-volume",AUDIO_FRAME:"audio-frame",NETWORK_QUALITY:"network-quality",CONNECTION_STATE_CHANGED:"connection-state-changed",AUDIO_PLAY_STATE_CHANGED:"audio-play-state-changed",VIDEO_PLAY_STATE_CHANGED:"video-play-state-changed",SCREEN_SHARE_STOPPED:"screen-share-stopped",DEVICE_CHANGED:"device-changed",PUBLISH_STATE_CHANGED:"publish-state-changed",TRACK:"track",STATISTICS:"statistics",SEI_MESSAGE:"sei-message",CUSTOM_MESSAGE:"custom-message",VIDEO_DECODE_DOWNGRADE_STATE_CHANGED:"video-decode-downgrade-state-changed",LAYER_DATA:"layerData",FIRST_VIDEO_FRAME:"first-video-frame"},XF=new Set([qF.ERROR,qF.AUTOPLAY_FAILED,qF.KICKED_OUT,qF.REMOTE_USER_ENTER,qF.REMOTE_USER_EXIT,qF.REMOTE_AUDIO_AVAILABLE,qF.REMOTE_AUDIO_UNAVAILABLE,qF.REMOTE_VIDEO_AVAILABLE,qF.REMOTE_VIDEO_UNAVAILABLE,qF.CONNECTION_STATE_CHANGED,qF.PUBLISH_STATE_CHANGED,qF.SCREEN_SHARE_STOPPED,qF.DEVICE_CHANGED,qF.FIRST_VIDEO_FRAME]);function QF(e){return"sub"===e?"auxiliary":"auxiliary"===e?"sub":"main"}function $F(e){return e===kF.QOS_PREFERENCE_CLEAR?"detail":e===kF.QOS_PREFERENCE_SMOOTH?"motion":""}var ZF={};eR(ZF,{bytes2ms:function(){return fw},convertObjectNumberToInt:function(){return nD},copyProperties:function(){return hw},deepClone:function(){return Kw},deepMerge:function(){return Jw},delay:function(){return rD},fibonacci:function(){return Ew},formatedTime:function(){return qw},getConstructorName:function(){return Pw},getContainerFromElement:function(){return Yw},getEnv:function(){return iw},getInternalVersion:function(){return Fw},getLoggerUrl:function(){return ow},getMuteStateFromFlag:function(){return Hw},getNetworkType:function(){return cw},getNumNetworkType:function(){return dw},getReconnectionTimeout:function(){return Tw},getStringByteLength:function(){return $w},getTurnServer:function(){return Gw},getUint32Version:function(){return tD},getValueType:function(){return kw},getViewListFromView:function(){return zw},glog:function(){return _w},ipv4ToUint32:function(){return Ww},isArray:function(){return ww},isAudioWorkletSupported:function(){return Mw},isBoolean:function(){return Rw},isConstructor:function(){return Ow},isEmpty:function(){return jw},isFunction:function(){return Sw},isLangChinese:function(){return gw},isMediaStreamTrack:function(){return Dw},isNumber:function(){return Aw},isObject:function(){return Cw},isOverseaSdkAppId:function(){return aw},isPlainObject:function(){return yw},isPortrait:function(){return Zw},isPromise:function(){return xw},isRemoteTrack:function(){return Nw},isString:function(){return bw},isUndefined:function(){return Iw},loadImage:function(){return eD},ms2bytes:function(){return mw},ms2samples:function(){return vw},performanceNow:function(){return Vw},promiseAny:function(){return Lw},samples2ms:function(){return pw},setNetworkType:function(){return lw},stringify:function(){return Xw},stringifyIncludeValue:function(){return Qw},throttlePromise:function(){return iD}});var eB={};eR(eB,{ScheduleRequestType:function(){return sB},getAbilityConfig:function(){return uB},getScheduleDomain:function(){return lB},isNeedToSchedule:function(){return nB},scheduleProxy:function(){return aB},sendScheduleRequest:function(){return iB},setIsNeedToSchedule:function(){return rB},setScheduleProxy:function(){return oB}});var tB=null,nB=!0;function rB(e){Rw(e)&&e!==nB&&(nB=e,sx.info("setIsNeedToSchedule ".concat(e)))}function iB(e){return aR(this,arguments,(function(e){var t=e.userId,n=e.sdkAppId,r=e.useStringRoomId,i=e.roomId,a=e.userSig,o=e.version,c=e.frameWorkType,u=e.role,l=e.latencyLevel;return f().mark((function e(){var d,h,p,m,v,_,g,y,E;return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(nB||!tB){e.next=2;break}return e.abrupt("return",{isCached:!0,result:tB});case 2:return d={delta:0,count:[1,1],msg:[],detail:[]},e.prev=3,(h=new FormData).append("userId",String(t)),h.append("sdkAppId",String(n)),h.append("isStrGroupId",String(r)),h.append("groupId",String(i)),h.append("sdkVersion",o),h.append("userSig",String(a)),u&&h.append("role",String(u)),l&&h.append("latencyLevel",String(l)),c&&h.append("frameWorkType",String(c)),p=Vw(),e.next=9,function(e,t,n){return new Promise((function(r,i){var a=null;Lw([hB((function(e){return t.count[0]=e+1}),(function(e){var r=e.error,i=e.retry,o=e.retriedCount,s=e.retryFuncArgs;t.msg[0]=r.message,a||(o>=1&&(s[0]=cB(n,"config",nC.MAIN,!0)),i())}))(cB(n,"config",nC.MAIN),e,{get timeout(){return 1e3*Ew(2+t.count[0])}}),hB((function(e){return t.count[1]=e+1}),(function(e){var r=e.error,i=e.retry,o=e.retriedCount,s=e.retryFuncArgs;t.msg[1]=r.message,a||(o>=2&&(s[0]=cB(n,"config",nC.BACKUP,!0)),i())}))(cB(n,"config",nC.BACKUP),e,{get timeout(){return 1e3*Ew(2+t.count[1])}})]).then((function(e){r(a=e)})).catch(i)}))}(h,d,n);case 9:return(m=e.sent).config&&(m.config.loggerDomain&&MR(m.config.loggerDomain),Rw(m.config.scheduleCache)&&rB(!m.config.scheduleCache)),d.delta=Vw()-p,v=function(e,t,n){var r={totalCost:0,local:0,dns:0,tcp:0,tls:0,request:0,response:0};try{var i,o=performance.getEntriesByType("resource"),c=cB(e,"config",nC.MAIN),u=cB(e,"config",nC.BACKUP),l=s(o);try{for(l.s();!(i=l.n()).done;){var d=i.value;if(d.startTime>=n&&(d.name===c||d.name===u)&&d.transferSize>0){var h=d.name===c?nC.MAIN:nC.BACKUP,f=Math.round(d.duration),p=Math.round(d.domainLookupStart-d.startTime),m=d.redirectStart>0?Math.round(d.redirectEnd-d.redirectStart):0,v=d.fetchStart>0?Math.round(d.domainLookupStart-d.fetchStart):0,_=Math.round(d.domainLookupEnd-d.domainLookupStart),g=Math.round(d.requestStart-d.secureConnectionStart),y=Math.round(d.secureConnectionStart-d.connectStart),E=Math.round(d.responseStart-d.requestStart),T=Math.round(d.responseEnd-d.responseStart),k=[_,g,y,E,T];jP.uploadEvent({log:"stat-schedule-net:".concat(f,"(").concat(p,"(").concat(m,"->").concat(v,")->").concat(k.join("->"),") ").concat(h),userId:t}),r=$A(QA({},r),{totalCost:f,local:p,dns:_,tcp:y,tls:g,request:E,response:T});break}}}catch(S){l.e(S)}finally{l.f()}}catch(a){sx.error("getScheduleDetailCost error",a)}return r}(Number(n),t,p),e.abrupt("return",(tB=m,{isCached:!1,result:m,detailCost:v}));case 15:throw e.prev=15,e.t0=e.catch(3),_=ww(e.t0)?e.t0[0]:e.t0,g=Aw(_.code)?_.code:0,y="schedule failed".concat(_.message?": ".concat(_.message):""),E=new yR({code:_R.SCHEDULE_FAILED,extraCode:g,message:mO({key:dO.JOIN_ROOM_FAILED,data:{error:y,code:g}})}),sx.error(y,g),E;case 19:case"end":return e.stop()}}),e,null,[[3,15]])}))()}))}"undefined"!=typeof document&&document.head.insertAdjacentHTML("beforeend",Object.values(JC).map((function(e){return'<link rel="dns-prefetch" href="https://'.concat(e,'">')})).join("\r\n")),rx.on("28",(function(){return rB(!0)})),rx.on("63",(function(){return rB(!0)})),rx.on("84",(function(){return rB(!0)})),rx.on("201",(function(e){"RECONNECTING"===e.state&&rB(!0)})),rx.on("202",(function(e){"RECONNECTING"===e.state&&rB(!0)}));var aB={main:"",backup:""};function oB(e){ww(e)?(aB.main=e[0],aB.backup=e[1]):aB.main=e}var sB=function(e){return e.CONFIG="config",e.TRTC_AUTO_CONF="trtcAutoConf",e.AUDIO_AI_AUTH="audioAiAuth",e}(sB||{});function cB(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:nC.MAIN,r=arguments.length>3&&void 0!==arguments[3]&&arguments[3];return"https://".concat(aB[n]||lB(e,n,r),"/api/v1/").concat(t)}function uB(e,t,n){var r=cB(e,t),i=cB(e,t,nC.BACKUP),a=new URLSearchParams(n).toString();return Lw([fetch("".concat(r,"?").concat(a)).then((function(e){return e.json()})),fetch("".concat(i,"?").concat(a)).then((function(e){return e.json()}))])}function lB(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:nC.MAIN,n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];return aw(e)?n?t===nC.MAIN?JC.MAIN_OVERSEA_BACKUP:JC.BACKUP_OVERSEA:t===nC.MAIN?JC.MAIN_OVERSEA:JC.BACKUP_OVERSEA:t===nC.MAIN?JC.MAIN:JC.BACKUP}function dB(e,t,n){return new Promise((function(r,i){aD({url:e,body:t,timeout:n.timeout,priority:"high"}).then((function(e){0===e.data.code?r(e.data.data):i({code:e.data.code,message:e.data.msg})})).catch(i)}))}var hB=function(e,t){return dD({retryFunction:dB,settings:{retries:3,timeout:0},onError:t,onRetrying:e})},fB=function(){return o((function e(){r(this,e),rR(this,"_log"),this._log=sx.createLogger({id:"fd"})}),[{key:"download",value:function(e,t){return aR(this,null,f().mark((function n(){var r,i,a,o,s;return f().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(r=(t||{}).type,i=void 0===r?"blob":r,e=e.replace(/(^|[^:])\/{2,}/g,"$1/"),n.prev=2,o=Vw(),!Sw(fetch)){n.next=10;break}return n.next=7,this.downloadWithFetch(e,i);case 7:n.t0=n.sent,n.next=13;break;case 10:return n.next=12,this.downloadWithXHR(e,i);case 12:n.t0=n.sent;case 13:if((a=n.t0)&&a.data){n.next=16;break}throw new Error("data is empty");case 16:return s=Vw()-o,n.abrupt("return",(this._log.info("downloaded: ".concat(e,", return type: ").concat(i,", cost: ").concat(s,"ms")),bO.addSuccessEvent({key:522700,cost:Vw()-o}),a.data));case 20:throw n.prev=20,n.t1=n.catch(2),this._log.error("failed to download: ".concat(e,", error: ").concat(n.t1)),bO.addFailedEvent({key:522700,error:n.t1}),n.t1;case 23:case"end":return n.stop()}}),n,this,[[2,20]])})))}},{key:"downloadWithFetch",value:function(e,t){return aR(this,null,f().mark((function n(){var r,i;return f().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return this._log.info("download with fetch: ".concat(e,", return type: ").concat(t)),n.prev=1,n.next=4,fetch(e);case 4:if((i=n.sent).ok){n.next=7;break}throw new Error("network response was not ok");case 7:if("arraybuffer"!==t){n.next=13;break}return n.next=10,i.arrayBuffer();case 10:n.t0=n.sent,n.next=16;break;case 13:return n.next=15,i.blob();case 15:n.t0=n.sent;case 16:return r=n.t0,n.abrupt("return",{data:r});case 20:throw n.prev=20,n.t1=n.catch(1),n.t1;case 23:case"end":return n.stop()}}),n,this,[[1,20]])})))}},{key:"downloadWithXHR",value:function(e,t){return this._log.info("download with xhr: ".concat(e,", return type: ").concat(t)),new Promise((function(n,r){var i=new XMLHttpRequest;i.open("GET",e,!0),i.responseType=t,i.onload=function(){200===i.status||0===i.status&&i.response?n({data:i.response}):r(new Error("XHR failed"))},i.onerror=r,i.send(null)}))}},{key:"loadWasm",value:function(e,t){return aR(this,null,f().mark((function n(){var r,i,a,o,s,c;return f().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(this._log.info("loadWasm ".concat(e,", importObject: ").concat(JSON.stringify(t))),r=Vw(),i=null,a=null,!Sw(WebAssembly.instantiateStreaming)||e.startsWith("data:application/octet-stream;base64,")||function(e){return e.startsWith("file://")}(e)||!Sw(fetch)){n.next=13;break}return n.prev=3,o=fetch(e),n.next=7,WebAssembly.instantiateStreaming(o,t);case 7:i=n.sent.instance,n.next=13;break;case 10:n.prev=10,n.t0=n.catch(3),a=n.t0;case 13:if(i){n.next=26;break}return n.prev=14,n.next=17,this.download(e,{type:"arraybuffer"});case 17:return s=n.sent,n.next=20,WebAssembly.instantiate(s,t);case 20:i=n.sent.instance,n.next=26;break;case 23:n.prev=23,n.t1=n.catch(14),a=n.t1;case 26:if(!i){n.next=29;break}return c=Vw()-r,n.abrupt("return",(this._log.info("loadedWasm ".concat(e,", cost: ").concat(c,"ms")),bO.addSuccessEvent({key:522701,cost:c}),i));case 29:throw this._log.error("failed to loadWasm ".concat(e,", error: ").concat(a)),bO.addFailedEvent({key:522701,error:a}),a;case 30:case"end":return n.stop()}}),n,this,[[3,10],[14,23]])})))}}])}();nR([GP({settings:{timeout:0,retries:3},onRetrying:function(e){this._log.warn("download retrying: ".concat(e))}})],fB.prototype,"download",1);var pB=new fB;function mB(e){var t=this,n=e.TRTC,r=e.room,i=e.errorModule;return{TRTC:n,room:r,assetsPath:e.assetsPath,fileDownloader:pB,innerEmitter:rx,constants:bR,environment:fD,utils:ZF,eventLogger:jP,log:this.room.getLogger(),loggerManager:sx,errorModule:i,kvStatManager:bO,rtcDectection:lx,trtc:this,rx:ML,enums:dx,schedule:eB,clearStarted:function(e,n){var r=e.getAlias(),i=GF.instances.get(t);if(i)if(n){var a=i.get(r+n);if(!a)return;a.started=!1}else i.forEach((function(e,t){t.startsWith(r)&&(e.started=!1)}))},startGetPCM:xL,createAudioNode:wM}}var vB=new WeakMap;function _B(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return uL((function(e,n){return function(){for(var r=arguments.length,i=new Array(r),a=0;a<r;a++)i[a]=arguments[a];try{yB.call(this,t,i,n,this._name)}catch(vx){return Promise.reject(vx)}return e.apply(this,i)}}))}function gB(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return uL((function(e,n){return function(){for(var r=arguments.length,i=new Array(r),a=0;a<r;a++)i[a]=arguments[a];try{yB.call(this,t,i,n,this._name)}catch(vx){throw vx}return e.apply(this,i)}}))}function yB(e,t,n,r){if(ww(e))for(var i=0;i<e.length;i++)EB.call(this,{rule:e[i],value:t[i],key:e[i].name,fnName:n,className:r});else EB.call(this,{rule:e,value:t[0],key:e.name,fnName:n,className:r})}function EB(e){var t=this,n=e.rule,r=e.value,i=e.key,a=e.fnName,o=e.className;function s(e){return{code:SF.INVALID_PARAMETER,extraCode:e,fnName:a,messageParams:{key:i,rule:n,value:r}}}if(Iw(r)){if(n.required)throw new CF(s(5001));if(Iw(n.defaultValue))return void(Sw(n.validate)&&n.validate.call(this,r,i,a,o,this));r=n.defaultValue}if(Array.isArray(n.type)){for(var c=!1,u=0;u<n.type.length;u++)null===n.type[u]&&null===r&&(c=!0),Sw(n.type[u])&&r instanceof n.type[u]&&(c=!0),bw(n.type[u])&&kw(r)===n.type[u].toLowerCase()&&(c=!0);if(!c)throw new CF({code:SF.INVALID_PARAMETER,extraCode:5002,fnName:a,messageParams:{key:i,rule:{type:n.type.map((function(e){return Ow(e)?Pw(e):bw(e)?e:kw(e)}))},value:r}})}else if(!Iw(n.type)&&kw(r)!==n.type)throw new CF(s(5002));if(!1===n.allowEmpty){var l=Aw(r)&&(0===r||Number.isNaN(r)),d=bw(r)&&""===r.trim();if(l||d)throw new CF(s(5003))}if(n.notLessThanZero&&Aw(r)&&r<0)throw new CF(s(5006));if(!Iw(n.min)&&Aw(r)&&r<n.min)throw new CF(s(5007));if(!Iw(n.max)&&Aw(r)&&r>n.max)throw new CF(s(5008));if(bw(n.instanceOf)){if(!r||r._name!==n.instanceOf)throw new CF(s(5004))}else if(Sw(n.instanceOf)&&!(r instanceof n.instanceOf))throw new CF(s(5004));if(Array.isArray(n.values)&&!n.values.includes(r))throw new CF(s(5005));var h=n.properties;yw(h)&&Cw(r)&&Object.keys(h).forEach((function(e){EB.call(t,{rule:h[e],value:r&&r[e],key:"".concat(e),fnName:a,className:o})}));var f=n.arrayItem;yw(f)&&ww(r)&&r.forEach((function(e,n){EB.call(t,{rule:f,value:e,key:"".concat(i,"[").concat(n,"]"),fnName:a,className:o})})),Sw(n.validate)&&n.validate.call(this,r,i,a,o,this)}function TB(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.getRemoteId,n=void 0===t?function(){return""}:t,r=e.replaceArg,i=e.getKVReportKey,a=e.ignoreLog;return uL((function(e,t){return function(){for(var o,s=this,c=arguments.length,u=new Array(c),l=0;l<c;l++)u[l]=arguments[l];function d(e,t,n){if(n&&n.includes(e))return"hided";if(r){var i=r.apply(void 0,u);if(u[i.argIndex]===t)return i.value}if(t===u||e in u)return t;try{return t instanceof HTMLElement?"id: ".concat(t.id," type:").concat(kw(t)):(JSON.stringify(t),t)}catch(Tx){return"type:".concat(kw(t))}}var h=this._log||sx;if(null!=a&&a.apply(void 0,u))return e.apply(this,u);u.length>0?h.info("".concat(t,"() ").concat(JSON.stringify(u,(function(e,t){return d(e,t,["userSig","privateMapKey"])})))):h.info("".concat(t,"()"));var f=i?i.apply(void 0,u):yO[t];try{var p=e.apply(this,u),m=Vw();return xw(p)?p.then((function(e){return h.info("".concat(t,"() success ").concat(n.call.apply(n,[s].concat(u)))),bO.addSuccessEvent({key:f,cost:Vw()-m}),e})).catch((function(e){var r,i=(e=CF.convertFrom.call(s,e,t,1===u.length?u[0]:u)).extraCode||e.code,a=null!=(r=e.message)&&r.includes(i)?"":" code:".concat(i);throw h.error("".concat(t,"() failed ").concat(n.call.apply(n,[s].concat(u))," ").concat(e).concat(a," params: ").concat(JSON.stringify(u,d))),bO.addFailedEvent({key:f,error:e}),e})):(bO.addSuccessEvent({key:f}),p)}catch(R){var v=(R=CF.convertFrom.call(this,R,t)).extraCode||R.code,_=null!=(o=R.message)&&o.includes(v)?"":" code:".concat(v);throw h.error("".concat(t,"() failed ").concat(R).concat(_," params: ").concat(JSON.stringify(u,d))),bO.addFailedEvent({key:f,error:R}),R}}}))}var kB=function(e){return uL((function(t,n){return function(r,i){return aR(this,null,f().mark((function a(){var o;return f().wrap((function(a){for(;;)switch(a.prev=a.next){case 0:if(o=this._plugins.get(r)){a.next=3;break}throw this._log.error("plugin ".concat(String(r)," is not found")),new CF({code:SF.OPERATION_ABORT,message:"plugin ".concat(String(r)," is not found"),fnName:n});case 3:if(!Sw(o.constructor.isSupported)||o.constructor.isSupported()){a.next=5;break}throw this._log.error("plugin ".concat(String(r)," is not supported")),new CF({code:SF.ENV_NOT_SUPPORTED,message:"plugin ".concat(String(r)," is not supported"),extraCode:5210,fnName:n});case 5:return a.abrupt("return",(yB.call(this,o.getValidateRule(e),[i],n,"TRTC"),t.call(this,o,i)));case 6:case"end":return a.stop()}}),a,this)})))}}))},SB=0,IB=function(){return o((function e(t,n){r(this,e),rR(this,"player"),rR(this,"publisher"),rR(this,"mixInput"),this.mixInput=new AM(n),t.url?(this.player=new Audio(t.url),this.player.crossOrigin="anonymous",this.publisher=new Audio(t.url),this.publisher.crossOrigin="anonymous",this.mixInput.replaceSource(this.publisher)):this.mixInput.replaceSource(t.track),this.mixInput.connect()}),[{key:"updateSettings",value:function(e){this.player&&(Iw(e.volume)||(this.volume=e.volume),Iw(e.loop)||(this.loop=e.loop),Iw(e.playbackRate)||(this.playbackRate=e.playbackRate))}},{key:"updateListener",value:function(e){if(this.player){if(e.onDurationChange){var t=e.onDurationChange;this.player.ondurationchange=function(e){t(e.target.duration)}}if(e.onTimeUpdate){var n=e.onTimeUpdate,r=this.player;r.ontimeupdate=function(){n(r.currentTime,r.duration)}}e.onEnded&&(this.player.onended=e.onEnded)}}},{key:"reset",value:function(){this.seek(0),this.mixInput.connect()}},{key:"seek",value:function(e){this.player&&(e<0&&e>this.player.duration||(this.player.currentTime=e,this.publisher.currentTime=e))}},{key:"play",value:function(){var e,t;return null==(e=this.publisher)||e.play(),null==(t=this.player)?void 0:t.play()}},{key:"pause",value:function(){var e,t;null==(e=this.player)||e.pause(),null==(t=this.publisher)||t.pause()}},{key:"stop",value:function(){var e;null==(e=this.player)||e.pause(),this.mixInput.disconnect()}},{key:"setOperation",value:function(e){"pause"===e&&this.pause(),"resume"===e&&(this.pause(),this.play()),"stop"===e&&(this.pause(),this.seek(0))}},{key:"volume",set:function(e){!this.player||!this.publisher||(this.player.volume=e,this.publisher.volume=e)}},{key:"loop",set:function(e){!this.player||!this.publisher||(this.player.loop=e,this.publisher.loop=e)}},{key:"playbackRate",set:function(e){!this.player||!this.publisher||(this.player.playbackRate=e,this.publisher.playbackRate=e)}}])}();function bB(e,t){if(t&&"function"!=typeof t)throw new CF({code:SF.INVALID_PARAMETER,message:"start audioMixer plugin: param ".concat(e," should be a function.")})}var AB=function(){function e(t){r(this,e),this.core=t,rR(this,"log"),rR(this,"mixedMusicMap",new Map),rR(this,"cacheMusicMap",new Map),SB+=1,this.log=t.log.createChild({id:"".concat(this.getAlias()).concat(SB)}),this.log.info("[audioMixer] created id=".concat(this.getAlias()).concat(SB)),this.core=t}return o(e,[{key:"getName",value:function(){return e.Name}},{key:"getAlias",value:function(){return"ax"}},{key:"getGroup",value:function(e){return null==e?void 0:e.id}},{key:"getValidateRule",value:function(t){switch(t){case"start":return e.startValidateRule;case"update":return e.updateValidateRule;case"stop":return e.stopValidateRule}}},{key:"start",value:function(e){return aR(this,null,f().mark((function t(){var n,r,i;return f().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=this.core.room,this.log.info("add music source, id: ".concat(e.id," url: ").concat(e.url,", track: ").concat(e.track)),r=e.id,e.url,!this.mixedMusicMap.has(r)){t.next=5;break}return t.abrupt("return");case 5:return(i=this.cacheMusicMap.get(r))?e.url?i.reset():(i.mixInput.replaceSource(e.track),i.mixInput.connect()):(i=new IB(e,n.audioManager),this.cacheMusicMap.set(r,i)),i.updateListener(e),i.updateSettings(e),t.next=11,i.play();case 11:this.mixedMusicMap.set(r,i),this.log.info("start mix audio track ".concat(r," success.")),bO.addEnum({key:502700,value:3}),this.kvUpload(e);case 15:case"end":return t.stop()}}),t,this)})))}},{key:"update",value:function(e){return aR(this,null,f().mark((function t(){var n,r,i,a;return f().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:n=e.id,r=e.operation,i=e.seekFrom,e.playbackRate,this.log.info("update music source, ".concat(JSON.stringify(e))),(a=this.mixedMusicMap.get(n))?(a.updateSettings(e),a.updateListener(e),Iw(r)||a.setOperation(r),Iw(i)||a.seek(i),this.kvUpload(e)):this.log.warn("update music source failed, music id: ".concat(n," not found."));case 4:case"end":return t.stop()}}),t,this)})))}},{key:"stop",value:function(e){return aR(this,arguments,(function(e){var t=this,n=e.id;return f().mark((function e(){var r;return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t.mixedMusicMap.has(n)&&(t.log.info("remove music source, music id: ".concat(n)),null==(r=t.mixedMusicMap.get(n))||r.stop(),t.mixedMusicMap.delete(n)),"*"===n&&t.destroyAllMusic();case 1:case"end":return e.stop()}}),e)}))()}))}},{key:"kvUpload",value:function(e){var t=e.track,n=e.loop,r=e.volume,i=e.playbackRate,a=e.operation,o=e.seekFrom,s=e.onTimeUpdate,c=e.onDurationChange,u=e.onEnded;t&&bO.addCount({key:502711}),n&&bO.addCount({key:502703}),r&&bO.addCount({key:502704}),i&&bO.addCount({key:502705}),a&&bO.addCount({key:502706}),o&&bO.addCount({key:502707}),"function"!=typeof s&&bO.addCount({key:502709}),"function"!=typeof u&&bO.addCount({key:502710}),"function"!=typeof c&&bO.addCount({key:502708})}},{key:"destroyAllMusic",value:function(){var e=this;this.log.info("destroy all music source."),this.mixedMusicMap.forEach((function(t,n){return e.stop({id:n})}))}},{key:"destroyAllCache",value:function(){this.log.info("destroy all music cache."),this.cacheMusicMap.clear()}},{key:"destroy",value:function(){this.log.info("destroy audio mixer plugin."),this.destroyAllMusic(),this.destroyAllCache()}}])}();rR(AB,"startValidateRule",{name:"options",required:!0,type:"object",properties:{id:{type:"string",required:!0},url:{type:"string",required:!1},track:{required:!1},loop:{type:"boolean"},volume:{type:"number"}},validate:function(e,t,n){if(e.url&&"*"!==e.url){var r=e.url.split("?")[0],i=r.split(".").pop(),a=["mp3","ogg","wav","flac"].indexOf(i)>=0,o=r.startsWith("blob"),s=r.startsWith("data");if(!(a||o||s))throw new CF({code:SF.INVALID_PARAMETER,message:"start audioMixer plugin: music url is invalid, please check your file format.",fnName:n})}if(!e.url&&!e.track)throw new CF({code:SF.INVALID_PARAMETER,message:"start audioMixer plugin: param url or track is required.",fnName:n});bB("onTimeUpdate",e.onTimeUpdate),bB("onEnded",e.onEnded),bB("onDurationChange",e.onDurationChange)}}),rR(AB,"updateValidateRule",{name:"options",required:!0,type:"object",properties:{id:{type:"string",required:!0},loop:{type:"boolean"},volume:{type:"number"},seekFrom:{type:"number"},operation:{type:"string",values:["pause","resume","stop"]}},validate:function(e,t,n){bB("onTimeUpdate",e.onTimeUpdate),bB("onEnded",e.onEnded),bB("onDurationChange",e.onDurationChange)}}),rR(AB,"stopValidateRule",{name:"options",type:"object",required:!0,properties:{id:{type:"string",required:!0}}}),rR(AB,"Name","AudioMixer");var RB,CB=AB,wB=0,DB=function(){function e(t){r(this,e),this.core=t,rR(this,"log"),rR(this,"audioContext",kM()),rR(this,"workletNode"),wB+=1,this.log=t.log.createChild({id:"".concat(this.getAlias()).concat(wB)}),this.log.info("[audioDenoiser] created id=".concat(this.getAlias()).concat(wB)),t.assetsPath&&this.preload("".concat(t.assetsPath,"/denoiser-wasm.js")).catch((function(e){}))}return o(e,[{key:"preload",value:function(e){return RB||(RB=this.doPreload(e)),RB}},{key:"doPreload",value:function(e){return aR(this,null,f().mark((function t(){var n,r;return f().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.core.fileDownloader.download(e,{type:"blob"});case 2:return n=t.sent,r=URL.createObjectURL(n),t.prev=4,t.next=7,mM(this.audioContext,r);case 7:t.next=12;break;case 9:throw t.prev=9,t.t0=t.catch(4),this.log.error("load worklet failed",t.t0),t.t0;case 12:return t.prev=12,URL.revokeObjectURL(r),t.finish(12);case 15:case"end":return t.stop()}}),t,this,[[4,9,12,15]])})))}},{key:"getName",value:function(){return e.Name}},{key:"getAlias",value:function(){return"ad"}},{key:"getGroup",value:function(){return"AIDenoiser_".concat(Date.now())}},{key:"getValidateRule",value:function(t){switch(t){case"start":return e.startValidateRule(this.core);case"update":return e.updateValidateRule;case"stop":return e.stopValidateRule}}},{key:"start",value:function(e){return aR(this,null,f().mark((function t(){var n,r,i,a,o,s,c,u,l,d=this;return f().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=this.core,r=n.room,i=n.schedule,t.next=3,this.preload("".concat(e.assetsPath,"/denoiser-wasm.js"));case 3:if(this.workletNode){t.next=15;break}return a=String(Date.now()).slice(0,-3),t.next=7,function(e,t){return aR(this,arguments,(function(e,t){var n=t.sdkAppId,r=t.userId,i=t.userSig,a=t.timestamp;return f().mark((function t(){var o,s,c,u,l,d,h,p;return f().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,e.getAbilityConfig(n,e.ScheduleRequestType.AUDIO_AI_AUTH,{sdkAppId:n,userId:r,userSig:i,timestamp:a});case 3:if(o=t.sent,s=o.data,c=s.errCode,u=s.errMsg,l=s.sign,"1"!==(d=s.status)){t.next=11;break}return t.abrupt("return",{auth:!0,sign:l,status:d,message:u});case 11:h="Init RTCAIDenoiser failed.",p="",t.t0=c,t.next=1===t.t0?15:2===t.t0?17:3===t.t0?19:4===t.t0?21:5===t.t0?23:6===t.t0?25:26;break;case 15:return p="Please check your params.",t.abrupt("break",26);case 17:return p="You need to buy packages. Refer to: https://cloud.tencent.com/document/product/647/44247",t.abrupt("break",26);case 19:return p="Server is invalid. Please contact our engineer. ",t.abrupt("break",26);case 21:return p="Your packages is not active. Refer to: https://cloud.tencent.com/document/product/647/44247",t.abrupt("break",26);case 23:return p="Your packages is expired. Refer to: https://cloud.tencent.com/document/product/647/44247",t.abrupt("break",26);case 25:p="Your version is not supported.";case 26:return t.abrupt("return",{auth:!1,status:d,message:u?"".concat(h," Reason: ").concat(u,". ").concat(p):"".concat(h,", ").concat(p)});case 29:return t.prev=29,t.t1=t.catch(0),t.abrupt("return",{auth:!1,status:"0",message:"Init RTCAIDenoiser failed. All requests failed. ".concat(t.t1)});case 32:case"end":return t.stop()}}),t,null,[[0,29]])}))()}))}(i,$A(QA({},e),{timestamp:a}));case 7:if(o=t.sent,s=o.auth,c=o.sign,u=o.status,l=o.message,s){t.next=14;break}throw this.log.info("RTCAIDenoiser: ".concat(e.userId," auth result: ").concat(s,". Message: ").concat(l)),new CF({code:SF.INVALID_PARAMETER,message:l});case 14:this.workletNode=new AudioWorkletNode(this.audioContext,"trtc-denoiser-processor",{numberOfInputs:1,numberOfOutputs:1}),this.workletNode.port.postMessage({type:"init",data:{sdkAppId:String(e.sdkAppId),userId:e.userId,timestamp:a,sign:c,status:u}}),this.workletNode.port.onmessage=function(e){var t,n=e.data;if("cost"===n.type){var r=(null==n?void 0:n.max)>20?"warn":(null==n?void 0:n.max)>10?"info":"debug";d.log[r]("avg cost: ".concat(n.value," max: ").concat(null==n?void 0:n.max,"(").concat(SR(new Date(null==n?void 0:n.maxCostTimestamp)),") hist: ").concat(null==(t=null==n?void 0:n.hist)?void 0:t.join(" ")))}else"log"===n.type&&d.log[n.logLevel]("".concat(n.value))};case 15:this.workletNode.port.postMessage({type:"enable"}),r.audioManager.addDenoiser(this.workletNode),r.sendAbilityStatus({ai_denoise:1});case 16:case"end":return t.stop()}}),t,this)})))}},{key:"update",value:function(){return aR(this,null,f().mark((function e(){return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:case"end":return e.stop()}}),e)})))}},{key:"stop",value:function(){return aR(this,null,f().mark((function e(){var t;return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.workletNode){e.next=2;break}return e.abrupt("return");case 2:return t=this.core.room,this.workletNode.port.postMessage({type:"disable"}),e.next=6,t.audioManager.removeDenoiser(this.workletNode);case 6:case"end":return e.stop()}}),e,this)})))}},{key:"destroy",value:function(){this.workletNode&&(this.workletNode.port.onmessage=null)}}],[{key:"startValidateRule",value:function(e){return{name:"options",required:!0,type:"object",properties:{sdkAppId:{type:"number",required:!0},userId:{type:"string",required:!0},userSig:{type:"string",required:!0}},validate:function(t,n,r,i){if(!e.room.audioManager.hasAudioTrack)throw new CF({code:SF.INVALID_OPERATION,extraCode:5106,fnName:r})}}}}])}();rR(DB,"updateValidateRule",{type:"object"}),rR(DB,"stopValidateRule",{type:"object"}),rR(DB,"Name","AIDenoiser");var NB=DB,xB=function(e){function i(){var e;return r(this,i),e=n(this,i),rR(t(e),"observer"),rR(t(e),"state","nominal"),e.onPressureChange=e.onPressureChange.bind(t(e)),e}return d(i,e),o(i,[{key:"stateNum",get:function(){switch(this.state){case"nominal":return 1;case"fair":return 2;case"serious":return 3;case"critical":return 4}}},{key:"start",value:function(){return aR(this,null,f().mark((function e(){return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.observer){e.next=12;break}if(e.prev=1,e.t0="PressureObserver"in window&&!bD,!e.t0){e.next=7;break}return this.observer=new PressureObserver(this.onPressureChange),e.next=7,this.observer.observe("cpu",{sampleInterval:2e3});case 7:e.next=12;break;case 9:e.prev=9,e.t1=e.catch(1),jP.uploadEvent({log:"stat-pressure-detector-start-failed",error:e.t1});case 12:case"end":return e.stop()}}),e,this,[[1,9]])})))}},{key:"onPressureChange",value:function(e){var t=this.stateNum,n=e[e.length-1];this.state=n.state,(this.stateNum>3||t>3)&&sx.info("".concat(n.source,": ").concat(n.state)),this.emit("state-changed",{type:n.source,state:this.state})}},{key:"destroy",value:function(){var e;try{null==(e=this.observer)||e.disconnect(),this.observer=null}catch(DC){jP.uploadEvent({log:"stat-pressure-detector-destroy-failed",error:DC})}}}])}(tR(oR(),1).EventEmitter),OB=new xB;function PB(e){var t=v(e,2),n=t[0],r=t[1],i=r.byteLength,a=parseInt(String(i/255),10),o=i%255,s=[];s.push(0,0,0,1,6,n);for(var c=0;c<a;c++)s.push(255);s.push(o);var u=new DataView(r);return s.push.apply(s,E(new Uint8Array(u.buffer))),s.push(128),new SL(new DataView(new Uint8Array(s).buffer),!0)}function MB(e){return"empty"===e.type||0===e.data.byteLength}function LB(e){return 1===e.getInt32(0)&&6===e.getInt8(4)}function VB(e){for(var t=0,n=0,r=new DataView(e),i=0;i<e.byteLength;i++)switch(r.getUint8(i)){case 0:t++;break;case 1:(2===t||3===t)&&n++,t=0;break;default:t=0}return n}function UB(e){var t=e.frame,n=e.seiMessageList;if(!n||0===n.length||0===t.data.byteLength)return t;var r=9-VB(t.data);if(r<=0)return t;for(var i=n.splice(0,r).reverse().map(PB),a=i.reduce((function(e,t){return e+t.dataView.byteLength}),0),o=new ArrayBuffer(a+t.data.byteLength),s=new DataView(o),c=new DataView(t.data),u=0,l=0;l<i.length;l++)for(var d=0;d<i[l].dataView.byteLength;d++)s.setInt8(u++,i[l].dataView.getInt8(d));for(var h=0;h<t.data.byteLength;h++)s.setInt8(u++,c.getInt8(h));return t.data=o,t}function FB(e){var t=e.frame,n=e.onSEI;try{var r=new DataView(t.data);if(MB(t)||!LB(r))return t;for(var i=[],a=0,o=-1,s=-1,c=0;c<t.data.byteLength;c++){var u=r.getUint8(c);if(0===u)a++;else if(1===u){if(2===a||3===a){var l=c-a;if(-1===o?o=l:-1===s&&(s=l,i.push(new SL(new DataView(r.buffer.slice(o,s)))),o=l,s=-1),6!==r.getUint8(c+1)){t.data=r.buffer.slice(l);break}}a=0}else a=0}null==n||n(i.reverse())}catch(wR){}return t}var BB=0,jB=function(){function e(t){r(this,e),this.core=t,rR(this,"log"),rR(this,"_seiMessageList",[]),rR(this,"_smallSeiMessageList",[]),rR(this,"_subStreamSeiMessageList",[]),BB++,this.log=t.log.createChild({id:"".concat(this.getAlias()).concat(BB)}),this.log.info("[sei] created id=".concat(this.getAlias()).concat(BB)),this.core=t,this.encode=this.encode.bind(this),this.decode=this.decode.bind(this)}return o(e,[{key:"encode",value:function(e){var t=e.frame,n=e.mediaType;try{return UB({frame:t,seiMessageList:8===n?this._smallSeiMessageList:2===n?this._subStreamSeiMessageList:this._seiMessageList})}catch(DC){this.log.warn(DC)}return t}},{key:"decode",value:function(e){var t=this,n=e.frame,r=e.track;return FB({frame:n,onSEI:function(e){e.forEach((function(e){t.core.trtc.emit(qF.SEI_MESSAGE,{seiPayloadType:e.seiPayloadType,data:e.seiPayload.buffer,userId:r.userId,streamType:2===r.mediaType?"sub":"main"})}))}})}},{key:"destroy",value:function(){this.log.debug("destory"),this.stop(),delete this.core}},{key:"getValidateRule",value:function(e){switch(e){case"start":case"update":case"stop":return{type:"object"}}}},{key:"start",value:function(){this.core.room.videoManager.addEncodeProcessor({processor:sP?this.encode:UB,type:2}),this.core.room.videoManager.addDecodeProcessor({processor:sP?this.decode:FB,type:2})}},{key:"stop",value:function(){this.core.room.videoManager.removeEncodeProcessor({type:2}),this.core.room.videoManager.removeDecodeProcessor({type:2})}},{key:"update",value:function(e){var t,n=e.buffer,r=e.options,i=[r.seiPayloadType,n],a=!!r.small;r.toSubStream?this._subStreamSeiMessageList.push(i):(this._seiMessageList.push(i),a&&this._smallSeiMessageList.push(i)),null==(t=this.core.room.scriptTransformWorker)||t.postMessage({type:"sei",data:i,isMain:!r.toSubStream,small:a})}},{key:"getName",value:function(){return e.Name}},{key:"getAlias",value:function(){return"sei"}},{key:"getGroup",value:function(){return"sei"}}])}();rR(jB,"autoStart",!0),rR(jB,"Name","SEI");var HB=jB;function GB(e){var t=e.frame,n=e.onDump;return null==n||n(),t}function WB(e){var t=e.frame,n=e.onDump;return null==n||n(),t}var JB,KB=0,zB=function(){function e(t){r(this,e),this.core=t,rR(this,"_core"),rR(this,"log"),rR(this,"dumpLocalVideoMap",{}),rR(this,"dumpRemoteVideoMap",{}),rR(this,"dialog"),this._core=t,this.log=t.log.createChild({id:"".concat(this.getAlias()).concat(++KB)}),this.log.info("created")}return o(e,[{key:"getName",value:function(){return e.Name}},{key:"getAlias",value:function(){return"dm"}},{key:"getGroup",value:function(){return"dm"}},{key:"getValidateRule",value:function(e){switch(e){case"start":return{name:"StartDebugOptions",required:!1};case"update":return{name:"UpdateDebugOptions",required:!1};case"stop":return{name:"StopDebugOptions",required:!1}}}},{key:"start",value:function(){return aR(this,null,f().mark((function e(){var t;return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(e.t0=!new URLSearchParams(location.search).has("trtcDebug")&&"true"!==(null==(t=window.sessionStorage)?void 0:t.getItem("TRTC_ENABLE_DEBUG_PLUGIN")),e.t0){e.next=5;break}return e.next=4,this.openDebugDiaLog();case 4:this.addVideoProcessor();case 5:case"end":return e.stop()}}),e,this)})))}},{key:"update",value:function(){}},{key:"stop",value:function(){this.closeDebugDiaLog(),this.removeVideoProcessor()}},{key:"destroy",value:function(){this.stop()}},{key:"openDebugDiaLog",value:function(){return aR(this,null,f().mark((function e(){var t,n,r;return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(e.prev=0,!JB){e.next=6;break}return e.next=4,JB;case 4:e.next=11;break;case 6:return n=Date.now(),r=new URLSearchParams(location.search).get("trtcDebugDialogPath")||(null==(t=window.sessionStorage)?void 0:t.getItem("TRTC_DEBUG_DIALOG_PATH"))||"https://unpkg.com/".concat("trtc-sdk-v5","@").concat(RR,"/assets/debug-dialog.js"),JB=this.loadScript(r),e.next=10,JB;case 10:this.log.info("download debug dialog script cost: ".concat(Date.now()-n,"ms"));case 11:this.dialog=new TRTCDebugDialog(this._core,this.log,this.dumpLocalVideoMap,this.dumpRemoteVideoMap),this._core.kvStatManager.addSuccessEvent({key:592705}),e.next=17;break;case 14:e.prev=14,e.t0=e.catch(0),this._core.kvStatManager.addFailedEvent({key:592705}),this.log.error("load debug dialog script failed: ",JSON.stringify(e.t0));case 17:case"end":return e.stop()}}),e,this,[[0,14]])})))}},{key:"closeDebugDiaLog",value:function(){var e;null==(e=this.dialog)||e.closeDialog(),this.dialog=null}},{key:"addVideoProcessor",value:function(){this._core.room.videoManager.addEncodeProcessor({processor:this._core.rtcDectection.IS_INSERTABLE_STREAM_SUPPORTED?this.encodeVideo.bind(this):GB,type:1}),this._core.room.videoManager.addDecodeProcessor({processor:this._core.rtcDectection.IS_INSERTABLE_STREAM_SUPPORTED?this.decodeVideo.bind(this):WB,type:1})}},{key:"removeVideoProcessor",value:function(){this._core.room.videoManager.removeEncodeProcessor({type:1}),this._core.room.videoManager.removeDecodeProcessor({type:1})}},{key:"encodeVideo",value:function(e){var t=this,n=e.frame,r=e.mediaType;return GB({frame:n,onDump:function(){if(r){var e=2===r?"sub":"main",i=t.dumpLocalVideoMap[e];i&&(i.data.push(n.data),i.duration>0&&Date.now()-i.startTimestamp>1e3*i.duration&&i.onDumpEnd())}}})}},{key:"decodeVideo",value:function(e){var t=this,n=e.frame,r=e.track;return WB({frame:n,onDump:function(){if(r){var e=t.dumpRemoteVideoMap["".concat(r.userId,"-").concat(r.streamType)];e&&(e.data.push(n.data),e.duration>0&&Date.now()-e.startTimestamp>1e3*e.duration&&e.onDumpEnd())}}})}},{key:"loadScript",value:function(e){var t=this;return new Promise((function(n,r){t.log.info("loading debug dialog from ".concat(e));var i=document.createElement("script");i.type="text/javascript",i.onload=n,i.onerror=r,i.crossOrigin="anonymous",i.src=e,document.head.append?document.head.append(i):document.getElementsByTagName("head")[0].appendChild(i)}))}}])}();rR(zB,"Name","Debug"),rR(zB,"autoStart",!0),nR([GP({settings:{timeout:3e3,retries:3},onError:function(e,t,n){var r;null!=(r=null==e?void 0:e.message)&&r.includes("timeout")?t():n(e)}})],zB.prototype,"loadScript",1);var YB=zB,qB=function(e){switch(e){case"webCodecs":return 504703;case"wasm":return 504704}throw new Error("decoder type not supported")},XB=function(){return o((function e(t,n,i){var a=this;r(this,e),rR(this,"trackDoneOB"),rR(this,"startOB"),rR(this,"stopOB"),rR(this,"inputFrameCount",0),rR(this,"decodedFrameCount",0),rR(this,"type","auto"),rR(this,"config"),rR(this,"decoder"),rR(this,"_decodeSink");var o=t.kvStatManager;t.trtc,this.config=i.config,this.trackDoneOB=SV(n,wP.INIT),this.stopOB=fV(this.trackDoneOB),this.startOB=fV(),"auto"===i.type?this.type="webCodecs":this.type=i.type;var s=fV();KL(this.startOB,cV(0),kU((function(e){var t=a.pipe(n);return s.next("STARTING"),n.log.info("decoder type: ".concat(a.type)),KL(t,JV(a.stopOB),WU((function(){}),(function(t){n.log.error(t),o.addFailedEvent({key:qB(a.type),error:t}),e>4?a.startOB.error(t):a.startOB.next(e+1)}))),KL(t,WV(1),jU(MV))})),JV(this.stopOB),WU((function(){n.player.setOutput(),s.next("STARTED")}),(function(e){s.next("FAILED")}),(function(){o.addSuccessEvent({key:qB(a.type)}),o.addSuccessEvent({key:504702})})))}),[{key:"mock",value:function(e){this._decodeSink?this._decodeSink.error(e):this.startOB.next(0)}},{key:"close",value:function(e){this.stopOB.next(e)}},{key:"pipe",value:function(e){var t=this;return eV()((function(n){return aR(t,null,f().mark((function t(){var r,i=this;return f().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:this._decodeSink=n,n.defer((function(){var e;null==(e=i.decoder)||e.close()})),r=this.type;try{"webCodecs"===r&&(this.decoder=new AudioDecoder({error:function(t){e.log.error(t),n.error(4)},output:function(t){i.decodedFrameCount++,n.next(t),e.player.write(t)}})),this.decoder.configure(this.config)}catch(vx){e.log.error(vx),n.error("webCodecs"===r?2:6)}case 3:case"end":return t.stop()}}),t,this)})))}))}},{key:"decodeFrame",value:function(e){var t;this.inputFrameCount++,"configured"===(null==(t=this.decoder)?void 0:t.state)&&this.decoder.decode(new EncodedAudioChunk({data:e.data,timestamp:e.timestamp,type:"key"}))}}])}(),QB={type:"object"},$B=function(){function e(t){r(this,e),this.core=t,rR(this,"log"),rR(this,"contextMap",new Map),rR(this,"decodeProcessorMap",new WeakMap),this.log=t.log.createChild({id:"".concat(this.getAlias())})}return o(e,[{key:"getAlias",value:function(){return e.Name}},{key:"getGroup",value:function(e){return e.track.userId+e.track.streamType}},{key:"getName",value:function(){return e.Name}},{key:"getValidateRule",value:function(e){return QB}},{key:"start",value:function(e){var t=this,n=e.track;this.decodeProcessorMap.set(n,this.decode(e)),this.core.room.audioManager.addDecodeProcessor({processor:function(e){var n=e.frame,r=e.track;return t.decodeProcessorMap.has(r)?t.decodeProcessorMap.get(r)({frame:n,track:r}):n},type:3})}},{key:"decode",value:function(e){var t=this;return function(n){var r=n.frame,i=n.track;if(i!==e.track)return r;if(t.contextMap.has(i))return t.contextMap.get(i).decodeFrame(r);var a=new XB(t.core,i,e);return KL(a.trackDoneOB,WV(1),WU((function(){t.core.clearStarted(t,t.getGroup(e)),t.stop({track:i})}))),t.contextMap.set(i,a),a.decodeFrame(r)}}},{key:"stop",value:function(e){var t=e.track,n=this.contextMap.get(t);n&&(n.close("stop"),this.contextMap.delete(t),0===this.contextMap.size&&this.core.room.audioManager.removeDecodeProcessor({type:3}))}},{key:"update",value:function(e){var t=this.contextMap.get(e.track);if(t){if("mock"===e.type)return void t.mock(10);t.close("update"),this.contextMap.set(e.track,new XB(this.core,e.track,e))}}}])}();rR($B,"Name","TRTCAudioDecoder");var ZB=$B,ej=0,tj=new Set,nj=null;CR("5.10.1-beta.9"),ux.checkStorage(),_P();var rj={RtcError:CF,ErrorCode:SF,ErrorCodeDictionary:IF},ij=function(e){function i(e,a){var o;return r(this,i),o=n(this,i),rR(t(o),"_room"),rR(t(o),"_eventListened",new Set),rR(t(o),"_localVideoTrack",null),rR(t(o),"_localAudioTrack",null),rR(t(o),"_localScreenTrack",null),rR(t(o),"_localScreenAudioTrack",null),rR(t(o),"_localVideoConfig",null),rR(t(o),"_localScreenConfig",null),rR(t(o),"_localAudioConfig",null),rR(t(o),"_remoteVideoConfigMap",new Map),rR(t(o),"_remoteAudioConfigMap",new Map),rR(t(o),"_remoteAudioVolumeMap",new Map),rR(t(o),"_remoteAudioMuteMap",new Map),rR(t(o),"_mediaTrackMap",new WeakMap),rR(t(o),"_log",sx.createLogger({id:"t".concat(++ej)})),rR(t(o),"_plugins",new Map),rR(t(o),"_networkQuality",null),rR(t(o),"_speakerId"),rR(t(o),"_getPCMAbortCtrl"),o._room=new e(QA({logger:o._log,frameWorkType:i.frameWorkType},a)),o._room.videoDecodeFallbackType=a.videoDecodeFallback,o._log.info("create() ".concat(JSON.stringify(a,(function(e,t){return"plugins"===e?t.map((function(e){return e.Name})):t})))),Object.defineProperties(t(o),{dumpAudio:{enumerable:!1,value:function(e){return this._room.audioManager.dump(e)}}}),a.plugins&&a.plugins.forEach((function(e){o._use(e,a.assetsPath)})),o._use(CB,a.assetsPath),o._use(NB,a.assetsPath),o._use(ZB,a.assetsPath||jR),o._use(YB),a.enableSEI&&uP&&o._use(HB),o._room.on("audio-volume",(function(e){!e.find((function(e){return""===e.userId}))&&o._localAudioTrack&&e.push({userId:"",volume:Math.floor(100*o._localAudioTrack.getAudioLevel())}),1===a.volumeType&&e.forEach((function(e){var t,n=""===e.userId?o._localAudioTrack:null==(t=o.room.remotePublishedUserMap.get(e.userId))?void 0:t.remoteAudioTrack;n&&(e.volume=n.dbVolume)})),o.emit(qF.AUDIO_VOLUME,{result:e.sort((function(e,t){return t.volume-e.volume}))})})),o._room.videoManager.on("error",(function(e){o._log.error(new CF({code:SF.OPERATION_FAILED,extraCode:5504,message:e.message,originError:e}))})),o._listenEvents(),o._initActiveSpeaker(),function(e){var t=e.emit;e.emit=function(){for(var n=arguments.length,r=new Array(n),i=0;i<n;i++)r[i]=arguments[i];try{return t.apply(e,r)}catch(vx){var a=mO({key:dO.CATCH_HANDLER_ERROR,data:{name:"trtc",event:r[0]},addDocLink:!1});return sx.warn("".concat(a,"\n\n").concat(vx.stack)),!1}}}(t(o)),o}return d(i,e),o(i,[{key:"room",get:function(){return this._room}},{key:"_listenEvents",value:function(){var e=this;FP(this,this._room).add("peer-join",(function(t){var n=t.userId;e.emit(qF.REMOTE_USER_ENTER,{userId:n})})).add("peer-leave",(function(t){e.emit(qF.REMOTE_USER_EXIT,{userId:t}),e._remoteAudioVolumeMap.delete(t)})).add("banned",(function(t){e._exitRoom().finally((function(){e.emit(qF.KICKED_OUT,{reason:t.reason})}))})).add("error",(function(t){e._exitRoom().finally((function(){e.emit(qF.ERROR,CF.convertFrom(t))}))})).add("signal-connection-state-changed",(function(t){e.emit(qF.CONNECTION_STATE_CHANGED,t)})).add("network-quality",(function(t){e._networkQuality=t;var n=$A(QA({},t),{uplinkRTT:Math.min(t.uplinkRTT,rw),downlinkRTT:Math.min(t.downlinkRTT,rw)});e.emit(qF.NETWORK_QUALITY,n)})).add("remote-published",(function(t){[t.remoteAudioTrack,t.remoteVideoTrack,t.remoteAuxiliaryTrack].forEach((function(n){FP(n,n).add("player-state-changed",(function(r){var i=$A(QA({},r),{userId:t.userId});n.kind===nC.VIDEO&&(i.streamType=QF(n.streamType)),e.emit(n.kind===nC.AUDIO?qF.AUDIO_PLAY_STATE_CHANGED:qF.VIDEO_PLAY_STATE_CHANGED,i)})).add("error",(function(t){t.getCode()===_R.PLAY_NOT_ALLOWED&&e.emit(qF.AUTOPLAY_FAILED,{userId:n.userId,resume:function(){return n.player.resume()}})}))}))})).add("remote-unpublished",(function(e){[e.remoteAudioTrack,e.remoteVideoTrack,e.remoteAuxiliaryTrack].forEach((function(e){BP(e)}))})).add("remote-publish-state-changed",(function(t){var n=t.prevMuteState,r=t.muteState,i=r.userId,a=n.audioAvailable,o=n.videoAvailable,s=r.audioAvailable,c=r.videoAvailable;s||e._remoteAudioConfigMap.delete(i),c||e._remoteVideoConfigMap.delete("".concat(i,"_main")),r.hasAuxiliary||e._remoteVideoConfigMap.delete("".concat(i,"_sub")),o!==c&&(c?e._onVideoAvailable({userId:i,streamType:"main"}):e._onVideoUnavailable({userId:i,streamType:"main"}),e.emit(c?qF.REMOTE_VIDEO_AVAILABLE:qF.REMOTE_VIDEO_UNAVAILABLE,{userId:i,streamType:"main"})),a!==s&&(s?e._onAudioAvailable({userId:i}):e._onAudioUnavailable({userId:i,muteState:r}),e.emit(s?qF.REMOTE_AUDIO_AVAILABLE:qF.REMOTE_AUDIO_UNAVAILABLE,{userId:i})),n.hasAuxiliary!==r.hasAuxiliary&&(r.hasAuxiliary?e._onVideoAvailable({userId:i,streamType:"sub"}):e._onVideoUnavailable({userId:i,streamType:"sub"}),e.emit(r.hasAuxiliary?qF.REMOTE_VIDEO_AVAILABLE:qF.REMOTE_VIDEO_UNAVAILABLE,{userId:i,streamType:"sub"}))})).add("sei-message",(function(t){e.emit(qF.SEI_MESSAGE,$A(QA({},t),{streamType:QF(t.streamType)}))})).add("firewall-restriction",(function(){e.emit(qF.ERROR,new CF({code:SF.OPERATION_FAILED,extraCode:5501}))})).add("heartbeat-report",(function(t){var n,r,i,a,o,s,c,u={2:"big",3:"small",7:"sub"},l={rtt:Math.min(t.msg_up_stream_info.msg_network_status.uint32_rtt||(null==(n=t.msg_down_stream_info[0])?void 0:n.msg_network_status.uint32_rtt)||(null==(r=e._networkQuality)?void 0:r.uplinkRTT)||(null==(i=e._networkQuality)?void 0:i.downlinkRTT)||0,rw),upLoss:(null==(a=e._networkQuality)?void 0:a.uplinkLoss)||0,downLoss:(null==(o=e._networkQuality)?void 0:o.downlinkLoss)||0,bytesSent:t.bytes_sent||0,bytesReceived:t.bytes_received||0,localStatistics:{audio:{bitrate:((null==(s=t.msg_up_stream_info.msg_audio_status)?void 0:s.uint32_audio_codec_bitrate)||0)/1e3,audioLevel:((null==(c=t.msg_up_stream_info.msg_audio_status)?void 0:c.uint32_audio_level)||0)/tO},video:t.msg_up_stream_info.msg_video_status.filter((function(e){return u[e.uint32_video_stream_type]})).map((function(e){return{bitrate:(e.uint32_video_codec_bitrate||0)/1e3,width:e.uint32_video_width,height:e.uint32_video_height,frameRate:e.uint32_video_enc_fps,videoType:u[e.uint32_video_stream_type]}}))},remoteStatistics:t.msg_down_stream_info.map((function(e){return{userId:e.msg_user_info.str_identifier,audio:{bitrate:(e.msg_audio_status.uint32_audio_codec_bitrate||0)/1e3,audioLevel:(e.msg_audio_status.uint32_audio_level||0)/tO},video:e.msg_video_status.map((function(e){return{bitrate:(e.uint32_video_codec_bitrate||0)/1e3,width:e.uint32_video_width,height:e.uint32_video_height,frameRate:e.uint32_video_dec_fps,videoType:u[e.uint32_video_stream_type]}}))}}))};e.emit(qF.STATISTICS,l)})).add("custom-message",(function(t){e.emit(qF.CUSTOM_MESSAGE,t)})).add("layerData",(function(t){return e.emit(qF.LAYER_DATA,t)})).add("first-video-frame",(function(t){e.emit(qF.FIRST_VIDEO_FRAME,$A(QA({},t),{streamType:QF(t.streamType)}))})),FP(this,UM).add("audioInputAdded",(function(t){e.emit(qF.DEVICE_CHANGED,{type:"microphone",action:"add",device:t})})).add("audioInputRemoved",(function(t){e.emit(qF.DEVICE_CHANGED,{type:"microphone",action:"remove",device:t})})).add("videoInputAdded",(function(t){e.emit(qF.DEVICE_CHANGED,{type:"camera",action:"add",device:t})})).add("videoInputRemoved",(function(t){e.emit(qF.DEVICE_CHANGED,{type:"camera",action:"remove",device:t})})).add("audioOutputAdded",(function(t){return aR(e,null,f().mark((function e(){var n;return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.emit(qF.DEVICE_CHANGED,{type:"speaker",action:"add",device:t}),!nj||nj.deviceId!==XC){e.next=5;break}return e.next=3,WM();case 3:n=e.sent.find((function(e){return e.deviceId===XC})),n&&nj.groupId!==n.groupId&&(nj=n,this.emit(qF.DEVICE_CHANGED,{type:"speaker",action:"active",device:n}));case 5:case"end":return e.stop()}}),e,this)})))})).add("audioOutputRemoved",(function(t){return aR(e,null,f().mark((function e(){var n,r,i;return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.emit(qF.DEVICE_CHANGED,{type:"speaker",action:"remove",device:t}),e.next=3,WM();case 3:if((n=e.sent[0])&&nj&&nj.groupId!==n.groupId){e.next=6;break}return e.abrupt("return");case 6:r=nj.deviceId===t.deviceId,i=nj.deviceId===XC&&nj.deviceId===n.deviceId,(r||i)&&(nj=n,this.emit(qF.DEVICE_CHANGED,{type:"speaker",action:"active",device:n}));case 8:case"end":return e.stop()}}),e,this)})))}))}},{key:"use",value:function(e){var t,n;"plugin"in e?(t=e.plugin,n=e.assetsPath):t=e,this._use(t,n||jR)}},{key:"_use",value:function(e,t){if(this._plugins.get(e.Name))this._log.warn("duplicate install plugin",e.Name);else{var n=new e(mB.call(this,{TRTC:i,room:this._room,errorModule:rj,assetsPath:t}));this._plugins.set(e.Name,n),e.autoStart&&this.startPlugin(e.Name)}}},{key:"enterRoom",value:function(e){return aR(this,null,f().mark((function t(){var n,r,a,o,s,c,u,l,d,h,p;return f().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=e.scene,o=void 0===a?"rtc":a,s=e.enableAutoPlayDialog,c=void 0===s||s,u=e.autoReceiveAudio,l=void 0===u||u,d=e.autoReceiveVideo,h=void 0!==d&&d,e.proxy&&(this._room.setProxyServer(e.proxy),!bw(e.proxy)&&e.proxy.turnServer&&(null==(r=(n=this._room).setTurnServer)||r.call(n,e.proxy.turnServer,e.proxy.iceTransportPolicy))),this._room.enableAutoPlayDialog=c,this._room.autoReceiveAudio=l,this._room.autoReceiveVideo=h,Rw(e.preferHW)&&(this._room.preferHW=e.preferHW),e.playoutDelay&&(this._room.playoutDelay=e.playoutDelay),e.jitterBufferDelay&&(this._room.jitterBufferDelay=e.jitterBufferDelay),p={sdkAppId:e.sdkAppId,userId:e.userId,userSig:e.userSig,privateMapKey:e.privateMapKey||null,latencyLevel:e.latencyLevel,role:"audience"===e.role?21:20,roomId:e.roomId||0,strRoomId:e.strRoomId||"",businessInfo:e.businessInfo||null,streamId:null,userDefineRecordId:e.userDefineRecordId||null,frameWorkType:e.frameWorkType,component:e.component,language:e.language,priority:e.priority,useVp8:e.useVp8,keepAlive:e.keepAlive},e.strRoomId&&!e.roomId?this._room.useStringRoomId=!0:this._room.useStringRoomId=!1,t.next=6,this._room.join(p,o,i.frameWorkType);case 6:this._checkTrackToPublish(),OB.start();case 8:case"end":return t.stop()}}),t,this)})))}},{key:"exitRoom",value:function(){return aR(this,null,f().mark((function e(){return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._exitRoom();case 2:return e.abrupt("return",e.sent);case 3:case"end":return e.stop()}}),e,this)})))}},{key:"switchRole",value:function(e,t){return aR(this,null,f().mark((function n(){return f().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return null!=t&&t.privateMapKey&&(this._room.privateMapKey=t.privateMapKey),null!=t&&t.latencyLevel&&(this._room.latencyLevel=t.latencyLevel),n.next=4,this._room.switchRole(e);case 4:"anchor"===e&&this._checkTrackToPublish();case 5:case"end":return n.stop()}}),n,this)})))}},{key:"destroy",value:function(){BP(this),this.removeAllListeners(),this._room.destroy(),tj.delete(this),0===tj.size&&OB.destroy(),this._localAudioTrack&&this.stopLocalAudio(),this._localVideoTrack&&this.stopLocalVideo(),this._localScreenTrack&&this.stopScreenShare(),this._plugins.forEach((function(e){var t;return null==(t=e.destroy)?void 0:t.call(e)})),this._plugins.clear(),rx.off("102",this._onLocalTrackCaptured,this)}},{key:"startLocalAudio",value:function(){return aR(this,arguments,(function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{publish:!0};return f().mark((function n(){var r,a,o,s,c,u,l;return f().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(!e._localAudioTrack){n.next=2;break}return n.abrupt("return",void e._log.warn("local audio is already started"));case 2:return r=t.publish,a=void 0===r||r,o=t.mute,s=t.option,c=new kL(e._room.audioManager),u={},l={muted:!0},s&&(Iw(s.microphoneId)?Iw(s.audioTrack)||(u.customSource=s.audioTrack):u.deviceId=s.microphoneId,s&&Aw(s.captureVolume)&&c.setCaptureVolume(s.captureVolume),Iw(s.profile)||(bw(s.profile)?ZR[s.profile]&&c.setProfile(ZR[s.profile]):c.setProfile(s.profile)),Aw(s.earMonitorVolume)&&(l.muted=!(s.earMonitorVolume>0),l.volume=s.earMonitorVolume),Iw(s.echoCancellation)||(c.profile.echoCancellation=s.echoCancellation),Iw(s.noiseSuppression)||(c.profile.noiseSuppression=s.noiseSuppression),Iw(s.autoGainControl)||(c.profile.autoGainControl=s.autoGainControl)),c.on("5",(function(t){e.emit(qF.ERROR,new CF({code:SF.DEVICE_ERROR,extraCode:5309,messageParams:{error:t}}))})),c.on("2",(function(t){e.emit(qF.DEVICE_CHANGED,{type:"microphone",action:"active",device:t})})),c.on("4",(function(t){var n;t.error&&(n=CF.convertFrom(t.error)),e.emit(qF.PUBLISH_STATE_CHANGED,$A(QA({},t),{error:n}))})),e._listenOutputTrackChanged(c),e._speakerId&&c.setAudioOutput(e._speakerId),n.next=11,c.capture(u);case 11:return Iw(o)||c.setMute(o),FP(c,c).add("player-state-changed",(function(t){e.emit(qF.AUDIO_PLAY_STATE_CHANGED,$A(QA({},t),{userId:""}))})),e.listeners(qF.AUDIO_FRAME).length>0&&(e._getPCMAbortCtrl=e._room.audioManager.getPCM((function(t){e.emit(i.EVENT.AUDIO_FRAME,{data:t})}))),e._getPCMAbortCtrl&&c.on("input-media-track-changed",(function(){e._getPCMAbortCtrl&&(e._getPCMAbortCtrl.abort("inputMediaTrackChanged"),e._getPCMAbortCtrl=e._room.audioManager.getPCM((function(t){e.emit(i.EVENT.AUDIO_FRAME,{data:t})})))})),a&&e._room.isJoined&&e._room.publish(c).catch((function(){})),e._localAudioTrack=c,e._localAudioConfig=$A(QA({},t),{publish:a}),n.next=20,e._updateAudioPlayOption({playOption:l,track:c});case 20:case"end":return n.stop()}}),n)}))()}))}},{key:"updateLocalAudio",value:function(e){return aR(this,null,f().mark((function t(){var n,r,i,a;return f().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this._localAudioTrack&&this._localAudioConfig){t.next=2;break}return t.abrupt("return");case 2:if(n=e.publish,r=e.mute,i=e.option,a={},t.t0=i,!t.t0){t.next=18;break}if(!i.microphoneId){t.next=10;break}return t.next=8,this._localAudioTrack.switchDevice(i.microphoneId);case 8:t.next=14;break;case 10:if(t.t1=Iw(i.audioTrack),t.t1){t.next=14;break}return t.next=14,this._localAudioTrack.setInputMediaStreamTrack(i.audioTrack);case 14:return Iw(i.captureVolume)||this._localAudioTrack.setCaptureVolume(i.captureVolume),Iw(i.earMonitorVolume)||(a.muted=!(i.earMonitorVolume>0),a.volume=i.earMonitorVolume),t.next=18,this._localAudioTrack.update3A(i);case 18:return this._room.isJoined&&!Iw(n)&&(n&&!this._localAudioConfig.publish&&this._room.publish(this._localAudioTrack).catch((function(){})),this._localAudioConfig.publish&&!n&&this._room.unpublish(this._localAudioTrack).catch((function(){}))),Iw(r)||this._localAudioTrack.setMute(r),t.next=22,this._updateAudioPlayOption({playOption:a,track:this._localAudioTrack,prevConfig:this._localAudioConfig});case 22:Jw(this._localAudioConfig,e);case 23:case"end":return t.stop()}}),t,this)})))}},{key:"stopLocalAudio",value:function(){return aR(this,null,f().mark((function e(){return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(e.t0=this._localAudioTrack,!e.t0){e.next=13;break}if(e.t1=this._room.isJoined,!e.t1){e.next=6;break}return e.next=6,this._room.unpublish(this._localAudioTrack).catch((function(){}));case 6:this._localAudioTrack.stop(),this._localAudioTrack.close(),this._room.audioManager.removeInput(this._localAudioTrack),BP(this._localAudioTrack),this._localAudioTrack=null,this._localAudioConfig=null,this._getPCMAbortCtrl&&(this._getPCMAbortCtrl.abort("stopLocalAudio"),delete this._getPCMAbortCtrl);case 13:case"end":return e.stop()}}),e,this)})))}},{key:"startLocalVideo",value:function(){return aR(this,arguments,(function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{publish:!0,view:null};return f().mark((function n(){var r,i,a,o,s,c,u,l;return f().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(!e._localVideoTrack){n.next=2;break}return n.abrupt("return",void e._log.warn("local video is already started"));case 2:return r=t.view,i=t.publish,a=void 0===i||i,o=t.mute,s=t.option,c=new AL(e._room.videoManager),u={},l={},Rw(null==s?void 0:s.avoidCropping)&&(c.avoidCropping=s.avoidCropping),s&&(s.cameraId?u.deviceId=s.cameraId:Iw(s.useFrontCamera)?Iw(s.videoTrack)||(u.customSource=s.videoTrack):u.facingMode=s.useFrontCamera?nC.FACING_MODE_USER:nC.FACING_MODE_ENVIRONMENT,s.qosPreference&&(u.contentHint=$F(s.qosPreference)),Iw(s.profile)||(bw(s.profile)?eC[s.profile]&&c.setProfile(eC[s.profile]):c.setProfile(s.profile)),Iw(s.fillMode)||(l.objectFit=s.fillMode),Iw(s.mirror)||(l.mirror=s.mirror),Iw(s.small)||(zO()?bw(s.small)?c.small=eC[s.small]:!0===s.small?c.small=eC["120p"]:c.small=s.small:e._log.warn("small stream is not supported"))),c.once("first-video-frame",(function(t){e.emit(qF.FIRST_VIDEO_FRAME,$A(QA({},t),{streamType:QF(t.streamType)}))})),c.on("5",(function(t){e.emit(qF.ERROR,new CF({code:SF.DEVICE_ERROR,extraCode:5308,messageParams:{error:t}}))})),c.on("2",(function(t){e.emit(qF.DEVICE_CHANGED,{type:"camera",action:"active",device:t})})),c.on("4",(function(t){var n;t.error&&(n=CF.convertFrom(t.error)),e.emit(qF.PUBLISH_STATE_CHANGED,$A(QA({},t),{error:n}))})),e._listenOutputTrackChanged(c),n.next=12,c.capture(u);case 12:if(n.t0=Iw(o),n.t0){n.next=16;break}return n.next=16,c.setMute(o);case 16:return FP(c,c).add("player-state-changed",(function(t){e.emit(qF.VIDEO_PLAY_STATE_CHANGED,$A(QA({},t),{userId:"",streamType:"main"}))})),a&&e._room.isJoined&&e._room.publish(c).catch((function(){})),e._localVideoTrack=c,e._localVideoConfig=$A(QA({},t),{view:r,publish:a}),n.next=22,e._updateVideoPlayOption({view:r,playOption:l,track:c});case 22:case"end":return n.stop()}}),n)}))()}))}},{key:"updateLocalVideo",value:function(e){return aR(this,null,f().mark((function t(){var n,r,i,a,o,s;return f().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this._localVideoTrack&&this._localVideoConfig){t.next=2;break}return t.abrupt("return");case 2:if(n=e.view,r=e.publish,i=e.mute,a=e.option,o={},!a){t.next=28;break}if(Iw(a.profile)||(bw(a.profile)?eC[a.profile]&&this._localVideoTrack.setProfile(eC[a.profile]):this._localVideoTrack.setProfile(a.profile),(!a.cameraId||!this._localVideoTrack.isNeedToSwitchDevice(a.cameraId))&&Iw(a.useFrontCamera)&&this._localVideoTrack.applyProfile()),!a.cameraId){t.next=10;break}return t.next=8,this._localVideoTrack.switchDevice(a.cameraId);case 8:t.next=19;break;case 10:if(!Iw(a.useFrontCamera)){t.next=17;break}if(t.t0=Iw(a.videoTrack),t.t0){t.next=15;break}return t.next=15,this._localVideoTrack.setInputMediaStreamTrack(a.videoTrack);case 15:t.next=19;break;case 17:return t.next=19,this._localVideoTrack.switchDevice(a.useFrontCamera?nC.FACING_MODE_USER:nC.FACING_MODE_ENVIRONMENT);case 19:if(Iw(a.fillMode)||(o.objectFit=a.fillMode),Iw(a.mirror)||(o.mirror=a.mirror),a.qosPreference&&this._localVideoTrack.mediaTrack&&this._localVideoTrack.setContentHint($F(a.qosPreference)),!a.small){t.next=27;break}s=!this._localVideoTrack.small,zO()?(!0===a.small?this._localVideoTrack.small=eC["120p"]:bw(a.small)?this._localVideoTrack.small=eC[a.small]:this._localVideoTrack.small=a.small,this._room.videoManager.update(),s&&this._room.enableSmall(!0)):this._log.warn("small stream is not supported"),t.next=28;break;case 27:!1===a.small&&this._localVideoTrack.small&&(delete this._localVideoTrack.small,this._room.videoManager.update(),this._room.enableSmall(!1));case 28:if(this._room.isJoined&&!Iw(r)&&(r&&!this._localVideoConfig.publish&&this._room.publish(this._localVideoTrack).catch((function(){})),this._localVideoConfig.publish&&!r&&this._room.unpublish(this._localVideoTrack).catch((function(){}))),t.t1=Iw(i),t.t1){t.next=33;break}return t.next=33,this._localVideoTrack.setMute(i);case 33:return t.next=35,this._updateVideoPlayOption({view:n,playOption:o,track:this._localVideoTrack,prevConfig:this._localVideoConfig});case 35:Jw(this._localVideoConfig,e);case 36:case"end":return t.stop()}}),t,this)})))}},{key:"stopLocalVideo",value:function(){return aR(this,null,f().mark((function e(){return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(e.t0=this._localVideoTrack,!e.t0){e.next=11;break}if(e.t1=this._room.isJoined,!e.t1){e.next=6;break}return e.next=6,this._room.unpublish(this._localVideoTrack).catch((function(){}));case 6:this._localVideoTrack.stop(),this._localVideoTrack.close(),BP(this._localVideoTrack),this._localVideoTrack=null,this._localVideoConfig=null;case 11:case"end":return e.stop()}}),e,this)})))}},{key:"startScreenShare",value:function(){return aR(this,arguments,(function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{publish:!0,view:null};return f().mark((function n(){var r,i,a,o,s,c,u,l,d,h,p,m;return f().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(!e._localScreenTrack){n.next=2;break}return n.abrupt("return",void e._log.warn("screen share is already started"));case 2:return r=t.view,i=void 0===r?null:r,a=t.publish,o=void 0===a||a,s=t.option,(c=new wL(e._room.videoManager)).on("4",(function(t){var n;t.error&&(n=CF.convertFrom(t.error)),e.emit(qF.PUBLISH_STATE_CHANGED,$A(QA({},t),{error:n}))})),c.once("first-video-frame",(function(t){e.emit(qF.FIRST_VIDEO_FRAME,$A(QA({},t),{streamType:QF(t.streamType)}))})),e._listenOutputTrackChanged(c),"main"===t.streamType&&(c.mediaType=4),u=null,l={},d={},s&&(Iw(s.profile)||(bw(s.profile)?tC[s.profile]&&c.setProfile(tC[s.profile]):c.setProfile(s.profile)),s.systemAudio&&(l.systemAudio=!0,l.echoCancellation=s.echoCancellation,l.noiseSuppression=s.noiseSuppression,l.autoGainControl=s.autoGainControl),Iw(s.fillMode)||(d.objectFit=s.fillMode),s.videoTrack&&(l.videoTrack=s.videoTrack),s.audioTrack&&(l.audioTrack=s.audioTrack),s.captureElement&&(l.captureElement=s.captureElement),s.preferDisplaySurface&&(l.preferDisplaySurface=s.preferDisplaySurface),s.qosPreference&&(l.contentHint=$F(s.qosPreference))),n.next=8,c.capture(l);case 8:if(h=n.sent,c.mediaTrack.addEventListener(nC.ENDED,(function(){e._stopScreenShare(),e.emit(qF.SCREEN_SHARE_STOPPED)})),n.t0=h.getAudioTracks()[0],!n.t0){n.next=16;break}return u=new NL(e._room.audioManager),n.next=15,u.setInputMediaStreamTrack(h.getAudioTracks()[0]);case 15:e._speakerId&&u.setAudioOutput(e._speakerId);case 16:if(FP(c,c).add("player-state-changed",(function(t){e.emit(qF.VIDEO_PLAY_STATE_CHANGED,$A(QA({},t),{userId:"",streamType:"sub"}))})),!o||!e._room.isJoined){n.next=20;break}m=[c],u&&m.push(u),(p=e._room).publish.apply(p,m).catch((function(){}));case 20:return e._localScreenTrack=c,e._localScreenAudioTrack=u,e._localScreenConfig=$A(QA({},t),{view:i,publish:o}),n.next=25,e._updateVideoPlayOption({view:i,playOption:d,track:c});case 25:case"end":return n.stop()}}),n)}))()}))}},{key:"updateScreenShare",value:function(e){return aR(this,null,f().mark((function t(){var n,r,i,a,o;return f().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this._localScreenTrack&&this._localScreenConfig){t.next=2;break}return t.abrupt("return");case 2:return n=e.view,r=e.publish,i=e.option,a={},i&&(Iw(i.fillMode)||(a.objectFit=i.fillMode),i.qosPreference)&&(o=$F(i.qosPreference),this._localScreenTrack.setContentHint(o)),this._room.isJoined&&!Iw(r)&&(r&&!this._localScreenConfig.publish&&(this._room.publish(this._localScreenTrack).catch((function(){})),this._localScreenAudioTrack&&this._room.publish(this._localScreenAudioTrack).catch((function(){}))),this._localScreenConfig.publish&&!r&&(this._room.unpublish(this._localScreenTrack).catch((function(){})),this._localScreenAudioTrack&&this._room.unpublish(this._localScreenAudioTrack).catch((function(){})))),t.next=7,this._updateVideoPlayOption({view:n,playOption:a,track:this._localScreenTrack,prevConfig:this._localScreenConfig});case 7:Jw(this._localScreenConfig,e);case 8:case"end":return t.stop()}}),t,this)})))}},{key:"stopScreenShare",value:function(){return aR(this,null,f().mark((function e(){return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._stopScreenShare();case 2:return e.abrupt("return",e.sent);case 3:case"end":return e.stop()}}),e,this)})))}},{key:"startRemoteVideo",value:function(e){return aR(this,null,f().mark((function t(){var n,r,i,a,o,s,c,u;return f().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=e.view,r=e.userId,i=e.streamType,a=e.option,o="".concat(r,"_").concat(i),!this._remoteVideoConfigMap.has(o)){t.next=3;break}return t.abrupt("return",void this._log.warn("remote video has already started. userId:".concat(r,", streamType:").concat(i)));case 3:if(s=this._room.remotePublishedUserMap.get(r)){t.next=6;break}return t.abrupt("return");case 6:return c={},u="main"===i?s.remoteVideoTrack:s.remoteAuxiliaryTrack,this._listenOutputTrackChanged(u),a&&(Iw(a.fillMode)||(c.objectFit=a.fillMode),Iw(a.mirror)||(c.mirror=a.mirror),Iw(a.poster)||(c.poster=a.poster),c.canvasRender=a.canvasRender,"main"===i&&!Iw(a.small)&&(!s.remoteVideoTrack.isSubscribing&&!s.remoteVideoTrack.isSubscribed&&s.remoteVideoTrack.setMediaType(a.small?8:4),this._room.changeType(a.small,u.user))),t.next=11,this._room.subscribe(u);case 11:return t.next=13,this._enableVideoDecodeFallback(u,i);case 13:return t.next=15,this._updateVideoPlayOption({view:n,playOption:c,track:u});case 15:this._emitTrackEvent(u),this._remoteVideoConfigMap.set(o,{config:e}),a&&!Iw(a.receiveWhenViewVisible)&&this._observeView({remoteTrack:u,view:n,receiveWhenViewVisible:a.receiveWhenViewVisible,viewRoot:null==a?void 0:a.viewRoot});case 18:case"end":return t.stop()}}),t,this)})))}},{key:"updateRemoteVideo",value:function(e){return aR(this,null,f().mark((function t(){var n,r,i,a,o,s,c,u,l,d,h,p,m,v,_;return f().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(i=e.view,a=e.userId,o=e.streamType,s=e.option,c="".concat(a,"_").concat(o),(u=this._remoteVideoConfigMap.get(c))&&this._room.remotePublishedUserMap.has(a)){t.next=3;break}return t.abrupt("return");case 3:if(l={},s&&(Iw(s.fillMode)||(l.objectFit=s.fillMode),Iw(s.mirror)||(l.mirror=s.mirror)),d=null,h=this._room.remotePublishedUserMap.get(a),"main"===o&&null!=h&&h.muteState.hasVideo&&(d=h.remoteVideoTrack),"sub"===o&&null!=h&&h.muteState.hasAuxiliary&&(d=h.remoteAuxiliaryTrack),d){t.next=8;break}return t.abrupt("return");case 8:return p=u.config,"main"===o&&s&&!Iw(s.small)&&this._room.changeType(s.small,d.user),t.next=12,this._updateVideoPlayOption({view:i,playOption:l,track:d,prevConfig:p});case 12:Jw(p,e),m=Iw(null==s?void 0:s.receiveWhenViewVisible)?null==(n=p.option)?void 0:n.receiveWhenViewVisible:s.receiveWhenViewVisible,v=Iw(i)?p.view:i,_=Iw(null==s?void 0:s.viewRoot)?null==(r=p.option)?void 0:r.viewRoot:s.viewRoot,this._observeView({remoteTrack:d,view:v,receiveWhenViewVisible:m,viewRoot:_});case 15:case"end":return t.stop()}}),t,this)})))}},{key:"stopRemoteVideo",value:function(e){return aR(this,null,f().mark((function t(){return f().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this._stopRemoteVideo(e));case 1:case"end":return t.stop()}}),t,this)})))}},{key:"_stopRemoteVideo",value:function(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];return aR(this,null,f().mark((function n(){var r,i,a,o,s,c,u,l,d;return f().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:r=[],(i=this._room.remotePublishedUserMap.get(e.userId))&&(a=i.muteState,o=i.remoteVideoTrack,s=i.remoteAuxiliaryTrack,"main"===e.streamType&&(o.stop(),a.hasVideo&&r.push(o)),"sub"===e.streamType&&(s.stop(),a.hasAuxiliary&&r.push(s))),c=0,u=r;case 3:if(!(c<u.length)){n.next=13;break}if(l=u[c],n.t0=t,!n.t0){n.next=10;break}return n.next=9,this._room.unsubscribe(l);case 9:this._mediaTrackMap.delete(l.outMediaTrack);case 10:c++,n.next=3;break;case 13:(d=this._remoteVideoConfigMap.get("".concat(e.userId,"_").concat(e.streamType)))&&d.observer&&d.observer.disconnect(),this._remoteVideoConfigMap.delete("".concat(e.userId,"_").concat(e.streamType));case 15:case"end":return n.stop()}}),n,this)})))}},{key:"muteRemoteAudio",value:function(e,t){return aR(this,null,f().mark((function n(){var r,i,a,o;return f().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(this._remoteAudioMuteMap.set(e,t),n.prev=1,"*"!==e){n.next=30;break}if(!t){n.next=8;break}return n.next=6,this._stopRemoteAudio({userId:e});case 6:n.next=28;break;case 8:r=E(this._room.remotePublishedUserMap.values()),i=s(r),n.prev=10,i.s();case 12:if((a=i.n()).done){n.next=20;break}if(o=a.value,n.t0=o.muteState.hasAudio&&!this._remoteAudioConfigMap.has(o.userId),!n.t0){n.next=18;break}return n.next=18,this._startRemoteAudio({userId:o.userId});case 18:n.next=12;break;case 20:n.next=25;break;case 22:n.prev=22,n.t1=n.catch(10),i.e(n.t1);case 25:return n.prev=25,i.f(),n.finish(25);case 28:n.next=39;break;case 30:if(!t){n.next=35;break}return n.next=33,this._stopRemoteAudio({userId:e});case 33:n.next=39;break;case 35:if(n.t2=this._remoteAudioConfigMap.has(e),n.t2){n.next=39;break}return n.next=39,this._startRemoteAudio({userId:e});case 39:n.next=44;break;case 41:throw n.prev=41,n.t3=n.catch(1),this._remoteAudioMuteMap.delete(e),n.t3;case 44:case"end":return n.stop()}}),n,this,[[1,41],[10,22,25,28]])})))}},{key:"setRemoteAudioVolume",value:function(e,t){if("*"===e){var n,r=s(E(this._room.remotePublishedUserMap.values()));try{for(r.s();!(n=r.n()).done;){var i=n.value;this._remoteAudioVolumeMap.set(i.userId,t),i.remoteAudioTrack.isSubscribed&&this._updateAudioPlayOption({playOption:{volume:t},track:i.remoteAudioTrack})}}catch(o){r.e(o)}finally{r.f()}}else if(e){var a=this._room.remotePublishedUserMap.get(e);this._remoteAudioVolumeMap.set(e,t),a&&a.remoteAudioTrack.isSubscribed&&this._updateAudioPlayOption({playOption:{volume:t},track:a.remoteAudioTrack})}}},{key:"startPlugin",value:function(e,t){return aR(this,null,f().mark((function n(){return f().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.abrupt("return",e.start(t));case 1:case"end":return n.stop()}}),n)})))}},{key:"updatePlugin",value:function(e,t){return aR(this,null,f().mark((function n(){return f().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.abrupt("return",e.update(t));case 1:case"end":return n.stop()}}),n)})))}},{key:"stopPlugin",value:function(e,t){return aR(this,null,f().mark((function n(){return f().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.abrupt("return",e.stop(t));case 1:case"end":return n.stop()}}),n)})))}},{key:"enableAudioVolumeEvaluation",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:2e3,t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];this._room.enableAudioVolumeEvaluation(e,t)}},{key:"on",value:function(e,t,n){var r=this;return this.listeners(e).includes(t)||(this._log.debug("on",e),g(i,"on",this,3)([e,t,n]),this._eventListened.add(e),e===i.EVENT.AUDIO_FRAME&&!this._getPCMAbortCtrl&&(this._getPCMAbortCtrl=this._room.audioManager.getPCM((function(e){r.emit(i.EVENT.AUDIO_FRAME,{data:e})})),this._localAudioTrack&&this._localAudioTrack.on("input-media-track-changed",(function(){r._getPCMAbortCtrl&&(r._getPCMAbortCtrl.abort("inputMediaTrackChanged"),r._getPCMAbortCtrl=r._room.audioManager.getPCM((function(e){r.emit(i.EVENT.AUDIO_FRAME,{data:e})})))})))),this}},{key:"emit",value:function(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r];try{XF.has(e)&&this._log.debug("emit ".concat(e," ").concat(JSON.stringify(n)))}catch(vx){}return g(i,"emit",this,3)([e].concat(n))}},{key:"off",value:function(e,t,n){var r,a;return this._log.debug("off",e),"*"===e?(this._eventListened.clear(),this.removeAllListeners(),null==(r=this._getPCMAbortCtrl)||r.abort("off"),delete this._getPCMAbortCtrl):(g(i,"off",this,3)([e,t,n]),e===i.EVENT.AUDIO_FRAME&&(null==(a=this._getPCMAbortCtrl)||a.abort("off"),delete this._getPCMAbortCtrl)),this}},{key:"getAudioTrack",value:function(){var e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{userId:"",streamType:"main"},n=null,r="main",i=!1;if(bw(t)?e=t:(e=t.userId,i=!0===t.processed,t.streamType&&(r=t.streamType)),e){var a=this._room.remotePublishedUserMap.get(e);a&&(n=a.remoteAudioTrack)}else n="sub"===r?this._localScreenAudioTrack:this._localAudioTrack;return n?i&&n.outMediaTrack&&n.outMediaTrack!==n.mediaTrack?n.outMediaTrack.clone():n.mediaTrack:null}},{key:"getVideoTrack",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{userId:"",streamType:"main"},t=e.userId,n=void 0===t?"":t,r=e.streamType,i=void 0===r?"main":r,a=e.processed,o=void 0!==a&&a,s=null;if(""===n)"main"===i&&this._localVideoTrack&&(s=this._localVideoTrack),"sub"===i&&this._localScreenTrack&&(s=this._localScreenTrack);else{var c=this._room.remotePublishedUserMap.get(n);c&&(s="main"===i?c.remoteVideoTrack:c.remoteAuxiliaryTrack)}return s?o&&s.outMediaTrack&&s.outMediaTrack!==s.mediaTrack?s.outMediaTrack.clone():s.mediaTrack:null}},{key:"getVideoSnapshot",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.userId,n=e.streamType,r=void 0===n?"main":n;if(t){var i=this._room.remotePublishedUserMap.get(t);if("main"===r&&null!=i&&i.muteState.hasVideo)return i.remoteVideoTrack.getVideoFrame();if("sub"===r&&null!=i&&i.muteState.hasAuxiliary)return i.remoteAuxiliaryTrack.getVideoFrame()}else{if("main"===r&&this._localVideoTrack)return this._localVideoTrack.getVideoFrame();if("sub"===r&&this._localScreenTrack)return this._localScreenTrack.getVideoFrame()}return""}},{key:"_setCurrentSpeaker",value:function(e){var t,n;this._speakerId=e,null==(t=this._localAudioTrack)||t.setAudioOutput(e),null==(n=this._localScreenAudioTrack)||n.setAudioOutput(e),this._room.remotePublishedUserMap.forEach((function(t){return t.remoteAudioTrack.setAudioOutput(e)}))}},{key:"setCurrentSpeaker",value:function(e){return aR(this,null,f().mark((function t(){var n=this;return f().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,WM();case 2:t.sent.forEach((function(t){t.deviceId===e&&(n._setCurrentSpeaker(e),n.emit(qF.DEVICE_CHANGED,{type:"speaker",action:"active",device:t}),nj=t)})),this._log.warn('the "setCurrentSpeaker" method of the instance will be deprecated in the future, please use "TRTC.setCurrentSpeaker" instead. For more information, please visit: https://web.sdk.qcloud.com/trtc/webrtc/v5/doc/en/TRTC.html#.setCurrentSpeaker');case 4:case"end":return t.stop()}}),t,this)})))}},{key:"_startRemoteAudio",value:function(e){return this._doStartRemoteAudio(e)}},{key:"_doStartRemoteAudio",value:function(e){return aR(this,null,f().mark((function t(){var n,r,i,a,o,s,c=this;return f().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=e.userId,!this._remoteAudioConfigMap.has(n)){t.next=3;break}return t.abrupt("return",void this._log.warn("remote audio has already started. userId:".concat(n)));case 3:if(r=this._room.remotePublishedUserMap.get(n)){t.next=6;break}return t.abrupt("return");case 6:return i={},a=r.remoteAudioTrack,this._listenOutputTrackChanged(a),this._speakerId&&a.setAudioOutput(this._speakerId),t.prev=8,o=this._remoteAudioVolumeMap.get(n),s=Aw(o)?o:100,i.volume=s,this._remoteAudioConfigMap.set(n,e),t.next=14,this._room.subscribe(a);case 14:return KL(SV(a,"decode-failed"),JV(SV(a,wP.INIT)),WU((function(){c.startPlugin(ZB.Name,{track:a,type:"auto",config:{codec:"opus",sampleRate:48e3,numberOfChannels:1}})}))),t.next=17,this._updateAudioPlayOption({playOption:i,track:a});case 17:t.next=22;break;case 19:throw t.prev=19,t.t0=t.catch(8),this._remoteAudioConfigMap.delete(n),t.t0;case 22:this._emitTrackEvent(a);case 23:case"end":return t.stop()}}),t,this,[[8,19]])})))}},{key:"_stopRemoteAudio",value:function(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];return aR(this,null,f().mark((function n(){var r;return f().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(r=this._room.remotePublishedUserMap.get(e.userId),n.t0=r,!n.t0){n.next=9;break}if(r.remoteAudioTrack.stop(),n.t1=r.muteState.hasAudio&&t,!n.t1){n.next=8;break}return n.next=8,this._room.unsubscribe(r.remoteAudioTrack);case 8:this._mediaTrackMap.delete(r.remoteAudioTrack.outMediaTrack);case 9:this._remoteAudioConfigMap.delete("".concat(e.userId));case 10:case"end":return n.stop()}}),n,this)})))}},{key:"_enableVideoDecodeFallback",value:function(e,t){var n,r=this,i=this._room.videoDecodeFallbackType;i&&this._plugins.has("TRTCVideoDecoder")&&(e.log.debug("remote video will fall back when decode failed",e.id),KL(SV(e,"decode-failed"),JV(SV(e,wP.INIT)),JU((function(){r.startPlugin("TRTCVideoDecoder",{type:"auto",renderer:"videoFrame",track:e,config:{codec:"avc1.420028"},fallback:i})})),IU(SV(e,"decode-downgrade-state-changed")),WU((function(i){n=i.state,r.emit(qF.VIDEO_DECODE_DOWNGRADE_STATE_CHANGED,$A(QA({},i),{streamType:t,userId:e.userId}))}),(function(t){e.log.error("fallback",t)}),(function(){"STARTED"===n&&e.log.info("fallback complete")}))))}},{key:"_updateVideoPlayOption",value:function(e){return aR(this,arguments,(function(e){var t=e.view,n=e.playOption,r=e.track,i=e.prevConfig;return f().mark((function e(){var a,o;return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r.setMirror(n.mirror),!(Iw(t)&&i&&i.view)||jw(n)){e.next=6;break}if(a=zw(i.view),e.t0=a.length>0,!e.t0){e.next=6;break}return e.next=6,r.play(a,n);case 6:if(Iw(t)){e.next=14;break}if(!((o=zw(t)).length>0)){e.next=13;break}return e.next=11,r.play(o,n);case 11:e.next=14;break;case 13:r.stop();case 14:case"end":return e.stop()}}),e)}))()}))}},{key:"_updateAudioPlayOption",value:function(e){return aR(this,arguments,(function(e){var t=e.playOption,n=void 0===t?{}:t,r=e.track;return e.prevConfig,f().mark((function e(){return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r.isPlayCalled){e.next=8;break}return e.prev=1,e.next=4,r.play(null,n);case 4:e.next=8;break;case 6:e.prev=6,e.t0=e.catch(1);case 8:Iw(n.muted)||r.setPlayerMute(n.muted),Iw(n.volume)||r.setAudioVolume(n.volume/100);case 9:case"end":return e.stop()}}),e,null,[[1,6]])}))()}))}},{key:"_listenOutputTrackChanged",value:function(e){var t=this;0===e.listeners("output-media-track-changed").length&&e.on("output-media-track-changed",(function(){return t._emitTrackEvent(e,!1)}))}},{key:"_emitTrackEvent",value:function(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],n=e.isRemote?e.userId:"";e.outMediaTrack&&(t&&this._mediaTrackMap.get(e.outMediaTrack)===n||(this._mediaTrackMap.set(e.outMediaTrack,n),this.emit(qF.TRACK,{userId:n,streamType:QF(e.streamType),track:e.outMediaTrack,sourceTrack:e.mediaTrack})))}},{key:"_checkTrackToPublish",value:function(){var e,t,n,r,i=[];if(null!=(t=this._localAudioConfig)&&t.publish&&this._localAudioTrack&&i.push(this._localAudioTrack),null!=(n=this._localVideoConfig)&&n.publish&&this._localVideoTrack&&i.push(this._localVideoTrack),null!=(r=this._localScreenConfig)&&r.publish&&(this._localScreenTrack&&i.push(this._localScreenTrack),this._localScreenAudioTrack&&i.push(this._localScreenAudioTrack)),0!==i.length)return(e=this._room).publish.apply(e,i).catch((function(){}))}},{key:"_observeView",value:function(e){var t=this,n=e.remoteTrack,r=e.view,i=e.receiveWhenViewVisible,a=void 0!==i&&i,o=e.viewRoot;if(!Iw(r)){var s=this._remoteVideoConfigMap.get("".concat(n.userId,"_").concat(QF(n.streamType)));if(s){var c=s.observer||void 0;if(null===r||ww(r)&&0===r.length||!a)return null==c||c.disconnect(),void(n.isSubscribed||this._room.subscribe(n).catch((function(){})));var u=s.visibleViewMap||new Map,l=-1;(!c||c.root!==o)&&(null==c||c.disconnect(),u.clear(),c=new IntersectionObserver((function(e){e.forEach((function(e){u.set(e.target,e.isIntersecting)})),clearTimeout(l),l=window.setTimeout((function(){var e=E(u.values()).find((function(e){return e}));n.log.info("view is".concat(e?"":" not"," visible")),e?n.isSubscribed||t._room.subscribe(n).catch((function(){})):n.isSubscribed&&t._room.unsubscribe(n).catch((function(){}))}),200)}),{root:o}));var d=new Set(zw(r));u.forEach((function(e,t){d.has(t)||(c.unobserve(t),u.delete(t))})),d.forEach((function(e){u.set(e,!0),c.observe(e)})),c.takeRecords().forEach((function(e){u.set(e.target,e.isIntersecting)})),s.visibleViewMap=u,s.observer=c}}}},{key:"_exitRoom",value:function(){return aR(this,null,f().mark((function e(){var t=this;return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(e.t0=this._room.isJoined,!e.t0){e.next=4;break}return e.next=4,this._room.leave();case 4:new Set([].concat(E(this._remoteAudioConfigMap.keys()),E(this._remoteAudioMuteMap.keys()))).forEach((function(e){t._stopRemoteAudio({userId:e}).catch()})),E(this._remoteVideoConfigMap.keys()).forEach((function(e){var n=e.includes("main")?"main":"sub",r=e.split("_".concat(n))[0];r&&t._stopRemoteVideo({userId:r,streamType:n}).catch()})),this._remoteVideoConfigMap.clear(),this._remoteAudioConfigMap.clear(),this._remoteAudioMuteMap.clear(),this._remoteAudioVolumeMap.clear(),function(e){var t=vB.get(e);t&&(t.forEach((function(e){return clearTimeout(e)})),vB.delete(e))}(this),this._room.remotePublishedUserMap.forEach((function(e){BP(e.remoteAudioTrack),BP(e.remoteVideoTrack),BP(e.remoteAuxiliaryTrack)}));case 12:case"end":return e.stop()}}),e,this)})))}},{key:"_stopScreenShare",value:function(){return aR(this,null,f().mark((function e(){var t,n,r;return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._localScreenTrack){e.next=7;break}if(!this._room.isJoined){e.next=6;break}return r=[this._localScreenTrack],this._localScreenAudioTrack&&r.push(this._localScreenAudioTrack),e.next=6,null==(t=this._room)?void 0:(n=t).unpublish.apply(n,r).catch((function(){}));case 6:this._localScreenTrack.stop(),this._localScreenTrack.close(),this._localScreenAudioTrack&&(this._localScreenAudioTrack.stop(),this._localScreenAudioTrack.close(),this._room.audioManager.removeInput(this._localScreenAudioTrack),this._localScreenAudioTrack=null),BP(this._localScreenTrack),this._localScreenTrack=null,this._localScreenConfig=null;case 7:case"end":return e.stop()}}),e,this)})))}},{key:"_onLocalTrackCaptured",value:function(e){"audio"===e.track.kind&&(!nj||FM(nj))&&(this._initActiveSpeaker(),rx.off("102",this._onLocalTrackCaptured,this))}},{key:"_initActiveSpeaker",value:function(){return aR(this,null,f().mark((function e(){var t;return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!nj||FM(nj)){e.next=4;break}this.emit(qF.DEVICE_CHANGED,{type:"speaker",action:"active",device:nj}),e.next=8;break;case 4:return e.next=6,WM();case 6:(t=e.sent)[0]&&!FM(t[0])?(nj=t[0],this.emit(qF.DEVICE_CHANGED,{type:"speaker",action:"active",device:t[0]})):rx.on("102",this._onLocalTrackCaptured,this);case 8:case"end":return e.stop()}}),e,this)})))}},{key:"_onAudioAvailable",value:function(e){var t=e.userId,n=this._remoteAudioMuteMap.has(t)?this._remoteAudioMuteMap.get(t):this._remoteAudioMuteMap.get("*");(!1===n||this._room.autoReceiveAudio&&!n)&&this._doStartRemoteAudio({userId:t}).catch((function(){}))}},{key:"_onVideoAvailable",value:function(e){var t=this,n=e.userId,r=e.streamType;if(this._room.autoReceiveVideo){var i=this._room.remotePublishedUserMap.get(n);if(i){var a,o="main"===r?i.remoteVideoTrack:i.remoteAuxiliaryTrack,s=[o];this._room.autoReceiveAudio&&i.remoteAudioTrack.isAvailable&&s.push(i.remoteAudioTrack),(a=this._room).subscribe.apply(a,s).then((function(){t._emitTrackEvent(o)})).catch((function(){}))}}}},{key:"_onAudioUnavailable",value:function(e){var t=e.userId,n=e.muteState;n.hasAudio&&n.audioMuted||this._stopRemoteAudio({userId:t},!1).catch((function(){}))}},{key:"_onVideoUnavailable",value:function(e){var t=e.userId,n=e.streamType;this._stopRemoteVideo({userId:t,streamType:n},!1).catch((function(){}))}},{key:"sendSEIMessage",value:function(e,t){var n,r=this._plugins.get("SEI");r&&(r.update({buffer:e,options:$A(QA({seiPayloadType:243},t),{small:!(null==(n=this._localVideoTrack)||!n.small)})}),bO.addCount({key:5e5,useUV:!0}))}},{key:"sendCustomMessage",value:function(e){var t,n;null==(n=(t=this._room).sendCustomMessage)||n.call(t,e),bO.addCount({key:500001,useUV:!0})}}],[{key:"create",value:function(e){}},{key:"_create",value:function(e,t){var n;TF&&(TF=!1,5!==sx.getLogLevel()&&(console.info("******************************************************************************"),console.info("* TRTC Web SDK"),console.info("* API Document: ".concat(BR,"/en/index.html")),console.info("* Changelog: ".concat(BR,"/en/tutorial-01-info-changelog.html")),console.info("* Report issues: https://github.com/LiteAVSDK/TRTC_Web/issues"),console.info("******************************************************************************")),sx.info("TRTC Web SDK Version:",RR),jN||sx.debug("Build Time:","2025-04-25 11:03:13"),sx.info("UA:",navigator.userAgent),sx.info("URL: ".concat(location.href).concat("IFRAME"===(null==(n=self.frameElement)?void 0:n.tagName)?" in iframe":"")),YN().then((function(e){e&&sx.info(zN)})));var r=new i(e,t||{});return tj.add(r),r}},{key:"setLogLevel",value:function(e,t){sx.setLogLevel(e),Iw(t)||(t?sx.enableUploadLog():sx.disableUploadLog())}},{key:"isSupported",value:function(){return VO()}},{key:"getCameraList",value:function(){return HM(!(arguments.length>0&&void 0!==arguments[0])||arguments[0])}},{key:"getMicrophoneList",value:function(){return jM(!(arguments.length>0&&void 0!==arguments[0])||arguments[0])}},{key:"getSpeakerList",value:function(){return WM(!(arguments.length>0&&void 0!==arguments[0])||arguments[0])}},{key:"setCurrentSpeaker",value:function(e){return aR(this,null,f().mark((function t(){var n,r,a=this;return f().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(bD&&(e===kF.SPEAKER||e===kF.HEADSET)){t.next=6;break}return t.next=3,WM();case 3:t.sent.forEach((function(t){t.deviceId===e&&(tj.forEach((function(n){n._setCurrentSpeaker(e),n.emit(qF.DEVICE_CHANGED,{type:"speaker",action:"active",device:t})})),nj=t)})),t.next=13;break;case 6:return t.next=8,i.getMicrophoneList();case 8:if(n=t.sent,r="",n.forEach((function(t){t.label===e&&(r=t.deviceId)})),r){t.next=12;break}return t.abrupt("return");case 12:tj.forEach((function(e){return aR(a,null,f().mark((function t(){return f().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(t.t0=e._localAudioTrack,!t.t0){t.next=4;break}return t.next=4,e.updateLocalAudio({option:{microphoneId:r}});case 4:case"end":return t.stop()}}),t)})))}));case 13:case"end":return t.stop()}}),t)})))}},{key:"_addKVStat",value:function(e){var t=e.type,n=e.key,r=e.value,i=e.base,a=e.useUV,o=e.version;switch(o&&(IO.version=o),t){case"count":IO.addCount({key:n,useUV:a});break;case"enum":IO.addEnum({key:n,value:r,useUV:a});break;case"number":IO.addNumber({key:n,value:r,split:i})}}}])}(mR.EventEmitter);rR(ij,"_loggerManager",sx),rR(ij,"EVENT",qF),rR(ij,"ERROR_CODE",SF),rR(ij,"TYPE",kF),rR(ij,"frameWorkType",30),nR([TB({replaceArg:function(e){return{argIndex:0,value:{name:"plugin"in e?e.plugin.Name:e.Name,assetsPath:"assetsPath"in e?null==e?void 0:e.assetsPath:"default"}}}})],ij.prototype,"use",1),nR([_B(VF.TRTC.enterRoom),KF("room",(function(e,t){var n=v(e,1)[0],r=v(t,1)[0];return(n.roomId||n.strRoomId)===(r.roomId||r.strRoomId)&&n.userId===r.userId&&n.sdkAppId===r.sdkAppId})),uL((function(e){return function(t){return this._log.setUserId(t.userId),this._log.setSdkAppId(t.sdkAppId),e.call(this,t)}})),TB()],ij.prototype,"enterRoom",1),nR([TB()],ij.prototype,"exitRoom",1),nR([_B(VF.TRTC.switchRole),zF("room",{merge:function(e,t){return t}}),TB()],ij.prototype,"switchRole",1),nR([TB()],ij.prototype,"destroy",1),nR([_B(VF.TRTC.startLocalAudio),KF("audio",(function(e,t){var n,r,i=v(e,1)[0],a=v(t,1)[0];return(null==(n=null==i?void 0:i.option)?void 0:n.microphoneId)===(null==(r=null==a?void 0:a.option)?void 0:r.microphoneId)})),TB()],ij.prototype,"startLocalAudio",1),nR([_B(VF.TRTC.updateLocalAudio),zF("audio",{debounce:{delay:200,getKey:function(){return"".concat(ej,"-localAudio")},isNeedToDebounce:function(e){var t;return!Iw(null==(t=e.option)?void 0:t.captureVolume)}}}),TB()],ij.prototype,"updateLocalAudio",1),nR([YF("audio"),TB()],ij.prototype,"stopLocalAudio",1),nR([_B(VF.TRTC.startLocalVideo),KF("video",(function(e,t){var n,r,i=v(e,1)[0],a=v(t,1)[0];return(null==(n=null==i?void 0:i.option)?void 0:n.cameraId)===(null==(r=null==a?void 0:a.option)?void 0:r.cameraId)})),TB()],ij.prototype,"startLocalVideo",1),nR([_B(VF.TRTC.updateLocalVideo),zF("video"),TB()],ij.prototype,"updateLocalVideo",1),nR([YF("video"),TB()],ij.prototype,"stopLocalVideo",1),nR([_B(VF.TRTC.startScreenShare),KF("screen",(function(){return!0})),TB()],ij.prototype,"startScreenShare",1),nR([_B(VF.TRTC.updateScreenShare),zF("screen"),TB()],ij.prototype,"updateScreenShare",1),nR([TB()],ij.prototype,"stopScreenShare",1),nR([_B(VF.TRTC.startRemoteVideo),KF((function(e){return"v".concat(e.userId).concat(e.streamType)}),(function(){return!0})),TB({getRemoteId:function(e){return"".concat(e.userId,"_").concat(e.streamType)}})],ij.prototype,"startRemoteVideo",1),nR([_B(VF.TRTC.updateRemoteVideo),zF((function(e){return"v".concat(e.userId).concat(e.streamType)})),TB({getRemoteId:function(e){return"".concat(e.userId,"_").concat(e.streamType)}})],ij.prototype,"updateRemoteVideo",1),nR([_B(VF.TRTC.stopRemoteVideo),uL((function(e){return function(t){return aR(this,null,f().mark((function n(){var r,i=this;return f().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if("*"!==t.userId){n.next=3;break}return r=[],n.abrupt("return",(this._room.remotePublishedUserMap.forEach((function(e){i._remoteVideoConfigMap.has("".concat(e.userId,"_main"))&&r.push(i.stopRemoteVideo({streamType:"main",userId:e.userId}).catch((function(){}))),i._remoteVideoConfigMap.has("".concat(e.userId,"_sub"))&&r.push(i.stopRemoteVideo({streamType:"sub",userId:e.userId}).catch((function(){})))})),Promise.all(r)));case 3:return n.abrupt("return",e.call(this,t));case 4:case"end":return n.stop()}}),n,this)})))}})),TB({getRemoteId:function(e){return"".concat(e.userId,"_").concat(e.streamType)}})],ij.prototype,"stopRemoteVideo",1),nR([YF((function(e){return"v".concat(e.userId).concat(e.streamType)}))],ij.prototype,"_stopRemoteVideo",1),nR([_B.apply(void 0,E(VF.TRTC.muteRemoteAudio)),TB({getRemoteId:function(e){return e}})],ij.prototype,"muteRemoteAudio",1),nR([gB.apply(void 0,E(VF.TRTC.setRemoteAudioVolume)),function(e,t){return uL((function(e,n){return function(){for(var n=this,r=arguments.length,i=new Array(r),a=0;a<r;a++)i[a]=arguments[a];var o=vB.get(this);o||(o=new Map,vB.set(this,o));var s=t.apply(void 0,i),c=o.get(s);if(!c||c<=0){e.apply(this,i);var u=setTimeout((function(){var e;null==(e=vB.get(n))||e.delete(s)}),200);o.set(s,u)}else{clearTimeout(c);var l=window.setTimeout((function(){var t;e.apply(n,i),null==(t=vB.get(n))||t.delete(s)}),200);o.set(s,l)}}}))}(0,(function(e){return e})),TB({getRemoteId:function(e){return e}})],ij.prototype,"setRemoteAudioVolume",1),nR([kB("start"),sL((function(e){var t;return null==(t=e.afterStart)?void 0:t.call(e)})),KF((function(e,t){return e.disableRandomCall?null:e.getAlias()+e.getGroup(t)})),TB({replaceArg:function(e){return{argIndex:0,value:e.getName()}},getKVReportKey:function(e){return EO[e.getName()]},ignoreLog:function(e){return"Debug"===e.getName()}})],ij.prototype,"startPlugin",1),nR([kB("update"),zF((function(e,t){return e.disableRandomCall?null:e.getAlias()+e.getGroup(t)})),TB({replaceArg:function(e){return{argIndex:0,value:e.getName()}},getKVReportKey:function(e){return TO[e.getName()]}})],ij.prototype,"updatePlugin",1),nR([kB("stop"),YF((function(e,t){if(e.disableRandomCall)return null;var n=e.getGroup(t),r=e.getAlias();return"*"===n?new RegExp("".concat(r,".*")):r+n})),TB({replaceArg:function(e){return{argIndex:0,value:e.getName()}},getKVReportKey:function(e){return kO[e.getName()]}})],ij.prototype,"stopPlugin",1),nR([gB.apply(void 0,E(VF.TRTC.enableAudioVolumeEvaluation))],ij.prototype,"enableAudioVolumeEvaluation",1),nR([TB()],ij.prototype,"getVideoSnapshot",1),nR([TB()],ij.prototype,"_setCurrentSpeaker",1),nR([KF((function(e){return"a".concat(e.userId)}),(function(){return!0}))],ij.prototype,"_startRemoteAudio",1),nR([uL((function(e){return function(t){return aR(this,null,f().mark((function n(){var r=this;return f().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.abrupt("return","*"===t.userId?Promise.all(E(this._room.remotePublishedUserMap.values()).map((function(e){return r._stopRemoteAudio($A(QA({},t),{userId:e.userId})).catch((function(){}))}))):e.call(this,t));case 1:case"end":return n.stop()}}),n,this)})))}})),YF((function(e){return"a".concat(e.userId)}))],ij.prototype,"_stopRemoteAudio",1),nR([YF("room")],ij.prototype,"_exitRoom",1),nR([YF("screen")],ij.prototype,"_stopScreenShare",1),nR([_B.apply(void 0,E(VF.TRTC.sendSEIMessage)),yF({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}})],ij.prototype,"sendSEIMessage",1),nR([_B(VF.TRTC.sendCustomMessage),yF({timesInSecond:30,maxSizeInSecond:8e3,getSize:function(e){return e.data.byteLength}})],ij.prototype,"sendCustomMessage",1),nR([_B(VF.TRTC.create)],ij,"_create",1);var aj=ij,oj=function(){return o((function e(){r(this,e),rR(this,"_set",new Set),rx.on(ax.LEAVE_SUCCESS,this.delete,this)}),[{key:"add",value:function(e){var t=e.room,n=e.roomId;if("rtc"!==t.scene){var r=this.getKey(t.userId,n||t.roomId,t.sdkAppId,t.useStringRoomId);this._set.add(r)}}},{key:"delete",value:function(e){var t=e.room,n=e.roomId;if("rtc"!==t.scene){var r=this.getKey(t.userId,t.roomId||n,t.sdkAppId,t.useStringRoomId);this._set.delete(r)}}},{key:"getKey",value:function(e,t,n,r){return"".concat(n,"_").concat(t,"_").concat(e,"_").concat(r)}},{key:"isJoined",value:function(e){var t=e.userId,n=e.roomId,r=e.sdkAppId,i=e.room;return"rtc"!==i.scene&&this._set.has(this.getKey(t,n,r,i.useStringRoomId))}}])}();function sj(){return aR(this,null,f().mark((function e(){var t,n,r,i,a,o,s,c,u,l,d,h,p,m;return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,jM();case 3:r=e.sent,t=r&&r.length,e.next=9;break;case 7:e.prev=7,e.t0=e.catch(0);case 9:return e.prev=9,e.next=12,HM();case 12:i=e.sent,n=i&&i.length,e.next=18;break;case 16:e.prev=16,e.t1=e.catch(9);case 18:a={microphone:t,camera:n},o=this.checkSystemResult.detail,s=o.isH264EncodeSupported,c=o.isVp8EncodeSupported,u=o.isH264DecodeSupported,l=o.isVp8DecodeSupported,d=lx.basis(),h={webRTC:d.isWebRTCSupported,getUserMedia:d.isGetUserMediaSupported,webSocket:d.isWebSocketsSupported,screenShare:d.isScreenShareSupported,webAudio:d.isWebAudioSupported,h264Encode:s,h264Decode:u,vp8Encode:c,vp8Decode:l},p={browser:d.browser,os:d.os,trtc:h,devices:a},m={isWebCodecSupported:d.isWebCodecSupported,isMediaSessionSupported:d.isMediaSessionSupported,isWebTransportSupported:d.isWebTransportSupported},jP.uploadEvent({log:"trtcstats-".concat(JSON.stringify(p)),userId:this.userId}),this._log.info("TrtcStats-".concat(JSON.stringify(p))),jP.uploadEvent({log:"trtcadvancedstats-".concat(JSON.stringify(m)),userId:this.userId});case 20:case"end":return e.stop()}}),e,this,[[0,7],[9,16]])})))}var cj=tR(oR()),uj="3",lj="5",dj={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,START_PUBLISH_CDN_STREAM_RES:8196,UPDATE_PUBLISH_CDN_STREAM_RES:8198,STOP_PUBLISH_CDN_STREAM_RES:8200,USER_LIST_RES:4137,SWITCH_ROLE_RES:4110,UPDATE_CONSTRAINT_CONFIG_RES:772,REBUILD_PEER_CONNECTION_RES:4150,SPC_PUBLISH_RESULT:4146,SPC_SUBSCRIBE_RESULT:4156,ABILITY_STATUS_REPORT_RESULT:4158,SERVER_FIRST_PACKAGE_RECEIVED:5e3,RECEIVE_CUSTOM_MSG:4140},hj=[dj.UPDATE_REMOTE_MUTE_STAT,dj.UPLINK_NETWORK_STATS,dj.USER_LIST_RES,dj.MUTE_RESULT,dj.SERVER_FIRST_PACKAGE_RECEIVED,dj.RECEIVE_CUSTOM_MSG],fj={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",START_PUBLISH_CDN_STREAM_RES:"start-publish-cdn-stream-res",UPDATE_PUBLISH_CDN_STREAM_RES:"update-publish-cdn-stream-res",STOP_PUBLISH_CDN_STREAM_RES:"stop-publish-cdn-stream-res",USER_LIST_RES:"user-list-res",SWITCH_ROLE_RES:"switch_role_res",MUTE_RESULT:"mute-result",UPDATE_CONSTRAINT_CONFIG_RES:"update-contraint-config-res",REBUILD_PEER_CONNECTION_RES:"rebuild-pc-res",SPC_PUBLISH_RESULT:"spc-publish-result",SPC_SUBSCRIBE_RESULT:"spc-subscribe-result",ABILITY_STATUS_REPORT_RESULT:"ability-status-report",SERVER_FIRST_PACKAGE_RECEIVED:"first-pkg-received",RECEIVE_CUSTOM_MSG:"receive-custom-msg"},pj="mute_uplink",mj="publish_state_change",vj="unpublish",_j="unsubscribe",gj="subscribe_change",yj="update_constraint_config",Ej=new Set,Tj=function(e){function i(e){var a,o,s,c;r(this,i),a=n(this,i),rR(t(a),"room"),rR(t(a),"sdkAppId"),rR(t(a),"userId"),rR(t(a),"userSig"),rR(t(a),"url"),rR(t(a),"backupUrl"),rR(t(a),"race"),rR(t(a),"destroyed",!1),rR(t(a),"_socketInUse"),rR(t(a),"_socket"),rR(t(a),"_backupSocket"),rR(t(a),"_signalInfo",{tinyId:void 0,clientIp:"",signalIp:"",relayIp:"",relayInnerIp:"",relayPort:0,endReportExtend:void 0,bakRelayIps:[]}),rR(t(a),"_currentState","DISCONNECTED"),rR(t(a),"_isReconnecting",!1),rR(t(a),"_seq",0),rR(t(a),"_log"),rR(t(a),"_lastMessageTime",-1),rR(t(a),"_connectStartTime",-1),rR(t(a),"_stopConnectRetry"),rR(t(a),"bytesSent",0),rR(t(a),"bytesReceived",0),rR(t(a),"keepAlive",!1),rR(t(a),"signalDomainWhenUnifiedProxy"),rR(t(a),"stopKeepAliveTimeout"),rR(t(a),"rtt",0),a.room=e.room,a.sdkAppId=e.sdkAppId,a.userId=e.userId,a.userSig=e.userSig,a.race=!!Iw(e.race)||e.race,a.signalDomainWhenUnifiedProxy=e.signalDomainWhenUnifiedProxy;var u=(null==(s=null==(o=a.room.scheduleResult)?void 0:o.config)?void 0:s.keepAliveClient)||0;return null!=(c=a.room.joinParams)&&c.keepAlive&&!u&&(u=1),u-Ej.size>0&&a.room.enableSPC&&(a.keepAlive=!0,Ej.add(a)),a.url=e.url,a.backupUrl=e.backupUrl,a._seq=0,a._log=sx.createLogger({id:"ws",userId:a.userId,sdkAppId:a.sdkAppId}),a.onmessage=a.onmessage.bind(a),a.onerror=a.onerror.bind(a),a.onclose=a.onclose.bind(a),a}return d(i,e),o(i,[{key:"urlParam",get:function(){var e="?sdkAppId=".concat(encodeURIComponent(this.sdkAppId),"&userId=").concat(encodeURIComponent(this.userId),"&userSig=").concat(encodeURIComponent(this.userSig),"&keepAlive=").concat(encodeURIComponent(Number(this.keepAlive)));this.signalDomainWhenUnifiedProxy&&(e+="&signalDomain=".concat(encodeURIComponent(this.signalDomainWhenUnifiedProxy)));var t=new URLSearchParams(location.search).get("clientIp");return t&&(e+="&clientIp=".concat(t)),this.race?"".concat(e,"&race=1"):e}},{key:"_urlWithParam",get:function(){return"".concat(this.url).concat(this.race?"/v2/ws":"").concat(this.urlParam)}},{key:"_backupUrlWithParam",get:function(){return"".concat(this.backupUrl).concat(this.race?"/v2/ws":"").concat(this.urlParam)}},{key:"isConnected",get:function(){return"CONNECTED"===this._currentState}},{key:"isConnecting",get:function(){return"CONNECTING"===this._currentState}},{key:"isOnline",get:function(){return"CONNECTED"===this._currentState&&Date.now()-this._lastMessageTime<12e3}},{key:"connect",value:function(){return aR(this,arguments,(function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1e4;return f().mark((function n(){var r;return f().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(!e.isConnected){n.next=2;break}return n.abrupt("return",Promise.resolve());case 2:return e._log.info("connect to [".concat(e.url,", ").concat(e.backupUrl,"]").concat(t?" timeout: ".concat(t):""," keepAlive: ").concat(Number(e.keepAlive))),e.emitConnectionStateChanged("CONNECTING"),e._connectStartTime=Vw(),r=[e.connectWS({url:e._urlWithParam,isMain:!0,timeout:t})],e.race&&e._backupUrlWithParam!==e._urlWithParam&&r.push(e.connectWS({url:e._backupUrlWithParam,isMain:!1,timeout:t})),n.next=7,Lw(r);case 7:e._socketInUse=n.sent,e.unbindAndCloseSocket(e._socketInUse===e._socket?nC.BACKUP:nC.MAIN),e.emitConnectionStateChanged("CONNECTED");case 10:case"end":return n.stop()}}),n)}))()}))}},{key:"connectWS",value:function(e){var t=this,n=e.url,r=e.timeout,i=e.isMain,a=new WebSocket(n);this.bindSocket(a),i?this._socket=a:this._backupSocket=a;var o=-1;return new Promise((function(e,n){a.onclose=n,a.onerror=n,a.onopen=function(){return e(a)},r&&(o=setTimeout((function(){t.unbindAndCloseSocket(i?nC.MAIN:nC.BACKUP),n(new yR({code:_R.SIGNAL_CHANNEL_SETUP_FAILED,message:"ws connect timeout"}))}),r))})).finally((function(){a.onclose=null,a.onerror=null,a.onopen=null,clearTimeout(o)}))}},{key:"bindSocket",value:function(e){e.addEventListener("close",this.onclose),e.addEventListener("error",this.onerror),e.addEventListener("message",this.onmessage)}},{key:"unbindSocket",value:function(e){e.removeEventListener("close",this.onclose),e.removeEventListener("error",this.onerror),e.removeEventListener("message",this.onmessage)}},{key:"unbindAndCloseSocket",value:function(e){if(e===nC.MAIN){if(this._socket){this.unbindSocket(this._socket);try{this._socket.close(1e3)}catch(DC){}this._socket=null}}else if(this._backupSocket){this.unbindSocket(this._backupSocket);try{this._backupSocket.close(1e3)}catch(DC){}this._backupSocket=null}}},{key:"onclose",value:function(e){e.target===this._socketInUse&&(this._log.warn("".concat(e.target===this._socket?"main":"backup"," is closed code:").concat(e.code," ").concat(e.reason)),this.emitConnectionStateChanged("DISCONNECTED"),(!e.wasClean||1e3!==e.code)&&this.startReconnection(),this.room.isJoining&&this.emit(lj,new yR({code:_R.SIGNAL_CHANNEL_SETUP_FAILED,message:"websocket onclose"})))}},{key:"onerror",value:function(e){this._log.error("".concat(e.target===this._socket?"main":"backup"," error observed")),this.emitConnectionStateChanged("DISCONNECTED"),e.target===this._socketInUse&&(this.unbindAndCloseSocket(nC.MAIN),this.unbindAndCloseSocket(nC.BACKUP),this._socketInUse=null,this.reconnect()),this.room.isJoining&&this.emit(lj,new yR({code:_R.SIGNAL_CHANNEL_SETUP_FAILED,message:"websocket onerror"}))}},{key:"onmessage",value:function(e){if(this.isConnected){this._lastMessageTime=Date.now(),this.bytesReceived+=$w(e.data);var t=JSON.parse(e.data),n=t.cmd,r=t.data,i=Object.values(dj),a=Object.keys(dj)[i.indexOf(n)],o=fj[a]||n;switch(hj.includes(n)||(this._log.debug("received ".concat(n," msg: ").concat(e.data)),o&&this._log.info("Received event: [ ".concat(o," ]"))),n){case dj.CHANNEL_SETUP_RESULT:if(0===t.code)this._signalInfo.clientIp=r.clientIp,this._signalInfo.signalIp=r.signalInnerIp,r.svrTime&&function(e){ER=e-(new Date).getTime();var t=new Date;t.setTime(e),sx.info("baseTime from server: ".concat(t," offset: ").concat(ER))}(r.svrTime),this._log.info("ChannelSetup Success ".concat(Vw()-this._connectStartTime)),bO.addSuccessEvent({key:521701,cost:Vw()-this._connectStartTime}),this._connectStartTime=-1,this.emit("1",{signalInfo:this._signalInfo});else{var s=new yR({code:_R.SIGNAL_CHANNEL_SETUP_FAILED,extraCode:t.code,message:mO({key:dO.SIGNAL_CHANNEL_SETUP_FAILED,data:{errorCode:t.code,errorMsg:t.message}})});this._log.error("".concat(t.code,", ").concat(t.message)),this.close(),bO.addFailedEvent({key:521701,error:s}),this.emit(lj,s)}break;case dj.JOIN_ROOM_RESULT:0===t.code&&(this._signalInfo.relayIp=r.relayOuterIp,this._signalInfo.relayInnerIp=r.relayInnerIp,this._signalInfo.bakRelayIps=r.bakRelayIps,this._signalInfo.relayPort=r.relayPort,this._signalInfo.tinyId=t.tinyId,this._signalInfo.endReportExtend=r.endReportExtend,this._log.info("signalIp:".concat(this._signalInfo.signalIp," clientIp:").concat(this._signalInfo.clientIp," relayIp: ").concat(this._signalInfo.relayIp))),this.emit(o,{data:t});break;default:this.emit(String(o),{data:t})}}}},{key:"reGetSignalChannelUrl",value:function(){return aR(this,null,f().mark((function e(){var t,n,r;return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(e.prev=0,this.room.joinParams){e.next=3;break}return e.abrupt("return");case 3:return rB(!0),e.next=6,this.room.schedule(this.room.joinParams);case 6:t=this.room.getSignalChannelUrl(),n=t.mainUrl,r=t.backupUrl,this.url=n,this.backupUrl=r,e.next=12;break;case 10:e.prev=10,e.t0=e.catch(0);case 12:case"end":return e.stop()}}),e,this,[[0,10]])})))}},{key:"startReconnection",value:function(){if(this._socketInUse){this._socketInUse.onclose=null,this._socketInUse.close(4011);var e=this._socketInUse===this._socket;this.unbindAndCloseSocket(e?nC.MAIN:nC.BACKUP),this._socketInUse=null,this.emitConnectionStateChanged("DISCONNECTED"),this.reconnect()}}},{key:"reconnect",value:function(){return aR(this,null,f().mark((function e(){var t,n,r,i,a,o,s,c,u;return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._isReconnecting){e.next=25;break}if(this.room.isJoined||!this.keepAlive){e.next=3;break}return e.abrupt("return",void this.close());case 3:return this._isReconnecting=!0,e.prev=4,this._log.warn("reconnect"),e.next=8,this.connect();case 8:return t=this.room,n=t.roomId,r=t.useStringRoomId,i=this._signalInfo,a=i.relayIp,o=i.relayInnerIp,s=i.relayPort,e.next=17,this.sendWaitForResponse({command:"reconnect",data:{roomId:n,useStringRoomId:r,relayInnerIp:o,relayOuterIp:a,relayPort:s},responseCommand:fj.CHANNEL_RECONNECT_RESULT});case 17:c=e.sent,0===(u=c.data).code?(this._log.warn("reconnect success"),this.stopReconnection(),bO.addSuccessEvent({key:521702,cost:Vw()-this._connectStartTime}),this._connectStartTime=-1,this.room.syncUserList(),this.room.checkConnectionsToReconnect()):(bO.addFailedEvent({key:521702,error:u.code}),this._log.warn("reconnect failed, ".concat(u.code," ").concat(u.message)),this.room.reJoin()),e.next=25;break;case 22:e.prev=22,e.t0=e.catch(4),this._log.error(e.t0),this.room.reJoin();case 25:case"end":return e.stop()}}),e,this,[[4,22]])})))}},{key:"send",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(this.isConnected&&!this.room.isLeft){var n={cmd:e,data:t,userId:this.userId,tinyId:this._signalInfo.tinyId,seq:++this._seq},r=JSON.stringify(n);return this._socketInUse.send(r),this.bytesSent+=$w(r),n.seq}}},{key:"sendWaitForResponse",value:function(e){var t=this,n=e.command,r=e.data,i=e.timeout,a=void 0===i?5e3:i,o=e.responseCommand,s=e.commandDesc,c=e.enableLog,u=void 0===c||c,l=e.addReceiveTime,d=void 0!==l&&l;return new Promise((function(e,i){var c=setTimeout((function(){t.off(o,l);var e=new yR({code:_R.API_CALL_TIMEOUT,message:mO({key:dO.API_CALL_TIMEOUT,data:{commandDesc:s,command:n}})});u&&t._log.warn(e),i(e)}),a),l=function(n){n.data.seq===h&&(clearTimeout(c),t.off(o,l),d&&(n.data.receiveTime=Date.now()),e(n))};t.on(o,l);var h=t.send(n,r)}))}},{key:"sendWaitForResponseWithRetry",value:function(e){var t=this,n=e.commandDesc,r=e.command,i=e.retries,a=void 0===i?0:i,o=e.retryTimeout,s=void 0===o?0:o;return dD({retryFunction:this.sendWaitForResponse,onError:function(e){var n=e.retry;t.isOnline?n():(t._log.warn("retry ".concat(r," when connected")),t.once(uj,n))},onRetrying:function(e){t._log.warn("".concat(n||r," timeout observed, retrying [").concat(e,"/").concat(a,"]"))},settings:{retries:a,timeout:s},context:this})(e)}},{key:"getCurrentState",value:function(){return this._currentState}},{key:"getSignalInfo",value:function(){return this._signalInfo}},{key:"stopReconnection",value:function(){this._isReconnecting=!1,this._stopConnectRetry&&this._stopConnectRetry()}},{key:"close",value:function(){this._log.info("closed"),clearTimeout(this.stopKeepAliveTimeout),Ej.delete(this),this.stopReconnection(),this._signalInfo={tinyId:void 0,clientIp:"",signalIp:"",relayIp:"",relayInnerIp:"",relayPort:0,bakRelayIps:[],endReportExtend:void 0},this._socketInUse=null,this.bytesSent=0,this.bytesReceived=0,this._stopConnectRetry&&this._stopConnectRetry(),this.unbindAndCloseSocket(nC.MAIN),this.unbindAndCloseSocket(nC.BACKUP),this.emitConnectionStateChanged("DISCONNECTED")}},{key:"destroy",value:function(){this.close(),this.destroyed=!0}},{key:"getBackupRelayIpPair",value:function(){var e,t=null==(e=this._signalInfo.bakRelayIps)?void 0:e.shift();return t&&(t.relayPort=t.relayPort||this._signalInfo.relayPort),t}},{key:"clearBakRelayIps",value:function(){this._signalInfo.bakRelayIps=[]}},{key:"stopKeepAliveIn",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:3600;if(this.keepAlive){this._log.info("stopKeepAlive in ".concat(t,"s")),this.stopKeepAliveTimeout=setTimeout((function(){e.keepAlive=!1,e._log.info("close due to not used ".concat(t,"s")),e.close(),e.off(fj.JOIN_ROOM_RESULT,n)}),1e3*t);var n=function(t){0===t.data.code&&(e._log.info("stopKeepAlive clear timeout"),clearTimeout(e.stopKeepAliveTimeout),e.off(fj.JOIN_ROOM_RESULT,n))};this.on(fj.JOIN_ROOM_RESULT,n)}}},{key:"emitConnectionStateChanged",value:function(e){e!==this._currentState&&(this._log.info("".concat(this._currentState," -> ").concat(e)),this.emit("2",{prevState:this._currentState,state:e}),this._currentState=e,"CONNECTED"===e?this.emit(uj):"DISCONNECTED"===e&&this.emit("6"))}}])}(cj.default);nR([GP({settings:{retries:1/0,timeout:2e3},onError:function(e,t){!this.room.isDestroyed&&!this.destroyed&&t()},onRetrying:function(e,t){this._log.warn("retrying to connect ".concat(e)),e>=3&&e%3==0&&this.reGetSignalChannelUrl(),t&&(this._stopConnectRetry=t,(this.room.isDestroyed||this.destroyed)&&t())}})],Tj.prototype,"connect",1);var kj=tR(oR()),Sj=0,Ij=!1,bj=new Set,Aj=!1,Rj=function(){return o((function e(t){r(this,e),rR(this,"userId"),rR(this,"tinyId"),rR(this,"_sdpSemantics"),rR(this,"_isUplink"),rR(this,"_room"),rR(this,"_log"),rR(this,"_signalChannel"),rR(this,"_isErrorObserved",!1),rR(this,"_waitForPeerConnectionConnectedPromise"),rR(this,"_waitForPeerConnectionConnectedPromiseReject",null),rR(this,"_peerConnection",null),rR(this,"_emitter",new kj.default),rR(this,"_currentState","DISCONNECTED"),rR(this,"_isReconnecting",!1),rR(this,"_reconnectionCount",0),rR(this,"_reconnectionTimer",-1),rR(this,"_isFirstConnection",!0),rR(this,"_prevTime",-1),rR(this,"_localAddress"),rR(this,"_remoteAddress"),this.userId=t.userId,this.tinyId=t.tinyId,this._room=t.room,this._sdpSemantics=t.room.sdpSemantics,this._isUplink=t.isUplink,this._log=sx.createLogger({id:"n-mpc",userId:this._room.userId,remoteUserId:this.userId,sdkAppId:this._room.sdkAppId,isLocal:this._isUplink}),this._signalChannel=t.signalChannel}),[{key:"beforeConnect",value:function(){this._prevTime<0&&(this._prevTime=Vw())}},{key:"afterConnect",value:function(){try{this._isFirstConnection?(this._isFirstConnection=!1,bO.addSuccessEvent({key:521705,cost:Math.min(Vw()-this._prevTime,3e4)})):this._isReconnecting&&bO.addSuccessEvent({key:521706,cost:Vw()-this._prevTime}),this._prevTime=-1}catch(mx){throw this._isFirstConnection?(this._isFirstConnection=!1,bO.addFailedEvent({key:521705,error:mx})):this._isReconnecting&&this._reconnectionCount>=3&&bO.addFailedEvent({key:521706,error:mx}),mx}}},{key:"initialize",value:function(){var e={iceServers:this._room.getIceServers(),iceTransportPolicy:this._room.getIceTransportPolicy(),sdpSemantics:this._sdpSemantics,bundlePolicy:"max-bundle",rtcpMuxPolicy:"require",tcpCandidatePolicy:"disable",IceTransportsType:"nohost"};this._peerConnection=new RTCPeerConnection(e),this._peerConnection.onconnectionstatechange=this.onConnectionStateChange.bind(this)}},{key:"close",value:function(e){this._log.info("close connection"),this._emitter.emit("closed",e),this._isReconnecting&&this.stopReconnection(),this.closePeerConnection(),bj.delete(this)}},{key:"closePeerConnection",value:function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];this._peerConnection&&(this._log.info("close pc"),this._peerConnection.onconnectionstatechange=null,this._peerConnection.close(),this._peerConnection=null,e&&this.emitConnectionStateChangedEvent("DISCONNECTED")),this._waitForPeerConnectionConnectedPromiseReject&&this._waitForPeerConnectionConnectedPromiseReject(new yR({code:_R.API_CALL_ABORTED,message:"connection closed"}))}},{key:"getDTLSTransportState",value:function(){if(!this._peerConnection)return bC;var e=null;if(this._isUplink){if(!XO()||0===this._peerConnection.getSenders().length)return bC;e=this._peerConnection.getSenders()[0].transport}else{if(!qO()||0===this._peerConnection.getReceivers().length)return bC;e=this._peerConnection.getReceivers()[0].transport}return e?e.state:bC}},{key:"onConnectionStateChange",value:function(e){var t=this._peerConnection.iceConnectionState,n=this.getDTLSTransportState();if(this._log.info("connectionState: ".concat(e.target.connectionState,", ICE: ").concat(t,", DTLS: ").concat(n)),e.target.connectionState===AC.CONNECTING&&this.emitConnectionStateChangedEvent("CONNECTING"),e.target.connectionState===AC.FAILED||e.target.connectionState===AC.CLOSED){var r="connection ".concat(e.target.connectionState,". ICE Transport state: ").concat(t,", DTLS Transport state: ").concat(n),i=new yR({message:r,code:_R.ICE_TRANSPORT_ERROR});this.emitConnectionStateChangedEvent("DISCONNECTED"),this.startReconnection(),this._isErrorObserved||this._emitter.emit("error",i)}(e.target.connectionState===AC.CONNECTED||e.target.connectionState===AC.COMPLETED)&&(this.logSelectedCandidate(),jP.logSuccessEvent({userId:this._room.userId,eventType:xC.ICE_CONNECTION_STATE}),this.emitConnectionStateChangedEvent("CONNECTED"))}},{key:"emitConnectionStateChangedEvent",value:function(e){return e!==this._currentState&&("CONNECTED"===e?(Sj=0,Ij=!1,Aj=!0,bj.add(this)):bj.delete(this),rx.emit(ax.PEER_CONNECTION_STATE_CHANGED,{room:this._room,prevState:this._currentState,state:e,remoteUserId:this._isUplink?void 0:this.userId}),this._emitter.emit("connection-state-changed",{prevState:this._currentState,state:e}),this._currentState=e,!0)}},{key:"getPeerConnection",value:function(){return this._peerConnection}},{key:"getRoom",value:function(){return this._room}},{key:"getUserId",value:function(){return this.userId}},{key:"getTinyId",value:function(){return this.tinyId}},{key:"logSelectedCandidate",value:function(){return aR(this,null,f().mark((function e(){var t,n,r,i,a,o,c;return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._peerConnection){e.next=2;break}return e.abrupt("return");case 2:return e.next=4,this._peerConnection.getStats();case 4:t=e.sent,n=s(t),e.prev=6,n.s();case 8:if((r=n.n()).done){e.next=16;break}if(i=v(r.value,2),a=i[1],!HO(a)){e.next=14;break}return o=t.get(a.localCandidateId),c=t.get(a.remoteCandidateId),o&&(this._log.info("local candidate: ".concat(o.candidateType," ").concat(o.protocol,":").concat(o.ip||o.address,":").concat(o.port," ").concat(o.networkType||""," ").concat("relay"===o.candidateType?"relayProtocol:".concat(o.relayProtocol):"")),this._localAddress="".concat(o.ip||o.address,":").concat(o.port)),c&&(this._log.info("remote candidate: ".concat(c.candidateType," ").concat(c.protocol,":").concat(c.ip||c.address,":").concat(c.port)),this._remoteAddress="".concat(c.protocol,":").concat(c.ip||c.address)),e.abrupt("break",16);case 14:e.next=8;break;case 16:e.next=21;break;case 18:e.prev=18,e.t0=e.catch(6),n.e(e.t0);case 21:return e.prev=21,n.f(),e.finish(21);case 24:case"end":return e.stop()}}),e,this,[[6,18,21,24]])})))}},{key:"getCurrentState",value:function(){return this._currentState}},{key:"waitForPeerConnectionConnected",value:function(){var e=this;return this._waitForPeerConnectionConnectedPromise||(this._waitForPeerConnectionConnectedPromise=new Promise((function(t,n){if("CONNECTED"===e._currentState)return t();e._waitForPeerConnectionConnectedPromiseReject=n;var r=function(e){"CONNECTED"===e.state&&(clearTimeout(o),a(),t())},i=function(t){t.room===e._room&&(clearTimeout(o),a(),n(new yR({code:_R.API_CALL_ABORTED,message:mO({key:dO.CONNECTION_ABORTED,data:"leave room"})})))},a=function(){rx.off(ax.LEAVE_SUCCESS,i,e),e._emitter.off("connection-state-changed",r,e)},o=setTimeout((function(){a();var t,r=new yR({code:_R.API_CALL_TIMEOUT,message:"connection timeout"});Sj+=1,t=e._signalChannel.isConnected,Sj>2&&!Ij&&0===bj.size&&t&&(e._log.warn("firewall restriction"),Ij=!0,e._emitter.emit("firewall-restriction")),n(r)}),WC);rx.on(ax.LEAVE_SUCCESS,i,e),e._emitter.on("connection-state-changed",r,e)})),this._waitForPeerConnectionConnectedPromise=this._waitForPeerConnectionConnectedPromise.finally((function(){e._waitForPeerConnectionConnectedPromise=null,e._waitForPeerConnectionConnectedPromiseReject=null}))),this._waitForPeerConnectionConnectedPromise}},{key:"getReconnectionCount",value:function(){return this._reconnectionCount}},{key:"startReconnection",value:function(){this._isReconnecting=!0,this.reconnect()}},{key:"clearReconnectionTimer",value:function(){-1!==this._reconnectionTimer&&(clearTimeout(this._reconnectionTimer),this._reconnectionTimer=-1)}},{key:"stopReconnection",value:function(){this._log.info("stop reconnection"),this._isReconnecting=!1,this._reconnectionCount=0,this.clearReconnectionTimer(),this._signalChannel.off(uj,this.reconnect,this)}},{key:"beforeReconnect",value:function(){if(-1!==this._reconnectionTimer)return this._log.warn("reconnect() is reconnecting, ignore"),-1;if(this._reconnectionCount>=wC()){this._log.warn("SDK has tried reconnect for ".concat(this._reconnectionCount," times, but all failed, please check your network")),this.stopReconnection();var e=new yR({code:this._isUplink?_R.UPLINK_RECONNECTION_FAILED:_R.DOWNLINK_RECONNECTION_FAILED,message:mO({key:this._isUplink?dO.UPLINK_RECONNECTION_FAILED:dO.DOWNLINK_RECONNECTION_FAILED})});return this.emitConnectionStateChangedEvent("DISCONNECTED"),this._emitter.emit("error",e),-1}return this._signalChannel.isConnected?(this._reconnectionCount+=1,this._log.warn("reconnect() trying [".concat(this._reconnectionCount,"]")),1):(this._log.warn("reconnect() signal channel is not connected, suspend reconnection until signal is connected"),this._signalChannel.once(uj,this.reconnect,this),-1)}},{key:"on",value:function(e,t,n){this._emitter.on(e,t,n)}},{key:"off",value:function(e,t,n){this._emitter.off(e,t,n)}},{key:"getIsReconnecting",value:function(){return this._isReconnecting}},{key:"isH264",get:function(){var e,t;return!(null==(t=null==(e=this._peerConnection)?void 0:e.remoteDescription)||!t.sdp.includes("H264"))}},{key:"setOffer",value:function(e){var t;return null==(t=this._peerConnection)?void 0:t.setLocalDescription(e)}},{key:"setAnswer",value:function(e){var t;return null==(t=this._peerConnection)?void 0:t.setRemoteDescription(e)}}])}();nR([gL(521712,!1)],Rj.prototype,"setOffer",1),nR([gL(521713,!1)],Rj.prototype,"setAnswer",1);var Cj=tR(pR()),wj=function(e){return Cj.default.parse(e)},Dj=function(e){return Cj.default.write(e)};function Nj(e){return Object.keys(e).filter((function(t){return e[t]}))}var xj=function(e){function i(e){var a;return r(this,i),a=n(this,i,[$A(QA({},e),{isUplink:!1})]),rR(t(a),"_flag",0),rR(t(a),"isRobot",!1),rR(t(a),"role","anchor"),rR(t(a),"remoteAudioTrack"),rR(t(a),"remoteVideoTrack"),rR(t(a),"remoteAuxiliaryTrack"),rR(t(a),"ssrc",{audio:0,video:0,auxiliary:0}),rR(t(a),"_isSDPExchanging",!1),a.flag=e.flag,a.isRobot=e.isRobot||!1,a.remoteAudioTrack=e.remoteAudioTrack||new XU(a._room,t(a)),a.remoteVideoTrack=e.remoteVideoTrack||new pF(a._room,t(a)),a.remoteAuxiliaryTrack=e.remoteAuxiliaryTrack||new mF(a._room,t(a)),a}return d(i,e),o(i,[{key:"videoCodec",get:function(){var e,t,n=null==(t=null==(e=this._peerConnection)?void 0:e.remoteDescription)?void 0:t.sdp;return n?n.includes("H264")?"h264":"vp8":"h264"}},{key:"subscribeState",get:function(){var e={audio:!1,video:!1,auxiliary:!1,smallVideo:!1};return this.remoteVideoTrack.isSubscribed&&(8&this.remoteVideoTrack.mediaType?e.smallVideo=!0:e.video=!0),this.remoteAudioTrack.isSubscribed&&(e.audio=!0),this.remoteAuxiliaryTrack.isSubscribed&&(e.auxiliary=!0),e}},{key:"muteState",get:function(){return Hw(this.flag,this.userId)}},{key:"flag",get:function(){return this._flag},set:function(e){var t,n,r;e!==this._flag&&(this._flag=e,null==(t=this.remoteAudioTrack)||t.onFlagChanged(),null==(n=this.remoteVideoTrack)||n.onFlagChanged(),null==(r=this.remoteAuxiliaryTrack)||r.onFlagChanged())}},{key:"hasMainStream",get:function(){return this.muteState.hasAudio||this.muteState.hasVideo||this.muteState.hasSmall}},{key:"hasAuxStream",get:function(){return this.muteState.hasAuxiliary}},{key:"isMainStreamSubscribed",get:function(){return(this.subscribeState.audio||this.subscribeState.video||this.subscribeState.smallVideo)&&(this.muteState.hasAudio||this.muteState.hasVideo||this.muteState.hasSmall)}},{key:"isAuxStreamSubscribed",get:function(){return this.subscribeState.auxiliary&&this.muteState.hasAuxiliary}},{key:"isSmallStreamSubscribed",get:function(){return this.subscribeState.smallVideo&&this.muteState.hasSmall}},{key:"isBigStreamSubscribed",get:function(){return this.subscribeState.video&&this.muteState.hasVideo}},{key:"isStreamUnpublished",value:function(e){return e===nC.MAIN?!this.muteState.hasAudio&&!this.muteState.hasVideo:!this.muteState.hasAuxiliary}},{key:"initialize",value:function(){g(i,"initialize",this,3)([]),this.installEvents(),this._peerConnection.ontrack=this.onTrack.bind(this)}},{key:"close",value:function(e){g(i,"close",this,3)([e]),this.emitConnectionStateChangedEvent("DISCONNECTED"),this.remoteAudioTrack.close(),this.remoteVideoTrack.close(),this.remoteAuxiliaryTrack.close(),this.uninstallEvents()}},{key:"installEvents",value:function(){}},{key:"uninstallEvents",value:function(){this._emitter.removeAllListeners()}},{key:"emitConnectionStateChangedEvent",value:function(e){var t,n,r=this._currentState,a=g(i,"emitConnectionStateChangedEvent",this,3)([e]);return a&&r!==e&&(null==(t=this.remoteVideoTrack)||t.emit("connection-state-changed",{prevState:r,state:e}),null==(n=this.remoteAuxiliaryTrack)||n.emit("connection-state-changed",{prevState:r,state:e})),a}},{key:"onTrack",value:function(e){var t=e.streams[0],n=e.track,r=t.id===pC?nC.MAIN:nC.AUXILIARY;this._log.debug("ontrack ".concat(r," ").concat(n.kind));var i=nC.AUDIO;n.kind===nC.VIDEO&&(i=r===nC.MAIN?nC.VIDEO:nC.AUXILIARY);var a=this.remoteAudioTrack;i===nC.VIDEO?a=this.remoteVideoTrack:i===nC.AUXILIARY&&(a=this.remoteAuxiliaryTrack),a.setInputMediaStreamTrack(n)}},{key:"addRRTRLine",value:function(e){var t=e.split("\r\n"),n=new Map;t.forEach((function(e,r){/^a=rtcp-fb:/.test(e)&&t[r+1]&&!/^a=rtcp-fb:/.test(t[r+1])&&n.set(r+1,"".concat(e.match(/^a=rtcp-fb:\d+/)[0]," rrtr"))}));for(var r=E(n),i=0;i<r.length;i++){var a=v(r[i],2),o=a[0],s=a[1];t.splice(o+i,0,s)}return t.join("\r\n")}},{key:"addSPSDescription",value:function(e){var t=wj(e);return t.media.forEach((function(e){e.type===nC.VIDEO&&e.fmtp.forEach((function(e){e.config+=";sps-pps-idr-in-keyframe=1"}))})),Dj(t)}},{key:"removeSDESDescription",value:function(e){var t=["urn:ietf:params:rtp-hdrext:sdes:mid","urn:ietf:params:rtp-hdrext:sdes:rtp-stream-id","urn:ietf:params:rtp-hdrext:sdes:repaired-rtp-stream-id"],n=wj(e);return n.media.forEach((function(e){e.ext&&(e.ext=e.ext.filter((function(e){return!t.includes(e.uri)})))})),Dj(n)}},{key:"isSubscriptionStateNotChanged",value:function(e){return JSON.stringify(e)===JSON.stringify(this.subscribeState)}},{key:"subscribe",value:function(e,t){return aR(this,null,f().mark((function n(){var r,i,a;return f().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(n.prev=0,n.t0=(null==(r=this._peerConnection)?void 0:r.connectionState)===AC.NEW||(null==(i=this._peerConnection)?void 0:i.connectionState)===AC.CONNECTING,!n.t0){n.next=5;break}return n.next=5,this.waitForPeerConnectionConnected();case 5:if(!this.isSubscriptionStateNotChanged(e)){n.next=13;break}if(n.t1=this._peerConnection,n.t1){n.next=12;break}return this.initialize(),n.next=11,this.connect(e);case 11:n.t1=n.sent;case 12:return n.abrupt("return",void n.t1);case 13:if(this._log.info("subscribe ".concat(t," ").concat(JSON.stringify(e))),!this._peerConnection&&!this._isSDPExchanging){n.next=20;break}return a="subscribe_change",Object.values(e).find((function(e){return!0===e}))||(a="unsubscribe"),n.next=18,this.sendSubscription(a,e);case 18:n.next=23;break;case 20:return this.initialize(),n.next=23,this.connect(e);case 23:n.next=28;break;case 25:throw n.prev=25,n.t2=n.catch(0),this._room.isJoined&&this.isStreamUnpublished(t)?(this._log.warn("".concat(n.t2.message," ").concat(JSON.stringify(this.muteState))),new yR({code:_R.REMOTE_STREAM_NOT_EXIST,message:"remote user ".concat(this.userId," unpublished stream")})):n.t2;case 28:case"end":return n.stop()}}),n,this,[[0,25]])})))}},{key:"unsubscribe",value:function(e){return aR(this,arguments,(function(e){var t=this,n=e.remoteTracks,r=e.streamType;return f().mark((function e(){var i,a;return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if("CONNECTED"!==t._currentState||("main"!==r||t.isMainStreamSubscribed)&&("auxiliary"!==r||t.isAuxStreamSubscribed)){e.next=2;break}return e.abrupt("return",void t._log.info("".concat(r," stream already unsubscribed")));case 2:return i=QA({},t.subscribeState),n.forEach((function(e){switch(e.mediaType){case 1:i.audio=!1;break;case 4:i.video=!1;break;case 8:i.smallVideo=!1;break;case 2:i.auxiliary=!1}})),a="subscribe_change",Object.values(i).find((function(e){return!0===e}))||(a="unsubscribe"),t._log.info("".concat("unsubscribe"===a?a:"subscribe"," ").concat(r," [").concat(Nj(i),"]")),e.next=9,t.sendSubscription(a,i);case 9:"unsubscribe"===a&&(t.closePeerConnection(),t.emitConnectionStateChangedEvent("DISCONNECTED"));case 10:case"end":return e.stop()}}),e)}))()}))}},{key:"sendSubscription",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.subscribeState,r={srcTinyId:this.tinyId,srcUserId:this.userId},i=_j,a=fj.UNSUBSCRIBE_RESULT;return"subscribe_change"===e&&(r={audio:n.audio,bigVideo:n.video,auxVideo:n.auxiliary,smallVideo:n.smallVideo,srcTinyId:this.tinyId},i=gj,a=fj.SUBSCRIBE_CHANGE_RESULT),this._signalChannel.sendWaitForResponse({command:i,data:r,responseCommand:a,timeout:1e4}).then((function(n){var r=n.data;if(0!==r.code){var i=new yR({code:r.code,message:mO({key:dO.ERROR_MESSAGE,data:{type:e,message:r.message}})});throw t._log.error(i),i}}))}},{key:"connect",value:function(){return aR(this,arguments,(function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.subscribeState;return f().mark((function n(){return f().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.prev=0,n.next=3,e.exchangeSDP(t);case 3:return n.next=5,e.waitForPeerConnectionConnected();case 5:n.next=10;break;case 7:throw n.prev=7,n.t0=n.catch(0),e.closePeerConnection(!0),n.t0;case 10:case"end":return n.stop()}}),n,null,[[0,7]])}))()}))}},{key:"exchangeSDP",value:function(e){return aR(this,null,f().mark((function t(){var n,r,i,a,o,s;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"),n=this._peerConnection.localDescription,r=n.type,i=n.sdp,a={type:r,sdp:i,srcUserId:this.userId,srcTinyId:this.tinyId,audio:e.audio,bigVideo:e.video,auxVideo:e.auxiliary,smallVideo:e.smallVideo},t.next=11,this._signalChannel.sendWaitForResponse({command:"subscribe",commandDesc:"exchange sdp",data:a,responseCommand:fj.SUBSCRIBE_RESULT,timeout:MC});case 11:if(o=t.sent,this._peerConnection){t.next=15;break}throw s=new yR({code:_R.INVALID_OPERATION,message:mO({key:dO.CONNECTION_CLOSED})}),this._log.warn(s),s;case 15:return t.next=17,this.onSubscribeResult(o);case 17:this._isSDPExchanging=!1,t.next=23;break;case 20:throw t.prev=20,t.t0=t.catch(0),this._isSDPExchanging=!1,t.t0;case 23:case"end":return t.stop()}}),t,this,[[0,20]])})))}},{key:"createOffer",value:function(){return aR(this,null,f().mark((function e(){var t,n;return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t={voiceActivityDetection:!1},$O()&&this._sdpSemantics===LC?(this._peerConnection.addTransceiver(nC.AUDIO,{direction:rC.RECVONLY}),this._peerConnection.addTransceiver(nC.VIDEO,{direction:rC.RECVONLY}),this._peerConnection.addTransceiver(nC.VIDEO,{direction:rC.RECVONLY})):(t.offerToReceiveAudio=!0,t.offerToReceiveVideo=!0),e.next=4,this._peerConnection.createOffer(t);case 4:if(!(n=e.sent).sdp){e.next=11;break}return e.next=8,LO();case 8:e.sent.isH264DecodeSupported||(this._log.warn("remove h264 desc from sdp"),n.sdp=function(e){var t=wj(e);return t.media.forEach((function(e){var t,n;if(e.type===nC.VIDEO){var r=new Set;e.rtp.forEach((function(e){var t=e.payload;return"H264"===e.codec&&r.add(t)})),e.fmtp.forEach((function(e){var t=e.payload,n=e.config.match(/apt=(\d+)/);n&&n[1]&&r.has(Number(n[1]))&&r.add(t)}));var i=function(e){var t=e.payload;return!r.has(t)};e.rtp=e.rtp.filter(i),e.rtcpFb=null==(t=e.rtcpFb)?void 0:t.filter(i),e.fmtp=e.fmtp.filter(i),e.payloads=null==(n=e.payloads)?void 0:n.split(" ").filter((function(e){return!r.has(Number(e))})).join(" ")}})),Dj(t)}(n.sdp)),n.sdp=this.addRRTRLine(n.sdp),n.sdp=this.addSPSDescription(n.sdp),n.sdp=function(e){var t=wj(e);return t.media.forEach((function(e){e.type===nC.AUDIO&&e.fmtp.forEach((function(e){e.config+=";sprop-stereo=1;stereo=1"}))})),Dj(t)}(n.sdp),this._sdpSemantics===LC&&(n.sdp=this.removeSDESDescription(n.sdp));case 11:return e.next=13,this.setOffer(n);case 13:case"end":return e.stop()}}),e,this)})))}},{key:"onSubscribeResult",value:function(e){return aR(this,null,f().mark((function t(){var n,r,i,a,o,s,c;return f().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=e&&e.data||{},r=n.code,i=n.message,a=void 0===i?"":i,o=e&&e.data&&e.data.data||{},s=o.type,c=o.sdp,r!==UC){t.next=3;break}throw new yR({code:_R.NOT_SUPPORTED_H264,message:mO({key:dO.NOT_SUPPORTED_H264DECODE})});case 3:if(t.prev=3,0===r){t.next=6;break}throw new yR({code:r,message:mO({key:dO.EXCHANGE_SDP_FAILED,data:{errMsg:a}})});case 6:return this._log.debug("accept remote answer: ".concat(c)),t.next=9,this.setAnswer({type:s,sdp:c});case 9:this.updateSSRC(c),t.next=15;break;case 12:throw t.prev=12,t.t0=t.catch(3),this._log.error(t.t0),t.t0;case 15:case"end":return t.stop()}}),t,this,[[3,12]])})))}},{key:"updateSSRC",value:function(e){var t=this;try{wj(e).media.forEach((function(e){if(e.ssrcs)if(e.type===nC.AUDIO){var n=e.ssrcs.find((function(e){var t;return null==(t=e.value)?void 0:t.includes(pC)}));n&&(t.ssrc.audio=Number(n.id))}else{var r=e.ssrcs.find((function(e){var t;return null==(t=e.value)?void 0:t.includes(pC)})),i=e.ssrcs.find((function(e){var t;return null==(t=e.value)?void 0:t.includes(mC)}));r&&(t.ssrc.video=Number(r.id)),i&&(t.ssrc.auxiliary=Number(i.id))}}))}catch(DC){}}},{key:"getMainStreamVideoTrackId",value:function(){return this.remoteVideoTrack&&this.remoteVideoTrack.mediaTrack?this.remoteVideoTrack.mediaTrack.id:""}},{key:"getAuxStreamVideoTrackId",value:function(){return this.remoteAuxiliaryTrack&&this.remoteAuxiliaryTrack.mediaTrack?this.remoteAuxiliaryTrack.mediaTrack.id:""}},{key:"reconnect",value:function(){return aR(this,null,f().mark((function e(){var t,n=this;return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(iR(i.prototype,this,"beforeReconnect").call(this)<0){e.next=14;break}return e.prev=1,this.closePeerConnection(),this.initialize(),e.next=6,this.connect();case 6:this.stopReconnection(),this._log.warn("reconnect() success"),e.next=14;break;case 10:e.prev=10,e.t0=e.catch(1),t=Tw(this._reconnectionCount),this._log.warn("reconnect() timeout, try again after ".concat(t/1e3,"s")),this._reconnectionTimer=setTimeout((function(){n.clearReconnectionTimer(),n.reconnect()}),t);case 14:case"end":return e.stop()}}),e,this,[[1,10]])})))}},{key:"getIsReconnecting",value:function(){return this._isReconnecting}},{key:"clearReconnectionTimer",value:function(){-1!==this._reconnectionTimer&&(clearTimeout(this._reconnectionTimer),this._reconnectionTimer=-1)}},{key:"getCurrentState",value:function(){return this._currentState}},{key:"setDelay",value:function(e){var t=e.audioDelay,n=e.videoDelay;this.remoteAudioTrack.stat.end2EndDelay=t,this.remoteVideoTrack.stat.end2EndDelay=n}},{key:"audioReceiver",get:function(){var e;return(null==(e=this._peerConnection)?void 0:e.getReceivers()[0])||null}}])}(Rj);nR([uL((function(e){return function(){for(var t=this,n=arguments.length,r=new Array(n),i=0;i<n;i++)r[i]=arguments[i];return new Promise((function(n,i){var a=function(e){t._emitter.off("closed",a),i(new yR({code:_R.API_CALL_ABORTED,message:mO({key:dO.CONNECTION_ABORTED,data:e})}))};t._emitter.on("closed",a),e.apply(t,r).then(n,i).finally((function(){t._emitter.off("closed",a)}))}))}}))],xj.prototype,"subscribe",1),nR([gL(521717,!1)],xj.prototype,"unsubscribe",1),nR([sL(Rj.prototype.afterConnect),oL(Rj.prototype.beforeConnect)],xj.prototype,"connect",1);var Oj=xj,Pj={voiceActivityDetection:!1},Mj=function(e){function i(e){var a;return r(this,i),a=n(this,i,[$A(QA({},e),{isUplink:!0})]),rR(t(a),"localMainAudioTrack",null),rR(t(a),"localMainVideoTrack",null),rR(t(a),"localAuxAudioTrack",null),rR(t(a),"localAuxVideoTrack",null),rR(t(a),"ssrc",{audio:0,video:0,small:0,auxiliary:0}),rR(t(a),"_isPublishingAux",!1),rR(t(a),"_publishingLocalAudioTrack"),rR(t(a),"_publishingLocalVideoTrack"),rR(t(a),"_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}),rR(t(a),"flag",0),a}return d(i,e),o(i,[{key:"videoCodec",get:function(){return this._mediaSettings.videoCodec.toLowerCase()||"h264"}},{key:"isMainStreamPublished",get:function(){return!(!this.localMainAudioTrack&&!this.localMainVideoTrack)}},{key:"isAuxStreamPublished",get:function(){return!(!this.localAuxVideoTrack&&!this.localAuxAudioTrack)}},{key:"publishState",get:function(){var e,t,n,r,i=this,a={audio:!1,bigVideo:!1,smallVideo:!1,auxVideo:!1};if(this._peerConnection){var o=this._peerConnection.getSenders();o&&(QO()?(a.audio=!(null==(e=o[0])||!e.track),a.bigVideo=!(null==(t=o[1])||!t.track),a.smallVideo=!(null==(n=o[2])||!n.track),a.auxVideo=!(null==(r=o[3])||!r.track)):o.forEach((function(e){e.track&&(e.track.kind===nC.AUDIO?a.audio=!0:(a.bigVideo=!0,i._room.videoManager.hasSmall&&(a.smallVideo=!0)))})))}return a}},{key:"initialize",value:function(){g(i,"initialize",this,3)([]),this.installEvents()}},{key:"reset",value:function(){this._isReconnecting&&this.stopReconnection(),this.closePeerConnection(),this.uninstallEvents()}},{key:"close",value:function(e){g(i,"close",this,3)([e]),this.reset(),this.emitConnectionStateChangedEvent("DISCONNECTED")}},{key:"installEvents",value:function(){this._emitter.listeners("connection-state-changed").includes(this.handleConnectionStateChange)||this._emitter.on("connection-state-changed",this.handleConnectionStateChange,this)}},{key:"uninstallEvents",value:function(){this._emitter.off("connection-state-changed",this.handleConnectionStateChange,this)}},{key:"emitConnectionStateChangedEvent",value:function(e,t){var n,r,a,o=this._currentState,s=g(i,"emitConnectionStateChangedEvent",this,3)([e]);return s&&o!==e&&(t?t.emit("connection-state-changed",{prevState:o,state:e}):(null==(n=this.localMainVideoTrack)||n.emit("connection-state-changed",{prevState:o,state:e}),null==(r=this.localAuxVideoTrack)||r.emit("connection-state-changed",{prevState:o,state:e}),null==(a=this._publishingLocalVideoTrack)||a.emit("connection-state-changed",{prevState:o,state:e}))),s}},{key:"publish",value:function(e){return aR(this,arguments,(function(e){var t=this,n=e.localAudioTrack,r=e.localVideoTrack,i=e.isAuxiliary;return f().mark((function e(){var a;return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t._peerConnection||t.initialize(),n&&(t._publishingLocalAudioTrack=n),r&&(t._publishingLocalVideoTrack=r),t._isPublishingAux=i,r&&!i&&r.small&&(a=t._room.videoManager.smallTrack),t.sendMediaSettings(),!$O()){e.next=11;break}return e.next=9,t.publishByTransceiver({localAudioTrack:n,localVideoTrack:r,smallTrack:a,isAuxiliary:i});case 9:e.next=13;break;case 11:return e.next=13,t.publishByAddTrack({localAudioTrack:n,localVideoTrack:r,smallTrack:a});case 13:t._publishingLocalAudioTrack=null,t._publishingLocalVideoTrack=null,t._isPublishingAux=!1,i?(r&&(t.localAuxVideoTrack=r),n&&(t.localAuxAudioTrack=n)):(r&&(t.localMainVideoTrack=r),n&&(t.localMainAudioTrack=n)),t.installTrackMuteEvents(n,r),t.sendMutedFlag();case 19:case"end":return e.stop()}}),e)}))()}))}},{key:"publishByTransceiver",value:function(e){return aR(this,arguments,(function(e){var t=this,n=e.localAudioTrack,r=e.localVideoTrack,i=e.smallTrack,a=e.isAuxiliary;return f().mark((function e(){var o,s,c,u,l,d;return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t._log.info("publish by transceiver"),o=new MediaStream,s=null==r?void 0:r.outMediaTrack,(c=null==n?void 0:n.outMediaTrack)&&o.addTrack(c),s&&o.addTrack(s),0!==(u=t._peerConnection.getTransceivers()).length){e.next=13;break}return t._peerConnection.addTransceiver(c||nC.AUDIO,{direction:rC.SENDONLY,streams:[o]}),t._peerConnection.addTransceiver(a?nC.VIDEO:s||nC.VIDEO,{direction:rC.SENDONLY,streams:[o]}),t._peerConnection.addTransceiver(i||nC.VIDEO,{direction:rC.SENDONLY,streams:[o]}),t._peerConnection.addTransceiver(a&&s||nC.VIDEO,{direction:rC.SENDONLY,streams:[o]}),e.next=11,t.connect();case 11:e.next=41;break;case 13:if(l=[],e.t0=c,!e.t0){e.next=21;break}return u[0].sender.track||l.push(0),e.next=19,u[0].sender.replaceTrack(c);case 19:return e.next=21,t.setBandwidth({bandwidth:(null==n?void 0:n.profile.bitrate)||40,type:nC.AUDIO});case 21:if(!s){e.next=35;break}return d=a?3:1,e.next=25,u[d].sender.replaceTrack(s);case 25:return e.next=27,t.setBandwidth({bandwidth:r.profile.bitrate,type:nC.VIDEO,videoType:a?nC.AUXILIARY:nC.BIG});case 27:if(l.push(d),e.t1=i,!e.t1){e.next=35;break}return e.next=32,u[2].sender.replaceTrack(i);case 32:return e.next=34,t.setBandwidth({bandwidth:r.small.bitrate,type:nC.VIDEO,videoType:nC.SMALL});case 34:l.push(2);case 35:return e.next=37,t.setTransceiverDirection(rC.SENDONLY,l);case 37:return e.next=39,t.doPublishChange();case 39:null==r||r.emit("connection-state-changed",{prevState:"DISCONNECTED",state:"CONNECTING"}),null==r||r.emit("connection-state-changed",{prevState:"CONNECTING",state:"CONNECTED"});case 41:case"end":return e.stop()}}),e)}))()}))}},{key:"publishByAddTrack",value:function(e){return aR(this,arguments,(function(e){var t=this,n=e.localAudioTrack,r=e.localVideoTrack,i=e.smallTrack;return f().mark((function e(){var a,o,s,c;return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t._log.info("publish by addtrack"),a=null==r?void 0:r.outMediaTrack,o=null==n?void 0:n.outMediaTrack,!t._peerConnection||"new"===t._peerConnection.connectionState){e.next=13;break}if(e.t0=n&&o,!e.t0){e.next=7;break}return e.next=7,t.addTrack(n);case 7:if(e.t1=a,!e.t1){e.next=12;break}return e.next=11,t.addTrack(r);case 11:e.t1=e.sent;case 12:return e.abrupt("return",void e.t1);case 13:return s=new MediaStream,o&&s.addTrack(o),a&&s.addTrack(a),o&&t._peerConnection.addTrack(o,s),a&&(t._peerConnection.addTrack(a,s),i)&&((c=new MediaStream).addTrack(i),t._peerConnection.addTrack(i,c)),e.next=17,t.connect();case 17:case"end":return e.stop()}}),e)}))()}))}},{key:"enableSmall",value:function(e){return aR(this,null,f().mark((function t(){var n;return f().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=this._peerConnection.getTransceivers(),!e){t.next=10;break}if(t.t0=this._room.videoManager.smallTrack,!t.t0){t.next=8;break}return t.next=6,n[2].sender.replaceTrack(this._room.videoManager.smallTrack);case 6:return t.next=8,this.setTransceiverDirection(rC.SENDONLY,[2]);case 8:t.next=14;break;case 10:return t.next=12,n[2].sender.replaceTrack(null);case 12:return t.next=14,this.setTransceiverDirection(rC.INACTIVE,[2]);case 14:return this.updateMediaSettings(),t.next=17,this.doPublishChange();case 17:case"end":return t.stop()}}),t,this)})))}},{key:"installTrackMuteEvents",value:function(){for(var e=this,t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];n.forEach((function(t){t&&(null==t||t.on("mute",e.sendMutedFlag,e),null==t||t.on("unmute",e.sendMutedFlag,e))}))}},{key:"uninstallTrackMuteEvents",value:function(){for(var e=this,t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];n.forEach((function(t){t&&(null==t||t.off("mute",e.sendMutedFlag,e),null==t||t.off("unmute",e.sendMutedFlag,e))}))}},{key:"unpublish",value:function(e){return aR(this,arguments,(function(e){var t=this,n=e.localAudioTrack,r=e.localVideoTrack;return f().mark((function e(){var i,a,o,s;return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(QO()){e.next=19;break}if(!n||!n.outMediaTrack||r||!t.localMainVideoTrack){e.next=7;break}return e.next=4,t.removeTrack(n);case 4:e.t0=void(t.localMainAudioTrack=null),e.next=18;break;case 7:if(!r||!r.outMediaTrack||n||!t.localMainAudioTrack){e.next=13;break}return e.next=10,t.removeTrack(r);case 10:e.t1=void(t.localMainVideoTrack=null),e.next=17;break;case 13:return e.next=15,t.doUnpublish();case 15:t.uninstallTrackMuteEvents(n,r),e.t1=void t.emitConnectionStateChangedEvent("DISCONNECTED",r);case 17:e.t0=e.t1;case 18:return e.abrupt("return",e.t0);case 19:if(i=r&&r===t.localAuxVideoTrack,a=null==r?void 0:r.outMediaTrack,o=t._peerConnection.getSenders(),s=[],e.t2=n,!e.t2){e.next=28;break}if(i?t.localAuxAudioTrack=null:t.localMainAudioTrack=null,e.t3=!t.localAuxAudioTrack&&!t.localMainAudioTrack,!e.t3){e.next=28;break}return e.next=27,o[0].replaceTrack(null);case 27:s.push(0);case 28:if(e.t4=a,!e.t4){e.next=45;break}if(!i){e.next=38;break}return e.next=33,o[3].replaceTrack(null);case 33:t.localAuxVideoTrack=null,t._mediaSettings=$A(QA({},t._mediaSettings),{auxVideoBps:0,auxVideoFps:0,auxVideoWidth:0,auxVideoHeight:0}),s.push(3),e.next=45;break;case 38:return e.next=40,o[1].replaceTrack(null);case 40:return e.next=42,o[2].replaceTrack(null);case 42:t.localMainVideoTrack=null,t._mediaSettings=$A(QA({},t._mediaSettings),{videoWidth:0,videoHeight:0,videoBps:0,videoFps:0,audioFs:0,audioChannel:0,audioBps:0,smallVideoWidth:0,smallVideoHeight:0,smallVideoFps:0,smallVideoBps:0}),s.push(1,2);case 45:if(!t.isMainStreamPublished&&!t.isAuxStreamPublished){e.next=52;break}return e.next=48,t.setTransceiverDirection(rC.INACTIVE,s);case 48:return e.next=50,t.doPublishChange(!1);case 50:e.next=54;break;case 52:return e.next=54,t.doUnpublish();case 54:t.uninstallTrackMuteEvents(n,r),null==r||r.emit("connection-state-changed",{prevState:t._currentState,state:"DISCONNECTED"});case 56:case"end":return e.stop()}}),e)}))()}))}},{key:"doPublishChange",value:function(){var e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];return aR(this,null,f().mark((function t(){var n,r;return f().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n={state:this.publishState,constraintConfig:this._mediaSettings},t.next=3,this._signalChannel.sendWaitForResponse({command:mj,data:n,responseCommand:fj.PUBLISH_STATE_CHANGE_RESULT,enableLog:e});case 3:r=t.sent,this.checkPublishResultCode(r.data.code,r.data.message);case 5:case"end":return t.stop()}}),t,this)})))}},{key:"doUnpublish",value:function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return this._signalChannel.sendWaitForResponse({command:vj,commandDesc:"unpublish",responseCommand:fj.UNPUBLISH_RESULT,enableLog:e}).catch((function(e){if(e.getCode()===_R.API_CALL_TIMEOUT)return Promise.resolve();throw e}))}},{key:"updateMediaSettings",value:function(){var e=this._room.checkSystemResult.detail,t=e.isH264EncodeSupported,n=e.isVp8EncodeSupported;t?this._mediaSettings.videoCodec="H264":n&&(this._mediaSettings.videoCodec="VP8");var r=this._publishingLocalAudioTrack||this.localMainAudioTrack||this.localAuxAudioTrack,i=this.localMainVideoTrack,a=this.localAuxVideoTrack;if(this._publishingLocalVideoTrack&&(this._isPublishingAux?a=this._publishingLocalVideoTrack:i=this._publishingLocalVideoTrack),aP){if(r&&r.outMediaTrack){var o=r.outMediaTrack.getSettings();this._mediaSettings.audioChannel=o.channelCount||1,this._mediaSettings.audioBps=1e3*r.profile.bitrate,this._mediaSettings.audioFs=o.sampleRate||0}if(i&&i.outMediaTrack){var s=i.outMediaTrack.getSettings();this._mediaSettings.videoWidth=s.width||0,this._mediaSettings.videoHeight=s.height||0,this._mediaSettings.videoFps=s.frameRate||0,this._mediaSettings.videoBps=1e3*i.profile.bitrate,i.small&&(this._mediaSettings.smallVideoWidth=i.small.width,this._mediaSettings.smallVideoHeight=i.small.height,this._mediaSettings.smallVideoFps=i.small.frameRate,this._mediaSettings.smallVideoBps=1e3*i.small.bitrate)}if(a&&a.outMediaTrack){var c=a.outMediaTrack.getSettings();this._mediaSettings.auxVideoWidth=c.width||0,this._mediaSettings.auxVideoHeight=c.height||0,this._mediaSettings.auxVideoFps=c.frameRate||0,this._mediaSettings.auxVideoBps=1e3*a.profile.bitrate}}else r&&r.outMediaTrack&&(this._mediaSettings.audioChannel=r.profile.channelCount,this._mediaSettings.audioBps=1e3*r.profile.bitrate,this._mediaSettings.audioFs=r.profile.sampleRate),i&&i.outMediaTrack&&(this._mediaSettings.videoWidth=i.profile.width,this._mediaSettings.videoHeight=i.profile.height,this._mediaSettings.videoFps=i.profile.frameRate,this._mediaSettings.videoBps=1e3*i.profile.bitrate);this._log.info("updateMediaSettings: ".concat(JSON.stringify(this._mediaSettings)))}},{key:"sendMediaSettings",value:function(){var e=this;this.updateMediaSettings(),this._signalChannel.sendWaitForResponse({command:yj,data:this._mediaSettings,responseCommand:fj.UPDATE_CONSTRAINT_CONFIG_RES}).then((function(t){0!==t.data.code&&e._log.warn(t.data.message)})).catch((function(){}))}},{key:"addTrack",value:function(e){return aR(this,null,f().mark((function t(){var n;return f().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(n=e===this.localAuxAudioTrack||e===this.localAuxVideoTrack,this._log.info("is adding ".concat(e.kind," track to current published local ").concat(n?nC.AUXILIARY:nC.MAIN," stream")),!$O()){t.next=9;break}return t.next=7,this.addTrackByTransceiver(e,n);case 7:t.next=11;break;case 9:return t.next=11,this.addTrackBySender(e);case 11:case"end":return t.stop()}}),t,this)})))}},{key:"addTrackByTransceiver",value:function(e,t){return aR(this,null,f().mark((function n(){var r,i,a;return f().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(e.mediaTrack){n.next=2;break}return n.abrupt("return");case 2:if(i=this._peerConnection.getTransceivers(),e.kind!==nC.AUDIO){n.next=8;break}return n.next=6,i[0].sender.replaceTrack(e.outMediaTrack);case 6:n.next=19;break;case 8:return a=t?3:1,n.next=11,i[a].sender.replaceTrack(e.outMediaTrack);case 11:if(n.t0=1===a&&null!=(r=this.localMainVideoTrack)&&r.small,!n.t0){n.next=15;break}return n.next=15,i[2].sender.replaceTrack(this._room.videoManager.smallTrack);case 15:if(n.t1=i[a].direction===rC.INACTIVE,!n.t1){n.next=19;break}return n.next=19,this.setTransceiverDirection(rC.SENDONLY,[a]);case 19:return this.updateMediaSettings(),n.next=22,this.doPublishChange();case 22:case"end":return n.stop()}}),n,this)})))}},{key:"addTrackBySender",value:function(e){return aR(this,null,f().mark((function t(){var n,r,i,a,o;return f().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(e.outMediaTrack){t.next=2;break}return t.abrupt("return");case 2:if(n=e.outMediaTrack,t.t0=QO()&&this._peerConnection.getTransceivers().findIndex((function(e){return"stopped"===e.direction}))>=0,!t.t0){t.next=8;break}return this._log.warn("transceiver is stopping, negotiate sdp first"),t.next=8,this.updateOffer("remove",n);case 8:if(r=this._peerConnection.getSenders().find((function(e){return e.track&&e.track.kind===n.kind})),!r||!r.track){t.next=15;break}return this._log.warn("sender already exists, remove sender first"),i=r.track,this.removeSender(r),t.next=15,this.updateOffer("remove",i);case 15:return n&&this._peerConnection.addTrack(n,new MediaStream([n])),n.kind===nC.VIDEO&&e instanceof AL&&e.small&&(a=new MediaStream,o=this._room.videoManager.smallTrack,a.addTrack(o),this._peerConnection.addTrack(o,a)),t.next=18,this.updateOffer("add",n);case 18:case"end":return t.stop()}}),t,this)})))}},{key:"isNeedToResetOfferOrder",value:function(){if(this._sdpSemantics===VC||!this._peerConnection||!this._peerConnection.localDescription)return!1;for(var e=this._peerConnection.localDescription.sdp,t=wj(e),n=0;n<t.media.length;n++)if(0===Number(t.media[n].mid)&&t.media[n].type===nC.VIDEO)return!0;return!1}},{key:"removeSender",value:function(e){var t=null;QO()&&(t=this._peerConnection.getTransceivers().find((function(t){return t.sender&&t.sender.track===e.track}))),this._peerConnection.removeTrack(e),t&&Sw(t.stop)&&(this._log.info("stop transceiver"),t.stop())}},{key:"removeTrack",value:function(e){return aR(this,null,f().mark((function t(){var n;return f().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(n=e===this.localAuxAudioTrack||e===this.localAuxVideoTrack,this._log.info("is removing ".concat(e.kind," track from current published local ").concat(n?nC.AUXILIARY:nC.MAIN," stream")),!$O()){t.next=9;break}return t.next=7,this.removeTrackByTransceiver(e,n);case 7:t.next=11;break;case 9:return t.next=11,this.removeTrackBySender(e);case 11:case"end":return t.stop()}}),t,this)})))}},{key:"removeTrackByTransceiver",value:function(e,t){return aR(this,null,f().mark((function n(){var r,i;return f().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(e.outMediaTrack){n.next=2;break}return n.abrupt("return");case 2:if(r=this._peerConnection.getTransceivers(),e.kind!==nC.AUDIO){n.next=8;break}return n.next=6,r[0].sender.replaceTrack(null);case 6:n.next=17;break;case 8:return i=t?3:1,n.next=11,r[i].sender.replaceTrack(null);case 11:if(n.t0=1===i&&e.small,!n.t0){n.next=15;break}return n.next=15,r[2].sender.replaceTrack(null);case 15:return n.next=17,this.setTransceiverDirection(rC.INACTIVE,[i]);case 17:return this.updateMediaSettings(),n.next=20,this.doPublishChange();case 20:case"end":return n.stop()}}),n,this)})))}},{key:"setTransceiverDirection",value:function(e,t){return aR(this,null,f().mark((function n(){var r,i,a,o,s,c;return f().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(wD){n.next=2;break}return n.abrupt("return");case 2:if(r=!1,i=!1,this._log.info("setting transceiver ".concat(t.join(",")," direction to ").concat(e)),a=this._peerConnection.getTransceivers(),t.forEach((function(t){a[t].direction!==e&&(a[t].direction=e,r=!0)})),!r){n.next=12;break}return this._log.info("updating offer"),n.next=9,this._peerConnection.createOffer();case 9:return o=n.sent,n.next=12,this.setOffer(o);case 12:if(s=-1,c=this._peerConnection.remoteDescription.sdp.split("\r\n").map((function(n){if(n.match(new RegExp("a=(".concat(rC.INACTIVE,"|").concat(rC.RECVONLY,"|").concat(rC.SENDONLY,")")))&&s++,t.includes(s)){if(e===rC.INACTIVE&&n.includes("a=".concat(rC.RECVONLY)))return i=!0,"a=".concat(e);if(e===rC.SENDONLY&&n.includes("a=".concat(rC.INACTIVE)))return i=!0,"a=".concat(rC.RECVONLY)}return n})).join("\r\n"),n.t0=i,!n.t0){n.next=18;break}return this._log.info("updating answer"),n.next=18,this.setAnswer({type:"answer",sdp:c});case 18:case"end":return n.stop()}}),n,this)})))}},{key:"removeTrackBySender",value:function(e){return aR(this,null,f().mark((function t(){var n,r=this;return f().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(e.outMediaTrack){t.next=2;break}return t.abrupt("return");case 2:if(e.kind!==nC.VIDEO||!this.isNeedToResetOfferOrder()||!this.localMainAudioTrack){t.next=8;break}return this.reset(),this.initialize(),t.next=7,this.publish({localAudioTrack:this.localMainAudioTrack,isAuxiliary:!1});case 7:return t.abrupt("return",void t.sent);case 8:return(n=this._peerConnection.getSenders().find((function(t){return t.track===e.outMediaTrack})))&&(this.removeSender(n),e.kind===nC.VIDEO&&e.small&&this._peerConnection.getSenders().forEach((function(e){e.track&&e.track.kind===nC.VIDEO&&r.removeSender(e)}))),t.next=12,this.updateOffer("remove",e.outMediaTrack);case 12:case"end":return t.stop()}}),t,this)})))}},{key:"replaceTrack",value:function(e){return aR(this,null,f().mark((function t(){var n,r,i,a;return f().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if((i=null==(n=this._peerConnection)?void 0:n.getSenders())&&0!==i.length&&e.mediaTrack){t.next=3;break}return t.abrupt("return",!1);case 3:if(r=$O()?e.kind===nC.AUDIO?i[0]:i[1]:i.find((function(t){return t.track&&t.track.kind===e.kind})),r){t.next=5;break}return t.abrupt("return",!1);case 5:if(a=e===this.localAuxAudioTrack||e===this.localAuxVideoTrack,this._log.info("is replacing ".concat(e.kind," track on ").concat(a?nC.AUXILIARY:nC.MAIN," stream")),e.kind!==nC.AUDIO){t.next=12;break}return t.next=10,r.replaceTrack(e.outMediaTrack);case 10:case 19:t.next=23;break;case 12:if(t.t0=e.kind===nC.VIDEO,!t.t0){t.next=23;break}if(!a){t.next=21;break}if(t.t1=i[3],!t.t1){t.next=19;break}return t.next=19,i[3].replaceTrack(e.outMediaTrack);case 21:return t.next=23,r.replaceTrack(e.outMediaTrack);case 23:return t.abrupt("return",!0);case 24:case"end":return t.stop()}}),t,this)})))}},{key:"updateOffer",value:function(e,t){return aR(this,null,f().mark((function n(){var r,i,a,o,s,c,u;return f().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.prev=0,n.next=3,this._peerConnection.createOffer(Pj);case 3:return r=n.sent,wD&&r.sdp&&(r.sdp=this.setSDPDirection(r.sdp,"sendrecv")),n.next=7,this.setOffer(r);case 7:return i=this.updateMediaSettings(),a={action:e,trackId:t.id,kind:t.kind===nC.VIDEO?"bigVideo":t.kind,type:"offer",sdp:this._peerConnection.localDescription.sdp,constraintConfig:i,state:this.publishState},this._log.info("createOffer success, sending updated offer to remote server"),this._log.debug("updatedOffer: ".concat(a.sdp)),n.next=11,this._signalChannel.sendWaitForResponse({command:"publish_change",data:a,responseCommand:fj.UPDATE_OFFER_RESULT,timeout:PC,commandDesc:"update offer"});case 11:return o=n.sent,s=o.data,c=s.code,u=s.message,0!==c&&this.checkPublishResultCode(c,u),n.next=18,this.acceptAnswer(o.data.data);case 18:r.sdp&&this.updateSSRC(r.sdp),n.next=24;break;case 21:throw n.prev=21,n.t0=n.catch(0),this._log.error(n.t0),n.t0;case 24:case"end":return n.stop()}}),n,this,[[0,21]])})))}},{key:"setBandwidth",value:function(e){return aR(this,arguments,(function(e){var t=this,n=e.bandwidth,r=e.type,i=e.videoType,a=e.sdp;return f().mark((function e(){var o,s,c,u;return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(rP()){e.next=2;break}return e.abrupt("return",a?r===nC.VIDEO?t.updateVideoBandwidthRestriction(a,n,i):t.updateAudioBandwidthRestriction(a,n):void 0);case 2:if(s=t._peerConnection.getSenders(),$O()?(c=0,r===nC.VIDEO&&(c=i===nC.SMALL?2:i===nC.AUXILIARY?3:1),o=s[c]):o=s.find((function(e){return e.track&&e.track.kind===r})),!o){e.next=18;break}return(!(u=o.getParameters()).encodings||0===u.encodings.length)&&(u.encodings=[{}]),u.encodings[0].maxBitrate=1e3*n,e.prev=7,e.next=10,o.setParameters(u);case 10:return t._log.info("".concat(i||"").concat(r," bandwidth ").concat(n," kbps")),e.abrupt("return",a);case 14:if(e.prev=14,e.t0=e.catch(7),t._log.info("failed to set bandwidth by setting maxBitrate: ".concat(e.t0)),!a){e.next=18;break}return e.abrupt("return",r===nC.VIDEO?t.updateVideoBandwidthRestriction(a,n,i):t.updateAudioBandwidthRestriction(a,n));case 18:return e.abrupt("return",a);case 19:case"end":return e.stop()}}),e,null,[[7,14]])}))()}))}},{key:"updateVideoBandwidthRestriction",value:function(e,t,n){var r="AS";wD&&(r="TIAS",t*=1e3);var i=0,a=-1;return n===nC.SMALL?i=1:n===nC.AUXILIARY&&(i=2),e.replace(/m=video (.*)\r\nc=IN (.*)\r\n/g,(function(e){return(a+=1)===i?"".concat(e,"b=").concat(r,":").concat(t,"\r\n"):e}))}},{key:"updateAudioBandwidthRestriction",value:function(e,t){var n="AS";return wD&&(n="TIAS",t*=1e3),e.replace(/m=audio (.*)\r\nc=IN (.*)\r\n/,"m=audio $1\r\nc=IN $2\r\nb=".concat(n,":").concat(t,"\r\n"))}},{key:"removeBandwidthRestriction",value:function(e){return e.replace(/b=AS:.*\r\n/,"").replace(/b=TIAS:.*\r\n/,"")}},{key:"removeVideoOrientation",value:function(e){return e.replace(/urn:3gpp:video-orientation/,"")}},{key:"connect",value:function(){return aR(this,null,f().mark((function e(){return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,this.exchangeSDP();case 3:return e.next=5,this.waitForPeerConnectionConnected();case 5:e.next=10;break;case 7:throw e.prev=7,e.t0=e.catch(0),this.closePeerConnection(!0),this.uninstallEvents(),e.t0;case 10:case"end":return e.stop()}}),e,this,[[0,7]])})))}},{key:"exchangeSDP",value:function(){return aR(this,null,f().mark((function e(){return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,this.createOffer();case 3:return this._log.info("createOffer success, sending offer to remote server"),e.next=6,this.doExchangeSDP();case 6:e.next=11;break;case 8:throw e.prev=8,e.t0=e.catch(0),e.t0;case 11:case"end":return e.stop()}}),e,this,[[0,8]])})))}},{key:"createOffer",value:function(){return aR(this,null,f().mark((function e(){var t;return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,this._peerConnection.createOffer(Pj);case 3:return t=e.sent,e.next=6,this.setOffer(t);case 6:t.sdp&&this.updateSSRC(t.sdp),e.next=12;break;case 9:throw e.prev=9,e.t0=e.catch(0),e.t0;case 12:case"end":return e.stop()}}),e,this,[[0,9]])})))}},{key:"doExchangeSDP",value:function(){var e=this,t={command:"publish",responseCommand:fj.PUBLISH_RESULT,data:{type:this._peerConnection.localDescription.type,sdp:this.removeVideoOrientation(this._peerConnection.localDescription.sdp),screen:this.localMainVideoTrack instanceof wL||this.localAuxVideoTrack instanceof wL,state:this.publishState,constraintConfig:this._mediaSettings},enableLog:!1};return this._log.debug("sending sdp offer: ".concat(t.data.sdp)),this._signalChannel.sendWaitForResponse(t).then((function(t){var n=t.data,r=n.code,i=n.message,a=n.data;return 0===r?e.acceptAnswer(a):e.checkPublishResultCode(r,i)}))}},{key:"setSDPDirection",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"all",r=wj(e);return r.media.forEach((function(e){("all"===n||e.type===n)&&(e.direction=t)})),Dj(r)}},{key:"acceptAnswer",value:function(e){return aR(this,null,f().mark((function t(){var n,r,i,a,o,s,c,u,l,d,h;return f().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(t.prev=0,!(this._publishingLocalAudioTrack||this._publishingLocalVideoTrack||this.isMainStreamPublished)){t.next=13;break}if(c=(null==(n=this._publishingLocalVideoTrack)?void 0:n.profile.bitrate)||(null==(r=this.localMainVideoTrack)?void 0:r.profile.bitrate),u=(null==(i=this._publishingLocalAudioTrack)?void 0:i.profile.bitrate)||(null==(a=this.localMainAudioTrack)?void 0:a.profile.bitrate),!c){t.next=8;break}return l=this._isPublishingAux?nC.AUXILIARY:nC.BIG,t.next=7,this.setBandwidth({bandwidth:c,type:nC.VIDEO,sdp:s,videoType:l});case 7:s=t.sent;case 8:if(t.t0=u,!t.t0){t.next=13;break}return t.next=12,this.setBandwidth({bandwidth:u,type:nC.AUDIO,sdp:s});case 12:s=t.sent;case 13:if(s=this.removeVideoOrientation(e.sdp),null==(o=this._publishingLocalVideoTrack)||!o.small){t.next=18;break}return d=this._room.smallStreamConfig,t.next=17,this.setBandwidth({bandwidth:this._publishingLocalVideoTrack.small.bitrate||d.bitrate,type:nC.VIDEO,videoType:nC.SMALL,sdp:s});case 17:s=t.sent;case 18:return h={type:e.type,sdp:s},t.next=21,this.setAnswer(h);case 21:this._log.debug("accepted answer: ".concat(s)),t.next=27;break;case 24:throw t.prev=24,t.t1=t.catch(0),this._log.error("failed to accept remote answer ".concat(t.t1)),t.t1;case 27:case"end":return t.stop()}}),t,this,[[0,24]])})))}},{key:"sendMutedFlag",value:function(e){var t,n,r;if(e!==this.localAuxAudioTrack&&e!==this.localAuxVideoTrack){var i={audio:!(null==(t=this.localMainAudioTrack)||!t.muted),bigVideo:!(null==(n=this.localMainVideoTrack)||!n.muted),auxVideo:!(null==(r=this.localAuxVideoTrack)||!r.muted)};this._log.info("send muted state: ".concat(JSON.stringify(i))),this._signalChannel.send(pj,i)}}},{key:"getIsReconnecting",value:function(){return this._isReconnecting}},{key:"reconnect",value:function(){return aR(this,null,f().mark((function e(){var t,n=this;return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(iR(i.prototype,this,"beforeReconnect").call(this)<0){e.next=22;break}return e.prev=1,e.next=4,this._signalChannel.sendWaitForResponse({command:vj,responseCommand:fj.UNPUBLISH_RESULT,enableLog:!1});case 4:if(this.closePeerConnection(),this.initialize(),e.t0=this.isMainStreamPublished,!e.t0){e.next=10;break}return e.next=10,this.publish({localAudioTrack:this.localMainAudioTrack,localVideoTrack:this.localMainVideoTrack,isAuxiliary:!1});case 10:if(e.t1=this.isAuxStreamPublished,!e.t1){e.next=14;break}return e.next=14,this.publish({localAudioTrack:this.localAuxAudioTrack,localVideoTrack:this.localAuxVideoTrack,isAuxiliary:!0});case 14:this._log.warn("reconnect() uplink reconnect successfully"),this.stopReconnection(),e.next=22;break;case 18:e.prev=18,e.t2=e.catch(1),t=Tw(this._reconnectionCount),this._log.warn("reconnect() timeout, try again after ".concat(t/1e3,"s")),this._reconnectionTimer=setTimeout((function(){n.clearReconnectionTimer(),n.reconnect()}),t);case 22:case"end":return e.stop()}}),e,this,[[1,18]])})))}},{key:"handleConnectionStateChange",value:function(e){"CONNECTED"===e.state&&(this.localMainVideoTrack||this._publishingLocalVideoTrack&&!this._isPublishingAux)&&rx.emit(ax.SEND_FIRST_VIDEO_FRAME,{room:this._room})}},{key:"updateSSRC",value:function(e){var t=this;try{wj(e).media.forEach((function(e,n){if(e.type===nC.AUDIO){var r=e.ssrcs&&e.ssrcs[0];r&&(t.ssrc.audio=Number(r.id))}else{if(t._sdpSemantics===VC&&e.ssrcGroups)return void e.ssrcGroups.forEach((function(e,n){var r=Number(e.ssrcs.split(" ")[0]);0===n?t.ssrc.video=r:1===n&&(t.ssrc.small=r)}));var i=e.ssrcs&&e.ssrcs[0];if(!i)return;switch(n){case 1:t.ssrc.video=Number(i.id);break;case 2:t.ssrc.small=Number(i.id);break;case 3:t.ssrc.auxiliary=Number(i.id)}}}))}catch(DC){}}},{key:"getVideoTrackId",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:nC.VIDEO;if(this._peerConnection){var t=this._peerConnection.getSenders();if(e===nC.AUXILIARY&&t[3]&&t[3].track)return t[3].track.id;if(e===nC.VIDEO&&t[1]&&t[1].track)return t[1].track.id}if(this.localMainVideoTrack&&e===nC.VIDEO){var n=this.localMainVideoTrack.mediaTrack;if(n)return n.id}if(this.localAuxVideoTrack&&e===nC.AUXILIARY){var r=this.localAuxVideoTrack.mediaTrack;if(r)return r.id}return""}},{key:"getSSRC",value:function(){return this.ssrc}},{key:"checkPublishResultCode",value:function(e,t){if(0!==e)throw e===UC?(this._log.error(hO.NOT_SUPPORTED_H264ENCODE),new yR({code:_R.NOT_SUPPORTED_H264,message:mO({key:dO.NOT_SUPPORTED_H264ENCODE})})):new yR({code:_R.UNKNOWN,message:mO({key:dO.SIGNAL_RESPONSE_FAILED,data:{signalResponse:fj.PUBLISH_RESULT,code:e,message:t}})})}}])}(Rj);nR([uL((function(e){return function(){for(var t=this,n=arguments.length,r=new Array(n),i=0;i<n;i++)r[i]=arguments[i];return new Promise((function(n,i){var a=function(e){t._emitter.off("closed",a),i(new yR({code:_R.API_CALL_ABORTED,message:mO({key:dO.CONNECTION_ABORTED,data:e})}))};t._emitter.on("closed",a),e.apply(t,r).then(n,i).finally((function(){t._emitter.off("closed",a)}))}))}}))],Mj.prototype,"publish",1),nR([gL(521715,!1)],Mj.prototype,"unpublish",1),nR([sL(Rj.prototype.afterConnect),oL(Rj.prototype.beforeConnect)],Mj.prototype,"connect",1);var Lj=Mj,Vj=function(){return o((function e(t,n){r(this,e),this.room=t,rR(this,"_log"),rR(this,"_prevReportTime",0),rR(this,"_prevReport",{}),rR(this,"_prevStats",null),rR(this,"_prevEncoderImplementation",""),rR(this,"_prevAuxEncoderImpl",""),rR(this,"_prevQualityLimitationReason",""),rR(this,"_prevAuxQualityLimitationReason",""),rR(this,"_prevDecoderImplementationMap",new Map),rR(this,"totalBytesSent",0),rR(this,"totalBytesReceived",0),rR(this,"_spcStats",null),this._log=n}),[{key:"statInterval",get:function(){return 0===this._prevReportTime?2:(Date.now()-this._prevReportTime)/1e3}},{key:"getSenderStats",value:function(e){return aR(this,null,f().mark((function t(){var n,r,i,a,o,s=this;return f().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(r={audio:{bytesSent:0,packetsSent:0,audioLevel:0,totalAudioEnergy:0},video:{bytesSent:0,packetsSent:0,framesEncoded:0,frameWidth:0,frameHeight:0,framesSent:0,fpsCapture:0},small:{bytesSent:0,packetsSent:0,framesEncoded:0,frameWidth:0,frameHeight:0,framesSent:0,fpsCapture:0},auxiliary:{bytesSent:0,packetsSent:0,framesEncoded:0,frameWidth:0,frameHeight:0,framesSent:0,fpsCapture:0},rtt:0},i=e.getPeerConnection(),a=e.getSSRC(),!i){t.next=18;break}if(t.prev=2,t.t0=this._spcStats,t.t0){t.next=8;break}return t.next=7,i.getStats();case 7:t.t0=t.sent;case 8:if(t.t0.forEach((function(t){var n,i,o,c;if("outbound-rtp"===t.type)if((t.mediaType||t.kind)===nC.VIDEO){if(t.ssrc===a.video?(c=nC.VIDEO,e.localMainVideoTrack):t.ssrc===a.small?c=nC.SMALL:t.ssrc===a.auxiliary&&(e.localAuxVideoTrack,c=nC.AUXILIARY),!c)return;if(r[c].bytesSent=t.bytesSent,r[c].packetsSent=t.packetsSent,r[c].framesEncoded=t.framesEncoded,Iw(t.keyFramesEncoded)||(r[c].keyFramesEncoded=t.keyFramesEncoded),Iw(t.nackCount)||(r[c].nackCount=t.nackCount),Iw(t.pliCount)||(r[c].pliCount=t.pliCount),Iw(t.retransmittedPacketsSent)||(r[c].retransmittedPacketsSent=t.retransmittedPacketsSent),Iw(t.totalEncodeTime)||(r[c].totalEncodeTime=t.totalEncodeTime),Iw(t.totalPacketSendDelay)||(r[c].totalPacketSendDelay=t.totalPacketSendDelay),!Iw(t.encoderImplementation)&&(c===nC.VIDEO&&s._prevEncoderImplementation!==t.encoderImplementation||c===nC.AUXILIARY&&s._prevAuxEncoderImpl!==t.encoderImplementation)){var u=2,l=s._prevEncoderImplementation;c===nC.AUXILIARY&&(u=7,l=s._prevAuxEncoderImpl),rx.emit("262",{userId:e.userId,streamType:u,prevImplementation:l,implementation:t.encoderImplementation,codec:e.videoCodec,isHWCodec:t.powerEfficientEncoder}),s[c===nC.VIDEO?"_prevEncoderImplementation":"_prevAuxEncoderImpl"]=t.encoderImplementation,s._log.info("".concat(c===nC.AUXILIARY?"aux ":"","encoderImplementation change to ").concat(t.encoderImplementation,"(").concat(e.videoCodec,") HWEncoder: ").concat(t.powerEfficientEncoder))}t.ssrc===a.video?!Iw(t.qualityLimitationReason)&&0!==t.bytesSent&&s._prevQualityLimitationReason!==t.qualityLimitationReason&&(s._log.info("qualityLimitationReason change to ".concat(t.qualityLimitationReason)),rx.emit("263",{userId:e.userId,reason:t.qualityLimitationReason,prevReason:s._prevQualityLimitationReason,streamType:2,isQosClearFirst:null==(n=e.localMainVideoTrack)?void 0:n.isQosClearFirst}),s._prevQualityLimitationReason=t.qualityLimitationReason):t.ssrc===a.auxiliary&&!Iw(t.qualityLimitationReason)&&0!==t.bytesSent&&s._prevAuxQualityLimitationReason!==t.qualityLimitationReason&&(s._log.info("aux qualityLimitationReason change to ".concat(t.qualityLimitationReason)),rx.emit("263",{userId:e.userId,reason:t.qualityLimitationReason,prevReason:s._prevAuxQualityLimitationReason,streamType:7,isQosClearFirst:null==(i=e.localAuxVideoTrack)?void 0:i.isQosClearFirst}),s._prevAuxQualityLimitationReason=t.qualityLimitationReason)}else r.audio.bytesSent=t.bytesSent,r.audio.packetsSent=t.packetsSent;else"candidate-pair"===t.type?HO(t)&&(s.totalBytesSent=t.bytesSent,Aw(t.currentRoundTripTime)&&(r.rtt=Math.floor(1e3*t.currentRoundTripTime))):"media-source"===t.type&&(t.kind===nC.AUDIO?(r.audio.audioLevel=t.audioLevel||0,r.audio.totalAudioEnergy=t.totalAudioEnergy||0,t.echoReturnLoss,t.totalSamplesDuration&&(r.audio.totalSamplesDuration=t.totalSamplesDuration)):t.kind===nC.VIDEO&&(t.trackIdentifier===e.getVideoTrackId(nC.VIDEO)?r.video.fpsCapture=t.framesPerSecond:t.trackIdentifier===e.getVideoTrackId(nC.AUXILIARY)?r.auxiliary.fpsCapture=t.framesPerSecond:r.small.fpsCapture=t.framesPerSecond));if(!Iw(t.audioLevel)&&null!=(o=e.localMainAudioTrack)&&o.mediaTrack&&t.trackIdentifier===e.localMainAudioTrack.mediaTrack.id&&(r.audio.audioLevel=t.audioLevel||0),!Iw(t.frameWidth)){var d=nC.SMALL;t.trackIdentifier===e.getVideoTrackId(nC.VIDEO)||t.ssrc===a.video?d=nC.VIDEO:(t.trackIdentifier===e.getVideoTrackId(nC.AUXILIARY)||t.ssrc===a.auxiliary)&&(d=nC.AUXILIARY),r[d].frameWidth=t.frameWidth,r[d].frameHeight=t.frameHeight,r[d].framesSent=t.framesSent}})),!e.localMainAudioTrack){t.next=12;break}o=e.localMainAudioTrack.getInternalAudioLevel(),r.audio.micAudioLevel=o,0===r.audio.audioLevel&&(r.audio.audioLevel=o);case 12:this.totalBytesSent||(this.totalBytesSent+=r.audio.bytesSent+r.video.bytesSent+r.auxiliary.bytesSent),Object.keys(r).forEach((function(t){t===nC.AUDIO?(e.localMainAudioTrack&&(e.localMainAudioTrack.stat=r[t]),e.localAuxAudioTrack&&(e.localAuxAudioTrack.stat=r[t])):t===nC.VIDEO?e.localMainVideoTrack&&(e.localMainVideoTrack.stat=r[t]):t===nC.AUXILIARY&&e.localAuxVideoTrack&&(e.localAuxVideoTrack.stat=r[t])})),t.next=18;break;case 15:t.prev=15,t.t1=t.catch(2),this._log.warn("failed to getStats on sender connection ".concat(t.t1));case 18:return t.abrupt("return",(0===r.rtt&&(r.rtt=(null==(n=this.room.networkQuality)?void 0:n.uplinkRTT)||0),r));case 19:case"end":return t.stop()}}),t,this,[[2,15]])})))}},{key:"getReceiverStats",value:function(e){return aR(this,null,f().mark((function t(){var n,r,i,a,o,s,c,u,l=this;return f().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(a={tinyId:e.tinyId,userId:e.userId,rtt:0,hasAudio:!1,hasVideo:!1,hasAuxiliary:!1,isSmallSubscribed:!1,audio:{bytesReceived:0,packetsReceived:0,packetsLost:0,p2pDelay:0,totalJitter:0,totalJitterCount:0,audioLevel:0,totalAudioEnergy:0,insertedSamplesForDeceleration:0,removedSamplesForAcceleration:0},video:{bytesReceived:0,packetsReceived:0,packetsLost:0,framesReceived:0,framesDecoded:0,frameWidth:0,frameHeight:0,fpsDecoded:0,freezeCount:0,totalFreezesDuration:0,totalJitter:0,totalJitterCount:0},auxiliary:{bytesReceived:0,packetsReceived:0,packetsLost:0,framesReceived:0,framesDecoded:0,frameWidth:0,frameHeight:0,fpsDecoded:0,totalJitter:0,totalJitterCount:0}},!(o=e.getPeerConnection())){t.next=19;break}if(t.prev=2,s=e.ssrc,c=e.muteState,u=e.subscribeState,t.t0=this._spcStats,t.t0){t.next=9;break}return t.next=8,o.getStats();case 8:t.t0=t.sent;case 9:t.t0.forEach((function(t){if("inbound-rtp"===t.type){var n=(t.mediaType||t.kind)===nC.AUDIO;if(n){if(t.ssrc!==s.audio||!c.hasAudio)return;a.audio.packetsReceived=t.packetsReceived,a.audio.bytesReceived=t.bytesReceived,a.audio.packetsLost=t.packetsLost,t.insertedSamplesForDeceleration&&(a.audio.insertedSamplesForDeceleration=t.insertedSamplesForDeceleration),t.removedSamplesForAcceleration&&(a.audio.removedSamplesForAcceleration=t.removedSamplesForAcceleration),t.totalSamplesDuration&&(a.audio.totalSamplesDuration=t.totalSamplesDuration),t.totalSamplesReceived&&(a.audio.totalSamplesReceived=t.totalSamplesReceived),t.concealedSamples&&(a.audio.concealedSamples=t.concealedSamples);var r=e.remoteAudioTrack;r.stat.packetsReceived=t.packetsReceived,r.stat.bytesReceived=t.bytesReceived,r.stat.packetsLost=t.packetsLost,a.audio.p2pDelay=r.stat.end2EndDelay,a.hasAudio=!0}else{if(wD&&0===t.bytesReceived)return;var i;t.ssrc===s.video&&c.hasVideo&&(a.video.packetsReceived=t.packetsReceived,a.video.bytesReceived=t.bytesReceived,a.video.packetsLost=t.packetsLost,a.video.framesReceived=t.framesReceived,a.video.framesDecoded=t.framesDecoded,a.video.fpsDecoded=t.framesPerSecond,a.hasVideo=!0,i=e.remoteVideoTrack,c.hasSmall&&u.smallVideo&&(a.isSmallSubscribed=!0),t.decoderImplementation&&(!l._prevDecoderImplementationMap.has(a.userId)||l._prevDecoderImplementationMap.get(a.userId)!==t.decoderImplementation)&&(l._log.info("".concat(a.userId," decoderImplementation change to ").concat(t.decoderImplementation," HWDecoder: ").concat(t.powerEfficientDecoder)),rx.emit("262",{userId:l.room.userId,remoteUserId:a.userId,prevImplementation:l._prevDecoderImplementationMap.get(a.userId),implementation:t.decoderImplementation,codec:e.videoCodec,isHWCodec:t.powerEfficientDecoder}),l._prevDecoderImplementationMap.set(a.userId,t.decoderImplementation))),t.ssrc===s.auxiliary&&c.hasAuxiliary&&(a.auxiliary.packetsReceived=t.packetsReceived,a.auxiliary.bytesReceived=t.bytesReceived,a.auxiliary.packetsLost=t.packetsLost,a.auxiliary.framesReceived=t.framesReceived,a.auxiliary.framesDecoded=t.framesDecoded,a.auxiliary.fpsDecoded=t.framesPerSecond,i=e.remoteAuxiliaryTrack,a.hasAuxiliary=!0),i&&(i.stat.packetsReceived=t.packetsReceived,i.stat.bytesReceived=t.bytesReceived,i.stat.packetsLost=t.packetsLost,i.stat.framesReceived=t.framesReceived,i.stat.framesDecoded=t.framesDecoded,t.jitterBufferDelay&&(i.stat.jitterBufferDelay=Math.floor(t.jitterBufferDelay/t.jitterBufferEmittedCount*1e3)))}t.jitterBufferDelay&&(n?(a.audio.totalJitter=t.jitterBufferDelay,a.audio.totalJitterCount=t.jitterBufferEmittedCount):t.ssrc===s.video&&c.hasVideo?(a.video.totalJitter=t.jitterBufferDelay,a.video.totalJitterCount=t.jitterBufferEmittedCount):t.ssrc===s.auxiliary&&c.hasAuxiliary&&(a.auxiliary.totalJitter=t.jitterBufferDelay,a.auxiliary.totalJitterCount=t.jitterBufferEmittedCount))}else"candidate-pair"===t.type&&HO(t)&&(l.totalBytesReceived=t.bytesReceived,Aw(t.currentRoundTripTime)&&(a.rtt=Math.floor(1e3*t.currentRoundTripTime)));Iw(t.frameWidth)||((t.trackIdentifier===e.getMainStreamVideoTrackId()||t.ssrc===s.video)&&(a.video.frameWidth=t.frameWidth,a.video.frameHeight=t.frameHeight,e.remoteVideoTrack.stat.frameWidth=t.frameWidth,e.remoteVideoTrack.stat.frameHeight=t.frameHeight),(t.trackIdentifier===e.getAuxStreamVideoTrackId()||t.ssrc===s.auxiliary)&&(a.auxiliary.frameWidth=t.frameWidth,a.auxiliary.frameHeight=t.frameHeight,e.remoteAuxiliaryTrack.stat.frameWidth=t.frameWidth,e.remoteAuxiliaryTrack.stat.frameHeight=t.frameHeight)),!Iw(t.audioLevel)&&e.muteState.audioAvailable&&e.remoteAudioTrack.mediaTrack&&t.trackIdentifier===e.remoteAudioTrack.mediaTrack.id&&(a.audio.audioLevel=t.audioLevel||0,a.audio.totalAudioEnergy=t.totalAudioEnergy||0)})),0===a.audio.audioLevel&&e.muteState.audioAvailable&&(a.audio.audioLevel=e.remoteAudioTrack.getInternalAudioLevel()||0),this.totalBytesReceived||(this.totalBytesReceived+=a.audio.bytesReceived+a.video.bytesReceived+a.auxiliary.bytesReceived),Iw(null==(n=e.remoteVideoTrack.player.stat)?void 0:n.fps)||(a.video.fpsRender=e.remoteVideoTrack.player.stat.fps),Iw(null==(r=e.remoteAuxiliaryTrack.player.stat)?void 0:r.fps)||(a.auxiliary.fpsRender=e.remoteAuxiliaryTrack.player.stat.fps),t.next=19;break;case 16:t.prev=16,t.t1=t.catch(2),this._log.warn("failed to getStats on receiver connection ".concat(t.t1));case 19:return t.abrupt("return",(0===a.rtt&&(a.rtt=(null==(i=this.room.networkQuality)?void 0:i.uplinkRTT)||0),a));case 20:case"end":return t.stop()}}),t,this,[[2,16]])})))}},{key:"getStats",value:function(e,t){return aR(this,null,f().mark((function n(){var r,i,a,o,c,u,l,d,h,p,m,_,g;return f().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(r={},i=[],!this.room.singlePC){n.next=13;break}if(a=this.room.singlePC.getPeerConnection()){n.next=5;break}return n.abrupt("return",{senderStats:r,receiverStats:i});case 5:return o=Vw(),n.next=8,a.getStats();case 8:c=n.sent,(u=Vw())-o>2e3&&this._log.warn("getStats cost ".concat(u-o,"ms")),l=[],d=new Set(["inbound-rtp","outbound-rtp","track","candidate-pair","media-source"]),c.forEach((function(e){return d.has(e.type)&&l.push(e)})),this._spcStats=l;case 13:if(n.t0=e,!n.t0){n.next=18;break}return n.next=17,this.getSenderStats(e);case 17:r=n.sent;case 18:h=s(t),n.prev=19,h.s();case 21:if((p=h.n()).done){n.next=29;break}return(m=v(p.value,2))[0],_=m[1],n.next=25,this.getReceiverStats(_);case 25:g=n.sent,i.push(g);case 27:n.next=21;break;case 29:n.next=34;break;case 31:n.prev=31,n.t1=n.catch(19),h.e(n.t1);case 34:return n.prev=34,h.f(),n.finish(34);case 37:return n.abrupt("return",{senderStats:r,receiverStats:i});case 38:case"end":return n.stop()}}),n,this,[[19,31,34,37]])})))}},{key:"getDifferenceValue",value:function(e,t){if(eL(e))return t;var n=t-e;return n<0?0:n}},{key:"prepareReport",value:function(e){var t,n=this,r=e.stats,i=e.report,a=e.freezeMap;if(!eL(r.senderStats)){var o={uint32_audio_level:r.senderStats.audio.audioLevel*tO,uint32_audio_energy:1e6*(r.senderStats.audio.totalAudioEnergy||0),uint32_audio_codec_bitrate:r.senderStats.audio.bytesSent};r.senderStats.audio.micAudioLevel&&(o.uint32_mic_audio_level=r.senderStats.audio.micAudioLevel*tO),r.senderStats.audio.totalSamplesDuration&&(i.msg_device_info.uint32_audio_capture_cost=r.senderStats.audio.totalSamplesDuration);var s=[];if(r.senderStats.video.bytesSent){var c={uint32_video_stream_type:2,uint32_video_codec_fps:r.senderStats.video.framesSent,uint32_video_capture_fps:r.senderStats.video.fpsCapture,uint32_video_width:r.senderStats.video.frameWidth,uint32_video_height:r.senderStats.video.frameHeight,uint32_video_codec_bitrate:r.senderStats.video.bytesSent,uint32_video_enc_fps:r.senderStats.video.framesEncoded,uint32_key_frame_count:r.senderStats.video.keyFramesEncoded,uint32_nack_count:r.senderStats.video.nackCount,uint32_pli_count:r.senderStats.video.pliCount,uint32_encode_cost:1e3*(r.senderStats.video.totalEncodeTime||0),uint32_send_packet_cost:1e3*(r.senderStats.video.totalPacketSendDelay||0),uint32_video_arq_packets:r.senderStats.video.retransmittedPacketsSent};s.push(c)}if(r.senderStats.small.bytesSent){var u={uint32_video_stream_type:3,uint32_video_codec_fps:r.senderStats.small.framesSent||0,uint32_video_capture_fps:r.senderStats.small.fpsCapture||0,uint32_video_width:r.senderStats.small.frameWidth||0,uint32_video_height:r.senderStats.small.frameHeight||0,uint32_video_codec_bitrate:r.senderStats.small.bytesSent,uint32_video_enc_fps:r.senderStats.small.framesEncoded||0,uint32_key_frame_count:r.senderStats.small.keyFramesEncoded,uint32_nack_count:r.senderStats.small.nackCount,uint32_pli_count:r.senderStats.small.pliCount,uint32_encode_cost:1e3*(r.senderStats.small.totalEncodeTime||0),uint32_send_packet_cost:1e3*(r.senderStats.small.totalPacketSendDelay||0),uint32_video_arq_packets:r.senderStats.small.retransmittedPacketsSent};s.push(u)}if(r.senderStats.auxiliary.bytesSent){var l={uint32_video_stream_type:7,uint32_video_codec_fps:r.senderStats.auxiliary.framesSent||0,uint32_video_capture_fps:r.senderStats.auxiliary.fpsCapture||0,uint32_video_width:r.senderStats.auxiliary.frameWidth||0,uint32_video_height:r.senderStats.auxiliary.frameHeight||0,uint32_video_codec_bitrate:r.senderStats.auxiliary.bytesSent,uint32_video_enc_fps:r.senderStats.auxiliary.framesEncoded||0,uint32_key_frame_count:r.senderStats.auxiliary.keyFramesEncoded,uint32_nack_count:r.senderStats.auxiliary.nackCount,uint32_pli_count:r.senderStats.auxiliary.pliCount,uint32_encode_cost:1e3*(r.senderStats.auxiliary.totalEncodeTime||0),uint32_send_packet_cost:1e3*(r.senderStats.auxiliary.totalPacketSendDelay||0),uint32_video_arq_packets:r.senderStats.auxiliary.retransmittedPacketsSent};s.push(l)}var d={uint32_bitrate:0,uint32_lost:0,uint32_rtt:r.senderStats.rtt};i.msg_up_stream_info={msg_audio_status:o,msg_video_status:s,msg_network_status:d}}var h=this.statInterval;i.msg_down_stream_info=[],r.receiverStats.forEach((function(e){var t={msg_user_info:{str_identifier:e.userId,uint64_tinyid:e.tinyId},msg_network_status:{uint32_rtt:e.rtt,uint32_bitrate:0,uint32_lost:0},msg_audio_status:{},msg_video_status:[]};if(e.hasAudio){var n={uint32_audio_p2p_delay:e.audio.p2pDelay,uint32_audio_cache_ms:e.audio.totalJitter,uint32_audio_cache_ms_count:e.audio.totalJitterCount,uint32_audio_codec_bitrate:e.audio.bytesReceived,uint32_audio_total_bitrate:e.audio.bytesReceived,uint32_audio_level:1e8*e.audio.audioLevel,uint32_audio_energy:1e6*e.audio.totalAudioEnergy,uint32_audio_receive:e.audio.packetsReceived,uint32_audio_origin_lost:e.audio.packetsLost};t.msg_audio_status=n}if(e.hasVideo){var r=a.get("".concat(e.userId,"_").concat(vC)),o=r?r.duration:0,s={uint32_video_stream_type:e.isSmallSubscribed?3:2,uint32_video_receive_fps:e.video.framesReceived,uint32_video_width:e.video.frameWidth,uint32_video_height:e.video.frameHeight,uint32_video_codec_bitrate:e.video.bytesReceived,uint32_video_receive:e.video.packetsReceived,uint32_video_origin_lost:e.video.packetsLost,uint32_video_block_time:o,uint32_video_dec_fps:e.video.framesDecoded,uint32_video_codec_fps:e.video.fpsRender,uint32_video_cache_ms:e.video.totalJitter,uint32_video_cache_ms_count:e.video.totalJitterCount};t.msg_video_status.push(s)}if(e.hasAuxiliary){var c=a.get("".concat(e.userId,"_").concat(_C)),u=c?c.duration:0,l={uint32_video_stream_type:7,uint32_video_receive_fps:e.auxiliary.framesReceived,uint32_video_width:e.auxiliary.frameWidth,uint32_video_height:e.auxiliary.frameHeight,uint32_video_codec_bitrate:e.auxiliary.bytesReceived,uint32_video_receive:e.auxiliary.packetsReceived+e.auxiliary.packetsLost,uint32_video_origin_lost:e.auxiliary.packetsLost,uint32_video_block_time:u,uint32_video_dec_fps:e.auxiliary.framesDecoded,uint32_video_codec_fps:e.video.fpsRender,uint32_video_cache_ms:e.auxiliary.totalJitter,uint32_video_cache_ms_count:e.auxiliary.totalJitterCount};t.msg_video_status.push(l)}i.msg_down_stream_info.push(t)}));var f=this._prevReport,p=this._prevStats;if(this._prevReport=JSON.parse(JSON.stringify(i)),this._prevStats=JSON.parse(JSON.stringify(r)),i.msg_up_stream_info.msg_audio_status&&f.msg_up_stream_info.msg_audio_status){var m=f.msg_up_stream_info.msg_audio_status,v=i.msg_up_stream_info.msg_audio_status;if(0===m.uint32_audio_codec_bitrate)v.uint32_audio_codec_bitrate=0;else{var _=this.getDifferenceValue(m.uint32_audio_codec_bitrate,v.uint32_audio_codec_bitrate);v.uint32_audio_codec_bitrate=Math.round(8*_/h),i.msg_up_stream_info.msg_network_status.uint32_bitrate+=v.uint32_audio_codec_bitrate}null!=(t=f.msg_device_info)&&t.uint32_audio_capture_cost?i.msg_device_info.uint32_audio_capture_cost=2*Math.floor(1e3*this.getDifferenceValue(f.msg_device_info.uint32_audio_capture_cost,i.msg_device_info.uint32_audio_capture_cost)/h):delete i.msg_device_info.uint32_audio_capture_cost}var g=f.msg_up_stream_info.msg_video_status;i.msg_up_stream_info.msg_video_status.forEach((function(e){var t=g.find((function(t){return t.uint32_video_stream_type===e.uint32_video_stream_type}));if(!t||0===t.uint32_video_codec_bitrate)return e.uint32_video_codec_bitrate=0,e.uint32_video_enc_fps=0,void(e.uint32_video_codec_fps=0);var r=0,a=0,o=0;t&&e.uint32_video_codec_bitrate>=t.uint32_video_codec_bitrate&&(r=t.uint32_video_codec_bitrate,a=t.uint32_video_enc_fps,o=t.uint32_video_codec_fps);var s=n.getDifferenceValue(r,e.uint32_video_codec_bitrate);e.uint32_video_codec_bitrate=Math.round(8*s/h),i.msg_up_stream_info.msg_network_status.uint32_bitrate+=e.uint32_video_codec_bitrate,e.uint32_video_enc_fps=Math.round(n.getDifferenceValue(a,e.uint32_video_enc_fps)/h),e.uint32_video_codec_fps=Math.round(n.getDifferenceValue(o,e.uint32_video_codec_fps)/h),0===t.uint32_video_width&&0===t.uint32_video_height&&0===t.uint32_video_codec_fps&&(e.uint32_video_codec_fps=e.uint32_video_enc_fps),Iw(t.uint32_key_frame_count)||(e.uint32_key_frame_count=Math.round(n.getDifferenceValue(t.uint32_key_frame_count,e.uint32_key_frame_count))),Iw(t.uint32_nack_count)||(e.uint32_nack_count=Math.round(n.getDifferenceValue(t.uint32_nack_count,e.uint32_nack_count))),Iw(t.uint32_pli_count)||(e.uint32_pli_count=Math.round(n.getDifferenceValue(t.uint32_pli_count,e.uint32_pli_count))),Iw(t.uint32_video_arq_packets)||(e.uint32_video_arq_packets=Math.round(n.getDifferenceValue(t.uint32_video_arq_packets,e.uint32_video_arq_packets))),Iw(t.uint32_encode_cost)||(e.uint32_encode_cost=Math.round(n.getDifferenceValue(t.uint32_encode_cost,e.uint32_encode_cost)/h)),Iw(t.uint32_send_packet_cost)||(e.uint32_send_packet_cost=Math.round(n.getDifferenceValue(t.uint32_send_packet_cost,e.uint32_send_packet_cost)/h))}));var y=f.msg_down_stream_info;i.msg_down_stream_info=i.msg_down_stream_info.filter((function(e){return y.find((function(t){return t.msg_user_info.uint64_tinyid===e.msg_user_info.uint64_tinyid}))}));var E=i.msg_down_stream_info;return E.forEach((function(e){var t=y.find((function(t){return t.msg_user_info.uint64_tinyid===e.msg_user_info.uint64_tinyid}));if(eL(e.msg_audio_status)||eL(t.msg_audio_status))e.msg_audio_status={};else{var r=e.msg_audio_status,i=t.msg_audio_status,a=n.getDifferenceValue(i.uint32_audio_cache_ms_count,r.uint32_audio_cache_ms_count);delete r.uint32_audio_cache_ms_count,r.uint32_audio_cache_ms=Math.floor(1e3*n.getDifferenceValue(i.uint32_audio_cache_ms,r.uint32_audio_cache_ms)/a)||0;var o=n.room.remotePublishedUserMap.get(e.msg_user_info.str_identifier);o&&(o.remoteAudioTrack.stat.jitterBufferDelay=r.uint32_audio_cache_ms),r.uint32_audio_origin_lost=n.getDifferenceValue(i.uint32_audio_origin_lost,r.uint32_audio_origin_lost),r.uint32_audio_receive=n.getDifferenceValue(i.uint32_audio_receive,r.uint32_audio_receive),r.uint32_audio_receive+=r.uint32_audio_origin_lost;var s=n.getDifferenceValue(i.uint32_audio_codec_bitrate,r.uint32_audio_codec_bitrate);r.uint32_audio_codec_bitrate=Math.round(8*s/h),r.uint32_audio_total_bitrate=Math.round(8*s/h)}if(e.msg_video_status&&t.msg_video_status){var c=t.msg_video_status;e.msg_video_status=e.msg_video_status.filter((function(e){return c.find((function(t){return t.uint32_video_stream_type===e.uint32_video_stream_type}))})),e.msg_video_status.forEach((function(e){var t=c.find((function(t){return t.uint32_video_stream_type===e.uint32_video_stream_type})),r=t.uint32_video_receive,i=t.uint32_video_origin_lost,a=t.uint32_video_codec_bitrate,o=t.uint32_video_receive_fps,s=t.uint32_video_dec_fps;e.uint32_video_origin_lost=n.getDifferenceValue(i,e.uint32_video_origin_lost),e.uint32_video_receive=n.getDifferenceValue(r,e.uint32_video_receive)+e.uint32_video_origin_lost;var u=n.getDifferenceValue(a,e.uint32_video_codec_bitrate);e.uint32_video_codec_bitrate=Math.round(8*u/h);var l=n.getDifferenceValue(o,e.uint32_video_receive_fps);e.uint32_video_receive_fps=Math.round(l/h),e.uint32_video_dec_fps=Math.round(n.getDifferenceValue(s,e.uint32_video_dec_fps)/h);var d=n.getDifferenceValue(t.uint32_video_cache_ms_count,e.uint32_video_cache_ms_count);delete e.uint32_video_cache_ms_count,e.uint32_video_cache_ms=Math.floor(1e3*n.getDifferenceValue(t.uint32_video_cache_ms,e.uint32_video_cache_ms)/d)||0}))}})),p&&r.receiverStats.forEach((function(e){if(e.audio.concealedSamples&&e.audio.totalSamplesReceived){var t=p.receiverStats.find((function(t){return t.userId===e.userId}));if(t&&t.audio.concealedSamples&&t.audio.totalSamplesReceived){var n=e.audio.concealedSamples-t.audio.concealedSamples,r=e.audio.totalSamplesReceived-t.audio.totalSamplesReceived,i=Math.floor(n/r*1e3*h);if(i>1e3*h/5){var a=E.find((function(t){return t.msg_user_info.str_identifier===e.userId}));a&&(a.msg_audio_status.uint32_audio_block_time=i)}}}})),i}},{key:"getStatsReport",value:function(e){return aR(this,arguments,(function(e){var t=this,n=e.uplinkConnection,r=e.downlinkConnections,i=e.freezeMap;return f().mark((function e(){var a,o;return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return a={msg_device_info:{},msg_up_stream_info:{msg_audio_status:{uint32_audio_format:11,uint32_audio_sample_rate:0,uint32_audio_codec_bitrate:0,uint32_audio_receive:0,uint32_audio_origin_lost:0,uint32_audio_level:0,uint32_audio_energy:0},msg_video_status:[],msg_network_status:{uint32_bitrate:0,uint32_rtt:0,uint32_lost:0}},msg_down_stream_info:[{msg_user_info:{str_identifier:"",uint64_tinyid:0},msg_audio_status:{uint32_audio_cache_ms:0,uint32_audio_format:11,uint32_audio_sample_rate:0,uint32_audio_codec_bitrate:0,uint32_audio_total_bitrate:0,uint32_audio_level:0,uint32_audio_energy:0,uint32_audio_receive:0,uint32_audio_origin_lost:0,uint32_audio_final_lost:0},msg_video_status:[{uint32_video_cache_ms:0,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}}]},e.next=3,t.getStats(n,r);case 3:return o=e.sent,e.abrupt("return",("{}"===JSON.stringify(t._prevReport)&&(t._prevReport=JSON.parse(JSON.stringify(a))),t.prepareReport({stats:o,report:a,freezeMap:i}),t._prevReportTime=Date.now(),a));case 5:case"end":return e.stop()}}),e)}))()}))}},{key:"reset",value:function(){this._prevReportTime=0,this._prevReport={},this._prevEncoderImplementation="",this._prevQualityLimitationReason="",this._prevDecoderImplementationMap=new Map}}])}(),Uj=function(e){function i(e){var a;r(this,i);var o=e.signalChannel,s=e.room;return a=n(this,i),rR(t(a),"_room"),rR(t(a),"_signalChannel"),rR(t(a),"_log"),rR(t(a),"uplinkRTT",0),rR(t(a),"uplinkLoss",0),rR(t(a),"downlinkRTT",0),rR(t(a),"downlinkLoss",0),rR(t(a),"pingResults",{}),rR(t(a),"_downlinkPrevStatMap",new Map),rR(t(a),"_downlinkLossAndRTTMap",new Map),rR(t(a),"_interval",-1),rR(t(a),"_uplinkNetworkQuality",0),rR(t(a),"_downlinkNetworkQuality",0),a._room=s,a._signalChannel=o,a._log=sx.createLogger({id:"q",userId:a._room.userId,sdkAppId:a._room.sdkAppId}),a.initialize(),a}return d(i,e),o(i,[{key:"uplinkNetworkQuality",get:function(){return this._uplinkNetworkQuality},set:function(e){e!==this._uplinkNetworkQuality&&this._log.info("uplink ".concat(this.uplinkNetworkQuality," -> ").concat(e,", rtt: ").concat(this.uplinkRTT,", loss: ").concat(this.uplinkLoss," ws-rtt: ").concat(this._signalChannel.rtt)),this._uplinkNetworkQuality=e}},{key:"downlinkNetworkQuality",get:function(){return this._downlinkNetworkQuality},set:function(e){if(e!==this._downlinkNetworkQuality){var t=this.getAverageLossAndRTT(E(this._downlinkLossAndRTTMap.values())),n=t.rtt,r=t.loss;this._log.info("downlink ".concat(this.downlinkNetworkQuality," -> ").concat(e,", rtt: ").concat(n,", loss: ").concat(r," ws-rtt: ").concat(this._signalChannel.rtt))}this._downlinkNetworkQuality=e}},{key:"initialize",value:function(){var e=this;this._signalChannel.on(fj.UPLINK_NETWORK_STATS,(function(t){e.handleUplinkNetworkQuality(t)})),this._signalChannel.on("2",this.handleSignalConnectionStateChange.bind(this)),this.start()}},{key:"handleUplinkNetworkQuality",value:function(e){var t,n;if(0===e.data.code){var r=e.data.data;if(r.delay&&this.updateDelay(r.delay),this._room.signalChannel&&r.wsRtt&&(this._room.signalChannel.rtt=r.wsRtt),!this._room.uplinkConnection)return this.uplinkNetworkQuality=0,this.uplinkLoss=0,void(this.uplinkRTT=0);var i=null==(n=null==(t=this._room)?void 0:t.uplinkConnection)?void 0:n.getPeerConnection();if(i&&this.isPeerConnectionDisconnected(i))return this.uplinkNetworkQuality=6,this.uplinkLoss=0,void(this.uplinkRTT=0);var a=r.expectAudPkg+r.expectVidPkg,o=r.recvAudPkg+r.recvVidPkg,s=a-o;0===a&&0===o||(this.uplinkLoss=s<=0?0:Math.round(s/a*100),this.uplinkRTT=r.rtt,this.uplinkNetworkQuality=this.getNetworkQuality(this.uplinkLoss,this.uplinkRTT))}}},{key:"handleDownlinkNetworkQuality",value:function(){return aR(this,null,f().mark((function e(){var t,n,r,i,a,o,s,c,u,l,d,h,p,m,v,_=this;return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(0!==this._room.remotePublishedUserMap.size){e.next=2;break}return e.abrupt("return",void(this.downlinkNetworkQuality=0));case 2:if(t=E(this._room.remotePublishedUserMap.values()),n=t.filter((function(e){var t;return(null==(t=e.getPeerConnection())?void 0:t.connectionState)===AC.CONNECTED})),t.filter((function(e){return _.isPeerConnectionDisconnected(e.getPeerConnection())})).length!==t.length){e.next=5;break}return e.abrupt("return",void(this.downlinkNetworkQuality=6));case 5:r=0;case 6:if(!(r<n.length)){e.next=24;break}if(i=n[r].getPeerConnection()){e.next=10;break}return e.abrupt("return");case 10:return e.next=12,this.getStat(i);case 12:if(a=e.sent,o=a.rtt,s=a.totalPacketsLost,c=a.totalPacketsReceived,this._downlinkPrevStatMap.has(i)){e.next=19;break}return this._downlinkPrevStatMap.set(i,{totalPacketsLost:s,totalPacketsReceived:c}),e.abrupt("continue",21);case 19:l=this._downlinkPrevStatMap.get(i),d=s-l.totalPacketsLost,h=c-l.totalPacketsReceived,u=d<=0||h<0?0:Math.round(d/(d+h)*100),this._downlinkPrevStatMap.set(i,{totalPacketsLost:s,totalPacketsReceived:c}),this._downlinkLossAndRTTMap.set(i,{rtt:o,loss:u,userId:n[r].getUserId(),audioDelay:n[r].remoteAudioTrack.stat.end2EndDelay,videoDelay:n[r].remoteVideoTrack.stat.end2EndDelay});case 21:r++,e.next=6;break;case 24:if(E(this._downlinkPrevStatMap.keys()).forEach((function(e){_.isPeerConnectionDisconnected(e)&&(_._downlinkPrevStatMap.delete(e),_._downlinkLossAndRTTMap.delete(e))})),0!==this._downlinkLossAndRTTMap.size){e.next=26;break}return e.abrupt("return",(this.downlinkRTT=0,this.downlinkLoss=0,void(this.downlinkNetworkQuality=0)));case 26:p=this.getAverageLossAndRTT(E(this._downlinkLossAndRTTMap.values())),m=p.rtt,v=p.loss,this.downlinkRTT=m,this.downlinkLoss=v,this.downlinkNetworkQuality=this.getNetworkQuality(v,m);case 28:case"end":return e.stop()}}),e,this)})))}},{key:"getStat",value:function(e){return aR(this,null,f().mark((function t(){var n,r,i;return f().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n={rtt:0,totalPacketsLost:0,totalPacketsReceived:0},e&&qO()){t.next=3;break}return t.abrupt("return",n);case 3:r=e.getReceivers(),t.prev=4,i=0;case 6:if(!(i<r.length)){t.next=13;break}return t.next=9,r[i].getStats();case 9:t.sent.forEach((function(e){"candidate-pair"===e.type&&Aw(e.currentRoundTripTime)&&(n.rtt=Math.round(1e3*e.currentRoundTripTime)),"inbound-rtp"===e.type&&(e.mediaType===nC.AUDIO||e.mediaType===nC.VIDEO)&&(n.totalPacketsLost+=e.packetsLost,n.totalPacketsReceived+=e.packetsReceived)}));case 10:i++,t.next=6;break;case 13:return t.abrupt("return",(0===n.rtt&&(n.rtt=this.uplinkRTT),n));case 16:return t.prev=16,t.t0=t.catch(4),t.abrupt("return",n);case 19:case"end":return t.stop()}}),t,this,[[4,16]])})))}},{key:"getAverageLossAndRTT",value:function(e){var t={rtt:0,loss:0};return Array.isArray(e)&&e.length>0&&(e.forEach((function(e){t.rtt+=e.rtt,t.loss+=e.loss})),Object.keys(t).forEach((function(n){t[n]=Math.round(t[n]/e.length)}))),t}},{key:"getNetworkQuality",value:function(e,t){return e>50||t>500?5:e>30||t>350?4:e>20||t>200?3:e>10||t>100?2:e>=0||t>=0?1:0}},{key:"handleSignalConnectionStateChange",value:function(e){"DISCONNECTED"===e.state?(this.uplinkRTT=0,this.uplinkLoss=0,this.uplinkNetworkQuality=6):"CONNECTED"===e.state&&6===this.uplinkNetworkQuality&&(this.uplinkNetworkQuality=5)}},{key:"handleUplinkConnectionStateChange",value:function(e){var t=e.state;"DISCONNECTED"===t?(this.uplinkLoss=0,this.uplinkRTT=0,this.uplinkNetworkQuality=6):"CONNECTED"===t&&6===this.uplinkNetworkQuality&&(this.uplinkNetworkQuality=5)}},{key:"isPeerConnectionDisconnected",value:function(e){return!(!e||e.connectionState!==AC.DISCONNECTED&&e.connectionState!==AC.FAILED&&e.connectionState!==AC.CLOSED)}},{key:"setUplinkConnection",value:function(e){this._room.uplinkConnection=e,this._room.uplinkConnection?this._room.uplinkConnection.on("connection-state-changed",this.handleUplinkConnectionStateChange.bind(this)):(this.uplinkNetworkQuality=0,this.uplinkRTT=0,this.uplinkLoss=0)}},{key:"start",value:function(){var e=this;-1===this._interval?(this._log.debug("start network quality calculating"),this._interval=MP.run("ric",(function(){var t;e.handleDownlinkNetworkQuality();var n=E(e._downlinkLossAndRTTMap.values());rx.emit(ax.NETWORK_QUALITY,{room:e._room,uplink:{rtt:e.uplinkRTT,loss:e.uplinkLoss},downlinks:n});var r=null==(t=e._room.scheduleResult.config)?void 0:t.pingDomainInfo,a={uplinkNetworkQuality:e.uplinkNetworkQuality,downlinkNetworkQuality:e.downlinkNetworkQuality,uplinkRTT:e.uplinkRTT,uplinkLoss:e.uplinkLoss,downlinkRTT:e.downlinkRTT,downlinkLoss:e.downlinkLoss};r&&(a=$A(QA({},a),{pingResults:e.uplinkRTT>r.rttThreshold||e.downlinkRTT>r.rttThreshold?e.pingResults:{}})),e.emit(i.EVENT_NETWORK_QUALITY,a);var o=Date.now();if(r&&(e.uplinkRTT>r.rttThreshold||e.downlinkRTT>r.rttThreshold)&&o-i.lastPingTime>1e3*r.interval){i.lastPingTime=Date.now();var c=r.domain.map((function(e){return function(e){var t=this;return new Promise((function(n){return aR(t,null,f().mark((function t(){var r,i,a,o;return f().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=setTimeout((function(){n({totalCost:1e4,local:0,dns:0,tcp:0,tls:0,request:0,response:0})}),1e4),i=Date.now(),a="https://".concat(e,"/?t=").concat(i),t.prev=1,t.next=4,fetch(a);case 4:t.next=8;break;case 6:t.prev=6,t.t0=t.catch(1);case 8:clearTimeout(r),o=function(e){var t={totalCost:0,local:0,redirect:0,httpCache:0,dns:0,tcp:0,tls:0,request:0,response:0};try{var n,i=s(performance.getEntriesByType("resource").reverse());try{for(i.s();!(n=i.n()).done;){var a=n.value;if(a.name===e){var o=Math.round(a.duration),c=Math.max(Math.round(a.domainLookupStart-a.startTime),0),u=a.redirectStart>0?Math.max(Math.round(a.redirectEnd-a.redirectStart),0):0,l=a.fetchStart>0?Math.max(Math.round(a.domainLookupStart-a.fetchStart),0):0,d=Math.round(a.domainLookupEnd-a.domainLookupStart),h=Math.round(a.requestStart-a.secureConnectionStart),f=Math.round(a.secureConnectionStart-a.connectStart),p=Math.round(a.responseStart-a.requestStart),m=Math.round(a.responseEnd-(a.responseStart||a.startTime));t=$A(QA({},t),{totalCost:o,local:c,redirect:u,httpCache:l,dns:d,tcp:f,tls:h,request:p,response:m});break}}}catch(v){i.e(v)}finally{i.f()}}catch(r){}return t}(a),0===o.totalCost&&(o.totalCost=Date.now()-i),n(o);case 11:case"end":return t.stop()}}),t,null,[[1,6]])})))}))}(e).then((function(t){return{domain:e,cost:t.totalCost}}))}));Promise.all(c).then((function(t){e.pingResults.isPoorNetwork=t.some((function(e){return e.cost>700})),e.pingResults.timestamp=o,e.pingResults.data=t,t.forEach((function(e){bO.addSuccessEvent({key:521718,cost:e.cost})})),e._log.warn("All ping results: ".concat(JSON.stringify(t)))})).catch((function(t){e._log.warn("Error during pinging domains: ".concat(t))}))}}),{delay:2e3})):this._log.info("network quality calculating is already started")}},{key:"stop",value:function(){this._log.debug("stopped"),-1!==this._interval&&(MP.clearTask(this._interval),this._interval=-1),this._downlinkLossAndRTTMap.clear(),this._downlinkPrevStatMap.clear()}},{key:"updateDelay",value:function(e){var t=this,n=this._room.tinyIdToUserIdMap;e.forEach((function(e){var r=e.srcTinyId,i=e.videoDelay,a=e.audioDelay,o=n.get(r);if(o){var s=t._room.remotePublishedUserMap.get(o);null==s||s.setDelay({videoDelay:i,audioDelay:a})}}))}}])}(tR(oR()).default);rR(Uj,"EVENT_NETWORK_QUALITY","0"),rR(Uj,"lastPingTime",0);var Fj=Uj,Bj=function(){return o((function e(t){var n=this;r(this,e),rR(this,"_frameWorkType"),rR(this,"_component"),rR(this,"_language"),rR(this,"connectionType"),rR(this,"_room"),rR(this,"_signalInfo",{tinyId:void 0,clientIp:"",signalIp:"",relayIp:"",relayInnerIp:"",relayPort:0,endReportExtend:void 0}),rR(this,"_keyPrefix"),rR(this,"_log"),rR(this,"_intervalId"),rR(this,"_firstPublishedUserList"),rR(this,"_networkQuality"),rR(this,"_basicInfo"),rR(this,"_pathJoinRoom"),rR(this,"_pathLeaveRoom"),rR(this,"_pathMainVideoMap"),rR(this,"_pathMainAudioMap"),rR(this,"_pathAuxiliaryMap"),rR(this,"_remoteStreamStatMap"),rR(this,"_localStreamStat"),rR(this,"_eventMap",new Map),rR(this,"_captureCostSum",0),rR(this,"_captureCostCount",0),rR(this,"isDestroyed",!1),this._frameWorkType=t.frameWorkType||30,this._component=t.component||0,this.connectionType=t.connectionType||1,this._language=t.language||0,this._room=t.room,this._keyPrefix="key_point",this._log=sx.createLogger({id:"kpm",userId:this._room.userId,sdkAppId:this._room.sdkAppId}),Object.getOwnPropertyNames(this.__proto__).forEach((function(e){e.startsWith("handle")&&Sw(n[e])&&(n[e]=function(e){var t=e.fn,n=e.context;return function(){try{for(var e=arguments.length,r=new Array(e),i=0;i<e;i++)r[i]=arguments[i];var a=t.apply(n,r);return xw(a)?a.catch((function(e){return sx.error("".concat(t.name,"() error observed ").concat(e))})):a}catch(DC){sx.error("".concat(t.name,"() error observed ").concat(DC))}}}({fn:n[e],context:n}))})),this.initData(),this.installEvents()}),[{key:"initData",value:function(){var e=this;this._firstPublishedUserList=[],this._networkQuality={totalUplinkRTT:0,totalUplinkLoss:0,count:0,totalDownlinkRTTAndLossMap:new Map},this._basicInfo={string_sdk_version:RR,uint32_os_type:15,string_device_name:"",string_http_user_agent:navigator.userAgent,string_os_version:"",uint32_avg_rtt:0,uint32_avg_up_loss:0,uint32_scene:"live"===this._room.scene?1:0,uint32_joining_duration:0,uint32_networkType:0,uint32_framework:this._frameWorkType,uint32_component:this._component,uint32_connection_type:this.connectionType,uint32_caller_coding_language:this._language,string_domain:location.hostname},this._pathJoinRoom={uint64_start_time:0,uint64_send_request_acc_ip_cmd_start_time:0,uint64_send_request_acc_ip_cmd_end_time:0,uint64_send_request_enter_room_cmd_start_time:0,uint64_send_request_enter_room_cmd_end_time:0,uint64_send_first_video_frame_time:0,uint64_recv_userlist_time:0,uint64_end_time:0,int32_send_request_acc_ip_cmd_ret:0,int32_send_request_enter_room_cmd_ret:0,int32_end_ret:0},this._pathLeaveRoom={uint64_start_time:0,uint64_send_request_exit_room_cmd_start_time:0,uint64_send_request_exit_room_cmd_end_time:0,uint64_end_time:0,int32_send_request_exit_room_cmd_ret:0,int32_end_ret:0},this._localStreamStat={totalVideoBitrate:0,totalVideoFPS:0,totalVideoHeight:0,totalVideoWidth:0,totalAudioLevel:0,videoCount:0,audioLevelCount:0,publishStartTime:0,statsToReport:{uint32_audio_capture_db:0,uint32_video_big_capture_fps:0,uint32_video_big_bitrate:0,uint32_video_big_resolution:0}},this._pathMainVideoMap=new Map,this._pathMainAudioMap=new Map,this._pathAuxiliaryMap=new Map,this._remoteStreamStatMap=new Map,YN().then((function(t){e._basicInfo.string_os_version=ZN(),e._basicInfo.string_device_name=t&&t.mobile?t.model:e._basicInfo.string_os_version}))}},{key:"addEvent",value:function(e,t){return this._eventMap.set(e,t),rx.on(e,t),this}},{key:"installEvents",value:function(){var e=this;this.handleUnload=this.handleUnload.bind(this),window.addEventListener("pagehide",this.handleUnload),this._room.once("banned",(function(){return e.handleLeaveSuccess({room:e._room,roomId:e._room.roomId})})),this.addEvent(ax.JOIN_START,this.handleJoinStart).addEvent(ax.JOIN_SCHEDULE_SUCCESS,this.handleJoinScheduleSuccess).addEvent(ax.JOIN_SIGNAL_CONNECTION_START,this.handleSignalConnectionStart).addEvent(ax.JOIN_SIGNAL_CONNECTION_END,this.handleSignalConnectionEnd).addEvent(ax.JOIN_SEND_CMD,this.handleJoinSendCMD).addEvent(ax.JOIN_RECEIVED_CMD_RES,this.handleJoinReceivedCMDResponce).addEvent(ax.JOIN_SUCCESS,this.handleJoinSuccess).addEvent(ax.JOIN_FAILED,this.handleJoinFailed).addEvent(ax.LEAVE_START,this.handleLeaveStart).addEvent(ax.LEAVE_SUCCESS,this.handleLeaveSuccess).addEvent(ax.LEAVE_SEND_CMD,this.handleLeaveSendCMD).addEvent(ax.LOCAL_TRACK_CAPTURE_START,this.handleTrackCaptureStart).addEvent(ax.LOCAL_TRACK_CAPTURE_SUCCESS,this.handleTrackCaptureSuccess).addEvent(ax.LOCAL_TRACK_CAPTURE_FAILED,this.handleTrackCaptureFailed).addEvent(ax.PUBLISH_START,this.handlePublishStart).addEvent(ax.SEND_FIRST_VIDEO_FRAME,this.handleSendFirstVideoFrame).addEvent(ax.SUBSCRIBE_START,this.handleSubscribeStart).addEvent(ax.SUBSCRIBE_SUCCESS,this.handleSubscribed).addEvent(ax.PLAY_TRACK_START,this.handlePlayStart).addEvent(ax.VIDEO_LOADED_DATA,this.handleVideoLoadedData).addEvent(ax.PLAYER_STATE_CHANGED,(function(t){var n=t.track,r=t.state,i=t.type;!n.isRemote||!e.hitTest(n.room)||"PLAYING"===r&&(i===nC.AUDIO?e.handleAudioPlaying(n):e.handleVideoPlaying(n))})).addEvent(ax.NETWORK_QUALITY,this.handleNetworkQuality).addEvent(ax.HEARTBEAT_REPORT,this.handleHeartbeatStats).addEvent(ax.RECEIVED_PUBLISHED_USER_LIST,this.handleReceivedPublishUserList).addEvent(ax.REMOTE_PUBLISH_STATE_CHANGED,(function(t){var n=t.room,r=t.prevMuteState,i=t.muteState;if(e.hitTest(n)){var a=r.hasAudio||r.hasVideo||r.hasSmall,o=r.hasAuxiliary,s=i.hasAudio||i.hasVideo||i.hasSmall,c=i.hasAuxiliary;!a&&s&&e.handleRemoteStreamAdded(i.userId,"main"),!o&&c&&e.handleRemoteStreamAdded(i.userId,"auxiliary")}})).addEvent(ax.SINGLE_CONNECTION_STAT,(function(t){var n=t.room,r=t.stat;e.hitTest(n)&&(e._pathJoinRoom.int32_ice_cost=r.ice,e._pathJoinRoom.int32_dtls_cost=r.dtls,e._pathJoinRoom.int32_peer_connection_cost=r.peerConnection)}))}},{key:"uninstallEvents",value:function(){window.removeEventListener("pagehide",this.handleUnload),this._eventMap.forEach((function(e,t){return rx.off(t,e)})),this._eventMap.clear()}},{key:"destroy",value:function(){this.uninstallEvents(),MP.clearTask(this._intervalId),0===this._pathJoinRoom.uint64_start_time&&(this._room=null),this.isDestroyed=!0}},{key:"handleUnload",value:function(){this._room.isJoined&&this.handleLeaveSuccess({room:this._room,roomId:this._room.roomId})}},{key:"handleJoinStart",value:function(e){this.hitTest(e.room)&&(0===this._pathJoinRoom.uint64_start_time&&(this._pathJoinRoom.uint64_start_time=Date.now()),e.params&&(Iw(e.params.frameWorkType)||(this._frameWorkType=e.params.frameWorkType,this._basicInfo.uint32_framework=this._frameWorkType),Iw(e.params.component)||(this._component=e.params.component,this._basicInfo.uint32_component=this._component),Iw(e.params.language)||(this._language=e.params.language,this._basicInfo.uint32_caller_coding_language=this._language)))}},{key:"handleJoinScheduleSuccess",value:function(e){var t=e.room,n=e.detailCost;if(this.hitTest(t)&&n){var r=n.totalCost,i=n.local,a=n.dns,o=n.tcp,s=n.tls,c=n.request,u=n.response;this._pathJoinRoom.int32_schedule_cost=r,this._pathJoinRoom.int32_schedule_local=i,this._pathJoinRoom.int32_schedule_dns=a,this._pathJoinRoom.int32_schedule_tcp=o,this._pathJoinRoom.int32_schedule_tls=s,this._pathJoinRoom.int32_schedule_request=c,this._pathJoinRoom.int32_schedule_response=u}}},{key:"handleSignalConnectionStart",value:function(e){var t=e.room;this.hitTest(t)&&0===this._pathJoinRoom.uint64_send_request_acc_ip_cmd_start_time&&(this._pathJoinRoom.uint64_send_request_acc_ip_cmd_start_time=Date.now())}},{key:"handleSignalConnectionEnd",value:function(e){var t=e.room,n=e.error;this.hitTest(t)&&0===this._pathJoinRoom.uint64_send_request_acc_ip_cmd_end_time&&(this._pathJoinRoom.uint64_send_request_acc_ip_cmd_end_time=Date.now(),n&&(this._pathJoinRoom.int32_send_request_acc_ip_cmd_ret=n instanceof yR?Number(n.getExtraCode()||n.getCode()):_R.UNKNOWN,this._pathJoinRoom.int32_end_ret=this._pathJoinRoom.int32_send_request_acc_ip_cmd_ret))}},{key:"handleJoinSendCMD",value:function(e){this.hitTest(e.room)&&0===this._pathJoinRoom.uint64_send_request_enter_room_cmd_start_time&&(this._pathJoinRoom.uint64_send_request_enter_room_cmd_start_time=Date.now())}},{key:"handleJoinReceivedCMDResponce",value:function(e){this.hitTest(e.room)&&0===this._pathJoinRoom.uint64_send_request_enter_room_cmd_end_time&&(this._pathJoinRoom.uint64_send_request_enter_room_cmd_end_time=Date.now(),this._pathJoinRoom.int32_send_request_enter_room_cmd_ret=e.code,0!==e.code&&(this._pathJoinRoom.int32_end_ret=this._pathJoinRoom.int32_send_request_enter_room_cmd_ret))}},{key:"handleJoinSuccess",value:function(e){this.hitTest(e.room)&&0===this._pathJoinRoom.uint64_end_time&&(this._pathJoinRoom.uint64_end_time=Date.now(),this._pathJoinRoom.int32_end_ret=0,this._signalInfo=e.room.getSignalInfo())}},{key:"handleJoinFailed",value:function(e){var t=this,n=e.room,r=e.error;this.hitTest(n)&&(this._pathJoinRoom.uint64_end_time=Date.now(),0===this._pathJoinRoom.int32_end_ret&&(this._pathJoinRoom.int32_end_ret=r.code||this._pathJoinRoom.int32_send_request_enter_room_cmd_ret||this._pathJoinRoom.int32_send_request_acc_ip_cmd_ret),setTimeout((function(){t.report()})))}},{key:"handleReceivedPublishUserList",value:function(e){this.hitTest(e.room)&&0===this._pathJoinRoom.uint64_recv_userlist_time&&(this._pathJoinRoom.uint64_recv_userlist_time=Date.now(),this._firstPublishedUserList=e.publishedUserList||[])}},{key:"handleSendFirstVideoFrame",value:function(e){var t=e.room;this.hitTest(t)&&0===this._pathJoinRoom.uint64_send_first_video_frame_time&&0!==this._pathJoinRoom.uint64_start_time&&(this._pathJoinRoom.uint64_send_first_video_frame_time=Date.now())}},{key:"handleLeaveStart",value:function(e){this.hitTest(e.room)&&(this._pathLeaveRoom.uint64_start_time=Date.now())}},{key:"handleLeaveSuccess",value:function(e){this.hitTest(e.room)&&0===this._pathLeaveRoom.uint64_end_time&&(this._pathLeaveRoom.uint64_end_time=Date.now(),0!==this._pathJoinRoom.uint64_end_time?this._basicInfo.uint32_joining_duration=this._pathLeaveRoom.uint64_end_time-this._pathJoinRoom.uint64_end_time:this._log.warn("pathJoinRoom endTime is 0"),this.report())}},{key:"handleLeaveSendCMD",value:function(e){this.hitTest(e.room)&&(this._pathLeaveRoom.uint64_send_request_exit_room_cmd_start_time=Date.now(),this._pathLeaveRoom.uint64_send_request_exit_room_cmd_end_time=Date.now())}},{key:"handleRemoteStreamAdded",value:function(e,t){var n,r="".concat(e,"_").concat(t);if(!this._remoteStreamStatMap.has(r)){var i={userId:e,totalVideoFPS:0,totalVideoBitrate:0,totalAudioLevel:0,totalAudioBitrate:0,totalLoss:0,audioCount:0,audioLevelCount:0,videoCount:0,networkQualityCount:0,streamAddedTime:Date.now(),subscribeStartTime:0,subscribedTime:0,playStreamTime:0,statsToReport:$A(QA({},Hj),{msg_user_info:new Gj({userId:e,tinyId:null==(n=this._room.remotePublishedUserMap.get(e))?void 0:n.tinyId,role:20})})};i.statsToReport.uint32_stream_type="main"===t?2:7,this._remoteStreamStatMap.set(r,i)}}},{key:"handleSubscribeStart",value:function(e){var t=e.room,n=e.remotePublishedUser,r=e.streamType,i=e.subscribeState;if(this.hitTest(t)){var a=n.userId,o=n.tinyId,s=n.role,c=new Gj({userId:a,tinyId:o,role:"anchor"===s?20:21}),u=Date.now(),l="".concat(a,"_").concat(r),d=this._remoteStreamStatMap.get(l);d&&0===d.subscribeStartTime&&(d.subscribeStartTime=u),"main"===r?(n.muteState.hasVideo&&(i.video||i.smallVideo)&&!this._pathMainVideoMap.has(l)&&this._pathMainVideoMap.set(l,{statsToReport:{msg_user_info:c,uint64_start_enter_time:this._pathJoinRoom.uint64_start_time,uint64_render_first_frame_time:0,uint64_combine_first_frame_time:0},userId:a,sendSubscribeCMDTime:u}),n.muteState.hasAudio&&i.audio&&!this._pathMainAudioMap.has(l)&&this._pathMainAudioMap.set(l,{statsToReport:{msg_user_info:c,uint64_start_enter_time:this._pathJoinRoom.uint64_start_time,uint64_play_first_frame_time:0},userId:a,sendSubscribeCMDTime:u})):n.muteState.hasAuxiliary&&i.auxiliary&&!this._pathAuxiliaryMap.has(l)&&this._pathAuxiliaryMap.set(l,{sendSubscribeCMDTime:u})}}},{key:"handleSubscribed",value:function(e){var t=e.room,n=e.remotePublishedUser,r=e.streamType;if(this.hitTest(t)){var i="".concat(n.userId,"_").concat(r),a=this._remoteStreamStatMap.get(i);a&&0===a.subscribedTime&&(a.subscribedTime=Date.now())}}},{key:"handlePlayStart",value:function(e){var t=e.track;if(t.isRemote&&this.hitTest(t.room)){var n="".concat(t.userId,"_").concat(t.streamType),r=this._remoteStreamStatMap.get(n);0===(null==r?void 0:r.playStreamTime)&&(r.playStreamTime=Date.now())}}},{key:"handleVideoLoadedData",value:function(e){var t=e.track;if(t.isRemote&&this.hitTest(t.room)){var n="".concat(t.userId,"_").concat(t.streamType),r=this._pathMainVideoMap.get(n);r&&0===r.statsToReport.uint64_combine_first_frame_time&&(r.statsToReport.uint64_combine_first_frame_time=Date.now())}}},{key:"handleVideoPlaying",value:function(e){var t="".concat(e.userId,"_").concat(e.streamType),n=Date.now(),r=this._pathMainVideoMap.get(t),i=this._remoteStreamStatMap.get(t);if(i){var a=i.statsToReport;if(a.uint32_video_render_first||"main"!==e.streamType?this.hasAuxFlag(e.userId):this.hasVideoFlag(e.userId)){var o=n-this._pathJoinRoom.uint64_start_time;a.uint32_video_render_first=o,bO.addNumber({key:516820,value:o})}}0===(null==r?void 0:r.statsToReport.uint64_render_first_frame_time)&&(r.statsToReport.uint64_render_first_frame_time=n)}},{key:"handleAudioPlaying",value:function(e){var t="".concat(e.userId,"_").concat(e.streamType),n=this._pathMainAudioMap.get(t);n&&0===n.statsToReport.uint64_play_first_frame_time&&(n.statsToReport.uint64_play_first_frame_time=Date.now())}},{key:"handleNetworkQuality",value:function(e){var t=this;this.hitTest(e.room)&&(this._networkQuality.totalUplinkLoss+=e.uplink.loss,this._networkQuality.totalUplinkRTT+=e.uplink.rtt,this._networkQuality.count++,e.downlinks.forEach((function(e){var n,r,i,a,o=e.rtt,s=e.loss,c=e.userId,u=e.videoDelay,l=e.audioDelay,d=t._networkQuality.totalDownlinkRTTAndLossMap.get(c);d?(d.totalRTT+=o,d.totalLoss+=s,u&&(d.totalVideoDelay=(d.totalVideoDelay||0)+u,d.videoDelayCount=(d.videoDelayCount||0)+1),l&&(d.totalAudioDelay=(d.totalAudioDelay||0)+l,d.audioDelayCount=(d.audioDelayCount||0)+1),d.count++):(u&&(r=u,i=1),l&&(n=l,a=1),t._networkQuality.totalDownlinkRTTAndLossMap.set(c,{totalRTT:o,totalLoss:s,count:1,totalAudioDelay:n,totalVideoDelay:r,audioDelayCount:a,videoDelayCount:i}))})))}},{key:"handleHeartbeatStats",value:function(e){var t=this;if(this.hitTest(e.room)){var n=e.report,r=n.msg_device_info,i=n.msg_up_stream_info,a=n.msg_down_stream_info;if(i.msg_video_status[0]){var o=i.msg_video_status[0],s=o.uint32_video_codec_bitrate,c=o.uint32_video_enc_fps,u=o.uint32_video_width,l=o.uint32_video_height;this._localStreamStat.totalVideoBitrate+=s,this._localStreamStat.totalVideoFPS+=c,this._localStreamStat.totalVideoWidth+=u,this._localStreamStat.totalVideoHeight+=l,this._localStreamStat.videoCount++}if(i.msg_audio_status){var d=i.msg_audio_status.uint32_audio_level;Math.floor(d/tO*100)>0&&(this._localStreamStat.totalAudioLevel+=d/tO,this._localStreamStat.audioLevelCount++)}a.forEach((function(e){var n=e.msg_user_info,r=e.msg_audio_status,i=e.msg_video_status,a=n.str_identifier,o=t._room.remotePublishedUserMap.get(a);if(i.forEach((function(e){var n=2===e.uint32_video_stream_type,r=7===e.uint32_video_stream_type,i="".concat(a,"_").concat(n?"main":"auxiliary"),s=t._remoteStreamStatMap.get(i);if(s&&(n&&null!=o&&o.remoteVideoTrack.isSubscribed||r&&null!=o&&o.remoteAuxiliaryTrack)){s.totalVideoFPS+=e.uint32_video_receive_fps,s.totalVideoBitrate+=e.uint32_video_codec_bitrate,s.videoCount++,0===s.statsToReport.uint32_video_width&&(s.statsToReport.uint32_video_width=e.uint32_video_width),0===s.statsToReport.uint32_video_height&&(s.statsToReport.uint32_video_height=e.uint32_video_height);var c=n?o.remoteVideoTrack:o.remoteAuxiliaryTrack;c.stat.jitterBufferDelay&&(s.videoJitterBufferDelay=c.stat.jitterBufferDelay),c.stat.framesReceived&&(s.statsToReport.uint32_video_consume_render_rate=Math.floor(c.stat.framesDecoded/c.stat.framesReceived*qA(10,6)))}})),!jw(r)){var s="".concat(a,"_main"),c=t._remoteStreamStatMap.get(s);t._remoteStreamStatMap.has(s)&&c&&null!=o&&o.remoteAudioTrack.isSubscribed&&(c.totalAudioBitrate+=r.uint32_audio_codec_bitrate,c.audioCount++,o.remoteAudioTrack.stat.jitterBufferDelay&&(c.audioJitterBufferDelay=o.remoteAudioTrack.stat.jitterBufferDelay),Math.floor(r.uint32_audio_level/tO*100)>0&&(c.totalAudioLevel+=r.uint32_audio_level/tO,c.audioLevelCount++))}})),r.uint32_audio_capture_cost&&(this._captureCostSum+=r.uint32_audio_capture_cost,this._captureCostCount+=1,this._captureCostCount>=100&&(this._basicInfo.uint32_audio_capture_cost=Math.floor(this._captureCostSum/this._captureCostCount),this._captureCostSum=0,this._captureCostCount=0))}}},{key:"handlePublishStart",value:function(e){var t=e.room;this.hitTest(t)&&0===this._localStreamStat.publishStartTime&&(this._localStreamStat.publishStartTime=Date.now())}},{key:"handleTrackCaptureStart",value:function(e){var t=e.track;1===t.mediaType&&!this._pathJoinRoom.uint64_init_audio_start_time&&(this._pathJoinRoom.uint64_init_audio_start_time=Date.now()),4===t.mediaType&&!this._pathJoinRoom.uint64_init_camera_start_time&&(this._pathJoinRoom.uint64_init_camera_start_time=Date.now())}},{key:"handleTrackCaptureSuccess",value:function(e){var t=e.track;1===t.mediaType&&!this._pathJoinRoom.uint64_init_audio_end_time&&(this._pathJoinRoom.int32_init_audio_ret=0,this._pathJoinRoom.uint64_init_audio_end_time=Date.now()),4===t.mediaType&&!this._pathJoinRoom.uint64_init_camera_end_time&&(this._pathJoinRoom.int32_init_camera_ret=0,this._pathJoinRoom.uint64_init_camera_end_time=Date.now())}},{key:"handleTrackCaptureFailed",value:function(e){var t=e.track,n=e.error,r={NotFoundError:1,NotAllowedError:2,NotReadableError:3,OverConstrainedError:4,AbortError:5,InvalidStateError:6,SecurityError:7,TypeError:8}[n.name]||(n instanceof yR?n.getExtraCode()||n.getCode():_R.UNKNOWN);1===t.mediaType&&!this._pathJoinRoom.uint64_init_audio_end_time&&(this._pathJoinRoom.int32_init_audio_ret=r,this._pathJoinRoom.uint64_init_audio_end_time=Date.now()),4===t.mediaType&&!this._pathJoinRoom.uint64_init_camera_end_time&&(this._pathJoinRoom.int32_init_camera_ret=r,this._pathJoinRoom.uint64_init_camera_end_time=Date.now())}},{key:"hasVideoFlag",value:function(e){return this._firstPublishedUserList.findIndex((function(t){return t.userId===e&&t.flag&oC}))>=0}},{key:"hasAudioFlag",value:function(e){return this._firstPublishedUserList.findIndex((function(t){return t.userId===e&&t.flag&uC}))>=0}},{key:"hasAuxFlag",value:function(e){return this._firstPublishedUserList.findIndex((function(t){return t.userId===e&&t.flag&cC}))>=0}},{key:"hitTest",value:function(e){return e===this._room}},{key:"prepareReport",value:function(){var e=this;if(this._captureCostCount>0&&!this._basicInfo.uint32_audio_capture_cost&&(this._basicInfo.uint32_audio_capture_cost=Math.floor(this._captureCostSum/this._captureCostCount),this._captureCostSum=0,this._captureCostCount=0),this._networkQuality.count>0&&(this._basicInfo.uint32_avg_rtt=Math.floor(this._networkQuality.totalUplinkRTT/this._networkQuality.count),this._basicInfo.uint32_avg_up_loss=Math.floor(this._networkQuality.totalUplinkLoss/this._networkQuality.count)),this._localStreamStat.videoCount>0){this._localStreamStat.statsToReport.uint32_video_big_capture_fps=Math.floor(this._localStreamStat.totalVideoFPS/this._localStreamStat.videoCount),this._localStreamStat.statsToReport.uint32_video_big_bitrate=Math.floor(this._localStreamStat.totalVideoBitrate/this._localStreamStat.videoCount);var t=Math.floor(this._localStreamStat.totalVideoWidth/this._localStreamStat.videoCount),n=Math.floor(this._localStreamStat.totalVideoHeight/this._localStreamStat.videoCount);this._localStreamStat.statsToReport.uint32_video_big_resolution=t<<16|n}this._localStreamStat.audioLevelCount>0&&(this._localStreamStat.statsToReport.uint32_audio_capture_db=Math.floor(this._localStreamStat.totalAudioLevel/this._localStreamStat.audioLevelCount*100)),this._remoteStreamStatMap.forEach((function(t,n){var r=t.userId,i=e._networkQuality.totalDownlinkRTTAndLossMap.get(r);if(i){var a=i.totalLoss,o=i.count,s=i.audioDelayCount,c=i.videoDelayCount,u=i.totalAudioDelay,l=i.totalVideoDelay;t.statsToReport.uint32_avg_down_loss=Math.floor(a/o),s&&u&&(t.statsToReport.uint32_audio_network_p2p_delay=Math.floor(u/s),t.audioJitterBufferDelay&&(t.statsToReport.uint32_p2p_delay=Math.floor(t.statsToReport.uint32_audio_network_p2p_delay+t.audioJitterBufferDelay))),c&&l&&(t.statsToReport.uint32_video_network_p2p_delay=Math.floor(l/c))}t.videoCount>0&&(t.statsToReport.uint32_video_avg_fps=Math.floor(t.totalVideoFPS/t.videoCount),t.statsToReport.uint32_video_avg_bitrate=Math.floor(t.totalVideoBitrate/t.videoCount)),t.audioCount>0&&(t.statsToReport.uint32_audio_recv_bitrate=t.statsToReport.uint32_audio_bitrate=Math.floor(t.totalAudioBitrate/t.audioCount)),t.audioLevelCount>0&&(t.statsToReport.uint32_audio_play_db=Math.floor(t.totalAudioLevel/t.audioLevelCount*100));var d=e._room.callDurationCalculator;d&&(t.statsToReport.uint32_audio_play_time=d.getDuration(n,nC.AUDIO),t.statsToReport.uint32_video_play_time=d.getDuration(n,nC.VIDEO)),t.statsToReport.uint32_video_render_first&&(t.statsToReport.uint32_video_render_first=Math.min(t.statsToReport.uint32_video_render_first,jj));var h=e._room.badCaseDetector,f=h.getDataFreezeDuration(n),p=f.dataFreeze,m=f.count,v=h.getRenderFreezeDuration(n).renderFreeze;t.statsToReport.uint32_video_block_count=m,t.statsToReport.uint32_video_block_time=Math.min(p,t.statsToReport.uint32_video_play_time),t.statsToReport.uint32_video_external_block_time=Math.min(v,t.statsToReport.uint32_video_play_time),h.isBlackStream(n)&&0===t.statsToReport.uint32_video_avg_fps?t.statsToReport.uint32_video_black_screen_subjective=1:t.statsToReport.uint32_video_black_screen_subjective=0})),this._pathMainAudioMap.forEach((function(t,n){e.hasAudioFlag(t.userId)?t.statsToReport.uint64_play_first_frame_time-t.statsToReport.uint64_start_enter_time>jj&&(t.statsToReport.uint64_play_first_frame_time=t.statsToReport.uint64_start_enter_time+jj):e._pathMainAudioMap.delete(n)})),this._pathMainVideoMap.forEach((function(t,n){e.hasVideoFlag(t.userId)?t.statsToReport.uint64_render_first_frame_time-t.statsToReport.uint64_start_enter_time>jj&&(t.statsToReport.uint64_render_first_frame_time=t.statsToReport.uint64_start_enter_time+jj):e._pathMainVideoMap.delete(n)})),this._pathJoinRoom.uint64_end_time-this._pathJoinRoom.uint64_start_time>jj&&(this._pathJoinRoom.uint64_end_time=this._pathJoinRoom.uint64_start_time+jj)}},{key:"getReportData",value:function(){this._basicInfo.uint32_networkType=dw();var e={uint32_sdk_app_id:Number(this._room.sdkAppId),msg_user_info:new Gj({userId:this._room.userId,tinyId:this._room.tinyId,role:"anchor"===this._room.role?20:21}),msg_basic_info:this._basicInfo,uint32_acc_ip:Ww(this._signalInfo.relayIp),uint32_client_ip:Ww(this._signalInfo.clientIp,!1),uint32_acc_port:this._signalInfo.relayPort||0,uint64_timestamp:Date.now(),uint32_seq:Math.floor(Math.random()*qA(2,31)),msg_path_enter_room:this._pathJoinRoom,msg_path_exit_room:this._pathLeaveRoom,msg_path_recv_video:E(this._pathMainVideoMap.values()).map((function(e){return e.statsToReport})),msg_quality_statistics:E(this._remoteStreamStatMap.values()).map((function(e){return e.statsToReport})),str_room_name:String(this._room.roomId||0),msg_path_recv_audio:E(this._pathMainAudioMap.values()).map((function(e){return e.statsToReport})),uint32_info_client_ip:Ww(this._signalInfo.clientIp,!1),error_code:[],msg_local_statistics:this._localStreamStat.statsToReport,bytes_report_buf_from_0x1:this._signalInfo.endReportExtend};return nD(e),e}},{key:"report",value:function(){return aR(this,null,f().mark((function e(){var t;return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,this.prepareReport(),t=this.getReportData(),e.next=5,this.upload(t);case 5:this.initData(),e.next=11;break;case 8:e.prev=8,e.t0=e.catch(0),this._log.warn(e.t0);case 11:return e.prev=11,this.isDestroyed&&(this._room=null),e.finish(11);case 14:case"end":return e.stop()}}),e,this,[[0,8,11,14]])})))}},{key:"upload",value:function(e){return aR(this,null,f().mark((function t(){var n,r,i,a,o,s;return f().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(0!==e.msg_path_enter_room.uint64_start_time){t.next=2;break}return t.abrupt("return");case 2:return n=Number(this._room.sdkAppId),t.next=5,oD(e);case 5:return r=t.sent,i=r instanceof ArrayBuffer,a="".concat(ow(n,KR.KEY_POINT),"&gzip=").concat(+i),o=!1,navigator.sendBeacon&&(o=navigator.sendBeacon(a,r)),s=[this.uploadKVStat(bO),this.uploadKVStat(IO)],o||s.push(aD({url:a,body:r,priority:"low"})),t.next=14,Promise.all(s);case 14:case"end":return t.stop()}}),t,this)})))}},{key:"setConnectionType",value:function(e){this.connectionType=e,this._basicInfo.uint32_connection_type=e}},{key:"uploadKVStat",value:function(e){return aR(this,null,f().mark((function t(){var n,r,i,a;return f().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(0!==(n=e.getReportData()).stats_count.length||0!==n.stats_distribution.length){t.next=3;break}return t.abrupt("return");case 3:return n.msg_sdk_basic_info=$A(QA({},n.msg_sdk_basic_info),{bytes_device_name:this._basicInfo.string_device_name||"",bytes_os_version:this._basicInfo.string_os_version||"",uint32_framework:this._frameWorkType,uint32_network_type:this._basicInfo.uint32_networkType||0}),this._log.debug(n),t.next=6,oD(n);case 6:r=t.sent,i="".concat(ow(+this._room.sdkAppId,KR.KV_STAT),"&gzip=").concat(+(r instanceof ArrayBuffer)),a=!1,navigator.sendBeacon&&(a=navigator.sendBeacon(i,r)),a||aD({url:i,body:r});case 10:case"end":return t.stop()}}),t,this)})))}}])}();nR([GP({settings:{timeout:500,retries:3}})],Bj.prototype,"upload",1);var jj=5e3,Hj={msg_user_info:null,uint32_video_avg_fps:0,uint32_video_width:0,uint32_video_height:0,uint32_video_avg_bitrate:0,uint32_video_block_time:0,uint32_video_play_time:0,uint32_audio_block_time:0,uint32_audio_play_time:0,uint32_audio_play_db:0,uint32_avg_down_loss:0,uint32_stream_type:0,uint32_video_block_count:0,uint32_audio_block_count:0,uint32_audio_bitrate:0,uint32_video_black_screen_subjective:0,uint32_audio_recv_bitrate:0,uint32_video_external_block_time:0,uint32_video_consume_render_rate:0},Gj=o((function e(t){r(this,e),rR(this,"str_identifier"),rR(this,"str_tinyid"),rR(this,"uint32_role"),this.str_identifier=String(t.userId),this.str_tinyid=String(t.tinyId||0),this.uint32_role=t.role})),Wj=Bj,Jj=function(){return o((function e(){r(this,e),rR(this,"_startTime"),rR(this,"_endTime"),this._startTime=0,this._endTime=0,this.start()}),[{key:"start",value:function(){0===this._startTime&&(this._startTime=Vw())}},{key:"stop",value:function(){0===this._endTime&&(this._endTime=Vw())}},{key:"getDuration",value:function(){return 0===this._endTime?Vw()-this._startTime:this._endTime-this._startTime}},{key:"startTime",get:function(){return this._startTime}},{key:"endTime",get:function(){return this._endTime}}])}(),Kj=function(){return o((function e(t){r(this,e),rR(this,"_room",null),rR(this,"_durationMap"),rR(this,"_eventMap",new Map),this._room=t.room,this._durationMap=new Map,this.installEvents()}),[{key:"installEvents",value:function(){var e=this;this._eventMap.set(ax.REMOTE_TRACK_SUBSCRIBED,this.handleSubscribed).set(ax.REMOTE_TRACK_UNSUBSCRIBED,this.handleUnsubscribed).set(ax.REMOTE_PUBLISH_STATE_CHANGED,(function(t){var n,r=t.room,i=t.prevMuteState,a=t.muteState,o=a.userId;if(e.hitTest(r)){i.hasAudio&&!a.hasAudio&&e.stopDurationItem("".concat(o,"_main"),nC.AUDIO),i.hasVideo&&!a.hasVideo&&e.stopDurationItem("".concat(o,"_main"),nC.VIDEO),i.hasAuxiliary&&!a.hasAuxiliary&&e.stopDurationItem("".concat(o,"_auxiliary"),nC.VIDEO);var s=null==(n=e._room)?void 0:n.remotePublishedUserMap.get(o);s&&(!i.hasAudio&&a.hasAudio&&s.remoteAudioTrack.isSubscribed&&e.addDuractionItem(o,nC.AUDIO,"main"),!i.hasVideo&&a.hasVideo&&s.remoteVideoTrack.isSubscribed&&e.addDuractionItem(o,nC.VIDEO,"main"),!i.hasAuxiliary&&a.hasAuxiliary&&s.remoteAuxiliaryTrack.isSubscribed&&e.addDuractionItem(o,nC.VIDEO,"auxiliary"))}})),this._eventMap.forEach((function(t,n){return rx.on(n,t,e)}))}},{key:"uninstallEvents",value:function(){var e=this;this._eventMap.forEach((function(t,n){return rx.off(n,t,e)})),this._eventMap.clear()}},{key:"handleSubscribed",value:function(e){var t=e.track;if(this.hitTest(t.room)){var n=t.userId,r=t.streamType,i=t.kind;t.isSubscribed?this.addDuractionItem(n,i,r):this.stopDurationItem("".concat(n,"_").concat(r),i)}}},{key:"handleUnsubscribed",value:function(e){var t=e.track;this.hitTest(t.room)&&this.stopDurationItem("".concat(t.userId,"_").concat(t.streamType),t.kind)}},{key:"isRecording",value:function(e){return e.findIndex((function(e){return 0===e.endTime}))>=0}},{key:"addDuractionItem",value:function(e,t,n){var r="".concat(e,"_").concat(n),i=new Jj,a=this._durationMap.get(r);a?this.isRecording(a[t])||a[t].push(i):this._durationMap.set(r,{userId:e,type:n,audio:t===nC.AUDIO?[i]:[],video:t===nC.AUDIO?[]:[i]})}},{key:"stopDurationItem",value:function(e,t){if(this._durationMap.has(e)){var n=this._durationMap.get(e)[t].find((function(e){return 0===e.endTime}));n&&n.stop()}}},{key:"hitTest",value:function(e){return this._room===e}},{key:"getDuration",value:function(e,t){return this._durationMap.has(e)?this._durationMap.get(e)[t].reduce((function(e,t){return e+t.getDuration()}),0):0}},{key:"getDurationMap",value:function(){return this._durationMap}},{key:"reset",value:function(){this._durationMap.clear()}},{key:"destroy",value:function(){this._room=null,this.uninstallEvents()}}])}(),zj=function(){return o((function e(t){r(this,e),rR(this,"_room"),rR(this,"_renderFreezeMap",new Map),rR(this,"_isVideoPlayingEventFiredMap",new Map),rR(this,"_dataFreezeMap",new Map),rR(this,"_monitorFreezeData",new Map),rR(this,"_eventMap",new Map),this._room=t.room,this.installEvents()}),[{key:"getRenderFreezeMap",value:function(){return this._renderFreezeMap}},{key:"getDataFreezeMap",value:function(){return this._dataFreezeMap}},{key:"installEvents",value:function(){var e=this;this._eventMap.set(ax.LEAVE_SUCCESS,(function(t){var n=t.room;e.hitTest(n)&&e.stop()})).set(ax.PLAY_TRACK_START,this.onPlayTrackStart).set(ax.UNSUBSCRIBE_SUCCESS,(function(t){var n=t.room,r=t.streamType,i=t.remotePublishedUser;if(e.hitTest(n)){var a=i.userId,o="".concat(a,"_").concat(r);e.stopDataFreeze({key:o,userId:a,type:r})}})).set(ax.REMOTE_PUBLISH_STATE_CHANGED,(function(t){var n=t.room,r=t.prevMuteState,i=t.muteState;if(e.hitTest(n)){var a=i.userId;if(r.hasVideo&&!i.hasVideo){var o="main",s="".concat(i.userId,"_").concat(o);e.stopDataFreeze({key:s,userId:a,type:o})}if(r.hasAuxiliary&&!i.hasAuxiliary){var c="auxiliary",u="".concat(i.userId,"_").concat(c);e.stopDataFreeze({key:u,userId:a,type:c})}}})).set(ax.PLAYER_STATE_CHANGED,(function(t){var n=t.track,r=t.state,i=t.reason,a=t.type;if(n.isRemote&&n.room&&e.hitTest(n.room)&&a===nC.VIDEO){if("PLAYING"===r){var o="".concat(n.userId,"_").concat(n.streamType);e._isVideoPlayingEventFiredMap.set(o,!0)}i===nC.MUTE?e.onVideoTrackMuted(n):i===nC.UNMUTE&&e.onVideoTrackUnmuted(n)}})).set(ax.HEARTBEAT_REPORT,this.onHearBeatReport),this._eventMap.forEach((function(t,n){return rx.on(n,t,e)}))}},{key:"uninstallEvents",value:function(){var e=this;this._eventMap.forEach((function(t,n){return rx.off(n,t,e)})),this._eventMap.clear()}},{key:"stop",value:function(){this._renderFreezeMap.clear(),this._dataFreezeMap.clear(),this._isVideoPlayingEventFiredMap.clear()}},{key:"onVideoTrackMuted",value:function(e){if(e.isSubscribed){var t=e.userId,n=e.streamType,r="".concat(t,"_").concat(n),i=this._dataFreezeMap.get(r),a=new Jj;i?i.durationItemList.push(a):this._dataFreezeMap.set(r,{userId:t,type:n,durationItemList:[a],isFreezing:function(){var e=this.durationItemList[this.durationItemList.length-1];return e&&0===e.endTime}})}}},{key:"onVideoTrackUnmuted",value:function(e){if(e.isSubscribed){var t=e.userId,n=e.streamType,r="".concat(t,"_").concat(n);this.stopDataFreeze({key:r,userId:t,type:n})}}},{key:"onHearBeatReport",value:function(e){var t=this,n=e.room,r=e.report;this.hitTest(n)&&r.msg_down_stream_info.forEach((function(e){var n=t._room.remotePublishedUserMap.get(e.msg_user_info.str_identifier);if(n){var r=n.userId,i=n.muteState;e.msg_video_status.forEach((function(e){2===e.uint32_video_stream_type&&i.hasVideo&&!i.videoMuted&&n.remoteVideoTrack.isSubscribed&&t.handleRenderFreeze({userId:r,fps:e.uint32_video_dec_fps,type:"main"}),7===e.uint32_video_stream_type&&i.hasAuxiliary&&n.remoteAuxiliaryTrack.isSubscribed&&t.handleRenderFreeze({userId:r,fps:e.uint32_video_dec_fps,type:"auxiliary"})}))}}))}},{key:"stopDataFreeze",value:function(e){var t=e.key,n=e.userId,r=e.type,i=this._dataFreezeMap.get(t);if(i&&i.isFreezing()){var a=i.durationItemList[i.durationItemList.length-1];a.stop();var o=a.getDuration();o>BC?this._monitorFreezeData.set(t,{userId:n,type:r,duration:o}):i.durationItemList.pop()}}},{key:"getTotalDuration",value:function(e){return e.reduce((function(e,t){var n=t.getDuration();return e+Math.min(n,5e3)}),0)}},{key:"handleRenderFreeze",value:function(e){return aR(this,arguments,(function(e){var t=this,n=e.userId,r=e.fps,i=e.type;return f().mark((function e(){var a,o,s,c,u;return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:a="".concat(n,"_").concat(i),o=t._renderFreezeMap.get(a),r<=2?(s=Vw(),o&&!o.isFreeze&&(o.freezeTimeline.push({startTime:s,endTime:0}),o.isFreeze=!0),o||t._renderFreezeMap.set(a,{userId:n,type:i,isFreeze:!0,freezeTimeline:[{startTime:s,endTime:0}],renderFreezeTotal:0})):o&&o.isFreeze&&(o.isFreeze=!1,(c=o.freezeTimeline.pop())&&(c.endTime=Vw(),u=c.endTime-c.startTime,o.freezeTimeline.push(c),o.renderFreezeTotal+=Math.min(5e3,u)));case 2:case"end":return e.stop()}}),e)}))()}))}},{key:"onPlayTrackStart",value:function(e){var t=e.track;if(t.isRemote&&this.hitTest(t.room)&&t.kind===nC.VIDEO&&t.isRemotePublished){var n="".concat(t.userId,"_").concat(t.streamType);this._isVideoPlayingEventFiredMap.has(n)||this._isVideoPlayingEventFiredMap.set(n,!1)}}},{key:"getDataFreezeDuration",value:function(e){var t={dataFreeze:0,count:0},n=this._dataFreezeMap.get(e);if(n){if(n.isFreezing()){var r=n.durationItemList[n.durationItemList.length-1];r.stop(),r.getDuration()<BC&&n.durationItemList.pop()}t.dataFreeze=this.getTotalDuration(n.durationItemList),t.count=n.durationItemList.length}return t}},{key:"getRenderFreezeDuration",value:function(e){var t=this._renderFreezeMap.get(e),n=0,r=0;if(t)if(t.isFreeze){var i=Vw()-t.freezeTimeline[t.freezeTimeline.length-1].startTime;n=t.renderFreezeTotal+Math.min(i,5e3),r=t.freezeTimeline.length}else n=t.renderFreezeTotal;return{renderFreeze:n,count:r}}},{key:"getMonitorFreeze",value:function(){return this._monitorFreezeData}},{key:"isBlackStream",value:function(e){return!!this._isVideoPlayingEventFiredMap.has(e)&&!this._isVideoPlayingEventFiredMap.get(e)}},{key:"resetMonitor",value:function(){this._monitorFreezeData.clear()}},{key:"hitTest",value:function(e){return e===this._room}},{key:"destroy",value:function(){this.uninstallEvents()}}])}(),Yj=tR(oR(),1),qj=[1,0,0,0,1,1,0,1],Xj=function(e){function t(e,i){var a;if(r(this,t),a=n(this,t,[e,{useDefaultProgram:!0,useFbo:!0,create2d:!0,name:"mirror",logger:i}]),e instanceof hF)try{a.setTexBuffer(qj)}catch(DC){e.destroy(new yR({code:_R.VIDEO_MANAGER_ERROR,extraCode:3,message:"create video node ".concat(a.name," error ").concat(DC.message||DC)}))}return a}return d(t,e),o(t,[{key:"draw2d",value:function(e,n,r,i,a){if(this.ctx2d){this.ctx2d.save(),this.ctx2d.scale(-1,1),this.ctx2d.translate(-this.width,0);var o=g(t,"draw2d",this,3)([e,n,r,i,a]);return this.ctx2d.restore(),o}return!1}},{key:"render",value:function(e){var t;return!(null==(t=this.input)||!t.requestFrame(e)||(this.useProgram(),this.useBufferFrame(),this.useInputTexture(),this.draw(),0))}}])}(ZU),Qj=function(){return o((function e(t,n){r(this,e),this.node=t,this.layout=n,rR(this,"positionBuffer")}),[{key:"x",get:function(){return this.layout.x||this.node.x}},{key:"y",get:function(){return this.layout.y||this.node.y}},{key:"width",get:function(){return this.layout.width||this.node.width}},{key:"height",get:function(){return this.layout.height||this.node.height}},{key:"right",get:function(){return this.x+this.width}},{key:"bottom",get:function(){return this.y+this.height}}])}(),$j=function(e){function i(e,a){var o;return r(this,i),o=n(this,i,[e,{useDefaultProgram:!0,useFbo:!0,name:"mix",create2d:!0,logger:a}]),rR(t(o),"inputs",[]),o}return d(i,e),o(i,[{key:"addInput",value:function(e,t){if(this.inputs[t.zIndex])throw new Error("input already exists");var n=new Qj(e,t);this.inputs[t.zIndex]=n}},{key:"resize",value:function(e,t){var n=this,r=this.inputs.reduce((function(e,t){return t?Object.assign(e,{width:Math.max(e.width,t.right),height:Math.max(e.height,t.bottom)}):e}),{width:0,height:0});g(i,"resize",this,3)([r.width,r.height]),this.context instanceof hF&&this.inputs.forEach((function(e){if(e){var t=n.layout2texCoords(e);e.positionBuffer?n.changeBufferData(e.positionBuffer,t):e.positionBuffer=n.createBuffer(t)}}))}},{key:"connect",value:function(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r];return g(i,"connect",this,3)([e].concat(n)),this.resize(0,0),e}},{key:"removeInput",value:function(e){this.inputs[this.inputs.findIndex((function(t){return(null==t?void 0:t.node)===e}))]=void 0}},{key:"render",value:function(e){var t=this.context.ctx;if(t.clearColor(0,0,0,0),!this.inputs.reduce((function(t,n){return(!n||!n.node.requestFrame(e))&&t}),!0)&&t){this.useProgram(),t.enable(t.BLEND),t.blendFunc(t.SRC_ALPHA,t.ONE_MINUS_SRC_ALPHA),this.useBufferFrame();for(var n=0;n<this.inputs.length;n++){var r=this.inputs[n];r&&(r.node.useTexture(),this.draw(r.positionBuffer))}return!0}return!1}},{key:"render2d",value:function(e){if(!this.inputs.reduce((function(t,n){return(!n||!n.node.requestFrame(e))&&t}),!0)&&this.ctx2d){this.ctx2d.clearRect(0,0,this.width,this.height);for(var t=0;t<this.inputs.length;t++){var n=this.inputs[t];n&&this.draw2d(n.node.image,n.x,n.y,n.width,n.height)}return!0}return!1}},{key:"getInfo",value:function(){var e=this.totalFrames,t=this.x,n=this.y,r=this.width,i=this.height,a=this.name,o=Date.now(),s=(e-this.lastInfo.totalFrames)/((o-this.lastInfo.timestamp)/1e3)|0;return this.lastInfo={totalFrames:e,x:t,y:n,width:r,height:i,timestamp:o,fps:s,name:a},QA({parent:this.inputs.filter((function(e){return e})).map((function(e){return e.node.getInfo()}))},this.lastInfo)}},{key:"close",value:function(){var e=this;g(i,"close",this,3)([]),this.inputs.forEach((function(t){var n,r;if(t&&(null==(n=t.node)||n.disconnect(),t.positionBuffer&&e.context instanceof hF))try{null==(r=e.context.ctx)||r.deleteBuffer(t.positionBuffer)}catch(yx){}}))}}])}(ZU),Zj=function(e){function i(e,a){var o;r(this,i),o=n(this,i,[e,a.input,{name:"vb",create2d:!1,useDefaultProgram:!1,useFbo:!1,createTexture:!0,logger:e.log}]),rR(t(o),"_bgTexture"),rR(t(o),"_waterMarkTexture"),rR(t(o),"_lastMaskTexture"),rR(t(o),"_lastMaskFbo"),rR(t(o),"_textureValid",!1),rR(t(o),"_selfieTextureValid",!1),rR(t(o),"_selfieSegmentation"),rR(t(o),"wasm"),rR(t(o),"_prePrograme"),rR(t(o),"_segmentationMask"),rR(t(o),"_weixin",!1),a.selfieSegmentation&&(o._selfieSegmentation=a.selfieSegmentation,o._selfieSegmentation.onResults=o.onPredict.bind(t(o)));try{o.init(a)}catch(vx){e.log.error(vx),e.destroy(new yR({code:_R.VIDEO_MANAGER_ERROR,extraCode:6,message:"init vb node error ".concat(vx.message||vx)}))}return o}return d(i,e),o(i,[{key:"init",value:function(e){var t=e.Wasm,n=this.context.ctx;if(this.wasm=new t.AllIn1(n),this.wasm.blurRadius=e.blurRadius||3,this.wasm.mirror=!!e.mirror,this.wasm.vbMode="blur"===e.bg?1:e.bg instanceof HTMLImageElement?2:"green"===e.bg?3:0,e.waterMark){var r=e.waterMark,i=r.x,a=r.y,o=r.width,s=r.height;this.wasm.setWaterMark(i,a,o,s)}if(e.beautyParams){var c=e.beautyParams,u=c.beauty,l=c.brightness,d=c.ruddy;this.wasm.setBeauty(u,l,d,null==e?void 0:e.width,null==e?void 0:e.height)}if(this.program=this.wasm.init(),this.useProgram(),this.setAttributes(this.positionBuffer,this.texCoordBuffer),n.uniform1i(n.getUniformLocation(this.program,"mask"),1),e.bg instanceof HTMLImageElement&&(n.uniform1i(n.getUniformLocation(this.program,"bg"),2),this._bgTexture=this.createTexture(e.bg)),e.waterMark&&(n.uniform1i(n.getUniformLocation(this.program,"waterMark"),3),this._waterMarkTexture=this.createTexture(e.waterMark.image)),n.uniform1i(n.getUniformLocation(this.program,"lastMask"),4),this._weixin){var h=this.context.createShader(n.FRAGMENT_SHADER,"#version 300 es\nprecision highp float;\nuniform sampler2D u_texture;\nuniform sampler2D mask;\n\nin vec2 v_texCoord;\nout vec4 outColor;\nvoid main() {\n outColor = vec4(texture(u_texture, v_texCoord).rgb, texture(mask, v_texCoord).a);\n}"),f=this.context.createShader(n.VERTEX_SHADER,"#version 300 es\nin vec2 a_position;\nin vec2 a_texCoord;\nout vec2 v_texCoord;\nvoid main() {\n gl_Position = vec4(a_position.x, a_position.y, 0, 1);\n v_texCoord = a_texCoord;\n}");this._prePrograme=this.context.createProgram(f,h),n.useProgram(this._prePrograme),this.setAttributes(this.positionBuffer,this.texCoordBuffer),n.uniform1i(n.getUniformLocation(this._prePrograme,"mask"),1)}}},{key:"onPredict",value:function(e){var t,n=this.context.ctx;this._weixin&&(this._lastMaskTexture||(this._lastMaskTexture=this.createTexture(this.image),this._lastMaskFbo=this.createFramebuffer(this._lastMaskTexture))),this.useProgram(),this._weixin?this.useTexture():null==this||this._selfieSegmentation.bindTexture(),n.activeTexture(n.TEXTURE1),null==(t=this._selfieSegmentation)||t.bindTexture2d(e),n.activeTexture(n.TEXTURE2),n.bindTexture(n.TEXTURE_2D,this._bgTexture||null),n.activeTexture(n.TEXTURE3),n.bindTexture(n.TEXTURE_2D,this._waterMarkTexture||null),this.useBufferFrame(),n.drawArrays(n.TRIANGLE_STRIP,0,4),this._segmentationMask=e,this.totalFrames++}},{key:"render",value:function(e){var t,n,r,i,a=this.context.ctx,o=this.image;this.tryVideoFrameCallback(o);var s=o.videoWidth,c=o.videoHeight;if(0===s||0===c)return!1;o.width=s,o.height=c;var u=!1;if(this.totalFrames)this._weixin?this.useTexture():null==(t=this._selfieSegmentation)||t.bindTexture(),u=this._selfieTextureValid,this._selfieTextureValid=!0;else{if(!this.program)return!1;this.useTexture(),u=this._textureValid,this._textureValid=!0}return this.width===s&&this.height===c&&u?a.texSubImage2D(a.TEXTURE_2D,0,0,0,a.RGBA,a.UNSIGNED_BYTE,o):(this.resize(s,c),a.texImage2D(a.TEXTURE_2D,0,a.RGBA,a.RGBA,a.UNSIGNED_BYTE,o)),this._weixin&&(a.useProgram(this._prePrograme),this.useTexture(),this._segmentationMask&&(a.activeTexture(a.TEXTURE1),null==(n=this._selfieSegmentation)||n.bindTexture2d(this._segmentationMask),a.bindFramebuffer(a.FRAMEBUFFER,this._lastMaskFbo||null)),a.drawArrays(a.TRIANGLE_STRIP,0,4),null==(r=this._selfieSegmentation)||r.bindTexture(),this._segmentationMask?a.copyTexSubImage2D(a.TEXTURE_2D,0,0,0,0,0,s,c):a.copyTexImage2D(a.TEXTURE_2D,0,a.RGBA,0,0,s,c,0)),null==(i=this._selfieSegmentation)||i.send(s,c),this.totalFrames||(a.activeTexture(a.TEXTURE2),a.bindTexture(a.TEXTURE_2D,this._bgTexture||null),a.activeTexture(a.TEXTURE3),a.bindTexture(a.TEXTURE_2D,this._waterMarkTexture||null),a.drawArrays(a.TRIANGLE_STRIP,0,4)),!1}},{key:"close",value:function(){var e;g(i,"close",this,3)([]);var t=this.context.ctx;this._bgTexture&&t.deleteTexture(this._bgTexture),this._waterMarkTexture&&t.deleteTexture(this._waterMarkTexture),this._lastMaskTexture&&t.deleteTexture(this._lastMaskTexture),this._lastMaskFbo&&t.deleteFramebuffer(this._lastMaskFbo),this._prePrograme&&t.deleteProgram(this._prePrograme),null==(e=this.wasm)||e.close()}}])}(cF),eH=function(e){function i(e){var a;r(this,i),a=n(this,i,[e,{name:"yuv-source",useDefaultProgram:!1,create2d:!1,useFbo:!1,createTexture:!1,logger:e.log,fragmentShaderSource:"\n precision highp float;\n uniform sampler2D ySampler;\n uniform sampler2D uSampler;\n uniform sampler2D vSampler;\n varying highp vec2 textureCoord;\n const mat4 YUV2RGB = mat4(\n 1.1643828125, 0, 1.59602734375, -.87078515625,\n 1.1643828125, -.39176171875, -.81296875, .52959375,\n 1.1643828125, 2.017234375, 0, -1.081390625,\n 0, 0, 0, 1);\n void main() {\n vec3 yuv;\n yuv.r = texture2D(ySampler, textureCoord).r;\n yuv.g = texture2D(uSampler, textureCoord).r;\n yuv.b = texture2D(vSampler, textureCoord).r;\n gl_FragColor = vec4(yuv,1) * YUV2RGB;\n }\n ",vertexShaderSource:"\n attribute vec4 vertexPos;\n attribute vec2 texturePos;\n varying vec2 textureCoord;\n void main() {\n gl_Position = vertexPos;\n textureCoord = texturePos;\n }"}]),rR(t(a),"yTextureRef"),rR(t(a),"uTextureRef"),rR(t(a),"vTextureRef"),rR(t(a),"Y"),rR(t(a),"U"),rR(t(a),"V"),a.useProgram();var o=a.context.ctx;return o.pixelStorei(o.PACK_ALIGNMENT,1),o.pixelStorei(o.UNPACK_ALIGNMENT,1),a.setTexBuffer([0,1,1,1,0,0,1,0]),a.yTextureRef=a._initTexture("ySampler",0),a.uTextureRef=a._initTexture("uSampler",1),a.vTextureRef=a._initTexture("vSampler",2),a._canvas=e._canvas,a}return d(i,e),o(i,[{key:"_initTexture",value:function(e,t){var n=this.context.ctx,r=n.createTexture();return n.bindTexture(n.TEXTURE_2D,r),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MAG_FILTER,n.LINEAR),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MIN_FILTER,n.LINEAR),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_S,n.CLAMP_TO_EDGE),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_T,n.CLAMP_TO_EDGE),n.bindTexture(n.TEXTURE_2D,null),n.uniform1i(n.getUniformLocation(this.program,e),t),r}},{key:"render",value:function(e){var t=this.context.ctx,n=this.width,r=this.height;return this.useProgram(),t.viewport(0,0,n,r),t.activeTexture(t.TEXTURE0),t.bindTexture(t.TEXTURE_2D,this.yTextureRef),t.texSubImage2D(t.TEXTURE_2D,0,0,0,n,r,t.LUMINANCE,t.UNSIGNED_BYTE,this.Y),t.activeTexture(t.TEXTURE1),t.bindTexture(t.TEXTURE_2D,this.uTextureRef),t.texSubImage2D(t.TEXTURE_2D,0,0,0,n/2,r/2,t.LUMINANCE,t.UNSIGNED_BYTE,this.U),t.activeTexture(t.TEXTURE2),t.bindTexture(t.TEXTURE_2D,this.vTextureRef),t.texSubImage2D(t.TEXTURE_2D,0,0,0,n/2,r/2,t.LUMINANCE,t.UNSIGNED_BYTE,this.V),this.draw(),!0}},{key:"resize",value:function(e,t){g(i,"resize",this,3)([e,t]);var n=this.context.ctx;n.activeTexture(n.TEXTURE0),n.bindTexture(n.TEXTURE_2D,this.yTextureRef),n.texImage2D(n.TEXTURE_2D,0,n.LUMINANCE,e,t,0,n.LUMINANCE,n.UNSIGNED_BYTE,null),n.activeTexture(n.TEXTURE1),n.bindTexture(n.TEXTURE_2D,this.uTextureRef),n.texImage2D(n.TEXTURE_2D,0,n.LUMINANCE,e/2,t/2,0,n.LUMINANCE,n.UNSIGNED_BYTE,null),n.activeTexture(n.TEXTURE2),n.bindTexture(n.TEXTURE_2D,this.vTextureRef),n.texImage2D(n.TEXTURE_2D,0,n.LUMINANCE,e/2,t/2,0,n.LUMINANCE,n.UNSIGNED_BYTE,null)}}])}(ZU),tH=[function(e){e.codec="avc1.420028"},function(e){delete e.hardwareAcceleration}],nH=function(e,t){switch(e){case"webCodecs":return"videoFrame"===t?514705:514706;case"wasm":return"webgl"===t?514707:"videoFrame"===t?514708:514709}throw new Error("decoder type not supported")},rH=0,iH=function(){return o((function e(t){var n=this;r(this,e),rR(this,"id",rH++),rR(this,"trackDoneOB"),rR(this,"startOB"),rR(this,"stopOB"),rR(this,"decoder"),rR(this,"videoContext"),rR(this,"gop",0),rR(this,"gop_helper",0),rR(this,"waitFirstKeyFrame",!0),rR(this,"startTimestamp",0),rR(this,"startTime",0),rR(this,"startPerformanceTime",0),rR(this,"inputFrameCount",0),rR(this,"decodedFrameCount",0),rR(this,"decodeFrameCount",0),rR(this,"downgradeLevel",0),rR(this,"lastDowngradeTime",0),rR(this,"lastFrameDiff",0),rR(this,"lastDecodeFrameTimestamp",0),rR(this,"config"),rR(this,"gop_before_configure",[]),rR(this,"videoElement"),rR(this,"type","wasm"),rR(this,"goodType"),rR(this,"renderer","2d"),rR(this,"wasmOption"),rR(this,"createDecoder"),rR(this,"_decodeSink"),rR(this,"isReported",!1),rR(this,"track"),rR(this,"stateChangeOB"),rR(this,"failedReason");var i=t.track,a=t.createDecoder;if(this.stateChangeOB=fV(),this.track=i,this.createDecoder=a,this.wasmOption={yuvMode:"webgl"===t.renderer,wasmPath:t.wasmPath,workerMode:t.workerMode,canvas:t.canvas},this.config=t.config,this.videoElement=t.videoElement,this.renderer=t.renderer,this.trackDoneOB=SV(i.availableState,wP.OFF),this.stopOB=fV(this.trackDoneOB),"auto"===t.type){switch(t.fallback){case"wasm":this.type="wasm",this.renderer="webgl";break;case"wasm_2d":this.type="wasm",this.renderer="2d";break;case"wasm_video":this.type="wasm",this.renderer="videoFrame";break;default:this.type="webCodecs"}this.wasmOption.yuvMode="webgl"===this.renderer}else this.type=t.type;this.changeRenderer(this.renderer),KL(this.stateChangeOB,fU((function(e,t){return e!==t&&i.onDecodeDowngradeStateChanged({type:n.type,renderer:n.renderer,reason:n.failedReason,prevState:e,state:t}),t}),"INITIALIZED"),JV(this.stopOB),WU()),this.start()}),[{key:"start",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;this.waitFirstKeyFrame=!0,this.stateChangeOB.next("STARTING");var n=KL(this.pipe(this.track),JV(this.stopOB),eV());KL(n,WU((function(){e.track.stat.framesDecoded++}),(function(n){if(e.track.log.error("".concat(e.id," play failed: ").concat(n," retryCount: ").concat(t)),bO.addFailedEvent({key:nH(e.type,e.renderer),error:n}),t>4)e.failedReason=n,e.stateChangeOB.next("FAILED");else{if(e.goodType)return void e.start(t);switch(e.type){case"webCodecs":e.type="wasm",e.changeRenderer("webgl");break;case"wasm":"webgl"===e.renderer&&e.changeRenderer("videoFrame")}e.start(t+1)}}),(function(){e.track.log.warn("".concat(e.id," decoderOB completed")),bO.addSuccessEvent({key:nH(e.type,e.renderer)}),bO.addSuccessEvent({key:514704})}))),KL(n,WV(1),WU((function(){e.track.player.handlePlaying("canvas"),e.goodType=e.type,e.stateChangeOB.next("STARTED")})))}},{key:"mock",value:function(e){this._decodeSink?this._decodeSink.error(e):this.start()}},{key:"close",value:function(e){this.stopOB.next(e)}},{key:"changeRenderer",value:function(e){this.renderer=e,"videoFrame"===this.renderer&&!PO()&&(this.renderer="2d"),this.wasmOption.yuvMode="webgl"===this.renderer}},{key:"decode",value:function(e){var t,n,r=this,i=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(!this.failedReason){this.inputFrameCount++;var a,o=new Uint8Array(e.data);if(0!==(a=o)[0]||0!==a[1]||0!==a[2]||1!==a[3]||o.length<5)return this.stateChangeOB.next("FAILED"),this.close("not h26x frame ".concat(o.subarray(0,5))),e;var s=!1;switch(31&o[4]){case 5:case 7:s=!0}if("configured"!==(null==(t=this.decoder)?void 0:t.state))return this.track.log.debug("not configured ".concat(this.inputFrameCount)),s&&(this.gop_before_configure=[]),this.gop_before_configure.push({data:e.data,timestamp:e.timestamp,type:e.type}),e;this.gop_before_configure.length>0&&!i&&(this.gop_before_configure.forEach((function(e){return r.decode(e,!0)})),this.gop_before_configure=[]);var c=e.timestamp;if(s?(this.gop=this.gop_helper,this.gop_helper=0):this.gop_helper++,this.decoder){if(this.waitFirstKeyFrame){if(!s)return void this.track.log.debug("wait first key frame ".concat(this.inputFrameCount," ").concat(o.subarray(0,5).join(" ")));this.waitFirstKeyFrame=!1,this.startTimestamp=c,this.startTime=Date.now(),this.startPerformanceTime=Vw()}switch(this.downgradeLevel){case 0:case 1:break;case 2:if(this.gop_helper>this.gop>>1)return;break;case 3:if(this.gop_helper>0)return;break;default:return}return(this.decodeFrameCount<10||this.decodeFrameCount%500==0)&&this.track.log.debug("decode ".concat(this.decodeFrameCount," gop: ").concat(this.gop," ").concat(c," ").concat(null==(n=e.getMetadata)?void 0:n.call(e).rtpTimestamp)),this.decodeFrameCount++,this.lastDecodeFrameTimestamp=c,void this.decoder.decode({data:e.data,type:e.type,timestamp:this.lastDecodeFrameTimestamp})}return e}}},{key:"checkDowngradeByFrameDiff",value:function(){var e=this.downgradeLevel,t=this.decodeFrameCount-this.decodedFrameCount;t>this.lastFrameDiff?(this.downgradeLevel++,this.downgradeLevel>4&&(this.downgradeLevel=4)):t<=this.lastFrameDiff&&this.downgradeLevel>0&&this.downgradeLevel--,this.downgradeLevel!==e&&this.track.log.debug("downgrade level ".concat(e," to ").concat(this.downgradeLevel," ").concat(this.decodeFrameCount," frameDiff: ").concat(t,", lastFrameDiff: ").concat(this.lastFrameDiff)),this.lastFrameDiff=t,this.lastDowngradeTime=Date.now()}},{key:"checkDowngradeByTimestampDiff",value:function(e){var t=this.downgradeLevel;this.lastDecodeFrameTimestamp-e>9e4?(this.downgradeLevel++,this.downgradeLevel>4&&(this.downgradeLevel=4)):this.downgradeLevel>0&&this.downgradeLevel--,this.downgradeLevel!==t&&this.track.log.debug("downgrade level ".concat(t," to ").concat(this.downgradeLevel))}},{key:"pipe",value:function(e){var t=this;return function(n){return aR(t,null,f().mark((function t(){var r,i,a,o,s,c,u,l,d,h,p,m=this;return f().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:this._decodeSink=n,i=e.mediaTrack,n.defer((function(){var t;e.player.setCanvas(),e.setInputMediaStreamTrack(i),null==r||r.close(),null==(t=m.videoContext)||t.destroy(),delete m._decodeSink})),a=this.renderer,o=this.type,e.log.info("decoder type: ".concat(this.type," renderer: ").concat(this.renderer)),t.prev=5,t.t0=o,t.next="wasm"===t.t0?9:"webCodecs"===t.t0?11:27;break;case 9:return r=this.createDecoder(o,this.wasmOption),t.abrupt("break",28);case 11:s=0;case 12:if(!(s<=tH.length)){t.next=25;break}return t.next=15,VideoDecoder.isConfigSupported(this.config);case 15:if(!t.sent.supported){t.next=19;break}return t.abrupt("break",25);case 19:if(s!==tH.length){t.next=21;break}return t.abrupt("return",void n.error(3));case 21:tH[s](this.config);case 22:s++,t.next=12;break;case 25:return r=this.createDecoder(o),t.abrupt("break",28);case 27:throw new Error("not supported yet");case 28:return c=0,r.on("videoFrame",(function(t){m.decodedFrameCount++,(++c<=10||c%500==0)&&e.log.debug("frame ".concat(c," ").concat(m.decodedFrameCount,"/").concat(m.decodeFrameCount," decoded ").concat(t.timestamp)),Date.now()-m.lastDowngradeTime>5e3&&("webCodecs"===m.type?m.checkDowngradeByFrameDiff():"wasm"===m.type&&m.checkDowngradeByTimestampDiff(t.timestamp)),n.next(t)})),r.on("error",(function(t){e.log.error(t),n.error("webCodecs"===o?4:8)})),t.next=33,r.initialize(this.videoElement);case 33:if(this._decodeSink){t.next=35;break}return t.abrupt("return");case 35:r.configure(this.config),"wasm"===o&&"webgl"===a?(this.videoContext=new hF({frameRate:15,logger:e.log,name:e.userId}),this.videoContext.create(),this.videoContext.on(hF.UNAVAILABLE,(function(t){e.log.error(t),n.error(7)})),u=new eH(this.videoContext),r.on("videoCodecInfo",(function(e){return u.resize(e.width,e.height)})),r.on("videoFrame",(function(e){u.Y=e.y,u.U=e.u,u.V=e.v,1===m.downgradeLevel?m.decodedFrameCount%2==0&&u.render(m.decodedFrameCount):u.render(m.decodedFrameCount)})),e.source=u,e.player.setCanvas(this.videoContext._canvas,2)):"videoFrame"===a?(e.player.setCanvas(),l=new MediaStreamTrackGenerator({kind:"video"}),d=l.writable.getWriter(),e.setInputMediaStreamTrack(l),r.on("videoFrame",(function(e){return d.write(e)}))):(this.videoContext=new fF({frameRate:15,logger:e.log,name:e.userId}),this.videoContext.create({alpha:!1}),h=this.videoContext.createVideoImageSource(),r.on("videoFrame",(function(e){h.image=e,h.update()})),p=new nF(this.videoContext,{name:"remotePlayer",logger:e.log}),h.connect(p),e.source=h,e.player.setCanvas(this.videoContext._canvas,2)),this.decoder=r,t.next=42;break;case 39:t.prev=39,t.t1=t.catch(5),e.log.error(t.t1),n.error("webCodecs"===o?2:6);case 42:case"end":return t.stop()}}),t,this,[[5,39]])})))}}}])}(),aH=function(e){function i(e){var a;return r(this,i),(a=n(this,i)).room=e,rR(t(a),"videoContext"),rR(t(a),"_glVideoContext"),rR(t(a),"_2dVideoContext"),rR(t(a),"destination"),rR(t(a),"smallVideoContext"),rR(t(a),"smallDestination"),rR(t(a),"smallTrackSource"),rR(t(a),"smallImageSource"),rR(t(a),"_isMirror",!1),rR(t(a),"cameraTrack"),rR(t(a),"cameraNode"),rR(t(a),"mirrorNode"),rR(t(a),"mixNode"),rR(t(a),"screenTrack"),rR(t(a),"screenNode"),rR(t(a),"selfModel",!1),rR(t(a),"blurRadius",3),rR(t(a),"arTrack"),rR(t(a),"Wasm"),rR(t(a),"waterMarkNode"),rR(t(a),"_waterMarkOption"),rR(t(a),"watermarkImageList",[]),rR(t(a),"_beautyParams"),rR(t(a),"isUsingArTrack",!1),rR(t(a),"_isMixScreen",!1),rR(t(a),"_virtualBackground"),rR(t(a),"_virtualBackgroundAbortCallback"),rR(t(a),"virtualBackgroundInstance"),rR(t(a),"_bgAssetPath"),rR(t(a),"log",sx.createLogger({id:"vm"})),rR(t(a),"_checkId",0),rR(t(a),"_use2d",!1),rR(t(a),"_autoSwitchRenderMode",!0),rR(t(a),"_selfieSegmentation"),rR(t(a),"encodePipeline",[]),rR(t(a),"decodePipeline",[]),e&&(a.log.setUserId(e.userId),a.log.setSdkAppId(e.sdkAppId)),a.smallVideoContext=new fF({frameRate:15,logger:a.log,name:"s"}),a.enablePrintDetail(),a}return d(i,e),o(i,[{key:"_hasVirtualBg",get:function(){return!!this._virtualBackground}},{key:"_hasWaterMark",get:function(){return this.watermarkImageList.length>0}},{key:"renderMode",get:function(){return this._autoSwitchRenderMode?"auto":this._use2d?"2d":"webgl"},set:function(e){if(this._autoSwitchRenderMode="auto"===e,!this._autoSwitchRenderMode){var t="2d"===e;this._use2d!==t&&(this._use2d=t,this.clear(),this.videoContext=this._use2d?this.get2dVideoContext():this.getGlVideoContext(),this.update())}}},{key:"get2dVideoContext",value:function(){return this._2dVideoContext?this._2dVideoContext.destroy():this._2dVideoContext=new fF({frameRate:15,logger:this.log,name:"m"}),this._2dVideoContext.create({alpha:this._hasWaterMark||this._hasVirtualBg}),this._2dVideoContext}},{key:"getGlVideoContext",value:function(){if(this._glVideoContext){if(this._glVideoContext.available)return this._glVideoContext}else this._glVideoContext=new hF({frameRate:15,logger:this.log,name:"m"});return this.initializeGlVideoContext(),this._glVideoContext}},{key:"initializeGlVideoContext",value:function(){var e=this;try{this._glVideoContext.create(),this._glVideoContext.on(hF.UNAVAILABLE,(function(t){var n;e.emit("error",t),e.log.warn("video context unavailable",t),null==(n=e._virtualBackgroundAbortCallback)||n.call(e,t),e.update().catch((function(t){e.log.error(t)}))}))}catch(wR){this.emit("error",wR)}}},{key:"enablePrintDetail",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:2e3;this._checkId=MP.run("interval",(function(){e.destination&&e.log.debug(e.destination.getInfo())}),{delay:t})}},{key:"destroy",value:function(){var e,t;null==(e=this._2dVideoContext)||e.destroy(),null==(t=this._glVideoContext)||t.destroy(),this.smallVideoContext.destroy(),MP.clearTask(this._checkId)}},{key:"needAlpha",get:function(){return this._hasWaterMark||this._hasVirtualBg}},{key:"active",get:function(){return(ON||this._isMixScreen||this._isMirror||this._hasWaterMark||this._hasVirtualBg||this._beautyParams)&&this.checkOrCreateVideoContext()}},{key:"sendCreateResult",value:function(){var e=arguments.length>1?arguments[1]:void 0,t="videoCtxGl"===(arguments.length>0&&void 0!==arguments[0]?arguments[0]:"videoCtxGl")?512700:512701;e?bO.addFailedEvent({key:t,error:e}):bO.addSuccessEvent({key:t})}},{key:"checkOrCreateVideoContext",value:function(){var e=this._use2d;if(this._autoSwitchRenderMode&&(this._use2d=!this._hasVirtualBg),this.videoContext)if(this.videoContext.available){var t=!this.videoContext.hasAlpha&&this.needAlpha;if(this._autoSwitchRenderMode&&e===this._hasVirtualBg)this.clear();else{if(!t)return!0;if(!this._use2d)return!0;this.clear()}}else{if(this._glVideoContext=new hF({frameRate:15,logger:this.log,name:"m"}),this.initializeGlVideoContext(),this._glVideoContext.available)return this.videoContext=this._glVideoContext,this.videoContext.available;this.log.warn("webgl is still not available"),this.clear(),this._use2d=!0}return this.videoContext=this._use2d?this.get2dVideoContext():this.getGlVideoContext(),this.videoContext.available}},{key:"smallTrack",get:function(){var e;return null==(e=this.smallDestination)?void 0:e.videoTrack}},{key:"hasSmall",get:function(){return!!this.smallTrack}},{key:"initialTrack",get:function(){var e;return null==(e=this.cameraTrack)?void 0:e.mediaTrack}},{key:"initVirtualBackground",value:function(e){return this._selfieSegmentation=e,this._selfieSegmentation.changeModel()}},{key:"setSmallVideo",value:function(e,t){var n=this;if(e){if(!this.smallVideoContext.available){if(this.smallVideoContext.create({alpha:!1}),!this.smallVideoContext.available)return;this.smallDestination=new aF(this.smallVideoContext,e,this.log),this.smallVideoContext.on(hF.UNAVAILABLE,(function(e){n.log.warn("small video context lost",e)}))}this.smallVideoContext.frameRate=e.frameRate,this.smallDestination.resolution=e,t?(this.smallTrackSource&&(this.smallTrackSource.close(),delete this.smallTrackSource),this.smallImageSource?this.smallImageSource.image=t:(this.smallImageSource=this.smallVideoContext.createVideoImageSource(t),this.smallImageSource.connect(this.smallDestination))):(this.smallImageSource&&(this.smallImageSource.close(),delete this.smallImageSource),this.smallTrackSource?this.smallTrackSource.replaceTrack(this.initialTrack):(this.smallTrackSource=this.smallVideoContext.createVideoTrackSource(this.initialTrack,"smallTrackSource"),this.smallTrackSource.connect(this.smallDestination)))}else this.smallVideoContext.available&&(this.smallVideoContext.destroy(),delete this.smallDestination,delete this.smallTrackSource,delete this.smallImageSource)}},{key:"_setMainOutput",value:function(e){var t;try{var n=this.cameraTrack,r=n.small,i=n.player;this.setSmallVideo(r,e),ON&&i.setCanvas(e);var a=e&&(null==(t=this.destination)?void 0:t.videoTrack)||this.initialTrack;return this.isUsingArTrack&&this.arTrack&&(this.emit("output-track-changed"),a=this.arTrack),this._selfieSegmentation&&e&&!this._use2d&&(this._selfieSegmentation._glName||this._selfieSegmentation.setCanvas(e)),this.log.info("set main output ".concat(a?a.label:"no output track")),n.setOutputMediaStreamTrack(a)}catch(vx){this.log.error("set main output failed",vx)}}},{key:"update",value:function(){return aR(this,null,f().mark((function e(){var t,n,r,i,a,o;return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.cameraTrack&&this.cameraTrack.mediaTrack){e.next=2;break}return e.abrupt("return");case 2:if(this.active){e.next=4;break}return e.abrupt("return",(this.cameraNode&&this.clear(),this._setMainOutput()));case 4:return r=this.cameraTrack,i=r.settings,a=r.profile,this._use2d||!this._virtualBackground&&!this._beautyParams?(this.destination||(this.destination=this.videoContext.createVideoTrackDestination({name:"mainDestination2d",logger:this.log})),16===VN?this.initialTrack instanceof CanvasCaptureMediaStreamTrack?(this.cameraNode&&(this.cameraNode instanceof cF?(this.cameraNode.close(),delete this.cameraNode):this.cameraNode.image=this.initialTrack.canvas),this.cameraNode||(this.cameraNode=this.videoContext.createVideoImageSource(this.initialTrack.canvas,{name:"cameraCanvasSource",logger:this.log}))):(this.cameraNode&&(this.cameraNode instanceof cF?this.cameraNode.replaceTrack(this.initialTrack):(this.cameraNode.close(),delete this.cameraNode)),this.cameraNode||(this.cameraNode=this.videoContext.createVideoTrackSource(this.initialTrack,"cameraTrackSource"))):this.cameraNode?this.cameraNode.replaceTrack(this.initialTrack):this.cameraNode=this.videoContext.createVideoTrackSource(this.initialTrack,"cameraNodeSource"),this.cameraNode.resize(i.width,i.height)):(this.cameraNode&&this.cameraNode.close(),this.destination?this.destination.disableCheckMute():this.destination=new iF(this.videoContext,{name:"mainDestination",logger:this.log}),this.cameraNode=new Zj(this.videoContext,{input:this.cameraTrack.mediaTrack,width:i.width,height:i.height,mirror:this._isMirror,bg:this._virtualBackground,selfModel:this.selfModel,waterMark:this._waterMarkOption,beautyParams:this._beautyParams,useTflite:!0,blurRadius:this.blurRadius,assetPath:this._bgAssetPath,selfieSegmentation:this._selfieSegmentation,Wasm:this.Wasm}),this.cameraNode.connect(this.destination),this.destination.enableCheckMute()),this.videoContext.frameRate=a.frameRate,this._use2d&&((o=this.cameraNode).disconnect(),this._isMirror&&(this.mirrorNode||(this.mirrorNode=new Xj(this.videoContext,this.log)),(o=o.connect(this.mirrorNode)).disconnect(),this.log.info("start mirror")),this.mixNode&&this.mixNode.close(),delete this.mixNode,(this._isMixScreen||this._hasWaterMark)&&(this.mixNode=new $j(this.videoContext,this.log),o.connect(this.mixNode,{zIndex:1}),this._hasWaterMark&&!this.waterMarkNode&&this._waterMarkOption&&(this.waterMarkNode=this.videoContext.createVideoImageSource(this._waterMarkOption.image,{autoResize:!1,logger:this.log}),this.waterMarkNode.resize(this._waterMarkOption.width,this._waterMarkOption.height),this.waterMarkNode.x=this._waterMarkOption.x,this.waterMarkNode.y=this._waterMarkOption.y),null==(t=this.waterMarkNode)||t.connect(this.mixNode,{zIndex:2}),this._isMixScreen&&this.screenTrack&&!this.screenNode&&(this.screenNode=this.videoContext.createVideoTrackSource(this.screenTrack.mediaTrack,"screenNodeSource")),null==(n=this.screenNode)||n.connect(this.mixNode,{zIndex:0}),o=this.mixNode,this.log.info("start mix","".concat(this.mixNode.width,"x").concat(this.mixNode.height))),o.connect(this.destination)),e.abrupt("return",(this.log.info("update ".concat(this._use2d?"2d":"webgl")),this._setMainOutput(this.videoContext._canvas)));case 7:case"end":return e.stop()}}),e,this)})))}},{key:"changeInput",value:function(e){var t,n,r,i;if(e instanceof wL)return this.log.info("change screen input",null==(t=e.mediaTrack)?void 0:t.label),this.setScreenTrack(e);if(e instanceof AL)return this.log.info("change video input",null==(n=e.mediaTrack)?void 0:n.label),this.setCameraTrack(e);if(e instanceof pF){this.log.info("change remote input",null==(r=e.mediaTrack)?void 0:r.label);var a=e.mediaTrack;return e.setOutputMediaStreamTrack(a)}this.log.warn("change unknown input",null==(i=e.mediaTrack)?void 0:i.label)}},{key:"removeInput",value:function(e){var t;e instanceof wL?(null==(t=this.screenNode)||t.close(),delete this.screenNode,delete this.screenTrack,this.update()):e instanceof AL?(this.clear(),delete this.cameraTrack,this.smallImageSource&&(this.smallImageSource.close(),delete this.smallImageSource),this.smallTrackSource&&(this.smallTrackSource.close(),delete this.smallTrackSource)):e instanceof pF&&e.source&&e.source.context.destroy()}},{key:"setCameraTrack",value:function(e){return aR(this,null,f().mark((function t(){return f().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:this.cameraTrack=e,this.update();case 1:case"end":return t.stop()}}),t,this)})))}},{key:"setScreenTrack",value:function(e){return this.screenTrack=e,this._isMixScreen&&(this.screenNode?this.screenNode.replaceTrack(e.mediaTrack):this.update()),e.setOutputMediaStreamTrack(e.mediaTrack)}},{key:"getWatermarkImage",value:function(e,t){return aR(this,null,f().mark((function n(){var r,i;return f().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(r=document.createElement("canvas"),t&&e&&(r.height=t,r.width=e),i=r.getContext("2d")){n.next=5;break}throw new yR({code:_R.NOT_SUPPORTED,message:"Make image failed because of canvas context is null"});case 5:return n.abrupt("return",(this.watermarkImageList.sort((function(e,t){return e.zIndex-t.zIndex})),this.watermarkImageList.forEach((function(e){var t=e.image,n=e.x,r=e.y,a=e.width,o=e.height;i.drawImage(t,n,r,a,o)})),eD(r.toDataURL())));case 6:case"end":return n.stop()}}),n,this)})))}},{key:"pushWaterMarkImageList",value:function(e){var t=e.type;this.watermarkImageList.some((function(t){return t.imageUrl===e.imageUrl&&t.height===e.height&&t.width===e.width&&t.x===e.x&&t.y===e.y&&t.type===e.type&&t.zIndex===e.zIndex}))||(("mute"===t||"watermark"===t)&&(this.watermarkImageList=this.watermarkImageList.filter((function(e){return e.type!==t}))),this.watermarkImageList.push(e))}},{key:"setBeautyParams",value:function(e){return aR(this,null,f().mark((function t(){return f().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:this._beautyParams=e,this.update();case 1:case"end":return t.stop()}}),t,this)})))}},{key:"stopBeauty",value:function(){return aR(this,null,f().mark((function e(){return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._beautyParams=void 0,this.update();case 1:case"end":return e.stop()}}),e,this)})))}},{key:"setWatermark",value:function(e){return aR(this,null,f().mark((function t(){var n,r,i,a,o,s,c,u,l,d,h,p,m,v,_;return f().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,eD((null==e?void 0:e.imageElement)||e.imageUrl);case 3:i=t.sent,t.next=9;break;case 6:throw t.prev=6,t.t0=t.catch(0),new yR({code:_R.INVALID_PARAMETER,message:"load image failed, url: ".concat(e.imageUrl)});case 9:if(a=e.x,o=void 0===a?0:a,s=e.y,c=void 0===s?0:s,u=e.width,l=void 0===u?i.width:u,d=e.height,h=void 0===d?i.height:d,p=e.type,m=void 0===p?"watermark":p,v=e.zIndex,_=void 0===v?2:v,!this.watermarkImageList.some((function(e){return e.type===m}))){t.next=20;break}return this.watermarkImageList=this.watermarkImageList.filter((function(e){return e.type!==m})),this.pushWaterMarkImageList({x:o,y:c,width:l,height:h,image:i,zIndex:_,type:m,imageUrl:e.imageUrl}),t.next=15,this.getWatermarkImage(null==(n=this.cameraTrack)?void 0:n.settings.width,null==(r=this.cameraTrack)?void 0:r.settings.height);case 15:i=t.sent,this._waterMarkOption={x:0,y:0,width:i.width,height:i.height,image:i},this.waterMarkNode?(this.waterMarkNode.x=0,this.waterMarkNode.y=0,this.waterMarkNode.resize(i.width,i.height),this.waterMarkNode.image=i):this.update(),t.next=23;break;case 20:return this.pushWaterMarkImageList({x:o,y:c,width:l,height:h,image:i,zIndex:_,type:m,imageUrl:e.imageUrl}),t.next=23,this.freshWatermark();case 23:this.log.info("set watermark",JSON.stringify(this.watermarkImageList,(function(e,t){return"imageUrl"===e?void 0:t})));case 24:case"end":return t.stop()}}),t,this,[[0,6]])})))}},{key:"deleteWatermark",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"watermark";return aR(this,null,f().mark((function t(){return f().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return this.watermarkImageList=this.watermarkImageList.filter((function(t){return t.type!==e})),this.log.info("delete watermark",e,JSON.stringify(this.watermarkImageList,(function(e,t){return"imageUrl"===e?void 0:t}))),t.next=4,this.freshWatermark();case 4:case"end":return t.stop()}}),t,this)})))}},{key:"freshWatermark",value:function(){return aR(this,null,f().mark((function e(){var t,n,r,i;return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return null==(t=this.waterMarkNode)||t.close(),delete this.waterMarkNode,delete this._waterMarkOption,e.next=3,this.getWatermarkImage(null==(n=this.cameraTrack)?void 0:n.settings.width,null==(r=this.cameraTrack)?void 0:r.settings.height);case 3:i=e.sent,this._waterMarkOption={x:0,y:0,width:i.width,height:i.height,image:i},this.update();case 5:case"end":return e.stop()}}),e,this)})))}},{key:"setVirtualBackground",value:function(e){return aR(this,null,f().mark((function t(){return f().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!e){t.next=13;break}if(e.onAbort&&(this._virtualBackgroundAbortCallback=e.onAbort),!this._use2d||this._autoSwitchRenderMode){t.next=3;break}return t.abrupt("return",Promise.reject(new Error("not support virtual background in 2d mode")));case 3:if(this._bgAssetPath=e.assetPath,"image"!==e.type){t.next=10;break}return t.next=7,eD(e.imageUrl);case 7:this._virtualBackground=t.sent,t.next=11;break;case 10:this.blurRadius=e.blurLevel||this.blurRadius||3,this._virtualBackground=e.type;case 11:t.next=14;break;case 13:delete this._virtualBackground,delete this._virtualBackgroundAbortCallback;case 14:return this.log.info("".concat(this._virtualBackground?"start":"stop"," virtual background, ").concat((null==e?void 0:e.type)||"",", ").concat(this.blurRadius||"")),t.next=17,this.update();case 17:if(!this._virtualBackground||this._glVideoContext.available){t.next=19;break}throw new yR({code:_R.INVALID_OPERATION,message:"webgl context create failed, ".concat(this._glVideoContext.error)});case 19:case"end":return t.stop()}}),t,this)})))}},{key:"mixScreen",get:function(){return this._isMixScreen},set:function(e){var t;this._isMixScreen=e,this._isMixScreen||(null==(t=this.screenNode)||t.close(),delete this.screenNode),this.update()}},{key:"mirror",get:function(){return this._isMirror},set:function(e){var t;this._isMirror!==e&&(this._isMirror=e,this._isMirror||(null==(t=this.mirrorNode)||t.close(),delete this.mirrorNode),this.update())}},{key:"enableAr",value:function(e){this.arTrack=e,this.isUsingArTrack=!0,this.update()}},{key:"updateAr",value:function(){return aR(this,null,f().mark((function e(){var t;return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(e.t0=null!=(t=this.cameraTrack)&&t.mediaTrack,!e.t0){e.next=4;break}return e.next=4,this.virtualBackgroundInstance.ar.updateInputTrack(this.cameraTrack.mediaTrack.clone());case 4:case"end":return e.stop()}}),e,this)})))}},{key:"disableAr",value:function(){var e;this.isUsingArTrack=!1,null==(e=this.arTrack)||e.stop(),this.arTrack=void 0,this.update()}},{key:"createDecodeContext",value:function(e){return new iH(e)}},{key:"clear",value:function(){var e;null==(e=this.videoContext)||e.disconnect(),delete this.destination,delete this.cameraNode,delete this.mirrorNode,delete this.screenNode,delete this.waterMarkNode}},{key:"addEncodeProcessor",value:function(e){var t,n=e.processor,r=e.type;this.encodePipeline.includes(n)||(this.encodePipeline[r]=n,null==(t=this.room)||t.enableInsertableStreams())}},{key:"addDecodeProcessor",value:function(e){var t,n=e.processor,r=e.type;this.decodePipeline.includes(n)||(this.decodePipeline[r]=n,null==(t=this.room)||t.enableInsertableStreams())}},{key:"removeEncodeProcessor",value:function(e){var t=e.type;this.encodePipeline[t]=void 0}},{key:"removeDecodeProcessor",value:function(e){var t=e.type;this.decodePipeline[t]=void 0}}])}(Yj.EventEmitter);nR([cL((function(e){this.log.error("update failed",e)}))],aH.prototype,"update",1);var oH=0,sH=function(e){function i(e){var a;return r(this,i),a=n(this,i,["room"]),rR(t(a),"seq",++oH),rR(t(a),"sdkAppId"),rR(t(a),"userId"),rR(t(a),"userSig"),rR(t(a),"privateMapKey"),rR(t(a),"latencyLevel"),rR(t(a),"tinyId"),rR(t(a),"scene"),rR(t(a),"roomId"),rR(t(a),"useStringRoomId"),rR(t(a),"role","anchor"),rR(t(a),"joinParams",null),rR(t(a),"localTracks",new Set),rR(t(a),"enableAutoPlayDialog",!0),rR(t(a),"autoReceiveAudio",!0),rR(t(a),"autoReceiveVideo",!0),rR(t(a),"proxy_ws"),rR(t(a),"proxy_wt"),rR(t(a),"proxy_unified"),rR(t(a),"checkSystemResult",{result:!0,detail:{isBrowserSupported:!0,isWebRTCSupported:!0,isWebCodecsSupported:!0,isMediaDevicesSupported:!0,isScreenShareSupported:!0,isSmallStreamSupported:!0,isH264EncodeSupported:!0,isVp8EncodeSupported:!0,isH264DecodeSupported:!0,isVp8DecodeSupported:!0}}),rR(t(a),"keyPointManager"),rR(t(a),"audioManager"),rR(t(a),"videoManager"),rR(t(a),"callDurationCalculator"),rR(t(a),"badCaseDetector"),rR(t(a),"scheduleResult",{domains:null,iceServers:null,iceTransportPolicy:null,trtcAutoConf:null}),rR(t(a),"videoDecodeFallbackType"),rR(t(a),"_isUsingCachedSchedule",!1),rR(t(a),"_log",sx.createLogger({id:"r".concat(a.seq)})),rR(t(a),"_joinedTimestamp",0),rR(t(a),"_sdkType"),rR(t(a),"heartbeatReport"),rR(t(a),"quality"),rR(t(a),"enableSEI"),rR(t(a),"isDestroyed",!1),a.useStringRoomId=!!e.useStringRoomId,Rw(e.autoReceiveAudio)&&(a.autoReceiveAudio=e.autoReceiveAudio),Rw(e.autoReceiveVideo)&&(a.autoReceiveVideo=e.autoReceiveVideo),Rw(e.enableAutoPlayDialog)&&(a.enableAutoPlayDialog=e.enableAutoPlayDialog),a._sdkType=e.sdkType,a.keyPointManager=new Wj({room:t(a),frameWorkType:e.frameWorkType,component:e.component,language:e.language}),a.callDurationCalculator=new Kj({room:t(a)}),a.badCaseDetector=new zj({room:t(a)}),a.audioManager=new OL(t(a)),a.videoManager=new aH(t(a)),a}return d(i,e),o(i,[{key:"scriptTransformWorker",get:function(){}},{key:"isMainStreamPublished",get:function(){var e,t=s(this.localTracks);try{for(t.s();!(e=t.n()).done;)if(4&e.value.mediaType)return!0}catch(n){t.e(n)}finally{t.f()}return!1}},{key:"isAuxStreamPublished",get:function(){var e,t=s(this.localTracks);try{for(t.s();!(e=t.n()).done;)if(2&e.value.mediaType)return!0}catch(n){t.e(n)}finally{t.f()}return!1}},{key:"hasAuxStream",get:function(){var e,t=s(this.remotePublishedUserMap.values());try{for(t.s();!(e=t.n()).done;)if(e.value.muteState.hasAuxiliary)return!0}catch(n){t.e(n)}finally{t.f()}return this.isAuxStreamPublished}},{key:"localMainVideoTrack",get:function(){var e,t=s(this.localTracks);try{for(t.s();!(e=t.n()).done;){var n=e.value;if(4&n.mediaType)return n}}catch(r){t.e(r)}finally{t.f()}return null}},{key:"localAuxVideoTrack",get:function(){var e,t=s(this.localTracks);try{for(t.s();!(e=t.n()).done;){var n=e.value;if(2&n.mediaType)return n}}catch(r){t.e(r)}finally{t.f()}return null}},{key:"getLogger",value:function(){return this._log}},{key:"isJoining",get:function(){return"joining"===this.state.toString()}},{key:"isJoined",get:function(){return"joined"===this.state}},{key:"isLeft",get:function(){return"left"===this.state}},{key:"addTrack",value:function(e){return aR(this,null,f().mark((function t(){return f().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.publish(e));case 1:case"end":return t.stop()}}),t,this)})))}},{key:"removeTrack",value:function(e){return aR(this,null,f().mark((function t(){return f().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.unpublish(e));case 1:case"end":return t.stop()}}),t,this)})))}},{key:"replaceTrack",value:function(e){return aR(this,null,f().mark((function e(){return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:case"end":return e.stop()}}),e)})))}},{key:"setEncodedDataProcessingListener",value:function(e){throw new Error("Method not implemented.")}},{key:"enableAIVoice",value:function(e){throw new Error("Method not implemented.")}},{key:"setProxyServer",value:function(e){var t=this;if(bw(e))e.startsWith("wss://")?this.proxy_ws=e:e.startsWith("https://")&&(this.proxy_wt=e);else if(yw(e)){var n=e.websocketProxy,r=e.webtransportProxy,i=e.loggerProxy,a=e.scheduleProxy,o=e.unifiedProxy;this.proxy_ws=n,this.proxy_wt=r,this.proxy_unified=o,o?(oB([o,o]),MR("https://".concat(o))):(i&&MR(i),a&&oB(a))}rx.once(ax.JOIN_RECEIVED_CMD_RES,(function(){return t.sendAbilityStatus({sched_domain:aB.main,sched_back_domain:aB.backup,signal_domain:t.proxy_ws||t.proxy_wt||""})}))}},{key:"getRemoteAudioStats",value:function(){return aR(this,null,f().mark((function e(){var t;return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t={},e.abrupt("return",(this.remotePublishedUserMap.forEach((function(e){t[e.userId]=e.remoteAudioTrack.stat})),t));case 2:case"end":return e.stop()}}),e,this)})))}},{key:"getTransportStats",value:function(){return aR(this,null,f().mark((function e(){var t,n,r,i,a;return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n={rtt:(null==(t=this.quality)?void 0:t.uplinkRTT)||0,downlinksRTT:{}},this.quality){r=s(this.quality.downlinkInfo);try{for(r.s();!(i=r.n()).done;)a=i.value,n.downlinksRTT[a.userId]=a.rtt}catch(o){r.e(o)}finally{r.f()}}return e.abrupt("return",n);case 3:case"end":return e.stop()}}),e,this)})))}},{key:"getRemoteVideoStats",value:function(){return aR(this,arguments,(function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"main";return f().mark((function n(){var r;return f().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r={},n.abrupt("return",(e.remotePublishedUserMap.forEach((function(e){var n="auxiliary"===t?e.remoteAuxiliaryTrack:e.remoteVideoTrack;r[e.userId]=n.stat})),r));case 2:case"end":return n.stop()}}),n)}))()}))}},{key:"checkDestroy",value:function(){if(this.isDestroyed)throw new yR({code:_R.INVALID_OPERATION,message:mO({key:dO.CLIENT_DESTROYED,data:{funName:"join"}})})}},{key:"destroy",value:function(){if(this.isJoined)throw this._log.warn(hO.INVALID_DESTROY),new yR({code:_R.INVALID_OPERATION,message:mO({key:dO.INVALID_DESTROY})});this._log.info("destroy room"),this.audioManager.destroy(),this.videoManager.destroy(),this.keyPointManager.destroy(),this.callDurationCalculator.destroy(),this.badCaseDetector.destroy(),this.isDestroyed=!0,rx.emit(ax.ROOM_DESTROY,{room:this})}},{key:"schedule",value:function(e,t){return aR(this,null,f().mark((function n(){var r,i,a,o,s,c,u,l,d=this;return f().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return o=Vw(),n.prev=1,n.next=4,iB({userId:this.userId,sdkAppId:this.sdkAppId,roomId:this.useStringRoomId?e.strRoomId:e.roomId,useStringRoomId:this.useStringRoomId,version:RR,userSig:this.userSig,role:"live"===this.scene?e.role:void 0,frameWorkType:t,latencyLevel:e.latencyLevel});case 4:s=n.sent,c=s.isCached,u=s.result,l=s.detailCost,this._isUsingCachedSchedule=c,this._log.info("schedule cache:".concat(+c," ").concat(Xw(u,{keysToExclude:["username","credential"]}))),c&&rx.once(ax.JOIN_RECEIVED_CMD_RES,(function(){return d.sendAbilityStatus({scheduleCache:1})})),this.scheduleResult=QA(QA({},this.scheduleResult),u),Aw(null==(r=u.config)?void 0:r.retryCount)&&CC(u.config.retryCount),bw(null==(i=u.config)?void 0:i.loggerDomain)&&MR(u.config.loggerDomain),this.videoDecodeFallbackType=(null==(a=u.config)?void 0:a.videoDecodeFallback)||this.videoDecodeFallbackType,rx.emit(ax.JOIN_SCHEDULE_SUCCESS,{room:this,schedule:this.scheduleResult,detailCost:l}),bO.addSuccessEvent({key:521700,cost:Vw()-o,split:50}),n.next=14;break;case 11:throw n.prev=11,n.t0=n.catch(1),bO.addFailedEvent({key:521700,error:n.t0}),n.t0;case 14:case"end":return n.stop()}}),n,this,[[1,11]])})))}},{key:"sendAbilityStatus",value:function(e){}},{key:"enableInsertableStreams",value:function(){return Promise.resolve()}}])}(wP),cH=tR(oR()),uH=tR(pR());function lH(e){for(var t,n=[],r=function(r){if(["rtx","red","ulpfec"].includes(e.rtp[r].codec))return 1;var i=e.fmtp.filter((function(t){return t.payload===e.rtp[r].payload}))[0];n.push({payload:e.rtp[r].payload,codec:e.rtp[r].codec,fmtp:i?i.config:"",rate:e.rtp[r].rate,rtx:"rtx"===(null==(t=e.rtp[r+1])?void 0:t.codec)?e.rtp[r+1].payload:0,rtcpfb:((null==e?void 0:e.rtcpFb)||[]).filter((function(t){return t.payload===e.rtp[r].payload})).map((function(e){var t=e.type,n=e.subtype;return{id:t,params:n?[n]:[]}}))})},i=0;i<e.rtp.length;i++)r(i);return n}var dH=function(e,t){return aR(void 0,null,f().mark((function n(){var r,i,a,o,s,c,u;return f().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return i=wj(e),(a={ice:{ufrag:"",password:""},dtls:{hash:"",fingerprint:"",setup:""},audio:{codecs:[],extensions:[]},video:{codecs:[],decoders:[],extensions:[]},useDataChannel:!1}).ice.ufrag=String(i.media[0].iceUfrag),a.ice.password=i.media[0].icePwd||"",i.fingerprint&&(a.dtls.hash=i.fingerprint.type,a.dtls.fingerprint=i.fingerprint.hash,a.dtls.setup=i.setup||""),i.media[0].fingerprint&&(a.dtls.hash=i.media[0].fingerprint.type,a.dtls.fingerprint=i.media[0].fingerprint.hash),a.dtls.setup=i.media[0].setup||"",o=i.media[0],s=i.media[1],o.ext&&(a.audio.extensions=o.ext.map((function(e){return{id:e.value,uri:e.uri}}))),s.ext&&(a.video.extensions=s.ext.map((function(e){return{id:e.value,uri:e.uri}}))),c={codec:o.rtp[0].codec,fmtp:o.fmtp[0].config,payload:o.fmtp[0].payload,rate:o.rtp[0].rate,channels:o.rtp[0].encoding,rtcpfb:[],rtx:0},null==(r=o.rtcpFb)||r.forEach((function(e){var t=e.payload,n=e.type,r=e.subtype;if(t===c.payload){var i={id:n,params:[]};r&&i.params.push(r),c.rtcpfb.push(i)}})),a.audio.codecs.push(c),u=["h264","vp8"],t&&u.shift(),a.video.codecs=E(lH(s)).filter((function(e){return u.includes(e.codec.toLocaleLowerCase())})),n.next=11,function(){return aR(this,null,f().mark((function e(){var t,n,r;return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return(t=new RTCPeerConnection).addTransceiver(nC.VIDEO,{direction:nC.TRANSCEIVER_DIRECTION_RECVONLY}),e.next=4,t.createOffer();case 4:if((n=e.sent).sdp){e.next=7;break}return e.abrupt("return",[]);case 7:return r=lH(wj(n.sdp).media[0]),e.abrupt("return",(t.close(),r));case 9:case"end":return e.stop()}}),e)})))}();case 11:return a.video.decoders=n.sent.filter((function(e){return["h264","vp8"].includes(e.codec.toLocaleLowerCase())})),n.abrupt("return",a);case 13:case"end":return n.stop()}}),n)})))},hH=function(e){var t=e.serverAbility,n=e.clientAbility,r=e.offerSDP,i=e.enableCustomMessage,a=wj(r),o={extmapAllowMixed:"extmap-allow-mixed",groups:a.groups,icelite:"ice-lite",media:[],msidSemantic:{semantic:"",token:"WMS"},name:"-",origin:{address:"127.0.0.1",username:"-",sessionId:String(Date.now()),sessionVersion:1,netType:"IN",ipVer:4},timing:{start:0,stop:0},version:0},s={candidates:t.candidates.map((function(e){return{component:1,foundation:"1",generation:0,ip:e.ip,port:e.port,priority:e.priority,transport:e.foundation,type:e.type}})),connection:{version:4,ip:"0.0.0.0"},direction:nC.TRANSCEIVER_DIRECTION_RECVONLY,ext:t.audio.extensions.map((function(e){return{value:e.id,uri:e.uri}})),fingerprint:{type:t.dtls.hash,hash:t.dtls.fingerprint},fmtp:[{payload:t.audio.codecs[0].payload,config:t.audio.codecs[0].fmtp}],icePwd:t.ice.password,iceUfrag:t.ice.ufrag,mid:"0",payloads:String(t.audio.codecs[0].payload),port:a.media[0].port,protocol:a.media[0].protocol,type:nC.AUDIO,setup:t.dtls.setup,rtcpFb:t.audio.codecs[0].rtcpfb.map((function(e){return{payload:t.audio.codecs[0].payload,type:e.id,subtype:e.params[0]}})),rtcpMux:"rtcp-mux",rtcpRsize:"rtcp-rsize",rtp:[{payload:t.audio.codecs[0].payload,codec:t.audio.codecs[0].codec,rate:t.audio.codecs[0].rate,encoding:t.audio.codecs[0].channels}]};return o.media.push(s),[1,2,3].forEach((function(e){o.media.push(fH({mid:e,serverAbility:t,clientAbility:n,parsedOffer:a}))})),i&&o.media.push(a.media.find((function(e){return"dc"===e.mid}))),Dj(o)},fH=function(e){var t=e.mid,n=e.serverAbility,r=e.clientAbility,i=e.parsedOffer,a=e.isDownlink,o=void 0!==a&&a,s={candidates:n.candidates.map((function(e){return{component:1,foundation:"1",generation:0,ip:e.ip,port:e.port,priority:e.priority,transport:e.foundation,type:e.type}})),connection:{version:4,ip:"0.0.0.0"},direction:nC.TRANSCEIVER_DIRECTION_RECVONLY,ext:n.video.extensions.map((function(e){return{value:e.id,uri:e.uri}})),fingerprint:{type:n.dtls.hash,hash:n.dtls.fingerprint},fmtp:[],icePwd:n.ice.password,iceUfrag:n.ice.ufrag,mid:String(t),payloads:"",port:i.media[0].port,protocol:i.media[0].protocol,type:nC.VIDEO,setup:n.dtls.setup,rtcpFb:[],rtcpMux:"rtcp-mux",rtcpRsize:"rtcp-rsize",rtp:[]};if(o){var c=n.video.decoders;(!c||0===c.length)&&(c=n.video.codecs),(!c||0===c.length)&&(c=r.video.decoders),c.forEach((function(e){pH(s,e)}))}else{var u=n.video.codecs.findIndex((function(e){return e.codec.toLowerCase()===(n.useVp8?"vp8":"h264")})),l=n.video.codecs[u]||r.video.codecs[0];pH(s,l)}return s},pH=function(e,t){e.payloads="".concat(e.payloads," ").concat(t.payload).trim(),e.fmtp.push({payload:t.payload,config:t.fmtp}),e.rtcpFb=[].concat(E(e.rtcpFb||[]),E(t.rtcpfb.map((function(e){return{payload:t.payload,type:e.id,subtype:e.params[0]}})))),e.rtp.push({payload:t.payload,codec:t.codec.toUpperCase(),rate:t.rate}),t.rtx&&(e.payloads="".concat(e.payloads," ").concat(t.rtx),e.fmtp.push({payload:t.rtx,config:"apt=".concat(t.payload)}),e.rtp.push({payload:t.rtx,codec:"rtx",rate:t.rate}))},mH=function(e){function i(e){var a;return r(this,i),(a=n(this,i)).room=e,rR(t(a),"mainFpsHealth",1),rR(t(a),"mainBitrateHealth",1),rR(t(a),"badMainBitrateHealthCount",0),rR(t(a),"lastEmitBadHealthTime",0),rR(t(a),"log"),!bD&&RN&&rx.on("262",a.onVideoCodecChanged,t(a)),a.log=e.getLogger().createChild({id:"h-d"}),a}return d(i,e),o(i,[{key:"onVideoCodecChanged",value:function(e){var t=e.remoteUserId,n=e.streamType,r=e.isHWCodec,i=e.codec;if(!t&&7!==n&&"h264"===i){if(!r)return void this.room.off("heartbeat-report",this.onHeartbeatReport,this);this.room.listeners("heartbeat-report").includes(this.onHeartbeatReport)||this.room.on("heartbeat-report",this.onHeartbeatReport,this)}}},{key:"onHeartbeatReport",value:function(e){var t=this;Date.now()-this.lastEmitBadHealthTime<3e4||(e.msg_up_stream_info.msg_video_status.forEach((function(e){if(e.uint32_video_enc_fps&&e.uint32_video_capture_fps){var n=e.uint32_video_enc_fps/e.uint32_video_capture_fps;2===e.uint32_video_stream_type&&(t.mainFpsHealth=n)}if(e.uint32_video_codec_bitrate&&2===e.uint32_video_stream_type){var r=t.room.localMainVideoTrack;r&&(t.mainBitrateHealth=e.uint32_video_codec_bitrate/1e3/r.profile.bitrate)}})),this.log.debug("mainBitrateHealth: ".concat(this.mainBitrateHealth," mainFpsHealth: ").concat(this.mainFpsHealth)),this.mainBitrateHealth>.5&&(this.badMainBitrateHealthCount=0),this.mainFpsHealth>.9&&this.mainBitrateHealth<.5&&(this.badMainBitrateHealthCount++,this.badMainBitrateHealthCount>3&&(this.badMainBitrateHealthCount=0,this.lastEmitBadHealthTime=Date.now(),this.log.warn("bad main bitrate health: ".concat(this.mainBitrateHealth)),this.emit("1",{isAux:!1}))))}},{key:"destroy",value:function(){rx.off("262",this.onVideoCodecChanged,this),this.room.off("heartbeat-report",this.onHeartbeatReport,this)}}])}(tR(oR()).EventEmitter);rR(mH,"EVENT_BAD_HEALTH","bad_health");var vH=mH;function _H(e){var t=e.seiMessageList,n=e.isAudio,r=e.isMain;return new TransformStream({transform:function(e,i){var a=e;n?audioEncodePipeline.forEach((function(e){a=e({frame:a})})):videoEncodePipeline.forEach((function(e){a=e({frame:a,seiMessageList:t,onDump:function(){self.postMessage({type:"dump",isAudio:n,data:a.data,userId:"",streamType:r?"main":"auxiliary"})}})})),i.enqueue(a)}})}function gH(e,t,n){return new TransformStream({transform:function(r,i){var a=r;videoDecodePipeline.forEach((function(r){a=r({frame:a,onSEI:function(n){n.forEach((function(n){self.postMessage({type:"sei",seiPayloadType:n.seiPayloadType,data:n.seiPayload.buffer,userId:e,streamType:t})}))},onDump:function(){self.postMessage({type:"dump",isAudio:n,data:a.data,userId:e,streamType:t})}})})),i.enqueue(a)}})}var yH=function(e){return e.TRACK="track",e.DATA_CHANNEL_MESSAGE="data_channel_msg",e[e.CONNECTION_STATE_CHANGED="connection-state-changed"]="CONNECTION_STATE_CHANGED",e[e.FIREWALL_RESTRICTION="firewall-restriction"]="FIREWALL_RESTRICTION",e.RECONNECTED="spc-reconnected",e.RECONNECT_FAILED="spc-reconnect-failed",e.ERROR="error",e.SEI_MESSAGE="sei-message",e.DUMP="dump",e}(yH||{}),EH=0,TH=!1,kH=new Set,SH=1,IH=function(e){function i(e){var a;r(this,i);var o=e.signalChannel,s=e.room,c=e.enableCustomMessage;return a=n(this,i),rR(t(a),"stat",{iceStartTime:0,iceEndTime:0,dtlsStartTime:0,dtlsEndTime:0,peerConnectionStartTime:0,peerConnectionEndTime:0}),rR(t(a),"currentState","DISCONNECTED"),rR(t(a),"_room"),rR(t(a),"_signalChannel"),rR(t(a),"_peerConnection",null),rR(t(a),"_datachannel",null),rR(t(a),"_enableCustomMessage"),rR(t(a),"_log"),rR(t(a),"_downlinkMIDMap",new Map),rR(t(a),"_downlinkMIDUserIDMap",new Map),rR(t(a),"_reconnectionTimer",-1),rR(t(a),"reconnectionCount",0),rR(t(a),"clientAbility"),rR(t(a),"_serverAbility",null),rR(t(a),"addDownlinkQueue",new Set),rR(t(a),"removeDownlinkQueue",new Set),rR(t(a),"_parsedAnswer",null),rR(t(a),"_updateSDPPromise",null),rR(t(a),"_waitForPCConnectedPromise"),rR(t(a),"clearConnectTimeout"),rR(t(a),"_isSDPLogged",!1),rR(t(a),"enableInsertableStreams",!1),rR(t(a),"insertableStreamsAbortMap",new Map),rR(t(a),"receiverRemoteTrackMap",new WeakMap),rR(t(a),"scriptTransformWorker"),rR(t(a),"_isRelayTried",!1),rR(t(a),"_rttOverCount",0),rR(t(a),"originOffer",null),a._room=s,a._enableCustomMessage=c,a._signalChannel=o,a._log=sx.createLogger({id:"spc".concat(SH++),userId:a._room.userId,sdkAppId:a._room.sdkAppId}),a._room.enableCodecPipeline&&(sP?a.enableInsertableStreams=!0:a.initScriptTransformWorker()),a._room.healthDetector.on("1",a.onBadHealth,t(a)),a}return d(i,e),o(i,[{key:"isH264EncodeSupported",get:function(){var e=this._room.checkSystemResult.detail.isH264EncodeSupported;return this._serverAbility&&(e=e&&!!this._serverAbility.video.codecs.find((function(e){return"h264"===e.codec.toLowerCase()}))),e}},{key:"addAbortController",value:function(e,t){var n;null==(n=this.insertableStreamsAbortMap.get(e))||n.abort("destory"),this.insertableStreamsAbortMap.set(e,t)}},{key:"isVP8EncodeSupported",get:function(){var e=this._room.checkSystemResult.detail.isVp8EncodeSupported;return this._serverAbility&&(e=e&&this._serverAbility.video.codecs.find((function(e){return"vp8"===e.codec.toLowerCase()}))),e}},{key:"videoCodec",get:function(){var e,t,n=null==(e=this._parsedAnswer)?void 0:e.media[1].rtp.find((function(e){return["h264","vp8"].includes(e.codec.toLowerCase())}));return n?n.codec.toLowerCase():null!=(t=this._serverAbility)&&t.useVp8?"vp8":"h264"}},{key:"downlinkVideoCodec",get:function(){var e;return null!=(e=this._serverAbility)&&e.video.decoders.find((function(e){return"h264"===e.codec.toLowerCase()}))?"h264":"vp8"}},{key:"isUsingH264",get:function(){return"h264"===this.videoCodec}},{key:"is42001fSupported",get:function(){return!!this.clientAbility&&!!this.clientAbility.video.codecs.find((function(e){return e.fmtp.includes("42001f")}))}},{key:"uplinkSSRC",get:function(){return this._peerConnection&&this._peerConnection.localDescription?function(e){var t=wj(e),n={audioSsrc:0,audioRtxSsrc:0,bigVideoSsrc:0,bigVideoRtxSsrc:0,smallVideoSsrc:0,smallVideoRtxSsrc:0,auxVideoSsrc:0,auxVideoRtxSsrc:0};return t.media.forEach((function(e,t){var r;if(e.ssrcs&&!Iw(e.ssrcs[0].id)){var i=Number(e.ssrcs[0].id),a=Number(null==(r=e.ssrcs.filter((function(e){return"cname"===e.attribute}))[1])?void 0:r.id);switch(t){case 0:n.audioSsrc=i;break;case 1:n.bigVideoSsrc=i,n.bigVideoRtxSsrc=a;break;case 2:n.smallVideoSsrc=i,n.smallVideoRtxSsrc=a;break;case 3:n.auxVideoSsrc=i,n.auxVideoRtxSsrc=a}}})),n}(this._peerConnection.localDescription.sdp):{audioSsrc:0,audioRtxSsrc:0,bigVideoSsrc:0,bigVideoRtxSsrc:0,smallVideoSsrc:0,smallVideoRtxSsrc:0,auxVideoSsrc:0,auxVideoRtxSsrc:0}}},{key:"onBadHealth",value:function(e){var t=e.isAux;this.useHWEncoder(!1,t?7:2)}},{key:"initScriptTransformWorker",value:function(){var e=this;cP&&(this.scriptTransformWorker=function(e){var t=[SL],n=[VB,MB,LB,PB,_H,gH],r="const videoEncodePipeline=[".concat(e.videoEncodePipeline.toString(),"];\n const videoDecodePipeline=[").concat(e.videoDecodePipeline.toString(),"];\n const audioEncodePipeline = [").concat(e.audioEncodePipeline.toString(),"];\n const audioDecodePipeline = [").concat(e.audioDecodePipeline.toString(),"];"),i="(()=>{".concat(t.map((function(e){return"const ".concat(e.name,"=(()=>").concat(e.toString(),")()")})).join("\n"),"\n").concat(n.map((function(e){return e.toString()})).join("\n"),";(").concat((function(){var e=[],t=[],n=[];self.onmessage=function(r){"sei"===r.data.type&&(r.data.isMain?(e.push(r.data.data),r.data.small&&n.push(r.data.data)):t.push(r.data.data))},self.onrtctransform=function(r){var i=r.transformer.options,a=i.isReceiver?gH(i.userId,i.streamType,i.isAudio):_H({isAudio:i.isAudio,seiMessageList:i.isMain?i.small?n:e:t,isMain:i.isMain});r.transformer.readable.pipeThrough(a).pipeTo(r.transformer.writable)}}),")();").concat(r,"})()"),a=new Blob([i],{type:"text/javascript"}),o=URL.createObjectURL(a),s=new Worker(o);return URL.revokeObjectURL(o),s}({videoEncodePipeline:this._room.videoManager.encodePipeline,videoDecodePipeline:this._room.videoManager.decodePipeline,audioEncodePipeline:this._room.audioManager.encodePipeline,audioDecodePipeline:this._room.audioManager.decodePipeline}),this.scriptTransformWorker.onmessage=function(t){"sei"===t.data.type&&e.emit("sei-message",t.data),"dump"===t.data.type&&e.emit("dump",t.data)},this.scriptTransformWorker.onerror=function(t){e._log.error("scriptTransformWorker error: ",t)})}},{key:"isReconnecting",get:function(){return"RECONNECTING"===this.currentState||this._reconnectionTimer>0||this.reconnectionCount>0}},{key:"dtlsTransport",get:function(){if(!this._peerConnection)return null;var e=this._peerConnection.getSenders();return 0===e.length?null:e[0].transport}},{key:"getPeerConnectionConfig",value:function(e){var t={encodedInsertableStreams:this.enableInsertableStreams,offerExtmapAllowMixed:!0,iceServers:e,iceTransportPolicy:this._room.getIceTransportPolicy(),sdpSemantics:this._room.sdpSemantics,bundlePolicy:"max-bundle",rtcpMuxPolicy:"require",tcpCandidatePolicy:"disable",IceTransportsType:"nohost"};return this._log.debug("getPeerConnectionConfig",JSON.stringify(t)),t}},{key:"initialize",value:function(e){return aR(this,null,f().mark((function t(){var n,r,i=this;return f().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,this._peerConnection=new RTCPeerConnection(this.getPeerConnectionConfig(e)),this._peerConnection.oniceconnectionstatechange=function(){if(i._peerConnection){var e=i._peerConnection.iceConnectionState;i._log.debug("ice state: ".concat(e)),"checking"===e&&0===i.stat.iceStartTime?i.stat.iceStartTime=Date.now():"connected"===e&&0===i.stat.iceEndTime?(i.stat.iceEndTime=Date.now(),i._signalChannel.clearBakRelayIps(),bO.addSuccessEvent({key:521711,cost:i.stat.iceEndTime-i.stat.iceStartTime})):"failed"===e&&bO.addFailedEvent({key:521711})}},this._peerConnection.onsignalingstatechange=function(){var e,t=(null==(e=i._peerConnection)?void 0:e.signalingState)||"";i._log["closed"===t?"debug":"info"]("signaling state: ".concat(t))},this._peerConnection.onconnectionstatechange=this.onConnectionStateChange.bind(this),this._peerConnection.ontrack=function(e){return i.emit("track",e)},this._enableCustomMessage&&(this._datachannel=this._peerConnection.createDataChannel("".concat(this._room.userId,"dc")),this._datachannel.binaryType="arraybuffer",this._datachannel.onopen=function(){i._log.info("datachannel open")},this._datachannel.onclose=function(){i._log.warn("datachannel close")},this._datachannel.onmessage=function(e){var t=new AH(e.data);i.emit("data_channel_msg",{data:t})},this._datachannel.onerror=function(e){i._log.warn("datachannel error",e)}),this._peerConnection.addTransceiver(nC.AUDIO,{direction:nC.TRANSCEIVER_DIRECTION_SENDONLY}),this._peerConnection.addTransceiver(nC.VIDEO,{direction:nC.TRANSCEIVER_DIRECTION_SENDONLY}),this._peerConnection.addTransceiver(nC.VIDEO,{direction:nC.TRANSCEIVER_DIRECTION_SENDONLY}),this._peerConnection.addTransceiver(nC.VIDEO,{direction:nC.TRANSCEIVER_DIRECTION_SENDONLY}),t.next=13,this._peerConnection.createOffer();case 13:return r=t.sent,t.next=16,dH(r.sdp,(null==(n=this._room.scheduleResult.config)?void 0:n.remove264FromSDP)||!1);case 16:return this.clientAbility=t.sent,this.originOffer=r,this.dtlsTransport&&(this.dtlsTransport.onstatechange=function(){var e=i.dtlsTransport;e&&(i._log.debug("dtls state: ".concat(e.state)),"connecting"===e.state&&0===i.stat.dtlsStartTime?i.stat.dtlsStartTime=Date.now():"connected"===e.state&&0===i.stat.dtlsEndTime&&(i.stat.dtlsEndTime=Date.now()))}),bO.addSuccessEvent({key:521707}),t.abrupt("return",this.clientAbility);case 23:throw t.prev=23,t.t0=t.catch(0),bO.addFailedEvent({key:521707,error:t.t0}),this._log.error("initialize failed ".concat(t.t0," \noffer: ").concat(null==r?void 0:r.sdp)),t.t0;case 26:case"end":return t.stop()}}),t,this,[[0,23]])})))}},{key:"setIceServers",value:function(e){return aR(this,null,f().mark((function t(){var n;return f().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this._peerConnection){t.next=5;break}if(this._log.info("setIceServers",JSON.stringify(e)),this._peerConnection.setConfiguration(this.getPeerConnectionConfig(e)),(null==(n=this._peerConnection)||!n.localDescription)&&this.originOffer){t.next=3;break}return t.abrupt("return",void this._log.warn("setIceServers warning, already has localDescription or no origin Offer"));case 3:return t.next=5,this.setOffer(this.originOffer);case 5:case"end":return t.stop()}}),t,this)})))}},{key:"setPriority",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"high";if(this._peerConnection)try{this._peerConnection.getSenders().forEach((function(n){var r=n.getParameters();r.encodings[0]&&(r.encodings[0].priority=t,r.encodings[0].networkPriority=t,n.setParameters(r).catch((function(t){e._log.warn("setPriority error ",t)})))}))}catch(DC){this._log.warn("setPriority error ",DC)}}},{key:"connect",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return aR(this,null,f().mark((function n(){var r,i,a,o,s,c,u;return f().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(n.prev=0,"CONNECTED"!==this.currentState){n.next=3;break}return n.abrupt("return");case 3:if(n.t0=(null==(r=this._peerConnection)||!r.localDescription)&&this.originOffer,!n.t0){n.next=7;break}return n.next=7,this.setOffer(this.originOffer);case 7:return o=Vw(),s={type:"answer",sdp:hH({serverAbility:e,clientAbility:this.clientAbility,offerSDP:this._peerConnection.localDescription.sdp,enableCustomMessage:this._enableCustomMessage})},this._serverAbility=e,n.next=11,this.setAnswer(s);case 11:return n.next=13,this.waitForPeerConnectionConnected();case 13:(c=(null==(i=this._room.scheduleResult.config)?void 0:i.priority)||(null==(a=this._room.joinParams)?void 0:a.priority)||new URLSearchParams(location.search).get("priority"))&&this.setPriority(c),t||bO.addSuccessEvent({key:521703,cost:Vw()-o}),n.next=21;break;case 17:throw n.prev=17,n.t1=n.catch(0),(u=n.t1 instanceof yR&&n.t1.code===_R.API_CALL_ABORTED)||this._log.error("connect failed: ".concat(n.t1),e),this.reset(),!u&&!this.isReconnecting&&(bO.addFailedEvent({key:521703,error:n.t1}),this.emitConnectionStateChangedEvent("DISCONNECTED"),this.startReconnection()),n.t1;case 21:case"end":return n.stop()}}),n,this,[[0,17]])})))}},{key:"reconnect",value:function(){return aR(this,null,f().mark((function e(){var t,n,r,i,a,o=this;return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(-1!==this._reconnectionTimer){e.next=41;break}if(this._signalChannel.isConnected){e.next=3;break}return e.abrupt("return",(this._log.warn("reconnect() wait signal channel is connected"),void this._signalChannel.once(uj,this.reconnect,this)));case 3:return e.prev=3,this.reconnectionCount+=1,this._log.warn("reconnect() trying [".concat(this.reconnectionCount,"]")),this.reset(),t=this._signalChannel.getBackupRelayIpPair(),e.next=8,this.initialize(this._room.getIceServers(null!=t&&t.iceServer?[t.iceServer]:[]));case 8:return n=e.sent,r=QA({ability:n},t),e.next=12,this._signalChannel.sendWaitForResponse({command:"rebuild_pc",responseCommand:fj.REBUILD_PEER_CONNECTION_RES,data:r,enableLog:!1});case 12:if(0===(i=e.sent).data.code){e.next=15;break}throw new yR({code:i.data.code,message:i.data.message});case 15:return e.next=17,this.connect(i.data.data.ability,!0);case 17:bO.addSuccessEvent({key:521704}),this._log.warn("reconnect() success"),this.stopReconnection(),rx.emit(ax.SPC_RECONNECTED,{room:this._room}),this.emit("spc-reconnected"),e.next=39;break;case 24:if(e.prev=24,e.t0=e.catch(3),this.isReconnecting){e.next=28;break}return e.abrupt("return");case 28:if(null==e.t0||!e.t0.message.includes("timeout")){e.next=38;break}return a=Tw(this.reconnectionCount),this._log.warn("reconnect() timeout, try again after ".concat(a/1e3,"s")),e.next=33,rD(a,(function(e){o._reconnectionTimer=e}));case 33:return this.clearReconnectionTimer(),e.next=36,this.reconnect();case 36:e.next=39;break;case 38:this._log.error("reconnect() failed ".concat(null==e.t0?void 0:e.t0.code," ").concat(e.t0)),bO.addFailedEvent({key:521704,error:e.t0}),this.reconnectionCount>=wC()&&this._log.warn("SDK has tried reconnect for ".concat(wC()," times, but all failed, please check your network")),this.stopReconnection(),this.emitConnectionStateChangedEvent("DISCONNECTED"),this.emit("error");case 39:e.next=42;break;case 41:this._log.warn("reconnect() is reconnecting, ignore current reconnection");case 42:case"end":return e.stop()}}),e,this,[[3,24]])})))}},{key:"getPeerConnection",value:function(){return this._peerConnection}},{key:"startReconnection",value:function(){return aR(this,null,f().mark((function e(){return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(e.t0=this.isReconnecting,e.t0){e.next=7;break}return this._log.warn("start reconnect"),this._updateSDPPromise=null,this.emitConnectionStateChangedEvent("RECONNECTING"),e.next=7,this.reconnect();case 7:case"end":return e.stop()}}),e,this)})))}},{key:"stopReconnection",value:function(){var e;this.isReconnecting&&(this._log.info("stop reconnect"),this.reconnectionCount=0,this.clearReconnectionTimer(),null==(e=this.clearConnectTimeout)||e.call(this),this._signalChannel.off(uj,this.reconnect,this),"RECONNECTING"===this.currentState&&this.emitConnectionStateChangedEvent("DISCONNECTED"))}},{key:"checkPeerConnectionToReconnect",value:function(){var e;!this.isReconnecting&&(null==(e=this._peerConnection)?void 0:e.connectionState)===AC.CLOSED&&this.startReconnection()}},{key:"clearReconnectionTimer",value:function(){-1!==this._reconnectionTimer&&(clearTimeout(this._reconnectionTimer),this._reconnectionTimer=-1)}},{key:"onConnectionStateChange",value:function(e){var t,n=(null==(t=this._peerConnection)?void 0:t.iceConnectionState)||"closed",r=this.getDTLSTransportState();this._log.info("connectionState: ".concat(e.target.connectionState," ICE: ").concat(n," DTLS: ").concat(r)),e.target.connectionState===AC.CONNECTING&&(0===this.stat.peerConnectionStartTime&&(this.stat.peerConnectionStartTime=Date.now()),this.emitConnectionStateChangedEvent("CONNECTING")),(e.target.connectionState===AC.FAILED||e.target.connectionState===AC.CLOSED)&&(this.emitConnectionStateChangedEvent("DISCONNECTED"),this._room.forceRelay?this.switchRelay(!1):this.startReconnection()),(e.target.connectionState===AC.CONNECTED||e.target.connectionState===AC.COMPLETED)&&(0===this.stat.peerConnectionEndTime&&(this.stat.peerConnectionEndTime=Date.now()),rx.emit(ax.SINGLE_CONNECTION_STAT,{room:this._room,stat:{ice:this.stat.iceEndTime-this.stat.iceStartTime,dtls:this.stat.dtlsEndTime-this.stat.dtlsStartTime,peerConnection:this.stat.peerConnectionEndTime-this.stat.peerConnectionStartTime}}),this.logSelectedCandidate(),this.emitConnectionStateChangedEvent("CONNECTED"))}},{key:"getDTLSTransportState",value:function(){if(!this._peerConnection)return bC;var e=null;return XO()&&0!==this._peerConnection.getSenders().length?(e=this._peerConnection.getSenders()[0].transport,qO()&&0!==this._peerConnection.getReceivers().length&&e?e.state:bC):bC}},{key:"emitConnectionStateChangedEvent",value:function(e){e!==this.currentState&&("RECONNECTING"===this.currentState&&"CONNECTING"===e||(this.emit(yH.CONNECTION_STATE_CHANGED,{prevState:this.currentState,state:e}),this.currentState=e))}},{key:"logSelectedCandidate",value:function(){return aR(this,null,f().mark((function e(){var t,n,r,i,a,o,c;return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._peerConnection){e.next=2;break}return e.abrupt("return");case 2:return e.next=4,this._peerConnection.getStats();case 4:t=e.sent,n=s(t),e.prev=6,n.s();case 8:if((r=n.n()).done){e.next=16;break}if((i=v(r.value,2))[0],a=i[1],!HO(a)){e.next=14;break}return o=t.get(a.localCandidateId),c=t.get(a.remoteCandidateId),o&&(this._log.info("local candidate: ".concat(o.candidateType," ").concat(o.protocol,":").concat(o.ip||o.address,":").concat(o.port," ").concat(o.networkType||""," ").concat("relay"===o.candidateType?"relayProtocol:".concat(o.relayProtocol):"")),o.networkType&&lw(o.networkType)),c&&this._log.info("remote candidate: ".concat(c.candidateType," ").concat(c.protocol,":").concat(c.ip||c.address,":").concat(c.port)),e.abrupt("break",16);case 14:e.next=8;break;case 16:e.next=21;break;case 18:e.prev=18,e.t0=e.catch(6),n.e(e.t0);case 21:return e.prev=21,n.f(),e.finish(21);case 24:case"end":return e.stop()}}),e,this,[[6,18,21,24]])})))}},{key:"waitForPeerConnectionConnected",value:function(){var e=this;return this._waitForPCConnectedPromise||(this._waitForPCConnectedPromise=new Promise((function(t,n){if("CONNECTED"===e.currentState)return t();var r=function(e){"CONNECTED"===e.state&&(clearTimeout(o),a(),t())},i=function(t){t.room===e._room&&(clearTimeout(o),a(),n(new yR({code:_R.API_CALL_ABORTED,message:mO({key:dO.CONNECTION_ABORTED,data:"leave room"})})))},a=function(){rx.off(ax.LEAVE_SUCCESS,i,e),e.off(yH.CONNECTION_STATE_CHANGED,r,e)},o=setTimeout((function(){a();var t,r=new yR({code:_R.API_CALL_TIMEOUT,message:"connection timeout"});EH+=1,t=e._signalChannel.isConnected,EH>2&&!TH&&0===kH.size&&t&&(e._log.warn("firewall restriction"),TH=!0,e.emit(yH.FIREWALL_RESTRICTION)),n(r)}),WC);e.clearConnectTimeout=function(){a(),clearTimeout(o),delete e.clearConnectTimeout},rx.on(ax.LEAVE_SUCCESS,i,e),e.on(yH.CONNECTION_STATE_CHANGED,r,e)})),this._waitForPCConnectedPromise=this._waitForPCConnectedPromise.finally((function(){e._waitForPCConnectedPromise=null,delete e.clearConnectTimeout}))),this._waitForPCConnectedPromise}},{key:"waitForReconnected",value:function(){var e=this;return this.isReconnecting?new Promise((function(t,n){e.once("spc-reconnected",t),e.once("error",n)})):Promise.resolve()}},{key:"addDownlink",value:function(e){return aR(this,null,f().mark((function t(){return f().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this._log.info("addDownlink(".concat(e.userId,") trying")),t.t0=this.isReconnecting,!t.t0){t.next=5;break}return t.next=5,this.waitForReconnected();case 5:if(t.t1=this._updateSDPPromise,!t.t1){t.next=9;break}return t.next=9,this._updateSDPPromise;case 9:if(this.updateLocalAndRemoteSDPConfig(e),0!==this.addDownlinkQueue.size){t.next=22;break}return t.prev=11,t.next=14,this.updateSDP();case 14:this._log.info("addDownlink(".concat(e.userId,") done")),t.next=22;break;case 17:return t.prev=17,t.t2=t.catch(11),this._log.error("addDownlink(".concat(e.userId,") failed ").concat(t.t2)),t.next=22,this.startReconnection();case 22:case"end":return t.stop()}}),t,this,[[11,17]])})))}},{key:"updateLocalAndRemoteSDPConfig",value:function(e){var t=e.ssrc,n=e.userId,r=e.tinyId;if(this._peerConnection){this._log.info("updateLocalAndRemoteSDPConfig ".concat(n," ").concat(JSON.stringify(t)));var i=this._peerConnection.getTransceivers().slice(4).filter((function(e){return"inactive"===e.direction})).slice(0,3).map((function(e){return e.direction=nC.TRANSCEIVER_DIRECTION_RECVONLY,Number(e.mid)}));this._parsedAnswer||(this._parsedAnswer=wj(this._peerConnection.remoteDescription.sdp));var a,o,s,c=this._parsedAnswer.media.filter((function(e){var t;return null==(t=e.ssrcs)?void 0:t.find((function(e){var t;return null==(t=e.value)?void 0:t.includes(r)}))}));if(3===c.length)a=c[0],o=c[1],s=c[2];else if(3===i.length)a=this._parsedAnswer.media.find((function(e){return Number(e.mid)===Number(i[0])})),o=this._parsedAnswer.media.find((function(e){return Number(e.mid)===Number(i[1])})),s=this._parsedAnswer.media.find((function(e){return Number(e.mid)===Number(i[2])}));else if(0===i.length){this._peerConnection.addTransceiver(nC.AUDIO,{direction:nC.TRANSCEIVER_DIRECTION_RECVONLY}),this._peerConnection.addTransceiver(nC.VIDEO,{direction:nC.TRANSCEIVER_DIRECTION_RECVONLY}),this._peerConnection.addTransceiver(nC.VIDEO,{direction:nC.TRANSCEIVER_DIRECTION_RECVONLY}),a=JSON.parse(JSON.stringify(this._parsedAnswer.media[0]));var u=fH({mid:1,serverAbility:this._serverAbility,clientAbility:this.clientAbility,parsedOffer:wj(this._peerConnection.localDescription.sdp),isDownlink:!0});o=JSON.parse(JSON.stringify(u)),s=JSON.parse(JSON.stringify(u)),a.mid=this._parsedAnswer.media.length,this._parsedAnswer.media.push(a),o.mid=this._parsedAnswer.media.length,this._parsedAnswer.media.push(o),s.mid=this._parsedAnswer.media.length,this._parsedAnswer.media.push(s)}a.direction=nC.TRANSCEIVER_DIRECTION_SENDONLY;var l="".concat(r,"-").concat(t.audio);a.ssrcs=[{id:t.audio,attribute:"cname",value:"".concat(l)},{id:t.audio,attribute:"msid",value:"".concat(l,"-").concat(nC.MAIN," ").concat(l,"-audio")}],o.direction=nC.TRANSCEIVER_DIRECTION_SENDONLY,o.ssrcs=[{id:t.video,attribute:"cname",value:"".concat(l)},{id:t.video,attribute:"msid",value:"".concat(l,"-").concat(nC.MAIN," ").concat(l,"-bigvideo")},{id:t.videoRtx,attribute:"cname",value:"".concat(l)},{id:t.videoRtx,attribute:"msid",value:"".concat(l,"-").concat(nC.MAIN," ").concat(l,"-bigvideo")}],o.ssrcGroups=[{semantics:"FID",ssrcs:"".concat(t.video," ").concat(t.videoRtx)}],s.direction=nC.TRANSCEIVER_DIRECTION_SENDONLY;var d="".concat(l,"-aux");s.ssrcs=[{id:t.auxiliary,attribute:"cname",value:d},{id:t.auxiliary,attribute:"msid",value:"".concat(d," ").concat(l,"-aux").concat(nC.VIDEO)},{id:t.auxiliaryRtx,attribute:"cname",value:"".concat(d," ").concat(l,"-aux").concat(nC.VIDEO)},{id:t.auxiliaryRtx,attribute:"msid",value:"".concat(d," ").concat(l,"-aux").concat(nC.VIDEO)}],s.ssrcGroups=[{semantics:"FID",ssrcs:"".concat(t.auxiliary," ").concat(t.auxiliaryRtx)}],this._parsedAnswer.groups&&(this._parsedAnswer.groups[0].mids=this._parsedAnswer.media.map((function(e){return e.mid})).join(" ")),this._downlinkMIDMap.set(n,[a.mid,o.mid,s.mid]),this._downlinkMIDUserIDMap.set(a.mid,n),this._downlinkMIDUserIDMap.set(o.mid,n),this._downlinkMIDUserIDMap.set(s.mid,n)}}},{key:"removeDownlink",value:function(e){return aR(this,null,f().mark((function t(){var n,r,i=this;return f().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this._downlinkMIDMap.has(e)&&this._peerConnection){t.next=2;break}return t.abrupt("return");case 2:if(this._log.info("removeDownlink(".concat(e,") trying")),t.t0=this.isReconnecting,!t.t0){t.next=7;break}return t.next=7,this.waitForReconnected();case 7:if(t.t1=this._updateSDPPromise,!t.t1){t.next=11;break}return t.next=11,this._updateSDPPromise;case 11:if(n=this._downlinkMIDMap.get(e),r=!1,this._peerConnection.getTransceivers().forEach((function(e){null!=n&&n.includes(Number(e.mid))&&(r=!0,e.direction="inactive")})),this._parsedAnswer||(this._parsedAnswer=wj(this._peerConnection.remoteDescription.sdp)),this._parsedAnswer.media.forEach((function(e){null!=n&&n.includes(Number(e.mid))&&(r=!0,e.direction="inactive",e.ssrcs=[],e.ssrcGroups=[])})),t.t2=0===this.removeDownlinkQueue.size&&r,!t.t2){t.next=19;break}return t.next=19,this.updateSDP();case 19:this._downlinkMIDMap.delete(e),null==n||n.forEach((function(e){return i._downlinkMIDUserIDMap.delete(e)})),this._log.info("removeDownlink(".concat(e,") done"));case 22:case"end":return t.stop()}}),t,this)})))}},{key:"setBandwidth",value:function(e){return aR(this,null,f().mark((function t(){var n,r,i,a,o,s,c,u,l;return f().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(n=e.audio,r=e.bigVideo,i=e.smallVideo,a=e.auxVideo,t.prev=3,!rP()){t.next=26;break}o=this._peerConnection.getSenders().slice(0,4),s=0;case 7:if(!(s<o.length)){t.next=17;break}if(c=void 0,u=o[s],0===s&&n?c=n:1===s&&r?c=r:2===s&&i?c=i:3===s&&a&&(c=a),t.t0=c,!t.t0){t.next=14;break}return t.next=14,this.setSenderMaxBitrate(u,c);case 14:s++,t.next=7;break;case 17:if(l=!1,r&&o[1].track&&(l=this.setStartBitrate(1,r)),a&&o[3].track&&(l=this.setStartBitrate(3,a)||l),t.t1=l,!t.t1){t.next=24;break}return t.next=24,this.updateSDP();case 24:t.next=28;break;case 26:return t.next=28,this.setBandwidthBySDP(e);case 28:this._log.info("setBandwidth ".concat(JSON.stringify(e))),t.next=34;break;case 31:t.prev=31,t.t2=t.catch(3),this._log.error("failed to set bandwidth: ".concat(t.t2));case 34:case"end":return t.stop()}}),t,this,[[3,31]])})))}},{key:"setStartBitrate",value:function(e,t){var n,r;return!(null==(n=this._peerConnection)||!n.remoteDescription||(this._parsedAnswer||(this._parsedAnswer=wj(this._peerConnection.remoteDescription.sdp)),null==(r=this._parsedAnswer.media[e])||!r.fmtp[0])||(this._parsedAnswer.media[e].fmtp[0].config+=";x-google-start-bitrate=".concat(t>5e3?5e3:t),0))}},{key:"setSenderMaxBitrate",value:function(e,t){var n=e.getParameters();return(!n.encodings||0===n.encodings.length)&&(n.encodings=[{}]),"unlimited"===t?delete n.encodings[0].maxBitrate:n.encodings[0].maxBitrate=1e3*t,e.setParameters(n)}},{key:"setBandwidthBySDP",value:function(e){var t=e.audio,n=e.bigVideo,r=e.smallVideo,i=e.auxVideo;if(this._peerConnection&&this._peerConnection.localDescription){var a=wj(this._peerConnection.localDescription.sdp);this._parsedAnswer||(this._parsedAnswer=wj(this._peerConnection.remoteDescription.sdp));var o=wD?"TIAS":"AS";t&&(a.media[0].bandwidth=[{type:o,limit:wD?1e3*t:t}],this._parsedAnswer.media[0].bandwidth=[{type:o,limit:wD?1e3*t:t}]),n&&(a.media[1].bandwidth=[{type:o,limit:wD?1e3*n:n}],this._parsedAnswer.media[1].bandwidth=[{type:o,limit:wD?1e3*n:n}]),r&&(a.media[2].bandwidth=[{type:o,limit:wD?1e3*r:r}],this._parsedAnswer.media[2].bandwidth=[{type:o,limit:wD?1e3*r:r}]),i&&(a.media[3].bandwidth=[{type:o,limit:wD?1e3*i:i}],this._parsedAnswer.media[3].bandwidth=[{type:o,limit:wD?1e3*i:i}]);var s={type:"offer",sdp:Dj(a)};return this.updateSDP({localDescription:s})}}},{key:"setScaleResolutionDownBy",value:function(e,t,n){var r=e.getParameters();(!r.encodings||0===r.encodings.length)&&(r.encodings=[{}]);var i=r.encodings[0].scaleResolutionDownBy;if(Iw(i)?1!==t:t!==i){var a="setScaleResolutionDownBy ".concat(n," ").concat(t);return i&&(a+=" prevScale: ".concat(i)),this._log.warn(a),r.encodings[0].scaleResolutionDownBy=t,e.setParameters(r)}}},{key:"updateSDP",value:function(){var e=this,t=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}).localDescription;if(!this._parsedAnswer)return Promise.resolve();var n=Dj(this._parsedAnswer);return this._updateSDPPromise=new Promise((function(r,i){return aR(e,null,f().mark((function e(){var a,o;return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(e.prev=0,e.t0=!t&&this._peerConnection,!e.t0){e.next=7;break}return this._log.info("creating offer"),e.next=6,this._peerConnection.createOffer();case 6:t=e.sent;case 7:if(e.t1=t,!e.t1){e.next=11;break}return e.next=11,this.setOffer(t);case 11:return e.next=13,this.setAnswer({type:"answer",sdp:n});case 13:this._updateSDPPromise=null,r(),e.next=20;break;case 17:e.prev=17,e.t2=e.catch(0),this._log.error(e.t2),!this._isSDPLogged&&this._peerConnection&&(this._log.warn("current offer: ".concat(this.filterSDPDirection(null==(a=this._peerConnection.localDescription)?void 0:a.sdp)," \nnext offer: ").concat(this.filterSDPDirection(null==t?void 0:t.sdp))),this._log.warn("current answer: ".concat(this.filterSDPDirection(null==(o=this._peerConnection.remoteDescription)?void 0:o.sdp)," \nnext answer: ").concat(this.filterSDPDirection(n))),this._log.warn("offer: ".concat(null==t?void 0:t.sdp)),this._log.warn("answer: ".concat(n)),this._log.warn("transceivers: ".concat(JSON.stringify(this._peerConnection.getTransceivers().map((function(e){return{mid:e.mid,currentDirection:e.currentDirection,direction:e.direction,stopped:e.stopped}}))))),this._log.warn("parsedAnswer: ".concat(JSON.stringify(this._parsedAnswer))),this._isSDPLogged=!0),this._updateSDPPromise=null,i(e.t2);case 20:case"end":return e.stop()}}),e,this,[[0,17]])})))})),this._updateSDPPromise}},{key:"setTransceiverDirection",value:function(e,t){return aR(this,null,f().mark((function n(){var r,i,a,o,c;return f().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(wD&&this._peerConnection&&this._parsedAnswer){n.next=2;break}return n.abrupt("return");case 2:this._log.info("setting transceiver ".concat(t.join(",")," direction to ").concat(e)),r=this._peerConnection.getTransceivers(),t.forEach((function(t){r[t].direction!==e&&(r[t].direction=e)})),i=s(t);try{for(i.s();!(a=i.n()).done;)o=a.value,c=this._parsedAnswer.media[o].direction,e===rC.INACTIVE&&c===rC.RECVONLY&&(this._parsedAnswer.media[o].direction=e),e===rC.SENDONLY&&c===rC.INACTIVE&&(this._parsedAnswer.media[o].direction=rC.RECVONLY)}catch(u){i.e(u)}finally{i.f()}return n.next=9,this.updateSDP();case 9:case"end":return n.stop()}}),n,this)})))}},{key:"filterSDPDirection",value:function(){return wj(arguments.length>0&&void 0!==arguments[0]?arguments[0]:"").media.map((function(e){return e.direction}))}},{key:"setOffer",value:function(e){this._log.info("setting offer");var t=function(e,t,n){var r=uH.default.parse(e);return r.media.forEach((function(e,i){var a;if((e.type===nC.AUDIO||e.type===nC.VIDEO)&&(function(e){if(e.rtcpFb){var t=[];e.rtcpFb.forEach((function(n,r){var i;t.push(n),e.rtcpFb&&(null==(i=e.rtcpFb[r+1])?void 0:i.payload)!==n.payload&&"rrtr"!==n.type&&t.push({payload:n.payload,type:"rrtr"})})),e.rtcpFb=t}}(e),function(e){e.type===nC.VIDEO&&e.fmtp&&e.fmtp.forEach((function(e){e.config.includes("apt")||(e.config+=";sps-pps-idr-in-keyframe=1")}))}(e),function(e){e.type===nC.AUDIO&&e.fmtp&&e.fmtp.forEach((function(e){e.config+=";sprop-stereo=1;stereo=1"}))}(e),function(e){var t=new Set(["urn:ietf:params:rtp-hdrext:sdes:mid","urn:ietf:params:rtp-hdrext:sdes:rtp-stream-id","urn:ietf:params:rtp-hdrext:sdes:repaired-rtp-stream-id"]);e.ext&&(e.ext=e.ext.filter((function(e){return!t.has(e.uri)})))}(e),e.type===nC.VIDEO))if(i<4)e.payloads="",e.fmtp=[],e.rtp=[],e.rtcpFb=[],t.video.codecs.forEach((function(t){return pH(e,t)}));else if(n){e.payloads="",e.fmtp=[],e.rtp=[],e.rtcpFb=[];var o=n.video.decoders;(!o||0===o.length)&&(o=n.video.codecs),(!o||0===o.length)&&(o=t.video.decoders),o.forEach((function(t){return pH(e,t)}))}null!=(a=e.payloads)&&a.includes("datachannel")&&r.groups&&e.mid&&(r.groups[0].mids=r.groups[0].mids.replace(e.mid,"dc"),e.mid="dc")})),uH.default.write(r)}(e.sdp,this.clientAbility,this._serverAbility);return this._log.debug(t),this._peerConnection.setLocalDescription({type:"offer",sdp:t})}},{key:"setAnswer",value:function(e){return this._log.info("setting answer"),this._log.debug(e.sdp),this._peerConnection.setRemoteDescription(e)}},{key:"switchVideoEncoder",value:function(e){return aR(this,null,f().mark((function t(){var n,r=this;return f().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this._peerConnection&&this._parsedAnswer&&this._serverAbility){t.next=2;break}return t.abrupt("return");case 2:if(n=!1,this._parsedAnswer.media.forEach((function(t){var i;if(t.type===nC.VIDEO){var a=r._serverAbility.video.codecs.find((function(t){return t.codec.toLowerCase()===e}));a&&(null==(i=t.payloads)||!i.includes(String(a.payload)))&&(t.fmtp=[],t.payloads="",t.rtp=[],t.rtcpFb=[],pH(t,a),n=!0)}})),t.t0=n,!t.t0){t.next=9;break}return this._log.warn("switch video encoder to ".concat(e)),t.next=9,this.updateSDP();case 9:case"end":return t.stop()}}),t,this)})))}},{key:"useHWEncoder",value:function(){var e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0],t=arguments.length>1?arguments[1]:void 0;return aR(this,null,f().mark((function n(){var r,i,a=this;return f().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(this._peerConnection&&this._parsedAnswer&&this._serverAbility){n.next=2;break}return n.abrupt("return");case 2:if(r=!1,i=[],Iw(t)?i=this._parsedAnswer.media.slice(1,4):2===t?i.push(this._parsedAnswer.media[1]):3===t?i.push(this._parsedAnswer.media[2]):7===t&&i.push(this._parsedAnswer.media[3]),i.forEach((function(t){var n,i;t.type===nC.VIDEO&&(e&&a.is42001fSupported?i=a.clientAbility.video.codecs.find((function(e){return e.fmtp.includes("42001f")})):e||(i=a._serverAbility.video.codecs.find((function(e){return e.codec.toLowerCase()===(a._serverAbility.useVp8?"vp8":"h264")}))),i&&(null==(n=t.payloads)||!n.includes(String(i.payload)))&&(t.fmtp=[],t.payloads="",t.rtp=[],t.rtcpFb=[],pH(t,i),r=!0))})),n.t0=r,!n.t0){n.next=10;break}return this._log.warn("use ".concat(e?"hw":"sw"," encoder")),n.next=10,this.updateSDP();case 10:case"end":return n.stop()}}),n,this)})))}},{key:"sendDataChannelMessage",value:function(e){var t;null==(t=this._datachannel)||t.send(e)}},{key:"reset",value:function(){this._peerConnection&&(this._peerConnection.close(),this._peerConnection.removeEventListener("track",this._peerConnection._onaddstreampoly,this),this._peerConnection._onaddstreampoly=null,this._peerConnection=null),this._waitForPCConnectedPromise=null,this._parsedAnswer=null,this.originOffer=null}},{key:"close",value:function(){this._log.info("close pc"),this.removeRTCListener(),this.insertableStreamsAbortMap.forEach((function(e){return cD(e.abort)&&e.abort("destroy")})),this.insertableStreamsAbortMap.clear(),this.reset(),this.emitConnectionStateChangedEvent("DISCONNECTED"),this._downlinkMIDMap.clear(),this.stopReconnection(),this.removeAllListeners(),this._room.healthDetector.off("1",this.onBadHealth,this)}},{key:"getReceiversByUserId",value:function(e){if(!this._peerConnection)return[];var t=this._peerConnection.getReceivers();return(this._downlinkMIDMap.get(e)||[]).map((function(e){return t[e]}))}},{key:"isUsingRelay",get:function(){return"relay"===this._room.getIceTransportPolicy()}},{key:"detectTCPAndUDP",value:function(e){var t,n=e.uplinkRTT,r=e.downlinkRTT;if("CONNECTED"===this.currentState&&(!this._isRelayTried||this._room.forceRelay)&&0!==this._room.getIceServers().length){var i=this._signalChannel.rtt,a=Math.max(n,r),o=(null==(t=this._room.scheduleResult.config)?void 0:t.useTurnTcpInfo)||{},s=o.rttRatioThreshold,c=o.rttThreshold;if(s&&c&&i&&a){var u=Math.floor(a/i),l=(this._isRelayTried||u>s)&&a>c;l?++this._rttOverCount<5||(this._log.warn("detectTCPAndUDP ws-rtt: ".concat(i," upRTT: ").concat(n," downRTT: ").concat(r," ratio: ").concat(u," over-count: ").concat(this._rttOverCount," isOver: ").concat(l," isRelayTried: ").concat(this._isRelayTried," force-relay: ").concat(this._room.forceRelay)),this.isUsingRelay||this._isRelayTried?this._room.forceRelay&&this.switchRelay(!1):(this._isRelayTried=!0,this._rttOverCount=0,this.switchRelay(!0))):this._rttOverCount=0}}}},{key:"switchRelay",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return aR(this,null,f().mark((function n(){var r,i,a;return f().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(this.isUsingRelay!==e){n.next=2;break}return n.abrupt("return");case 2:return r=e?"relay":"udp",i=e?521709:521710,n.prev=3,this._room.forceRelay=e,this._log.warn("switchRelay ".concat(r)),a=Date.now(),n.next=8,this.doSwitchRelay(r);case 8:this._log.warn("switchRelay ".concat(r," success")),bO.addSuccessEvent({key:i,cost:Date.now()-a}),n.next=22;break;case 12:if(n.prev=12,n.t0=n.catch(3),this._log.warn("switchRelay ".concat(r," failed"),n.t0),bO.addFailedEvent({key:i,error:n.t0}),!t){n.next=20;break}this._room.reJoin(),n.next=22;break;case 20:return n.next=22,this.switchRelay(!e,!0);case 22:case"end":return n.stop()}}),n,this,[[3,12]])})))}},{key:"doSwitchRelay",value:function(e){var t=this;return new Promise((function(n,r){var i=setTimeout((function(){t.stopReconnection(),r(new Error("switch ".concat(e," timeout")))}),1e4);t.startReconnection().then(n,r).finally((function(){return clearTimeout(i)}))}))}},{key:"removeRTCListener",value:function(){this._peerConnection&&(this._peerConnection.oniceconnectionstatechange=null,this._peerConnection.onconnectionstatechange=null,this._peerConnection.onsignalingstatechange=null,this._peerConnection.ontrack=null),this.dtlsTransport&&(this.dtlsTransport.onstatechange=null)}}])}(cH.default);nR([vL("reconnect")],IH.prototype,"startReconnection",1),nR([_L((function(e){return e.userId}))],IH.prototype,"addDownlink",1),nR([_L((function(e){return e}))],IH.prototype,"removeDownlink",1),nR([mL(!0)],IH.prototype,"updateSDP",1),nR([gL(521712,!1)],IH.prototype,"setOffer",1),nR([gL(521713,!1)],IH.prototype,"setAnswer",1);var bH=o((function e(t){r(this,e),rR(this,"tag"),rR(this,"len"),rR(this,"data");var n=new DataView(t);this.tag=n.getUint16(),this.len=n.getUint16(2),this.data=new Uint8Array(t).slice(4,4+this.len).buffer})),AH=o((function e(t){var n=this;r(this,e),rR(this,"tinyId"),rR(this,"data");for(var i=new DataView(t),a=0,o=[];a<i.byteLength;){var s=i.getUint16(a+2),c=new bH(new Uint8Array(t).slice(a,a+2+2+s).buffer);o.push(c),a+=4+s}o.forEach((function(e){1===e.tag?n.tinyId=(new TextDecoder).decode(e.data):2===e.tag&&(n.data=e.data)}))})),RH=new Set;function CH(){var e=Math.floor(4294967296*Math.random());return RH.has(e)?CH():(RH.add(e),e)}var wH=function(e){function i(e){var a;return r(this,i),a=n(this,i),rR(t(a),"userId"),rR(t(a),"tinyId"),rR(t(a),"_sdpSemantics"),rR(t(a),"_isUplink"),rR(t(a),"_room"),rR(t(a),"_log"),rR(t(a),"_currentState","DISCONNECTED"),rR(t(a),"_prevTime",-1),a.userId=e.userId,a.tinyId=e.tinyId,a._room=e.room,a._sdpSemantics=e.room.sdpSemantics,a._isUplink=e.isUplink,a._log=sx.createLogger({id:"n",userId:a._room.userId,remoteUserId:a._isUplink?void 0:a.userId,sdkAppId:a._room.sdkAppId,isLocal:a._isUplink}),a}return d(i,e),o(i,[{key:"_peerConnection",get:function(){var e;return(null==(e=this.singlePC)?void 0:e.getPeerConnection())||null}},{key:"singlePC",get:function(){return this._room.singlePC}},{key:"_signalChannel",get:function(){return this._room.signalChannel}},{key:"close",value:function(e){this._log.info("close connection"),this.emit("closed",e)}},{key:"emitConnectionStateChangedEvent",value:function(e){return e!==this._currentState&&(rx.emit(ax.PEER_CONNECTION_STATE_CHANGED,{room:this._room,prevState:this._currentState,state:e,remoteUserId:this._isUplink?void 0:this.userId}),this.emit("connection-state-changed",{prevState:this._currentState,state:e}),this._currentState=e,!0)}},{key:"getPeerConnection",value:function(){return this._peerConnection}},{key:"getRoom",value:function(){return this._room}},{key:"getUserId",value:function(){return this.userId}},{key:"getTinyId",value:function(){return this.tinyId}},{key:"getCurrentState",value:function(){return this._currentState}},{key:"isH264",get:function(){var e,t;return!(null==(t=null==(e=this._peerConnection)?void 0:e.remoteDescription)||!t.sdp.includes("H264"))}}])}(tR(oR()).default),DH=function(e){function i(e){var a;return r(this,i),a=n(this,i,[$A(QA({},e),{isUplink:!0})]),rR(t(a),"localMainAudioTrack",null),rR(t(a),"localMainVideoTrack",null),rR(t(a),"localAuxAudioTrack",null),rR(t(a),"localAuxVideoTrack",null),rR(t(a),"_isPublishingAux",!1),rR(t(a),"_publishingLocalAudioTrack"),rR(t(a),"_publishingLocalVideoTrack"),rR(t(a),"_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}),rR(t(a),"_flag",0),rR(t(a),"_checkPublishStateTimeoutId",-1),a.initialize(),a}return d(i,e),o(i,[{key:"videoCodec",get:function(){var e;return(null==(e=this.singlePC)?void 0:e.videoCodec)||"h264"}},{key:"ssrc",get:function(){if(!this.singlePC)return{audio:0,video:0,videoRtx:0,small:0,smallRtx:0,auxiliary:0,auxiliaryRtx:0};var e=this.singlePC.uplinkSSRC;return{audio:e.audioSsrc||0,video:e.bigVideoSsrc||0,videoRtx:e.bigVideoRtxSsrc||0,small:e.smallVideoSsrc||0,smallRtx:e.smallVideoRtxSsrc||0,auxiliary:e.auxVideoSsrc||0,auxiliaryRtx:e.auxVideoRtxSsrc||0}}},{key:"flag",get:function(){return this._flag},set:function(e){this._flag!==e&&(this._flag=e,this.checkPublishState())}},{key:"checkPublishState",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];if(t||!(this._checkPublishStateTimeoutId>0)){var n=this.publishState,r=this.serverPublishState,i=Object.keys(n).find((function(e){return n[e]!==r[e]}));if(i){if(!t)return void(this._checkPublishStateTimeoutId=MP.run("timeout",(function(){return e.checkPublishState(!0)}),{delay:1e4,count:1}));this._log.warn("publish state not matched, ".concat(i," local:").concat(n[i]," server:").concat(r[i]," ").concat(ZN()," ").concat(qN())),bO.addCount({key:521e3})}MP.clearTask(this._checkPublishStateTimeoutId),this._checkPublishStateTimeoutId=-1}}},{key:"isMainStreamPublished",get:function(){return!(!this.localMainAudioTrack&&!this.localMainVideoTrack)}},{key:"isAuxStreamPublished",get:function(){return!(!this.localAuxVideoTrack&&!this.localAuxAudioTrack)}},{key:"publishState",get:function(){var e,t,n,r,i=this,a={audio:!1,bigVideo:!1,smallVideo:!1,auxVideo:!1};if(this._peerConnection){var o=this._peerConnection.getSenders();o&&(QO()?(a.audio=!(null==(e=o[0])||!e.track),a.bigVideo=!(null==(t=o[1])||!t.track),a.smallVideo=!(null==(n=o[2])||!n.track),a.auxVideo=!(null==(r=o[3])||!r.track)):o.forEach((function(e){e.track&&(e.track.kind===nC.AUDIO?a.audio=!0:(a.bigVideo=!0,i._room.videoManager.hasSmall&&(a.smallVideo=!0)))})))}return a}},{key:"publishingState",get:function(){var e=this.publishState,t=QA({},e);return this._publishingLocalAudioTrack&&(t.audio=!0),this._publishingLocalVideoTrack&&(this._isPublishingAux?t.auxVideo=!0:(t.bigVideo=!0,this._publishingLocalVideoTrack.small&&(t.smallVideo=!0))),t}},{key:"serverPublishState",get:function(){return{audio:!!(this.flag&uC),bigVideo:!!(this.flag&oC),smallVideo:!!(this.flag&sC),auxVideo:!!(this.flag&cC)}}},{key:"muteState",get:function(){var e,t,n;return{audio:!(null==(e=this.localMainAudioTrack)||!e.muted),bigVideo:!(null==(t=this.localMainVideoTrack)||!t.muted),auxVideo:!(null==(n=this.localAuxVideoTrack)||!n.muted)}}},{key:"initialize",value:function(){this.installEvents()}},{key:"close",value:function(e){var t,n,r=s((null==(t=this._peerConnection)?void 0:t.getSenders())||[]);try{for(r.s();!(n=r.n()).done;)n.value.replaceTrack(null)}catch(a){r.e(a)}finally{r.f()}g(i,"close",this,3)([e]),this.uninstallEvents(),this.uninstallTrackMuteEvents(this.localMainAudioTrack,this.localMainVideoTrack,this.localAuxVideoTrack),this.emitConnectionStateChangedEvent("DISCONNECTED")}},{key:"installEvents",value:function(){this.listeners("connection-state-changed").includes(this.handleConnectionStateChange)||this.on("connection-state-changed",this.handleConnectionStateChange,this),this.installSPCEvents()}},{key:"installSPCEvents",value:function(){var e,t;null!=(e=this.singlePC)&&e.listeners("spc-reconnected").includes(this.onSinglePCReconnected)||null==(t=this.singlePC)||t.on("spc-reconnected",this.onSinglePCReconnected,this)}},{key:"uninstallSPCEvents",value:function(){var e;null==(e=this.singlePC)||e.off("spc-reconnected",this.onSinglePCReconnected,this)}},{key:"uninstallEvents",value:function(){this.off("connection-state-changed",this.handleConnectionStateChange,this),this.uninstallSPCEvents()}},{key:"emitConnectionStateChangedEvent",value:function(e,t){var n,r,a,o=this._currentState,s=g(i,"emitConnectionStateChangedEvent",this,3)([e]);return s&&o!==e&&(t?t.emit("connection-state-changed",{prevState:o,state:e}):(null==(n=this.localMainVideoTrack)||n.emit("connection-state-changed",{prevState:o,state:e}),null==(r=this.localAuxVideoTrack)||r.emit("connection-state-changed",{prevState:o,state:e}),null==(a=this._publishingLocalVideoTrack)||a.emit("connection-state-changed",{prevState:o,state:e}))),s}},{key:"onVideoEncodeFailed",value:function(e){var t;e&&e.isMediaTrackActive&&"h264"===this.videoCodec&&(this._log.warn("h264 encoder not working"),null!=(t=this.singlePC)&&t.isVP8EncodeSupported&&(this._log.warn("switch to vp8"),this.singlePC.switchVideoEncoder("vp8")))}},{key:"publish",value:function(e){return aR(this,arguments,(function(e){var t=this,n=e.localAudioTrack,r=e.localVideoTrack,i=e.isAuxiliary;return f().mark((function e(){var a,o,s,c,u,l,d,h,p,m,v;return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t.singlePC){e.next=2;break}return e.abrupt("return");case 2:return t.installEvents(),e.next=5,t.singlePC.waitForPeerConnectionConnected();case 5:if(p=t.publishState,m=t.muteState,n&&(t._publishingLocalAudioTrack=n,p.audio=!0,m.audio=n.muted),!r){e.next=22;break}if(t.singlePC.isH264EncodeSupported||t.singlePC.isVP8EncodeSupported){e.next=9;break}throw new yR({code:_R.NOT_SUPPORTED_H264,message:mO({key:dO.NOT_SUPPORTED_H264ENCODE})});case 9:if(e.t0=t.singlePC.isUsingH264&&!t.singlePC.isH264EncodeSupported&&t.singlePC.isVP8EncodeSupported,!e.t0){e.next=14;break}return t._log.warn("h264 encoder not supported"),e.next=14,t.singlePC.switchVideoEncoder("vp8");case 14:if(e.t1=bD&&115===AN()&&r.profile.width*r.profile.height<=230400,!e.t1){e.next=20;break}return t._log.warn("fallback video to 480p"),r.setProfile(eC["480p_2"]),e.next=20,r.applyProfile();case 20:t._publishingLocalVideoTrack=r,i?(p.auxVideo=!0,m.auxVideo=r.muted):(p.bigVideo=!0,m.bigVideo=r.muted);case 22:return t._isPublishingAux=i,r&&!i&&r.small&&(h=t._room.videoManager.smallTrack,p.smallVideo=!0),e.next=26,t._signalChannel.sendWaitForResponseWithRetry({command:"publish/v2",responseCommand:fj.SPC_PUBLISH_RESULT,data:$A(QA({},t.singlePC.uplinkSSRC),{state:p,muteState:m}),retries:3});case 26:return e.next=28,t.publishByTransceiver({localAudioTrack:n,localVideoTrack:r,smallTrack:h,isAuxiliary:i});case 28:if(t._publishingLocalAudioTrack=null,t._publishingLocalVideoTrack=null,t._isPublishingAux=!1,!r){e.next=36;break}return t[i?"localAuxVideoTrack":"localMainVideoTrack"]=r,v=r.scaleResolutionDownBy,e.next=36,t.singlePC.setScaleResolutionDownBy(t._peerConnection.getSenders()[i?3:1],v,r.streamType);case 36:return n&&(t[i?"localAuxAudioTrack":"localMainAudioTrack"]=n),e.next=39,t.singlePC.setBandwidth({audio:(null==(a=t.localMainAudioTrack)?void 0:a.profile.bitrate)||(null==(o=t.localAuxAudioTrack)?void 0:o.profile.bitrate),bigVideo:null==(s=t.localMainVideoTrack)?void 0:s.profile.bitrate,smallVideo:null==(u=null==(c=t.localMainVideoTrack)?void 0:c.small)?void 0:u.bitrate,auxVideo:null==(l=t.localAuxVideoTrack)?void 0:l.profile.bitrate});case 39:t.sendMediaSettings(),t.installTrackMuteEvents(n,r),(t._room.preferHW||null!=(d=t._room.scheduleResult.config)&&d.preferHW)&&r&&r.profile.width*r.profile.height>=921600&&t.singlePC.useHWEncoder(!0,i?7:2);case 42:case"end":return e.stop()}}),e)}))()}))}},{key:"publishByTransceiver",value:function(e){var t=this,n=e.localAudioTrack,r=e.localVideoTrack,i=e.smallTrack,a=e.isAuxiliary;if($O()){this._log.info("publish by transceiver");var o=null==r?void 0:r.outMediaTrack,s=null==n?void 0:n.outMediaTrack,c=this._peerConnection.getTransceivers(),u=[],l=[],d=function(e,n,r){var i,a,o=c[n].sender.replaceTrack(r);l.push(n),null!=(i=t.singlePC)&&i.enableInsertableStreams&&o.then((function(){return t.createEncodedStreams(c[n].sender,e)})),null!=(a=t.singlePC)&&a.scriptTransformWorker&&t.initSenderTransfrom(c[n].sender,e),u.push(o)};s&&d(n.mediaType,0,s),o&&d(r.mediaType,a?3:1,o),i&&d(8,2,i);var h=this.singlePC.setTransceiverDirection(rC.SENDONLY,l);return u.push(h),Promise.all(u)}}},{key:"getTrackByMediaType",value:function(e){switch(e){case 1:return this.localMainAudioTrack||this._publishingLocalAudioTrack;case 4:case 8:return this.localMainVideoTrack||this._publishingLocalVideoTrack;case 2:return this.localAuxVideoTrack||this._publishingLocalVideoTrack;default:return null}}},{key:"createEncodedStreams",value:function(e,t){var n,r,i=this;if(!this.singlePC.insertableStreamsAbortMap.has(e)){var a=e.createEncodedStreams(),o=new AbortController;null==(n=this.singlePC)||n.addAbortController(e,o),(null!=(r=this.getTrackByMediaType(t))&&r.enableEncodeFrame?a.readable.pipeThrough(new TransformStream({transform:function(e,n){var r,a=i.getTrackByMediaType(t);n.enqueue(null!=(r=i.singlePC)&&r.isUsingH264&&a?a.encodeFrame(e,8===t):e)}}),o):a.readable).pipeTo(a.writable,o).catch((function(e){i._log.debug("encoded stream error",e),"destory"!==e&&i._log.warn(e)}))}}},{key:"initSenderTransfrom",value:function(e,t){if(this._peerConnection&&this.singlePC&&this.singlePC.scriptTransformWorker){var n=2!==t,r=8===t;e.transform||(e.transform=new RTCRtpScriptTransform(this.singlePC.scriptTransformWorker,{isReceiver:!1,isAudio:1===t,isMain:n,isSmall:r}))}}},{key:"enableSmall",value:function(e){return aR(this,null,f().mark((function t(){var n,r,i;return f().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this.singlePC){t.next=2;break}return t.abrupt("return");case 2:if(r=this._peerConnection.getTransceivers(),!e){t.next=13;break}if(!this._room.videoManager.smallTrack){t.next=11;break}return i=r[2].sender,null!=(n=this.singlePC)&&n.enableInsertableStreams&&this.createEncodedStreams(i,8),t.next=9,i.replaceTrack(this._room.videoManager.smallTrack);case 9:return t.next=11,this.singlePC.setTransceiverDirection(rC.SENDONLY,[2]);case 11:t.next=17;break;case 13:return t.next=15,r[2].sender.replaceTrack(null);case 15:return t.next=17,this.singlePC.setTransceiverDirection(rC.INACTIVE,[2]);case 17:return this.updateMediaSettings(),t.next=20,this.doPublishChange();case 20:case"end":return t.stop()}}),t,this)})))}},{key:"installTrackMuteEvents",value:function(){for(var e=this,t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];n.forEach((function(t){t&&(null==t||t.on("mute",e.sendMutedFlag,e),null==t||t.on("unmute",e.sendMutedFlag,e))}))}},{key:"uninstallTrackMuteEvents",value:function(){for(var e=this,t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];n.forEach((function(t){t&&(null==t||t.off("mute",e.sendMutedFlag,e),null==t||t.off("unmute",e.sendMutedFlag,e))}))}},{key:"unpublish",value:function(e){return aR(this,arguments,(function(e){var t=this,n=e.localAudioTrack,r=e.localVideoTrack;return f().mark((function e(){var i,a,o,s;return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(i=r&&r===t.localAuxVideoTrack,a=null==r?void 0:r.outMediaTrack,o=t._peerConnection.getSenders(),s=[],e.t0=n,!e.t0){e.next=9;break}if(i?t.localAuxAudioTrack=null:t.localMainAudioTrack=null,e.t1=!t.localMainAudioTrack&&!t.localAuxAudioTrack,!e.t1){e.next=9;break}return e.next=8,o[0].replaceTrack(null);case 8:s.push(0);case 9:if(e.t2=a,!e.t2){e.next=26;break}if(!i){e.next=19;break}return e.next=14,o[3].replaceTrack(null);case 14:t.localAuxVideoTrack=null,t._mediaSettings=$A(QA({},t._mediaSettings),{auxVideoBps:0,auxVideoFps:0,auxVideoWidth:0,auxVideoHeight:0}),s.push(3),e.next=26;break;case 19:return e.next=21,o[1].replaceTrack(null);case 21:return e.next=23,o[2].replaceTrack(null);case 23:t.localMainVideoTrack=null,t._mediaSettings=$A(QA({},t._mediaSettings),{videoWidth:0,videoHeight:0,videoBps:0,videoFps:0,audioFs:0,audioChannel:0,audioBps:0,smallVideoWidth:0,smallVideoHeight:0,smallVideoFps:0,smallVideoBps:0}),s.push(1,2);case 26:if(!t.isMainStreamPublished&&!t.isAuxStreamPublished){e.next=33;break}return e.next=29,t.singlePC.setTransceiverDirection(rC.INACTIVE,s);case 29:return e.next=31,t.doPublishChange(!1);case 31:e.next=35;break;case 33:return e.next=35,t.doUnpublish();case 35:t.uninstallTrackMuteEvents(n,r),null==r||r.emit("connection-state-changed",{prevState:t._currentState,state:"DISCONNECTED"});case 37:case"end":return e.stop()}}),e)}))()}))}},{key:"doPublishChange",value:function(){var e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];return aR(this,null,f().mark((function t(){var n,r;return f().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n={state:this.publishingState,constraintConfig:this._mediaSettings},t.next=3,this._signalChannel.sendWaitForResponseWithRetry({command:mj,data:n,responseCommand:fj.PUBLISH_STATE_CHANGE_RESULT,enableLog:e,retries:3});case 3:r=t.sent,this.checkPublishResultCode(r.data.code,r.data.message);case 5:case"end":return t.stop()}}),t,this)})))}},{key:"doUnpublish",value:function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return this._signalChannel.sendWaitForResponse({command:vj,commandDesc:"unpublish",responseCommand:fj.UNPUBLISH_RESULT,enableLog:e}).catch((function(e){if(e.getCode()===_R.API_CALL_TIMEOUT)return Promise.resolve();throw e}))}},{key:"updateMediaSettings",value:function(){var e;this._mediaSettings.videoCodec=(null==(e=this.singlePC)?void 0:e.videoCodec)||"h264";var t=this._publishingLocalAudioTrack||this.localMainAudioTrack||this.localAuxAudioTrack,n=this.localMainVideoTrack,r=this.localAuxVideoTrack;if(this._publishingLocalVideoTrack&&(this._isPublishingAux?r=this._publishingLocalVideoTrack:n=this._publishingLocalVideoTrack),aP){if(t&&t.outMediaTrack){var i=t.outMediaTrack.getSettings();this._mediaSettings.audioChannel=i.channelCount||1,this._mediaSettings.audioBps=1e3*t.profile.bitrate,this._mediaSettings.audioFs=i.sampleRate||0}if(n&&n.outMediaTrack){var a=n.outMediaTrack.getSettings(),o=n.scaleResolutionDownBy;this._mediaSettings.videoWidth=a.width/o||0,this._mediaSettings.videoHeight=a.height/o||0,this._mediaSettings.videoFps=a.frameRate||0,this._mediaSettings.videoBps=1e3*n.profile.bitrate,n.small&&(this._mediaSettings.smallVideoWidth=n.small.width,this._mediaSettings.smallVideoHeight=n.small.height,this._mediaSettings.smallVideoFps=n.small.frameRate,this._mediaSettings.smallVideoBps=1e3*n.small.bitrate)}if(r&&r.outMediaTrack){var s=r.outMediaTrack.getSettings(),c=r.scaleResolutionDownBy;this._mediaSettings.auxVideoWidth=s.width/c||0,this._mediaSettings.auxVideoHeight=s.height/c||0,this._mediaSettings.auxVideoFps=s.frameRate||0,this._mediaSettings.auxVideoBps=1e3*r.profile.bitrate}}else t&&t.outMediaTrack&&(this._mediaSettings.audioChannel=t.profile.channelCount,this._mediaSettings.audioBps=1e3*t.profile.bitrate,this._mediaSettings.audioFs=t.profile.sampleRate),n&&n.outMediaTrack&&(this._mediaSettings.videoWidth=n.profile.width,this._mediaSettings.videoHeight=n.profile.height,this._mediaSettings.videoFps=n.profile.frameRate,this._mediaSettings.videoBps=1e3*n.profile.bitrate);this._log.info("updateMediaSettings: ".concat(JSON.stringify(this._mediaSettings)))}},{key:"sendMediaSettings",value:function(){var e=this;this.updateMediaSettings(),this._signalChannel.sendWaitForResponse({command:yj,data:this._mediaSettings,responseCommand:fj.UPDATE_CONSTRAINT_CONFIG_RES}).then((function(t){0!==t.data.code&&e._log.warn(t.data.message)})).catch((function(){}))}},{key:"addTrack",value:function(e){return aR(this,null,f().mark((function t(){var n;return f().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(n=e===this.localAuxAudioTrack||e===this.localAuxVideoTrack,this._log.info("is adding ".concat(e.kind," track to current published local ").concat(n?nC.AUXILIARY:nC.MAIN," stream")),t.t0=QO(),!t.t0){t.next=8;break}return t.next=8,this.addTrackByTransceiver(e,n);case 8:case"end":return t.stop()}}),t,this)})))}},{key:"addTrackByTransceiver",value:function(e,t){return aR(this,null,f().mark((function n(){var r,i,a;return f().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(e.mediaTrack){n.next=2;break}return n.abrupt("return");case 2:if(i=this._peerConnection.getTransceivers(),e.kind!==nC.AUDIO){n.next=8;break}return n.next=6,i[0].sender.replaceTrack(e.outMediaTrack);case 6:n.next=19;break;case 8:return a=t?3:1,n.next=11,i[a].sender.replaceTrack(e.outMediaTrack);case 11:if(n.t0=1===a&&null!=(r=this.localMainVideoTrack)&&r.small,!n.t0){n.next=15;break}return n.next=15,i[2].sender.replaceTrack(this._room.videoManager.smallTrack);case 15:if(n.t1=i[a].direction===rC.INACTIVE,!n.t1){n.next=19;break}return n.next=19,this.singlePC.setTransceiverDirection(rC.SENDONLY,[a]);case 19:return this.updateMediaSettings(),n.next=22,this.doPublishChange();case 22:case"end":return n.stop()}}),n,this)})))}},{key:"removeTrack",value:function(e){return aR(this,null,f().mark((function t(){var n;return f().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(n=e===this.localAuxAudioTrack||e===this.localAuxVideoTrack,this._log.info("is removing ".concat(e.kind," track from current published local ").concat(n?nC.AUXILIARY:nC.MAIN," stream")),t.t0=QO(),!t.t0){t.next=8;break}return t.next=8,this.removeTrackByTransceiver(e,n);case 8:case"end":return t.stop()}}),t,this)})))}},{key:"removeTrackByTransceiver",value:function(e,t){return aR(this,null,f().mark((function n(){var r,i;return f().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(e.mediaTrack){n.next=2;break}return n.abrupt("return");case 2:if(r=this._peerConnection.getTransceivers(),e.kind!==nC.AUDIO){n.next=8;break}return n.next=6,r[0].sender.replaceTrack(null);case 6:n.next=17;break;case 8:return i=t?3:1,n.next=11,r[i].sender.replaceTrack(null);case 11:if(n.t0=1===i&&this._room.videoManager.hasSmall,!n.t0){n.next=15;break}return n.next=15,r[2].sender.replaceTrack(null);case 15:return n.next=17,this.singlePC.setTransceiverDirection(rC.INACTIVE,[i]);case 17:return this.updateMediaSettings(),n.next=20,this.doPublishChange();case 20:case"end":return n.stop()}}),n,this)})))}},{key:"replaceTrack",value:function(e){return aR(this,null,f().mark((function t(){var n,r,i,a;return f().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(r=null==(n=this._peerConnection)?void 0:n.getSenders(),i=e.outMediaTrack||e.mediaTrack,r&&0!==r.length&&i&&!r.find((function(e){return e.track===i}))){t.next=3;break}return t.abrupt("return",!1);case 3:if(a=e===this.localAuxAudioTrack||e===this.localAuxVideoTrack,this._log.info("is replacing ".concat(i.kind," track ").concat(i.id," ").concat(i.label," on ").concat(a?nC.AUXILIARY:nC.MAIN," stream")),t.t0=i.kind===nC.AUDIO&&r[0],!t.t0){t.next=9;break}return t.next=9,r[0].replaceTrack(i);case 9:if(t.t1=i.kind===nC.VIDEO,!t.t1){t.next=19;break}if(t.t2=!a&&r[1],!t.t2){t.next=15;break}return t.next=15,r[1].replaceTrack(i);case 15:if(t.t3=a&&r[3],!t.t3){t.next=19;break}return t.next=19,r[3].replaceTrack(i);case 19:return t.abrupt("return",!0);case 20:case"end":return t.stop()}}),t,this)})))}},{key:"setBandwidth",value:function(e){return aR(this,arguments,(function(e){var t=this,n=e.bandwidth,r=e.type,i=e.videoType;return f().mark((function e(){var a;return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!t.singlePC){e.next=5;break}return a={},r===nC.AUDIO?a.audio=n:"big"===i?a.bigVideo=n:"small"===i?a.smallVideo=n:a.auxVideo=n,e.next=5,t.singlePC.setBandwidth(a);case 5:case"end":return e.stop()}}),e)}))()}))}},{key:"sendMutedFlag",value:function(e){e===this.localAuxAudioTrack||e===this.localAuxVideoTrack||(this._log.info("send muted state: ".concat(JSON.stringify(this.muteState))),this._signalChannel.sendWaitForResponseWithRetry({command:pj,responseCommand:fj.MUTE_RESULT,data:this.muteState,retries:3}).catch((function(){})))}},{key:"handleConnectionStateChange",value:function(e){"CONNECTED"===e.state&&(this.localMainVideoTrack||this._publishingLocalVideoTrack&&!this._isPublishingAux)&&rx.emit(ax.SEND_FIRST_VIDEO_FRAME,{room:this._room})}},{key:"getVideoTrackId",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:nC.VIDEO;if(this._peerConnection){var t=this._peerConnection.getSenders();if(e===nC.AUXILIARY&&t[3]&&t[3].track)return t[3].track.id;if(e===nC.VIDEO&&t[1]&&t[1].track)return t[1].track.id}if(this.localMainVideoTrack&&e===nC.VIDEO){var n=this.localMainVideoTrack.mediaTrack;if(n)return n.id}if(this.localAuxVideoTrack&&e===nC.AUXILIARY){var r=this.localAuxVideoTrack.mediaTrack;if(r)return r.id}return""}},{key:"getSSRC",value:function(){return this.ssrc}},{key:"checkPublishResultCode",value:function(e,t){if(0!==e)throw e===UC?(this._log.error(hO.NOT_SUPPORTED_H264ENCODE),new yR({code:_R.NOT_SUPPORTED_H264,message:mO({key:dO.NOT_SUPPORTED_H264ENCODE})})):new yR({code:_R.UNKNOWN,message:mO({key:dO.SIGNAL_RESPONSE_FAILED,data:{signalResponse:fj.PUBLISH_RESULT,code:e,message:t}})})}},{key:"onSinglePCReconnected",value:function(){return aR(this,null,f().mark((function e(){return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(e.t0=this.isMainStreamPublished,!e.t0){e.next=5;break}return this._log.warn("republish main stream"),e.next=5,this.publish({localAudioTrack:this.localMainAudioTrack,localVideoTrack:this.localMainVideoTrack,isAuxiliary:!1});case 5:if(e.t1=this.isAuxStreamPublished,!e.t1){e.next=10;break}return this._log.warn("republish aux stream"),e.next=10,this.publish({localAudioTrack:this.localAuxAudioTrack,localVideoTrack:this.localAuxVideoTrack,isAuxiliary:!0});case 10:case"end":return e.stop()}}),e,this)})))}}])}(wH);nR([sL((function(e){var t=e.localVideoTrack;null==t||t.once("6",this.onVideoEncodeFailed,this)}))],DH.prototype,"publish",1),nR([sL((function(e){var t=e.localVideoTrack;null==t||t.off("6",this.onVideoEncodeFailed,this)}))],DH.prototype,"unpublish",1);var NH=DH;function xH(e){return Object.keys(e).filter((function(t){return e[t]}))}var OH=function(e){function i(e){var a;return r(this,i),a=n(this,i,[$A(QA({},e),{isUplink:!1})]),rR(t(a),"_flag",0),rR(t(a),"isRobot",!1),rR(t(a),"role","anchor"),rR(t(a),"remoteAudioTrack"),rR(t(a),"remoteVideoTrack"),rR(t(a),"remoteAuxiliaryTrack"),rR(t(a),"ssrc",{audio:0,video:0,videoRtx:0,auxiliary:0,auxiliaryRtx:0}),rR(t(a),"jitterBufferTimeoutId",-1),a.flag=e.flag,a.isRobot=e.isRobot||!1,a.remoteAudioTrack=new XU(a._room,t(a)),a.remoteVideoTrack=new pF(a._room,t(a)),a.remoteAuxiliaryTrack=new mF(a._room,t(a)),a.initialize(),a}return d(i,e),o(i,[{key:"videoCodec",get:function(){var e;return(null==(e=this.singlePC)?void 0:e.downlinkVideoCodec)||"h264"}},{key:"subscribeState",get:function(){return{audio:this.remoteAudioTrack.isSubscribed||this.remoteAudioTrack.isSubscribing,video:this.remoteVideoTrack.isBig&&(this.remoteVideoTrack.isSubscribed||this.remoteVideoTrack.isSubscribing),smallVideo:this.remoteVideoTrack.isSmall&&(this.remoteVideoTrack.isSubscribed||this.remoteVideoTrack.isSubscribing),auxiliary:this.remoteAuxiliaryTrack.isSubscribed||this.remoteAuxiliaryTrack.isSubscribing}}},{key:"muteState",get:function(){return Hw(this.flag,this.userId)}},{key:"flag",get:function(){return this._flag},set:function(e){var t,n,r;e!==this._flag&&(this._flag=e,null==(t=this.remoteAudioTrack)||t.onFlagChanged(),null==(n=this.remoteVideoTrack)||n.onFlagChanged(),null==(r=this.remoteAuxiliaryTrack)||r.onFlagChanged())}},{key:"hasMainStream",get:function(){return this.muteState.hasAudio||this.muteState.hasVideo||this.muteState.hasSmall}},{key:"hasAuxStream",get:function(){return this.muteState.hasAuxiliary}},{key:"isMainStreamSubscribed",get:function(){return(this.subscribeState.audio||this.subscribeState.video||this.subscribeState.smallVideo)&&(this.muteState.hasAudio||this.muteState.hasVideo||this.muteState.hasSmall)}},{key:"isAuxStreamSubscribed",get:function(){return this.subscribeState.auxiliary&&this.muteState.hasAuxiliary}},{key:"isSmallStreamSubscribed",get:function(){return this.subscribeState.smallVideo&&this.muteState.hasSmall}},{key:"isBigStreamSubscribed",get:function(){return this.subscribeState.video&&this.muteState.hasVideo}},{key:"isStreamUnpublished",value:function(e){return e===nC.MAIN?!this.muteState.hasAudio&&!this.muteState.hasVideo:!this.muteState.hasAuxiliary}},{key:"initialize",value:function(){this.installEvents()}},{key:"close",value:function(e){clearTimeout(this.jitterBufferTimeoutId),g(i,"close",this,3)([e]),this.emitConnectionStateChangedEvent("DISCONNECTED"),this.remoteAudioTrack.close(),this.remoteVideoTrack.close(),this.remoteAuxiliaryTrack.close(),this.uninstallEvents(),this.removeDownlink()}},{key:"installEvents",value:function(){this.singlePC&&(this.listeners("track").includes(this.onTrack)||this.singlePC.on("track",this.onTrack,this),this.listeners("spc-reconnected").includes(this.onSinglePCReconnected)||this.singlePC.on("spc-reconnected",this.onSinglePCReconnected,this))}},{key:"uninstallEvents",value:function(){this.singlePC&&(this.singlePC.off("track",this.onTrack,this),this.singlePC.off("spc-reconnected",this.onSinglePCReconnected,this))}},{key:"emitConnectionStateChangedEvent",value:function(e){var t,n,r=this._currentState,a=g(i,"emitConnectionStateChangedEvent",this,3)([e]);return a&&r!==e&&(null==(t=this.remoteVideoTrack)||t.emit("connection-state-changed",{prevState:r,state:e}),null==(n=this.remoteAuxiliaryTrack)||n.emit("connection-state-changed",{prevState:r,state:e})),a}},{key:"onTrack",value:function(e){var t,n,r=e.streams[0],i=e.track,a=e.receiver;if(r.id.includes(this.tinyId)){var o=r.id.includes("aux")?"auxiliary":"main";this._log.debug("ontrack ".concat(o," ").concat(i.kind));var s=nC.AUDIO;i.kind===nC.VIDEO&&(s=o===nC.MAIN?nC.VIDEO:nC.AUXILIARY);var c=this.remoteAudioTrack;s===nC.VIDEO?c=this.remoteVideoTrack:s===nC.AUXILIARY&&(c=this.remoteAuxiliaryTrack),null==(t=this.singlePC)||t.receiverRemoteTrackMap.set(a,c),null!=(n=this.singlePC)&&n.scriptTransformWorker&&this.initReceiverTransform(a,o,i.kind===nC.AUDIO),this.singlePC.enableInsertableStreams&&this.createEncodedStreams(a),c.setInputMediaStreamTrack(i)}}},{key:"createEncodedStreams",value:function(e){var t=this;if(!this.singlePC.insertableStreamsAbortMap.has(e)){var n=e.createEncodedStreams(),r=new AbortController,i={abortController:r,enqueue:function(n){var r,i,a=null==(r=t.singlePC)?void 0:r.receiverRemoteTrackMap.get(e);return a&&("video"!==a.kind||null!=(i=t.singlePC)&&i.isUsingH264)?a.decodeFrame(n):n}};n.readable.pipeThrough(new TransformStream({transform:function(e,t){var n=i.enqueue(e);n&&t.enqueue(n)}})).pipeTo(n.writable,r).catch((function(e){"destory"!==e&&t._log.warn(e)})),this.singlePC.addAbortController(e,r)}}},{key:"initReceiverTransform",value:function(e,t,n){!this._peerConnection||!this.singlePC||!this.singlePC.scriptTransformWorker||e.transform||(e.transform=new RTCRtpScriptTransform(this.singlePC.scriptTransformWorker,{isReceiver:!0,isAudio:n,userId:this.userId,streamType:t}))}},{key:"subscribe",value:function(e,t){return aR(this,null,f().mark((function n(){var r;return f().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(n.prev=0,this._log.info("subscribe ".concat(t," ").concat(xH(e))),!this.hasSSRC){n.next=8;break}return r="subscribe_change",Object.values(e).find((function(e){return!0===e}))||(r="unsubscribe"),n.next=6,this.sendSubscription(r,e);case 6:n.next=11;break;case 8:return n.next=10,this.doSubscribe(e);case 10:this.checkTrackEnded(e);case 11:n.next=16;break;case 13:throw n.prev=13,n.t0=n.catch(0),this._room.isJoined&&this.isStreamUnpublished(t)?(this._log.warn("".concat(n.t0.message," ").concat(JSON.stringify(this.muteState))),new yR({code:_R.REMOTE_STREAM_NOT_EXIST,message:"remote user ".concat(this.userId," unpublished stream")})):n.t0;case 16:case"end":return n.stop()}}),n,this,[[0,13]])})))}},{key:"checkTrackEnded",value:function(e){var t,n,r;if((e.audio&&"ended"===(null==(t=this.remoteAudioTrack.mediaTrack)?void 0:t.readyState)||e.video&&"ended"===(null==(n=this.remoteVideoTrack.mediaTrack)?void 0:n.readyState)||e.auxiliary&&"ended"===(null==(r=this.remoteAuxiliaryTrack.mediaTrack)?void 0:r.readState))&&this.singlePC&&!this.singlePC.isReconnecting){if(this._log.warn("remote track ended start spc reconnect"),RN&&DN<92)return;this.singlePC.startReconnection()}}},{key:"unsubscribe",value:function(e){return aR(this,arguments,(function(e){var t=this,n=e.remoteTracks,r=e.streamType;return f().mark((function e(){var i,a,o;return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(("main"!==r||t.isMainStreamSubscribed)&&("auxiliary"!==r||t.isAuxStreamSubscribed)){e.next=2;break}return e.abrupt("return",void t._log.info("".concat(r," stream already unsubscribed")));case 2:return a=QA({},t.subscribeState),n.forEach((function(e){switch(e.mediaType){case 1:a.audio=!1;break;case 4:a.video=!1;break;case 8:a.smallVideo=!1;break;case 2:a.auxiliary=!1}})),o="subscribe_change",Object.values(a).find((function(e){return!0===e}))||(o="unsubscribe"),t._log.info("".concat("unsubscribe"===o?o:"subscribe"," ").concat(r," [").concat(xH(a),"]")),"unsubscribe"===o&&(null==(i=t.singlePC)||i.removeDownlinkQueue.add(t.tinyId)),e.next=10,t.sendSubscription(o,a);case 10:if(e.t0="unsubscribe"===o,!e.t0){e.next=14;break}return e.next=14,t.removeDownlink();case 14:case"end":return e.stop()}}),e)}))()}))}},{key:"sendSubscription",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.subscribeState,r={srcTinyId:this.tinyId,srcUserId:this.userId},i=_j,a=fj.UNSUBSCRIBE_RESULT;return"subscribe_change"===e&&(r={audio:n.audio,bigVideo:n.video,auxVideo:n.auxiliary,smallVideo:n.smallVideo,srcTinyId:this.tinyId},i=gj,a=fj.SUBSCRIBE_CHANGE_RESULT),this._signalChannel.sendWaitForResponseWithRetry({command:i,data:r,responseCommand:a,timeout:1e4,retries:3}).then((function(n){var r=n.data;if(0!==r.code){var i=new yR({code:r.code,message:mO({key:dO.ERROR_MESSAGE,data:{type:e,message:r.message}})});throw t._log.error(i),i}}))}},{key:"getMainStreamVideoTrackId",value:function(){return this.remoteVideoTrack&&this.remoteVideoTrack.mediaTrack?this.remoteVideoTrack.mediaTrack.id:""}},{key:"getAuxStreamVideoTrackId",value:function(){return this.remoteAuxiliaryTrack&&this.remoteAuxiliaryTrack.mediaTrack?this.remoteAuxiliaryTrack.mediaTrack.id:""}},{key:"setDelay",value:function(e){var t=e.audioDelay,n=e.videoDelay;this.remoteAudioTrack.stat.end2EndDelay=t,this.remoteVideoTrack.stat.end2EndDelay=n}},{key:"onSinglePCReconnected",value:function(){return aR(this,null,f().mark((function e(){return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(e.t0=this.ssrc.audio||this.ssrc.video||this.ssrc.auxiliary,!e.t0){e.next=8;break}return this._log.warn("resubscribe ".concat(JSON.stringify(this.subscribeState))),e.next=5,this.doSubscribe(this.subscribeState);case 5:this.remoteAudioTrack.checkDecodeResult(),this.remoteVideoTrack.checkDecodeResult(),this.remoteAuxiliaryTrack.checkDecodeResult();case 8:case"end":return e.stop()}}),e,this)})))}},{key:"hasSSRC",get:function(){return this.ssrc.audio&&this.ssrc.video&&this.ssrc.auxiliary}},{key:"doSubscribe",value:function(){return aR(this,arguments,(function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.subscribeState,n=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];return f().mark((function r(){var i,a,o,s,c,u,l,d,h,p,m,v,_,g,y;return f().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if(!e.singlePC){r.next=34;break}return e.singlePC.addDownlinkQueue.add(e.tinyId),r.next=4,e.singlePC.waitForPeerConnectionConnected();case 4:if(r.prev=4,!n&&e.hasSSRC){r.next=25;break}return i={audioSsrc:CH(),bigVideoSsrc:CH(),bigVideoRtxSsrc:CH(),auxVideoSsrc:CH(),auxVideoRtxSsrc:CH()},a=i.audioSsrc,o=i.bigVideoSsrc,s=i.bigVideoRtxSsrc,c=i.auxVideoSsrc,u=i.auxVideoRtxSsrc,e.ssrc={audio:a,video:o,videoRtx:s,auxiliary:c,auxiliaryRtx:u},e.singlePC.addDownlinkQueue.delete(e.tinyId),r.next=11,e.singlePC.addDownlink({userId:e.userId,tinyId:e.tinyId,ssrc:e.ssrc});case 11:return r.prev=11,r.next=14,e._signalChannel.sendWaitForResponseWithRetry({command:"subscribe/v3",responseCommand:fj.SPC_SUBSCRIBE_RESULT,data:{srcUserId:e.userId,srcTinyId:e.tinyId,audio:t.audio,bigVideo:t.video,auxVideo:t.auxiliary,smallVideo:t.smallVideo,customData:!1,ssrc:i},retries:3,retryTimeout:0});case 14:if(0===(l=r.sent).data.code){r.next=17;break}throw new yR({code:l.data.code,message:l.data.message});case 17:r.next=24;break;case 19:return r.prev=19,r.t0=r.catch(11),r.next=23,e.removeDownlink();case 23:throw r.t0;case 24:return r.abrupt("return");case 25:return e.singlePC.addDownlinkQueue.delete(e.tinyId),r.next=28,e.singlePC.addDownlink({userId:e.userId,tinyId:e.tinyId,ssrc:e.ssrc});case 28:if(r.prev=28,yP){r.next=31;break}return r.abrupt("return");case 31:return d=e._room.jitterBufferDelay||{},h=d.main,p=d.aux,m=e._room.scheduleResult.config||{},v=m.jitterDelay,_=void 0===v?h:v,g=m.jitterDelayAux,y=void 0===g?p:g,(Aw(_)||Aw(y))&&e.setJitterBufferDelay({mainDelay:_,auxDelay:y}),r.finish(28);case 34:case"end":return r.stop()}}),r,null,[[4,,28,34],[11,19]])}))()}))}},{key:"removeDownlink",value:function(){return aR(this,null,f().mark((function e(){var t;return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.singlePC){e.next=2;break}return e.abrupt("return");case 2:return this.ssrc={audio:0,video:0,videoRtx:0,auxiliary:0,auxiliaryRtx:0},this.singlePC.removeDownlinkQueue.delete(this.tinyId),(null!=(t=this._room.scheduleResult.config)&&t.jitterDelay||null!=t&&t.jitterDelayAux)&&this.setJitterBufferDelay({mainDelay:0,auxDelay:0}),e.next=7,this.singlePC.removeDownlink(this.userId);case 7:case"end":return e.stop()}}),e,this)})))}},{key:"setJitterBufferDelay",value:function(e){var t=this,n=e.mainDelay,r=e.auxDelay;if(!yP||!this.singlePC||!this._peerConnection||uD(n)&&uD(r))return Promise.resolve();this._log.info("set jitterBuffer main: ".concat(n," aux: ").concat(r));var i=this.singlePC.getReceiversByUserId(this.userId);return Aw(n)&&(this.remoteAudioTrack.jitterBufferDelay=n,this.remoteVideoTrack.jitterBufferDelay=n),Aw(r)&&(this.remoteAuxiliaryTrack.jitterBufferDelay=r,uD(n)&&(this.remoteAudioTrack.jitterBufferDelay=r)),new Promise((function(e){t.doSetJitterBufferDelay({mainDelay:n,auxDelay:r,receivers:i,resolve:e})}))}},{key:"doSetJitterBufferDelay",value:function(e){var t=this,n=e.mainDelay,r=e.auxDelay,i=e.receivers,a=e.resolve;try{if(0===n&&0===r)return i.forEach((function(e){return e.jitterBufferTarget=0})),a();if(i.forEach((function(e){var i,a=e.track===t.remoteAuxiliaryTrack.outMediaTrack||uD(n)&&e.track===t.remoteAudioTrack.outMediaTrack;if(!(a&&uD(r)||!a&&uD(n))){var o=a?r||0:n,s=(e.jitterBufferTarget||0)+100;s>o||(e.jitterBufferTarget=s,t._log.debug("set ".concat(a?"aux ":"").concat(null==(i=null==e?void 0:e.track)?void 0:i.kind," jitterBuffer delay ").concat(s," -> ").concat(o)))}})),!i.find((function(e){var i=e.track===t.remoteAuxiliaryTrack.outMediaTrack?r||0:n;return e.jitterBufferTarget<i})))return this._log.info("set jitterBuffer main: ".concat(n," aux: ").concat(r," done")),a();this.jitterBufferTimeoutId=setTimeout((function(){t.doSetJitterBufferDelay({mainDelay:n,auxDelay:r,receivers:i,resolve:a})}),1e3)}catch(DR){this._log.warn("set jitterBuffer delay error: ".concat(DR)),clearTimeout(this.jitterBufferTimeoutId),a()}}},{key:"audioReceiver",get:function(){var e;return(null==(e=this.singlePC)?void 0:e.getReceiversByUserId(this.userId)[0])||null}}])}(wH);nR([mL(),uL((function(e){return function(){for(var t=this,n=arguments.length,r=new Array(n),i=0;i<n;i++)r[i]=arguments[i];return new Promise((function(n,i){var a=function(e){t.off("closed",a),i(new yR({code:_R.API_CALL_ABORTED,message:mO({key:dO.CONNECTION_ABORTED,data:e})}))};t.on("closed",a),e.apply(t,r).then(n,i).finally((function(){t.off("closed",a)}))}))}}))],OH.prototype,"subscribe",1),nR([mL()],OH.prototype,"unsubscribe",1),nR([_L((function(){return"jitter"}))],OH.prototype,"setJitterBufferDelay",1);var PH=OH,MH=function(e){function i(e,a){var o;return r(this,i),(o=n(this,i)).room=e,o.signalChannel=a,rR(t(o),"log"),rR(t(o),"cmdIdSeqMap",new Map),rR(t(o),"messageMap",new Map),o.log=sx.createLogger({id:"cmm",userId:e.userId}),o.onReceiveMsg=o.onReceiveMsg.bind(t(o)),a.on(fj.RECEIVE_CUSTOM_MSG,o.onReceiveMsg),o.room.on("peer-leave",(function(e){E(o.messageMap.keys()).forEach((function(t){t.split("_").slice(0,-1).join("_")===e&&o.messageMap.delete(t)}))})),o}return d(i,e),o(i,[{key:"send",value:function(e){var t=e.cmdId,n=e.data,r=this.cmdIdSeqMap.get(t)||Math.floor(16383*Math.random()),i={cmdId:t,msg:btoa(String.fromCharCode.apply(String,E(new Uint8Array(n)))),ordered:!0,reliable:!0,streamSeq:r};this.cmdIdSeqMap.set(t,r+1),this.signalChannel.send("channel_msg",i),this.log.debug("send custom msg: ".concat(JSON.stringify(i)))}},{key:"onReceiveMsg",value:function(e){var t=this,n=e.data.data,r=this.room.tinyIdToUserIdMap.get(n.srcTinyId);if(r){var a={userId:r,cmdId:n.cmdId,seq:n.streamSeq,data:Uint8Array.from(atob(n.msg),(function(e){return e.charCodeAt(0)})).buffer};if(n.ordered){var o="".concat(r,"_").concat(a.cmdId),s=this.messageMap.get(o);if(s&&0!==s.lastSeq)if(Math.abs(s.lastSeq-a.seq)>i.SEQ_INTERVAL)this.messageMap.set(o,{lastSeq:a.seq,cachedMessageMap:new Map}),this.emitMessage(a);else if(a.seq>s.lastSeq){if(a.seq===s.lastSeq+1)this.emitMessage(a);else if(!s.cachedMessageMap.has(a.seq)){var c=setTimeout((function(){return t.emitMessage(a,!0)}),5e3);s.cachedMessageMap.set(a.seq,{message:a,timeoutId:c})}}else this.log.debug("drop message ".concat(a.userId,"-").concat(a.cmdId,"-").concat(a.seq));else s||(s={lastSeq:0,cachedMessageMap:new Map},this.messageMap.set(o,s),setTimeout((function(){return t.emitMessage(a,!0)}),100)),s.cachedMessageMap.set(a.seq,{message:a})}else this.emit("message",a)}else{this.log.warn("receive msg from unknown user, wait peer-join tinyId: ".concat(n.srcTinyId));var u=function(r){r.tinyId===n.srcTinyId&&(t.room.off("peer-join",u),t.onReceiveMsg(e))};this.room.on("peer-join",u),rD(2e3).then((function(){return t.room.off("peer-join",u)}))}}},{key:"emitMessage",value:function(e){var t,n=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r=this.messageMap.get("".concat(e.userId,"_").concat(e.cmdId)),i=e;if(r){if(n){var a=E(r.cachedMessageMap.values()).sort((function(e,t){return e.message.seq-t.message.seq}));a[0]&&(i=a[0].message)}0!==r.lastSeq&&i.seq-r.lastSeq>1&&this.log.debug("msg lost userId: ".concat(i.userId," seq: ").concat(r.lastSeq," -> ").concat(i.seq)),r.lastSeq=i.seq,clearTimeout(null==(t=r.cachedMessageMap.get(i.seq))?void 0:t.timeoutId),r.cachedMessageMap.delete(i.seq)}this.log.debug("receive custom msg: ".concat(JSON.stringify(i))),this.emit("message",i);var o=null==r?void 0:r.cachedMessageMap.get(i.seq+1);o&&this.emitMessage(o.message)}}])}(tR(oR()).EventEmitter);rR(MH,"SEQ_INTERVAL",300);var LH=MH,VH=IR.isString,UH=IR.isUndefined,FH=IR.getNetworkType,BH=IR.isEmpty,jH=function(e){function i(e){var a;return r(this,i),a=n(this,i,[e]),rR(t(a),"_businessInfo"),rR(t(a),"userManager"),rR(t(a),"_version"),rR(t(a),"_heartbeat",-1),rR(t(a),"_lastHeartBeatTime",-1),rR(t(a),"_stats"),rR(t(a),"_joinTimeout",-1),rR(t(a),"_firstPublishedList",null),rR(t(a),"_joinReject",null),rR(t(a),"_isRelayChanged",!1),rR(t(a),"sdpSemantics"),rR(t(a),"signalChannel",null),rR(t(a),"uplinkConnection",null),rR(t(a),"singlePC",null),rR(t(a),"enableSPC",ZO),rR(t(a),"_changeBigSmallRecords",new Map),rR(t(a),"networkQuality"),rR(t(a),"_iceTransportPolicy"),rR(t(a),"forceRelay",!1),rR(t(a),"_turnServers",[]),rR(t(a),"_iceServersFromJoin"),rR(t(a),"_syncUserListInterval",-1),rR(t(a),"_smallStreamConfig",{bitrate:100,frameRate:15,height:120,width:160}),rR(t(a),"enableSEI",!1),rR(t(a),"_enableAudioVolumeEvaluation",!1),rR(t(a),"_audioVolumeIntervalId",0),rR(t(a),"_enableMultiAuxStream",!1),rR(t(a),"_pureAudioPushMode",!1),rR(t(a),"_customMessageManager"),rR(t(a),"preferHW",!1),rR(t(a),"healthDetector"),rR(t(a),"playoutDelay"),rR(t(a),"jitterBufferDelay"),rR(t(a),"_updateAudioLevelTaskId",-1),a._stats=new Vj(t(a),a._log),a.userManager=new gF(a.userId,a._log),a._version=RR,a.sdpSemantics=VC,UH(e.sdpSemantics)?lx.isUnifiedPlanDefault()&&(a.sdpSemantics=LC):a.sdpSemantics=e.sdpSemantics,a._log.info("sdpSemantics: ".concat(a.sdpSemantics,", netType: ").concat(FH())),e.iceTransportPolicy&&(a._iceTransportPolicy=e.iceTransportPolicy),a._enableMultiAuxStream=!UH(e.enableMultiAuxStream)&&e.enableMultiAuxStream,a.enableSEI=e.enableSEI&&ZO,!UH(e.enableSPC)&&ZO&&(a.enableSPC=e.enableSPC),a.preferHW=!!e.preferHW,a._initBusinessInfo(e),a.healthDetector=new vH(t(a)),a}return d(i,e),o(i,[{key:"isMainStreamPublished",get:function(){var e;return!(null==(e=this.uplinkConnection)||!e.isMainStreamPublished)}},{key:"isMainAudioPublished",get:function(){var e;return!(null==(e=this.uplinkConnection)||!e.localMainAudioTrack)}},{key:"isAuxStreamPublished",get:function(){var e;return!(null==(e=this.uplinkConnection)||!e.isAuxStreamPublished)}},{key:"hasAuxStream",get:function(){return E(this.remotePublishedUserMap.values()).findIndex((function(e){return e.muteState.hasAuxiliary}))>=0}},{key:"userMap",get:function(){return this.userManager.userMap}},{key:"remotePublishedUserMap",get:function(){return this.userManager.remotePublishedUserMap}},{key:"tinyIdToUserIdMap",get:function(){return new Map(E(this.userMap.values()).map((function(e){return[e.tinyId,e.userId]})))}},{key:"join",value:function(e,t,n){return aR(this,null,f().mark((function t(){var n=this;return f().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",(this.userManager.mySelfId=this.userId,this.userManager.on("1",(function(e){n.emit("peer-join",e)})),this.userManager.on("2",(function(e){n.closeDownLinkConnection(e,"remote user exitRoom"),n.emit("peer-leave",e)})),this.userManager.on("3",this.createDownlinkConnection,this),this.userManager.on("5",this.closeDownLinkConnection,this),this.userManager.on("6",(function(e){var t=function(e,t){var n={};for(var r in e)KA.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&WA){var i,a=s(WA(e));try{for(a.s();!(i=a.n()).done;)r=i.value,t.indexOf(r)<0&&zA.call(e,r)&&(n[r]=e[r])}catch(o){a.e(o)}finally{a.f()}}return n}(e,[]);rx.emit(ax.REMOTE_PUBLISH_STATE_CHANGED,QA({room:n},t)),n.emit("remote-publish-state-changed",QA({},t))})),this.joinParams=e,new Promise((function(t,r){return aR(n,null,f().mark((function n(){var i,a,o;return f().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return this._joinReject=r,n.prev=1,this.checkDestroy(),n.prev=3,n.next=6,Promise.all([this.initialize(),this.initSinglePC()]);case 6:n.next=15;break;case 8:if(n.prev=8,n.t0=n.catch(3),n.t0 instanceof yR&&n.t0.code===_R.SPC_INITIALIZED_FAILED){n.next=12;break}return n.abrupt("return",r(n.t0));case 12:return null==(i=this.signalChannel)||i.destroy(),n.next=15,this.initialize();case 15:return o=Vw(),n.next=18,this.doJoin(e,null==(a=this.singlePC)?void 0:a.clientAbility);case 18:bO.addSuccessEvent({key:521708,cost:Vw()-o}),t(),this._firstPublishedList&&this.onPublishedUserList({data:{userList:this._firstPublishedList}}),n.next=26;break;case 23:n.prev=23,n.t1=n.catch(1),bO.addFailedEvent({key:521708,error:n.t1}),r(n.t1);case 26:this._joinReject=null;case 27:case"end":return n.stop()}}),n,this,[[1,23],[3,8]])})))}))));case 1:case"end":return t.stop()}}),t,this)})))}},{key:"initSinglePC",value:function(){return aR(this,null,f().mark((function e(){var t=this;return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.enableSPC||this.singlePC){e.next=11;break}return this.singlePC=new IH({signalChannel:this.signalChannel,room:this,enableCustomMessage:!1}),this.singlePC.on("sei-message",(function(e){return t.emit("sei-message",e)})),this.singlePC.on("dump",(function(e){return t.emit("dump",e)})),this.singlePC.once("error",(function(){return t.fallbackToMPC()})),e.prev=2,e.next=5,this.singlePC.initialize();case 5:return e.abrupt("return",e.sent);case 8:throw e.prev=8,e.t0=e.catch(2),this.fallbackToMPC(),new yR({code:_R.SPC_INITIALIZED_FAILED,message:null==e.t0?void 0:e.t0.message});case 11:case"end":return e.stop()}}),e,this,[[2,8]])})))}},{key:"doJoin",value:function(e,t){var n=this;return new Promise((function(r,i){return aR(n,null,f().mark((function n(){var a,o,s,c,u,l=this;return f().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:e.privateMapKey&&(this.privateMapKey=e.privateMapKey),e.latencyLevel&&(this.latencyLevel=e.latencyLevel),this.signalChannel.once(lj,(function(e){l.clearJoinTimeout(),rx.emit(ax.JOIN_SIGNAL_CONNECTION_END,{room:l,error:e}),i(e)})),Rw(null==(o=null==(a=this.scheduleResult)?void 0:a.config)?void 0:o.singlePC)&&ZO&&(this.enableSPC=this.scheduleResult.config.singlePC),this.keyPointManager.setConnectionType(this.singlePC?1:2),t&&this.playoutDelay&&(t.playoutDelay=this.playoutDelay),c={roomId:String(e.roomId||e.strRoomId),useStringRoomId:this.useStringRoomId,privateMapKey:this.privateMapKey,latencyLevel:this.latencyLevel,trtcRole:e.role,trtcScene:"live"===this.scene?2:1,sdpSemantics:this.sdpSemantics,version:this._version,ua:navigator&&navigator.userAgent||"",terminalType:ex(),netType:dw(),bussinessInfo:this._businessInfo,ability:t,sdkType:this._sdkType,userSig:this.userSig,receiveMix:!0},this._log.debug("join room signal data: ".concat(JSON.stringify(c))),u=5e3,null!=(s=this.scheduleResult.config)&&s.enterRoomTimeout&&this.scheduleResult.config.enterRoomTimeout>=1&&(u=1e3*this.scheduleResult.config.enterRoomTimeout),this._joinTimeout=window.setTimeout((function(){i(new yR({code:_R.JOIN_ROOM_FAILED,message:mO({key:dO.JOIN_ROOM_TIMEOUT})}))}),u),rx.emit(ax.JOIN_SEND_CMD,{room:this}),this.signalChannel.send(this.singlePC?"join/v2":"join",c),this.signalChannel.once(fj.JOIN_ROOM_RESULT,(function(t){return aR(l,null,f().mark((function n(){var a,o,s,c,u;return f().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(this.clearJoinTimeout(),a=t.data,o=a.code,s=a.message,c=a.data,u=a.tinyId,rx.emit(ax.JOIN_RECEIVED_CMD_RES,{room:this,code:o}),0!==o){n.next=19;break}if(this._log.info("Join room success, start heartbeat"),u&&(this.tinyId=u),this.startHeartbeat(),this.syncUserList(),this.startSyncUserListInterval(),this._firstPublishedList=c.publishers,this._iceServersFromJoin=c.iceServer?[c.iceServer]:[],n.t0=this.singlePC,!n.t0){n.next=16;break}return n.next=15,this.singlePC.setIceServers(this.getIceServers());case 15:this.singlePC.connect($A(QA({},c.ability),{useVp8:c.ability.useVp8||!!e.useVp8})).catch((function(){}));case 16:r(),n.next=20;break;case 19:this._log.error("Join room failed result: ".concat(o," error: ").concat(s)),i(new yR({code:_R.JOIN_ROOM_FAILED,extraCode:o,message:mO({key:dO.JOIN_ROOM_FAILED,data:{error:s,code:o}})}));case 20:case"end":return n.stop()}}),n,this)})))}));case 5:case"end":return n.stop()}}),n,this)})))}))}},{key:"reJoin",value:function(){var e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];return aR(this,null,f().mark((function t(){var n,r,i,a=this;return f().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.isJoined){t.next=22;break}return t.prev=1,this._log.warn("reJoin pending: ".concat(this.joinParams.roomId)),r=[],this.singlePC&&(this.singlePC.close(),this.singlePC=null,r.push(this.initSinglePC().then((function(e){return n=e,e})))),this.signalChannel&&(this.signalChannel.race=e,this.signalChannel.close(),r.push(this.signalChannel.connect())),t.next=8,Promise.all(r);case 8:return t.next=10,this.doJoin($A(QA({},this.joinParams),{role:"anchor"===this.role?20:21,privateMapKey:this.privateMapKey,latencyLevel:this.latencyLevel}),n);case 10:if(this._log.warn("reJoin success"),jP.logSuccessEvent({userId:this.userId,eventType:xC.REJOIN}),!this.singlePC){t.next=15;break}i=function(e){var t;"CONNECTED"===e.state&&(null==(t=a.singlePC)||t.off(yH.CONNECTION_STATE_CHANGED,i),a.uplinkConnection instanceof NH&&(a.uplinkConnection.installEvents(),a.uplinkConnection.onSinglePCReconnected()),a.remotePublishedUserMap.forEach((function(e){e.installEvents(),e.onSinglePCReconnected()})))},this.singlePC.on(yH.CONNECTION_STATE_CHANGED,i),this.checkConnectionsToReconnect(),this.uplinkConnection instanceof Lj&&!this.uplinkConnection.getIsReconnecting()&&this.uplinkConnection.startReconnection();case 15:t.next=20;break;case 17:t.prev=17,t.t0=t.catch(1),this._log.warn("reJoin fail ".concat(t.t0)),this.reset(),jP.logFailedEvent({userId:this.userId,eventType:xC.REJOIN,error:t.t0}),this.emit("error",new yR({code:_R.JOIN_ROOM_FAILED,message:mO({key:dO.REJOIN_ROOM_FAILED,data:{roomId:this.joinParams.roomId}})}));case 20:t.next=23;break;case 22:this._log.warn("reJoin abort");case 23:case"end":return t.stop()}}),t,this,[[1,17]])})))}},{key:"initialize",value:function(){return aR(this,null,f().mark((function e(){var t,n,r,i,a,o,s=this;return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=this.getSignalChannelUrl(),r=n.mainUrl,i=n.backupUrl,a=this.signalChannel||function(e){return E(Ej.values()).find((function(t){return t.room.userId===e&&!t.room.isJoined}))||null}(this.userId),o=!!(a&&a.isConnected&&a.keepAlive&&a.userId===this.userId),Array.isArray(this.scheduleResult.domains)&&this.scheduleResult.domains.length>0&&(t=this.scheduleResult.domains[0]),this._log.info("".concat(o?"reuse":"setup"," signal channel")),o?(a.url=r,a.backupUrl=i,a.room=this,this.signalChannel=a):(a&&a.close(),this.signalChannel=new Tj({sdkAppId:this.sdkAppId,userId:this.userId,userSig:this.userSig,url:r,backupUrl:i,race:this.enableSPC&&!this.proxy_ws,room:this,signalDomainWhenUnifiedProxy:this.proxy_unified?t:void 0}),this._customMessageManager=new LH(this,this.signalChannel),this._customMessageManager.on("message",(function(e){s.emit("custom-message",e)}))),this.networkQuality||(this.networkQuality=new Fj({signalChannel:this.signalChannel,room:this}),this.networkQuality.on(Fj.EVENT_NETWORK_QUALITY,(function(e){var t;s.emit("network-quality",e),null==(t=s.singlePC)||t.detectTCPAndUDP(e)}))),FP(this,this.signalChannel).add("2",(function(e){rx.emit(ax.SIGNAL_CONNECTION_STATE_CHANGED,QA({room:s},e)),s.emit("signal-connection-state-changed",e)})).add("4",(function(e){s.reset(),s.emit("error",e)})).add(fj.PEER_JOIN,(function(e){var t=e.data.data,n=t.srcTinyId,r=t.userId,i=t.role;s.userManager.addUser({userId:r,tinyId:n,role:i})})).add(fj.PEER_LEAVE,(function(e){var t=e.data.data,n=t.userId,r=t.reason,i=void 0===r?0:r;s.userManager.deleteUser(n,i)})).add(fj.UPDATE_REMOTE_MUTE_STAT,(function(e){s._lastHeartBeatTime>0&&Date.now()-s._lastHeartBeatTime>=1e4&&s.doHeartbeat(),s.onPublishedUserList(e.data)})).add(fj.CLIENT_BANNED,(function(e){var t=e.data.data.reason;if(jP.uploadEvent({log:"stat-banned:".concat(t),userId:s.userId}),"user_time_out"===t)return s._log.warn("".concat(t," last heart beat time: ").concat(s._lastHeartBeatTime," interval: ").concat(Date.now()-s._lastHeartBeatTime,", visibility: ").concat(document.visibilityState)),void s.reJoin();s._log["kick"===t?"error":"info"]("user was banned because of [".concat(t,"]")),s.reset(),s.emit("banned",{reason:t})})),this.signalChannel.once("1",(function(e){s.tinyId=e.signalInfo.tinyId,rx.emit(ax.JOIN_SIGNAL_CONNECTION_END,{room:s})})),rx.emit(ax.JOIN_SIGNAL_CONNECTION_START,{room:this}),e.next=10,this.signalChannel.connect();case 10:return o&&rx.emit(ax.JOIN_SIGNAL_CONNECTION_END,{room:this}),e.abrupt("return",o);case 12:case"end":return e.stop()}}),e,this)})))}},{key:"setSignalChannel",value:function(e){this.signalChannel=e,e||BP(this)}},{key:"leave",value:function(){return aR(this,null,f().mark((function e(){var t;return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,this.doHeartbeat();case 3:e.next=7;break;case 5:e.prev=5,e.t0=e.catch(0);case 7:this._log.info("leave() => leaving room"),rx.emit(ax.LEAVE_SEND_CMD,{room:this}),null==(t=this.signalChannel)||t.send("leave");case 8:case"end":return e.stop()}}),e,this,[[0,5]])})))}},{key:"clearNetworkQuality",value:function(){this.networkQuality&&(this.networkQuality.stop(),delete this.networkQuality)}},{key:"closeConnections",value:function(){var e=this;this.remotePublishedUserMap.forEach((function(t){e.closeDownLinkConnection(t.userId,"you exitRoom")}))}},{key:"clearJoinTimeout",value:function(){clearTimeout(this._joinTimeout),this._joinTimeout=-1}},{key:"startHeartbeat",value:function(){-1===this._heartbeat&&(this._heartbeat=MP.run("ric",this.doHeartbeat.bind(this),{delay:2e3}))}},{key:"stopHeartbeat",value:function(){-1!==this._heartbeat&&(this._log.info("stopHeartbeat"),MP.clearTask(this._heartbeat),this._heartbeat=-1,this._lastHeartBeatTime=-1)}},{key:"doHeartbeat",value:function(){return aR(this,null,f().mark((function e(){var t,n,r,i,a,o;return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=this.badCaseDetector.getMonitorFreeze(),e.next=3,this._stats.getStatsReport({uplinkConnection:this.uplinkConnection,downlinkConnections:this.remotePublishedUserMap,freezeMap:n});case 3:r=e.sent,this.badCaseDetector.resetMonitor(),i=null!=(t=this.signalChannel)&&t.isConnected?function(e){if(vF.has(e)){var t=vF.get(e).map((function(e){return{uint32_event_id:e.eventId,uint64_date:e.timestamp,str_userid:e.remoteUserId,uint32_param1:e.param1,uint32_param2:e.param2,uint32_video_stream_type:e.streamType}}));return vF.delete(e),t}return[]}(this.userId):[],a=$A(QA({str_sdk_version:AR,uint64_datetime:(new Date).getTime(),msg_user_info:{str_identifier:this.userId,uint64_tinyid:this.tinyId},msg_event_msg:i,str_acc_ip:this.getSignalInfo().relayIp,str_client_ip:this.getSignalInfo().clientIp},r),{msg_device_info:QA({uint32_terminal_type:15,str_device_name:navigator.platform,str_os_version:"",uint32_net_type:dw()},r.msg_device_info)}),this.heartbeatReport=a,rx.emit(ax.HEARTBEAT_REPORT,{room:this,report:a}),this.signalChannel&&(this.signalChannel.isConnected&&(this.signalChannel.send("quality_report",a),o=Date.now(),this._lastHeartBeatTime>0&&o-this._lastHeartBeatTime>1e4&&this._log.warn("heartbeat took ".concat(o-this._lastHeartBeatTime)),this._lastHeartBeatTime=o,this.signalChannel.isOnline||(this._log.warn("signal channel is not online"),this.signalChannel.startReconnection())),this.emit("heartbeat-report",$A(QA({},a),{bytes_sent:this._stats.totalBytesSent+this.signalChannel.bytesSent,bytes_received:this._stats.totalBytesReceived+this.signalChannel.bytesReceived}))),!this._isRelayChanged&&this.isRelayMaybeFailed()&&(this.reJoin(),this._isRelayChanged=!0);case 8:case"end":return e.stop()}}),e,this)})))}},{key:"onPublishedUserList",value:function(e){var t=this;if(this.isJoined){var n=e.data.userList.filter((function(e){return e.flag!==fC})).map((function(e){var n=e.userId,r=e.srcTinyId,i=e.flag;n===t.userId&&t.uplinkConnection&&(t.uplinkConnection.flag=i);var a=t.remotePublishedUserMap.get(n);return a&&t.checkSubscribeBigSmallVideo(a),{userId:n,tinyId:r,flag:i}}));e.data.mixRobotList.forEach((function(e){var t=e.userId,r=e.srcTinyId,i=e.flag,a=e.mixUserList;n.unshift({userId:t,tinyId:r,flag:i,isRobot:!0,mixUserList:a})})),rx.emit(ax.RECEIVED_PUBLISHED_USER_LIST,{room:this,publishedUserList:n}),this.userManager.setRemotePublishedUserList(n)}}},{key:"closeUplink",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"you unpublished";this.uplinkConnection&&(this.localTracks.size>0&&this.uplinkConnection.doUnpublish(),this.uplinkConnection.close(e),this.uplinkConnection instanceof Lj&&(this.uplinkConnection=null)),this.localTracks.forEach((function(e){return e.unpublish()})),this.localTracks.clear()}},{key:"createDownlinkConnection",value:function(e){var t=e.userId,n=e.tinyId,r=e.flag,i=e.isRobot,a=new(this.singlePC?PH:Oj)({userId:t,tinyId:n,room:this,signalChannel:this.signalChannel,enableSEI:this.enableSEI,flag:r,isRobot:i});this.userManager.addRemotePublishedUser(a),this.installDownlinkEvents(a,t),this.emit("remote-published",a)}},{key:"closeDownLinkConnection",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"remote user unpublished",n=this.remotePublishedUserMap.get(e);n&&(n.close(t),this.emit("remote-unpublished",n))}},{key:"installDownlinkEvents",value:function(e,t){var n=this;e.on("error",(function(e){var r=e.getCode();r!==_R.ICE_TRANSPORT_ERROR&&(r===_R.DOWNLINK_RECONNECTION_FAILED&&n.closeDownLinkConnection(t),n.emit("error",e))})),e.on("connection-state-changed",(function(t){n.emit("media-connection-state-changed",$A(QA({},t),{userId:e.userId}))})),e.on("firewall-restriction",(function(){n.emit("firewall-restriction")}))}},{key:"startSyncUserListInterval",value:function(){-1===this._syncUserListInterval&&(this._syncUserListInterval=MP.run("ric",this.syncUserList.bind(this)))}},{key:"stopSyncUserListInterval",value:function(){MP.clearTask(this._syncUserListInterval),this._syncUserListInterval=-1}},{key:"syncUserList",value:function(){var e=this;return this.getUserList().then((function(t){e.userManager.setUserList(t)})).catch((function(t){e._log.debug("sync user list failed: ".concat(t))}))}},{key:"getUserList",value:function(){var e;return null!=(e=this.signalChannel)&&e.isConnected?this.signalChannel.sendWaitForResponse({command:"get_user_list",responseCommand:fj.USER_LIST_RES,enableLog:!1,timeout:2e3}).then((function(e){var t=e.data,n=t.code,r=t.message;if(0===n)return(t.data&&t.data.userList||[]).map((function(e){return{userId:e.userId,tinyId:e.srcTinyId,role:e.role}}));throw mO({key:dO.SIGNAL_RESPONSE_FAILED,data:{signalResponse:fj.USER_LIST_RES,code:n,message:r}})})):Promise.reject("not connected")}},{key:"getAllConnections",value:function(){var e=E(this.remotePublishedUserMap.values());return this.uplinkConnection&&e.push(this.uplinkConnection),e}},{key:"isRelayMaybeFailed",value:function(){if(this.signalChannel&&!this.signalChannel.isOnline||!Aj)return!1;if(this.singlePC)return this.singlePC.reconnectionCount>6;var e=this.getAllConnections();if(0===e.length)return!1;for(var t=0;t<e.length;t++)if(e[t].getReconnectionCount()<6)return!1;return!0}},{key:"checkConnectionsToReconnect",value:function(){var e,t=this;this.singlePC?(null==(e=this.singlePC.getPeerConnection())?void 0:e.connectionState)===AC.CLOSED&&!this.singlePC.isReconnecting&&(this._log.warn("spc pc is closed but not reconnect"),this.singlePC.startReconnection()):this.getAllConnections().forEach((function(e){if(e instanceof Rj&&!e.getIsReconnecting()){var n=e.getPeerConnection();n&&n.connectionState===AC.CLOSED&&(t._log.warn("[".concat(e.getUserId(),"] pc is closed but not reconnect")),e.startReconnection())}}))}},{key:"fallbackToMPC",value:function(){return aR(this,null,f().mark((function e(){var t,n,r,i,a,o;return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._log.warn("fallback to multi pc"),jP.uploadEvent({log:"stat-fallback",userId:this.userId}),this.enableSPC=!1,null==(t=this.singlePC)||t.close(),this.singlePC=null,e.t0=this.isJoined,!e.t0){e.next=9;break}return e.next=9,this.reJoin(!1);case 9:if(!this.uplinkConnection){e.next=21;break}if(n=this.uplinkConnection,this.uplinkConnection=new Lj({userId:this.userId,tinyId:this.tinyId,room:this,signalChannel:this.signalChannel,enableSEI:this.enableSEI}),e.t1=n.isMainStreamPublished,!e.t1){e.next=16;break}return e.next=16,this.uplinkConnection.publish({localAudioTrack:n.localMainAudioTrack,localVideoTrack:n.localMainVideoTrack,isAuxiliary:!1});case 16:if(e.t2=n.isAuxStreamPublished,!e.t2){e.next=20;break}return e.next=20,this.uplinkConnection.publish({localAudioTrack:n.localAuxAudioTrack,localVideoTrack:n.localAuxVideoTrack,isAuxiliary:!0});case 20:n.close();case 21:r=0,i=E(this.remotePublishedUserMap.values());case 22:if(!(r<i.length)){e.next=38;break}if(a=i[r],o=new Oj({userId:a.userId,tinyId:a.tinyId,room:this,signalChannel:this.signalChannel,enableSEI:this.enableSEI,flag:a.flag,remoteAudioTrack:a.remoteAudioTrack,remoteVideoTrack:a.remoteVideoTrack,remoteAuxiliaryTrack:a.remoteAuxiliaryTrack}),this.installDownlinkEvents(o,a.userId),this.remotePublishedUserMap.set(a.userId,o),e.t3=a.isMainStreamSubscribed,!e.t3){e.next=31;break}return e.next=31,o.subscribe(a.subscribeState,"main");case 31:if(e.t4=a.isAuxStreamSubscribed,!e.t4){e.next=35;break}return e.next=35,o.subscribe(a.subscribeState,"auxiliary");case 35:r++,e.next=22;break;case 38:case"end":return e.stop()}}),e,this)})))}},{key:"destroy",value:function(){this.isDestroyed||(this.signalChannel&&(this._log.info("destroying SignalChannel"),this.signalChannel.close(),this.signalChannel=null),g(i,"destroy",this,3)([]),this._joinReject&&(this._joinReject(new yR({code:_R.INVALID_OPERATION,message:mO({key:dO.CLIENT_DESTROYED,data:{funName:"join"}})})),this.clearJoinTimeout(),this.reset()),this.removeAllListeners(),this.healthDetector.destroy(),MP.clearTask(this._audioVolumeIntervalId))}},{key:"switchRole",value:function(e){return aR(this,null,f().mark((function t(){return f().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(t.t0=this.role!==e,!t.t0){t.next=5;break}return"audience"===e&&this.uplinkConnection&&this.closeUplink("you switch role to audience"),t.next=5,this.doSwitchRole(e);case 5:case"end":return t.stop()}}),t,this)})))}},{key:"doSwitchRole",value:function(e){var t=this,n={command:"change_role",data:{role:"anchor"===e?20:21,privateMapKey:this.privateMapKey,latencyLevel:this.latencyLevel},responseCommand:fj.SWITCH_ROLE_RES,retries:1};return this._log.info("switchRole signal data: ".concat(JSON.stringify(n.data))),this.signalChannel.sendWaitForResponseWithRetry(n).then((function(n){var r=n.data,i=r.code,a=r.message;if(0!==i)throw new yR({code:_R.SWITCH_ROLE_FAILED,message:mO({key:dO.SWITCH_ROLE_FAILED,data:{message:a,code:i}})});t.role=e})).catch((function(e){throw e instanceof yR&&e.getCode()===_R.API_CALL_TIMEOUT&&(e=new yR({code:_R.SWITCH_ROLE_FAILED,message:mO({key:dO.SWITCH_ROLE_TIMEOUT})})),t._log.error(e),e}))}},{key:"publish",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return aR(this,null,f().mark((function e(){var n,r,i,a,o,s=this;return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n={},r={},t.forEach((function(e){e instanceof kL&&(e instanceof NL?r.audio=e:n.audio=e),e instanceof AL&&(e instanceof wL&&2===e.mediaType?r.video=e:n.video=e)})),i=BH(n),a=BH(r),(!i||!a)&&!this.uplinkConnection&&(this.singlePC?this.uplinkConnection=new NH({userId:this.userId,tinyId:this.tinyId,room:this}):this.uplinkConnection=new Lj({userId:this.userId,tinyId:this.tinyId,room:this,signalChannel:this.signalChannel,enableSEI:this.enableSEI}),this.uplinkConnection.on("connection-state-changed",(function(e){s.emit("media-connection-state-changed",$A(QA({},e),{userId:s.userId}))})),this.uplinkConnection.on("firewall-restriction",(function(){s.emit("firewall-restriction")})),this.uplinkConnection.on("error",(function(e){var t=e.getCode();t!==_R.ICE_TRANSPORT_ERROR&&(t===_R.UPLINK_RECONNECTION_FAILED&&s.closeUplink(),s.emit("error",e))}))),o=t.map((function(e){return e.kind})).join(","),e.t0=i,e.t0){e.next=11;break}return this._log.info("publish() => main ".concat(o)),e.next=10,this.uplinkConnection.publish({localAudioTrack:n.audio,localVideoTrack:n.video,isAuxiliary:!1});case 10:this._log.info("main is published");case 11:if(e.t1=a,e.t1){e.next=17;break}return this._log.info("publish() => aux ".concat(o)),e.next=16,this.uplinkConnection.publish({localAudioTrack:r.audio,localVideoTrack:r.video,isAuxiliary:!0});case 16:this._log.info("aux is published");case 17:case"end":return e.stop()}}),e,this)})))}},{key:"unpublish",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return aR(this,null,f().mark((function e(){var n,r,i;return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(("live"!==this.scene||"anchor"===this.role)&&(this.isMainStreamPublished||this.isAuxStreamPublished)&&this.uplinkConnection){e.next=2;break}return e.abrupt("return");case 2:if(n={},r={},t.forEach((function(e){!e.mediaTrack||!e.isPublished||(e instanceof kL&&(e instanceof NL?r.audio=e:n.audio=e),e instanceof AL&&(e instanceof wL&&2===e.mediaType?r.video=e:n.video=e))})),e.prev=4,i=t.map((function(e){return e.kind})).join(","),e.t0=BH(n),e.t0){e.next=11;break}return this._log.info("unpublish() => main ".concat(i)),e.next=11,this.uplinkConnection.unpublish({localAudioTrack:n.audio,localVideoTrack:n.video});case 11:if(e.t1=BH(r),e.t1){e.next=16;break}return this._log.info("unpublish() => aux ".concat(i)),e.next=16,this.uplinkConnection.unpublish({localAudioTrack:r.audio,localVideoTrack:r.video});case 16:e.next=20;break;case 18:e.prev=18,e.t2=e.catch(4);case 20:0===this.localTracks.size&&this.closeUplink("you unpublished");case 21:case"end":return e.stop()}}),e,this,[[4,18]])})))}},{key:"addTrack",value:function(e){if(!this.uplinkConnection||!e.mediaTrack)return Promise.resolve();var t=this.uplinkConnection.addTrack(e);return e.publish(this,t),t}},{key:"removeTrack",value:function(e){return this.uplinkConnection&&e.mediaTrack?this.uplinkConnection.removeTrack(e).then((function(t){return e.unpublish(),t})):Promise.resolve()}},{key:"replaceTrack",value:function(e){return this.uplinkConnection&&e.mediaTrack&&nP()?this.uplinkConnection.replaceTrack(e).then((function(t){t&&rx.emit(ax.LOCAL_TRACK_REPLACED,{track:e})})):Promise.resolve()}},{key:"setBandWidth",value:function(e){return aR(this,null,f().mark((function t(){return f().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(t.t0=this.uplinkConnection,!t.t0){t.next=6;break}return t.next=4,this.uplinkConnection.setBandwidth(e);case 4:return t.next=6,this.uplinkConnection.sendMediaSettings();case 6:case"end":return t.stop()}}),t,this)})))}},{key:"enableSmall",value:function(e){return aR(this,null,f().mark((function t(){return f().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this.uplinkConnection&&this.uplinkConnection.localMainVideoTrack){t.next=2;break}return t.abrupt("return",Promise.resolve());case 2:if(t.t0=e&&this.uplinkConnection.localMainVideoTrack.small,!t.t0){t.next=6;break}return t.next=6,this.setBandWidth({type:nC.VIDEO,videoType:nC.SMALL,bandwidth:this.uplinkConnection.localMainVideoTrack.small.bitrate});case 6:return t.next=8,this.uplinkConnection.enableSmall(e);case 8:case"end":return t.stop()}}),t,this)})))}},{key:"subscribe",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return aR(this,null,f().mark((function e(){var n,r,i,a,o,c,u,l,d,h;return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=t.filter((function(e){return!e.isSubscribed})),0!==t.length){e.next=2;break}return e.abrupt("return");case 2:if(n=t[0].userId,r=this.remotePublishedUserMap.get(n)){e.next=5;break}return e.abrupt("return");case 5:return i=t.find((function(e){return 2===e.mediaType}))?"auxiliary":"main",e.prev=6,a=QA({},r.subscribeState),t.forEach((function(e){switch(e.mediaType){case 1:a.audio=!0;break;case 4:a.video=!0;break;case 8:a.smallVideo=!0;break;case 2:a.auxiliary=!0}})),(o=this._changeBigSmallRecords.get(n))&&o.options.smallVideo&&r.muteState.hasSmall&&a.video&&(a.video=!1,a.smallVideo=!0),rx.emit(ax.SUBSCRIBE_START,{room:this,streamType:i,remotePublishedUser:r,subscribeState:a}),this._log.info("subscribe() => ".concat(n," ").concat(i," [").concat(Nj(a),"] prev: [").concat(Nj(r.subscribeState),"]")),e.next=15,r.subscribe(a,i);case 15:this._log.info("subscribe ".concat(n," ").concat(i," done")),c=s(t),e.prev=17,c.s();case 19:if((u=c.n()).done){e.next=27;break}if(l=u.value,e.t0=l.mediaTrack,e.t0){e.next=25;break}return e.next=25,l.waitHasMediaTrack();case 25:e.next=19;break;case 27:e.next=32;break;case 29:e.prev=29,e.t1=e.catch(17),c.e(e.t1);case 32:return e.prev=32,c.f(),e.finish(32);case 35:rx.emit(ax.SUBSCRIBE_SUCCESS,{room:this,streamType:i,remotePublishedUser:r}),e.next=42;break;case 38:throw e.prev=38,e.t2=e.catch(6),d=e.t2 instanceof yR?e.t2.getCode():_R.UNKNOWN,h=e.t2,e.t2 instanceof yR?d===_R.REMOTE_STREAM_NOT_EXIST&&(h=new yR({code:_R.API_CALL_ABORTED,message:mO({key:dO.API_CALL_ABORTED,data:{message:e.t2.message,userId:n,streamType:i}})}),this._log.warn(h)):(h=new yR({code:d,message:mO({key:dO.SUBSCRIBE_FAILED,data:{message:e.t2.message,userId:n,streamType:i}})}),this._log.error(h)),h;case 42:case"end":return e.stop()}}),e,this,[[6,38],[17,29,32,35]])})))}},{key:"unsubscribe",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return aR(this,null,f().mark((function e(){var n,r,i;return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=t[0].userId,r=this.remotePublishedUserMap.get(n)){e.next=3;break}return e.abrupt("return");case 3:return i=t.find((function(e){return 2===e.mediaType}))?"auxiliary":"main",this._log.info("unsubscribe() => ".concat(n," ").concat(i)),e.prev=5,e.next=8,r.unsubscribe({remoteTracks:t,streamType:i});case 8:e.next=13;break;case 10:e.prev=10,e.t0=e.catch(5),this._log.warn("unsubscribe() => failed ".concat(e.t0));case 13:t.forEach((function(e){e.unsubscribe(),8===e.mediaType&&e.setMediaType(4)})),rx.emit(ax.UNSUBSCRIBE_SUCCESS,{room:this,streamType:i,remotePublishedUser:r});case 14:case"end":return e.stop()}}),e,this,[[5,10]])})))}},{key:"setEncodedDataProcessingListener",value:function(e){throw new Error("Method not implemented.")}},{key:"enableAudioVolumeEvaluation",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:2e3,n=arguments.length>1?arguments[1]:void 0;if(t<=0)return this._enableAudioVolumeEvaluation=!1,void MP.clearTask(this._audioVolumeIntervalId);t=Math.floor(Math.max(t,100)),rx.emit(ax.AUDIO_LEVEL_INTERVAL,{interval:t}),this._audioVolumeIntervalId&&MP.clearTask(this._audioVolumeIntervalId),this._enableAudioVolumeEvaluation=!0,this._audioVolumeIntervalId=MP.run("intervalInWorker",(function(){var r;OM.isRunning?e.stopUpdateAudioLevelFromSenderStat():e.updateAudioLevelFromSenderStat(t,n);var i=[];null==(r=e.remotePublishedUserMap)||r.forEach((function(t){if(t.muteState.hasAudio){!OM.isRunning&&t.muteState.audioAvailable&&t.remoteAudioTrack.isSubscribed?e.updateDownlinkAudioLevelFromReceiver(t):t.remoteAudioTrack.volume=0;var n=Math.floor(100*t.remoteAudioTrack.getAudioLevel());i.push({userId:t.userId,volume:n})}})),e.emit("audio-volume",i)}),{delay:t,backgroundTask:n})}},{key:"updateAudioLevelFromSenderStat",value:function(e,t){return aR(this,null,f().mark((function n(){var r,i,a,o=this;return f().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(this.uplinkConnection&&this.uplinkConnection.localMainAudioTrack&&-1===this._updateAudioLevelTaskId){n.next=2;break}return n.abrupt("return");case 2:if(i=null==(r=this.uplinkConnection.getPeerConnection())?void 0:r.getSenders()[0]){n.next=5;break}return n.abrupt("return");case 5:a=Math.max(e,500),this._log.warn("updateAudioLevelFromSenderStat ".concat(a)),this._updateAudioLevelTaskId=MP.run("intervalInWorker",(function(){return aR(o,null,f().mark((function e(){var t,n;return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.uplinkConnection&&this.uplinkConnection.localMainAudioTrack){e.next=2;break}return e.abrupt("return",void this.stopUpdateAudioLevelFromSenderStat());case 2:return e.next=4,i.getStats();case 4:if(t=e.sent,!(this._updateAudioLevelTaskId<0)){e.next=7;break}return e.abrupt("return");case 7:n=this.uplinkConnection.localMainAudioTrack,t.forEach((function(e){"media-source"===e.type&&e.audioLevel&&(n.volume=e.audioLevel)}));case 9:case"end":return e.stop()}}),e,this)})))}),{delay:a,backgroundTask:t});case 7:case"end":return n.stop()}}),n,this)})))}},{key:"stopUpdateAudioLevelFromSenderStat",value:function(){var e;-1!==this._updateAudioLevelTaskId&&(this._log.warn("stopUpdateAudioLevelFromSenderStat"),MP.clearTask(this._updateAudioLevelTaskId),this._updateAudioLevelTaskId=-1,null!=(e=this.uplinkConnection)&&e.localMainAudioTrack&&(this.uplinkConnection.localMainAudioTrack.volume=0))}},{key:"updateDownlinkAudioLevelFromReceiver",value:function(e){var t,n=e.audioReceiver;if(iP&&n){var r=null==(t=n.getSynchronizationSources()[0])?void 0:t.audioLevel;Aw(r)?e.remoteAudioTrack.volume=Math.min(2*r,1):n.getStats().then((function(t){t.forEach((function(t){"inbound-rtp"===t.type&&Aw(t.audioLevel)&&(e.remoteAudioTrack.volume=t.audioLevel)}))}))}}},{key:"getLocalAudioStats",value:function(){return aR(this,null,f().mark((function e(){var t,n;return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n={},e.abrupt("return",(n[this.userId]={bytesSent:0,packetsSent:0,audioLevel:0},null!=(t=this.uplinkConnection)&&t.localMainAudioTrack&&(n[this.userId]=this.uplinkConnection.localMainAudioTrack.stat),n));case 2:case"end":return e.stop()}}),e,this)})))}},{key:"getLocalVideoStats",value:function(){return aR(this,null,f().mark((function e(){var t,n,r;return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r={},e.abrupt("return",(r[this.userId]=(null==(n=null==(t=this.uplinkConnection)?void 0:t.localMainVideoTrack)?void 0:n.stat)||{bytesSent:0,packetsSent:0,framesEncoded:0,framesSent:0,frameWidth:0,frameHeight:0,fpsCapture:0},r));case 2:case"end":return e.stop()}}),e,this)})))}},{key:"getTransportStats",value:function(){return aR(this,null,f().mark((function e(){var t,n,r,i,a,o,c;return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t={rtt:0,downlinksRTT:{}},!this.uplinkConnection){e.next=6;break}return e.next=4,this._stats.getSenderStats(this.uplinkConnection);case 4:n=e.sent,t.rtt=n.rtt;case 6:r=s(this.remotePublishedUserMap),e.prev=7,r.s();case 9:if((i=r.n()).done){e.next=17;break}return a=v(i.value,2),o=a[1],e.next=13,this._stats.getReceiverStats(o);case 13:c=e.sent,t.downlinksRTT[c.userId]=c.rtt;case 15:e.next=9;break;case 17:e.next=22;break;case 19:e.prev=19,e.t0=e.catch(7),r.e(e.t0);case 22:return e.prev=22,r.f(),e.finish(22);case 25:return e.abrupt("return",t);case 26:case"end":return e.stop()}}),e,this,[[7,19,22,25]])})))}},{key:"getRemoteVideoStats",value:function(e){return aR(this,null,f().mark((function t(){var n,r,i,a,o,c;return f().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:n={},r=s(this.remotePublishedUserMap);try{for(r.s();!(i=r.n()).done;)a=v(i.value,2),o=a[0],c=a[1],"main"===e&&c.muteState.hasVideo&&(n[o]=c.remoteVideoTrack.stat),"auxiliary"===e&&c.muteState.hasAuxiliary&&(n[o]=c.remoteAuxiliaryTrack.stat)}catch(u){r.e(u)}finally{r.f()}return t.abrupt("return",n);case 4:case"end":return t.stop()}}),t,this)})))}},{key:"getRemoteAudioStats",value:function(){return aR(this,null,f().mark((function e(){var t,n,r,i,a,o;return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t={},n=s(this.remotePublishedUserMap);try{for(n.s();!(r=n.n()).done;)i=v(r.value,2),a=i[0],(o=i[1]).muteState.hasAudio&&(t[a]=o.remoteAudioTrack.stat)}catch(c){n.e(c)}finally{n.f()}return e.abrupt("return",t);case 4:case"end":return e.stop()}}),e,this)})))}},{key:"setTurnServer",value:function(e,t){this._log.info("set turn server: ".concat(JSON.stringify(e)," ").concat(t||""));var n=[];Array.isArray(e)?e.forEach((function(e){return n.push(IR.getTurnServer(e))})):IR.isPlainObject(e)&&n.push(IR.getTurnServer(e)),this._turnServers=n,t&&(this._iceTransportPolicy=t)}},{key:"sendStartMixTranscode",value:function(e){return this.signalChannel.sendWaitForResponse({command:"start_mcu_mix",data:e,timeout:5e3,responseCommand:fj.START_MIX_TRANSCODE_RES,commandDesc:"startMixTranscode"})}},{key:"sendStopMixTranscode",value:function(e){return this.signalChannel.sendWaitForResponse({command:"stop_mcu_mix",data:e,timeout:5e3,responseCommand:fj.STOP_MIX_TRANSCODE_RES,commandDesc:"stopMixTranscode"})}},{key:"sendStartPublishCDN",value:function(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];return this.signalChannel.sendWaitForResponse({command:t?"start_publishing":"start_push_user_cdn",data:e,timeout:5e3,responseCommand:t?fj.START_PUBLISH_TENCENT_CDN_RES:fj.START_PUBLISH_GIVEN_CDN_RES,commandDesc:"startPublishCDN"})}},{key:"sendStopPublishCDN",value:function(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];return this.signalChannel.sendWaitForResponse({command:t?"stop_publishing":"stop_push_user_cdn",data:e,timeout:5e3,responseCommand:t?fj.STOP_PUBLISH_TENCENT_CDN_RES:fj.STOP_PUBLISH_GIVEN_CDN_RES,commandDesc:"stopPublishCDN"})}},{key:"sendStartPushStreamToRoom",value:function(e){return this.signalChannel.sendWaitForResponse({command:"start_publish_cdn_stream",data:e,timeout:5e3,responseCommand:fj.START_PUBLISH_CDN_STREAM_RES,commandDesc:"startPublishCDNStream"})}},{key:"sendUpdatePushStreamToRoom",value:function(e){return this.signalChannel.sendWaitForResponse({command:"update_publish_cdn_stream",data:e,timeout:5e3,responseCommand:fj.UPDATE_PUBLISH_CDN_STREAM_RES,commandDesc:"updatePublishCDNStream"})}},{key:"sendStopPushStreamToRoom",value:function(e){return this.signalChannel.sendWaitForResponse({command:"stop_publish_cdn_stream",data:e,timeout:5e3,responseCommand:fj.STOP_PUBLISH_CDN_STREAM_RES,commandDesc:"stopPublishCDNStream"})}},{key:"sendAbilityStatus",value:function(e){var t;null==(t=this.signalChannel)||t.sendWaitForResponse({command:"ability_status_report",data:e,timeout:5e3,responseCommand:fj.ABILITY_STATUS_REPORT_RESULT,commandDesc:"ability status report"}).catch((function(e){}))}},{key:"getIceServers",value:function(e){var t,n;return this._turnServers.length>0?this._turnServers:null!=(t=this.scheduleResult.iceServers)&&t.length?this.scheduleResult.iceServers:null!=e&&e.length?e:null!=(n=this._iceServersFromJoin)&&n.length?this._iceServersFromJoin:[]}},{key:"getIceTransportPolicy",value:function(){return this.forceRelay?"relay":this._iceTransportPolicy||this.scheduleResult.iceTransportPolicy||"all"}},{key:"getLogger",value:function(){return this._log}},{key:"enableAIVoice",value:function(){throw new Error("Method not implemented.")}},{key:"getSignalChannelUrl",value:function(){var e={mainUrl:"",backupUrl:""},t=IR.getEnv();return t?(e.mainUrl="wss://".concat(t,".rtc.qq.com"),e.backupUrl=e.mainUrl):this.proxy_ws?(e.mainUrl=this.proxy_ws,e.backupUrl=e.mainUrl):this.proxy_unified?(e.mainUrl="wss://".concat(this.proxy_unified),e.backupUrl=e.mainUrl):Array.isArray(this.scheduleResult.domains)&&this.scheduleResult.domains.length>0&&(e.mainUrl="wss://".concat(this.scheduleResult.domains[0]),e.backupUrl=e.mainUrl,this.scheduleResult.domains[1]&&(e.backupUrl="wss://".concat(this.scheduleResult.domains[1]))),e}},{key:"getSignalInfo",value:function(){var e;return(null==(e=this.signalChannel)?void 0:e.getSignalInfo())||{clientIp:"",relayIp:""}}},{key:"reset",value:function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];this.stopSyncUserListInterval(),this.stopHeartbeat(),this.closeConnections(),this.clearNetworkQuality(),this.closeUplink("you exitRoom"),this.signalChannel&&(e&&this.signalChannel.keepAlive&&this.signalChannel.isConnected?this.signalChannel.stopKeepAliveIn(3600):(this.signalChannel.close(),this.setSignalChannel(null))),this._stats.reset(),this.userManager.clear(),this.userManager.removeAllListeners(),this.singlePC&&(this.singlePC.close(),this.singlePC=null),this.scheduleResult={domains:null,iceServers:null,iceTransportPolicy:null,trtcAutoConf:null}}},{key:"checkSubscribeBigSmallVideo",value:function(e){return aR(this,null,f().mark((function t(){var n,r,i,a,o,s,c,u,l;return f().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=e.subscribeState,r=e.userId,i=e.muteState,a=i.hasSmall,o=i.hasVideo,(a||o)&&(n.video||n.smallVideo)){t.next=3;break}return t.abrupt("return");case 3:if(!(!(s=this._changeBigSmallRecords.get(r))||s.isSubscribing||s.reSubscribeCount<=0)){t.next=6;break}return t.abrupt("return");case 6:if(c=s.options,u=s.reSubscribeCount,!(c.video&&n.video||c.smallVideo&&n.smallVideo&&a)){t.next=9;break}return t.abrupt("return");case 9:if(l={audio:e.remoteAudioTrack.isSubscribed||e.remoteAudioTrack.isSubscribing,auxiliary:e.remoteAuxiliaryTrack.isSubscribed||e.remoteAuxiliaryTrack.isSubscribing,video:c.video,smallVideo:c.smallVideo},t.prev=10,!a&&l.smallVideo&&(l.video=!0,l.smallVideo=!1),l.smallVideo!==n.smallVideo||l.video!==n.video){t.next=13;break}return t.abrupt("return");case 13:return s.isSubscribing=!0,s.reSubscribeCount=u-1,t.next=17,e.subscribe(l,"main");case 17:e.remoteVideoTrack.setMediaType(l.smallVideo?8:4),this._log.info("change [".concat(r,"] to ").concat(l.smallVideo?"small":"big"," video successfully. count ").concat(ew-s.reSubscribeCount,".")),s.isSubscribing=!1,s.reSubscribeCount=ew,t.next=26;break;case 23:t.prev=23,t.t0=t.catch(10),this._log.info("change [".concat(r,"] to ").concat(l.smallVideo?"small":"big"," video failed. count ").concat(ew-s.reSubscribeCount,".")),s.isSubscribing=!1,0===s.reSubscribeCount&&this._changeBigSmallRecords.delete(r);case 26:case"end":return t.stop()}}),t,this,[[10,23]])})))}},{key:"changeType",value:function(e,t){var n={options:{video:!e,smallVideo:e},isSubscribing:!1,reSubscribeCount:ew};this._changeBigSmallRecords.set(t.userId,n),this._log.info("set [".concat(t.userId,"] video prefer type: ").concat(e?"small":"big"));var r=this.remotePublishedUserMap.get(t.userId);r&&this.checkSubscribeBigSmallVideo(r)}},{key:"smallStreamConfig",get:function(){return this._smallStreamConfig}},{key:"_initBusinessInfo",value:function(e){this._businessInfo=e.businessInfo;var t={};if(VH(e.businessInfo)&&(t=JSON.parse(e.businessInfo)),!UH(e.pureAudioPushMode)){if(!Number.isInteger(Number(e.pureAudioPushMode)))throw new yR({code:_R.INVALID_PARAMETER,message:mO({key:dO.INVALID_PURE_AUDIO})});this._pureAudioPushMode=e.pureAudioPushMode,t.Str_uc_params||(t.Str_uc_params={}),t.Str_uc_params.pure_audio_push_mod=this._pureAudioPushMode}if(!UH(e.userDefineRecordId)){if(null===e.userDefineRecordId.match(/^[A-Za-z0-9_-]{1,64}$/gi))throw new yR({code:_R.INVALID_PARAMETER,message:mO({key:dO.INVALID_USER_DEFINE_RECORDID})});t.Str_uc_params||(t.Str_uc_params={}),t.Str_uc_params.userdefine_record_id=e.userDefineRecordId}if(!UH(e.userDefinePushArgs)){if(!(VH(e.userDefinePushArgs)&&String(e.userDefinePushArgs)&&String(e.userDefinePushArgs).length<=256))throw new yR({code:_R.INVALID_PARAMETER,message:mO({key:dO.INVALID_USER_DEFINE_PUSH_ARGS})});t.Str_uc_params||(t.Str_uc_params={}),t.Str_uc_params.userdefine_push_args=e.userDefinePushArgs}BH(t)||(this._businessInfo=JSON.stringify(t))}},{key:"sendCustomMessage",value:function(e){var t;null==(t=this._customMessageManager)||t.send(e)}},{key:"enableInsertableStreams",value:function(){return aR(this,null,f().mark((function e(){return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.singlePC||this.singlePC.enableInsertableStreams||!sP){e.next=7;break}return this.singlePC.enableInsertableStreams=!0,e.next=4,this.singlePC.waitForPeerConnectionConnected();case 4:return e.next=6,this.singlePC.startReconnection();case 6:return e.abrupt("return",e.sent);case 7:case"end":return e.stop()}}),e,this)})))}},{key:"sendSignalMessage",value:function(e){var t;return this.signalChannel?null==(t=this.signalChannel)?void 0:t.sendWaitForResponseWithRetry(e):Promise.reject(new yR({code:_R.INVALID_OPERATION,message:"not join"}))}},{key:"enableCodecPipeline",get:function(){return this.videoManager.encodePipeline.length>0||this.videoManager.decodePipeline.length>0||this.audioManager.encodePipeline.length>0||this.audioManager.decodePipeline.length>0}},{key:"scriptTransformWorker",get:function(){var e;return null==(e=this.singlePC)?void 0:e.scriptTransformWorker}}])}(sH);return nR([AP(["left",wP.INIT],"joined"),GP({settings:{retries:1,timeout:0},onRetrying:function(e){this._log.warn("join retry ".concat(e))},onRetryFailed:function(e){this._log.error("join failed",e)},onError:function(e,t){this._isUsingCachedSchedule&&!this.isDestroyed?(this._log.warn("is using cached schedule, retry join"),rB(!0),this.reset(),t()):this.signalChannel&&this.signalChannel.isConnected&&this.signalChannel.keepAlive?(this._log.warn("is using keepAlive ws, retry join"),this.signalChannel.close(),this.reset(),t()):(this.reset(),t())}}),uL((function(e){var t=new oj;return function(n,r,i){return aR(this,null,f().mark((function a(){var o,s,c,u=this;return f().wrap((function(a){for(;;)switch(a.prev=a.next){case 0:if(o=String(n.roomId||n.strRoomId),this.userId=n.userId,this.sdkAppId=n.sdkAppId,this.userSig=n.userSig,this._log.setSdkAppId(this.sdkAppId),this._log.setUserId(this.userId),this.scene=r,n.privateMapKey=n.privateMapKey||"",!this.isJoined){a.next=3;break}throw new yR({code:_R.INVALID_OPERATION,message:mO({key:dO.INVALID_JOIN})});case 3:if(this.checkDestroy(),!t.isJoined({userId:this.userId,roomId:o,sdkAppId:this.sdkAppId,room:this})){a.next=5;break}throw new yR({code:_R.INVALID_OPERATION,message:mO({key:dO.REPEAT_JOIN,data:this.userId})});case 5:if(t.add({room:this,roomId:o}),this.role=21===n.role?"audience":"anchor",this._log.info("Join() => joining room: ".concat(o," useStringRoomId: ").concat(this.useStringRoomId," scene: ").concat(this.scene," role: ").concat(this.role)),rx.emit(ax.JOIN_START,{room:this,roomId:o,params:n}),(s=IR.getEnv())||(s=zR.QCLOUD,this.proxy_ws&&(this.proxy_ws.startsWith(iC.OLD_CLOUD_LADDER)?s=zR.OLD_CLOUD_LADDER:this.proxy_ws.startsWith(iC.WEBRTC)&&(s=zR.WEBRTC))),jP.setConfig({env:s,sdkAppId:String(this.sdkAppId),userId:this.userId,roomId:o}),lx.checkSystemRequirementsInternal().then((function(e){u.checkSystemResult=e,sj.call(u)})),a.prev=8,a.t0=!(this.proxy_ws||this.proxy_wt||this.scheduleResult.domains||IR.getEnv()),!a.t0){a.next=13;break}return a.next=13,this.schedule(n,i);case 13:return a.next=15,e.call(this,n,r,i);case 15:return c=a.sent,a.abrupt("return",(this.roomId=o,this._joinedTimestamp=IR.performanceNow(),rx.emit(ax.JOIN_SUCCESS,{room:this}),30===i&&!n.component&&jP.uploadEvent({log:"stat-conv-".concat(Number(jN),"-").concat(location.hostname),userId:this.userId}),c));case 19:throw a.prev=19,a.t1=a.catch(8),t.delete({room:this,roomId:o}),rx.emit(ax.JOIN_FAILED,{room:this,error:a.t1}),a.t1;case 22:case"end":return a.stop()}}),a,this,[[8,19]])})))}}))],jH.prototype,"join",1),nR([AP("joined","left",{ignoreError:!0,success:function(){this.reset(!0)}}),uL((function(e){return function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return aR(this,null,f().mark((function t(){return f().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return rx.emit(ax.LEAVE_START,{room:this}),t.next=3,e.call.apply(e,[this].concat(n));case 3:rx.emit(ax.LEAVE_SUCCESS,{room:this,roomId:this.roomId});case 4:case"end":return t.stop()}}),t,this)})))}})),vL("leave room"),WP({fnName:"publish",validateArgs:!1}),WP({fnName:"unsubscribe",validateArgs:!1})],jH.prototype,"leave",1),nR([mL(),uL((function(e){return function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return aR(this,null,f().mark((function t(){var r,i=this;return f().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(("live"!==this.scene||"anchor"===this.role)&&(n=n.filter((function(e){return e.outMediaTrack&&"capture"===e.state})),n.length)){t.next=2;break}return t.abrupt("return");case 2:return rx.emit("61",{room:this}),r=e.apply(this,n),t.abrupt("return",(n.forEach((function(e){return e.publish(i,r)})),r));case 5:case"end":return t.stop()}}),t,this)})))}})),GP({settings:{retries:wC,timeout:function(e){return Tw(e)}},onError:function(e,t,n){var r;null!=(r=e.message)&&r.includes("timeout")?(this._log.warn("publish timeout"),t()):(this._log.error("publish failed: ".concat(e)),n(e),rx.emit(ax.PUBLISH_FAILED,{room:this}))}})],jH.prototype,"publish",1),nR([WP({fnName:"publish"}),function(e,t,n){var r=n.value;return n.value=function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];var i=fL.get(this);if(i){var a=i.queue.filter((function(e,n){if(0===n)return!0;var r=!0;return e.args.forEach((function(e){t.find((function(t){return t===e}))||(r=!1)})),!r||(e.reject(new yR({code:_R.API_CALL_ABORTED,message:"api-call"})),!1)}));i.queue=a}return r.apply(this,t)},n},mL(),uL((function(e){return function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];var i=e.apply(this,n);return n.forEach((function(e){return e.unpublish()})),i}})),sL((function(){var e,t;0===this.localTracks.size&&XO()&&(null==(t=null==(e=this.singlePC)?void 0:e.getPeerConnection())||t.getSenders().forEach((function(e){return e.track&&e.replaceTrack(null)})))}))],jH.prototype,"unpublish",1),nR([cL((function(e){if(e.code!==_R.API_CALL_ABORTED)throw e})),_L((function(e){return e.userId}))],jH.prototype,"replaceTrack",1),nR([_L((function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return t[0].userId})),PL(),uL((function(e){return function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];var i=e.apply(this,n);return n.forEach((function(e){return!e.isSubscribed&&e.subscribe(i)})),i}})),GP({settings:{retries:wC,timeout:function(e){return Tw(e)}},onError:function(e,t,n,r){e.message.includes("timeout")?(this._log.warn("subscribe timeout"),t()):(this._log.error("subscribe failed: ".concat(e)),n(e),rx.emit(ax.SUBSCRIBE_FAILED,{room:this,remoteTracks:r}))}})],jH.prototype,"subscribe",1),nR([WP({fnName:"subscribe",callback:function(){for(var e=this,t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];this.singlePC||n.forEach((function(t){var n=e.remotePublishedUserMap.get(t.userId);n&&!n.isMainStreamSubscribed&&!n.isAuxStreamSubscribed&&n.close("you unsubscribed")}))}}),_L((function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return t[0].userId}))],jH.prototype,"unsubscribe",1),aj.create=aj._create.bind(aj,jH),aj},"object"==("undefined"==typeof exports?"undefined":k(exports))&&"undefined"!=typeof module?module.exports=A():"function"==typeof define&&define.amd?define(A):(b="undefined"!=typeof globalThis?globalThis:b||self).TRTC=A()},"function"==typeof define&&define.amd?define(["core-js/modules/es.symbol.js","core-js/modules/es.symbol.description.js","core-js/modules/es.symbol.iterator.js","core-js/modules/es.array.concat.js","core-js/modules/es.array.every.js","core-js/modules/es.array.fill.js","core-js/modules/es.array.filter.js","core-js/modules/es.array.find.js","core-js/modules/es.array.find-index.js","core-js/modules/es.array.for-each.js","core-js/modules/es.array.from.js","core-js/modules/es.array.includes.js","core-js/modules/es.array.index-of.js","core-js/modules/es.array.is-array.js","core-js/modules/es.array.iterator.js","core-js/modules/es.array.join.js","core-js/modules/es.array.last-index-of.js","core-js/modules/es.array.map.js","core-js/modules/es.array.reduce.js","core-js/modules/es.array.reduce-right.js","core-js/modules/es.array.reverse.js","core-js/modules/es.array.slice.js","core-js/modules/es.array.some.js","core-js/modules/es.array.sort.js","core-js/modules/es.array.splice.js","core-js/modules/es.array-buffer.constructor.js","core-js/modules/es.array-buffer.slice.js","core-js/modules/es.data-view.js","core-js/modules/es.date.now.js","core-js/modules/es.date.to-json.js","core-js/modules/es.date.to-string.js","core-js/modules/es.function.bind.js","core-js/modules/es.function.name.js","core-js/modules/es.map.js","core-js/modules/es.math.fround.js","core-js/modules/es.math.log10.js","core-js/modules/es.math.sign.js","core-js/modules/es.math.trunc.js","core-js/modules/es.number.constructor.js","core-js/modules/es.number.is-integer.js","core-js/modules/es.number.is-nan.js","core-js/modules/es.number.to-fixed.js","core-js/modules/es.object.assign.js","core-js/modules/es.object.create.js","core-js/modules/es.object.define-properties.js","core-js/modules/es.object.define-property.js","core-js/modules/es.object.freeze.js","core-js/modules/es.object.get-own-property-descriptor.js","core-js/modules/es.object.get-own-property-descriptors.js","core-js/modules/es.object.get-own-property-names.js","core-js/modules/es.object.get-prototype-of.js","core-js/modules/es.object.keys.js","core-js/modules/es.object.set-prototype-of.js","core-js/modules/es.object.to-string.js","core-js/modules/es.object.values.js","core-js/modules/es.parse-float.js","core-js/modules/es.parse-int.js","core-js/modules/es.promise.js","core-js/modules/es.promise.finally.js","core-js/modules/es.reflect.apply.js","core-js/modules/es.reflect.get.js","core-js/modules/es.reflect.own-keys.js","core-js/modules/es.regexp.constructor.js","core-js/modules/es.regexp.exec.js","core-js/modules/es.regexp.flags.js","core-js/modules/es.regexp.to-string.js","core-js/modules/es.set.js","core-js/modules/es.string.ends-with.js","core-js/modules/es.string.from-code-point.js","core-js/modules/es.string.includes.js","core-js/modules/es.string.iterator.js","core-js/modules/es.string.match.js","core-js/modules/es.string.pad-start.js","core-js/modules/es.string.replace.js","core-js/modules/es.string.search.js","core-js/modules/es.string.split.js","core-js/modules/es.string.starts-with.js","core-js/modules/es.string.trim.js","core-js/modules/es.string.link.js","core-js/modules/es.string.small.js","core-js/modules/es.typed-array.float32-array.js","core-js/modules/es.typed-array.int8-array.js","core-js/modules/es.typed-array.uint8-array.js","core-js/modules/es.typed-array.uint8-clamped-array.js","core-js/modules/es.typed-array.copy-within.js","core-js/modules/es.typed-array.every.js","core-js/modules/es.typed-array.fill.js","core-js/modules/es.typed-array.filter.js","core-js/modules/es.typed-array.find.js","core-js/modules/es.typed-array.find-index.js","core-js/modules/es.typed-array.for-each.js","core-js/modules/es.typed-array.from.js","core-js/modules/es.typed-array.includes.js","core-js/modules/es.typed-array.index-of.js","core-js/modules/es.typed-array.iterator.js","core-js/modules/es.typed-array.join.js","core-js/modules/es.typed-array.last-index-of.js","core-js/modules/es.typed-array.map.js","core-js/modules/es.typed-array.reduce.js","core-js/modules/es.typed-array.reduce-right.js","core-js/modules/es.typed-array.reverse.js","core-js/modules/es.typed-array.set.js","core-js/modules/es.typed-array.slice.js","core-js/modules/es.typed-array.some.js","core-js/modules/es.typed-array.sort.js","core-js/modules/es.typed-array.subarray.js","core-js/modules/es.typed-array.to-locale-string.js","core-js/modules/es.typed-array.to-string.js","core-js/modules/es.weak-map.js","core-js/modules/esnext.global-this.js","core-js/modules/web.dom-collections.for-each.js","core-js/modules/web.dom-collections.iterator.js","core-js/modules/web.timers.js","core-js/modules/web.url.js","core-js/modules/web.url.to-json.js","core-js/modules/web.url-search-params.js"],factory):factory();
|