trtc-sdk-v5 5.10.1-beta.6 → 5.10.1-beta.7
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/virtual-background/virtual-background.esm.js +1 -1
- package/plugins/video-effect/virtual-background/virtual-background.umd.js +1 -1
- package/plugins/video-effect/watermark/package.json +1 -1
- package/plugins/voice-changer/package.json +1 -1
- package/trtc.es5.js +1 -0
- package/trtc.esm.js +26 -26
- package/trtc.js +1 -1
package/trtc.es5.js
ADDED
|
@@ -0,0 +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){(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 o(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 a(e,t,n){return t&&o(e.prototype,t),n&&o(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 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 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},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",p="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: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 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 p(e,t,n,r){return p="undefined"!=typeof Reflect&&Reflect.set?Reflect.set:function(e,t,n,r){var i,o=_(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 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,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)||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,o){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(o?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="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function A(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var R=function(e){try{return!!e()}catch(t){return!0}};Sf({target:"Array",stat:!0},{isArray:Kc});var C={},w="object"==("undefined"==typeof document?"undefined":k(document))&&document.all,D=void 0===w&&void 0!==w?function(e){return"function"==typeof e||e===w}:function(e){return"function"==typeof e},N=D,x=function(e){return"object"==k(e)?null!==e:N(e)},O=x,P=Af.document,M=O(P)&&O(P.createElement),L=function(e){return M?P.createElement(e):{}},U=L,V=!vc&&!R((function(){return 7!==Object.defineProperty(U("div"),"a",{get:function(){return 7}}).a})),F=vc&&R((function(){return 42!==Object.defineProperty((function(){}),"prototype",{value:42,writable:!1}).prototype})),B=x,j=String,H=TypeError,G=function(e){if(B(e))return e;throw new H(j(e)+" is not an object")},W=!R((function(){var e=function(){}.bind();return"function"!=typeof e||e.hasOwnProperty("prototype")})),J=W,z=Function.prototype,K=z.call,q=J&&z.bind.bind(K,K),Y=J?q:function(e){return function(){return K.apply(e,arguments)}},X=R,Q=function(e,t){var n=[][e];return!!n&&X((function(){n.call(null,t||function(){return 1},1)}))},$=Sf,Z=Ph,ee=Uh,te=Q,ne=Y([].join);$({target:"Array",proto:!0,forced:Z!==Object||!te("join",",")},{join:function(e){return ne(ee(this),void 0===e?",":e)}});var re=String,ie=function(e){try{return re(e)}catch(t){return"Object"}},oe=D,ae=ie,se=TypeError,ce=function(e){if(oe(e))return e;throw new se(ae(e)+" is not a function")},ue=function(e){return null==e},le=ue,de=TypeError,he=function(e){if(le(e))throw new de("Can't call method on "+e);return e},fe=he,pe=Object,me=function(e){return pe(fe(e))},ve=me,_e=Y({}.hasOwnProperty),ge=Object.hasOwn||function(e,t){return _e(ve(e),t)},ye=Uf,Ee=D,Te=Jc,ke=Mf("toStringTag"),Se=Object,Ie="Arguments"===Te(function(){return arguments}()),be=ye?Te: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=Se(e),ke))?n:Ie?Te(t):"Object"===(r=Te(t))&&Ee(t.callee)?"Arguments":r},Ae=Af,Re=D,Ce=function(e,t){return arguments.length<2?(n=Ae[e],Re(n)?n:void 0):Ae[e]&&Ae[e][t];var n},we={},De={get exports(){return we},set exports(e){we=e}},Ne=Af,xe=Object.defineProperty,Oe=function(e,t){try{xe(Ne,e,{value:t,configurable:!0,writable:!0})}catch(n){Ne[e]=t}return t},Pe=Af,Me=Oe,Le="__core-js_shared__",Ue=De.exports=Pe[Le]||Me(Le,{});(Ue.versions||(Ue.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 Ve=D,Fe=we,Be=Y(Function.toString);Ve(Fe.inspectSource)||(Fe.inspectSource=function(e){return Be(e)});var je=Fe.inspectSource,He=Y,Ge=R,We=D,Je=be,ze=je,Ke=function(){},qe=Ce("Reflect","construct"),Ye=/^\s*(?:class|function)\b/,Xe=He(Ye.exec),Qe=!Ye.test(Ke),$e=function(e){if(!We(e))return!1;try{return qe(Ke,[],e),!0}catch(t){return!1}},Ze=function(e){if(!We(e))return!1;switch(Je(e)){case"AsyncFunction":case"GeneratorFunction":case"AsyncGeneratorFunction":return!1}try{return Qe||!!Xe(Ye,ze(e))}catch(t){return!0}};Ze.sham=!0;var et=!qe||Ge((function(){var e;return $e($e.call)||!$e(Object)||!$e((function(){e=!0}))||e}))?Ze:$e;Sf({target:"Math",stat:!0},{trunc:at});var tt,nt,rt,it=Math.ceil,ot=Math.floor,at=Math.trunc||function(e){var t=+e;return(t>0?ot:it)(t)},st=at,ct=function(e){var t=+e;return t!=t||0===t?0:st(t)},ut=ct,lt=Math.max,dt=Math.min,ht=function(e,t){var n=ut(e);return n<0?lt(n+t,0):dt(n,t)},ft=ct,pt=Math.min,mt=function(e){var t=ft(e);return t>0?pt(t,9007199254740991):0},vt=mt,_t=function(e){return vt(e.length)},gt=function(e,t){return{enumerable:!(1&e),configurable:!(2&e),writable:!(4&e),value:t}},yt=vc,Et=C,Tt=gt,kt=function(e,t,n){yt?Et.f(e,t,Tt(0,n)):e[t]=n},St={},It={get exports(){return St},set exports(e){St=e}},bt=vc,At=ge,Rt=Function.prototype,Ct=bt&&Object.getOwnPropertyDescriptor,wt=At(Rt,"name"),Dt={EXISTS:wt,PROPER:wt&&"something"===function(){}.name,CONFIGURABLE:wt&&(!bt||bt&&Ct(Rt,"name").configurable)},Nt=D,xt=Af.WeakMap,Ot=Nt(xt)&&/native code/.test(String(xt)),Pt=C,Mt=gt,Lt=vc?function(e,t,n){return Pt.f(e,t,Mt(1,n))}:function(e,t,n){return e[t]=n,e},Ut=we,Vt=function(e,t){return Ut[e]||(Ut[e]=t||{})},Ft=Y,Bt=0,jt=Math.random(),Ht=Ft(1..toString),Gt=function(e){return"Symbol("+(void 0===e?"":e)+")_"+Ht(++Bt+jt,36)},Wt=Gt,Jt=Vt("keys"),zt=function(e){return Jt[e]||(Jt[e]=Wt(e))},Kt={},qt=Ot,Yt=Af,Xt=x,Qt=Lt,$t=ge,Zt=we,en=zt,tn=Kt,nn="Object already initialized",rn=Yt.TypeError,on=Yt.WeakMap;if(qt||Zt.state){var an=Zt.state||(Zt.state=new on);an.get=an.get,an.has=an.has,an.set=an.set,tt=function(e,t){if(an.has(e))throw new rn(nn);return t.facade=e,an.set(e,t),t},nt=function(e){return an.get(e)||{}},rt=function(e){return an.has(e)}}else{var sn=en("state");tn[sn]=!0,tt=function(e,t){if($t(e,sn))throw new rn(nn);return t.facade=e,Qt(e,sn,t),t},nt=function(e){return $t(e,sn)?e[sn]:{}},rt=function(e){return $t(e,sn)}}var cn={set:tt,get:nt,has:rt,enforce:function(e){return rt(e)?nt(e):tt(e,{})},getterFor:function(e){return function(t){var n;if(!Xt(t)||(n=nt(t)).type!==e)throw new rn("Incompatible receiver, "+e+" required");return n}}},un=Y,ln=R,dn=D,hn=ge,fn=vc,pn=Dt.CONFIGURABLE,mn=je,vn=cn.enforce,_n=cn.get,gn=String,yn=Object.defineProperty,En=un("".slice),Tn=un("".replace),kn=un([].join),Sn=fn&&!ln((function(){return 8!==yn((function(){}),"length",{value:8}).length})),In=String(String).split("String"),bn=It.exports=function(e,t,n){"Symbol("===En(gn(t),0,7)&&(t="["+Tn(gn(t),/^Symbol\(([^)]*)\).*$/,"$1")+"]"),n&&n.getter&&(t="get "+t),n&&n.setter&&(t="set "+t),(!hn(e,"name")||pn&&e.name!==t)&&(fn?yn(e,"name",{value:t,configurable:!0}):e.name=t),Sn&&n&&hn(n,"arity")&&e.length!==n.arity&&yn(e,"length",{value:n.arity});try{n&&hn(n,"constructor")&&n.constructor?fn&&yn(e,"prototype",{writable:!1}):e.prototype&&(e.prototype=void 0)}catch(i){}var r=vn(e);return hn(r,"source")||(r.source=kn(In,"string"==typeof t?t:"")),e};Function.prototype.toString=bn((function(){return dn(this)&&_n(this).source||mn(this)}),"toString");var An=St,Rn=C,Cn=function(e,t,n){return n.get&&An(n.get,t,{getter:!0}),n.set&&An(n.set,t,{setter:!0}),Rn.f(e,t,n)},wn=G,Dn=function(){var e=wn(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},Nn=vc,xn=Cn,On=Dn,Pn=R,Mn=Af.RegExp,Ln=Mn.prototype,Un=Nn&&Pn((function(){var e=!0;try{Mn(".","d")}catch(s){e=!1}var t={},n="",r=e?"dgimsy":"gimsy",i=function(e,r){Object.defineProperty(t,e,{get:function(){return n+=r,!0}})},o={dotAll:"s",global:"g",ignoreCase:"i",multiline:"m",sticky:"y"};for(var a in e&&(o.hasIndices="d"),o)i(a,o[a]);return Object.getOwnPropertyDescriptor(Ln,"flags").get.call(t)!==r||n!==r}));Un&&xn(Ln,"flags",{configurable:!0,get:On});var Vn=D,Fn=C,Bn=St,jn=Oe,Hn=function(e,t,n,r){r||(r={});var i=r.enumerable,o=void 0!==r.name?r.name:t;if(Vn(n)&&Bn(n,o,r),r.global)i?e[t]=n:jn(t,n);else{try{r.unsafe?e[t]&&(i=!0):delete e[t]}catch(a){}i?e[t]=n:Fn.f(e,t,{value:n,enumerable:!1,configurable:!r.nonConfigurable,writable:!r.nonWritable})}return e},Gn=ki,Wn=Hn,Jn=th,zn=R,Kn=Mf,qn=Lt,Yn=Kn("species"),Xn=RegExp.prototype,Qn=function(e,t,n,r){var i=Kn(e),o=!zn((function(){var t={};return t[i]=function(){return 7},7!==""[e](t)})),a=o&&!zn((function(){var t=!1,n=/a/;return"split"===e&&((n={}).constructor={},n.constructor[Yn]=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===Jn||a===Xn.exec?o&&!i?{done:!0,value:Gn(s,t,n,r)}:{done:!0,value:Gn(e,n,t,r)}:{done:!1}}));Wn(String.prototype,e,c[0]),Wn(Xn,i,c[1])}r&&qn(Xn[i],"sham",!0)},$n=be,Zn=String,er=function(e){if("Symbol"===$n(e))throw new TypeError("Cannot convert a Symbol value to a string");return Zn(e)},tr=ce,nr=ue,rr=function(e,t){var n=e[t];return nr(n)?void 0:tr(n)},ir=Y,or=ct,ar=er,sr=he,cr=ir("".charAt),ur=ir("".charCodeAt),lr=ir("".slice),dr=function(e){return function(t,n){var r,i,o=ar(sr(t)),a=or(n),s=o.length;return a<0||a>=s?e?"":void 0:(r=ur(o,a))<55296||r>56319||a+1===s||(i=ur(o,a+1))<56320||i>57343?e?cr(o,a):r:e?lr(o,a,a+2):i-56320+(r-55296<<10)+65536}},hr={codeAt:dr(!1),charAt:dr(!0)},fr=hr.charAt,pr=function(e,t,n){return t+(n?fr(e,t).length:1)},mr=ki,vr=G,_r=D,gr=Jc,yr=th,Er=TypeError,Tr=function(e,t){var n=e.exec;if(_r(n)){var r=mr(n,e,t);return null!==r&&vr(r),r}if("RegExp"===gr(e))return mr(yr,e,t);throw new Er("RegExp#exec called on incompatible receiver")},kr=ki,Sr=G,Ir=ue,br=mt,Ar=er,Rr=he,Cr=rr,wr=pr,Dr=Tr;Qn("match",(function(e,t,n){return[function(t){var n=Rr(this),r=Ir(t)?void 0:Cr(t,e);return r?kr(r,t,n):new RegExp(t)[e](Ar(n))},function(e){var r=Sr(this),i=Ar(e),o=n(t,r,i);if(o.done)return o.value;if(!r.global)return Dr(r,i);var a=r.unicode;r.lastIndex=0;for(var s,c=[],u=0;null!==(s=Dr(r,i));){var l=Ar(s[0]);c[u]=l,""===l&&(r.lastIndex=wr(i,br(r.lastIndex),a)),u++}return 0===u?null:c}]}));var Nr,xr,Or=Af.navigator,Pr=Or&&Or.userAgent,Mr=Pr?String(Pr):"",Lr=Af,Ur=Mr,Vr=Lr.process,Fr=Lr.Deno,Br=Vr&&Vr.versions||Fr&&Fr.version,jr=Br&&Br.v8;jr&&(xr=(Nr=jr.split("."))[0]>0&&Nr[0]<4?1:+(Nr[0]+Nr[1])),!xr&&Ur&&(!(Nr=Ur.match(/Edge\/(\d+)/))||Nr[1]>=74)&&(Nr=Ur.match(/Chrome\/(\d+)/))&&(xr=+Nr[1]);var Hr=xr,Gr=R,Wr=Hr,Jr=Mf("species"),zr=function(e){return Wr>=51||!Gr((function(){var t=[];return(t.constructor={})[Jr]=function(){return{foo:1}},1!==t[e](Boolean).foo}))},Kr=Sf,qr=Kc,Yr=et,Xr=x,Qr=ht,$r=_t,Zr=Uh,ei=kt,ti=Mf,ni=si,ri=zr("slice"),ii=ti("species"),oi=Array,ai=Math.max;Kr({target:"Array",proto:!0,forced:!ri},{slice:function(e,t){var n,r,i,o=Zr(this),a=$r(o),s=Qr(e,a),c=Qr(void 0===t?a:t,a);if(qr(o)&&(n=o.constructor,(Yr(n)&&(n===oi||qr(n.prototype))||Xr(n)&&null===(n=n[ii]))&&(n=void 0),n===oi||void 0===n))return ni(o,s,c);for(r=new(void 0===n?oi:n)(ai(c-s,0)),i=0;s<c;s++,i++)s in o&&ei(r,i,o[s]);return r.length=i,r}});var si=Y([].slice),ci=Y,ui=ce,li=x,di=ge,hi=si,fi=W,pi=Function,mi=ci([].concat),vi=ci([].join),_i={},gi=fi?pi.bind:function(e){var t=ui(this),n=t.prototype,r=hi(arguments,1),i=function(){var n=mi(r,hi(arguments));return this instanceof i?function(e,t,n){if(!di(_i,t)){for(var r=[],i=0;i<t;i++)r[i]="a["+i+"]";_i[t]=pi("C,a","return new C("+vi(r,",")+")")}return _i[t](e,n)}(t,n.length,n):t.apply(e,n)};return li(n)&&(i.prototype=n),i},yi=gi;Sf({target:"Function",proto:!0,forced:Function.bind!==yi},{bind:yi});var Ei=W,Ti=Function.prototype.call,ki=Ei?Ti.bind(Ti):function(){return Ti.apply(Ti,arguments)},Si=Y({}.isPrototypeOf),Ii=Af,bi={},Ai=Mf;bi.f=Ai;var Ri=Ii,Ci=ge,wi=bi,Di=C.f,Ni=function(e){var t=Ri.Symbol||(Ri.Symbol={});Ci(t,e)||Di(t,e,{value:wi.f(e)})};Ni("iterator"),Sf({target:"Object",stat:!0,sham:!vc},{create:wo});var xi=Sf,Oi=vc,Pi=Mi.f;xi({target:"Object",stat:!0,forced:Object.defineProperties!==Pi,sham:!Oi},{defineProperties:Pi});var Mi={},Li=me,Ui=ao;Sf({target:"Object",stat:!0,forced:R((function(){Ui(1)}))},{keys:function(e){return Ui(Li(e))}});var Vi=Jc,Fi=Y,Bi=function(e){if("Function"===Vi(e))return Fi(e)},ji=Uh,Hi=ht,Gi=_t,Wi=function(e){return function(t,n,r){var i=ji(t),o=Gi(i);if(0===o)return!e&&-1;var a,s=Hi(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}},Ji={includes:Wi(!0),indexOf:Wi(!1)},zi=Sf,Ki=Ji.indexOf,qi=Q,Yi=Bi([].indexOf),Xi=!!Yi&&1/Yi([1],1,-0)<0;zi({target:"Array",proto:!0,forced:Xi||!qi("indexOf")},{indexOf:function(e){var t=arguments.length>1?arguments[1]:void 0;return Xi?Yi(this,e,t)||0:Ki(this,e,t)}});var Qi=ge,$i=Uh,Zi=Ji.indexOf,eo=Kt,to=Y([].push),no=function(e,t){var n,r=$i(e),i=0,o=[];for(n in r)!Qi(eo,n)&&Qi(r,n)&&to(o,n);for(;t.length>i;)Qi(r,n=t[i++])&&(~Zi(o,n)||to(o,n));return o},ro=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"],io=no,oo=ro,ao=Object.keys||function(e){return io(e,oo)},so=vc,co=F,uo=C,lo=G,ho=Uh,fo=ao;Mi.f=so&&!co?Object.defineProperties:function(e,t){lo(e);for(var n,r=ho(t),i=fo(t),o=i.length,a=0;o>a;)uo.f(e,n=i[a++],r[n]);return e};var po,mo=Ce("document","documentElement"),vo=G,_o=Mi,go=ro,yo=Kt,Eo=mo,To=L,ko="prototype",So="script",Io=zt("IE_PROTO"),bo=function(){},Ao=function(e){return"<"+So+">"+e+"</"+So+">"},Ro=function(e){e.write(Ao("")),e.close();var t=e.parentWindow.Object;return e=null,t},Co=function(){try{po=new ActiveXObject("htmlfile")}catch(i){}var e,t,n;Co="undefined"!=typeof document?document.domain&&po?Ro(po):(t=To("iframe"),n="java"+So+":",t.style.display="none",Eo.appendChild(t),t.src=String(n),(e=t.contentWindow.document).open(),e.write(Ao("document.F=Object")),e.close(),e.F):Ro(po);for(var r=go.length;r--;)delete Co[ko][go[r]];return Co()};yo[Io]=!0;var wo=Object.create||function(e,t){var n;return null!==e?(bo[ko]=vo(e),n=new bo,bo[ko]=null,n[Io]=e):n=Co(),void 0===t?n:_o.f(n,t)},Do=Mf,No=wo,xo=C.f,Oo=Do("unscopables"),Po=Array.prototype;void 0===Po[Oo]&&xo(Po,Oo,{configurable:!0,value:No(null)});var Mo=function(e){Po[Oo][e]=!0},Lo={},Uo={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},Vo=L("span").classList,Fo=Vo&&Vo.constructor&&Vo.constructor.prototype,Bo=Fo===Object.prototype?void 0:Fo,jo=C.f,Ho=ge,Go=Mf("toStringTag"),Wo=function(e,t,n){e&&!n&&(e=e.prototype),e&&!Ho(e,Go)&&jo(e,Go,{configurable:!0,value:t})},Jo=Af,zo=Uo,Ko=Bo,qo=Ts,Yo=Lt,Xo=Wo,Qo=Mf("iterator"),$o=qo.values,Zo=function(e,t){if(e){if(e[Qo]!==$o)try{Yo(e,Qo,$o)}catch(r){e[Qo]=$o}if(Xo(e,t,!0),zo[t])for(var n in qo)if(e[n]!==qo[n])try{Yo(e,n,qo[n])}catch(r){e[n]=qo[n]}}};for(var ea in zo)Zo(Jo[ea]&&Jo[ea].prototype,ea);Zo(Ko,"DOMTokenList");var ta=!R((function(){function e(){}return e.prototype.constructor=null,Object.getPrototypeOf(new e)!==e.prototype})),na=me,ra=ma,ia=ta;Sf({target:"Object",stat:!0,forced:R((function(){ra(1)})),sham:!ia},{getPrototypeOf:function(e){return ra(na(e))}});var oa,aa,sa,ca=ge,ua=D,la=me,da=ta,ha=zt("IE_PROTO"),fa=Object,pa=fa.prototype,ma=da?fa.getPrototypeOf:function(e){var t=la(e);if(ca(t,ha))return t[ha];var n=t.constructor;return ua(n)&&t instanceof n?n.prototype:t instanceof fa?pa:null},va=R,_a=D,ga=x,ya=ma,Ea=Hn,Ta=Mf("iterator"),ka=!1;[].keys&&("next"in(sa=[].keys())?(aa=ya(ya(sa)))!==Object.prototype&&(oa=aa):ka=!0);var Sa=!ga(oa)||va((function(){var e={};return oa[Ta].call(e)!==e}));Sa&&(oa={}),_a(oa[Ta])||Ea(oa,Ta,(function(){return this}));var Ia={IteratorPrototype:oa,BUGGY_SAFARI_ITERATORS:ka},ba=Ia.IteratorPrototype,Aa=wo,Ra=gt,Ca=Wo,wa=Lo,Da=function(){return this},Na=function(e,t,n,r){var i=t+" Iterator";return e.prototype=Aa(ba,{next:Ra(+!r,n)}),Ca(e,i,!1),wa[i]=Da,e};Sf({target:"Object",stat:!0},{setPrototypeOf:Ha});var xa=Y,Oa=ce,Pa=x,Ma=function(e){return Pa(e)||null===e},La=String,Ua=TypeError,Va=function(e,t,n){try{return xa(Oa(Object.getOwnPropertyDescriptor(e,t)[n]))}catch(r){}},Fa=x,Ba=he,ja=function(e){if(Ma(e))return e;throw new Ua("Can't set "+La(e)+" as a prototype")},Ha=Object.setPrototypeOf||("__proto__"in{}?function(){var e,t=!1,n={};try{(e=Va(Object.prototype,"__proto__","set"))(n,[]),t=n instanceof Array}catch(r){}return function(n,r){return Ba(n),ja(r),Fa(n)?(t?e(n,r):n.__proto__=r,n):n}}():void 0),Ga=Sf,Wa=ki,Ja=D,za=Na,Ka=ma,qa=Ha,Ya=Wo,Xa=Lt,Qa=Hn,$a=Lo,Za=Dt.PROPER,es=Dt.CONFIGURABLE,ts=Ia.IteratorPrototype,ns=Ia.BUGGY_SAFARI_ITERATORS,rs=Mf("iterator"),is="keys",os="values",as="entries",ss=function(){return this},cs=function(e,t,n,r,i,o,a){za(n,t,r);var s,c,u,l=function(e){if(e===i&&m)return m;if(!ns&&e&&e in f)return f[e];switch(e){case is:case os:case as:return function(){return new n(this,e)}}return function(){return new n(this)}},d=t+" Iterator",h=!1,f=e.prototype,p=f[rs]||f["@@iterator"]||i&&f[i],m=!ns&&p||l(i),v="Array"===t&&f.entries||p;if(v&&(s=Ka(v.call(new e)))!==Object.prototype&&s.next&&(Ka(s)!==ts&&(qa?qa(s,ts):Ja(s[rs])||Qa(s,rs,ss)),Ya(s,d,!0)),Za&&i===os&&p&&p.name!==os&&(es?Xa(f,"name",os):(h=!0,m=function(){return Wa(p,this)})),i)if(c={values:l(os),keys:o?m:l(is),entries:l(as)},a)for(u in c)(ns||h||!(u in f))&&Qa(f,u,c[u]);else Ga({target:t,proto:!0,forced:ns||h},c);return f[rs]!==m&&Qa(f,rs,m,{name:i}),$a[t]=m,c},us=function(e,t){return{value:e,done:t}},ls=Uh,ds=Mo,hs=Lo,fs=cn,ps=C.f,ms=cs,vs=us,_s=vc,gs="Array Iterator",ys=fs.set,Es=fs.getterFor(gs),Ts=ms(Array,"Array",(function(e,t){ys(this,{type:gs,target:ls(e),index:0,kind:t})}),(function(){var e=Es(this),t=e.target,n=e.index++;if(!t||n>=t.length)return e.target=null,vs(void 0,!0);switch(e.kind){case"keys":return vs(n,!1);case"values":return vs(t[n],!1)}return vs([n,t[n]],!1)}),"values"),ks=hs.Arguments=hs.Array;if(ds("keys"),ds("values"),ds("entries"),_s&&"values"!==ks.name)try{ps(ks,"name",{value:"values"})}catch(PF){}var Ss=hr.charAt,Is=er,bs=cn,As=cs,Rs=us,Cs="String Iterator",ws=bs.set,Ds=bs.getterFor(Cs);As(String,"String",(function(e){ws(this,{type:Cs,string:Is(e),index:0})}),(function(){var e,t=Ds(this),n=t.string,r=t.index;return r>=n.length?Rs(void 0,!0):(e=Ss(n,r),t.index+=e.length,Rs(e,!1))}));var Ns=Hr,xs=R,Os=Af.String,Ps=!!Object.getOwnPropertySymbols&&!xs((function(){var e=Symbol("symbol detection");return!Os(e)||!(Object(e)instanceof Symbol)||!Symbol.sham&&Ns&&Ns<41})),Ms=Ps&&!Symbol.sham&&"symbol"==k(Symbol.iterator),Ls=Ce,Us=D,Vs=Si,Fs=Object,Bs=Ms?function(e){return"symbol"==k(e)}:function(e){var t=Ls("Symbol");return Us(t)&&Vs(t.prototype,Fs(e))},js=ki,Hs=D,Gs=x,Ws=TypeError,Js=ki,zs=x,Ks=Bs,qs=rr,Ys=function(e,t){var n,r;if("string"===t&&Hs(n=e.toString)&&!Gs(r=js(n,e)))return r;if(Hs(n=e.valueOf)&&!Gs(r=js(n,e)))return r;if("string"!==t&&Hs(n=e.toString)&&!Gs(r=js(n,e)))return r;throw new Ws("Can't convert object to primitive value")},Xs=TypeError,Qs=Mf("toPrimitive"),$s=function(e,t){if(!zs(e)||Ks(e))return e;var n,r=qs(e,Qs);if(r){if(void 0===t&&(t="default"),n=Js(r,e,t),!zs(n)||Ks(n))return n;throw new Xs("Can't convert object to primitive value")}return void 0===t&&(t="number"),Ys(e,t)},Zs=$s,ec=Bs,tc=function(e){var t=Zs(e,"string");return ec(t)?t:t+""},nc=vc,rc=V,ic=F,oc=G,ac=tc,sc=TypeError,cc=Object.defineProperty,uc=Object.getOwnPropertyDescriptor,lc="enumerable",dc="configurable",hc="writable";C.f=nc?ic?function(e,t,n){if(oc(e),t=ac(t),oc(n),"function"==typeof e&&"prototype"===t&&"value"in n&&hc in n&&!n[hc]){var r=uc(e,t);r&&r[hc]&&(e[t]=n.value,n={configurable:dc in n?n[dc]:r[dc],enumerable:lc in n?n[lc]:r[lc],writable:!1})}return cc(e,t,n)}:cc:function(e,t,n){if(oc(e),t=ac(t),oc(n),rc)try{return cc(e,t,n)}catch(PF){}if("get"in n||"set"in n)throw new sc("Accessors not supported");return"value"in n&&(e[t]=n.value),e};var fc=Sf,pc=vc,mc=C.f;fc({target:"Object",stat:!0,forced:Object.defineProperty!==mc,sham:!pc},{defineProperty:mc});var vc=!R((function(){return 7!==Object.defineProperty({},1,{get:function(){return 7}})[1]})),_c=vc,gc=Dt.EXISTS,yc=Y,Ec=Cn,Tc=Function.prototype,kc=yc(Tc.toString),Sc=/function\b(?:\s|\/\*[\S\s]*?\*\/|\/\/[^\n\r]*[\n\r]+)*([^\s(/]*)/,Ic=yc(Sc.exec);_c&&!gc&&Ec(Tc,"name",{configurable:!0,get:function(){try{return Ic(Sc,kc(this))[1]}catch(PF){return""}}});var bc=ki,Ac=ge,Rc=Si,Cc=Dn,wc=RegExp.prototype,Dc=function(e){var t=e.flags;return void 0!==t||"flags"in wc||Ac(e,"flags")||!Rc(wc,e)?t:bc(Cc,e)},Nc=Dt.PROPER,xc=Hn,Oc=G,Pc=er,Mc=R,Lc=Dc,Uc="toString",Vc=RegExp.prototype,Fc=Vc[Uc],Bc=Mc((function(){return"/a/b"!==Fc.call({source:"a",flags:"b"})})),jc=Nc&&Fc.name!==Uc;(Bc||jc)&&xc(Vc,Uc,(function(){var e=Oc(this);return"/"+Pc(e.source)+"/"+Pc(Lc(e))}),{unsafe:!0});var Hc=Y,Gc=Hc({}.toString),Wc=Hc("".slice),Jc=function(e){return Wc(Gc(e),8,-1)},zc=Jc,Kc=Array.isArray||function(e){return"Array"===zc(e)},qc=TypeError,Yc=function(e){if(e>9007199254740991)throw qc("Maximum allowed index exceeded");return e},Xc=Kc,Qc=et,$c=x,Zc=Mf("species"),eu=Array,tu=function(e){var t;return Xc(e)&&(t=e.constructor,(Qc(t)&&(t===eu||Xc(t.prototype))||$c(t)&&null===(t=t[Zc]))&&(t=void 0)),void 0===t?eu:t},nu=function(e,t){return new(tu(e))(0===t?0:t)},ru=Sf,iu=R,ou=Kc,au=x,su=me,cu=_t,uu=Yc,lu=kt,du=nu,hu=zr,fu=Hr,pu=Mf("isConcatSpreadable"),mu=fu>=51||!iu((function(){var e=[];return e[pu]=!1,e.concat()[0]!==e})),vu=function(e){if(!au(e))return!1;var t=e[pu];return void 0!==t?!!t:ou(e)};ru({target:"Array",proto:!0,arity:1,forced:!mu||!hu("concat")},{concat:function(e){var t,n,r,i,o,a=su(this),s=du(a,0),c=0;for(t=-1,r=arguments.length;t<r;t++)if(vu(o=-1===t?a:arguments[t]))for(i=cu(o),uu(c+i),n=0;n<i;n++,c++)n in o&&lu(s,c,o[n]);else uu(c+1),lu(s,c++,o);return s.length=c,s}});var _u=Iu,gu=ce,yu=G;Sf({target:"Reflect",stat:!0,forced:!R((function(){Reflect.apply((function(){}))}))},{apply:function(e,t,n){return _u(gu(e),t,yu(n))}});var Eu=W,Tu=Function.prototype,ku=Tu.apply,Su=Tu.call,Iu="object"==("undefined"==typeof Reflect?"undefined":k(Reflect))&&Reflect.apply||(Eu?Su.bind(ku):function(){return Su.apply(ku,arguments)}),bu=Y,Au=me,Ru=Math.floor,Cu=bu("".charAt),wu=bu("".replace),Du=bu("".slice),Nu=/\$([$&'`]|\d{1,2}|<[^>]*>)/g,xu=/\$([$&'`]|\d{1,2})/g,Ou=Iu,Pu=ki,Mu=Y,Lu=Qn,Uu=R,Vu=G,Fu=D,Bu=ue,ju=ct,Hu=mt,Gu=er,Wu=he,Ju=pr,zu=rr,Ku=function(e,t,n,r,i,o){var a=n+e.length,s=r.length,c=xu;return void 0!==i&&(i=Au(i),c=Nu),wu(o,c,(function(o,c){var u;switch(Cu(c,0)){case"$":return"$";case"&":return e;case"`":return Du(t,0,n);case"'":return Du(t,a);case"<":u=i[Du(c,1,-1)];break;default:var l=+c;if(0===l)return o;if(l>s){var d=Ru(l/10);return 0===d?o:d<=s?void 0===r[d-1]?Cu(c,1):r[d-1]+Cu(c,1):o}u=r[l-1]}return void 0===u?"":u}))},qu=Tr,Yu=Mf("replace"),Xu=Math.max,Qu=Math.min,$u=Mu([].concat),Zu=Mu([].push),el=Mu("".indexOf),tl=Mu("".slice),nl="$0"==="a".replace(/./,"$0"),rl=!!/./[Yu]&&""===/./[Yu]("a","$0");Lu("replace",(function(e,t,n){var r=rl?"$":"$0";return[function(e,n){var r=Wu(this),i=Bu(e)?void 0:zu(e,Yu);return i?Pu(i,e,r,n):Pu(t,Gu(r),e,n)},function(e,i){var o=Vu(this),a=Gu(e);if("string"==typeof i&&-1===el(i,r)&&-1===el(i,"$<")){var s=n(t,o,a,i);if(s.done)return s.value}var c=Fu(i);c||(i=Gu(i));var u,l=o.global;l&&(u=o.unicode,o.lastIndex=0);for(var d,h=[];null!==(d=qu(o,a))&&(Zu(h,d),l);){""===Gu(d[0])&&(o.lastIndex=Ju(a,Hu(o.lastIndex),u))}for(var f,p="",m=0,v=0;v<h.length;v++){for(var _,g=Gu((d=h[v])[0]),y=Xu(Qu(ju(d.index),a.length),0),E=[],T=1;T<d.length;T++)Zu(E,void 0===(f=d[T])?f:String(f));var k=d.groups;if(c){var S=$u([g],E,y,a);void 0!==k&&Zu(S,k),_=Gu(Ou(i,void 0,S))}else _=Ku(g,a,y,E,k,i);y>=m&&(p+=tl(a,m,y)+_,m=y+g.length)}return p+tl(a,m)}]}),!!Uu((function(){var e=/./;return e.exec=function(){var e=[];return e.groups={a:"7"},e},"7"!=="".replace(e,"$<a>")}))||!nl||rl);var il=R,ol=D,al=/#|\.prototype\./,sl=function(e,t){var n=ul[cl(e)];return n===dl||n!==ll&&(ol(t)?il(t):!!t)},cl=sl.normalize=function(e){return String(e).replace(al,".").toLowerCase()},ul=sl.data={},ll=sl.NATIVE="N",dl=sl.POLYFILL="P",hl=sl,fl=D,pl=x,ml=Ha,vl=function(e,t,n){var r,i;return ml&&fl(r=t.constructor)&&r!==n&&pl(i=r.prototype)&&i!==n.prototype&&ml(e,i),e},_l={},gl=Jc,yl=Uh,El=Al.f,Tl=si,kl="object"==("undefined"==typeof window?"undefined":k(window))&&window&&Object.getOwnPropertyNames?Object.getOwnPropertyNames(window):[];_l.f=function(e){return kl&&"Window"===gl(e)?function(e){try{return El(e)}catch(PF){return Tl(kl)}}(e):El(yl(e))};var Sl=Sf,Il=R,bl=_l.f;Sl({target:"Object",stat:!0,forced:Il((function(){return!Object.getOwnPropertyNames(1)}))},{getOwnPropertyNames:bl});var Al={},Rl=no,Cl=ro.concat("length","prototype");Al.f=Object.getOwnPropertyNames||function(e){return Rl(e,Cl)};var wl=x,Dl=Jc,Nl=Mf("match"),xl=function(e){var t;return wl(e)&&(void 0!==(t=e[Nl])?!!t:"RegExp"===Dl(e))},Ol=R,Pl=Af.RegExp,Ml=Ol((function(){var e=Pl("a","y");return e.lastIndex=2,null!==e.exec("abcd")})),Ll=Ml||Ol((function(){return!Pl("a","y").sticky})),Ul={BROKEN_CARET:Ml||Ol((function(){var e=Pl("^r","gy");return e.lastIndex=2,null!==e.exec("str")})),MISSED_STICKY:Ll,UNSUPPORTED_Y:Ml},Vl=C.f,Fl=Ce,Bl=Cn,jl=vc,Hl=Mf("species"),Gl=function(e){var t=Fl(e);jl&&t&&!t[Hl]&&Bl(t,Hl,{configurable:!0,get:function(){return this}})},Wl=R,Jl=Af.RegExp,zl=Wl((function(){var e=Jl(".","s");return!(e.dotAll&&e.test("\n")&&"s"===e.flags)})),Kl=R,ql=Af.RegExp,Yl=Kl((function(){var e=ql("(?<a>b)","g");return"b"!==e.exec("b").groups.a||"bc"!=="b".replace(e,"$<a>c")})),Xl=vc,Ql=Af,$l=Y,Zl=hl,ed=vl,td=Lt,nd=wo,rd=Al.f,id=Si,od=xl,ad=er,sd=Dc,cd=Ul,ud=function(e,t,n){n in e||Vl(e,n,{configurable:!0,get:function(){return t[n]},set:function(e){t[n]=e}})},ld=Hn,dd=R,hd=ge,fd=cn.enforce,pd=Gl,md=zl,vd=Yl,_d=Mf("match"),gd=Ql.RegExp,yd=gd.prototype,Ed=Ql.SyntaxError,Td=$l(yd.exec),kd=$l("".charAt),Sd=$l("".replace),Id=$l("".indexOf),bd=$l("".slice),Ad=/^\?<[^\s\d!#%&*+<=>@^][^\s!#%&*+<=>@^]*>/,Rd=/a/g,Cd=/a/g,wd=new gd(Rd)!==Rd,Dd=cd.MISSED_STICKY,Nd=cd.UNSUPPORTED_Y,xd=Xl&&(!wd||Dd||md||vd||dd((function(){return Cd[_d]=!1,gd(Rd)!==Rd||gd(Cd)===Cd||"/a/i"!==String(gd(Rd,"i"))})));if(Zl("RegExp",xd)){for(var Od=function(e,t){var n,r,i,o,a,s,c=id(yd,this),u=od(e),l=void 0===t,d=[],h=e;if(!c&&u&&l&&e.constructor===Od)return e;if((u||id(yd,e))&&(e=e.source,l&&(t=sd(h))),e=void 0===e?"":ad(e),t=void 0===t?"":ad(t),h=e,md&&"dotAll"in Rd&&(r=!!t&&Id(t,"s")>-1)&&(t=Sd(t,/s/g,"")),n=t,Dd&&"sticky"in Rd&&(i=!!t&&Id(t,"y")>-1)&&Nd&&(t=Sd(t,/y/g,"")),vd&&(o=function(e){for(var t,n=e.length,r=0,i="",o=[],a=nd(null),s=!1,c=!1,u=0,l="";r<=n;r++){if("\\"===(t=kd(e,r)))t+=kd(e,++r);else if("]"===t)s=!1;else if(!s)switch(!0){case"["===t:s=!0;break;case"("===t:if(i+=t,"?:"===bd(e,r+1,r+3))continue;Td(Ad,bd(e,r+1))&&(r+=2,c=!0),u++;continue;case">"===t&&c:if(""===l||hd(a,l))throw new Ed("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=ed(gd(e,t),c?this:yd,Od),(r||i||d.length)&&(s=fd(a),r&&(s.dotAll=!0,s.raw=Od(function(e){for(var t,n=e.length,r=0,i="",o=!1;r<=n;r++)"\\"!==(t=kd(e,r))?o||"."!==t?("["===t?o=!0:"]"===t&&(o=!1),i+=t):i+="[\\s\\S]":i+=t+kd(e,++r);return i}(e),n)),i&&(s.sticky=!0),d.length&&(s.groups=d)),e!==h)try{td(a,"source",""===h?"(?:)":h)}catch(PF){}return a},Pd=rd(gd),Md=0;Pd.length>Md;)ud(Od,gd,Pd[Md++]);yd.constructor=Od,Od.prototype=yd,ld(Ql,"RegExp",Od,{constructor:!0})}pd("RegExp");var Ld=ki,Ud=Y,Vd=er,Fd=Dn,Bd=Ul,jd=wo,Hd=cn.get,Gd=zl,Wd=Yl,Jd=Vt("native-string-replace",String.prototype.replace),zd=RegExp.prototype.exec,Kd=zd,qd=Ud("".charAt),Yd=Ud("".indexOf),Xd=Ud("".replace),Qd=Ud("".slice),$d=function(){var e=/a/,t=/b*/g;return Ld(zd,e,"a"),Ld(zd,t,"a"),0!==e.lastIndex||0!==t.lastIndex}(),Zd=Bd.BROKEN_CARET,eh=void 0!==/()??/.exec("")[1];($d||eh||Zd||Gd||Wd)&&(Kd=function(e){var t,n,r,i,o,a,s,c=this,u=Hd(c),l=Vd(e),d=u.raw;if(d)return d.lastIndex=c.lastIndex,t=Ld(Kd,d,l),c.lastIndex=d.lastIndex,t;var h=u.groups,f=Zd&&c.sticky,p=Ld(Fd,c),m=c.source,v=0,_=l;if(f&&(p=Xd(p,"y",""),-1===Yd(p,"g")&&(p+="g"),_=Qd(l,c.lastIndex),c.lastIndex>0&&(!c.multiline||c.multiline&&"\n"!==qd(l,c.lastIndex-1))&&(m="(?: "+m+")",_=" "+_,v++),n=new RegExp("^(?:"+m+")",p)),eh&&(n=new RegExp("^"+m+"$(?!\\s)",p)),$d&&(r=c.lastIndex),i=Ld(zd,f?n:c,_),f?i?(i.input=Qd(i.input,v),i[0]=Qd(i[0],v),i.index=c.lastIndex,c.lastIndex+=i[0].length):c.lastIndex=0:$d&&i&&(c.lastIndex=c.global?i.index+i[0].length:r),eh&&i&&i.length>1&&Ld(Jd,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=jd(null),o=0;o<h.length;o++)a[(s=h[o])[0]]=i[s[1]];return i});var th=Kd;Sf({target:"RegExp",proto:!0,forced:/./.exec!==th},{exec:th});var nh=et,rh=ie,ih=TypeError,oh=function(e){if(nh(e))return e;throw new ih(rh(e)+" is not a constructor")},ah=G,sh=oh,ch=ue,uh=Mf("species"),lh=function(e,t){var n,r=ah(e).constructor;return void 0===r||ch(n=ah(r)[uh])?t:sh(n)},dh=ki,hh=Y,fh=Qn,ph=G,mh=ue,vh=he,_h=lh,gh=pr,yh=mt,Eh=er,Th=rr,kh=Tr,Sh=R,Ih=Ul.UNSUPPORTED_Y,bh=Math.min,Ah=hh([].push),Rh=hh("".slice),Ch=!Sh((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]})),wh="c"==="abbc".split(/(b)*/)[1]||4!=="test".split(/(?:)/,-1).length||2!=="ab".split(/(?:ab)*/).length||4!==".".split(/(.?)(.?)/).length||".".split(/()()/).length>1||"".split(/.?/).length;fh("split",(function(e,t,n){var r="0".split(void 0,0).length?function(e,n){return void 0===e&&0===n?[]:dh(t,this,e,n)}:t;return[function(t,n){var i=vh(this),o=mh(t)?void 0:Th(t,e);return o?dh(o,t,i,n):dh(r,Eh(i),t,n)},function(e,i){var o=ph(this),a=Eh(e);if(!wh){var s=n(r,o,a,i,r!==t);if(s.done)return s.value}var c=_h(o,RegExp),u=o.unicode,l=(o.ignoreCase?"i":"")+(o.multiline?"m":"")+(o.unicode?"u":"")+(Ih?"g":"y"),d=new c(Ih?"^(?:"+o.source+")":o,l),h=void 0===i?4294967295:i>>>0;if(0===h)return[];if(0===a.length)return null===kh(d,a)?[a]:[];for(var f=0,p=0,m=[];p<a.length;){d.lastIndex=Ih?0:p;var v,_=kh(d,Ih?Rh(a,p):a);if(null===_||(v=bh(yh(d.lastIndex+(Ih?p:0)),a.length))===f)p=gh(a,p,u);else{if(Ah(m,Rh(a,f,p)),m.length===h)return m;for(var g=1;g<=_.length-1;g++)if(Ah(m,_[g]),m.length===h)return m;p=f=v}}return Ah(m,Rh(a,f)),m}]}),wh||!Ch,Ih);var Dh=R,Nh=Jc,xh=Object,Oh=Y("".split),Ph=Dh((function(){return!xh("z").propertyIsEnumerable(0)}))?function(e){return"String"===Nh(e)?Oh(e,""):xh(e)}:xh,Mh=Ph,Lh=he,Uh=function(e){return Mh(Lh(e))},Vh=Sf,Fh=R,Bh=Uh,jh=Gh.f,Hh=vc;Vh({target:"Object",stat:!0,forced:!Hh||Fh((function(){jh(1)})),sham:!Hh},{getOwnPropertyDescriptor:function(e,t){return jh(Bh(e),t)}});var Gh={},Wh={},Jh={}.propertyIsEnumerable,zh=Object.getOwnPropertyDescriptor,Kh=zh&&!Jh.call({1:2},1);Wh.f=Kh?function(e){var t=zh(this,e);return!!t&&t.enumerable}:Jh;var qh=vc,Yh=ki,Xh=Wh,Qh=gt,$h=Uh,Zh=tc,ef=ge,tf=V,nf=Object.getOwnPropertyDescriptor;Gh.f=qh?nf:function(e,t){if(e=$h(e),t=Zh(t),tf)try{return nf(e,t)}catch(PF){}if(ef(e,t))return Qh(!Yh(Xh.f,e,t),e[t])};var rf={};rf.f=Object.getOwnPropertySymbols;var of=Ce,af=Al,sf=rf,cf=G,uf=Y([].concat),lf=of("Reflect","ownKeys")||function(e){var t=af.f(cf(e)),n=sf.f;return n?uf(t,n(e)):t},df=ge,hf=lf,ff=Gh,pf=C,mf=function(e,t,n){for(var r=hf(t),i=pf.f,o=ff.f,a=0;a<r.length;a++){var s=r[a];df(e,s)||n&&df(n,s)||i(e,s,o(t,s))}},vf=Af,_f=Gh.f,gf=Lt,yf=Hn,Ef=Oe,Tf=mf,kf=hl,Sf=function(e,t){var n,r,i,o,a,s=e.target,c=e.global,u=e.stat;if(n=c?vf:u?vf[s]||Ef(s,{}):vf[s]&&vf[s].prototype)for(r in t){if(o=t[r],i=e.dontCallGetSet?(a=_f(n,r))&&a.value:n[r],!kf(c?r:s+(u?".":"#")+r,e.forced)&&void 0!==i){if(k(o)==k(i))continue;Tf(o,i)}(e.sham||i&&i.sham)&&gf(o,"sham",!0),yf(n,r,o,e)}},If=Af;Sf({global:!0,forced:If.globalThis!==If},{globalThis:If});var bf=function(e){return e&&e.Math===Math&&e},Af=bf("object"==("undefined"==typeof globalThis?"undefined":k(globalThis))&&globalThis)||bf("object"==("undefined"==typeof window?"undefined":k(window))&&window)||bf("object"==("undefined"==typeof self?"undefined":k(self))&&self)||bf("object"==k(b)&&b)||bf("object"==k(b)&&b)||function(){return this}()||Function("return this")(),Rf=Vt,Cf=ge,wf=Gt,Df=Ps,Nf=Ms,xf=Af.Symbol,Of=Rf("wks"),Pf=Nf?xf.for||xf:xf&&xf.withoutSetter||wf,Mf=function(e){return Cf(Of,e)||(Of[e]=Df&&Cf(xf,e)?xf[e]:Pf("Symbol."+e)),Of[e]},Lf={};Lf[Mf("toStringTag")]="z";var Uf="[object z]"===String(Lf),Vf=be,Ff=Uf?{}.toString:function(){return"[object "+Vf(this)+"]"};Uf||Hn(Object.prototype,"toString",Ff,{unsafe:!0});var Bf=Y,jf=Hn,Hf=Date.prototype,Gf="Invalid Date",Wf="toString",Jf=Bf(Hf[Wf]),zf=Bf(Hf.getTime);String(new Date(NaN))!==Gf&&jf(Hf,Wf,(function(){var e=zf(this);return e==e?Jf(this):Gf}));var Kf=Sf,qf=vc,Yf=Y,Xf=ge,Qf=D,$f=Si,Zf=er,ep=Cn,tp=mf,np=Af.Symbol,rp=np&&np.prototype;if(qf&&Qf(np)&&(!("description"in rp)||void 0!==np().description)){var ip={},op=function(){var e=arguments.length<1||void 0===arguments[0]?void 0:Zf(arguments[0]),t=$f(rp,this)?new np(e):void 0===e?np():np(e);return""===e&&(ip[t]=!0),t};tp(op,np),op.prototype=rp,rp.constructor=op;var ap="Symbol(description detection)"===String(np("description detection")),sp=Yf(rp.valueOf),cp=Yf(rp.toString),up=/^Symbol\((.*)\)[^)]+$/,lp=Yf("".replace),dp=Yf("".slice);ep(rp,"description",{configurable:!0,get:function(){var e=sp(this);if(Xf(ip,e))return"";var t=cp(e),n=ap?dp(t,7,-1):lp(t,up,"$1");return""===n?void 0:n}}),Kf({global:!0,constructor:!0,forced:!0},{Symbol:op})}var hp=Af,fp=Uo,pp=Bo,mp=xp,vp=Lt,_p=function(e){if(e&&e.forEach!==mp)try{vp(e,"forEach",mp)}catch(PF){e.forEach=mp}};for(var gp in fp)fp[gp]&&_p(hp[gp]&&hp[gp].prototype);_p(pp);var yp=ce,Ep=W,Tp=Bi(Bi.bind),kp=function(e,t){return yp(e),void 0===t?e:Ep?Tp(e,t):function(){return e.apply(t,arguments)}},Sp=kp,Ip=Ph,bp=me,Ap=_t,Rp=nu,Cp=Y([].push),wp=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=bp(c),m=Ip(p),v=Ap(m),_=Sp(u,l),g=0,y=d||Rp,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:Cp(E,h)}else switch(e){case 4:return!1;case 7:Cp(E,h)}return o?-1:r||i?i:E}},Dp={forEach:wp(0),map:wp(1),filter:wp(2),some:wp(3),every:wp(4),find:wp(5),findIndex:wp(6),filterReject:wp(7)},Np=Dp.forEach,xp=Q("forEach")?[].forEach:function(e){return Np(this,e,arguments.length>1?arguments[1]:void 0)};Sf({target:"Array",proto:!0,forced:[].forEach!==xp},{forEach:xp});var Op=ki,Pp=Ce,Mp=Mf,Lp=Hn,Up=Sf,Vp=Af,Fp=ki,Bp=Y,jp=vc,Hp=Ps,Gp=R,Wp=ge,Jp=Si,zp=G,Kp=Uh,qp=tc,Yp=er,Xp=gt,Qp=wo,$p=ao,Zp=Al,em=_l,tm=rf,nm=Gh,rm=C,im=Mi,om=Wh,am=Hn,sm=Cn,cm=Vt,um=Kt,lm=Gt,dm=Mf,hm=bi,fm=Ni,pm=function(){var e=Pp("Symbol"),t=e&&e.prototype,n=t&&t.valueOf,r=Mp("toPrimitive");t&&!t[r]&&Lp(t,r,(function(e){return Op(n,this)}),{arity:1})},mm=Wo,vm=cn,_m=Dp.forEach,gm=zt("hidden"),ym="Symbol",Em="prototype",Tm=vm.set,km=vm.getterFor(ym),Sm=Object[Em],Im=Vp.Symbol,bm=Im&&Im[Em],Am=Vp.RangeError,Rm=Vp.TypeError,Cm=Vp.QObject,wm=nm.f,Dm=rm.f,Nm=em.f,xm=om.f,Om=Bp([].push),Pm=cm("symbols"),Mm=cm("op-symbols"),Lm=cm("wks"),Um=!Cm||!Cm[Em]||!Cm[Em].findChild,Vm=function(e,t,n){var r=wm(Sm,t);r&&delete Sm[t],Dm(e,t,n),r&&e!==Sm&&Dm(Sm,t,r)},Fm=jp&&Gp((function(){return 7!==Qp(Dm({},"a",{get:function(){return Dm(this,"a",{value:7}).a}})).a}))?Vm:Dm,Bm=function(e,t){var n=Pm[e]=Qp(bm);return Tm(n,{type:ym,tag:e,description:t}),jp||(n.description=t),n},jm=function(e,t,n){e===Sm&&jm(Mm,t,n),zp(e);var r=qp(t);return zp(n),Wp(Pm,r)?(n.enumerable?(Wp(e,gm)&&e[gm][r]&&(e[gm][r]=!1),n=Qp(n,{enumerable:Xp(0,!1)})):(Wp(e,gm)||Dm(e,gm,Xp(1,Qp(null))),e[gm][r]=!0),Fm(e,r,n)):Dm(e,r,n)},Hm=function(e,t){zp(e);var n=Kp(t),r=$p(n).concat(zm(n));return _m(r,(function(t){jp&&!Fp(Gm,n,t)||jm(e,t,n[t])})),e},Gm=function(e){var t=qp(e),n=Fp(xm,this,t);return!(this===Sm&&Wp(Pm,t)&&!Wp(Mm,t))&&(!(n||!Wp(this,t)||!Wp(Pm,t)||Wp(this,gm)&&this[gm][t])||n)},Wm=function(e,t){var n=Kp(e),r=qp(t);if(n!==Sm||!Wp(Pm,r)||Wp(Mm,r)){var i=wm(n,r);return!i||!Wp(Pm,r)||Wp(n,gm)&&n[gm][r]||(i.enumerable=!0),i}},Jm=function(e){var t=Nm(Kp(e)),n=[];return _m(t,(function(e){Wp(Pm,e)||Wp(um,e)||Om(n,e)})),n},zm=function(e){var t=e===Sm,n=Nm(t?Mm:Kp(e)),r=[];return _m(n,(function(e){!Wp(Pm,e)||t&&!Wp(Sm,e)||Om(r,Pm[e])})),r};Hp||(Im=function(){if(Jp(bm,this))throw new Rm("Symbol is not a constructor");var e=arguments.length&&void 0!==arguments[0]?Yp(arguments[0]):void 0,t=lm(e),n=function(e){var r=void 0===this?Vp:this;r===Sm&&Fp(n,Mm,e),Wp(r,gm)&&Wp(r[gm],t)&&(r[gm][t]=!1);var i=Xp(1,e);try{Fm(r,t,i)}catch(PF){if(!(PF instanceof Am))throw PF;Vm(r,t,i)}};return jp&&Um&&Fm(Sm,t,{configurable:!0,set:n}),Bm(t,e)},am(bm=Im[Em],"toString",(function(){return km(this).tag})),am(Im,"withoutSetter",(function(e){return Bm(lm(e),e)})),om.f=Gm,rm.f=jm,im.f=Hm,nm.f=Wm,Zp.f=em.f=Jm,tm.f=zm,hm.f=function(e){return Bm(dm(e),e)},jp&&(sm(bm,"description",{configurable:!0,get:function(){return km(this).description}}),am(Sm,"propertyIsEnumerable",Gm,{unsafe:!0}))),Up({global:!0,constructor:!0,wrap:!0,forced:!Hp,sham:!Hp},{Symbol:Im}),_m($p(Lm),(function(e){fm(e)})),Up({target:ym,stat:!0,forced:!Hp},{useSetter:function(){Um=!0},useSimple:function(){Um=!1}}),Up({target:"Object",stat:!0,forced:!Hp,sham:!jp},{create:function(e,t){return void 0===t?Qp(e):Hm(Qp(e),t)},defineProperty:jm,defineProperties:Hm,getOwnPropertyDescriptor:Wm}),Up({target:"Object",stat:!0,forced:!Hp},{getOwnPropertyNames:Jm}),pm(),mm(Im,ym),um[gm]=!0;var Km=Ps&&!!Symbol.for&&!!Symbol.keyFor,qm=Sf,Ym=Ce,Xm=ge,Qm=er,$m=Vt,Zm=Km,ev=$m("string-to-symbol-registry"),tv=$m("symbol-to-string-registry");qm({target:"Symbol",stat:!0,forced:!Zm},{for:function(e){var t=Qm(e);if(Xm(ev,t))return ev[t];var n=Ym("Symbol")(t);return ev[t]=n,tv[n]=t,n}});var nv=Sf,rv=ge,iv=Bs,ov=ie,av=Km,sv=Vt("symbol-to-string-registry");nv({target:"Symbol",stat:!0,forced:!av},{keyFor:function(e){if(!iv(e))throw new TypeError(ov(e)+" is not a symbol");if(rv(sv,e))return sv[e]}});var cv=Kc,uv=D,lv=Jc,dv=er,hv=Y([].push),fv=Sf,pv=Ce,mv=Iu,vv=ki,_v=Y,gv=R,yv=D,Ev=Bs,Tv=si,kv=function(e){if(uv(e))return e;if(cv(e)){for(var t=e.length,n=[],r=0;r<t;r++){var i=e[r];"string"==typeof i?hv(n,i):"number"!=typeof i&&"Number"!==lv(i)&&"String"!==lv(i)||hv(n,dv(i))}var o=n.length,a=!0;return function(e,t){if(a)return a=!1,t;if(cv(this))return t;for(var r=0;r<o;r++)if(n[r]===e)return t}}},Sv=Ps,Iv=String,bv=pv("JSON","stringify"),Av=_v(/./.exec),Rv=_v("".charAt),Cv=_v("".charCodeAt),wv=_v("".replace),Dv=_v(1..toString),Nv=/[\uD800-\uDFFF]/g,xv=/^[\uD800-\uDBFF]$/,Ov=/^[\uDC00-\uDFFF]$/,Pv=!Sv||gv((function(){var e=pv("Symbol")("stringify detection");return"[null]"!==bv([e])||"{}"!==bv({a:e})||"{}"!==bv(Object(e))})),Mv=gv((function(){return'"\\udf06\\ud834"'!==bv("\udf06\ud834")||'"\\udead"'!==bv("\udead")})),Lv=function(e,t){var n=Tv(arguments),r=kv(t);if(yv(r)||void 0!==e&&!Ev(e))return n[1]=function(e,t){if(yv(r)&&(t=vv(r,this,Iv(e),t)),!Ev(t))return t},mv(bv,null,n)},Uv=function(e,t,n){var r=Rv(n,t-1),i=Rv(n,t+1);return Av(xv,e)&&!Av(Ov,i)||Av(Ov,e)&&!Av(xv,r)?"\\u"+Dv(Cv(e,0),16):e};bv&&fv({target:"JSON",stat:!0,arity:3,forced:Pv||Mv},{stringify:function(e,t,n){var r=Tv(arguments),i=mv(Pv?Lv:bv,null,r);return Mv&&"string"==typeof i?wv(i,Nv,Uv):i}});var Vv=rf,Fv=me;Sf({target:"Object",stat:!0,forced:!Ps||R((function(){Vv.f(1)}))},{getOwnPropertySymbols:function(e){var t=Vv.f;return t?t(Fv(e)):[]}});var Bv=Dp.every;Sf({target:"Array",proto:!0,forced:!Q("every")},{every:function(e){return Bv(this,e,arguments.length>1?arguments[1]:void 0)}});var jv=me,Hv=ht,Gv=_t,Wv=function(e){for(var t=jv(this),n=Gv(t),r=arguments.length,i=Hv(r>1?arguments[1]:void 0,n),o=r>2?arguments[2]:void 0,a=void 0===o?n:Hv(o,n);a>i;)t[i++]=e;return t},Jv=Mo;Sf({target:"Array",proto:!0},{fill:Wv}),Jv("fill");var zv=Dp.filter;Sf({target:"Array",proto:!0,forced:!zr("filter")},{filter:function(e){return zv(this,e,arguments.length>1?arguments[1]:void 0)}});var Kv=Sf,qv=Dp.find,Yv=Mo,Xv="find",Qv=!0;Xv in[]&&Array(1)[Xv]((function(){Qv=!1})),Kv({target:"Array",proto:!0,forced:Qv},{find:function(e){return qv(this,e,arguments.length>1?arguments[1]:void 0)}}),Yv(Xv);var $v=Sf,Zv=Dp.findIndex,e_=Mo,t_="findIndex",n_=!0;t_ in[]&&Array(1)[t_]((function(){n_=!1})),$v({target:"Array",proto:!0,forced:n_},{findIndex:function(e){return Zv(this,e,arguments.length>1?arguments[1]:void 0)}}),e_(t_);var r_=ki,i_=G,o_=rr,a_=function(e,t,n){var r,i;i_(e);try{if(!(r=o_(e,"return"))){if("throw"===t)throw n;return n}r=r_(r,e)}catch(PF){i=!0,r=PF}if("throw"===t)throw n;if(i)throw r;return i_(r),n},s_=G,c_=a_,u_=Lo,l_=Mf("iterator"),d_=Array.prototype,h_=function(e){return void 0!==e&&(u_.Array===e||d_[l_]===e)},f_=be,p_=rr,m_=ue,v_=Lo,__=Mf("iterator"),g_=function(e){if(!m_(e))return p_(e,__)||p_(e,"@@iterator")||v_[f_(e)]},y_=ki,E_=ce,T_=G,k_=ie,S_=g_,I_=TypeError,b_=function(e,t){var n=arguments.length<2?S_(e):t;if(E_(n))return T_(y_(n,e));throw new I_(k_(e)+" is not iterable")},A_=kp,R_=ki,C_=me,w_=function(e,t,n,r){try{return r?t(s_(n)[0],n[1]):t(n)}catch(PF){c_(e,"throw",PF)}},D_=h_,N_=et,x_=_t,O_=kt,P_=b_,M_=g_,L_=Array,U_=function(e){var t=C_(e),n=N_(this),r=arguments.length,i=r>1?arguments[1]:void 0,o=void 0!==i;o&&(i=A_(i,r>2?arguments[2]:void 0));var a,s,c,u,l,d,h=M_(t),f=0;if(!h||this===L_&&D_(h))for(a=x_(t),s=n?new this(a):L_(a);a>f;f++)d=o?i(t[f],f):t[f],O_(s,f,d);else for(s=n?new this:[],l=(u=P_(t,h)).next;!(c=R_(l,u)).done;f++)d=o?w_(u,i,[c.value,f],!0):c.value,O_(s,f,d);return s.length=f,s},V_=Mf("iterator"),F_=!1;try{var B_=0,j_={next:function(){return{done:!!B_++}},return:function(){F_=!0}};j_[V_]=function(){return this},Array.from(j_,(function(){throw 2}))}catch(PF){}var H_=function(e,t){try{if(!t&&!F_)return!1}catch(PF){return!1}var n=!1;try{var r={};r[V_]=function(){return{next:function(){return{done:n=!0}}}},e(r)}catch(PF){}return n},G_=U_;Sf({target:"Array",stat:!0,forced:!H_((function(e){Array.from(e)}))},{from:G_});var W_=xl,J_=TypeError,z_=function(e){if(W_(e))throw new J_("The method doesn't accept regular expressions");return e},K_=Mf("match"),q_=function(e){var t=/./;try{"/./"[e](t)}catch(n){try{return t[K_]=!1,"/./"[e](t)}catch(r){}}return!1},Y_=Sf,X_=z_,Q_=he,$_=er,Z_=q_,eg=Y("".indexOf);Y_({target:"String",proto:!0,forced:!Z_("includes")},{includes:function(e){return!!~eg($_(Q_(this)),$_(X_(e)),arguments.length>1?arguments[1]:void 0)}});var tg=Ji.includes,ng=Mo;Sf({target:"Array",proto:!0,forced:R((function(){return!Array(1).includes()}))},{includes:function(e){return tg(this,e,arguments.length>1?arguments[1]:void 0)}}),ng("includes");var rg=Iu,ig=Uh,og=ct,ag=_t,sg=Q,cg=Math.min,ug=[].lastIndexOf,lg=!!ug&&1/[1].lastIndexOf(1,-0)<0,dg=sg("lastIndexOf"),hg=lg||!dg?function(e){if(lg)return rg(ug,this,arguments)||0;var t=ig(this),n=ag(t);if(0===n)return-1;var r=n-1;for(arguments.length>1&&(r=cg(r,og(arguments[1]))),r<0&&(r=n+r);r>=0;r--)if(r in t&&t[r]===e)return r||0;return-1}:ug;Sf({target:"Array",proto:!0,forced:hg!==[].lastIndexOf},{lastIndexOf:hg});var fg=Dp.map;Sf({target:"Array",proto:!0,forced:!zr("map")},{map:function(e){return fg(this,e,arguments.length>1?arguments[1]:void 0)}});var pg=ce,mg=me,vg=Ph,_g=_t,gg=TypeError,yg="Reduce of empty array with no initial value",Eg=function(e){return function(t,n,r,i){var o=mg(t),a=vg(o),s=_g(o);if(pg(n),0===s&&r<2)throw new gg(yg);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 gg(yg)}for(;e?c>=0:s>c;c+=u)c in a&&(i=n(i,a[c],c,o));return i}},Tg={left:Eg(!1),right:Eg(!0)},kg=Af,Sg=Mr,Ig=Jc,bg=function(e){return Sg.slice(0,e.length)===e},Ag=bg("Bun/")?"BUN":bg("Cloudflare-Workers")?"CLOUDFLARE":bg("Deno/")?"DENO":bg("Node.js/")?"NODE":kg.Bun&&"string"==typeof Bun.version?"BUN":kg.Deno&&"object"==k(Deno.version)?"DENO":"process"===Ig(kg.process)?"NODE":kg.window&&kg.document?"BROWSER":"REST",Rg="NODE"===Ag,Cg=Tg.left;Sf({target:"Array",proto:!0,forced:!Rg&&Hr>79&&Hr<83||!Q("reduce")},{reduce:function(e){var t=arguments.length;return Cg(this,e,t,t>1?arguments[1]:void 0)}});var wg=Tg.right;Sf({target:"Array",proto:!0,forced:!Rg&&Hr>79&&Hr<83||!Q("reduceRight")},{reduceRight:function(e){return wg(this,e,arguments.length,arguments.length>1?arguments[1]:void 0)}});var Dg=Sf,Ng=Kc,xg=Y([].reverse),Og=[1,2];Dg({target:"Array",proto:!0,forced:String(Og)===String(Og.reverse())},{reverse:function(){return Ng(this)&&(this.length=this.length),xg(this)}});var Pg=Dp.some;Sf({target:"Array",proto:!0,forced:!Q("some")},{some:function(e){return Pg(this,e,arguments.length>1?arguments[1]:void 0)}});var Mg=ie,Lg=TypeError,Ug=function(e,t){if(!delete e[t])throw new Lg("Cannot delete property "+Mg(t)+" of "+Mg(e))},Vg=si,Fg=Math.floor,Bg=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=Fg(n/2),s=Bg(Vg(e,0,a),t),c=Bg(Vg(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},jg=Bg,Hg=Mr.match(/firefox\/(\d+)/i),Gg=!!Hg&&+Hg[1],Wg=/MSIE|Trident/.test(Mr),Jg=Mr.match(/AppleWebKit\/(\d+)\./),zg=!!Jg&&+Jg[1],Kg=Sf,qg=Y,Yg=ce,Xg=me,Qg=_t,$g=Ug,Zg=er,ey=R,ty=jg,ny=Q,ry=Gg,iy=Wg,oy=Hr,ay=zg,sy=[],cy=qg(sy.sort),uy=qg(sy.push),ly=ey((function(){sy.sort(void 0)})),dy=ey((function(){sy.sort(null)})),hy=ny("sort"),fy=!ey((function(){if(oy)return oy<70;if(!(ry&&ry>3)){if(iy)return!0;if(ay)return ay<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++)sy.push({k:t+r,v:n})}for(sy.sort((function(e,t){return t.v-e.v})),r=0;r<sy.length;r++)t=sy[r].k.charAt(0),i.charAt(i.length-1)!==t&&(i+=t);return"DGBEFHACIJK"!==i}}));Kg({target:"Array",proto:!0,forced:ly||!dy||!hy||!fy},{sort:function(e){void 0!==e&&Yg(e);var t=Xg(this);if(fy)return void 0===e?cy(t):cy(t,e);var n,r,i=[],o=Qg(t);for(r=0;r<o;r++)r in t&&uy(i,t[r]);for(ty(i,function(e){return function(t,n){return void 0===n?-1:void 0===t?1:void 0!==e?+e(t,n)||0:Zg(t)>Zg(n)?1:-1}}(e)),n=Qg(i),r=0;r<n;)t[r]=i[r++];for(;r<o;)$g(t,r++);return t}});var py=vc,my=Kc,vy=TypeError,_y=Object.getOwnPropertyDescriptor,gy=py&&!function(){if(void 0!==this)return!0;try{Object.defineProperty([],"length",{writable:!1}).length=1}catch(PF){return PF instanceof TypeError}}(),yy=Sf,Ey=me,Ty=ht,ky=ct,Sy=_t,Iy=gy?function(e,t){if(my(e)&&!_y(e,"length").writable)throw new vy("Cannot set read only .length");return e.length=t}:function(e,t){return e.length=t},by=Yc,Ay=nu,Ry=kt,Cy=Ug,wy=zr("splice"),Dy=Math.max,Ny=Math.min;yy({target:"Array",proto:!0,forced:!wy},{splice:function(e,t){var n,r,i,o,a,s,c=Ey(this),u=Sy(c),l=Ty(e,u),d=arguments.length;for(0===d?n=r=0:1===d?(n=0,r=u-l):(n=d-2,r=Ny(Dy(ky(t),0),u-l)),by(u+n-r),i=Ay(c,r),o=0;o<r;o++)(a=l+o)in c&&Ry(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]:Cy(c,s);for(o=u;o>u-r+n;o--)Cy(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]:Cy(c,s);for(o=0;o<n;o++)c[o+l]=arguments[o+2];return Iy(c,u-r+n),i}});var xy=Sf,Oy=Bi,Py=R,My=_T,Ly=G,Uy=ht,Vy=mt,Fy=lh,By=My.ArrayBuffer,jy=My.DataView,Hy=jy.prototype,Gy=Oy(By.prototype.slice),Wy=Oy(Hy.getUint8),Jy=Oy(Hy.setUint8);xy({target:"ArrayBuffer",proto:!0,unsafe:!0,forced:Py((function(){return!new By(2).slice(1,void 0).byteLength}))},{slice:function(e,t){if(Gy&&void 0===t)return Gy(Ly(this),e);for(var n=Ly(this).byteLength,r=Uy(e,n),i=Uy(void 0===t?n:t,n),o=new(Fy(this,By))(Vy(i-r)),a=new jy(this),s=new jy(o),c=0;r<i;)Jy(s,c++,Wy(a,r++));return o}}),Sf({global:!0,constructor:!0,forced:!zy},{DataView:_T.DataView});var zy="undefined"!=typeof ArrayBuffer&&"undefined"!=typeof DataView,Ky=Hn,qy=function(e,t,n){for(var r in t)Ky(e,r,t[r],n);return e},Yy=Si,Xy=TypeError,Qy=function(e,t){if(Yy(t,e))return e;throw new Xy("Incorrect invocation")},$y=ct,Zy=mt,eE=RangeError,tE=function(e){if(void 0===e)return 0;var t=$y(e),n=Zy(t);if(t!==n)throw new eE("Wrong length or index");return n};Sf({target:"Math",stat:!0},{fround:cE}),Sf({target:"Math",stat:!0},{sign:nE});var nE=Math.sign||function(e){var t=+e;return 0===t||t!=t?t:t<0?-1:1},rE=nE,iE=Math.abs,oE=2220446049250313e-31,aE=1/oE,sE=function(e,t,n,r){var i=+e,o=iE(i),a=rE(i);if(o<r)return a*function(e){return e+aE-aE}(o/r/t)*r*t;var s=(1+t/oE)*o,c=s-(s-o);return c>n||c!=c?Infinity*a:a*c},cE=Math.fround||function(e){return sE(e,1.1920928955078125e-7,34028234663852886e22,11754943508222875e-54)},uE=Array,lE=Math.abs,dE=Math.pow,hE=Math.floor,fE=Math.log,pE=Math.LN2,mE={pack:function(e,t,n){var r,i,o,a=uE(n),s=8*n-t-1,c=(1<<s)-1,u=c>>1,l=23===t?dE(2,-24)-dE(2,-77):0,d=e<0||0===e&&1/e<0?1:0,h=0;for((e=lE(e))!=e||Infinity===e?(i=e!=e?1:0,r=c):(r=hE(fE(e)/pE),e*(o=dE(2,-r))<1&&(r--,o*=2),(e+=r+u>=1?l/o:l*dE(2,1-u))*o>=2&&(r++,o/=2),r+u>=c?(i=0,r=c):r+u>=1?(i=(e*o-1)*dE(2,t),r+=u):(i=e*dE(2,u-1)*dE(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+=dE(2,t),l-=a}return(u?-1:1)*n*dE(2,l-t)}},vE=Af,_E=Y,gE=vc,yE=zy,EE=Lt,TE=Cn,kE=qy,SE=R,IE=Qy,bE=ct,AE=mt,RE=tE,CE=cE,wE=mE,DE=ma,NE=Ha,xE=Wv,OE=si,PE=vl,ME=mf,LE=Wo,UE=cn,VE=Dt.PROPER,FE=Dt.CONFIGURABLE,BE="ArrayBuffer",jE="DataView",HE="prototype",GE="Wrong index",WE=UE.getterFor(BE),JE=UE.getterFor(jE),zE=UE.set,KE=vE[BE],qE=KE,YE=qE&&qE[HE],XE=vE[jE],QE=XE&&XE[HE],$E=Object.prototype,ZE=vE.Array,eT=vE.RangeError,tT=_E(xE),nT=_E([].reverse),rT=wE.pack,iT=wE.unpack,oT=function(e){return[255&e]},aT=function(e){return[255&e,e>>8&255]},sT=function(e){return[255&e,e>>8&255,e>>16&255,e>>24&255]},cT=function(e){return e[3]<<24|e[2]<<16|e[1]<<8|e[0]},uT=function(e){return rT(CE(e),23,4)},lT=function(e){return rT(e,52,8)},dT=function(e,t,n){TE(e[HE],t,{configurable:!0,get:function(){return n(this)[t]}})},hT=function(e,t,n,r){var i=JE(e),o=RE(n),a=!!r;if(o+t>i.byteLength)throw new eT(GE);var s=i.bytes,c=o+i.byteOffset,u=OE(s,c,c+t);return a?u:nT(u)},fT=function(e,t,n,r,i,o){var a=JE(e),s=RE(n),c=r(+i),u=!!o;if(s+t>a.byteLength)throw new eT(GE);for(var l=a.bytes,d=s+a.byteOffset,h=0;h<t;h++)l[d+h]=c[u?h:t-h-1]};if(yE){var pT=VE&&KE.name!==BE;SE((function(){KE(1)}))&&SE((function(){new KE(-1)}))&&!SE((function(){return new KE,new KE(1.5),new KE(NaN),1!==KE.length||pT&&!FE}))?pT&&FE&&EE(KE,"name",BE):((qE=function(e){return IE(this,YE),PE(new KE(RE(e)),this,qE)})[HE]=YE,YE.constructor=qE,ME(qE,KE)),NE&&DE(QE)!==$E&&NE(QE,$E);var mT=new XE(new qE(2)),vT=_E(QE.setInt8);mT.setInt8(0,2147483648),mT.setInt8(1,2147483649),!mT.getInt8(0)&&mT.getInt8(1)||kE(QE,{setInt8:function(e,t){vT(this,e,t<<24>>24)},setUint8:function(e,t){vT(this,e,t<<24>>24)}},{unsafe:!0})}else YE=(qE=function(e){IE(this,YE);var t=RE(e);zE(this,{type:BE,bytes:tT(ZE(t),0),byteLength:t}),gE||(this.byteLength=t,this.detached=!1)})[HE],QE=(XE=function(e,t,n){IE(this,QE),IE(e,YE);var r=WE(e),i=r.byteLength,o=bE(t);if(o<0||o>i)throw new eT("Wrong offset");if(o+(n=void 0===n?i-o:AE(n))>i)throw new eT("Wrong length");zE(this,{type:jE,buffer:e,byteLength:n,byteOffset:o,bytes:r.bytes}),gE||(this.buffer=e,this.byteLength=n,this.byteOffset=o)})[HE],gE&&(dT(qE,"byteLength",WE),dT(XE,"buffer",JE),dT(XE,"byteLength",JE),dT(XE,"byteOffset",JE)),kE(QE,{getInt8:function(e){return hT(this,1,e)[0]<<24>>24},getUint8:function(e){return hT(this,1,e)[0]},getInt16:function(e){var t=hT(this,2,e,arguments.length>1&&arguments[1]);return(t[1]<<8|t[0])<<16>>16},getUint16:function(e){var t=hT(this,2,e,arguments.length>1&&arguments[1]);return t[1]<<8|t[0]},getInt32:function(e){return cT(hT(this,4,e,arguments.length>1&&arguments[1]))},getUint32:function(e){return cT(hT(this,4,e,arguments.length>1&&arguments[1]))>>>0},getFloat32:function(e){return iT(hT(this,4,e,arguments.length>1&&arguments[1]),23)},getFloat64:function(e){return iT(hT(this,8,e,arguments.length>1&&arguments[1]),52)},setInt8:function(e,t){fT(this,1,e,oT,t)},setUint8:function(e,t){fT(this,1,e,oT,t)},setInt16:function(e,t){fT(this,2,e,aT,t,arguments.length>2&&arguments[2])},setUint16:function(e,t){fT(this,2,e,aT,t,arguments.length>2&&arguments[2])},setInt32:function(e,t){fT(this,4,e,sT,t,arguments.length>2&&arguments[2])},setUint32:function(e,t){fT(this,4,e,sT,t,arguments.length>2&&arguments[2])},setFloat32:function(e,t){fT(this,4,e,uT,t,arguments.length>2&&arguments[2])},setFloat64:function(e,t){fT(this,8,e,lT,t,arguments.length>2&&arguments[2])}});LE(qE,BE),LE(XE,jE);var _T={ArrayBuffer:qE,DataView:XE},gT=Sf,yT=Af,ET=Gl,TT="ArrayBuffer",kT=_T[TT];gT({global:!0,constructor:!0,forced:yT[TT]!==kT},{ArrayBuffer:kT}),ET(TT);var ST=Sf,IT=Date,bT=Y(IT.prototype.getTime);ST({target:"Date",stat:!0},{now:function(){return bT(new IT)}});var AT=ct,RT=er,CT=he,wT=RangeError,DT=function(e){var t=RT(CT(this)),n="",r=AT(e);if(r<0||Infinity===r)throw new wT("Wrong number of repetitions");for(;r>0;(r>>>=1)&&(t+=t))1&r&&(n+=t);return n},NT=Y,xT=mt,OT=er,PT=he,MT=NT(DT),LT=NT("".slice),UT=Math.ceil,VT=function(e){return function(t,n,r){var i,o,a=OT(PT(t)),s=xT(n),c=a.length,u=void 0===r?" ":OT(r);return s<=c||""===u?a:((o=MT(u,UT((i=s-c)/u.length))).length>i&&(o=LT(o,0,i)),e?a+o:o+a)}},FT={start:VT(!1),end:VT(!0)},BT=Y,jT=R,HT=FT.start,GT=RangeError,WT=isFinite,JT=Math.abs,zT=Date.prototype,KT=zT.toISOString,qT=BT(zT.getTime),YT=BT(zT.getUTCDate),XT=BT(zT.getUTCFullYear),QT=BT(zT.getUTCHours),$T=BT(zT.getUTCMilliseconds),ZT=BT(zT.getUTCMinutes),ek=BT(zT.getUTCMonth),tk=BT(zT.getUTCSeconds),nk=jT((function(){return"0385-07-25T07:06:39.999Z"!==KT.call(new Date(-50000000000001))}))||!jT((function(){KT.call(new Date(NaN))}))?function(){if(!WT(qT(this)))throw new GT("Invalid time value");var e=this,t=XT(e),n=$T(e),r=t<0?"-":t>9999?"+":"";return r+HT(JT(t),r?6:4,0)+"-"+HT(ek(e)+1,2,0)+"-"+HT(YT(e),2,0)+"T"+HT(QT(e),2,0)+":"+HT(ZT(e),2,0)+":"+HT(tk(e),2,0)+"."+HT(n,3,0)+"Z"}:KT,rk=nk;Sf({target:"Date",proto:!0,forced:Date.prototype.toISOString!==rk},{toISOString:rk});var ik=me,ok=$s;Sf({target:"Date",proto:!0,arity:1,forced:R((function(){return null!==new Date(NaN).toJSON()||1!==Date.prototype.toJSON.call({toISOString:function(){return 1}})}))},{toJSON:function(e){var t=ik(this),n=ok(t,"number");return"number"!=typeof n||isFinite(n)?t.toISOString():null}});var ak={},sk={get exports(){return ak},set exports(e){ak=e}},ck=mk;Sf({target:"Object",stat:!0,forced:Object.isExtensible!==ck},{isExtensible:ck});var uk=R((function(){if("function"==typeof ArrayBuffer){var e=new ArrayBuffer(8);Object.isExtensible(e)&&Object.defineProperty(e,"a",{value:8})}})),lk=R,dk=x,hk=Jc,fk=uk,pk=Object.isExtensible,mk=lk((function(){pk(1)}))||fk?function(e){return!!dk(e)&&((!fk||"ArrayBuffer"!==hk(e))&&(!pk||pk(e)))}:pk,vk=Sf,_k=x,gk=ak.onFreeze,yk=kk,Ek=R,Tk=Object.preventExtensions;vk({target:"Object",stat:!0,forced:Ek((function(){Tk(1)})),sham:!yk},{preventExtensions:function(e){return Tk&&_k(e)?Tk(gk(e)):e}});var kk=!R((function(){return Object.isExtensible(Object.preventExtensions({}))})),Sk=Sf,Ik=Y,bk=Kt,Ak=x,Rk=ge,Ck=C.f,wk=Al,Dk=_l,Nk=mk,xk=kk,Ok=!1,Pk=Gt("meta"),Mk=0,Lk=function(e){Ck(e,Pk,{value:{objectID:"O"+Mk++,weakData:{}}})},Uk=sk.exports={enable:function(){Uk.enable=function(){},Ok=!0;var e=wk.f,t=Ik([].splice),n={};n[Pk]=1,e(n).length&&(wk.f=function(n){for(var r=e(n),i=0,o=r.length;i<o;i++)if(r[i]===Pk){t(r,i,1);break}return r},Sk({target:"Object",stat:!0,forced:!0},{getOwnPropertyNames:Dk.f}))},fastKey:function(e,t){if(!Ak(e))return"symbol"==k(e)?e:("string"==typeof e?"S":"P")+e;if(!Rk(e,Pk)){if(!Nk(e))return"F";if(!t)return"E";Lk(e)}return e[Pk].objectID},getWeakData:function(e,t){if(!Rk(e,Pk)){if(!Nk(e))return!0;if(!t)return!1;Lk(e)}return e[Pk].weakData},onFreeze:function(e){return xk&&Ok&&Nk(e)&&!Rk(e,Pk)&&Lk(e),e}};bk[Pk]=!0;var Vk=kp,Fk=ki,Bk=G,jk=ie,Hk=h_,Gk=_t,Wk=Si,Jk=b_,zk=g_,Kk=a_,qk=TypeError,Yk=function(e,t){this.stopped=e,this.result=t},Xk=Yk.prototype,Qk=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=Vk(t,l),v=function(e){return r&&Kk(r,"normal",e),new Yk(!0,e)},_=function(e){return d?(Bk(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=zk(e)))throw new qk(jk(e)+" is not iterable");if(Hk(i)){for(o=0,a=Gk(e);a>o;o++)if((s=_(e[o]))&&Wk(Xk,s))return s;return new Yk(!1)}r=Jk(e,i)}for(c=h?e.next:r.next;!(u=Fk(c,r)).done;){try{s=_(u.value)}catch(PF){Kk(r,"throw",PF)}if("object"==k(s)&&s&&Wk(Xk,s))return s}return new Yk(!1)},$k=Sf,Zk=Af,eS=Y,tS=hl,nS=Hn,rS=ak,iS=Qk,oS=Qy,aS=D,sS=ue,cS=x,uS=R,lS=H_,dS=Wo,hS=vl,fS=function(e,t,n){var r=-1!==e.indexOf("Map"),i=-1!==e.indexOf("Weak"),o=r?"set":"add",a=Zk[e],s=a&&a.prototype,c=a,u={},l=function(e){var t=eS(s[e]);nS(s,e,"add"===e?function(e){return t(this,0===e?0:e),this}:"delete"===e?function(e){return!(i&&!cS(e))&&t(this,0===e?0:e)}:"get"===e?function(e){return i&&!cS(e)?void 0:t(this,0===e?0:e)}:"has"===e?function(e){return!(i&&!cS(e))&&t(this,0===e?0:e)}:function(e,n){return t(this,0===e?0:e,n),this})};if(tS(e,!aS(a)||!(i||s.forEach&&!uS((function(){(new a).entries().next()})))))c=n.getConstructor(t,e,r,o),rS.enable();else if(tS(e,!0)){var d=new c,h=d[o](i?{}:-0,1)!==d,f=uS((function(){d.has(1)})),p=lS((function(e){new a(e)})),m=!i&&uS((function(){for(var e=new a,t=5;t--;)e[o](t,t);return!e.has(-0)}));p||((c=t((function(e,t){oS(e,s);var n=hS(new a,e,c);return sS(t)||iS(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,$k({global:!0,constructor:!0,forced:c!==a},u),dS(c,e),i||n.setStrong(c,e,r),c},pS=wo,mS=Cn,vS=qy,_S=kp,gS=Qy,yS=ue,ES=Qk,TS=cs,kS=us,SS=Gl,IS=vc,bS=ak.fastKey,AS=cn.set,RS=cn.getterFor,CS={getConstructor:function(e,t,n,r){var i=e((function(e,i){gS(e,o),AS(e,{type:t,index:pS(null),first:null,last:null,size:0}),IS||(e.size=0),yS(i)||ES(i,e[r],{that:e,AS_ENTRIES:n})})),o=i.prototype,a=RS(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=bS(t,!0),key:t,value:n,previous:r=o.last,next:null,removed:!1},o.first||(o.first=s),r&&(r.next=s),IS?o.size++:e.size++,"F"!==i&&(o.index[i]=s)),e},c=function(e,t){var n,r=a(e),i=bS(t);if("F"!==i)return r.index[i];for(n=r.first;n;n=n.next)if(n.key===t)return n};return vS(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=pS(null),IS?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),IS?n.size--:t.size--}return!!r},forEach:function(e){for(var t,n=a(this),r=_S(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)}}),vS(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)}}),IS&&mS(o,"size",{configurable:!0,get:function(){return a(this).size}}),i},setStrong:function(e,t,n){var r=t+" Iterator",i=RS(t),o=RS(r);TS(e,t,(function(e,t){AS(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)?kS("keys"===t?n.key:"values"===t?n.value:[n.key,n.value],!1):(e.target=null,kS(void 0,!0))}),n?"entries":"values",!n,!0),SS(t)}};fS("Map",(function(e){return function(){return e(this,arguments.length?arguments[0]:void 0)}}),CS);var wS=Math.log,DS=Math.LOG10E;Sf({target:"Math",stat:!0},{log10:Math.log10||function(e){return wS(e)*DS}});var NS="\t\n\v\f\r \u2028\u2029\ufeff",xS=he,OS=er,PS=NS,MS=Y("".replace),LS=RegExp("^["+PS+"]+"),US=RegExp("(^|[^"+PS+"])["+PS+"]+$"),VS=function(e){return function(t){var n=OS(xS(t));return 1&e&&(n=MS(n,LS,"")),2&e&&(n=MS(n,US,"$1")),n}},FS={start:VS(1),end:VS(2),trim:VS(3)},BS=Dt.PROPER,jS=R,HS=NS,GS=FS.trim;Sf({target:"String",proto:!0,forced:function(e){return jS((function(){return!!HS[e]()||"
"!=="
"[e]()||BS&&HS[e].name!==e}))}("trim")},{trim:function(){return GS(this)}});var WS=Af,JS=R,zS=Y,KS=er,qS=FS.trim,YS=NS,XS=WS.parseInt,QS=WS.Symbol,$S=QS&&QS.iterator,ZS=/^[+-]?0x/i,eI=zS(ZS.exec),tI=8!==XS(YS+"08")||22!==XS(YS+"0x16")||$S&&!JS((function(){XS(Object($S))}))?function(e,t){var n=qS(KS(e));return XS(n,t>>>0||(eI(ZS,n)?16:10))}:XS;Sf({global:!0,forced:parseInt!==tI},{parseInt:tI});var nI=Y(1..valueOf),rI=Sf,iI=vc,oI=Af,aI=Ii,sI=Y,cI=hl,uI=ge,lI=vl,dI=Si,hI=Bs,fI=$s,pI=R,mI=Al.f,vI=Gh.f,_I=C.f,gI=nI,yI=FS.trim,EI="Number",TI=oI[EI];aI[EI];var kI=TI.prototype,SI=oI.TypeError,II=sI("".slice),bI=sI("".charCodeAt),AI=function(e){var t,n,r,i,o,a,s,c,u=fI(e,"number");if(hI(u))throw new SI("Cannot convert a Symbol value to a number");if("string"==typeof u&&u.length>2)if(u=yI(u),43===(t=bI(u,0))||45===t){if(88===(n=bI(u,2))||120===n)return NaN}else if(48===t){switch(bI(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=II(u,2)).length,s=0;s<a;s++)if((c=bI(o,s))<48||c>i)return NaN;return parseInt(o,r)}return+u},RI=cI(EI,!TI(" 0o1")||!TI("0b1")||TI("+0x1")),CI=function(e){var t,n=arguments.length<1?0:TI(function(e){var t=fI(e,"number");return"bigint"==typeof t?t:AI(t)}(e));return dI(kI,t=this)&&pI((function(){gI(t)}))?lI(Object(n),this,CI):n};CI.prototype=kI,RI&&(kI.constructor=CI),rI({global:!0,constructor:!0,wrap:!0,forced:RI},{Number:CI});RI&&function(e,t){for(var n,r=iI?mI(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++)uI(t,n=r[i])&&!uI(e,n)&&_I(e,n,vI(t,n))}(aI[EI],TI);var wI=x,DI=Math.floor,NI=Number.isInteger||function(e){return!wI(e)&&isFinite(e)&&DI(e)===e};Sf({target:"Number",stat:!0},{isInteger:NI}),Sf({target:"Number",stat:!0},{isNaN:function(e){return e!=e}});var xI=Sf,OI=Y,PI=ct,MI=nI,LI=DT,UI=R,VI=RangeError,FI=String,BI=Math.floor,jI=OI(LI),HI=OI("".slice),GI=OI(1..toFixed),WI=function(e,t,n){return 0===t?n:t%2==1?WI(e,t-1,n*e):WI(e*e,t/2,n)},JI=function(e,t,n){for(var r=-1,i=n;++r<6;)i+=t*e[r],e[r]=i%1e7,i=BI(i/1e7)},zI=function(e,t){for(var n=6,r=0;--n>=0;)r+=e[n],e[n]=BI(r/t),r=r%t*1e7},KI=function(e){for(var t=6,n="";--t>=0;)if(""!==n||0===t||0!==e[t]){var r=FI(e[t]);n=""===n?r:n+jI("0",7-r.length)+r}return n};xI({target:"Number",proto:!0,forced:UI((function(){return"0.000"!==GI(8e-5,3)||"1"!==GI(.9,0)||"1.25"!==GI(1.255,2)||"1000000000000000128"!==GI(0xde0b6b3a7640080,0)}))||!UI((function(){GI({})}))},{toFixed:function(e){var t,n,r,i,o=MI(this),a=PI(e),s=[0,0,0,0,0,0],c="",u="0";if(a<0||a>20)throw new VI("Incorrect fraction digits");if(o!=o)return"NaN";if(o<=-1e21||o>=1e21)return FI(o);if(o<0&&(c="-",o=-o),o>1e-21)if(n=(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*WI(2,69,1))-69)<0?o*WI(2,-t,1):o/WI(2,t,1),n*=4503599627370496,(t=52-t)>0){for(JI(s,0,n),r=a;r>=7;)JI(s,1e7,0),r-=7;for(JI(s,WI(10,r,1),0),r=t-1;r>=23;)zI(s,1<<23),r-=23;zI(s,1<<r),JI(s,1,1),zI(s,2),u=KI(s)}else JI(s,0,n),JI(s,1<<-t,0),u=KI(s)+jI("0",a);return u=a>0?c+((i=u.length)<=a?"0."+jI("0",a-i)+u:HI(u,0,i-a)+"."+HI(u,i-a)):c+u}});var qI=vc,YI=Y,XI=ki,QI=R,$I=ao,ZI=rf,eb=Wh,tb=me,nb=Ph,rb=Object.assign,ib=Object.defineProperty,ob=YI([].concat),ab=!rb||QI((function(){if(qI&&1!==rb({b:1},rb(ib({},"a",{enumerable:!0,get:function(){ib(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!==rb({},e)[n]||$I(rb({},t)).join("")!==r}))?function(e,t){for(var n=tb(e),r=arguments.length,i=1,o=ZI.f,a=eb.f;r>i;)for(var s,c=nb(arguments[i++]),u=o?ob($I(c),o(c)):$I(c),l=u.length,d=0;l>d;)s=u[d++],qI&&!XI(a,c,s)||(n[s]=c[s]);return n}:rb,sb=ab;Sf({target:"Object",stat:!0,arity:2,forced:Object.assign!==sb},{assign:sb});var cb=Sf,ub=kk,lb=R,db=x,hb=ak.onFreeze,fb=Object.freeze;cb({target:"Object",stat:!0,forced:lb((function(){fb(1)})),sham:!ub},{freeze:function(e){return fb&&db(e)?fb(hb(e)):e}});var pb=lf,mb=Uh,vb=Gh,_b=kt;Sf({target:"Object",stat:!0,sham:!vc},{getOwnPropertyDescriptors:function(e){for(var t,n,r=mb(e),i=vb.f,o=pb(r),a={},s=0;o.length>s;)void 0!==(n=i(r,t=o[s++]))&&_b(a,t,n);return a}});var gb=vc,yb=R,Eb=Y,Tb=ma,kb=ao,Sb=Uh,Ib=Eb(Wh.f),bb=Eb([].push),Ab=gb&&yb((function(){var e=Object.create(null);return e[2]=2,!Ib(e,2)})),Rb=function(e){return function(t){for(var n,r=Sb(t),i=kb(r),o=Ab&&null===Tb(r),a=i.length,s=0,c=[];a>s;)n=i[s++],gb&&!(o?n in r:Ib(r,n))||bb(c,e?[n,r[n]]:r[n]);return c}},Cb={entries:Rb(!0),values:Rb(!1)}.values;Sf({target:"Object",stat:!0},{values:function(e){return Cb(e)}});var wb=Af,Db=R,Nb=er,xb=FS.trim,Ob=NS,Pb=Y("".charAt),Mb=wb.parseFloat,Lb=wb.Symbol,Ub=Lb&&Lb.iterator,Vb=1/Mb(Ob+"-0")!=-Infinity||Ub&&!Db((function(){Mb(Object(Ub))}))?function(e){var t=xb(Nb(e)),n=Mb(t);return 0===n&&"-"===Pb(t,0)?-0:n}:Mb;Sf({global:!0,forced:parseFloat!==Vb},{parseFloat:Vb});var Fb=TypeError,Bb=function(e,t){if(e<t)throw new Fb("Not enough arguments");return e},jb=Af,Hb=Iu,Gb=D,Wb=Ag,Jb=Mr,zb=si,Kb=Bb,qb=jb.Function,Yb=/MSIE .\./.test(Jb)||"BUN"===Wb&&function(){var e=jb.Bun.version.split(".");return e.length<3||"0"===e[0]&&(e[1]<3||"3"===e[1]&&"0"===e[2])}(),Xb=function(e,t){var n=t?2:1;return Yb?function(r,i){var o=Kb(arguments.length,1)>n,a=Gb(r)?r:qb(r),s=o?zb(arguments,n):[],c=o?function(){Hb(a,this,s)}:a;return t?e(c,i):e(c)}:e},Qb=Sf,$b=Af,Zb=Xb($b.setInterval,!0);Qb({global:!0,bind:!0,forced:$b.setInterval!==Zb},{setInterval:Zb});var eA=Sf,tA=Af,nA=Xb(tA.setTimeout,!0);eA({global:!0,bind:!0,forced:tA.setTimeout!==nA},{setTimeout:nA});var rA,iA,oA,aA,sA=/(?:ipad|iphone|ipod).*applewebkit/i.test(Mr),cA=Af,uA=Iu,lA=kp,dA=D,hA=ge,fA=R,pA=mo,mA=si,vA=L,_A=Bb,gA=sA,yA=Rg,EA=cA.setImmediate,TA=cA.clearImmediate,kA=cA.process,SA=cA.Dispatch,IA=cA.Function,bA=cA.MessageChannel,AA=cA.String,RA=0,CA={},wA="onreadystatechange";fA((function(){rA=cA.location}));var DA=function(e){if(hA(CA,e)){var t=CA[e];delete CA[e],t()}},NA=function(e){return function(){DA(e)}},xA=function(e){DA(e.data)},OA=function(e){cA.postMessage(AA(e),rA.protocol+"//"+rA.host)};EA&&TA||(EA=function(e){_A(arguments.length,1);var t=dA(e)?e:IA(e),n=mA(arguments,1);return CA[++RA]=function(){uA(t,void 0,n)},iA(RA),RA},TA=function(e){delete CA[e]},yA?iA=function(e){kA.nextTick(NA(e))}:SA&&SA.now?iA=function(e){SA.now(NA(e))}:bA&&!gA?(aA=(oA=new bA).port2,oA.port1.onmessage=xA,iA=lA(aA.postMessage,aA)):cA.addEventListener&&dA(cA.postMessage)&&!cA.importScripts&&rA&&"file:"!==rA.protocol&&!fA(OA)?(iA=OA,cA.addEventListener("message",xA,!1)):iA=wA in vA("script")?function(e){pA.appendChild(vA("script"))[wA]=function(){pA.removeChild(this),DA(e)}}:function(e){setTimeout(NA(e),0)});var PA={set:EA,clear:TA},MA=Af,LA=vc,UA=Object.getOwnPropertyDescriptor,VA=function(e){if(!LA)return MA[e];var t=UA(MA,e);return t&&t.value},FA=function(){this.head=null,this.tail=null};FA.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 BA,jA,HA,GA,WA,JA=FA,zA=/ipad|iphone|ipod/i.test(Mr)&&"undefined"!=typeof Pebble,KA=/web0s(?!.*chrome)/i.test(Mr),qA=Af,YA=VA,XA=kp,QA=PA.set,$A=JA,ZA=sA,eR=zA,tR=KA,nR=Rg,rR=qA.MutationObserver||qA.WebKitMutationObserver,iR=qA.document,oR=qA.process,aR=qA.Promise,sR=YA("queueMicrotask");if(!sR){var cR=new $A,uR=function(){var e,t;for(nR&&(e=oR.domain)&&e.exit();t=cR.get();)try{t()}catch(PF){throw cR.head&&BA(),PF}e&&e.enter()};ZA||nR||tR||!rR||!iR?!eR&&aR&&aR.resolve?((GA=aR.resolve(void 0)).constructor=aR,WA=XA(GA.then,GA),BA=function(){WA(uR)}):nR?BA=function(){oR.nextTick(uR)}:(QA=XA(QA,qA),BA=function(){QA(uR)}):(jA=!0,HA=iR.createTextNode(""),new rR(uR).observe(HA,{characterData:!0}),BA=function(){HA.data=jA=!jA}),sR=function(e){cR.head||BA(),cR.add(e)}}var lR=sR,dR=function(e){try{return{error:!1,value:e()}}catch(PF){return{error:!0,value:PF}}},hR=Af.Promise,fR={},pR=ce,mR=TypeError,vR=function(e){var t,n;this.promise=new e((function(e,r){if(void 0!==t||void 0!==n)throw new mR("Bad Promise constructor");t=e,n=r})),this.resolve=pR(t),this.reject=pR(n)};fR.f=function(e){return new vR(e)};var _R=G,gR=x,yR=fR,ER=function(e,t){if(_R(e),gR(t)&&t.constructor===e)return t;var n=yR.f(e);return(0,n.resolve)(t),n.promise},TR=Sf,kR=hR,SR=R,IR=Ce,bR=D,AR=lh,RR=ER,CR=Hn,wR=kR&&kR.prototype;if(TR({target:"Promise",proto:!0,real:!0,forced:!!kR&&SR((function(){wR.finally.call({then:function(){}},(function(){}))}))},{finally:function(e){var t=AR(this,IR("Promise")),n=bR(e);return this.then(n?function(n){return RR(t,e()).then((function(){return n}))}:e,n?function(n){return RR(t,e()).then((function(){throw n}))}:e)}}),bR(kR)){var DR=IR("Promise").prototype.finally;wR.finally!==DR&&CR(wR,"finally",DR,{unsafe:!0})}var NR=Af,xR=hR,OR=D,PR=hl,MR=je,LR=Mf,UR=Ag,VR=Hr;xR&&xR.prototype;var FR,BR,jR,HR=LR("species"),GR=!1,WR=OR(NR.PromiseRejectionEvent),JR=PR("Promise",(function(){var e=MR(xR),t=e!==String(xR);if(!t&&66===VR)return!0;if(!VR||VR<51||!/native code/.test(e)){var n=new xR((function(e){e(1)})),r=function(e){e((function(){}),(function(){}))};if((n.constructor={})[HR]=r,!(GR=n.then((function(){}))instanceof r))return!0}return!(t||"BROWSER"!==UR&&"DENO"!==UR||WR)})),zR={CONSTRUCTOR:JR,REJECTION_EVENT:WR,SUBCLASSING:GR},KR=Sf,qR=Rg,YR=Af,XR=ki,QR=Hn,$R=Ha,ZR=Wo,eC=Gl,tC=ce,nC=D,rC=x,iC=Qy,oC=lh,aC=PA.set,sC=lR,cC=function(e,t){try{1===arguments.length?console.error(e):console.error(e,t)}catch(PF){}},uC=dR,lC=JA,dC=cn,hC=hR,fC=fR,pC="Promise",mC=zR.CONSTRUCTOR,vC=zR.REJECTION_EVENT,_C=zR.SUBCLASSING,gC=dC.getterFor(pC),yC=dC.set,EC=hC&&hC.prototype,TC=hC,kC=EC,SC=YR.TypeError,IC=YR.document,bC=YR.process,AC=fC.f,RC=AC,CC=!!(IC&&IC.createEvent&&YR.dispatchEvent),wC="unhandledrejection",DC=function(e){var t;return!(!rC(e)||!nC(t=e.then))&&t},NC=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&&LC(t),t.rejection=1),!0===s?n=o:(l&&l.enter(),n=s(o),l&&(l.exit(),i=!0)),n===e.promise?u(new SC("Promise-chain cycle")):(r=DC(n))?XR(r,n,c,u):c(n)):u(o)}catch(PF){l&&!i&&l.exit(),u(PF)}},xC=function(e,t){e.notified||(e.notified=!0,sC((function(){for(var n,r=e.reactions;n=r.get();)NC(n,e);e.notified=!1,t&&!e.rejection&&PC(e)})))},OC=function(e,t,n){var r,i;CC?((r=IC.createEvent("Event")).promise=t,r.reason=n,r.initEvent(e,!1,!0),YR.dispatchEvent(r)):r={promise:t,reason:n},!vC&&(i=YR["on"+e])?i(r):e===wC&&cC("Unhandled promise rejection",n)},PC=function(e){XR(aC,YR,(function(){var t,n=e.facade,r=e.value;if(MC(e)&&(t=uC((function(){qR?bC.emit("unhandledRejection",r,n):OC(wC,n,r)})),e.rejection=qR||MC(e)?2:1,t.error))throw t.value}))},MC=function(e){return 1!==e.rejection&&!e.parent},LC=function(e){XR(aC,YR,(function(){var t=e.facade;qR?bC.emit("rejectionHandled",t):OC("rejectionhandled",t,e.value)}))},UC=function(e,t,n){return function(r){e(t,r,n)}},VC=function(e,t,n){e.done||(e.done=!0,n&&(e=n),e.value=t,e.state=2,xC(e,!0))},FC=function(e,t,n){if(!e.done){e.done=!0,n&&(e=n);try{if(e.facade===t)throw new SC("Promise can't be resolved itself");var r=DC(t);r?sC((function(){var n={done:!1};try{XR(r,t,UC(FC,n,e),UC(VC,n,e))}catch(PF){VC(n,PF,e)}})):(e.value=t,e.state=1,xC(e,!1))}catch(PF){VC({done:!1},PF,e)}}};if(mC&&(kC=(TC=function(e){iC(this,kC),tC(e),XR(FR,this);var t=gC(this);try{e(UC(FC,t),UC(VC,t))}catch(PF){VC(t,PF)}}).prototype,(FR=function(e){yC(this,{type:pC,done:!1,notified:!1,parent:!1,reactions:new lC,rejection:!1,state:0,value:null})}).prototype=QR(kC,"then",(function(e,t){var n=gC(this),r=AC(oC(this,TC));return n.parent=!0,r.ok=!nC(e)||e,r.fail=nC(t)&&t,r.domain=qR?bC.domain:void 0,0===n.state?n.reactions.add(r):sC((function(){NC(r,n)})),r.promise})),BR=function(){var e=new FR,t=gC(e);this.promise=e,this.resolve=UC(FC,t),this.reject=UC(VC,t)},fC.f=AC=function(e){return e===TC||undefined===e?new BR(e):RC(e)},nC(hC)&&EC!==Object.prototype)){jR=EC.then,_C||QR(EC,"then",(function(e,t){var n=this;return new TC((function(e,t){XR(jR,n,e,t)})).then(e,t)}),{unsafe:!0});try{delete EC.constructor}catch(PF){}$R&&$R(EC,kC)}KR({global:!0,constructor:!0,wrap:!0,forced:mC},{Promise:TC}),ZR(TC,pC,!1),eC(pC);var BC=hR,jC=zR.CONSTRUCTOR||!H_((function(e){BC.all(e).then(void 0,(function(){}))})),HC=ki,GC=ce,WC=fR,JC=dR,zC=Qk;Sf({target:"Promise",stat:!0,forced:jC},{all:function(e){var t=this,n=WC.f(t),r=n.resolve,i=n.reject,o=JC((function(){var n=GC(t.resolve),o=[],a=0,s=1;zC(e,(function(e){var c=a++,u=!1;s++,HC(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 KC=Sf,qC=zR.CONSTRUCTOR,YC=hR,XC=Ce,QC=D,$C=Hn,ZC=YC&&YC.prototype;if(KC({target:"Promise",proto:!0,forced:qC,real:!0},{catch:function(e){return this.then(void 0,e)}}),QC(YC)){var ew=XC("Promise").prototype.catch;ZC.catch!==ew&&$C(ZC,"catch",ew,{unsafe:!0})}var tw=ki,nw=ce,rw=fR,iw=dR,ow=Qk;Sf({target:"Promise",stat:!0,forced:jC},{race:function(e){var t=this,n=rw.f(t),r=n.reject,i=iw((function(){var i=nw(t.resolve);ow(e,(function(e){tw(i,t,e).then(n.resolve,r)}))}));return i.error&&r(i.value),n.promise}});var aw=fR;Sf({target:"Promise",stat:!0,forced:zR.CONSTRUCTOR},{reject:function(e){var t=aw.f(this);return(0,t.reject)(e),t.promise}});var sw=Sf,cw=zR.CONSTRUCTOR,uw=ER;Ce("Promise"),sw({target:"Promise",stat:!0,forced:cw},{resolve:function(e){return uw(this,e)}});var lw=ge,dw=ki,hw=x,fw=G,pw=function(e){return void 0!==e&&(lw(e,"value")||lw(e,"writable"))},mw=Gh,vw=ma;Sf({target:"Reflect",stat:!0},{get:function e(t,n){var r,i,o=arguments.length<3?t:arguments[2];return fw(t)===o?t[n]:(r=mw.f(t,n))?pw(r)?r.value:void 0===r.get?void 0:dw(r.get,o):hw(i=vw(t))?e(i,n,o):void 0}}),Sf({target:"Reflect",stat:!0},{ownKeys:lf}),fS("Set",(function(e){return function(){return e(this,arguments.length?arguments[0]:void 0)}}),CS);var _w,gw=Sf,yw=Bi,Ew=Gh.f,Tw=mt,kw=er,Sw=z_,Iw=he,bw=q_,Aw=yw("".slice),Rw=Math.min,Cw=bw("endsWith");gw({target:"String",proto:!0,forced:!!(Cw||(_w=Ew(String.prototype,"endsWith"),!_w||_w.writable))&&!Cw},{endsWith:function(e){var t=kw(Iw(this));Sw(e);var n=arguments.length>1?arguments[1]:void 0,r=t.length,i=void 0===n?r:Rw(Tw(n),r),o=kw(e);return Aw(t,i-o.length,i)===o}});var ww=Sf,Dw=Y,Nw=ht,xw=RangeError,Ow=String.fromCharCode,Pw=String.fromCodePoint,Mw=Dw([].join);ww({target:"String",stat:!0,arity:1,forced:!!Pw&&1!==Pw.length},{fromCodePoint:function(e){for(var t,n=[],r=arguments.length,i=0;r>i;){if(t=+arguments[i++],Nw(t,1114111)!==t)throw new xw(t+" is not a valid code point");n[i]=t<65536?Ow(t):Ow(55296+((t-=65536)>>10),t%1024+56320)}return Mw(n,"")}});var Lw=/Version\/10(?:\.\d+){1,2}(?: [\w./]+)?(?: Mobile\/\w+)? Safari\//.test(Mr),Uw=FT.start;Sf({target:"String",proto:!0,forced:Lw},{padStart:function(e){return Uw(this,e,arguments.length>1?arguments[1]:void 0)}}),Sf({target:"Object",stat:!0},{is:Vw});var Vw=Object.is||function(e,t){return e===t?0!==e||1/e==1/t:e!=e&&t!=t},Fw=ki,Bw=G,jw=ue,Hw=he,Gw=Vw,Ww=er,Jw=rr,zw=Tr;Qn("search",(function(e,t,n){return[function(t){var n=Hw(this),r=jw(t)?void 0:Jw(t,e);return r?Fw(r,t,n):new RegExp(t)[e](Ww(n))},function(e){var r=Bw(this),i=Ww(e),o=n(t,r,i);if(o.done)return o.value;var a=r.lastIndex;Gw(a,0)||(r.lastIndex=0);var s=zw(r,i);return Gw(r.lastIndex,a)||(r.lastIndex=a),null===s?-1:s.index}]}));var Kw=Sf,qw=Bi,Yw=Gh.f,Xw=mt,Qw=er,$w=z_,Zw=he,eD=q_,tD=qw("".slice),nD=Math.min,rD=eD("startsWith"),iD=!rD&&!!function(){var e=Yw(String.prototype,"startsWith");return e&&!e.writable}();Kw({target:"String",proto:!0,forced:!iD&&!rD},{startsWith:function(e){var t=Qw(Zw(this));$w(e);var n=Xw(nD(arguments.length>1?arguments[1]:void 0,t.length)),r=Qw(e);return tD(t,n,n+r.length)===r}});var oD=he,aD=er,sD=/"/g,cD=Y("".replace),uD=function(e,t,n,r){var i=aD(oD(e)),o="<"+t;return""!==n&&(o+=" "+n+'="'+cD(aD(r),sD,""")+'"'),o+">"+i+"</"+t+">"},lD=R,dD=function(e){return lD((function(){var t=""[e]('"');return t!==t.toLowerCase()||t.split('"').length>3}))},hD=uD;Sf({target:"String",proto:!0,forced:dD("link")},{link:function(e){return hD(this,"a","href",e)}});var fD=uD;Sf({target:"String",proto:!0,forced:dD("small")},{small:function(){return fD(this,"small","","")}});var pD,mD,vD,_D={},gD={get exports(){return _D},set exports(e){_D=e}},yD=zy,ED=vc,TD=Af,kD=D,SD=x,ID=ge,bD=be,AD=ie,RD=Lt,CD=Hn,wD=Cn,DD=Si,ND=ma,xD=Ha,OD=Mf,PD=Gt,MD=cn.enforce,LD=cn.get,UD=TD.Int8Array,VD=UD&&UD.prototype,FD=TD.Uint8ClampedArray,BD=FD&&FD.prototype,jD=UD&&ND(UD),HD=VD&&ND(VD),GD=Object.prototype,WD=TD.TypeError,JD=OD("toStringTag"),zD=PD("TYPED_ARRAY_TAG"),KD="TypedArrayConstructor",qD=yD&&!!xD&&"Opera"!==bD(TD.opera),YD=!1,XD={Int8Array:1,Uint8Array:1,Uint8ClampedArray:1,Int16Array:2,Uint16Array:2,Int32Array:4,Uint32Array:4,Float32Array:4,Float64Array:8},QD={BigInt64Array:8,BigUint64Array:8},$D=function(e){var t=ND(e);if(SD(t)){var n=LD(t);return n&&ID(n,KD)?n[KD]:$D(t)}},ZD=function(e){if(!SD(e))return!1;var t=bD(e);return ID(XD,t)||ID(QD,t)};for(pD in XD)(vD=(mD=TD[pD])&&mD.prototype)?MD(vD)[KD]=mD:qD=!1;for(pD in QD)(vD=(mD=TD[pD])&&mD.prototype)&&(MD(vD)[KD]=mD);if((!qD||!kD(jD)||jD===Function.prototype)&&(jD=function(){throw new WD("Incorrect invocation")},qD))for(pD in XD)TD[pD]&&xD(TD[pD],jD);if((!qD||!HD||HD===GD)&&(HD=jD.prototype,qD))for(pD in XD)TD[pD]&&xD(TD[pD].prototype,HD);if(qD&&ND(BD)!==HD&&xD(BD,HD),ED&&!ID(HD,JD))for(pD in YD=!0,wD(HD,JD,{configurable:!0,get:function(){return SD(this)?this[zD]:void 0}}),XD)TD[pD]&&RD(TD[pD],zD,pD);var eN={NATIVE_ARRAY_BUFFER_VIEWS:qD,TYPED_ARRAY_TAG:YD&&zD,aTypedArray:function(e){if(ZD(e))return e;throw new WD("Target is not a typed array")},aTypedArrayConstructor:function(e){if(kD(e)&&(!xD||DD(jD,e)))return e;throw new WD(AD(e)+" is not a typed array constructor")},exportTypedArrayMethod:function(e,t,n,r){if(ED){if(n)for(var i in XD){var o=TD[i];if(o&&ID(o.prototype,e))try{delete o.prototype[e]}catch(PF){try{o.prototype[e]=t}catch(a){}}}HD[e]&&!n||CD(HD,e,n?t:qD&&VD[e]||t,r)}},exportTypedArrayStaticMethod:function(e,t,n){var r,i;if(ED){if(xD){if(n)for(r in XD)if((i=TD[r])&&ID(i,e))try{delete i[e]}catch(PF){}if(jD[e]&&!n)return;try{return CD(jD,e,n?t:qD&&jD[e]||t)}catch(PF){}}for(r in XD)!(i=TD[r])||i[e]&&!n||CD(i,e,t)}},getTypedArrayConstructor:$D,isView:function(e){if(!SD(e))return!1;var t=bD(e);return"DataView"===t||ID(XD,t)||ID(QD,t)},isTypedArray:ZD,TypedArray:jD,TypedArrayPrototype:HD},tN=Af,nN=R,rN=H_,iN=eN.NATIVE_ARRAY_BUFFER_VIEWS,oN=tN.ArrayBuffer,aN=tN.Int8Array,sN=!iN||!nN((function(){aN(1)}))||!nN((function(){new aN(-1)}))||!rN((function(e){new aN,new aN(null),new aN(1.5),new aN(e)}),!0)||nN((function(){return 1!==new aN(new oN(2),1,void 0).length})),cN=ct,uN=RangeError,lN=function(e){var t=cN(e);if(t<0)throw new uN("The argument can't be less than 0");return t},dN=RangeError,hN=function(e,t){var n=lN(e);if(n%t)throw new dN("Wrong offset");return n},fN=Math.round,pN=be,mN=$s,vN=TypeError,_N=function(e){var t=mN(e,"number");if("number"==typeof t)throw new vN("Can't convert number to bigint");return BigInt(t)},gN=kp,yN=ki,EN=oh,TN=me,kN=_t,SN=b_,IN=g_,bN=h_,AN=function(e){var t=pN(e);return"BigInt64Array"===t||"BigUint64Array"===t},RN=eN.aTypedArrayConstructor,CN=_N,wN=function(e){var t,n,r,i,o,a,s,c,u=EN(this),l=TN(e),d=arguments.length,h=d>1?arguments[1]:void 0,f=void 0!==h,p=IN(l);if(p&&!bN(p))for(c=(s=SN(l,p)).next,l=[];!(a=yN(c,s)).done;)l.push(a.value);for(f&&d>2&&(h=gN(h,arguments[2])),n=kN(l),r=new(RN(u))(n),i=AN(r),t=0;n>t;t++)o=f?h(l[t],t):l[t],r[t]=i?CN(o):+o;return r},DN=_t,NN=function(e,t,n){for(var r=0,i=arguments.length>2?n:DN(t),o=new e(i);i>r;)o[r]=t[r++];return o},xN=Sf,ON=Af,PN=ki,MN=vc,LN=sN,UN=eN,VN=_T,FN=Qy,BN=gt,jN=Lt,HN=NI,GN=mt,WN=tE,JN=hN,zN=function(e){var t=fN(e);return t<0?0:t>255?255:255&t},KN=tc,qN=ge,YN=be,XN=x,QN=Bs,$N=wo,ZN=Si,ex=Ha,tx=Al.f,nx=wN,rx=Dp.forEach,ix=Gl,ox=Cn,ax=C,sx=Gh,cx=NN,ux=vl,lx=cn.get,dx=cn.set,hx=cn.enforce,fx=ax.f,px=sx.f,mx=ON.RangeError,vx=VN.ArrayBuffer,_x=vx.prototype,gx=VN.DataView,yx=UN.NATIVE_ARRAY_BUFFER_VIEWS,Ex=UN.TYPED_ARRAY_TAG,Tx=UN.TypedArray,kx=UN.TypedArrayPrototype,Sx=UN.isTypedArray,Ix="BYTES_PER_ELEMENT",bx="Wrong length",Ax=function(e,t){ox(e,t,{configurable:!0,get:function(){return lx(this)[t]}})},Rx=function(e){var t;return ZN(_x,e)||"ArrayBuffer"===(t=YN(e))||"SharedArrayBuffer"===t},Cx=function(e,t){return Sx(e)&&!QN(t)&&t in e&&HN(+t)&&t>=0},wx=function(e,t){return t=KN(t),Cx(e,t)?BN(2,e[t]):px(e,t)},Dx=function(e,t,n){return t=KN(t),!(Cx(e,t)&&XN(n)&&qN(n,"value"))||qN(n,"get")||qN(n,"set")||n.configurable||qN(n,"writable")&&!n.writable||qN(n,"enumerable")&&!n.enumerable?fx(e,t,n):(e[t]=n.value,e)};MN?(yx||(sx.f=wx,ax.f=Dx,Ax(kx,"buffer"),Ax(kx,"byteOffset"),Ax(kx,"byteLength"),Ax(kx,"length")),xN({target:"Object",stat:!0,forced:!yx},{getOwnPropertyDescriptor:wx,defineProperty:Dx}),gD.exports=function(e,t,n){var r=e.match(/\d+/)[0]/8,i=e+(n?"Clamped":"")+"Array",o="get"+e,a="set"+e,s=ON[i],c=s,u=c&&c.prototype,l={},d=function(e,t){fx(e,t,{get:function(){return function(e,t){var n=lx(e);return n.view[o](t*r+n.byteOffset,!0)}(this,t)},set:function(e){return function(e,t,i){var o=lx(e);o.view[a](t*r+o.byteOffset,n?zN(i):i,!0)}(this,t,e)},enumerable:!0})};yx?LN&&(c=t((function(e,t,n,i){return FN(e,u),ux(XN(t)?Rx(t)?void 0!==i?new s(t,JN(n,r),i):void 0!==n?new s(t,JN(n,r)):new s(t):Sx(t)?cx(c,t):PN(nx,c,t):new s(WN(t)),e,c)})),ex&&ex(c,Tx),rx(tx(s),(function(e){e in c||jN(c,e,s[e])})),c.prototype=u):(c=t((function(e,t,n,i){FN(e,u);var o,a,s,l=0,h=0;if(XN(t)){if(!Rx(t))return Sx(t)?cx(c,t):PN(nx,c,t);o=t,h=JN(n,r);var f=t.byteLength;if(void 0===i){if(f%r)throw new mx(bx);if((a=f-h)<0)throw new mx(bx)}else if((a=GN(i)*r)+h>f)throw new mx(bx);s=a/r}else s=WN(t),o=new vx(a=s*r);for(dx(e,{buffer:o,byteOffset:h,byteLength:a,length:s,view:new gx(o)});l<s;)d(e,l++)})),ex&&ex(c,Tx),u=c.prototype=$N(kx)),u.constructor!==c&&jN(u,"constructor",c),hx(u).TypedArrayConstructor=c,Ex&&jN(u,Ex,i);var h=c!==s;l[i]=c,xN({global:!0,constructor:!0,forced:h,sham:!yx},l),Ix in c||jN(c,Ix,r),Ix in u||jN(u,Ix,r),ix(i)}):gD.exports=function(){},_D("Float32",(function(e){return function(t,n,r){return e(this,t,n,r)}})),_D("Int8",(function(e){return function(t,n,r){return e(this,t,n,r)}})),_D("Uint8",(function(e){return function(t,n,r){return e(this,t,n,r)}})),_D("Uint8",(function(e){return function(t,n,r){return e(this,t,n,r)}}),!0);var Nx=Mo;Sf({target:"Array",proto:!0},{copyWithin:Ux}),Nx("copyWithin");var xx=me,Ox=ht,Px=_t,Mx=Ug,Lx=Math.min,Ux=[].copyWithin||function(e,t){var n=xx(this),r=Px(n),i=Ox(e,r),o=Ox(t,r),a=arguments.length>2?arguments[2]:void 0,s=Lx((void 0===a?r:Ox(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]:Mx(n,i),i+=c,o+=c;return n},Vx=eN,Fx=Y(Ux),Bx=Vx.aTypedArray;(0,Vx.exportTypedArrayMethod)("copyWithin",(function(e,t){return Fx(Bx(this),e,t,arguments.length>2?arguments[2]:void 0)}));var jx=Dp.every,Hx=eN.aTypedArray;(0,eN.exportTypedArrayMethod)("every",(function(e){return jx(Hx(this),e,arguments.length>1?arguments[1]:void 0)}));var Gx=lh,Wx=eN.aTypedArrayConstructor,Jx=eN.getTypedArrayConstructor,zx=function(e){return Wx(Gx(e,Jx(e)))},Kx=NN,qx=zx,Yx=Dp.filter,Xx=function(e,t){return Kx(qx(e),t)},Qx=eN.aTypedArray;(0,eN.exportTypedArrayMethod)("filter",(function(e){var t=Yx(Qx(this),e,arguments.length>1?arguments[1]:void 0);return Xx(this,t)}));var $x=Dp.find,Zx=eN.aTypedArray;(0,eN.exportTypedArrayMethod)("find",(function(e){return $x(Zx(this),e,arguments.length>1?arguments[1]:void 0)}));var eO=Dp.findIndex,tO=eN.aTypedArray;(0,eN.exportTypedArrayMethod)("findIndex",(function(e){return eO(tO(this),e,arguments.length>1?arguments[1]:void 0)}));var nO=Dp.forEach,rO=eN.aTypedArray;(0,eN.exportTypedArrayMethod)("forEach",(function(e){nO(rO(this),e,arguments.length>1?arguments[1]:void 0)}));var iO=Ji.includes,oO=eN.aTypedArray;(0,eN.exportTypedArrayMethod)("includes",(function(e){return iO(oO(this),e,arguments.length>1?arguments[1]:void 0)}));var aO=Ji.indexOf,sO=eN.aTypedArray;(0,eN.exportTypedArrayMethod)("indexOf",(function(e){return aO(sO(this),e,arguments.length>1?arguments[1]:void 0)}));var cO=Af,uO=R,lO=Y,dO=eN,hO=Ts,fO=Mf("iterator"),pO=cO.Uint8Array,mO=lO(hO.values),vO=lO(hO.keys),_O=lO(hO.entries),gO=dO.aTypedArray,yO=dO.exportTypedArrayMethod,EO=pO&&pO.prototype,TO=!uO((function(){EO[fO].call([1])})),kO=!!EO&&EO.values&&EO[fO]===EO.values&&"values"===EO.values.name,SO=function(){return mO(gO(this))};yO("entries",(function(){return _O(gO(this))}),TO),yO("keys",(function(){return vO(gO(this))}),TO),yO("values",SO,TO||!kO,{name:"values"}),yO(fO,SO,TO||!kO,{name:"values"});var IO=eN.aTypedArray,bO=eN.exportTypedArrayMethod,AO=Y([].join);bO("join",(function(e){return AO(IO(this),e)}));var RO=Iu,CO=hg,wO=eN.aTypedArray;(0,eN.exportTypedArrayMethod)("lastIndexOf",(function(e){var t=arguments.length;return RO(CO,wO(this),t>1?[e,arguments[1]]:[e])}));var DO=Dp.map,NO=zx,xO=eN.aTypedArray;(0,eN.exportTypedArrayMethod)("map",(function(e){return DO(xO(this),e,arguments.length>1?arguments[1]:void 0,(function(e,t){return new(NO(e))(t)}))}));var OO=Tg.left,PO=eN.aTypedArray;(0,eN.exportTypedArrayMethod)("reduce",(function(e){var t=arguments.length;return OO(PO(this),e,t,t>1?arguments[1]:void 0)}));var MO=Tg.right,LO=eN.aTypedArray;(0,eN.exportTypedArrayMethod)("reduceRight",(function(e){var t=arguments.length;return MO(LO(this),e,t,t>1?arguments[1]:void 0)}));var UO=eN.aTypedArray,VO=eN.exportTypedArrayMethod,FO=Math.floor;VO("reverse",(function(){for(var e,t=this,n=UO(t).length,r=FO(n/2),i=0;i<r;)e=t[i],t[i++]=t[--n],t[n]=e;return t}));var BO=Dp.some,jO=eN.aTypedArray;(0,eN.exportTypedArrayMethod)("some",(function(e){return BO(jO(this),e,arguments.length>1?arguments[1]:void 0)}));var HO=Bi,GO=R,WO=ce,JO=jg,zO=Gg,KO=Wg,qO=Hr,YO=zg,XO=eN.aTypedArray,QO=eN.exportTypedArrayMethod,$O=Af.Uint16Array,ZO=$O&&HO($O.prototype.sort),eP=!(!ZO||GO((function(){ZO(new $O(2),null)}))&&GO((function(){ZO(new $O(2),{})}))),tP=!!ZO&&!GO((function(){if(qO)return qO<74;if(zO)return zO<67;if(KO)return!0;if(YO)return YO<602;var e,t,n=new $O(516),r=Array(516);for(e=0;e<516;e++)t=e%4,n[e]=515-e,r[e]=e-2*t+3;for(ZO(n,(function(e,t){return(e/4|0)-(t/4|0)})),e=0;e<516;e++)if(n[e]!==r[e])return!0}));QO("sort",(function(e){return void 0!==e&&WO(e),tP?ZO(this,e):JO(XO(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))}),!tP||eP);var nP=mt,rP=ht,iP=zx,oP=eN.aTypedArray;(0,eN.exportTypedArrayMethod)("subarray",(function(e,t){var n=oP(this),r=n.length,i=rP(e,r);return new(iP(n))(n.buffer,n.byteOffset+i*n.BYTES_PER_ELEMENT,nP((void 0===t?r:rP(t,r))-i))}));var aP=Iu,sP=eN,cP=R,uP=si,lP=Af.Int8Array,dP=sP.aTypedArray,hP=sP.exportTypedArrayMethod,fP=[].toLocaleString,pP=!!lP&&cP((function(){fP.call(new lP(1))}));hP("toLocaleString",(function(){return aP(fP,pP?uP(dP(this)):dP(this),uP(arguments))}),cP((function(){return[1,2].toLocaleString()!==new lP([1,2]).toLocaleString()}))||!cP((function(){lP.prototype.toLocaleString.call([1,2])})));var mP=eN.exportTypedArrayMethod,vP=R,_P=Y,gP=Af.Uint8Array,yP=gP&&gP.prototype||{},EP=[].toString,TP=_P([].join);vP((function(){EP.call({})}))&&(EP=function(){return TP(this)});var kP=yP.toString!==EP;mP("toString",EP,kP);var SP=zx,IP=si,bP=eN.aTypedArray;(0,eN.exportTypedArrayMethod)("slice",(function(e,t){for(var n=IP(bP(this),e,t),r=SP(this),i=0,o=n.length,a=new r(o);o>i;)a[i]=n[i++];return a}),R((function(){new Int8Array(1).slice()})));var AP=Af,RP=ki,CP=eN,wP=_t,DP=hN,NP=me,xP=R,OP=AP.RangeError,PP=AP.Int8Array,MP=PP&&PP.prototype,LP=MP&&MP.set,UP=CP.aTypedArray,VP=CP.exportTypedArrayMethod,FP=!xP((function(){var e=new Uint8ClampedArray(2);return RP(LP,e,{length:1,0:3},1),3!==e[1]})),BP=FP&&CP.NATIVE_ARRAY_BUFFER_VIEWS&&xP((function(){var e=new PP(2);return e.set(1),e.set("2",1),0!==e[0]||2!==e[1]}));VP("set",(function(e){UP(this);var t=DP(arguments.length>1?arguments[1]:void 0,1),n=NP(e);if(FP)return RP(LP,this,n,t);var r=this.length,i=wP(n),o=0;if(i+t>r)throw new OP("Wrong length");for(;o<i;)this[t+o]=n[o++]}),!FP||BP);var jP=Wv,HP=_N,GP=be,WP=ki,JP=R,zP=eN.aTypedArray,KP=eN.exportTypedArrayMethod,qP=Y("".slice);KP("fill",(function(e){var t=arguments.length;zP(this);var n="Big"===qP(GP(this),0,3)?HP(e):+e;return WP(jP,this,n,t>1?arguments[1]:void 0,t>2?arguments[2]:void 0)}),JP((function(){var e=0;return new Int8Array(2).fill({valueOf:function(){return e++}}),1!==e}))),(0,eN.exportTypedArrayStaticMethod)("from",wN,sN);var YP=Sf,XP=R,QP=x,$P=Jc,ZP=uk,eM=Object.isFrozen;YP({target:"Object",stat:!0,forced:ZP||XP((function(){eM(1)}))},{isFrozen:function(e){return!QP(e)||(!(!ZP||"ArrayBuffer"!==$P(e))||!!eM&&eM(e))}});var tM=Sf,nM=R,rM=x,iM=Jc,oM=uk,aM=Object.isSealed;tM({target:"Object",stat:!0,forced:oM||nM((function(){aM(1)}))},{isSealed:function(e){return!rM(e)||(!(!oM||"ArrayBuffer"!==iM(e))||!!aM&&aM(e))}});var sM=Sf,cM=x,uM=ak.onFreeze,lM=kk,dM=R,hM=Object.seal;sM({target:"Object",stat:!0,forced:dM((function(){hM(1)})),sham:!lM},{seal:function(e){return hM&&cM(e)?hM(uM(e)):e}});var fM=Y,pM=qy,mM=ak.getWeakData,vM=Qy,_M=G,gM=ue,yM=x,EM=Qk,TM=ge,kM=cn.set,SM=cn.getterFor,IM=Dp.find,bM=Dp.findIndex,AM=fM([].splice),RM=0,CM=function(e){return e.frozen||(e.frozen=new wM)},wM=function(){this.entries=[]},DM=function(e,t){return IM(e.entries,(function(e){return e[0]===t}))};wM.prototype={get:function(e){var t=DM(this,e);if(t)return t[1]},has:function(e){return!!DM(this,e)},set:function(e,t){var n=DM(this,e);n?n[1]=t:this.entries.push([e,t])},delete:function(e){var t=bM(this.entries,(function(t){return t[0]===e}));return~t&&AM(this.entries,t,1),!!~t}};var NM,xM={getConstructor:function(e,t,n,r){var i=e((function(e,i){vM(e,o),kM(e,{type:t,id:RM++,frozen:null}),gM(i)||EM(i,e[r],{that:e,AS_ENTRIES:n})})),o=i.prototype,a=SM(t),s=function(e,t,n){var r=a(e),i=mM(_M(t),!0);return!0===i?CM(r).set(t,n):i[r.id]=n,e};return pM(o,{delete:function(e){var t=a(this);if(!yM(e))return!1;var n=mM(e);return!0===n?CM(t).delete(e):n&&TM(n,t.id)&&delete n[t.id]},has:function(e){var t=a(this);if(!yM(e))return!1;var n=mM(e);return!0===n?CM(t).has(e):n&&TM(n,t.id)}}),pM(o,n?{get:function(e){var t=a(this);if(yM(e)){var n=mM(e);if(!0===n)return CM(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}},OM=kk,PM=Af,MM=Y,LM=qy,UM=ak,VM=fS,FM=xM,BM=x,jM=cn.enforce,HM=R,GM=Ot,WM=Object,JM=Array.isArray,zM=WM.isExtensible,KM=WM.isFrozen,qM=WM.isSealed,YM=WM.freeze,XM=WM.seal,QM=!PM.ActiveXObject&&"ActiveXObject"in PM,$M=function(e){return function(){return e(this,arguments.length?arguments[0]:void 0)}},ZM=VM("WeakMap",$M,FM),eL=ZM.prototype,tL=MM(eL.set);if(GM)if(QM){NM=FM.getConstructor($M,"WeakMap",!0),UM.enable();var nL=MM(eL.delete),rL=MM(eL.has),iL=MM(eL.get);LM(eL,{delete:function(e){if(BM(e)&&!zM(e)){var t=jM(this);return t.frozen||(t.frozen=new NM),nL(this,e)||t.frozen.delete(e)}return nL(this,e)},has:function(e){if(BM(e)&&!zM(e)){var t=jM(this);return t.frozen||(t.frozen=new NM),rL(this,e)||t.frozen.has(e)}return rL(this,e)},get:function(e){if(BM(e)&&!zM(e)){var t=jM(this);return t.frozen||(t.frozen=new NM),rL(this,e)?iL(this,e):t.frozen.get(e)}return iL(this,e)},set:function(e,t){if(BM(e)&&!zM(e)){var n=jM(this);n.frozen||(n.frozen=new NM),rL(this,e)?tL(this,e,t):n.frozen.set(e,t)}else tL(this,e,t);return this}})}else OM&&HM((function(){var e=YM([]);return tL(new ZM,e,1),!KM(e)}))&&LM(eL,{set:function(e,t){var n;return JM(e)&&(KM(e)?n=YM:qM(e)&&(n=XM)),tL(this,e,t),n&&n(e),this}});var oL=Sf,aL=Af,sL=VA,cL=Ce,uL=ki,lL=Y,dL=vc,hL=wU,fL=Hn,pL=Cn,mL=qy,vL=Wo,_L=Na,gL=cn,yL=Qy,EL=D,TL=ge,kL=kp,SL=be,IL=G,bL=x,AL=er,RL=wo,CL=gt,wL=b_,DL=g_,NL=us,xL=Bb,OL=jg,PL=Mf("iterator"),ML="URLSearchParams",LL=ML+"Iterator",UL=gL.set,VL=gL.getterFor(ML),FL=gL.getterFor(LL),BL=sL("fetch"),jL=sL("Request"),HL=sL("Headers"),GL=jL&&jL.prototype,WL=HL&&HL.prototype,JL=aL.TypeError,zL=aL.encodeURIComponent,KL=String.fromCharCode,qL=cL("String","fromCodePoint"),YL=parseInt,XL=lL("".charAt),QL=lL([].join),$L=lL([].push),ZL=lL("".replace),eU=lL([].shift),tU=lL([].splice),nU=lL("".split),rU=lL("".slice),iU=lL(/./.exec),oU=/\+/g,aU=/^[0-9a-f]+$/i,sU=function(e,t){var n=rU(e,t,t+2);return iU(aU,n)?YL(n,16):NaN},cU=function(e){for(var t=0,n=128;n>0&&e&n;n>>=1)t++;return t},uU=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},lU=function(e){for(var t=(e=ZL(e,oU," ")).length,n="",r=0;r<t;){var i=XL(e,r);if("%"===i){if("%"===XL(e,r+1)||r+3>t){n+="%",r++;continue}var o=sU(e,r+1);if(o!=o){n+=i,r++;continue}r+=2;var a=cU(o);if(0===a)i=KL(o);else{if(1===a||a>4){n+="�",r++;continue}for(var s=[o],c=1;c<a&&!(++r+3>t||"%"!==XL(e,r));){var u=sU(e,r+1);if(u!=u){r+=3;break}if(u>191||u<128)break;$L(s,u),r+=2,c++}if(s.length!==a){n+="�";continue}var l=uU(s);null===l?n+="�":i=qL(l)}}n+=i,r++}return n},dU=/[!'()~]|%20/g,hU={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+"},fU=function(e){return hU[e]},pU=function(e){return ZL(zL(e),dU,fU)},mU=_L((function(e,t){UL(this,{type:LL,target:VL(e).entries,index:0,kind:t})}),ML,(function(){var e=FL(this),t=e.target,n=e.index++;if(!t||n>=t.length)return e.target=null,NL(void 0,!0);var r=t[n];switch(e.kind){case"keys":return NL(r.key,!1);case"values":return NL(r.value,!1)}return NL([r.key,r.value],!1)}),!0),vU=function(e){this.entries=[],this.url=null,void 0!==e&&(bL(e)?this.parseObject(e):this.parseQuery("string"==typeof e?"?"===XL(e,0)?rU(e,1):e:AL(e)))};vU.prototype={type:ML,bindURL:function(e){this.url=e,this.update()},parseObject:function(e){var t,n,r,i,o,a,s,c=this.entries,u=DL(e);if(u)for(n=(t=wL(e,u)).next;!(r=uL(n,t)).done;){if(o=(i=wL(IL(r.value))).next,(a=uL(o,i)).done||(s=uL(o,i)).done||!uL(o,i).done)throw new JL("Expected sequence with length 2");$L(c,{key:AL(a.value),value:AL(s.value)})}else for(var l in e)TL(e,l)&&$L(c,{key:l,value:AL(e[l])})},parseQuery:function(e){if(e)for(var t,n,r=this.entries,i=nU(e,"&"),o=0;o<i.length;)(t=i[o++]).length&&(n=nU(t,"="),$L(r,{key:lU(eU(n)),value:lU(QL(n,"="))}))},serialize:function(){for(var e,t=this.entries,n=[],r=0;r<t.length;)e=t[r++],$L(n,pU(e.key)+"="+pU(e.value));return QL(n,"&")},update:function(){this.entries.length=0,this.parseQuery(this.url.query)},updateURL:function(){this.url&&this.url.update()}};var _U=function(){yL(this,gU);var e=UL(this,new vU(arguments.length>0?arguments[0]:void 0));dL||(this.size=e.entries.length)},gU=_U.prototype;if(mL(gU,{append:function(e,t){var n=VL(this);xL(arguments.length,2),$L(n.entries,{key:AL(e),value:AL(t)}),dL||this.length++,n.updateURL()},delete:function(e){for(var t=VL(this),n=xL(arguments.length,1),r=t.entries,i=AL(e),o=n<2?void 0:arguments[1],a=void 0===o?o:AL(o),s=0;s<r.length;){var c=r[s];if(c.key!==i||void 0!==a&&c.value!==a)s++;else if(tU(r,s,1),void 0!==a)break}dL||(this.size=r.length),t.updateURL()},get:function(e){var t=VL(this).entries;xL(arguments.length,1);for(var n=AL(e),r=0;r<t.length;r++)if(t[r].key===n)return t[r].value;return null},getAll:function(e){var t=VL(this).entries;xL(arguments.length,1);for(var n=AL(e),r=[],i=0;i<t.length;i++)t[i].key===n&&$L(r,t[i].value);return r},has:function(e){for(var t=VL(this).entries,n=xL(arguments.length,1),r=AL(e),i=n<2?void 0:arguments[1],o=void 0===i?i:AL(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=VL(this);xL(arguments.length,1);for(var r,i=n.entries,o=!1,a=AL(e),s=AL(t),c=0;c<i.length;c++)(r=i[c]).key===a&&(o?tU(i,c--,1):(o=!0,r.value=s));o||$L(i,{key:a,value:s}),dL||(this.size=i.length),n.updateURL()},sort:function(){var e=VL(this);OL(e.entries,(function(e,t){return e.key>t.key?1:-1})),e.updateURL()},forEach:function(e){for(var t,n=VL(this).entries,r=kL(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 mU(this,"keys")},values:function(){return new mU(this,"values")},entries:function(){return new mU(this,"entries")}},{enumerable:!0}),fL(gU,PL,gU.entries,{name:"entries"}),fL(gU,"toString",(function(){return VL(this).serialize()}),{enumerable:!0}),dL&&pL(gU,"size",{get:function(){return VL(this).entries.length},configurable:!0,enumerable:!0}),vL(_U,ML),oL({global:!0,constructor:!0,forced:!hL},{URLSearchParams:_U}),!hL&&EL(HL)){var yU=lL(WL.has),EU=lL(WL.set),TU=function(e){if(bL(e)){var t,n=e.body;if(SL(n)===ML)return t=e.headers?new HL(e.headers):new HL,yU(t,"content-type")||EU(t,"content-type","application/x-www-form-urlencoded;charset=UTF-8"),RL(e,{body:CL(0,AL(n)),headers:CL(0,t)})}return e};if(EL(BL)&&oL({global:!0,enumerable:!0,dontCallGetSet:!0,forced:!0},{fetch:function(e){return BL(e,arguments.length>1?TU(arguments[1]):{})}}),EL(jL)){var kU=function(e){return yL(this,GL),new jL(e,arguments.length>1?TU(arguments[1]):{})};GL.constructor=kU,kU.prototype=GL,oL({global:!0,constructor:!0,dontCallGetSet:!0,forced:!0},{Request:kU})}}var SU={URLSearchParams:_U,getState:VL},IU=ki;Sf({target:"URL",proto:!0,enumerable:!0},{toJSON:function(){return IU(URL.prototype.toString,this)}});var bU,AU=R,RU=vc,CU=Mf("iterator"),wU=!AU((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&&!RU||!t.sort||"https://a/c%20d?a=1&c=3"!==e.href||"3"!==t.get("c")||"a=1"!==String(new URLSearchParams("?a=1"))||!t[CU]||"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})),DU=Y,NU=2147483647,xU=/[^\0-\u007E]/,OU=/[.\u3002\uFF0E\uFF61]/g,PU="Overflow: input needs wider integers to process",MU=RangeError,LU=DU(OU.exec),UU=Math.floor,VU=String.fromCharCode,FU=DU("".charCodeAt),BU=DU([].join),jU=DU([].push),HU=DU("".replace),GU=DU("".split),WU=DU("".toLowerCase),JU=function(e){return e+22+75*(e<26)},zU=function(e,t,n){var r=0;for(e=n?UU(e/700):e>>1,e+=UU(e/t);e>455;)e=UU(e/35),r+=36;return UU(r+36*e/(e+38))},KU=function(e){var t=[];e=function(e){for(var t=[],n=0,r=e.length;n<r;){var i=FU(e,n++);if(i>=55296&&i<=56319&&n<r){var o=FU(e,n++);56320==(64512&o)?jU(t,((1023&i)<<10)+(1023&o)+65536):(jU(t,i),n--)}else jU(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&&jU(t,VU(r));var c=t.length,u=c;for(c&&jU(t,"-");u<i;){var l=NU;for(n=0;n<e.length;n++)(r=e[n])>=o&&r<l&&(l=r);var d=u+1;if(l-o>UU((NU-a)/d))throw new MU(PU);for(a+=(l-o)*d,o=l,n=0;n<e.length;n++){if((r=e[n])<o&&++a>NU)throw new MU(PU);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;jU(t,VU(JU(p+m%v))),h=UU(m/v),f+=36}jU(t,VU(JU(h))),s=zU(a,d,u===c),a=0,u++}}a++,o++}return BU(t,"")},qU=Sf,YU=vc,XU=wU,QU=Af,$U=kp,ZU=Y,eV=Hn,tV=Cn,nV=Qy,rV=ge,iV=ab,oV=U_,aV=si,sV=hr.codeAt,cV=function(e){var t,n,r=[],i=GU(HU(WU(e),OU,"."),".");for(t=0;t<i.length;t++)n=i[t],jU(r,LU(xU,n)?"xn--"+KU(n):n);return BU(r,".")},uV=er,lV=Wo,dV=Bb,hV=SU,fV=cn,pV=fV.set,mV=fV.getterFor("URL"),vV=hV.URLSearchParams,_V=hV.getState,gV=QU.URL,yV=QU.TypeError,EV=QU.parseInt,TV=Math.floor,kV=Math.pow,SV=ZU("".charAt),IV=ZU(/./.exec),bV=ZU([].join),AV=ZU(1..toString),RV=ZU([].pop),CV=ZU([].push),wV=ZU("".replace),DV=ZU([].shift),NV=ZU("".split),xV=ZU("".slice),OV=ZU("".toLowerCase),PV=ZU([].unshift),MV="Invalid scheme",LV="Invalid host",UV="Invalid port",VV=/[a-z]/i,FV=/[\d+-.a-z]/i,BV=/\d/,jV=/^0x/i,HV=/^[0-7]+$/,GV=/^\d+$/,WV=/^[\da-f]+$/i,JV=/[\0\t\n\r #%/:<>?@[\\\]^|]/,zV=/[\0\t\n\r #/:<>?@[\\\]^|]/,KV=/^[\u0000-\u0020]+/,qV=/(^|[^\u0000-\u0020])[\u0000-\u0020]+$/,YV=/[\t\n\r]/g,XV=function(e){var t,n,r,i;if("number"==typeof e){for(t=[],n=0;n<4;n++)PV(t,e%256),e=TV(e/256);return bV(t,".")}if("object"==k(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+=AV(e[n],16),n<7&&(t+=":")));return"["+t+"]"}return e},QV={},$V=iV({},QV,{" ":1,'"':1,"<":1,">":1,"`":1}),ZV=iV({},$V,{"#":1,"?":1,"{":1,"}":1}),eF=iV({},ZV,{"/":1,":":1,";":1,"=":1,"@":1,"[":1,"\\":1,"]":1,"^":1,"|":1}),tF=function(e,t){var n=sV(e,0);return n>32&&n<127&&!rV(t,e)?e:encodeURIComponent(e)},nF={ftp:21,file:null,http:80,https:443,ws:80,wss:443},rF=function(e,t){var n;return 2===e.length&&IV(VV,SV(e,0))&&(":"===(n=SV(e,1))||!t&&"|"===n)},iF=function(e){var t;return e.length>1&&rF(xV(e,0,2))&&(2===e.length||"/"===(t=SV(e,2))||"\\"===t||"?"===t||"#"===t)},oF=function(e){return"."===e||"%2e"===OV(e)},aF={},sF={},cF={},uF={},lF={},dF={},hF={},fF={},pF={},mF={},vF={},_F={},gF={},yF={},EF={},TF={},kF={},SF={},IF={},bF={},AF={},RF=function(e,t,n){var r,i,o,a=uV(e);if(t){if(i=this.parse(a))throw new yV(i);this.searchParams=null}else{if(void 0!==n&&(r=new RF(n,!0)),i=this.parse(a,null,r))throw new yV(i);(o=_V(new vV)).bindURL(this),this.searchParams=o}};RF.prototype={type:"URL",parse:function(e,t,n){var r,i,o,a,s,c=this,u=t||aF,l=0,d="",h=!1,f=!1,p=!1;for(e=uV(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=wV(e,KV,""),e=wV(e,qV,"$1")),e=wV(e,YV,""),r=oV(e);l<=r.length;){switch(i=r[l],u){case aF:if(!i||!IV(VV,i)){if(t)return MV;u=cF;continue}d+=OV(i),u=sF;break;case sF:if(i&&(IV(FV,i)||"+"===i||"-"===i||"."===i))d+=OV(i);else{if(":"!==i){if(t)return MV;d="",u=cF,l=0;continue}if(t&&(c.isSpecial()!==rV(nF,d)||"file"===d&&(c.includesCredentials()||null!==c.port)||"file"===c.scheme&&!c.host))return;if(c.scheme=d,t)return void(c.isSpecial()&&nF[c.scheme]===c.port&&(c.port=null));d="","file"===c.scheme?u=yF:c.isSpecial()&&n&&n.scheme===c.scheme?u=uF:c.isSpecial()?u=fF:"/"===r[l+1]?(u=lF,l++):(c.cannotBeABaseURL=!0,CV(c.path,""),u=IF)}break;case cF:if(!n||n.cannotBeABaseURL&&"#"!==i)return MV;if(n.cannotBeABaseURL&&"#"===i){c.scheme=n.scheme,c.path=aV(n.path),c.query=n.query,c.fragment="",c.cannotBeABaseURL=!0,u=AF;break}u="file"===n.scheme?yF:dF;continue;case uF:if("/"!==i||"/"!==r[l+1]){u=dF;continue}u=pF,l++;break;case lF:if("/"===i){u=mF;break}u=SF;continue;case dF:if(c.scheme=n.scheme,i===bU)c.username=n.username,c.password=n.password,c.host=n.host,c.port=n.port,c.path=aV(n.path),c.query=n.query;else if("/"===i||"\\"===i&&c.isSpecial())u=hF;else if("?"===i)c.username=n.username,c.password=n.password,c.host=n.host,c.port=n.port,c.path=aV(n.path),c.query="",u=bF;else{if("#"!==i){c.username=n.username,c.password=n.password,c.host=n.host,c.port=n.port,c.path=aV(n.path),c.path.length--,u=SF;continue}c.username=n.username,c.password=n.password,c.host=n.host,c.port=n.port,c.path=aV(n.path),c.query=n.query,c.fragment="",u=AF}break;case hF:if(!c.isSpecial()||"/"!==i&&"\\"!==i){if("/"!==i){c.username=n.username,c.password=n.password,c.host=n.host,c.port=n.port,u=SF;continue}u=mF}else u=pF;break;case fF:if(u=pF,"/"!==i||"/"!==SV(d,l+1))continue;l++;break;case pF:if("/"!==i&&"\\"!==i){u=mF;continue}break;case mF:if("@"===i){h&&(d="%40"+d),h=!0,o=oV(d);for(var m=0;m<o.length;m++){var v=o[m];if(":"!==v||p){var _=tF(v,eF);p?c.password+=_:c.username+=_}else p=!0}d=""}else if(i===bU||"/"===i||"?"===i||"#"===i||"\\"===i&&c.isSpecial()){if(h&&""===d)return"Invalid authority";l-=oV(d).length+1,d="",u=vF}else d+=i;break;case vF:case _F:if(t&&"file"===c.scheme){u=TF;continue}if(":"!==i||f){if(i===bU||"/"===i||"?"===i||"#"===i||"\\"===i&&c.isSpecial()){if(c.isSpecial()&&""===d)return LV;if(t&&""===d&&(c.includesCredentials()||null!==c.port))return;if(a=c.parseHost(d))return a;if(d="",u=kF,t)return;continue}"["===i?f=!0:"]"===i&&(f=!1),d+=i}else{if(""===d)return LV;if(a=c.parseHost(d))return a;if(d="",u=gF,t===_F)return}break;case gF:if(!IV(BV,i)){if(i===bU||"/"===i||"?"===i||"#"===i||"\\"===i&&c.isSpecial()||t){if(""!==d){var g=EV(d,10);if(g>65535)return UV;c.port=c.isSpecial()&&g===nF[c.scheme]?null:g,d=""}if(t)return;u=kF;continue}return UV}d+=i;break;case yF:if(c.scheme="file","/"===i||"\\"===i)u=EF;else{if(!n||"file"!==n.scheme){u=SF;continue}switch(i){case bU:c.host=n.host,c.path=aV(n.path),c.query=n.query;break;case"?":c.host=n.host,c.path=aV(n.path),c.query="",u=bF;break;case"#":c.host=n.host,c.path=aV(n.path),c.query=n.query,c.fragment="",u=AF;break;default:iF(bV(aV(r,l),""))||(c.host=n.host,c.path=aV(n.path),c.shortenPath()),u=SF;continue}}break;case EF:if("/"===i||"\\"===i){u=TF;break}n&&"file"===n.scheme&&!iF(bV(aV(r,l),""))&&(rF(n.path[0],!0)?CV(c.path,n.path[0]):c.host=n.host),u=SF;continue;case TF:if(i===bU||"/"===i||"\\"===i||"?"===i||"#"===i){if(!t&&rF(d))u=SF;else if(""===d){if(c.host="",t)return;u=kF}else{if(a=c.parseHost(d))return a;if("localhost"===c.host&&(c.host=""),t)return;d="",u=kF}continue}d+=i;break;case kF:if(c.isSpecial()){if(u=SF,"/"!==i&&"\\"!==i)continue}else if(t||"?"!==i)if(t||"#"!==i){if(i!==bU&&(u=SF,"/"!==i))continue}else c.fragment="",u=AF;else c.query="",u=bF;break;case SF:if(i===bU||"/"===i||"\\"===i&&c.isSpecial()||!t&&("?"===i||"#"===i)){if(".."===(s=OV(s=d))||"%2e."===s||".%2e"===s||"%2e%2e"===s?(c.shortenPath(),"/"===i||"\\"===i&&c.isSpecial()||CV(c.path,"")):oF(d)?"/"===i||"\\"===i&&c.isSpecial()||CV(c.path,""):("file"===c.scheme&&!c.path.length&&rF(d)&&(c.host&&(c.host=""),d=SV(d,0)+":"),CV(c.path,d)),d="","file"===c.scheme&&(i===bU||"?"===i||"#"===i))for(;c.path.length>1&&""===c.path[0];)DV(c.path);"?"===i?(c.query="",u=bF):"#"===i&&(c.fragment="",u=AF)}else d+=tF(i,ZV);break;case IF:"?"===i?(c.query="",u=bF):"#"===i?(c.fragment="",u=AF):i!==bU&&(c.path[0]+=tF(i,QV));break;case bF:t||"#"!==i?i!==bU&&("'"===i&&c.isSpecial()?c.query+="%27":c.query+="#"===i?"%23":tF(i,QV)):(c.fragment="",u=AF);break;case AF:i!==bU&&(c.fragment+=tF(i,$V))}l++}},parseHost:function(e){var t,n,r;if("["===SV(e,0)){if("]"!==SV(e,e.length-1))return LV;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 SV(e,d)};if(":"===h()){if(":"!==SV(e,1))return;d+=2,l=++u}for(;h();){if(8===u)return;if(":"!==h()){for(t=n=0;n<4&&IV(WV,h());)t=16*t+EV(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(!IV(BV,h()))return;for(;IV(BV,h());){if(o=EV(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}(xV(e,1,-1)),!t)return LV;this.host=t}else if(this.isSpecial()){if(e=cV(e),IV(JV,e))return LV;if(t=function(e){var t,n,r,i,o,a,s,c=NV(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"===SV(i,0)&&(o=IV(jV,i)?16:8,i=xV(i,8===o?1:2)),""===i)a=0;else{if(!IV(10===o?GV:8===o?HV:WV,i))return e;a=EV(i,o)}CV(n,a)}for(r=0;r<t;r++)if(a=n[r],r===t-1){if(a>=kV(256,5-t))return null}else if(a>255)return null;for(s=RV(n),r=0;r<n.length;r++)s+=n[r]*kV(256,3-r);return s}(e),null===t)return LV;this.host=t}else{if(IV(zV,e))return LV;for(t="",n=oV(e),r=0;r<n.length;r++)t+=tF(n[r],QV);this.host=t}},cannotHaveUsernamePasswordPort:function(){return!this.host||this.cannotBeABaseURL||"file"===this.scheme},includesCredentials:function(){return""!==this.username||""!==this.password},isSpecial:function(){return rV(nF,this.scheme)},shortenPath:function(){var e=this.path,t=e.length;!t||"file"===this.scheme&&1===t&&rF(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+=XV(i),null!==o&&(u+=":"+o)):"file"===t&&(u+="//"),u+=e.cannotBeABaseURL?a[0]:a.length?"/"+bV(a,"/"):"",null!==s&&(u+="?"+s),null!==c&&(u+="#"+c),u},setHref:function(e){var t=this.parse(e);if(t)throw new yV(t);this.searchParams.update()},getOrigin:function(){var e=this.scheme,t=this.port;if("blob"===e)try{return new CF(e.path[0]).origin}catch(PF){return"null"}return"file"!==e&&this.isSpecial()?e+"://"+XV(this.host)+(null!==t?":"+t:""):"null"},getProtocol:function(){return this.scheme+":"},setProtocol:function(e){this.parse(uV(e)+":",aF)},getUsername:function(){return this.username},setUsername:function(e){var t=oV(uV(e));if(!this.cannotHaveUsernamePasswordPort()){this.username="";for(var n=0;n<t.length;n++)this.username+=tF(t[n],eF)}},getPassword:function(){return this.password},setPassword:function(e){var t=oV(uV(e));if(!this.cannotHaveUsernamePasswordPort()){this.password="";for(var n=0;n<t.length;n++)this.password+=tF(t[n],eF)}},getHost:function(){var e=this.host,t=this.port;return null===e?"":null===t?XV(e):XV(e)+":"+t},setHost:function(e){this.cannotBeABaseURL||this.parse(e,vF)},getHostname:function(){var e=this.host;return null===e?"":XV(e)},setHostname:function(e){this.cannotBeABaseURL||this.parse(e,_F)},getPort:function(){var e=this.port;return null===e?"":uV(e)},setPort:function(e){this.cannotHaveUsernamePasswordPort()||(""===(e=uV(e))?this.port=null:this.parse(e,gF))},getPathname:function(){var e=this.path;return this.cannotBeABaseURL?e[0]:e.length?"/"+bV(e,"/"):""},setPathname:function(e){this.cannotBeABaseURL||(this.path=[],this.parse(e,kF))},getSearch:function(){var e=this.query;return e?"?"+e:""},setSearch:function(e){""===(e=uV(e))?this.query=null:("?"===SV(e,0)&&(e=xV(e,1)),this.query="",this.parse(e,bF)),this.searchParams.update()},getSearchParams:function(){return this.searchParams.facade},getHash:function(){var e=this.fragment;return e?"#"+e:""},setHash:function(e){""!==(e=uV(e))?("#"===SV(e,0)&&(e=xV(e,1)),this.fragment="",this.parse(e,AF)):this.fragment=null},update:function(){this.query=this.searchParams.serialize()||null}};var CF=function(e){var t=nV(this,wF),n=dV(arguments.length,1)>1?arguments[1]:void 0,r=pV(t,new RF(e,!1,n));YU||(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())},wF=CF.prototype,DF=function(e,t){return{get:function(){return mV(this)[e]()},set:t&&function(e){return mV(this)[t](e)},configurable:!0,enumerable:!0}};if(YU&&(tV(wF,"href",DF("serialize","setHref")),tV(wF,"origin",DF("getOrigin")),tV(wF,"protocol",DF("getProtocol","setProtocol")),tV(wF,"username",DF("getUsername","setUsername")),tV(wF,"password",DF("getPassword","setPassword")),tV(wF,"host",DF("getHost","setHost")),tV(wF,"hostname",DF("getHostname","setHostname")),tV(wF,"port",DF("getPort","setPort")),tV(wF,"pathname",DF("getPathname","setPathname")),tV(wF,"search",DF("getSearch","setSearch")),tV(wF,"searchParams",DF("getSearchParams")),tV(wF,"hash",DF("getHash","setHash"))),eV(wF,"toJSON",(function(){return mV(this).serialize()}),{enumerable:!0}),eV(wF,"toString",(function(){return mV(this).serialize()}),{enumerable:!0}),gV){var NF=gV.createObjectURL,xF=gV.revokeObjectURL;NF&&eV(CF,"createObjectURL",$U(NF,gV)),xF&&eV(CF,"revokeObjectURL",$U(xF,gV))}lV(CF,"URL"),qU({global:!0,constructor:!0,forced:!XU,sham:!YU},{URL:CF});var OF={};return function(e){e.exports=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)}var o="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:void 0!==b?b:"undefined"!=typeof self?self:{},u=function(e){return e&&e.Math===Math&&e},l=u("object"==("undefined"==typeof globalThis?"undefined":k(globalThis))&&globalThis)||u("object"==("undefined"==typeof window?"undefined":k(window))&&window)||u("object"==("undefined"==typeof self?"undefined":k(self))&&self)||u("object"==k(o)&&o)||u("object"==k(o)&&o)||function(){return this}()||Function("return this")(),h={},p=function(e){try{return!!e()}catch(o){return!0}},m=!p((function(){return 7!==Object.defineProperty({},1,{get:function(){return 7}})[1]})),_=!p((function(){var e=function(){}.bind();return"function"!=typeof e||e.hasOwnProperty("prototype")})),T=_,S=Function.prototype.call,A=T?S.bind(S):function(){return S.apply(S,arguments)},R={},C={}.propertyIsEnumerable,w=Object.getOwnPropertyDescriptor,D=w&&!C.call({1:2},1);R.f=D?function(e){var t=w(this,e);return!!t&&t.enumerable}:C;var N,x,O=function(e,t){return{enumerable:!(1&e),configurable:!(2&e),writable:!(4&e),value:t}},P=_,M=Function.prototype,L=M.call,U=P&&M.bind.bind(L,L),V=P?U:function(e){return function(){return L.apply(e,arguments)}},F=V,B=F({}.toString),j=F("".slice),H=function(e){return j(B(e),8,-1)},G=p,W=H,J=Object,z=V("".split),K=G((function(){return!J("z").propertyIsEnumerable(0)}))?function(e){return"String"===W(e)?z(e,""):J(e)}:J,q=function(e){return null==e},Y=q,X=TypeError,Q=function(e){if(Y(e))throw new X("Can't call method on "+e);return e},$=K,Z=Q,ee=function(e){return $(Z(e))},te="object"==("undefined"==typeof document?"undefined":k(document))&&document.all,ne=void 0===te&&void 0!==te?function(e){return"function"==typeof e||e===te}:function(e){return"function"==typeof e},re=ne,ie=function(e){return"object"==k(e)?null!==e:re(e)},oe=l,ae=ne,se=function(e,t){return arguments.length<2?(n=oe[e],ae(n)?n:void 0):oe[e]&&oe[e][t];var n},ce=V({}.isPrototypeOf),ue=l.navigator,le=ue&&ue.userAgent,de=le?String(le):"",he=l,fe=de,pe=he.process,me=he.Deno,ve=pe&&pe.versions||me&&me.version,_e=ve&&ve.v8;_e&&(x=(N=_e.split("."))[0]>0&&N[0]<4?1:+(N[0]+N[1])),!x&&fe&&(!(N=fe.match(/Edge\/(\d+)/))||N[1]>=74)&&(N=fe.match(/Chrome\/(\d+)/))&&(x=+N[1]);var ge=x,ye=ge,Ee=p,Te=l.String,ke=!!Object.getOwnPropertySymbols&&!Ee((function(){var e=Symbol("symbol detection");return!Te(e)||!(Object(e)instanceof Symbol)||!Symbol.sham&&ye&&ye<41})),Se=ke&&!Symbol.sham&&"symbol"==k(Symbol.iterator),Ie=se,be=ne,Ae=ce,Re=Object,Ce=Se?function(e){return"symbol"==k(e)}:function(e){var t=Ie("Symbol");return be(t)&&Ae(t.prototype,Re(e))},we=String,De=function(e){try{return we(e)}catch(o){return"Object"}},Ne=ne,xe=De,Oe=TypeError,Pe=function(e){if(Ne(e))return e;throw new Oe(xe(e)+" is not a function")},Me=Pe,Le=q,Ue=function(e,t){var n=e[t];return Le(n)?void 0:Me(n)},Ve=A,Fe=ne,Be=ie,je=TypeError,He={},Ge={get exports(){return He},set exports(e){He=e}},We=l,Je=Object.defineProperty,ze=function(e,t){try{Je(We,e,{value:t,configurable:!0,writable:!0})}catch(u){We[e]=t}return t},Ke=l,qe=ze,Ye="__core-js_shared__",Xe=Ge.exports=Ke[Ye]||qe(Ye,{});(Xe.versions||(Xe.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=He,$e=function(e,t){return Qe[e]||(Qe[e]=t||{})},Ze=Q,et=Object,tt=function(e){return et(Ze(e))},nt=tt,rt=V({}.hasOwnProperty),it=Object.hasOwn||function(e,t){return rt(nt(e),t)},ot=V,at=0,st=Math.random(),ct=ot(1..toString),ut=function(e){return"Symbol("+(void 0===e?"":e)+")_"+ct(++at+st,36)},lt=$e,dt=it,ht=ut,ft=ke,pt=Se,mt=l.Symbol,vt=lt("wks"),_t=pt?mt.for||mt:mt&&mt.withoutSetter||ht,gt=function(e){return dt(vt,e)||(vt[e]=ft&&dt(mt,e)?mt[e]:_t("Symbol."+e)),vt[e]},yt=A,Et=ie,Tt=Ce,kt=Ue,St=function(e,t){var n,r;if("string"===t&&Fe(n=e.toString)&&!Be(r=Ve(n,e)))return r;if(Fe(n=e.valueOf)&&!Be(r=Ve(n,e)))return r;if("string"!==t&&Fe(n=e.toString)&&!Be(r=Ve(n,e)))return r;throw new je("Can't convert object to primitive value")},It=TypeError,bt=gt("toPrimitive"),At=function(e,t){if(!Et(e)||Tt(e))return e;var n,r=kt(e,bt);if(r){if(void 0===t&&(t="default"),n=yt(r,e,t),!Et(n)||Tt(n))return n;throw new It("Can't convert object to primitive value")}return void 0===t&&(t="number"),St(e,t)},Rt=At,Ct=Ce,wt=function(e){var t=Rt(e,"string");return Ct(t)?t:t+""},Dt=ie,Nt=l.document,xt=Dt(Nt)&&Dt(Nt.createElement),Ot=function(e){return xt?Nt.createElement(e):{}},Pt=Ot,Mt=!m&&!p((function(){return 7!==Object.defineProperty(Pt("div"),"a",{get:function(){return 7}}).a})),Lt=m,Ut=A,Vt=R,Ft=O,Bt=ee,jt=wt,Ht=it,Gt=Mt,Wt=Object.getOwnPropertyDescriptor;h.f=Lt?Wt:function(e,t){if(e=Bt(e),t=jt(t),Gt)try{return Wt(e,t)}catch(u){}if(Ht(e,t))return Ft(!Ut(Vt.f,e,t),e[t])};var Jt={},zt=m&&p((function(){return 42!==Object.defineProperty((function(){}),"prototype",{value:42,writable:!1}).prototype})),Kt=ie,qt=String,Yt=TypeError,Xt=function(e){if(Kt(e))return e;throw new Yt(qt(e)+" is not an object")},Qt=m,$t=Mt,Zt=zt,en=Xt,tn=wt,nn=TypeError,rn=Object.defineProperty,on=Object.getOwnPropertyDescriptor,an="enumerable",sn="configurable",cn="writable";Jt.f=Qt?Zt?function(e,t,n){if(en(e),t=tn(t),en(n),"function"==typeof e&&"prototype"===t&&"value"in n&&cn in n&&!n[cn]){var r=on(e,t);r&&r[cn]&&(e[t]=n.value,n={configurable:sn in n?n[sn]:r[sn],enumerable:an in n?n[an]:r[an],writable:!1})}return rn(e,t,n)}:rn:function(e,t,n){if(en(e),t=tn(t),en(n),$t)try{return rn(e,t,n)}catch(l){}if("get"in n||"set"in n)throw new nn("Accessors not supported");return"value"in n&&(e[t]=n.value),e};var un=Jt,ln=O,dn=m?function(e,t,n){return un.f(e,t,ln(1,n))}:function(e,t,n){return e[t]=n,e},hn={},fn={get exports(){return hn},set exports(e){hn=e}},pn=m,mn=it,vn=Function.prototype,_n=pn&&Object.getOwnPropertyDescriptor,gn=mn(vn,"name"),yn={EXISTS:gn,PROPER:gn&&"something"===function(){}.name,CONFIGURABLE:gn&&(!pn||pn&&_n(vn,"name").configurable)},En=ne,Tn=He,kn=V(Function.toString);En(Tn.inspectSource)||(Tn.inspectSource=function(e){return kn(e)});var Sn,In,bn,An=Tn.inspectSource,Rn=ne,Cn=l.WeakMap,wn=Rn(Cn)&&/native code/.test(String(Cn)),Dn=ut,Nn=$e("keys"),xn=function(e){return Nn[e]||(Nn[e]=Dn(e))},On={},Pn=wn,Mn=l,Ln=ie,Un=dn,Vn=it,Fn=He,Bn=xn,jn=On,Hn="Object already initialized",Gn=Mn.TypeError,Wn=Mn.WeakMap;if(Pn||Fn.state){var Jn=Fn.state||(Fn.state=new Wn);Jn.get=Jn.get,Jn.has=Jn.has,Jn.set=Jn.set,Sn=function(e,t){if(Jn.has(e))throw new Gn(Hn);return t.facade=e,Jn.set(e,t),t},In=function(e){return Jn.get(e)||{}},bn=function(e){return Jn.has(e)}}else{var zn=Bn("state");jn[zn]=!0,Sn=function(e,t){if(Vn(e,zn))throw new Gn(Hn);return t.facade=e,Un(e,zn,t),t},In=function(e){return Vn(e,zn)?e[zn]:{}},bn=function(e){return Vn(e,zn)}}var Kn={set:Sn,get:In,has:bn,enforce:function(e){return bn(e)?In(e):Sn(e,{})},getterFor:function(e){return function(t){var n;if(!Ln(t)||(n=In(t)).type!==e)throw new Gn("Incompatible receiver, "+e+" required");return n}}},qn=V,Yn=p,Xn=ne,Qn=it,$n=m,Zn=yn.CONFIGURABLE,er=An,tr=Kn.enforce,nr=Kn.get,rr=String,ir=Object.defineProperty,or=qn("".slice),ar=qn("".replace),sr=qn([].join),cr=$n&&!Yn((function(){return 8!==ir((function(){}),"length",{value:8}).length})),ur=String(String).split("String"),lr=fn.exports=function(e,t,n){"Symbol("===or(rr(t),0,7)&&(t="["+ar(rr(t),/^Symbol\(([^)]*)\).*$/,"$1")+"]"),n&&n.getter&&(t="get "+t),n&&n.setter&&(t="set "+t),(!Qn(e,"name")||Zn&&e.name!==t)&&($n?ir(e,"name",{value:t,configurable:!0}):e.name=t),cr&&n&&Qn(n,"arity")&&e.length!==n.arity&&ir(e,"length",{value:n.arity});try{n&&Qn(n,"constructor")&&n.constructor?$n&&ir(e,"prototype",{writable:!1}):e.prototype&&(e.prototype=void 0)}catch(h){}var r=tr(e);return Qn(r,"source")||(r.source=sr(ur,"string"==typeof t?t:"")),e};Function.prototype.toString=lr((function(){return Xn(this)&&nr(this).source||er(this)}),"toString");var dr=ne,hr=Jt,fr=hn,pr=ze,mr=function(e,t,n,r){r||(r={});var i=r.enumerable,o=void 0!==r.name?r.name:t;if(dr(n)&&fr(n,o,r),r.global)i?e[t]=n:pr(t,n);else{try{r.unsafe?e[t]&&(i=!0):delete e[t]}catch(m){}i?e[t]=n:hr.f(e,t,{value:n,enumerable:!1,configurable:!r.nonConfigurable,writable:!r.nonWritable})}return e},vr={},_r=Math.ceil,gr=Math.floor,yr=Math.trunc||function(e){var t=+e;return(t>0?gr:_r)(t)},Er=yr,Tr=function(e){var t=+e;return t!=t||0===t?0:Er(t)},kr=Tr,Sr=Math.max,Ir=Math.min,br=function(e,t){var n=kr(e);return n<0?Sr(n+t,0):Ir(n,t)},Ar=Tr,Rr=Math.min,Cr=function(e){var t=Ar(e);return t>0?Rr(t,9007199254740991):0},wr=Cr,Dr=function(e){return wr(e.length)},Nr=ee,xr=br,Or=Dr,Pr=function(e){return function(t,n,r){var i=Nr(t),o=Or(i);if(0===o)return!e&&-1;var a,s=xr(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}},Mr={includes:Pr(!0),indexOf:Pr(!1)},Lr=it,Ur=ee,Vr=Mr.indexOf,Fr=On,Br=V([].push),jr=function(e,t){var n,r=Ur(e),i=0,o=[];for(n in r)!Lr(Fr,n)&&Lr(r,n)&&Br(o,n);for(;t.length>i;)Lr(r,n=t[i++])&&(~Vr(o,n)||Br(o,n));return o},Hr=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"],Gr=jr,Wr=Hr.concat("length","prototype");vr.f=Object.getOwnPropertyNames||function(e){return Gr(e,Wr)};var Jr={};Jr.f=Object.getOwnPropertySymbols;var zr=se,Kr=vr,qr=Jr,Yr=Xt,Xr=V([].concat),Qr=zr("Reflect","ownKeys")||function(e){var t=Kr.f(Yr(e)),n=qr.f;return n?Xr(t,n(e)):t},$r=it,Zr=Qr,ei=h,ti=Jt,ni=function(e,t,n){for(var r=Zr(t),i=ti.f,o=ei.f,a=0;a<r.length;a++){var s=r[a];$r(e,s)||n&&$r(n,s)||i(e,s,o(t,s))}},ri=p,ii=ne,oi=/#|\.prototype\./,ai=function(e,t){var n=ci[si(e)];return n===li||n!==ui&&(ii(t)?ri(t):!!t)},si=ai.normalize=function(e){return String(e).replace(oi,".").toLowerCase()},ci=ai.data={},ui=ai.NATIVE="N",li=ai.POLYFILL="P",di=ai,hi=l,fi=h.f,pi=dn,mi=mr,vi=ze,_i=ni,gi=di,yi=function(e,t){var n,r,i,o,a,s=e.target,c=e.global,u=e.stat;if(n=c?hi:u?hi[s]||vi(s,{}):hi[s]&&hi[s].prototype)for(r in t){if(o=t[r],i=e.dontCallGetSet?(a=fi(n,r))&&a.value:n[r],!gi(c?r:s+(u?".":"#")+r,e.forced)&&void 0!==i){if(k(o)==k(i))continue;_i(o,i)}(e.sham||i&&i.sham)&&pi(o,"sham",!0),mi(n,r,o,e)}},Ei={};Ei[gt("toStringTag")]="z";var Ti="[object z]"===String(Ei),ki=ne,Si=H,Ii=gt("toStringTag"),bi=Object,Ai="Arguments"===Si(function(){return arguments}()),Ri=Ti?Si: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=bi(e),Ii))?n:Ai?Si(t):"Object"===(r=Si(t))&&ki(t.callee)?"Arguments":r},Ci=Ri,wi=String,Di=function(e){if("Symbol"===Ci(e))throw new TypeError("Cannot convert a Symbol value to a string");return wi(e)},Ni=hn,xi=Jt,Oi=function(e,t,n){return n.get&&Ni(n.get,t,{getter:!0}),n.set&&Ni(n.set,t,{setter:!0}),xi.f(e,t,n)},Pi=yi,Mi=m,Li=V,Ui=it,Vi=ne,Fi=ce,Bi=Di,ji=Oi,Hi=ni,Gi=l.Symbol,Wi=Gi&&Gi.prototype;if(Mi&&Vi(Gi)&&(!("description"in Wi)||void 0!==Gi().description)){var Ji={},zi=function(){var e=arguments.length<1||void 0===arguments[0]?void 0:Bi(arguments[0]),t=Fi(Wi,this)?new Gi(e):void 0===e?Gi():Gi(e);return""===e&&(Ji[t]=!0),t};Hi(zi,Gi),zi.prototype=Wi,Wi.constructor=zi;var Ki="Symbol(description detection)"===String(Gi("description detection")),qi=Li(Wi.valueOf),Yi=Li(Wi.toString),Xi=/^Symbol\((.*)\)[^)]+$/,Qi=Li("".replace),$i=Li("".slice);ji(Wi,"description",{configurable:!0,get:function(){var e=qi(this);if(Ui(Ji,e))return"";var t=Yi(e),n=Ki?$i(t,7,-1):Qi(t,Xi,"$1");return""===n?void 0:n}}),Pi({global:!0,constructor:!0,forced:!0},{Symbol:zi})}var Zi={},eo=jr,to=Hr,no=Object.keys||function(e){return eo(e,to)},ro=m,io=zt,oo=Jt,ao=Xt,so=ee,co=no;Zi.f=ro&&!io?Object.defineProperties:function(e,t){ao(e);for(var n,r=so(t),i=co(t),o=i.length,a=0;o>a;)oo.f(e,n=i[a++],r[n]);return e};var uo,lo=se("document","documentElement"),ho=Xt,fo=Zi,po=Hr,mo=On,vo=lo,_o=Ot,go="prototype",yo="script",Eo=xn("IE_PROTO"),To=function(){},ko=function(e){return"<"+yo+">"+e+"</"+yo+">"},So=function(e){e.write(ko("")),e.close();var t=e.parentWindow.Object;return e=null,t},Io=function(){try{uo=new ActiveXObject("htmlfile")}catch(h){}var e,t,n;Io="undefined"!=typeof document?document.domain&&uo?So(uo):(t=_o("iframe"),n="java"+yo+":",t.style.display="none",vo.appendChild(t),t.src=String(n),(e=t.contentWindow.document).open(),e.write(ko("document.F=Object")),e.close(),e.F):So(uo);for(var r=po.length;r--;)delete Io[go][po[r]];return Io()};mo[Eo]=!0;var bo=Object.create||function(e,t){var n;return null!==e?(To[go]=ho(e),n=new To,To[go]=null,n[Eo]=e):n=Io(),void 0===t?n:fo.f(n,t)},Ao=gt,Ro=bo,Co=Jt.f,wo=Ao("unscopables"),Do=Array.prototype;void 0===Do[wo]&&Co(Do,wo,{configurable:!0,value:Ro(null)});var No=function(e){Do[wo][e]=!0},xo=Mr.includes,Oo=No;yi({target:"Array",proto:!0,forced:p((function(){return!Array(1).includes()}))},{includes:function(e){return xo(this,e,arguments.length>1?arguments[1]:void 0)}}),Oo("includes");var Po,Mo,Lo,Uo={},Vo=!p((function(){function e(){}return e.prototype.constructor=null,Object.getPrototypeOf(new e)!==e.prototype})),Fo=it,Bo=ne,jo=tt,Ho=Vo,Go=xn("IE_PROTO"),Wo=Object,Jo=Wo.prototype,zo=Ho?Wo.getPrototypeOf:function(e){var t=jo(e);if(Fo(t,Go))return t[Go];var n=t.constructor;return Bo(n)&&t instanceof n?n.prototype:t instanceof Wo?Jo:null},Ko=p,qo=ne,Yo=ie,Xo=zo,Qo=mr,$o=gt("iterator"),Zo=!1;[].keys&&("next"in(Lo=[].keys())?(Mo=Xo(Xo(Lo)))!==Object.prototype&&(Po=Mo):Zo=!0);var ea=!Yo(Po)||Ko((function(){var e={};return Po[$o].call(e)!==e}));ea&&(Po={}),qo(Po[$o])||Qo(Po,$o,(function(){return this}));var ta={IteratorPrototype:Po,BUGGY_SAFARI_ITERATORS:Zo},na=Jt.f,ra=it,ia=gt("toStringTag"),oa=function(e,t,n){e&&!n&&(e=e.prototype),e&&!ra(e,ia)&&na(e,ia,{configurable:!0,value:t})},aa=ta.IteratorPrototype,sa=bo,ca=O,ua=oa,la=Uo,da=function(){return this},ha=function(e,t,n,r){var i=t+" Iterator";return e.prototype=sa(aa,{next:ca(+!r,n)}),ua(e,i,!1),la[i]=da,e},fa=V,pa=Pe,ma=ie,va=function(e){return ma(e)||null===e},_a=String,ga=TypeError,ya=function(e,t,n){try{return fa(pa(Object.getOwnPropertyDescriptor(e,t)[n]))}catch(l){}},Ea=ie,Ta=Q,ka=function(e){if(va(e))return e;throw new ga("Can't set "+_a(e)+" as a prototype")},Sa=Object.setPrototypeOf||("__proto__"in{}?function(){var e,t=!1,n={};try{(e=ya(Object.prototype,"__proto__","set"))(n,[]),t=n instanceof Array}catch(l){}return function(n,r){return Ta(n),ka(r),Ea(n)?(t?e(n,r):n.__proto__=r,n):n}}():void 0),Ia=yi,ba=A,Aa=ne,Ra=ha,Ca=zo,wa=Sa,Da=oa,Na=dn,xa=mr,Oa=Uo,Pa=yn.PROPER,Ma=yn.CONFIGURABLE,La=ta.IteratorPrototype,Ua=ta.BUGGY_SAFARI_ITERATORS,Va=gt("iterator"),Fa="keys",Ba="values",ja="entries",Ha=function(){return this},Ga=function(e,t,n,r,i,o,a){Ra(n,t,r);var s,c,u,l=function(e){if(e===i&&m)return m;if(!Ua&&e&&e in f)return f[e];switch(e){case Fa:case Ba:case ja:return function(){return new n(this,e)}}return function(){return new n(this)}},d=t+" Iterator",h=!1,f=e.prototype,p=f[Va]||f["@@iterator"]||i&&f[i],m=!Ua&&p||l(i),v="Array"===t&&f.entries||p;if(v&&(s=Ca(v.call(new e)))!==Object.prototype&&s.next&&(Ca(s)!==La&&(wa?wa(s,La):Aa(s[Va])||xa(s,Va,Ha)),Da(s,d,!0)),Pa&&i===Ba&&p&&p.name!==Ba&&(Ma?Na(f,"name",Ba):(h=!0,m=function(){return ba(p,this)})),i)if(c={values:l(Ba),keys:o?m:l(Fa),entries:l(ja)},a)for(u in c)(Ua||h||!(u in f))&&xa(f,u,c[u]);else Ia({target:t,proto:!0,forced:Ua||h},c);return f[Va]!==m&&xa(f,Va,m,{name:i}),Oa[t]=m,c},Wa=function(e,t){return{value:e,done:t}},Ja=ee,za=No,Ka=Uo,qa=Kn,Ya=Jt.f,Xa=Ga,Qa=Wa,$a=m,Za="Array Iterator",es=qa.set,ts=qa.getterFor(Za),ns=Xa(Array,"Array",(function(e,t){es(this,{type:Za,target:Ja(e),index:0,kind:t})}),(function(){var e=ts(this),t=e.target,n=e.index++;if(!t||n>=t.length)return e.target=null,Qa(void 0,!0);switch(e.kind){case"keys":return Qa(n,!1);case"values":return Qa(t[n],!1)}return Qa([n,t[n]],!1)}),"values"),rs=Ka.Arguments=Ka.Array;if(za("keys"),za("values"),za("entries"),$a&&"values"!==rs.name)try{Ya(rs,"name",{value:"values"})}catch(UG){}var is=Pe,os=tt,as=K,ss=Dr,cs=TypeError,us="Reduce of empty array with no initial value",ls=function(e){return function(t,n,r,i){var o=os(t),a=as(o),s=ss(o);if(is(n),0===s&&r<2)throw new cs(us);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 cs(us)}for(;e?c>=0:s>c;c+=u)c in a&&(i=n(i,a[c],c,o));return i}},ds={left:ls(!1),right:ls(!0)},hs=p,fs=function(e,t){var n=[][e];return!!n&&hs((function(){n.call(null,t||function(){return 1},1)}))},ps=l,ms=de,vs=H,_s=function(e){return ms.slice(0,e.length)===e},gs=_s("Bun/")?"BUN":_s("Cloudflare-Workers")?"CLOUDFLARE":_s("Deno/")?"DENO":_s("Node.js/")?"NODE":ps.Bun&&"string"==typeof Bun.version?"BUN":ps.Deno&&"object"==k(Deno.version)?"DENO":"process"===vs(ps.process)?"NODE":ps.window&&ps.document?"BROWSER":"REST",ys="NODE"===gs,Es=ds.left;yi({target:"Array",proto:!0,forced:!ys&&ge>79&&ge<83||!fs("reduce")},{reduce:function(e){var t=arguments.length;return Es(this,e,t,t>1?arguments[1]:void 0)}});var Ts=ds.right;yi({target:"Array",proto:!0,forced:!ys&&ge>79&&ge<83||!fs("reduceRight")},{reduceRight:function(e){return Ts(this,e,arguments.length,arguments.length>1?arguments[1]:void 0)}});var ks=H,Ss=Array.isArray||function(e){return"Array"===ks(e)},Is=yi,bs=Ss,As=V([].reverse),Rs=[1,2];Is({target:"Array",proto:!0,forced:String(Rs)===String(Rs.reverse())},{reverse:function(){return bs(this)&&(this.length=this.length),As(this)}});var Cs=De,ws=TypeError,Ds=V([].slice),Ns=Ds,xs=Math.floor,Os=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=xs(n/2),s=Os(Ns(e,0,a),t),c=Os(Ns(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},Ps=Os,Ms=de.match(/firefox\/(\d+)/i),Ls=!!Ms&&+Ms[1],Us=/MSIE|Trident/.test(de),Vs=de.match(/AppleWebKit\/(\d+)\./),Fs=!!Vs&&+Vs[1],Bs=yi,js=V,Hs=Pe,Gs=tt,Ws=Dr,Js=function(e,t){if(!delete e[t])throw new ws("Cannot delete property "+Cs(t)+" of "+Cs(e))},zs=Di,Ks=p,qs=Ps,Ys=fs,Xs=Ls,Qs=Us,$s=ge,Zs=Fs,ec=[],tc=js(ec.sort),nc=js(ec.push),rc=Ks((function(){ec.sort(void 0)})),ic=Ks((function(){ec.sort(null)})),oc=Ys("sort"),ac=!Ks((function(){if($s)return $s<70;if(!(Xs&&Xs>3)){if(Qs)return!0;if(Zs)return Zs<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++)ec.push({k:t+r,v:n})}for(ec.sort((function(e,t){return t.v-e.v})),r=0;r<ec.length;r++)t=ec[r].k.charAt(0),i.charAt(i.length-1)!==t&&(i+=t);return"DGBEFHACIJK"!==i}}));Bs({target:"Array",proto:!0,forced:rc||!ic||!oc||!ac},{sort:function(e){void 0!==e&&Hs(e);var t=Gs(this);if(ac)return void 0===e?tc(t):tc(t,e);var n,r,i=[],o=Ws(t);for(r=0;r<o;r++)r in t&&nc(i,t[r]);for(qs(i,function(e){return function(t,n){return void 0===n?-1:void 0===t?1:void 0!==e?+e(t,n)||0:zs(t)>zs(n)?1:-1}}(e)),n=Ws(i),r=0;r<n;)t[r]=i[r++];for(;r<o;)Js(t,r++);return t}});var sc="undefined"!=typeof ArrayBuffer&&"undefined"!=typeof DataView,cc=mr,uc=function(e,t,n){for(var r in t)cc(e,r,t[r],n);return e},lc=ce,dc=TypeError,hc=function(e,t){if(lc(t,e))return e;throw new dc("Incorrect invocation")},fc=Tr,pc=Cr,mc=RangeError,vc=function(e){if(void 0===e)return 0;var t=fc(e),n=pc(t);if(t!==n)throw new mc("Wrong length or index");return n},_c=Math.sign||function(e){var t=+e;return 0===t||t!=t?t:t<0?-1:1},gc=_c,yc=Math.abs,Ec=2220446049250313e-31,Tc=1/Ec,kc=function(e,t,n,r){var i=+e,o=yc(i),a=gc(i);if(o<r)return a*function(e){return e+Tc-Tc}(o/r/t)*r*t;var s=(1+t/Ec)*o,c=s-(s-o);return c>n||c!=c?Infinity*a:a*c},Sc=Math.fround||function(e){return kc(e,1.1920928955078125e-7,34028234663852886e22,11754943508222875e-54)},Ic=Array,bc=Math.abs,Ac=Math.pow,Rc=Math.floor,Cc=Math.log,wc=Math.LN2,Dc={pack:function(e,t,n){var r,i,o,a=Ic(n),s=8*n-t-1,c=(1<<s)-1,u=c>>1,l=23===t?Ac(2,-24)-Ac(2,-77):0,d=e<0||0===e&&1/e<0?1:0,h=0;for((e=bc(e))!=e||Infinity===e?(i=e!=e?1:0,r=c):(r=Rc(Cc(e)/wc),e*(o=Ac(2,-r))<1&&(r--,o*=2),(e+=r+u>=1?l/o:l*Ac(2,1-u))*o>=2&&(r++,o/=2),r+u>=c?(i=0,r=c):r+u>=1?(i=(e*o-1)*Ac(2,t),r+=u):(i=e*Ac(2,u-1)*Ac(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+=Ac(2,t),l-=a}return(u?-1:1)*n*Ac(2,l-t)}},Nc=tt,xc=br,Oc=Dr,Pc=function(e){for(var t=Nc(this),n=Oc(t),r=arguments.length,i=xc(r>1?arguments[1]:void 0,n),o=r>2?arguments[2]:void 0,a=void 0===o?n:xc(o,n);a>i;)t[i++]=e;return t},Mc=ne,Lc=ie,Uc=Sa,Vc=function(e,t,n){var r,i;return Uc&&Mc(r=t.constructor)&&r!==n&&Lc(i=r.prototype)&&i!==n.prototype&&Uc(e,i),e},Fc=l,Bc=V,jc=m,Hc=sc,Gc=dn,Wc=Oi,Jc=uc,zc=p,Kc=hc,qc=Tr,Yc=Cr,Xc=vc,Qc=Sc,$c=Dc,Zc=zo,eu=Sa,tu=Pc,nu=Ds,ru=Vc,iu=ni,ou=oa,au=Kn,su=yn.PROPER,cu=yn.CONFIGURABLE,uu="ArrayBuffer",lu="DataView",du="prototype",hu="Wrong index",fu=au.getterFor(uu),pu=au.getterFor(lu),mu=au.set,vu=Fc[uu],_u=vu,gu=_u&&_u[du],yu=Fc[lu],Eu=yu&&yu[du],Tu=Object.prototype,ku=Fc.Array,Su=Fc.RangeError,Iu=Bc(tu),bu=Bc([].reverse),Au=$c.pack,Ru=$c.unpack,Cu=function(e){return[255&e]},wu=function(e){return[255&e,e>>8&255]},Du=function(e){return[255&e,e>>8&255,e>>16&255,e>>24&255]},Nu=function(e){return e[3]<<24|e[2]<<16|e[1]<<8|e[0]},xu=function(e){return Au(Qc(e),23,4)},Ou=function(e){return Au(e,52,8)},Pu=function(e,t,n){Wc(e[du],t,{configurable:!0,get:function(){return n(this)[t]}})},Mu=function(e,t,n,r){var i=pu(e),o=Xc(n),a=!!r;if(o+t>i.byteLength)throw new Su(hu);var s=i.bytes,c=o+i.byteOffset,u=nu(s,c,c+t);return a?u:bu(u)},Lu=function(e,t,n,r,i,o){var a=pu(e),s=Xc(n),c=r(+i),u=!!o;if(s+t>a.byteLength)throw new Su(hu);for(var l=a.bytes,d=s+a.byteOffset,h=0;h<t;h++)l[d+h]=c[u?h:t-h-1]};if(Hc){var Uu=su&&vu.name!==uu;zc((function(){vu(1)}))&&zc((function(){new vu(-1)}))&&!zc((function(){return new vu,new vu(1.5),new vu(NaN),1!==vu.length||Uu&&!cu}))?Uu&&cu&&Gc(vu,"name",uu):((_u=function(e){return Kc(this,gu),ru(new vu(Xc(e)),this,_u)})[du]=gu,gu.constructor=_u,iu(_u,vu)),eu&&Zc(Eu)!==Tu&&eu(Eu,Tu);var Vu=new yu(new _u(2)),Fu=Bc(Eu.setInt8);Vu.setInt8(0,2147483648),Vu.setInt8(1,2147483649),!Vu.getInt8(0)&&Vu.getInt8(1)||Jc(Eu,{setInt8:function(e,t){Fu(this,e,t<<24>>24)},setUint8:function(e,t){Fu(this,e,t<<24>>24)}},{unsafe:!0})}else gu=(_u=function(e){Kc(this,gu);var t=Xc(e);mu(this,{type:uu,bytes:Iu(ku(t),0),byteLength:t}),jc||(this.byteLength=t,this.detached=!1)})[du],Eu=(yu=function(e,t,n){Kc(this,Eu),Kc(e,gu);var r=fu(e),i=r.byteLength,o=qc(t);if(o<0||o>i)throw new Su("Wrong offset");if(o+(n=void 0===n?i-o:Yc(n))>i)throw new Su("Wrong length");mu(this,{type:lu,buffer:e,byteLength:n,byteOffset:o,bytes:r.bytes}),jc||(this.buffer=e,this.byteLength=n,this.byteOffset=o)})[du],jc&&(Pu(_u,"byteLength",fu),Pu(yu,"buffer",pu),Pu(yu,"byteLength",pu),Pu(yu,"byteOffset",pu)),Jc(Eu,{getInt8:function(e){return Mu(this,1,e)[0]<<24>>24},getUint8:function(e){return Mu(this,1,e)[0]},getInt16:function(e){var t=Mu(this,2,e,arguments.length>1&&arguments[1]);return(t[1]<<8|t[0])<<16>>16},getUint16:function(e){var t=Mu(this,2,e,arguments.length>1&&arguments[1]);return t[1]<<8|t[0]},getInt32:function(e){return Nu(Mu(this,4,e,arguments.length>1&&arguments[1]))},getUint32:function(e){return Nu(Mu(this,4,e,arguments.length>1&&arguments[1]))>>>0},getFloat32:function(e){return Ru(Mu(this,4,e,arguments.length>1&&arguments[1]),23)},getFloat64:function(e){return Ru(Mu(this,8,e,arguments.length>1&&arguments[1]),52)},setInt8:function(e,t){Lu(this,1,e,Cu,t)},setUint8:function(e,t){Lu(this,1,e,Cu,t)},setInt16:function(e,t){Lu(this,2,e,wu,t,arguments.length>2&&arguments[2])},setUint16:function(e,t){Lu(this,2,e,wu,t,arguments.length>2&&arguments[2])},setInt32:function(e,t){Lu(this,4,e,Du,t,arguments.length>2&&arguments[2])},setUint32:function(e,t){Lu(this,4,e,Du,t,arguments.length>2&&arguments[2])},setFloat32:function(e,t){Lu(this,4,e,xu,t,arguments.length>2&&arguments[2])},setFloat64:function(e,t){Lu(this,8,e,Ou,t,arguments.length>2&&arguments[2])}});ou(_u,uu),ou(yu,lu);var Bu={ArrayBuffer:_u,DataView:yu},ju=se,Hu=Oi,Gu=m,Wu=gt("species"),Ju=function(e){var t=ju(e);Gu&&t&&!t[Wu]&&Hu(t,Wu,{configurable:!0,get:function(){return this}})},zu=Ju,Ku="ArrayBuffer",qu=Bu[Ku];yi({global:!0,constructor:!0,forced:l[Ku]!==qu},{ArrayBuffer:qu}),zu(Ku);var Yu=H,Xu=V,Qu=function(e){if("Function"===Yu(e))return Xu(e)},$u=V,Zu=p,el=ne,tl=Ri,nl=An,rl=function(){},il=se("Reflect","construct"),ol=/^\s*(?:class|function)\b/,al=$u(ol.exec),sl=!ol.test(rl),cl=function(e){if(!el(e))return!1;try{return il(rl,[],e),!0}catch(UG){return!1}},ul=function(e){if(!el(e))return!1;switch(tl(e)){case"AsyncFunction":case"GeneratorFunction":case"AsyncGeneratorFunction":return!1}try{return sl||!!al(ol,nl(e))}catch(UG){return!0}};ul.sham=!0;var ll=!il||Zu((function(){var e;return cl(cl.call)||!cl(Object)||!cl((function(){e=!0}))||e}))?ul:cl,dl=ll,hl=De,fl=TypeError,pl=function(e){if(dl(e))return e;throw new fl(hl(e)+" is not a constructor")},ml=Xt,vl=pl,_l=q,gl=gt("species"),yl=function(e,t){var n,r=ml(e).constructor;return void 0===r||_l(n=ml(r)[gl])?t:vl(n)},El=yi,Tl=Qu,kl=p,Sl=Xt,Il=br,bl=Cr,Al=yl,Rl=Bu.ArrayBuffer,Cl=Bu.DataView,wl=Cl.prototype,Dl=Tl(Rl.prototype.slice),Nl=Tl(wl.getUint8),xl=Tl(wl.setUint8);El({target:"ArrayBuffer",proto:!0,unsafe:!0,forced:kl((function(){return!new Rl(2).slice(1,void 0).byteLength}))},{slice:function(e,t){if(Dl&&void 0===t)return Dl(Sl(this),e);for(var n=Sl(this).byteLength,r=Il(e,n),i=Il(void 0===t?n:t,n),o=new(Al(this,Rl))(bl(i-r)),a=new Cl(this),s=new Cl(o),c=0;r<i;)xl(s,c++,Nl(a,r++));return o}});var Ol,Pl,Ml,Ll,Ul=_,Vl=Function.prototype,Fl=Vl.apply,Bl=Vl.call,jl="object"==("undefined"==typeof Reflect?"undefined":k(Reflect))&&Reflect.apply||(Ul?Bl.bind(Fl):function(){return Bl.apply(Fl,arguments)}),Hl=Pe,Gl=_,Wl=Qu(Qu.bind),Jl=function(e,t){return Hl(e),void 0===t?e:Gl?Wl(e,t):function(){return e.apply(t,arguments)}},zl=TypeError,Kl=function(e,t){if(e<t)throw new zl("Not enough arguments");return e},ql=/(?:ipad|iphone|ipod).*applewebkit/i.test(de),Yl=l,Xl=jl,Ql=Jl,$l=ne,Zl=it,ed=p,td=lo,nd=Ds,rd=Ot,id=Kl,od=ql,ad=ys,sd=Yl.setImmediate,cd=Yl.clearImmediate,ud=Yl.process,ld=Yl.Dispatch,dd=Yl.Function,hd=Yl.MessageChannel,fd=Yl.String,pd=0,md={},vd="onreadystatechange";ed((function(){Ol=Yl.location}));var _d=function(e){if(Zl(md,e)){var t=md[e];delete md[e],t()}},gd=function(e){return function(){_d(e)}},yd=function(e){_d(e.data)},Ed=function(e){Yl.postMessage(fd(e),Ol.protocol+"//"+Ol.host)};sd&&cd||(sd=function(e){id(arguments.length,1);var t=$l(e)?e:dd(e),n=nd(arguments,1);return md[++pd]=function(){Xl(t,void 0,n)},Pl(pd),pd},cd=function(e){delete md[e]},ad?Pl=function(e){ud.nextTick(gd(e))}:ld&&ld.now?Pl=function(e){ld.now(gd(e))}:hd&&!od?(Ll=(Ml=new hd).port2,Ml.port1.onmessage=yd,Pl=Ql(Ll.postMessage,Ll)):Yl.addEventListener&&$l(Yl.postMessage)&&!Yl.importScripts&&Ol&&"file:"!==Ol.protocol&&!ed(Ed)?(Pl=Ed,Yl.addEventListener("message",yd,!1)):Pl=vd in rd("script")?function(e){td.appendChild(rd("script"))[vd]=function(){td.removeChild(this),_d(e)}}:function(e){setTimeout(gd(e),0)});var Td={set:sd,clear:cd},kd=l,Sd=m,Id=Object.getOwnPropertyDescriptor,bd=function(e){if(!Sd)return kd[e];var t=Id(kd,e);return t&&t.value},Ad=function(){this.head=null,this.tail=null};Ad.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 Rd,Cd,wd,Dd,Nd,xd=Ad,Od=/ipad|iphone|ipod/i.test(de)&&"undefined"!=typeof Pebble,Pd=/web0s(?!.*chrome)/i.test(de),Md=l,Ld=bd,Ud=Jl,Vd=Td.set,Fd=xd,Bd=ql,jd=Od,Hd=Pd,Gd=ys,Wd=Md.MutationObserver||Md.WebKitMutationObserver,Jd=Md.document,zd=Md.process,Kd=Md.Promise,qd=Ld("queueMicrotask");if(!qd){var Yd=new Fd,Xd=function(){var e,t;for(Gd&&(e=zd.domain)&&e.exit();t=Yd.get();)try{t()}catch(UG){throw Yd.head&&Rd(),UG}e&&e.enter()};Bd||Gd||Hd||!Wd||!Jd?!jd&&Kd&&Kd.resolve?((Dd=Kd.resolve(void 0)).constructor=Kd,Nd=Ud(Dd.then,Dd),Rd=function(){Nd(Xd)}):Gd?Rd=function(){zd.nextTick(Xd)}:(Vd=Ud(Vd,Md),Rd=function(){Vd(Xd)}):(Cd=!0,wd=Jd.createTextNode(""),new Wd(Xd).observe(wd,{characterData:!0}),Rd=function(){wd.data=Cd=!Cd}),qd=function(e){Yd.head||Rd(),Yd.add(e)}}var Qd=qd,$d=function(e){try{return{error:!1,value:e()}}catch(UG){return{error:!0,value:UG}}},Zd=l.Promise,eh=l,th=Zd,nh=ne,rh=di,ih=An,oh=gt,ah=gs,sh=ge;th&&th.prototype;var ch=oh("species"),uh=!1,lh=nh(eh.PromiseRejectionEvent),dh=rh("Promise",(function(){var e=ih(th),t=e!==String(th);if(!t&&66===sh)return!0;if(!sh||sh<51||!/native code/.test(e)){var n=new th((function(e){e(1)})),r=function(e){e((function(){}),(function(){}))};if((n.constructor={})[ch]=r,!(uh=n.then((function(){}))instanceof r))return!0}return!(t||"BROWSER"!==ah&&"DENO"!==ah||lh)})),hh={CONSTRUCTOR:dh,REJECTION_EVENT:lh,SUBCLASSING:uh},fh={},ph=Pe,mh=TypeError,vh=function(e){var t,n;this.promise=new e((function(e,r){if(void 0!==t||void 0!==n)throw new mh("Bad Promise constructor");t=e,n=r})),this.resolve=ph(t),this.reject=ph(n)};fh.f=function(e){return new vh(e)};var _h,gh,yh,Eh=yi,Th=ys,kh=l,Sh=A,Ih=mr,bh=Sa,Ah=oa,Rh=Ju,Ch=Pe,wh=ne,Dh=ie,Nh=hc,xh=yl,Oh=Td.set,Ph=Qd,Mh=function(e,t){try{1===arguments.length?console.error(e):console.error(e,t)}catch(UG){}},Lh=$d,Uh=xd,Vh=Kn,Fh=Zd,Bh=fh,jh="Promise",Hh=hh.CONSTRUCTOR,Gh=hh.REJECTION_EVENT,Wh=hh.SUBCLASSING,Jh=Vh.getterFor(jh),zh=Vh.set,Kh=Fh&&Fh.prototype,qh=Fh,Yh=Kh,Xh=kh.TypeError,Qh=kh.document,$h=kh.process,Zh=Bh.f,ef=Zh,tf=!!(Qh&&Qh.createEvent&&kh.dispatchEvent),nf="unhandledrejection",rf=function(e){var t;return!(!Dh(e)||!wh(t=e.then))&&t},of=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&&lf(t),t.rejection=1),!0===s?n=o:(l&&l.enter(),n=s(o),l&&(l.exit(),i=!0)),n===e.promise?u(new Xh("Promise-chain cycle")):(r=rf(n))?Sh(r,n,c,u):c(n)):u(o)}catch(UG){l&&!i&&l.exit(),u(UG)}},af=function(e,t){e.notified||(e.notified=!0,Ph((function(){for(var n,r=e.reactions;n=r.get();)of(n,e);e.notified=!1,t&&!e.rejection&&cf(e)})))},sf=function(e,t,n){var r,i;tf?((r=Qh.createEvent("Event")).promise=t,r.reason=n,r.initEvent(e,!1,!0),kh.dispatchEvent(r)):r={promise:t,reason:n},!Gh&&(i=kh["on"+e])?i(r):e===nf&&Mh("Unhandled promise rejection",n)},cf=function(e){Sh(Oh,kh,(function(){var t,n=e.facade,r=e.value;if(uf(e)&&(t=Lh((function(){Th?$h.emit("unhandledRejection",r,n):sf(nf,n,r)})),e.rejection=Th||uf(e)?2:1,t.error))throw t.value}))},uf=function(e){return 1!==e.rejection&&!e.parent},lf=function(e){Sh(Oh,kh,(function(){var t=e.facade;Th?$h.emit("rejectionHandled",t):sf("rejectionhandled",t,e.value)}))},df=function(e,t,n){return function(r){e(t,r,n)}},hf=function(e,t,n){e.done||(e.done=!0,n&&(e=n),e.value=t,e.state=2,af(e,!0))},ff=function(e,t,n){if(!e.done){e.done=!0,n&&(e=n);try{if(e.facade===t)throw new Xh("Promise can't be resolved itself");var r=rf(t);r?Ph((function(){var n={done:!1};try{Sh(r,t,df(ff,n,e),df(hf,n,e))}catch(UG){hf(n,UG,e)}})):(e.value=t,e.state=1,af(e,!1))}catch(UG){hf({done:!1},UG,e)}}};if(Hh&&(Yh=(qh=function(e){Nh(this,Yh),Ch(e),Sh(_h,this);var t=Jh(this);try{e(df(ff,t),df(hf,t))}catch(UG){hf(t,UG)}}).prototype,(_h=function(e){zh(this,{type:jh,done:!1,notified:!1,parent:!1,reactions:new Uh,rejection:!1,state:0,value:null})}).prototype=Ih(Yh,"then",(function(e,t){var n=Jh(this),r=Zh(xh(this,qh));return n.parent=!0,r.ok=!wh(e)||e,r.fail=wh(t)&&t,r.domain=Th?$h.domain:void 0,0===n.state?n.reactions.add(r):Ph((function(){of(r,n)})),r.promise})),gh=function(){var e=new _h,t=Jh(e);this.promise=e,this.resolve=df(ff,t),this.reject=df(hf,t)},Bh.f=Zh=function(e){return e===qh||void 0===e?new gh(e):ef(e)},wh(Fh)&&Kh!==Object.prototype)){yh=Kh.then,Wh||Ih(Kh,"then",(function(e,t){var n=this;return new qh((function(e,t){Sh(yh,n,e,t)})).then(e,t)}),{unsafe:!0});try{delete Kh.constructor}catch(UG){}bh&&bh(Kh,Yh)}Eh({global:!0,constructor:!0,wrap:!0,forced:Hh},{Promise:qh}),Ah(qh,jh,!1),Rh(jh);var pf=Uo,mf=gt("iterator"),vf=Array.prototype,_f=function(e){return void 0!==e&&(pf.Array===e||vf[mf]===e)},gf=Ri,yf=Ue,Ef=q,Tf=Uo,kf=gt("iterator"),Sf=function(e){if(!Ef(e))return yf(e,kf)||yf(e,"@@iterator")||Tf[gf(e)]},If=A,bf=Pe,Af=Xt,Rf=De,Cf=Sf,wf=TypeError,Df=function(e,t){var n=arguments.length<2?Cf(e):t;if(bf(n))return Af(If(n,e));throw new wf(Rf(e)+" is not iterable")},Nf=A,xf=Xt,Of=Ue,Pf=function(e,t,n){var r,i;xf(e);try{if(!(r=Of(e,"return"))){if("throw"===t)throw n;return n}r=Nf(r,e)}catch(UG){i=!0,r=UG}if("throw"===t)throw n;if(i)throw r;return xf(r),n},Mf=Jl,Lf=A,Uf=Xt,Vf=De,Ff=_f,Bf=Dr,jf=ce,Hf=Df,Gf=Sf,Wf=Pf,Jf=TypeError,zf=function(e,t){this.stopped=e,this.result=t},Kf=zf.prototype,qf=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=Mf(t,l),v=function(e){return r&&Wf(r,"normal",e),new zf(!0,e)},_=function(e){return d?(Uf(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=Gf(e)))throw new Jf(Vf(e)+" is not iterable");if(Ff(i)){for(o=0,a=Bf(e);a>o;o++)if((s=_(e[o]))&&jf(Kf,s))return s;return new zf(!1)}r=Hf(e,i)}for(c=h?e.next:r.next;!(u=Lf(c,r)).done;){try{s=_(u.value)}catch(UG){Wf(r,"throw",UG)}if("object"==k(s)&&s&&jf(Kf,s))return s}return new zf(!1)},Yf=gt("iterator"),Xf=!1;try{var Qf=0,$f={next:function(){return{done:!!Qf++}},return:function(){Xf=!0}};$f[Yf]=function(){return this},Array.from($f,(function(){throw 2}))}catch(UG){}var Zf=function(e,t){try{if(!t&&!Xf)return!1}catch(UG){return!1}var n=!1;try{var r={};r[Yf]=function(){return{next:function(){return{done:n=!0}}}},e(r)}catch(UG){}return n},ep=Zd,tp=hh.CONSTRUCTOR||!Zf((function(e){ep.all(e).then(void 0,(function(){}))})),np=A,rp=Pe,ip=fh,op=$d,ap=qf;yi({target:"Promise",stat:!0,forced:tp},{all:function(e){var t=this,n=ip.f(t),r=n.resolve,i=n.reject,o=op((function(){var n=rp(t.resolve),o=[],a=0,s=1;ap(e,(function(e){var c=a++,u=!1;s++,np(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 sp=yi,cp=hh.CONSTRUCTOR,up=Zd,lp=se,dp=ne,hp=mr,fp=up&&up.prototype;if(sp({target:"Promise",proto:!0,forced:cp,real:!0},{catch:function(e){return this.then(void 0,e)}}),dp(up)){var pp=lp("Promise").prototype.catch;fp.catch!==pp&&hp(fp,"catch",pp,{unsafe:!0})}var mp=A,vp=Pe,_p=fh,gp=$d,yp=qf;yi({target:"Promise",stat:!0,forced:tp},{race:function(e){var t=this,n=_p.f(t),r=n.reject,i=gp((function(){var i=vp(t.resolve);yp(e,(function(e){mp(i,t,e).then(n.resolve,r)}))}));return i.error&&r(i.value),n.promise}});var Ep=fh;yi({target:"Promise",stat:!0,forced:hh.CONSTRUCTOR},{reject:function(e){var t=Ep.f(this);return(0,t.reject)(e),t.promise}});var Tp=Xt,kp=ie,Sp=fh,Ip=function(e,t){if(Tp(e),kp(t)&&t.constructor===e)return t;var n=Sp.f(e);return(0,n.resolve)(t),n.promise},bp=yi,Ap=hh.CONSTRUCTOR,Rp=Ip;se("Promise"),bp({target:"Promise",stat:!0,forced:Ap},{resolve:function(e){return Rp(this,e)}});var Cp=yi,wp=Zd,Dp=p,Np=se,xp=ne,Op=yl,Pp=Ip,Mp=mr,Lp=wp&&wp.prototype;if(Cp({target:"Promise",proto:!0,real:!0,forced:!!wp&&Dp((function(){Lp.finally.call({then:function(){}},(function(){}))}))},{finally:function(e){var t=Op(this,Np("Promise")),n=xp(e);return this.then(n?function(n){return Pp(t,e()).then((function(){return n}))}:e,n?function(n){return Pp(t,e()).then((function(){throw n}))}:e)}}),xp(wp)){var Up=Np("Promise").prototype.finally;Lp.finally!==Up&&Mp(Lp,"finally",Up,{unsafe:!0})}var Vp=ie,Fp=H,Bp=gt("match"),jp=Xt,Hp=function(){var e=jp(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},Gp=A,Wp=it,Jp=ce,zp=Hp,Kp=RegExp.prototype,qp=p,Yp=l.RegExp,Xp=qp((function(){var e=Yp("a","y");return e.lastIndex=2,null!==e.exec("abcd")})),Qp=Xp||qp((function(){return!Yp("a","y").sticky})),$p=Xp||qp((function(){var e=Yp("^r","gy");return e.lastIndex=2,null!==e.exec("str")})),Zp={BROKEN_CARET:$p,MISSED_STICKY:Qp,UNSUPPORTED_Y:Xp},em=Jt.f,tm=p,nm=l.RegExp,rm=tm((function(){var e=nm(".","s");return!(e.dotAll&&e.test("\n")&&"s"===e.flags)})),im=p,om=l.RegExp,am=im((function(){var e=om("(?<a>b)","g");return"b"!==e.exec("b").groups.a||"bc"!=="b".replace(e,"$<a>c")})),sm=m,cm=l,um=V,lm=di,dm=Vc,hm=dn,fm=bo,pm=vr.f,mm=ce,vm=function(e){var t;return Vp(e)&&(void 0!==(t=e[Bp])?!!t:"RegExp"===Fp(e))},_m=Di,gm=function(e){var t=e.flags;return void 0!==t||"flags"in Kp||Wp(e,"flags")||!Jp(Kp,e)?t:Gp(zp,e)},ym=Zp,Em=function(e,t,n){n in e||em(e,n,{configurable:!0,get:function(){return t[n]},set:function(e){t[n]=e}})},Tm=mr,km=p,Sm=it,Im=Kn.enforce,bm=Ju,Am=rm,Rm=am,Cm=gt("match"),wm=cm.RegExp,Dm=wm.prototype,Nm=cm.SyntaxError,xm=um(Dm.exec),Om=um("".charAt),Pm=um("".replace),Mm=um("".indexOf),Lm=um("".slice),Um=/^\?<[^\s\d!#%&*+<=>@^][^\s!#%&*+<=>@^]*>/,Vm=/a/g,Fm=/a/g,Bm=new wm(Vm)!==Vm,jm=ym.MISSED_STICKY,Hm=ym.UNSUPPORTED_Y,Gm=sm&&(!Bm||jm||Am||Rm||km((function(){return Fm[Cm]=!1,wm(Vm)!==Vm||wm(Fm)===Fm||"/a/i"!==String(wm(Vm,"i"))})));if(lm("RegExp",Gm)){for(var Wm=function(e,t){var n,r,i,o,a,s,c=mm(Dm,this),u=vm(e),l=void 0===t,d=[],h=e;if(!c&&u&&l&&e.constructor===Wm)return e;if((u||mm(Dm,e))&&(e=e.source,l&&(t=gm(h))),e=void 0===e?"":_m(e),t=void 0===t?"":_m(t),h=e,Am&&"dotAll"in Vm&&(r=!!t&&Mm(t,"s")>-1)&&(t=Pm(t,/s/g,"")),n=t,jm&&"sticky"in Vm&&(i=!!t&&Mm(t,"y")>-1)&&Hm&&(t=Pm(t,/y/g,"")),Rm&&(o=function(e){for(var t,n=e.length,r=0,i="",o=[],a=fm(null),s=!1,c=!1,u=0,l="";r<=n;r++){if("\\"===(t=Om(e,r)))t+=Om(e,++r);else if("]"===t)s=!1;else if(!s)switch(!0){case"["===t:s=!0;break;case"("===t:if(i+=t,"?:"===Lm(e,r+1,r+3))continue;xm(Um,Lm(e,r+1))&&(r+=2,c=!0),u++;continue;case">"===t&&c:if(""===l||Sm(a,l))throw new Nm("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=dm(wm(e,t),c?this:Dm,Wm),(r||i||d.length)&&(s=Im(a),r&&(s.dotAll=!0,s.raw=Wm(function(e){for(var t,n=e.length,r=0,i="",o=!1;r<=n;r++)"\\"!==(t=Om(e,r))?o||"."!==t?("["===t?o=!0:"]"===t&&(o=!1),i+=t):i+="[\\s\\S]":i+=t+Om(e,++r);return i}(e),n)),i&&(s.sticky=!0),d.length&&(s.groups=d)),e!==h)try{hm(a,"source",""===h?"(?:)":h)}catch(UG){}return a},Jm=pm(wm),zm=0;Jm.length>zm;)Em(Wm,wm,Jm[zm++]);Dm.constructor=Wm,Wm.prototype=Dm,Tm(cm,"RegExp",Wm,{constructor:!0})}bm("RegExp");var Km=A,qm=V,Ym=Di,Xm=Hp,Qm=Zp,$m=bo,Zm=Kn.get,ev=rm,tv=am,nv=$e("native-string-replace",String.prototype.replace),rv=RegExp.prototype.exec,iv=rv,ov=qm("".charAt),av=qm("".indexOf),sv=qm("".replace),cv=qm("".slice),uv=function(){var e=/a/,t=/b*/g;return Km(rv,e,"a"),Km(rv,t,"a"),0!==e.lastIndex||0!==t.lastIndex}(),lv=Qm.BROKEN_CARET,dv=void 0!==/()??/.exec("")[1];(uv||dv||lv||ev||tv)&&(iv=function(e){var t,n,r,i,o,a,s,c=this,u=Zm(c),l=Ym(e),d=u.raw;if(d)return d.lastIndex=c.lastIndex,t=Km(iv,d,l),c.lastIndex=d.lastIndex,t;var h=u.groups,f=lv&&c.sticky,p=Km(Xm,c),m=c.source,v=0,_=l;if(f&&(p=sv(p,"y",""),-1===av(p,"g")&&(p+="g"),_=cv(l,c.lastIndex),c.lastIndex>0&&(!c.multiline||c.multiline&&"\n"!==ov(l,c.lastIndex-1))&&(m="(?: "+m+")",_=" "+_,v++),n=new RegExp("^(?:"+m+")",p)),dv&&(n=new RegExp("^"+m+"$(?!\\s)",p)),uv&&(r=c.lastIndex),i=Km(rv,f?n:c,_),f?i?(i.input=cv(i.input,v),i[0]=cv(i[0],v),i.index=c.lastIndex,c.lastIndex+=i[0].length):c.lastIndex=0:uv&&i&&(c.lastIndex=c.global?i.index+i[0].length:r),dv&&i&&i.length>1&&Km(nv,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=$m(null),o=0;o<h.length;o++)a[(s=h[o])[0]]=i[s[1]];return i});var hv=iv;yi({target:"RegExp",proto:!0,forced:/./.exec!==hv},{exec:hv});var fv=Tr,pv=Di,mv=Q,vv=RangeError,_v=V,gv=Cr,yv=Di,Ev=function(e){var t=pv(mv(this)),n="",r=fv(e);if(r<0||Infinity===r)throw new vv("Wrong number of repetitions");for(;r>0;(r>>>=1)&&(t+=t))1&r&&(n+=t);return n},Tv=Q,kv=_v(Ev),Sv=_v("".slice),Iv=Math.ceil,bv=function(e){return function(t,n,r){var i,o,a=yv(Tv(t)),s=gv(n),c=a.length,u=void 0===r?" ":yv(r);return s<=c||""===u?a:((o=kv(u,Iv((i=s-c)/u.length))).length>i&&(o=Sv(o,0,i)),e?a+o:o+a)}},Av={start:bv(!1),end:bv(!0)},Rv=/Version\/10(?:\.\d+){1,2}(?: [\w./]+)?(?: Mobile\/\w+)? Safari\//.test(de),Cv=Av.start;yi({target:"String",proto:!0,forced:Rv},{padStart:function(e){return Cv(this,e,arguments.length>1?arguments[1]:void 0)}});var wv=A,Dv=mr,Nv=hv,xv=p,Ov=gt,Pv=dn,Mv=Ov("species"),Lv=RegExp.prototype,Uv=V,Vv=Tr,Fv=Di,Bv=Q,jv=Uv("".charAt),Hv=Uv("".charCodeAt),Gv=Uv("".slice),Wv=function(e){return function(t,n){var r,i,o=Fv(Bv(t)),a=Vv(n),s=o.length;return a<0||a>=s?e?"":void 0:(r=Hv(o,a))<55296||r>56319||a+1===s||(i=Hv(o,a+1))<56320||i>57343?e?jv(o,a):r:e?Gv(o,a,a+2):i-56320+(r-55296<<10)+65536}},Jv={codeAt:Wv(!1),charAt:Wv(!0)},zv=Jv.charAt,Kv=V,qv=tt,Yv=Math.floor,Xv=Kv("".charAt),Qv=Kv("".replace),$v=Kv("".slice),Zv=/\$([$&'`]|\d{1,2}|<[^>]*>)/g,e_=/\$([$&'`]|\d{1,2})/g,t_=A,n_=Xt,r_=ne,i_=H,o_=hv,a_=TypeError,s_=jl,c_=A,u_=V,l_=function(e,t,n,r){var i=Ov(e),o=!xv((function(){var t={};return t[i]=function(){return 7},7!==""[e](t)})),a=o&&!xv((function(){var t=!1,n=/a/;return"split"===e&&((n={}).constructor={},n.constructor[Mv]=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===Nv||a===Lv.exec?o&&!i?{done:!0,value:wv(s,t,n,r)}:{done:!0,value:wv(e,n,t,r)}:{done:!1}}));Dv(String.prototype,e,c[0]),Dv(Lv,i,c[1])}r&&Pv(Lv[i],"sham",!0)},d_=p,h_=Xt,f_=ne,p_=q,m_=Tr,v_=Cr,__=Di,g_=Q,y_=function(e,t,n){return t+(n?zv(e,t).length:1)},E_=Ue,T_=function(e,t,n,r,i,o){var a=n+e.length,s=r.length,c=e_;return void 0!==i&&(i=qv(i),c=Zv),Qv(o,c,(function(o,c){var u;switch(Xv(c,0)){case"$":return"$";case"&":return e;case"`":return $v(t,0,n);case"'":return $v(t,a);case"<":u=i[$v(c,1,-1)];break;default:var l=+c;if(0===l)return o;if(l>s){var d=Yv(l/10);return 0===d?o:d<=s?void 0===r[d-1]?Xv(c,1):r[d-1]+Xv(c,1):o}u=r[l-1]}return void 0===u?"":u}))},k_=function(e,t){var n=e.exec;if(r_(n)){var r=t_(n,e,t);return null!==r&&n_(r),r}if("RegExp"===i_(e))return t_(o_,e,t);throw new a_("RegExp#exec called on incompatible receiver")},S_=gt("replace"),I_=Math.max,b_=Math.min,A_=u_([].concat),R_=u_([].push),C_=u_("".indexOf),w_=u_("".slice),D_=function(e){return void 0===e?e:String(e)},N_="$0"==="a".replace(/./,"$0"),x_=!!/./[S_]&&""===/./[S_]("a","$0"),O_=!d_((function(){var e=/./;return e.exec=function(){var e=[];return e.groups={a:"7"},e},"7"!=="".replace(e,"$<a>")}));l_("replace",(function(e,t,n){var r=x_?"$":"$0";return[function(e,n){var r=g_(this),i=p_(e)?void 0:E_(e,S_);return i?c_(i,e,r,n):c_(t,__(r),e,n)},function(e,i){var o=h_(this),a=__(e);if("string"==typeof i&&-1===C_(i,r)&&-1===C_(i,"$<")){var s=n(t,o,a,i);if(s.done)return s.value}var c=f_(i);c||(i=__(i));var u,l=o.global;l&&(u=o.unicode,o.lastIndex=0);for(var d,h=[];null!==(d=k_(o,a))&&(R_(h,d),l);)""===__(d[0])&&(o.lastIndex=y_(a,v_(o.lastIndex),u));for(var f="",p=0,m=0;m<h.length;m++){for(var v,_=__((d=h[m])[0]),g=I_(b_(m_(d.index),a.length),0),y=[],E=1;E<d.length;E++)R_(y,D_(d[E]));var T=d.groups;if(c){var k=A_([_],y,g,a);void 0!==T&&R_(k,T),v=__(s_(i,void 0,k))}else v=T_(_,a,g,y,T,i);g>=p&&(f+=w_(a,p,g)+v,p=g+_.length)}return f+w_(a,p)}]}),!O_||!N_||x_);var P_="\t\n\v\f\r \u2028\u2029\ufeff",M_=Q,L_=Di,U_=P_,V_=V("".replace),F_=RegExp("^["+U_+"]+"),B_=RegExp("(^|[^"+U_+"])["+U_+"]+$"),j_=function(e){return function(t){var n=L_(M_(t));return 1&e&&(n=V_(n,F_,"")),2&e&&(n=V_(n,B_,"$1")),n}},H_={start:j_(1),end:j_(2),trim:j_(3)},G_=yn.PROPER,W_=p,J_=P_,z_=H_.trim;yi({target:"String",proto:!0,forced:function(e){return W_((function(){return!!J_[e]()||"
"!=="
"[e]()||G_&&J_[e].name!==e}))}("trim")},{trim:function(){return z_(this)}});var K_,q_,Y_,X_={},Q_={get exports(){return X_},set exports(e){X_=e}},$_=sc,Z_=m,eg=l,tg=ne,ng=ie,rg=it,ig=Ri,og=De,ag=dn,sg=mr,cg=Oi,ug=ce,lg=zo,dg=Sa,hg=gt,fg=ut,pg=Kn.enforce,mg=Kn.get,vg=eg.Int8Array,_g=vg&&vg.prototype,gg=eg.Uint8ClampedArray,yg=gg&&gg.prototype,Eg=vg&&lg(vg),Tg=_g&&lg(_g),kg=Object.prototype,Sg=eg.TypeError,Ig=hg("toStringTag"),bg=fg("TYPED_ARRAY_TAG"),Ag="TypedArrayConstructor",Rg=$_&&!!dg&&"Opera"!==ig(eg.opera),Cg=!1,wg={Int8Array:1,Uint8Array:1,Uint8ClampedArray:1,Int16Array:2,Uint16Array:2,Int32Array:4,Uint32Array:4,Float32Array:4,Float64Array:8},Dg={BigInt64Array:8,BigUint64Array:8},Ng=function(e){var t=lg(e);if(ng(t)){var n=mg(t);return n&&rg(n,Ag)?n[Ag]:Ng(t)}},xg=function(e){if(!ng(e))return!1;var t=ig(e);return rg(wg,t)||rg(Dg,t)};for(K_ in wg)(Y_=(q_=eg[K_])&&q_.prototype)?pg(Y_)[Ag]=q_:Rg=!1;for(K_ in Dg)(Y_=(q_=eg[K_])&&q_.prototype)&&(pg(Y_)[Ag]=q_);if((!Rg||!tg(Eg)||Eg===Function.prototype)&&(Eg=function(){throw new Sg("Incorrect invocation")},Rg))for(K_ in wg)eg[K_]&&dg(eg[K_],Eg);if((!Rg||!Tg||Tg===kg)&&(Tg=Eg.prototype,Rg))for(K_ in wg)eg[K_]&&dg(eg[K_].prototype,Tg);if(Rg&&lg(yg)!==Tg&&dg(yg,Tg),Z_&&!rg(Tg,Ig))for(K_ in Cg=!0,cg(Tg,Ig,{configurable:!0,get:function(){return ng(this)?this[bg]:void 0}}),wg)eg[K_]&&ag(eg[K_],bg,K_);var Og={NATIVE_ARRAY_BUFFER_VIEWS:Rg,TYPED_ARRAY_TAG:Cg&&bg,aTypedArray:function(e){if(xg(e))return e;throw new Sg("Target is not a typed array")},aTypedArrayConstructor:function(e){if(tg(e)&&(!dg||ug(Eg,e)))return e;throw new Sg(og(e)+" is not a typed array constructor")},exportTypedArrayMethod:function(e,t,n,r){if(Z_){if(n)for(var i in wg){var o=eg[i];if(o&&rg(o.prototype,e))try{delete o.prototype[e]}catch(UG){try{o.prototype[e]=t}catch(m){}}}Tg[e]&&!n||sg(Tg,e,n?t:Rg&&_g[e]||t,r)}},exportTypedArrayStaticMethod:function(e,t,n){var r,i;if(Z_){if(dg){if(n)for(r in wg)if((i=eg[r])&&rg(i,e))try{delete i[e]}catch(UG){}if(Eg[e]&&!n)return;try{return sg(Eg,e,n?t:Rg&&Eg[e]||t)}catch(UG){}}for(r in wg)!(i=eg[r])||i[e]&&!n||sg(i,e,t)}},getTypedArrayConstructor:Ng,isView:function(e){if(!ng(e))return!1;var t=ig(e);return"DataView"===t||rg(wg,t)||rg(Dg,t)},isTypedArray:xg,TypedArray:Eg,TypedArrayPrototype:Tg},Pg=l,Mg=p,Lg=Zf,Ug=Og.NATIVE_ARRAY_BUFFER_VIEWS,Vg=Pg.ArrayBuffer,Fg=Pg.Int8Array,Bg=!Ug||!Mg((function(){Fg(1)}))||!Mg((function(){new Fg(-1)}))||!Lg((function(e){new Fg,new Fg(null),new Fg(1.5),new Fg(e)}),!0)||Mg((function(){return 1!==new Fg(new Vg(2),1,void 0).length})),jg=ie,Hg=Math.floor,Gg=Number.isInteger||function(e){return!jg(e)&&isFinite(e)&&Hg(e)===e},Wg=Tr,Jg=RangeError,zg=function(e){var t=Wg(e);if(t<0)throw new Jg("The argument can't be less than 0");return t},Kg=RangeError,qg=function(e,t){var n=zg(e);if(n%t)throw new Kg("Wrong offset");return n},Yg=Math.round,Xg=Ri,Qg=At,$g=TypeError,Zg=function(e){var t=Qg(e,"number");if("number"==typeof t)throw new $g("Can't convert number to bigint");return BigInt(t)},ey=Jl,ty=A,ny=pl,ry=tt,iy=Dr,oy=Df,ay=Sf,sy=_f,cy=function(e){var t=Xg(e);return"BigInt64Array"===t||"BigUint64Array"===t},uy=Og.aTypedArrayConstructor,ly=Zg,dy=function(e){var t,n,r,i,o,a,s,c,u=ny(this),l=ry(e),d=arguments.length,h=d>1?arguments[1]:void 0,f=void 0!==h,p=ay(l);if(p&&!sy(p))for(c=(s=oy(l,p)).next,l=[];!(a=ty(c,s)).done;)l.push(a.value);for(f&&d>2&&(h=ey(h,arguments[2])),n=iy(l),r=new(uy(u))(n),i=cy(r),t=0;n>t;t++)o=f?h(l[t],t):l[t],r[t]=i?ly(o):+o;return r},hy=Ss,fy=ll,py=ie,my=gt("species"),vy=Array,_y=function(e){var t;return hy(e)&&(t=e.constructor,(fy(t)&&(t===vy||hy(t.prototype))||py(t)&&null===(t=t[my]))&&(t=void 0)),void 0===t?vy:t},gy=Jl,yy=K,Ey=tt,Ty=Dr,ky=function(e,t){return new(_y(e))(0===t?0:t)},Sy=V([].push),Iy=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=Ey(c),m=yy(p),v=Ty(m),_=gy(u,l),g=0,y=d||ky,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:Sy(E,h)}else switch(e){case 4:return!1;case 7:Sy(E,h)}return o?-1:r||i?i:E}},by={forEach:Iy(0),map:Iy(1),filter:Iy(2),some:Iy(3),every:Iy(4),find:Iy(5),findIndex:Iy(6),filterReject:Iy(7)},Ay=Dr,Ry=yi,Cy=l,wy=A,Dy=m,Ny=Bg,xy=Og,Oy=Bu,Py=hc,My=O,Ly=dn,Uy=Gg,Vy=Cr,Fy=vc,By=qg,jy=function(e){var t=Yg(e);return t<0?0:t>255?255:255&t},Hy=wt,Gy=it,Wy=Ri,Jy=ie,zy=Ce,Ky=bo,qy=ce,Yy=Sa,Xy=vr.f,Qy=dy,$y=by.forEach,Zy=Ju,eE=Oi,tE=Jt,nE=h,rE=function(e,t,n){for(var r=0,i=arguments.length>2?n:Ay(t),o=new e(i);i>r;)o[r]=t[r++];return o},iE=Vc,oE=Kn.get,aE=Kn.set,sE=Kn.enforce,cE=tE.f,uE=nE.f,lE=Cy.RangeError,dE=Oy.ArrayBuffer,hE=dE.prototype,fE=Oy.DataView,pE=xy.NATIVE_ARRAY_BUFFER_VIEWS,mE=xy.TYPED_ARRAY_TAG,vE=xy.TypedArray,_E=xy.TypedArrayPrototype,gE=xy.isTypedArray,yE="BYTES_PER_ELEMENT",EE="Wrong length",TE=function(e,t){eE(e,t,{configurable:!0,get:function(){return oE(this)[t]}})},kE=function(e){var t;return qy(hE,e)||"ArrayBuffer"===(t=Wy(e))||"SharedArrayBuffer"===t},SE=function(e,t){return gE(e)&&!zy(t)&&t in e&&Uy(+t)&&t>=0},IE=function(e,t){return t=Hy(t),SE(e,t)?My(2,e[t]):uE(e,t)},bE=function(e,t,n){return t=Hy(t),!(SE(e,t)&&Jy(n)&&Gy(n,"value"))||Gy(n,"get")||Gy(n,"set")||n.configurable||Gy(n,"writable")&&!n.writable||Gy(n,"enumerable")&&!n.enumerable?cE(e,t,n):(e[t]=n.value,e)};Dy?(pE||(nE.f=IE,tE.f=bE,TE(_E,"buffer"),TE(_E,"byteOffset"),TE(_E,"byteLength"),TE(_E,"length")),Ry({target:"Object",stat:!0,forced:!pE},{getOwnPropertyDescriptor:IE,defineProperty:bE}),Q_.exports=function(e,t,n){var r=e.match(/\d+/)[0]/8,i=e+(n?"Clamped":"")+"Array",o="get"+e,a="set"+e,s=Cy[i],c=s,u=c&&c.prototype,l={},d=function(e,t){cE(e,t,{get:function(){return function(e,t){var n=oE(e);return n.view[o](t*r+n.byteOffset,!0)}(this,t)},set:function(e){return function(e,t,i){var o=oE(e);o.view[a](t*r+o.byteOffset,n?jy(i):i,!0)}(this,t,e)},enumerable:!0})};pE?Ny&&(c=t((function(e,t,n,i){return Py(e,u),iE(Jy(t)?kE(t)?void 0!==i?new s(t,By(n,r),i):void 0!==n?new s(t,By(n,r)):new s(t):gE(t)?rE(c,t):wy(Qy,c,t):new s(Fy(t)),e,c)})),Yy&&Yy(c,vE),$y(Xy(s),(function(e){e in c||Ly(c,e,s[e])})),c.prototype=u):(c=t((function(e,t,n,i){Py(e,u);var o,a,s,l=0,h=0;if(Jy(t)){if(!kE(t))return gE(t)?rE(c,t):wy(Qy,c,t);o=t,h=By(n,r);var f=t.byteLength;if(void 0===i){if(f%r)throw new lE(EE);if((a=f-h)<0)throw new lE(EE)}else if((a=Vy(i)*r)+h>f)throw new lE(EE);s=a/r}else s=Fy(t),o=new dE(a=s*r);for(aE(e,{buffer:o,byteOffset:h,byteLength:a,length:s,view:new fE(o)});l<s;)d(e,l++)})),Yy&&Yy(c,vE),u=c.prototype=Ky(_E)),u.constructor!==c&&Ly(u,"constructor",c),sE(u).TypedArrayConstructor=c,mE&&Ly(u,mE,i);var h=c!==s;l[i]=c,Ry({global:!0,constructor:!0,forced:h,sham:!pE},l),yE in c||Ly(c,yE,r),yE in u||Ly(u,yE,r),Zy(i)}):Q_.exports=function(){},X_("Float32",(function(e){return function(t,n,r){return e(this,t,n,r)}})),X_("Uint8",(function(e){return function(t,n,r){return e(this,t,n,r)}}));var AE=Pc,RE=Zg,CE=Ri,wE=A,DE=p,NE=Og.aTypedArray,xE=Og.exportTypedArrayMethod,OE=V("".slice);xE("fill",(function(e){var t=arguments.length;NE(this);var n="Big"===OE(CE(this),0,3)?RE(e):+e;return wE(AE,this,n,t>1?arguments[1]:void 0,t>2?arguments[2]:void 0)}),DE((function(){var e=0;return new Int8Array(2).fill({valueOf:function(){return e++}}),1!==e}))),(0,Og.exportTypedArrayStaticMethod)("from",dy,Bg);var PE=l,ME=A,LE=Og,UE=Dr,VE=qg,FE=tt,BE=p,jE=PE.RangeError,HE=PE.Int8Array,GE=HE&&HE.prototype,WE=GE&&GE.set,JE=LE.aTypedArray,zE=LE.exportTypedArrayMethod,KE=!BE((function(){var e=new Uint8ClampedArray(2);return ME(WE,e,{length:1,0:3},1),3!==e[1]})),qE=KE&&LE.NATIVE_ARRAY_BUFFER_VIEWS&&BE((function(){var e=new HE(2);return e.set(1),e.set("2",1),0!==e[0]||2!==e[1]}));zE("set",(function(e){JE(this);var t=VE(arguments.length>1?arguments[1]:void 0,1),n=FE(e);if(KE)return ME(WE,this,n,t);var r=this.length,i=UE(n),o=0;if(i+t>r)throw new jE("Wrong length");for(;o<i;)this[t+o]=n[o++]}),!KE||qE);var YE=Qu,XE=p,QE=Pe,$E=Ps,ZE=Ls,eT=Us,tT=ge,nT=Fs,rT=Og.aTypedArray,iT=Og.exportTypedArrayMethod,oT=l.Uint16Array,aT=oT&&YE(oT.prototype.sort),sT=!(!aT||XE((function(){aT(new oT(2),null)}))&&XE((function(){aT(new oT(2),{})}))),cT=!!aT&&!XE((function(){if(tT)return tT<74;if(ZE)return ZE<67;if(eT)return!0;if(nT)return nT<602;var e,t,n=new oT(516),r=Array(516);for(e=0;e<516;e++)t=e%4,n[e]=515-e,r[e]=e-2*t+3;for(aT(n,(function(e,t){return(e/4|0)-(t/4|0)})),e=0;e<516;e++)if(n[e]!==r[e])return!0}));iT("sort",(function(e){return void 0!==e&&QE(e),cT?aT(this,e):$E(rT(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))}),!cT||sT);var uT={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},lT=Ot("span").classList,dT=lT&&lT.constructor&&lT.constructor.prototype,hT=dT===Object.prototype?void 0:dT,fT=by.forEach,pT=fs("forEach")?[].forEach:function(e){return fT(this,e,arguments.length>1?arguments[1]:void 0)},mT=l,vT=uT,_T=hT,gT=pT,yT=dn,ET=function(e){if(e&&e.forEach!==gT)try{yT(e,"forEach",gT)}catch(UG){e.forEach=gT}};for(var TT in vT)vT[TT]&&ET(mT[TT]&&mT[TT].prototype);ET(_T);var kT=l,ST=uT,IT=hT,bT=ns,AT=dn,RT=oa,CT=gt("iterator"),wT=bT.values,DT=function(e,t){if(e){if(e[CT]!==wT)try{AT(e,CT,wT)}catch(UG){e[CT]=wT}if(RT(e,t,!0),ST[t])for(var n in bT)if(e[n]!==bT[n])try{AT(e,n,bT[n])}catch(UG){e[n]=bT[n]}}};for(var NT in ST)DT(kT[NT]&&kT[NT].prototype,NT);DT(IT,"DOMTokenList");var xT=Jv.charAt,OT=Di,PT=Kn,MT=Ga,LT=Wa,UT="String Iterator",VT=PT.set,FT=PT.getterFor(UT);MT(String,"String",(function(e){VT(this,{type:UT,string:OT(e),index:0})}),(function(){var e,t=FT(this),n=t.string,r=t.index;return r>=n.length?LT(void 0,!0):(e=xT(n,r),t.index+=e.length,LT(e,!1))}));var BT=p,jT=m,HT=gt("iterator"),GT=!BT((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&&!jT||!t.sort||"https://a/c%20d?a=1&c=3"!==e.href||"3"!==t.get("c")||"a=1"!==String(new URLSearchParams("?a=1"))||!t[HT]||"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})),WT=m,JT=V,zT=A,KT=p,qT=no,YT=Jr,XT=R,QT=tt,$T=K,ZT=Object.assign,ek=Object.defineProperty,tk=JT([].concat),nk=!ZT||KT((function(){if(WT&&1!==ZT({b:1},ZT(ek({},"a",{enumerable:!0,get:function(){ek(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!==ZT({},e)[n]||qT(ZT({},t)).join("")!==r}))?function(e,t){for(var n=QT(e),r=arguments.length,i=1,o=YT.f,a=XT.f;r>i;)for(var s,c=$T(arguments[i++]),u=o?tk(qT(c),o(c)):qT(c),l=u.length,d=0;l>d;)s=u[d++],WT&&!zT(a,c,s)||(n[s]=c[s]);return n}:ZT,rk=Xt,ik=Pf,ok=m,ak=Jt,sk=O,ck=Jl,uk=A,lk=tt,dk=function(e,t,n,r){try{return r?t(rk(n)[0],n[1]):t(n)}catch(UG){ik(e,"throw",UG)}},hk=_f,fk=ll,pk=Dr,mk=function(e,t,n){ok?ak.f(e,t,sk(0,n)):e[t]=n},vk=Df,_k=Sf,gk=Array,yk=V,Ek=2147483647,Tk=/[^\0-\u007E]/,kk=/[.\u3002\uFF0E\uFF61]/g,Sk="Overflow: input needs wider integers to process",Ik=RangeError,bk=yk(kk.exec),Ak=Math.floor,Rk=String.fromCharCode,Ck=yk("".charCodeAt),wk=yk([].join),Dk=yk([].push),Nk=yk("".replace),xk=yk("".split),Ok=yk("".toLowerCase),Pk=function(e){return e+22+75*(e<26)},Mk=function(e,t,n){var r=0;for(e=n?Ak(e/700):e>>1,e+=Ak(e/t);e>455;)e=Ak(e/35),r+=36;return Ak(r+36*e/(e+38))},Lk=function(e){var t=[];e=function(e){for(var t=[],n=0,r=e.length;n<r;){var i=Ck(e,n++);if(i>=55296&&i<=56319&&n<r){var o=Ck(e,n++);56320==(64512&o)?Dk(t,((1023&i)<<10)+(1023&o)+65536):(Dk(t,i),n--)}else Dk(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&&Dk(t,Rk(r));var c=t.length,u=c;for(c&&Dk(t,"-");u<i;){var l=Ek;for(n=0;n<e.length;n++)(r=e[n])>=o&&r<l&&(l=r);var d=u+1;if(l-o>Ak((Ek-a)/d))throw new Ik(Sk);for(a+=(l-o)*d,o=l,n=0;n<e.length;n++){if((r=e[n])<o&&++a>Ek)throw new Ik(Sk);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;Dk(t,Rk(Pk(p+m%v))),h=Ak(m/v),f+=36}Dk(t,Rk(Pk(h))),s=Mk(a,d,u===c),a=0,u++}}a++,o++}return wk(t,"")},Uk=yi,Vk=V,Fk=br,Bk=RangeError,jk=String.fromCharCode,Hk=String.fromCodePoint,Gk=Vk([].join);Uk({target:"String",stat:!0,arity:1,forced:!!Hk&&1!==Hk.length},{fromCodePoint:function(e){for(var t,n=[],r=arguments.length,i=0;r>i;){if(t=+arguments[i++],Fk(t,1114111)!==t)throw new Bk(t+" is not a valid code point");n[i]=t<65536?jk(t):jk(55296+((t-=65536)>>10),t%1024+56320)}return Gk(n,"")}});var Wk=yi,Jk=l,zk=bd,Kk=se,qk=A,Yk=V,Xk=m,Qk=GT,$k=mr,Zk=Oi,eS=uc,tS=oa,nS=ha,rS=Kn,iS=hc,oS=ne,aS=it,sS=Jl,cS=Ri,uS=Xt,lS=ie,dS=Di,hS=bo,fS=O,pS=Df,mS=Sf,vS=Wa,_S=Kl,gS=Ps,yS=gt("iterator"),ES="URLSearchParams",TS=ES+"Iterator",kS=rS.set,SS=rS.getterFor(ES),IS=rS.getterFor(TS),bS=zk("fetch"),AS=zk("Request"),RS=zk("Headers"),CS=AS&&AS.prototype,wS=RS&&RS.prototype,DS=Jk.TypeError,NS=Jk.encodeURIComponent,xS=String.fromCharCode,OS=Kk("String","fromCodePoint"),PS=parseInt,MS=Yk("".charAt),LS=Yk([].join),US=Yk([].push),VS=Yk("".replace),FS=Yk([].shift),BS=Yk([].splice),jS=Yk("".split),HS=Yk("".slice),GS=Yk(/./.exec),WS=/\+/g,JS=/^[0-9a-f]+$/i,zS=function(e,t){var n=HS(e,t,t+2);return GS(JS,n)?PS(n,16):NaN},KS=function(e){for(var t=0,n=128;n>0&&e&n;n>>=1)t++;return t},qS=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},YS=function(e){for(var t=(e=VS(e,WS," ")).length,n="",r=0;r<t;){var i=MS(e,r);if("%"===i){if("%"===MS(e,r+1)||r+3>t){n+="%",r++;continue}var o=zS(e,r+1);if(o!=o){n+=i,r++;continue}r+=2;var a=KS(o);if(0===a)i=xS(o);else{if(1===a||a>4){n+="�",r++;continue}for(var s=[o],c=1;c<a&&!(3+ ++r>t||"%"!==MS(e,r));){var u=zS(e,r+1);if(u!=u){r+=3;break}if(u>191||u<128)break;US(s,u),r+=2,c++}if(s.length!==a){n+="�";continue}var l=qS(s);null===l?n+="�":i=OS(l)}}n+=i,r++}return n},XS=/[!'()~]|%20/g,QS={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+"},$S=function(e){return QS[e]},ZS=function(e){return VS(NS(e),XS,$S)},eI=nS((function(e,t){kS(this,{type:TS,target:SS(e).entries,index:0,kind:t})}),ES,(function(){var e=IS(this),t=e.target,n=e.index++;if(!t||n>=t.length)return e.target=null,vS(void 0,!0);var r=t[n];switch(e.kind){case"keys":return vS(r.key,!1);case"values":return vS(r.value,!1)}return vS([r.key,r.value],!1)}),!0),tI=function(e){this.entries=[],this.url=null,void 0!==e&&(lS(e)?this.parseObject(e):this.parseQuery("string"==typeof e?"?"===MS(e,0)?HS(e,1):e:dS(e)))};tI.prototype={type:ES,bindURL:function(e){this.url=e,this.update()},parseObject:function(e){var t,n,r,i,o,a,s,c=this.entries,u=mS(e);if(u)for(n=(t=pS(e,u)).next;!(r=qk(n,t)).done;){if(o=(i=pS(uS(r.value))).next,(a=qk(o,i)).done||(s=qk(o,i)).done||!qk(o,i).done)throw new DS("Expected sequence with length 2");US(c,{key:dS(a.value),value:dS(s.value)})}else for(var l in e)aS(e,l)&&US(c,{key:l,value:dS(e[l])})},parseQuery:function(e){if(e)for(var t,n,r=this.entries,i=jS(e,"&"),o=0;o<i.length;)(t=i[o++]).length&&(n=jS(t,"="),US(r,{key:YS(FS(n)),value:YS(LS(n,"="))}))},serialize:function(){for(var e,t=this.entries,n=[],r=0;r<t.length;)e=t[r++],US(n,ZS(e.key)+"="+ZS(e.value));return LS(n,"&")},update:function(){this.entries.length=0,this.parseQuery(this.url.query)},updateURL:function(){this.url&&this.url.update()}};var nI=function(){iS(this,rI);var e=kS(this,new tI(arguments.length>0?arguments[0]:void 0));Xk||(this.size=e.entries.length)},rI=nI.prototype;if(eS(rI,{append:function(e,t){var n=SS(this);_S(arguments.length,2),US(n.entries,{key:dS(e),value:dS(t)}),Xk||this.length++,n.updateURL()},delete:function(e){for(var t=SS(this),n=_S(arguments.length,1),r=t.entries,i=dS(e),o=n<2?void 0:arguments[1],a=void 0===o?o:dS(o),s=0;s<r.length;){var c=r[s];if(c.key!==i||void 0!==a&&c.value!==a)s++;else if(BS(r,s,1),void 0!==a)break}Xk||(this.size=r.length),t.updateURL()},get:function(e){var t=SS(this).entries;_S(arguments.length,1);for(var n=dS(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;_S(arguments.length,1);for(var n=dS(e),r=[],i=0;i<t.length;i++)t[i].key===n&&US(r,t[i].value);return r},has:function(e){for(var t=SS(this).entries,n=_S(arguments.length,1),r=dS(e),i=n<2?void 0:arguments[1],o=void 0===i?i:dS(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=SS(this);_S(arguments.length,1);for(var r,i=n.entries,o=!1,a=dS(e),s=dS(t),c=0;c<i.length;c++)(r=i[c]).key===a&&(o?BS(i,c--,1):(o=!0,r.value=s));o||US(i,{key:a,value:s}),Xk||(this.size=i.length),n.updateURL()},sort:function(){var e=SS(this);gS(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=sS(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 eI(this,"keys")},values:function(){return new eI(this,"values")},entries:function(){return new eI(this,"entries")}},{enumerable:!0}),$k(rI,yS,rI.entries,{name:"entries"}),$k(rI,"toString",(function(){return SS(this).serialize()}),{enumerable:!0}),Xk&&Zk(rI,"size",{get:function(){return SS(this).entries.length},configurable:!0,enumerable:!0}),tS(nI,ES),Wk({global:!0,constructor:!0,forced:!Qk},{URLSearchParams:nI}),!Qk&&oS(RS)){var iI=Yk(wS.has),oI=Yk(wS.set),aI=function(e){if(lS(e)){var t,n=e.body;if(cS(n)===ES)return t=e.headers?new RS(e.headers):new RS,iI(t,"content-type")||oI(t,"content-type","application/x-www-form-urlencoded;charset=UTF-8"),hS(e,{body:fS(0,dS(n)),headers:fS(0,t)})}return e};if(oS(bS)&&Wk({global:!0,enumerable:!0,dontCallGetSet:!0,forced:!0},{fetch:function(e){return bS(e,arguments.length>1?aI(arguments[1]):{})}}),oS(AS)){var sI=function(e){return iS(this,CS),new AS(e,arguments.length>1?aI(arguments[1]):{})};CS.constructor=sI,sI.prototype=CS,Wk({global:!0,constructor:!0,dontCallGetSet:!0,forced:!0},{Request:sI})}}var cI,uI=yi,lI=m,dI=GT,hI=l,fI=Jl,pI=V,mI=mr,vI=Oi,_I=hc,gI=it,yI=nk,EI=function(e){var t=lk(e),n=fk(this),r=arguments.length,i=r>1?arguments[1]:void 0,o=void 0!==i;o&&(i=ck(i,r>2?arguments[2]:void 0));var a,s,c,u,l,d,h=_k(t),f=0;if(!h||this===gk&&hk(h))for(a=pk(t),s=n?new this(a):gk(a);a>f;f++)d=o?i(t[f],f):t[f],mk(s,f,d);else for(s=n?new this:[],l=(u=vk(t,h)).next;!(c=uk(l,u)).done;f++)d=o?dk(u,i,[c.value,f],!0):c.value,mk(s,f,d);return s.length=f,s},TI=Ds,kI=Jv.codeAt,SI=function(e){var t,n,r=[],i=xk(Nk(Ok(e),kk,"."),".");for(t=0;t<i.length;t++)n=i[t],Dk(r,bk(Tk,n)?"xn--"+Lk(n):n);return wk(r,".")},II=Di,bI=oa,AI=Kl,RI={URLSearchParams:nI,getState:SS},CI=Kn,wI=CI.set,DI=CI.getterFor("URL"),NI=RI.URLSearchParams,xI=RI.getState,OI=hI.URL,PI=hI.TypeError,MI=hI.parseInt,LI=Math.floor,UI=Math.pow,VI=pI("".charAt),FI=pI(/./.exec),BI=pI([].join),jI=pI(1..toString),HI=pI([].pop),GI=pI([].push),WI=pI("".replace),JI=pI([].shift),zI=pI("".split),KI=pI("".slice),qI=pI("".toLowerCase),YI=pI([].unshift),XI="Invalid scheme",QI="Invalid host",$I="Invalid port",ZI=/[a-z]/i,eb=/[\d+-.a-z]/i,tb=/\d/,nb=/^0x/i,rb=/^[0-7]+$/,ib=/^\d+$/,ob=/^[\da-f]+$/i,ab=/[\0\t\n\r #%/:<>?@[\\\]^|]/,sb=/[\0\t\n\r #/:<>?@[\\\]^|]/,cb=/^[\u0000-\u0020]+/,ub=/(^|[^\u0000-\u0020])[\u0000-\u0020]+$/,lb=/[\t\n\r]/g,db=function(e){var t,n,r,i;if("number"==typeof e){for(t=[],n=0;n<4;n++)YI(t,e%256),e=LI(e/256);return BI(t,".")}if("object"==k(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+=jI(e[n],16),n<7&&(t+=":")));return"["+t+"]"}return e},hb={},fb=yI({},hb,{" ":1,'"':1,"<":1,">":1,"`":1}),pb=yI({},fb,{"#":1,"?":1,"{":1,"}":1}),mb=yI({},pb,{"/":1,":":1,";":1,"=":1,"@":1,"[":1,"\\":1,"]":1,"^":1,"|":1}),vb=function(e,t){var n=kI(e,0);return n>32&&n<127&&!gI(t,e)?e:encodeURIComponent(e)},_b={ftp:21,file:null,http:80,https:443,ws:80,wss:443},gb=function(e,t){var n;return 2===e.length&&FI(ZI,VI(e,0))&&(":"===(n=VI(e,1))||!t&&"|"===n)},yb=function(e){var t;return e.length>1&&gb(KI(e,0,2))&&(2===e.length||"/"===(t=VI(e,2))||"\\"===t||"?"===t||"#"===t)},Eb=function(e){return"."===e||"%2e"===qI(e)},Tb={},kb={},Sb={},Ib={},bb={},Ab={},Rb={},Cb={},wb={},Db={},Nb={},xb={},Ob={},Pb={},Mb={},Lb={},Ub={},Vb={},Fb={},Bb={},jb={},Hb=function(e,t,n){var r,i,o,a=II(e);if(t){if(i=this.parse(a))throw new PI(i);this.searchParams=null}else{if(void 0!==n&&(r=new Hb(n,!0)),i=this.parse(a,null,r))throw new PI(i);(o=xI(new NI)).bindURL(this),this.searchParams=o}};Hb.prototype={type:"URL",parse:function(e,t,n){var r,i,o,a,s,c=this,u=t||Tb,l=0,d="",h=!1,f=!1,p=!1;for(e=II(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=WI(e,cb,""),e=WI(e,ub,"$1")),e=WI(e,lb,""),r=EI(e);l<=r.length;){switch(i=r[l],u){case Tb:if(!i||!FI(ZI,i)){if(t)return XI;u=Sb;continue}d+=qI(i),u=kb;break;case kb:if(i&&(FI(eb,i)||"+"===i||"-"===i||"."===i))d+=qI(i);else{if(":"!==i){if(t)return XI;d="",u=Sb,l=0;continue}if(t&&(c.isSpecial()!==gI(_b,d)||"file"===d&&(c.includesCredentials()||null!==c.port)||"file"===c.scheme&&!c.host))return;if(c.scheme=d,t)return void(c.isSpecial()&&_b[c.scheme]===c.port&&(c.port=null));d="","file"===c.scheme?u=Pb:c.isSpecial()&&n&&n.scheme===c.scheme?u=Ib:c.isSpecial()?u=Cb:"/"===r[l+1]?(u=bb,l++):(c.cannotBeABaseURL=!0,GI(c.path,""),u=Fb)}break;case Sb:if(!n||n.cannotBeABaseURL&&"#"!==i)return XI;if(n.cannotBeABaseURL&&"#"===i){c.scheme=n.scheme,c.path=TI(n.path),c.query=n.query,c.fragment="",c.cannotBeABaseURL=!0,u=jb;break}u="file"===n.scheme?Pb:Ab;continue;case Ib:if("/"!==i||"/"!==r[l+1]){u=Ab;continue}u=wb,l++;break;case bb:if("/"===i){u=Db;break}u=Vb;continue;case Ab:if(c.scheme=n.scheme,i===cI)c.username=n.username,c.password=n.password,c.host=n.host,c.port=n.port,c.path=TI(n.path),c.query=n.query;else if("/"===i||"\\"===i&&c.isSpecial())u=Rb;else if("?"===i)c.username=n.username,c.password=n.password,c.host=n.host,c.port=n.port,c.path=TI(n.path),c.query="",u=Bb;else{if("#"!==i){c.username=n.username,c.password=n.password,c.host=n.host,c.port=n.port,c.path=TI(n.path),c.path.length--,u=Vb;continue}c.username=n.username,c.password=n.password,c.host=n.host,c.port=n.port,c.path=TI(n.path),c.query=n.query,c.fragment="",u=jb}break;case Rb:if(!c.isSpecial()||"/"!==i&&"\\"!==i){if("/"!==i){c.username=n.username,c.password=n.password,c.host=n.host,c.port=n.port,u=Vb;continue}u=Db}else u=wb;break;case Cb:if(u=wb,"/"!==i||"/"!==VI(d,l+1))continue;l++;break;case wb:if("/"!==i&&"\\"!==i){u=Db;continue}break;case Db:if("@"===i){h&&(d="%40"+d),h=!0,o=EI(d);for(var m=0;m<o.length;m++){var v=o[m];if(":"!==v||p){var _=vb(v,mb);p?c.password+=_:c.username+=_}else p=!0}d=""}else if(i===cI||"/"===i||"?"===i||"#"===i||"\\"===i&&c.isSpecial()){if(h&&""===d)return"Invalid authority";l-=EI(d).length+1,d="",u=Nb}else d+=i;break;case Nb:case xb:if(t&&"file"===c.scheme){u=Lb;continue}if(":"!==i||f){if(i===cI||"/"===i||"?"===i||"#"===i||"\\"===i&&c.isSpecial()){if(c.isSpecial()&&""===d)return QI;if(t&&""===d&&(c.includesCredentials()||null!==c.port))return;if(a=c.parseHost(d))return a;if(d="",u=Ub,t)return;continue}"["===i?f=!0:"]"===i&&(f=!1),d+=i}else{if(""===d)return QI;if(a=c.parseHost(d))return a;if(d="",u=Ob,t===xb)return}break;case Ob:if(!FI(tb,i)){if(i===cI||"/"===i||"?"===i||"#"===i||"\\"===i&&c.isSpecial()||t){if(""!==d){var g=MI(d,10);if(g>65535)return $I;c.port=c.isSpecial()&&g===_b[c.scheme]?null:g,d=""}if(t)return;u=Ub;continue}return $I}d+=i;break;case Pb:if(c.scheme="file","/"===i||"\\"===i)u=Mb;else{if(!n||"file"!==n.scheme){u=Vb;continue}switch(i){case cI:c.host=n.host,c.path=TI(n.path),c.query=n.query;break;case"?":c.host=n.host,c.path=TI(n.path),c.query="",u=Bb;break;case"#":c.host=n.host,c.path=TI(n.path),c.query=n.query,c.fragment="",u=jb;break;default:yb(BI(TI(r,l),""))||(c.host=n.host,c.path=TI(n.path),c.shortenPath()),u=Vb;continue}}break;case Mb:if("/"===i||"\\"===i){u=Lb;break}n&&"file"===n.scheme&&!yb(BI(TI(r,l),""))&&(gb(n.path[0],!0)?GI(c.path,n.path[0]):c.host=n.host),u=Vb;continue;case Lb:if(i===cI||"/"===i||"\\"===i||"?"===i||"#"===i){if(!t&&gb(d))u=Vb;else if(""===d){if(c.host="",t)return;u=Ub}else{if(a=c.parseHost(d))return a;if("localhost"===c.host&&(c.host=""),t)return;d="",u=Ub}continue}d+=i;break;case Ub:if(c.isSpecial()){if(u=Vb,"/"!==i&&"\\"!==i)continue}else if(t||"?"!==i)if(t||"#"!==i){if(i!==cI&&(u=Vb,"/"!==i))continue}else c.fragment="",u=jb;else c.query="",u=Bb;break;case Vb:if(i===cI||"/"===i||"\\"===i&&c.isSpecial()||!t&&("?"===i||"#"===i)){if(".."===(s=qI(s=d))||"%2e."===s||".%2e"===s||"%2e%2e"===s?(c.shortenPath(),"/"===i||"\\"===i&&c.isSpecial()||GI(c.path,"")):Eb(d)?"/"===i||"\\"===i&&c.isSpecial()||GI(c.path,""):("file"===c.scheme&&!c.path.length&&gb(d)&&(c.host&&(c.host=""),d=VI(d,0)+":"),GI(c.path,d)),d="","file"===c.scheme&&(i===cI||"?"===i||"#"===i))for(;c.path.length>1&&""===c.path[0];)JI(c.path);"?"===i?(c.query="",u=Bb):"#"===i&&(c.fragment="",u=jb)}else d+=vb(i,pb);break;case Fb:"?"===i?(c.query="",u=Bb):"#"===i?(c.fragment="",u=jb):i!==cI&&(c.path[0]+=vb(i,hb));break;case Bb:t||"#"!==i?i!==cI&&("'"===i&&c.isSpecial()?c.query+="%27":c.query+="#"===i?"%23":vb(i,hb)):(c.fragment="",u=jb);break;case jb:i!==cI&&(c.fragment+=vb(i,fb))}l++}},parseHost:function(e){var t,n,r;if("["===VI(e,0)){if("]"!==VI(e,e.length-1))return QI;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 VI(e,d)};if(":"===h()){if(":"!==VI(e,1))return;d+=2,l=++u}for(;h();){if(8===u)return;if(":"!==h()){for(t=n=0;n<4&&FI(ob,h());)t=16*t+MI(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(!FI(tb,h()))return;for(;FI(tb,h());){if(o=MI(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}(KI(e,1,-1)),!t)return QI;this.host=t}else if(this.isSpecial()){if(e=SI(e),FI(ab,e))return QI;if(t=function(e){var t,n,r,i,o,a,s,c=zI(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"===VI(i,0)&&(o=FI(nb,i)?16:8,i=KI(i,8===o?1:2)),""===i)a=0;else{if(!FI(10===o?ib:8===o?rb:ob,i))return e;a=MI(i,o)}GI(n,a)}for(r=0;r<t;r++)if(a=n[r],r===t-1){if(a>=UI(256,5-t))return null}else if(a>255)return null;for(s=HI(n),r=0;r<n.length;r++)s+=n[r]*UI(256,3-r);return s}(e),null===t)return QI;this.host=t}else{if(FI(sb,e))return QI;for(t="",n=EI(e),r=0;r<n.length;r++)t+=vb(n[r],hb);this.host=t}},cannotHaveUsernamePasswordPort:function(){return!this.host||this.cannotBeABaseURL||"file"===this.scheme},includesCredentials:function(){return""!==this.username||""!==this.password},isSpecial:function(){return gI(_b,this.scheme)},shortenPath:function(){var e=this.path,t=e.length;!t||"file"===this.scheme&&1===t&&gb(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+=db(i),null!==o&&(u+=":"+o)):"file"===t&&(u+="//"),u+=e.cannotBeABaseURL?a[0]:a.length?"/"+BI(a,"/"):"",null!==s&&(u+="?"+s),null!==c&&(u+="#"+c),u},setHref:function(e){var t=this.parse(e);if(t)throw new PI(t);this.searchParams.update()},getOrigin:function(){var e=this.scheme,t=this.port;if("blob"===e)try{return new Gb(e.path[0]).origin}catch(UG){return"null"}return"file"!==e&&this.isSpecial()?e+"://"+db(this.host)+(null!==t?":"+t:""):"null"},getProtocol:function(){return this.scheme+":"},setProtocol:function(e){this.parse(II(e)+":",Tb)},getUsername:function(){return this.username},setUsername:function(e){var t=EI(II(e));if(!this.cannotHaveUsernamePasswordPort()){this.username="";for(var n=0;n<t.length;n++)this.username+=vb(t[n],mb)}},getPassword:function(){return this.password},setPassword:function(e){var t=EI(II(e));if(!this.cannotHaveUsernamePasswordPort()){this.password="";for(var n=0;n<t.length;n++)this.password+=vb(t[n],mb)}},getHost:function(){var e=this.host,t=this.port;return null===e?"":null===t?db(e):db(e)+":"+t},setHost:function(e){this.cannotBeABaseURL||this.parse(e,Nb)},getHostname:function(){var e=this.host;return null===e?"":db(e)},setHostname:function(e){this.cannotBeABaseURL||this.parse(e,xb)},getPort:function(){var e=this.port;return null===e?"":II(e)},setPort:function(e){this.cannotHaveUsernamePasswordPort()||(""===(e=II(e))?this.port=null:this.parse(e,Ob))},getPathname:function(){var e=this.path;return this.cannotBeABaseURL?e[0]:e.length?"/"+BI(e,"/"):""},setPathname:function(e){this.cannotBeABaseURL||(this.path=[],this.parse(e,Ub))},getSearch:function(){var e=this.query;return e?"?"+e:""},setSearch:function(e){""===(e=II(e))?this.query=null:("?"===VI(e,0)&&(e=KI(e,1)),this.query="",this.parse(e,Bb)),this.searchParams.update()},getSearchParams:function(){return this.searchParams.facade},getHash:function(){var e=this.fragment;return e?"#"+e:""},setHash:function(e){""!==(e=II(e))?("#"===VI(e,0)&&(e=KI(e,1)),this.fragment="",this.parse(e,jb)):this.fragment=null},update:function(){this.query=this.searchParams.serialize()||null}};var Gb=function(e){var t=_I(this,Wb),n=AI(arguments.length,1)>1?arguments[1]:void 0,r=wI(t,new Hb(e,!1,n));lI||(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())},Wb=Gb.prototype,Jb=function(e,t){return{get:function(){return DI(this)[e]()},set:t&&function(e){return DI(this)[t](e)},configurable:!0,enumerable:!0}};if(lI&&(vI(Wb,"href",Jb("serialize","setHref")),vI(Wb,"origin",Jb("getOrigin")),vI(Wb,"protocol",Jb("getProtocol","setProtocol")),vI(Wb,"username",Jb("getUsername","setUsername")),vI(Wb,"password",Jb("getPassword","setPassword")),vI(Wb,"host",Jb("getHost","setHost")),vI(Wb,"hostname",Jb("getHostname","setHostname")),vI(Wb,"port",Jb("getPort","setPort")),vI(Wb,"pathname",Jb("getPathname","setPathname")),vI(Wb,"search",Jb("getSearch","setSearch")),vI(Wb,"searchParams",Jb("getSearchParams")),vI(Wb,"hash",Jb("getHash","setHash"))),mI(Wb,"toJSON",(function(){return DI(this).serialize()}),{enumerable:!0}),mI(Wb,"toString",(function(){return DI(this).serialize()}),{enumerable:!0}),OI){var zb=OI.createObjectURL,Kb=OI.revokeObjectURL;zb&&mI(Gb,"createObjectURL",fI(zb,OI)),Kb&&mI(Gb,"revokeObjectURL",fI(Kb,OI))}bI(Gb,"URL"),uI({global:!0,constructor:!0,forced:!dI,sham:!lI},{URL:Gb});var qb=A;yi({target:"URL",proto:!0,enumerable:!0},{toJSON:function(){return qb(URL.prototype.toString,this)}});var Yb=!0,Xb=!0;function Qb(e,t,n){var r=e.match(t);return r&&r.length>=n&&parseInt(r[n],10)}function $b(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 o=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,o),i.apply(this,[e,o])};var 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);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,o.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 Zb(e){return"boolean"!=typeof e?new Error("Argument type: "+k(e)+". Please use a boolean."):(Yb=e,e?"adapter.js logging disabled":"adapter.js logging enabled")}function eA(e){return"boolean"!=typeof e?new Error("Argument type: "+k(e)+". Please use a boolean."):(Xb=!e,"adapter.js deprecation warnings "+(e?"disabled":"enabled"))}function tA(){if("object"==("undefined"==typeof window?"undefined":k(window))){if(Yb)return;"undefined"!=typeof console&&"function"==typeof console.log&&console.log.apply(console,arguments)}}function nA(e,t){Xb&&console.warn(e+" is deprecated, please use "+t+" instead.")}function rA(e){return"[object Object]"===Object.prototype.toString.call(e)}function iA(e){return rA(e)?Object.keys(e).reduce((function(t,n){var r=rA(e[n]),i=r?iA(e[n]):e[n],o=r&&!Object.keys(i).length;return void 0===i||o?t:Object.assign(t,c({},n,i))}),{}):e}function oA(e,t,n){t&&!n.has(t.id)&&(n.set(t.id,t),Object.keys(t).forEach((function(r){r.endsWith("Id")?oA(e,e.get(t[r]),n):r.endsWith("Ids")&&t[r].forEach((function(t){oA(e,e.get(t),n)}))})))}function aA(e,t,n){var r=n?"outbound-rtp":"inbound-rtp",i=new Map;if(null===t)return i;var o=[];return e.forEach((function(e){"track"===e.type&&e.trackIdentifier===t.id&&o.push(e)})),o.forEach((function(t){e.forEach((function(n){n.type===r&&n.trackId===t.id&&oA(e,n,i)}))})),i}var sA=tA;function cA(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 o={};"number"==typeof r.ideal?(o[i("min",n)]=r.ideal,t.optional.push(o),(o={})[i("max",n)]=r.ideal,t.optional.push(o)):(o[i("",n)]=r.ideal,t.optional.push(o))}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 o=function(e,t,n){t in e&&!(n in e)&&(e[n]=e[t],delete e[t])};o((e=JSON.parse(JSON.stringify(e))).audio,"autoGainControl","googAutoGainControl"),o(e.audio,"noiseSuppression","googNoiseSuppression"),e.audio=r(e.audio)}if(e&&"object"==k(e.video)){var a=e.video.facingMode;a=a&&("object"==k(a)?a:{ideal:a});var s,c=t.version<66;if(a&&("user"===a.exact||"environment"===a.exact||"user"===a.ideal||"environment"===a.ideal)&&(!n.mediaDevices.getSupportedConstraints||!n.mediaDevices.getSupportedConstraints().facingMode||c)&&(delete e.video.facingMode,"environment"===a.exact||"environment"===a.ideal?s=["back","rear"]:"user"!==a.exact&&"user"!==a.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=a.exact?{exact:n.deviceId}:{ideal:n.deviceId}),e.video=r(e.video),sA("chrome: "+JSON.stringify(e)),i(e)}));e.video=r(e.video)}return sA("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: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(o(e))}))}))}.bind(n),n.mediaDevices.getUserMedia){var a=n.mediaDevices.getUserMedia.bind(n.mediaDevices);n.mediaDevices.getUserMedia=function(e){return i(e,(function(e){return a(e).then((function(t){if(e.audio&&!t.getAudioTracks().length||e.video&&!t.getVideoTracks().length)throw t.getTracks().forEach((function(e){e.stop()})),new DOMException("","NotFoundError");return t}),(function(e){return Promise.reject(o(e))}))}))}}}}function uA(e){e.MediaStream=e.MediaStream||e.webkitMediaStream}function lA(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 o=new Event("track");o.track=r.track,o.receiver=i,o.transceiver={receiver:i},o.streams=[t.stream],n.dispatchEvent(o)})),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 o=new Event("track");o.track=r,o.receiver=i,o.transceiver={receiver:i},o.streams=[t.stream],n.dispatchEvent(o)}))},this.addEventListener("addstream",this._ontrackpoly)),t.apply(this,arguments)}}else $b(e,"track",(function(e){return e.transceiver||Object.defineProperty(e,"transceiver",{value:{receiver:e.receiver}}),e}))}function dA(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 o=e.RTCPeerConnection.prototype.removeStream;e.RTCPeerConnection.prototype.removeStream=function(e){var t=this;this._senders=this._senders||[],o.apply(this,[e]),e.getTracks().forEach((function(e){var 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 a=e.RTCPeerConnection.prototype.getSenders;e.RTCPeerConnection.prototype.getSenders=function(){var e=this,t=a.apply(this,[]);return t.forEach((function(t){return t._pc=e})),t},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 hA(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],o=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 a=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]]})))};if(arguments.length>=2){var c=function(e){i(s(a(e)))};return t.apply(this,[c,r])}return new Promise((function(n,r){t.apply(e,[function(e){n(s(a(e)))},r])})).then(i,o)}}}function fA(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 aA(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}),$b(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 aA(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,o=arguments[0];return this.getSenders().forEach((function(e){e.track===o&&(t?r=!0:t=e)})),this.getReceivers().forEach((function(e){return e.track===o&&(n?r=!0:n=e),e.track===o})),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 pA(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 mA(e,t){if(e.RTCPeerConnection){if(e.RTCPeerConnection.prototype.addTrack&&t.version>=65)return pA(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 o=this._streams[n.id];if(o)o.addTrack(t),Promise.resolve().then((function(){r.dispatchEvent(new Event("negotiationneeded"))}));else{var a=new e.MediaStream([t]);this._streams[n.id]=a,this._reverseStreams[a.id]=n,this.addStream(a)}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 o=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]),o.apply(this,arguments)):o.apply(this,arguments)};var a=Object.getOwnPropertyDescriptor(e.RTCPeerConnection.prototype,"localDescription");Object.defineProperty(e.RTCPeerConnection.prototype,"localDescription",{get:function(){var e=a.get.apply(this);return""===e.type?e:s(this,e)}}),e.RTCPeerConnection.prototype.removeTrack=function(e){var t,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 vA(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 _A(e,t){$b(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 gA=Object.freeze({__proto__:null,shimMediaStream:uA,shimOnTrack:lA,shimGetSendersWithDtmf:dA,shimGetStats:hA,shimSenderReceiverGetStats:fA,shimAddTrackRemoveTrackWithNative:pA,shimAddTrackRemoveTrack:mA,shimPeerConnection:vA,fixNegotiationNeeded:_A,shimGetUserMedia:cA,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,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 yA(e,t){var n=e&&e.navigator,r=e&&e.MediaStreamTrack;if(n.getUserMedia=function(e,t,r){nA("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])},o=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")),o(e)},r&&r.prototype.getSettings){var a=r.prototype.getSettings;r.prototype.getSettings=function(){var e=a.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 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,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],o=e[1],a=e[2];return r.apply(this,[i||null]).then((function(e){if(t.version<53&&!o)try{e.forEach((function(e){e.type=n[e.type]||e.type}))}catch(zR){if("TypeError"!==zR.name)throw zR;e.forEach((function(t,r){e.set(r,Object.assign({},t,{type:n[t.type]||t.type}))}))}return e})).then(o,a)}}}function kA(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 SA(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}),$b(e,"track",(function(e){return e.receiver._pc=e.srcElement,e})),e.RTCRtpReceiver.prototype.getStats=function(){return this._pc.getStats(this.track)}}}function IA(e){e.RTCPeerConnection&&!("removeStream"in e.RTCPeerConnection.prototype)&&(e.RTCPeerConnection.prototype.removeStream=function(e){var t=this;nA("removeStream","removeTrack"),this.getSenders().forEach((function(n){n.track&&e.getTracks().includes(n.track)&&t.removeTrack(n)}))})}function bA(e){e.DataChannel&&!e.RTCDataChannel&&(e.RTCDataChannel=e.DataChannel)}function AA(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,o=i.getParameters();(!("encodings"in o)||1===o.encodings.length&&0===Object.keys(o.encodings[0]).length)&&(o.encodings=e,i.sendEncodings=e,this.setParametersPromises.push(i.setParameters(o).then((function(){delete i.sendEncodings})).catch((function(){delete i.sendEncodings}))))}return r})}}function RA(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 CA(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 wA(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 DA=Object.freeze({__proto__:null,shimOnTrack:EA,shimPeerConnection:TA,shimSenderGetStats:kA,shimReceiverGetStats:SA,shimRemoveStream:IA,shimRTCDataChannel:bA,shimAddTransceiver:AA,shimGetParameters:RA,shimCreateOffer:CA,shimCreateAnswer:wA,shimGetUserMedia:yA,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 NA(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),o=1;o<r;o++)i[o-1]=arguments[o];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 xA(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 OA(e){if("object"==k(e)&&e.RTCPeerConnection){var t=e.RTCPeerConnection.prototype,n=t.createOffer,r=t.createAnswer,i=t.setLocalDescription,o=t.setRemoteDescription,a=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=o.apply(this,[e]);return n?(r.then(t,n),Promise.resolve()):r},t.setRemoteDescription=s,s=function(e,t,n){var r=a.apply(this,[e]);return n?(r.then(t,n),Promise.resolve()):r},t.addIceCandidate=s}}function PA(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(MA(e))}}!t.getUserMedia&&t.mediaDevices&&t.mediaDevices.getUserMedia&&(t.getUserMedia=function(e,n,r){t.mediaDevices.getUserMedia(e).then(n,r)}.bind(t))}function MA(e){return e&&void 0!==e.video?Object.assign({},e,{video:iA(e.video)}):e}function LA(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 o=e.iceServers[i];void 0===o.urls&&o.url?(nA("RTCIceServer.url","RTCIceServer.urls"),(o=JSON.parse(JSON.stringify(o))).urls=o.url,delete o.url,r.push(o)):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 UA(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 VA(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 FA(e){"object"!=k(e)||e.AudioContext||(e.AudioContext=e.webkitAudioContext)}var BA=Object.freeze({__proto__:null,shimLocalStreamsAPI:NA,shimRemoteStreamsAPI:xA,shimCallbacksAPI:OA,shimGetUserMedia:PA,shimConstraints:MA,shimRTCIceServerUrls:LA,shimTrackEventTransceiver:UA,shimCreateOfferLegacy:VA,shimAudioContext:FA}),jA={},HA={get exports(){return jA},set exports(e){jA=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 o=r[i],a=t.matchPrefix(e,"a=rtpmap:"+o+" ")[0];if(a){var s=t.parseRtpMap(a),c=t.matchPrefix(e,"a=fmtp:"+o+" ");switch(s.parameters=c.length?t.parseFmtp(c[0]):{},s.rtcpFeedback=t.matchPrefix(e,"a=rtcp-fb:"+o+" ").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),o=-1!==i.fecMechanisms.indexOf("RED"),a=-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),o&&((t=JSON.parse(JSON.stringify(t))).fec={ssrc:c,mechanism:a?"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 o=t.matchPrefix(e,"a=rtcp-mux");return n.mux=o.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 o=t.matchPrefix(e,"a=sctp-port:");if(o.length>0)return{port:parseInt(o[0].substring(12),10),protocol:r.fmt,maxMessageSize:n};var a=t.matchPrefix(e,"a=sctpmap:");if(a.length>0){var s=a[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}(HA);var GA=jA,WA=e({__proto__:null,default:GA},[jA]);function JA(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=GA.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,$b(e,"icecandidate",(function(t){return t.candidate&&Object.defineProperty(t,"candidate",{value:new e.RTCIceCandidate(t.candidate),writable:"false"}),t}))}}function zA(e){!e.RTCIceCandidate||e.RTCIceCandidate&&"relayProtocol"in e.RTCIceCandidate.prototype||$b(e,"icecandidate",(function(e){if(e.candidate){var t=GA.parseCandidate(e.candidate.candidate);"relay"===t.type&&(e.candidate.relayProtocol={0:"tls",1:"tcp",2:"udp"}[t.priority>>24])}return e}))}function KA(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=GA.splitSections(e.sdp);return t.shift(),t.some((function(e){var t=GA.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),o=function(e,n){var r=65536;"firefox"===t.browser&&57===t.version&&(r=65535);var i=GA.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===o?Number.POSITIVE_INFINITY:0===i||0===o?Math.max(i,o):Math.min(i,o);var a={};Object.defineProperty(a,"maxMessageSize",{get:function(){return e}}),this._sctp=a}return n.apply(this,arguments)}}}function qA(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},$b(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 YA(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 XA(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 QA(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 $A(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 ZA=Object.freeze({__proto__:null,shimRTCIceCandidate:JA,shimRTCIceCandidateRelayProtocol:zA,shimMaxMessageSize:KA,shimSendThrowTypeError:qA,shimConnectionState:YA,removeExtmapAllowMixed:XA,shimAddIceCandidateNullOrEmpty:QA,shimParameterlessSetLocalDescription:$A});!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=tA,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=Qb(n.userAgent,/Firefox\/(\d+)\./,1);else if(n.webkitGetUserMedia||!1===e.isSecureContext&&e.webkitRTCPeerConnection)t.browser="chrome",t.version=Qb(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=Qb(n.userAgent,/AppleWebKit\/(\d+)\./,1),t.supportsUnifiedPlan=e.RTCRtpTransceiver&&"currentDirection"in e.RTCRtpTransceiver.prototype}return t}(e),i={browserDetails:r,commonShim:ZA,extractVersion:Qb,disableLog:Zb,disableWarnings:eA,sdp:WA};switch(r.browser){case"chrome":if(!gA||!vA||!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=gA,QA(e,r),$A(e),cA(e,r),uA(e),vA(e,r),lA(e),mA(e,r),dA(e),hA(e),fA(e),_A(e,r),JA(e),zA(e),YA(e),KA(e,r),qA(e),XA(e,r);break;case"firefox":if(!DA||!TA||!t.shimFirefox)return n("Firefox shim is not included in this adapter release."),i;n("adapter.js shimming firefox."),i.browserShim=DA,QA(e,r),$A(e),yA(e,r),TA(e,r),EA(e),IA(e),kA(e),SA(e),bA(e),AA(e),RA(e),CA(e),wA(e),JA(e),YA(e),KA(e,r),qA(e);break;case"safari":if(!BA||!t.shimSafari)return n("Safari shim is not included in this adapter release."),i;n("adapter.js shimming safari."),i.browserShim=BA,QA(e,r),$A(e),LA(e),VA(e),OA(e),NA(e),xA(e),UA(e),PA(e),FA(e),JA(e),zA(e),KA(e,r),qA(e),XA(e,r);break;default:n("Unsupported browser!")}}({window:"undefined"==typeof window?void 0:window});var eR,tR=Object.create,nR=Object.defineProperty,rR=Object.defineProperties,iR=Object.getOwnPropertyDescriptor,oR=Object.getOwnPropertyDescriptors,aR=Object.getOwnPropertyNames,sR=Object.getOwnPropertySymbols,cR=Object.getPrototypeOf,uR=Object.prototype.hasOwnProperty,lR=Object.prototype.propertyIsEnumerable,dR=Reflect.get,hR=Math.pow,fR=function(e,t,n){return t in e?nR(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n},pR=function(e,t){for(var n in t||(t={}))uR.call(t,n)&&fR(e,n,t[n]);if(sR){var r,i=s(sR(t));try{for(i.s();!(r=i.n()).done;)n=r.value,lR.call(t,n)&&fR(e,n,t[n])}catch(o){i.e(o)}finally{i.f()}}return e},mR=function(e,t){return rR(e,oR(t))},vR=function(e,t){return function(){return t||e((t={exports:{}}).exports,t),t.exports}},_R=function(e,t){for(var n in t)nR(e,n,{get:t[n],enumerable:!0})},gR=function(e,t,n){return n=null!=e?tR(cR(e)):{},function(e,t,n,r){if(t&&"object"==k(t)||"function"==typeof t){var i,o=s(aR(t));try{var a=function(){var o=i.value;!uR.call(e,o)&&o!==n&&nR(e,o,{get:function(){return t[o]},enumerable:!(r=iR(t,o))||r.enumerable})};for(o.s();!(i=o.n()).done;)a()}catch(c){o.e(c)}finally{o.f()}}return e}(!t&&e&&e.__esModule?n:nR(n,"default",{value:e,enumerable:!0}),e)},yR=function(e,t,n,r){for(var i,o=r>1?void 0:r?iR(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&&nR(t,n,o),o},ER=function(e,t,n){return fR(e,"symbol"!=k(t)?t+"":t,n)},TR=function(e,t,n){return dR(cR(e),n,t)},kR=function(e,t,n){return new Promise((function(r,i){var o=function(e){try{s(n.next(e))}catch(Nx){i(Nx)}},a=function(e){try{s(n.throw(e))}catch(Nx){i(Nx)}},s=function(e){return e.done?r(e.value):Promise.resolve(e.value).then(o,a)};s((n=n.apply(e,t)).next())}))},SR=vR((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)})),IR=vR((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")}))}))})),bR=vR((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=IR(),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}}))}))}})),AR=vR((function(e,t){var n=IR(),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"}})),RR=vR((function(e){var t=bR(),n=AR();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})),CR=vR((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")}))}))})),wR=vR((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=CR(),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}}))}))}})),DR=vR((function(e,t){var n=CR(),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"}})),NR=vR((function(e){var t=wR(),n=DR();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})),xR=gR(SR()),OR=((eR=OR||{})[eR.INVALID_PARAMETER=4096]="INVALID_PARAMETER",eR[eR.INVALID_OPERATION=4097]="INVALID_OPERATION",eR[eR.NOT_SUPPORTED=4098]="NOT_SUPPORTED",eR[eR.DEVICE_NOT_FOUND=4099]="DEVICE_NOT_FOUND",eR[eR.INITIALIZE_FAILED=4100]="INITIALIZE_FAILED",eR[eR.SIGNAL_CHANNEL_SETUP_FAILED=16385]="SIGNAL_CHANNEL_SETUP_FAILED",eR[eR.SIGNAL_CHANNEL_ERROR=16386]="SIGNAL_CHANNEL_ERROR",eR[eR.ICE_TRANSPORT_ERROR=16387]="ICE_TRANSPORT_ERROR",eR[eR.JOIN_ROOM_FAILED=16388]="JOIN_ROOM_FAILED",eR[eR.CREATE_OFFER_FAILED=16389]="CREATE_OFFER_FAILED",eR[eR.SIGNAL_CHANNEL_RECONNECTION_FAILED=16390]="SIGNAL_CHANNEL_RECONNECTION_FAILED",eR[eR.UPLINK_RECONNECTION_FAILED=16391]="UPLINK_RECONNECTION_FAILED",eR[eR.DOWNLINK_RECONNECTION_FAILED=16392]="DOWNLINK_RECONNECTION_FAILED",eR[eR.REMOTE_STREAM_NOT_EXIST=16400]="REMOTE_STREAM_NOT_EXIST",eR[eR.CLIENT_BANNED=16448]="CLIENT_BANNED",eR[eR.SERVER_TIMEOUT=16449]="SERVER_TIMEOUT",eR[eR.SUBSCRIPTION_TIMEOUT=16450]="SUBSCRIPTION_TIMEOUT",eR[eR.PLAY_NOT_ALLOWED=16451]="PLAY_NOT_ALLOWED",eR[eR.DEVICE_AUTO_RECOVER_FAILED=16452]="DEVICE_AUTO_RECOVER_FAILED",eR[eR.START_PUBLISH_CDN_FAILED=16453]="START_PUBLISH_CDN_FAILED",eR[eR.STOP_PUBLISH_CDN_FAILED=16454]="STOP_PUBLISH_CDN_FAILED",eR[eR.START_MIX_TRANSCODE_FAILED=16455]="START_MIX_TRANSCODE_FAILED",eR[eR.STOP_MIX_TRANSCODE_FAILED=16456]="STOP_MIX_TRANSCODE_FAILED",eR[eR.NOT_SUPPORTED_H264=16457]="NOT_SUPPORTED_H264",eR[eR.SWITCH_ROLE_FAILED=16458]="SWITCH_ROLE_FAILED",eR[eR.API_CALL_TIMEOUT=16459]="API_CALL_TIMEOUT",eR[eR.SCHEDULE_FAILED=16460]="SCHEDULE_FAILED",eR[eR.API_CALL_ABORTED=16461]="API_CALL_ABORTED",eR[eR.SPC_INITIALIZED_FAILED=16462]="SPC_INITIALIZED_FAILED",eR[eR.VIDEO_MANAGER_ERROR=16463]="VIDEO_MANAGER_ERROR",eR[eR.UNKNOWN=65535]="UNKNOWN",eR),PR=OR,MR=function(e){function i(e){var o;r(this,i);var a=e.name,s=void 0===a?"RtcError":a,c=e.message,u=e.code,l=void 0===u?PR.UNKNOWN:u,d=e.extraCode,h=void 0===d?0:d,f=e.constraint,p="<".concat(function(e){for(var t in PR)if(PR[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 o=n(this,i,[m]),ER(t(o),"code"),ER(t(o),"extraCode"),ER(t(o),"message"),ER(t(o),"originMessage"),ER(t(o),"name"),ER(t(o),"constraint"),o.code=l,o.extraCode=h,o.name=s,o.message=m,o.constraint=f,o.originMessage=c,o}return d(i,e),a(i,[{key:"getCode",value:function(){return this.code}},{key:"getExtraCode",value:function(){return this.extraCode}},{key:"toString",value:function(){return this.originMessage}}])}(I(Error)),LR=MR,UR=((new Date).getTime(),0),VR=function(){return(new Date).getTime()+UR},FR=function(){var e=new Date;return e.setTime(VR()),e.toLocaleString()},BR=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)},jR={};_R(jR,{bytes2ms:function(){return Dw},convertObjectNumberToInt:function(){return yD},copyProperties:function(){return ww},deepClone:function(){return uD},deepMerge:function(){return cD},delay:function(){return ED},fibonacci:function(){return Uw},formatedTime:function(){return hD},getConstructorName:function(){return Qw},getContainerFromElement:function(){return dD},getEnv:function(){return Tw},getInternalVersion:function(){return nD},getLoggerUrl:function(){return Sw},getMuteStateFromFlag:function(){return oD},getNetworkType:function(){return bw},getNumNetworkType:function(){return Cw},getReconnectionTimeout:function(){return Vw},getStringByteLength:function(){return mD},getTurnServer:function(){return aD},getUint32Version:function(){return gD},getValueType:function(){return Fw},getViewListFromView:function(){return lD},glog:function(){return Pw},ipv4ToUint32:function(){return sD},isArray:function(){return zw},isAudioWorkletSupported:function(){return $w},isBoolean:function(){return Ww},isConstructor:function(){return Xw},isEmpty:function(){return iD},isFunction:function(){return Bw},isLangChinese:function(){return Mw},isMediaStreamTrack:function(){return Kw},isNumber:function(){return Gw},isObject:function(){return Jw},isOverseaSdkAppId:function(){return kw},isPlainObject:function(){return Lw},isPortrait:function(){return vD},isPromise:function(){return Yw},isRemoteTrack:function(){return qw},isString:function(){return Hw},isUndefined:function(){return jw},loadImage:function(){return _D},ms2bytes:function(){return xw},ms2samples:function(){return Ow},performanceNow:function(){return eD},promiseAny:function(){return Zw},samples2ms:function(){return Nw},setNetworkType:function(){return Rw},stringify:function(){return fD},stringifyIncludeValue:function(){return pD},throttlePromise:function(){return TD}});var HR={};_R(HR,{AUDIO_MUTE_BIT:function(){return RC},AUDIO_STAT_BIT:function(){return AC},AUX_STAT_BIT:function(){return bC},AUX_STREAM_MSID:function(){return xC},BACKEND_ENV:function(){return TC},BASE_DOC_URL:function(){return rC},BASE_HOST:function(){return ZR},CAPABILITIES_KEYS:function(){return yw},CLASS_NAME:function(){return lw},CLOUD_CONSOLE_URL:function(){return nC},CROSS_ROOM_BIT:function(){return DC},DATA_FREEZE_TIMING:function(){return rw},DEFAULT_ASSETS_URL:function(){return iC},DOC_URL:function(){return oC},DTLS_STATE_UNKNOWN:function(){return HC},ENV_NAME:function(){return lC},EXCHANGE_SDP_TIMEOUT:function(){return $C},IS_WORKER:function(){return qR},IS_WORKLET:function(){return YR},KIBANA_EVENT:function(){return YC},LOCAL_STREAM_PUBLISH_STATE:function(){return nw},LOGGER_CMD_TYPE:function(){return uC},LOGGER_DOMAIN:function(){return aC},LOGGER_DOMAIN_OVERSEA:function(){return sC},LOG_LEVEL:function(){return dC},LOG_LEVEL_NAME:function(){return mw},MAIN_STREAM_MSID:function(){return NC},MAX_RTT:function(){return Ew},MICROPHONE_COMMUNICATIONS:function(){return pw},MICROPHONE_DEFAULT:function(){return hw},MUTE_ALL_BIT:function(){return wC},NAME:function(){return yC},NETWORK_TYPE:function(){return pC},NOT_SUPPORTED_H264:function(){return tw},PAUSED_RETRY_COUNT:function(){return dw},PEERCONNECTION_CONNECTING_TIMEOUT:function(){return sw},PEER_CONNECTION_STATE:function(){return GC},PEER_LEAVE_REASON:function(){return vw},RECOVER_CAPTURE_INTERVAL:function(){return gw},REMOTE_STREAM_TYPE_AUX:function(){return PC},REMOTE_STREAM_TYPE_MAIN:function(){return OC},RENDER_FREEZE_TIMING:function(){return iw},SCHEDULE_DOMAIN:function(){return cw},SCHEDULE_TIMEOUT:function(){return uw},SDP_SEMANTICS_PLAN_B:function(){return ew},SDP_SEMANTICS_UNIFIED_PLAN:function(){return ZC},SECOND_HOST:function(){return eC},SIGNAL_PING_PONG_INTERVAL:function(){return fC},SIGNAL_PING_TIMEOUT:function(){return hC},SIGNAL_RECONNECTION_COUNT:function(){return qC},SMALL_STAT_BIT:function(){return IC},SPEAKER_DEFAULT:function(){return fw},STORAGE_EXPIRES_TIME:function(){return mC},STREAM_TYPE_BIG:function(){return ow},STREAM_TYPE_SMALL:function(){return aw},SUBSCRIBE_SMALL_RETRY_COUNT:function(){return _w},SYNC_USER_LIST_INTERVAL:function(){return XC},Scene:function(){return kC},THIRD_HOST:function(){return tC},TRANSPORT_DIRECTION:function(){return EC},TRTC_ERROR_ASSISTANCE:function(){return cC},TRTC_QUALITY_BAD:function(){return FC},TRTC_QUALITY_DISCONNECTED:function(){return jC},TRTC_QUALITY_EXCELLENT:function(){return LC},TRTC_QUALITY_GOOD:function(){return UC},TRTC_QUALITY_POOR:function(){return VC},TRTC_QUALITY_UNKNOWN:function(){return MC},TRTC_QUALITY_VERY_BAD:function(){return BC},UPDATE_OFFER_TIMEOUT:function(){return QC},VIDEO_MUTE_BIT:function(){return CC},VIDEO_STAT_BIT:function(){return SC},audioProfileMap:function(){return vC},getRetryCount:function(){return zC},getScriptDir:function(){return XR},innerVersion:function(){return GR},loggerProxy:function(){return QR},screenProfileMap:function(){return gC},setLoggerProxy:function(){return $R},setRetryCount:function(){return JC},setVersion:function(){return JR},version:function(){return WR},videoProfileMap:function(){return _C}});var GR="4.15.00.1600",WR="5.0.0";function JR(e){WR=e;var t=v(e.split(".").map((function(e){return parseInt(e,10)})),3),n=t[0],r=t[1],i=t[2];GR="".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 zR,KR,qR="undefined"!=typeof importScripts,YR="undefined"!=typeof registerProcessor,XR=function(){var e=qR?self.location.href:document.currentScript.src;return e.substring(0,e.lastIndexOf("/")+1)},QR="",$R=function(e){return QR=e},ZR="web.sdk.qcloud.com",eC="web.sdk.tencent.cn",tC="web.sdk.cloud.tencent.cn",nC="https://console.cloud.tencent.com/trtc",rC="https://".concat(ZR,"/trtc/webrtc/v5/doc"),iC="https://web.sdk.qcloud.com/trtc/webrtc/v5/assets/",oC="".concat(rC,"/zh-cn/"),aC="https://yun.tim.qq.com",sC="https://apisgp.my-imcloud.com",cC="trtc_error_assistance",uC={LOG:"jssdk_log",EVENT:"jssdk_event",KEY_POINT:"jssdk_new_endreport",KV_STAT:"jssdk_key_metrics_report"},lC={QCLOUD:"qcloud",OLD_CLOUD_LADDER:"trtc",WEBRTC:"webrtc"},dC=((KR=dC||{})[KR.TRACE=0]="TRACE",KR[KR.DEBUG=1]="DEBUG",KR[KR.INFO=2]="INFO",KR[KR.WARN=3]="WARN",KR[KR.ERROR=4]="ERROR",KR[KR.NONE=5]="NONE",KR),hC=18e3,fC=2e3,pC={unknown:0,wifi:1,"3g":2,"2g":3,"4g":4,wired:5,"5g":6},mC=6048e5,vC={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}},_C={"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}},gC={"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}},yC={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"},EC={INACTIVE:"inactive",SENDONLY:"sendonly",RECVONLY:"recvonly"},TC={OLD_CLOUD_LADDER:"wss://trtc.rtc.qq.com",WEBRTC:"wss://webrtc.qq.com"},kC=((zR=kC||{}).LIVE="live",zR.RTC="rtc",zR),SC=1,IC=2,bC=4,AC=8,RC=64,CC=16,wC=112,DC=128,NC="5Y2wZK8nANNAoVw6dSAHVjNxrD1ObBM2kBPV",xC="224d130c-7b5c-415b-aaa2-79c2eb5a6df2",OC=yC.MAIN,PC=yC.AUXILIARY,MC=0,LC=1,UC=2,VC=3,FC=4,BC=5,jC=6,HC="unknown",GC={NEW:"new",CONNECTING:"connecting",FAILED:"failed",CLOSED:"closed",DISCONNECTED:"disconnected",CONNECTED:"connected",COMPLETED:"completed"},WC=1/0;function JC(e){WC=e}function zC(){return WC}var KC,qC=30,YC={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"},XC=1e4,QC=1e4,$C=1e4,ZC="unified-plan",ew="plan-b",tw=1028,nw=((KC=nw||{})[KC.UNPUBLISH=-1]="UNPUBLISH",KC[KC.PUBLISHING=0]="PUBLISHING",KC[KC.PUBLISHED=1]="PUBLISHED",KC),rw=500,iw=1e3,ow=yC.BIG,aw=yC.SMALL,sw=1e4,cw={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"},uw=2e3,lw={TRTC:"TRTC",CLIENT:"Client",LOCAL_STREAM:"LocalStream",REMOTE_STREAM:"RemoteStream",STREAM:"Stream"},dw=5,hw="default",fw=hw,pw="communications",mw=Object.keys(dC),vw=["normal leave","timeout leave","kick","role change"],_w=10,gw=2e3,yw=["width","height","frameRate","facingMode","sampleRate","sampleSize","channelCount","deviceId","min","max"],Ew=1e4,Tw=function(){return new URLSearchParams(location.search).get("trtc_env")||""},kw=function(e){return Number(e)<14e8},Sw=function(e,t){var n;n=QR||(kw(e)?sC:aC);var r=Math.floor(Math.random()*hR(2,31));return"".concat(n,"/v5/AVQualityReportSvc/C2S?random=").concat(r,"&sdkappid=").concat(e,"&cmdtype=").concat(t)},Iw="unknown";function bw(){if("unknown"!==Iw)return Iw;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&&(Iw=Aw(i,o)),Iw}function Aw(e,t){if(pC[e])return e;switch(e){case"cellular":case"wimax":return t||"unknown";case"ethernet":return"wired";default:return"unknown"}}function Rw(e){Iw=Aw(e)}function Cw(){return pC[bw()]}function ww(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 o=Object.getOwnPropertyDescriptor(t,i)||"";Object.defineProperty(e,i,o)}}}catch(a){r.e(a)}finally{r.f()}return e}function Dw(e){return Nw(e/4,arguments.length>1&&void 0!==arguments[1]?arguments[1]:48e3)}function Nw(e){return 1e3*e/(arguments.length>1&&void 0!==arguments[1]?arguments[1]:48e3)}function xw(e){return 4*Ow(e,arguments.length>1&&void 0!==arguments[1]?arguments[1]:48e3)}function Ow(e){return e*(arguments.length>1&&void 0!==arguments[1]?arguments[1]:48e3)/1e3}var Pw="undefined"!=typeof window&&"function"==typeof window.glog?window.glog:function(){},Mw=function(){var e=navigator.language;return"zh"===(e=e.substring(0,2))},Lw=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 Uw(e){var t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1;return e<=1?t:Uw(e-1,t,(arguments.length>1&&void 0!==arguments[1]?arguments[1]:1)+t)}function Vw(e){return e>8?3e4:1e3*Uw(e)}function Fw(e){return Reflect.apply(Object.prototype.toString,e,[]).replace(/^\[object\s(\w+)\]$/,"$1").toLowerCase()}var Bw=function(e){return"function"==typeof e},jw=function(e){return void 0===e},Hw=function(e){return"string"==typeof e},Gw=function(e){return"number"==typeof e},Ww=function(e){return"boolean"==typeof e},Jw=function(e){return"object"===Fw(e)},zw=function(e){return"array"===Fw(e)},Kw=function(e){return Fw(e)==="MediaStreamTrack".toLowerCase()},qw=function(e){return e.isRemote},Yw=function(e){return"promise"===Fw(e)},Xw=function(e){return Bw(e)&&e.prototype.constructor===e},Qw=function(e){return Xw(e)?e.prototype.constructor.name:""},$w="undefined"!=typeof AudioWorkletNode;function Zw(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 eD(){return performance&&performance.now?Math.floor(performance.now()):Date.now()}var tD=function(e){return+e<10?"0".concat(e):e},nD=function(e){var t=e.match(/^\d+\.\d+\.\d+/)[0];if(!t)return e;var n=t.split("."),r=tD(n[1])+tD(n[2]);return n[1]-15>0&&(n[1]="15"),n[2]-15>0&&(n[2]="15"),"".concat(n.join("."),".").concat(r)},rD=Object.prototype.hasOwnProperty;function iD(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(Lw(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(rD.call(e,t))return!1;return!0}return!1}function oD(e,t){return{userId:t,hasAudio:!!(e&AC),hasVideo:!!(e&SC),hasAuxiliary:!!(e&bC),hasSmall:!!(e&IC),audioMuted:!!(e&RC),videoMuted:!!(e&CC),audioAvailable:!(!(e&AC)||e&RC),videoAvailable:!(!(e&SC)||e&CC)}}function aD(e){var t={urls:e.url.startsWith("turn:")||e.url.startsWith("turns:")?e.url:"turn:".concat(e.url)};return!jw(e.username)&&!jw(e.credential)&&(t.username=e.username,t.credential=e.credential,t.credentialType="password",jw(e.credentialType)||(t.credentialType=e.credentialType)),t}function sD(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];if(!Hw(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 cD=function(e,t,n,r){if(!Jw(e)||!Jw(t))return 0;for(var i,o=0,a=Object.keys(t),s=0,c=a.length;s<c;s++)if(i=a[s],!(jw(t[i])||n&&n.includes(i)))if(Jw(e[i])&&Jw(t[i]))o+=cD(e[i],t[i],n,r);else{if(r&&r.includes(t[i]))continue;e[i]!==t[i]&&(e[i]=uD(t[i]),o+=1)}return o};function uD(e){if(zw(e)){var t=[];return e.forEach((function(e,n){t[n]=uD(e)})),t}if(Jw(e)){var n={};return Object.keys(e).forEach((function(t){n[t]=uD(e[t])})),n}return e}var lD=function(e){var t=[];if(zw(e))t=E(e);else if(Hw(e)){var n=document.getElementById(e);n&&t.push(n)}else e&&t.push(e);return t},dD=function(e){return Hw(e)?document.getElementById(e):e},hD=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 fD(e,t){var n=t.keysToInclude,r=t.keysToExclude;try{if(zw(e))return"[".concat(e.map((function(e){return fD(e,{keysToInclude:n,keysToExclude:r})})).join(","),"]");if(!Lw(e)||!zw(n)&&!zw(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]=Lw(e[t])||zw(e[t])?JSON.parse(fD(e[t],{keysToExclude:r,keysToInclude:n})):e[t])})),JSON.stringify(i)}catch(KC){return"{}"}}function pD(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)})),fD(e,{keysToInclude:n})}function mD(e){return e.replace(/[\u4e00-\u9fa5]/g,"aa").length}var vD=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},_D=function(e){return kR(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(Hw(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 LR({code:PR.INVALID_PARAMETER,message:"load image failed, url: ".concat(e)}))}})));case 1:case"end":return t.stop()}}),t)})))},gD=function(e){var t=e.split(".");return+t[0]<<24|+t[1]<<16|+t[2]<<8|+t[3]},yD=function(e){return Object.keys(e).forEach((function(t){Gw(e[t])&&(t.startsWith("uint")||t.startsWith("int"))?e[t]=Math.floor(e[t]):(Lw(e[t])||zw(e[t]))&&yD(e[t])})),e};function ED(e,t){return new Promise((function(n){var r=setTimeout(n,e);t&&t(r)}))}function TD(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 kD(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(Nx){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=o||5e3,s.open(i,t,!0),s.send(n)}))}function SD(e){return kR(this,null,f().mark((function t(){var n,r,i,o;return f().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=eD(),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",(bx.debug("compressJSON ".concat(r.length," -> ").concat(o.byteLength," ").concat(eD()-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 ID=Object.prototype.hasOwnProperty,bD=function(e){return"function"==typeof e},AD=function(e){return void 0===e},RD=function(e){return e.isRemote};function CD(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(ID.call(e,t))return!1;return!0}return!1}var wD=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,p=n.timeout,m=void 0===p?1e3:p,v=0,_=-1,g=0,y=function(n,c){return kR(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&&a&&a.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<(bD(h)?h():h)?(v++,g=1,bD(i)&&i.call(T,v,p),_=window.setTimeout((function(){_=-1,y(n,c)}),bD(m)?m(v):m)):(p(),bD(o)&&o.call(T,e.t0))},bD(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)}},DD=function(){function e(t){r(this,e),ER(this,"userId"),ER(this,"remoteUserId"),ER(this,"id"),ER(this,"sdkAppId"),ER(this,"type"),ER(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}return a(e,[{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):"","]")),bx.log(e,t,AD(this.userId)||CD(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)}}])}(),ND={};_R(ND,{ANDROID_VERSION:function(){return WD},CHROME_MAJOR_VERSION:function(){return qN},CHROME_VERSION:function(){return YN},EDGE_VERSION:function(){return QD},EDG_MAJOR_VERSION:function(){return eN},EDG_VERSION:function(){return ZD},FIREFOX_MAJOR_VERSION:function(){return YD},FIREFOX_VERSION:function(){return qD},HUAWEI_VERSION:function(){return MN},IE_VERSION:function(){return dN},IOS_MAIN_VERSION:function(){return tx},IOS_VERSION:function(){return ex},IPADQQB_VERSION:function(){return kN},IS_ANDROID:function(){return GD},IS_ANDROID_WEBVIEW:function(){return ZN},IS_ANY_SAFARI:function(){return QN},IS_CHROME:function(){return zN},IS_CHROME_OS:function(){return AN},IS_CHROMIUM_BASE:function(){return JN},IS_EDG:function(){return $D},IS_EDGE:function(){return XD},IS_ELECTRON:function(){return wN},IS_FIREFOX:function(){return KD},IS_HEADLESS_CHROME:function(){return KN},IS_HONOR:function(){return PN},IS_HUAWEI:function(){return ON},IS_HUAWEIBROWSER:function(){return xN},IS_IE:function(){return lN},IS_IE8:function(){return uN},IS_IOS:function(){return HD},IS_IOS_13_OR_14:function(){return ix},IS_IOS_15_1:function(){return rx},IS_IPAD:function(){return VD},IS_IPADQQB:function(){return TN},IS_IPAD_PRO:function(){return FD},IS_IPHONE:function(){return BD},IS_IPOD:function(){return jD},IS_LINUX:function(){return bN},IS_LOCAL:function(){return ox},IS_MAC:function(){return IN},IS_MACQQB:function(){return yN},IS_MIBROWSER:function(){return DN},IS_MQQB:function(){return mN},IS_NATIVE_ANDROID:function(){return zD},IS_OLD_ANDROID:function(){return JD},IS_OPENHARMONY:function(){return HN},IS_OPPOBROWSER:function(){return VN},IS_SAFARI:function(){return XN},IS_SAFARI_15_1:function(){return nx},IS_SAMSUNGBROWSER:function(){return LN},IS_SOGOU:function(){return rN},IS_SOGOUM:function(){return tN},IS_TBS:function(){return oN},IS_UCBROWSER:function(){return CN},IS_VIVOBROWSER:function(){return BN},IS_WECHAT:function(){return hN},IS_WIN:function(){return SN},IS_WQQB:function(){return _N},IS_WX:function(){return RN},IS_X5MQQB:function(){return pN},IS_XWEB:function(){return sN},MACQQB_VERSION:function(){return EN},MI_VERSION:function(){return NN},MQQB_VERSION:function(){return vN},OPENHARMONY_VERSION:function(){return GN},OPPO_VERSION:function(){return FN},SAFARI_VERSION:function(){return $N},SAMSUNG_VERSION:function(){return UN},SOGOUM_VERSION:function(){return nN},SOGOU_VERSION:function(){return iN},TBS_VERSION:function(){return aN},UA_DATA_STRING:function(){return dx},USER_AGENT:function(){return xD},VIVO_VERSION:function(){return jN},WECHAT_VERSION:function(){return fN},WQQB_VERSION:function(){return gN},XWEB_VERSION:function(){return cN},browserInfo:function(){return sx},getBrowserInfo:function(){return cx},getChromeMajorVersion:function(){return WN},getDeviceModel:function(){return fx},getOSName:function(){return mx},getOSNumber:function(){return vx},getOSString:function(){return _x},getOSType:function(){return yx},getTerminalType:function(){return gx},getUserAgentData:function(){return hx},isLocalStorageEnabled:function(){return ax},isMobile:function(){return lx}});var xD="undefined"==typeof navigator?"":navigator.userAgent,OD=function(e){return new RegExp(e,"i").test(xD)},PD=function(e){if(OD(e)){var t=new RegExp("".concat(e,"\\/([\\d.]+)")),n=xD.match(t);if(n&&n[1])return n[1]}return""},MD=function(e){if(OD(e)){var t=new RegExp("".concat(e,"\\/(\\d+)")),n=xD.match(t);if(n&&n[1])return parseFloat(n[1])}return NaN},LD=/AppleWebKit\/([\d.]+)/i.exec(xD),UD=LD?parseFloat(LD[1]):NaN,VD=OD("iPad"),FD="undefined"!=typeof navigator&&navigator.maxTouchPoints&&navigator.maxTouchPoints>2&&OD("Macintosh"),BD=OD("iPhone")&&!VD,jD=OD("iPod"),HD=BD||VD||jD||FD,GD=OD("Android"),WD=function(){if(GD){var e=xD.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}(),JD=GD&&OD("webkit")&&WD<2.3,zD=GD&&WD<5&&UD<537,KD=OD("Firefox"),qD=PD("Firefox"),YD=MD("Firefox"),XD=OD("Edge"),QD=PD("Edge"),$D=OD("Edg"),ZD=PD("Edg"),eN=MD("Edg"),tN=OD("SogouMobileBrowser"),nN=PD("SogouMobileBrowser"),rN=OD("MetaSr\\s"),iN=PD("MetaSr\\s"),oN=OD("TBS"),aN=PD("TBS"),sN=OD("XWEB"),cN=PD("XWEB"),uN=OD("MSIE\\s8\\.0"),lN=OD("MSIE\\/\\d+"),dN=function(){if(lN){var e=/MSIE\s(\d+)\.\d/.exec(xD),t=e&&parseFloat(e[1]);return!t&&/Trident\/7.0/i.test(xD)&&/rv:11.0/.test(xD)&&(t=11),t}return NaN}(),hN=OD("(micromessenger|webbrowser)"),fN=PD("MicroMessenger"),pN=!oN&&OD("MQQBrowser")&&OD("COVC"),mN=!oN&&OD("MQQBrowser")&&!OD("COVC"),vN=mN||pN?PD("MQQBrowser"):"",_N=!oN&&OD(" QQBrowser"),gN=PD(" QQBrowser"),yN=!oN&&OD("QQBrowserLite"),EN=PD("QQBrowserLite"),TN=!oN&&OD("MQBHD"),kN=PD("MQBHD"),SN=OD("Windows"),IN=!HD&&OD("MAC OS X"),bN=!GD&&OD("Linux"),AN=OD("CrOS"),RN=OD("MicroMessenger"),CN=OD("UCBrowser"),wN=OD("Electron"),DN=OD("MiuiBrowser"),NN=PD("MiuiBrowser"),xN=OD("HuaweiBrowser"),ON=OD("Huawei")||OD("HUAWEI"),PN=OD("Honor")||OD("HONOR"),MN=PD("HuaweiBrowser"),LN=OD("SamsungBrowser"),UN=PD("SamsungBrowser"),VN=OD("HeyTapBrowser"),FN=PD("HeyTapBrowser"),BN=OD("VivoBrowser"),jN=PD("VivoBrowser"),HN=OD("OpenHarmony"),GN=PD("OpenHarmony"),WN=function(){return MD("Chrome")},JN=OD("Chrome"),zN=!XD&&!rN&&!tN&&!oN&&!sN&&!$D&&!_N&&!DN&&!xN&&!LN&&!VN&&!BN&&JN,KN=OD("HeadlessChrome"),qN=WN(),YN=PD("Chrome"),XN=!JN&&!mN&&!pN&&!yN&&!TN&&OD("Safari"),QN=XN||HD,$N=PD("Version"),ZN=/Android.*(wv|.0.0.0)/.test(xD),ex=function(){if(FD)return $N;if(HD){var e=xD.match(/OS (\d+)_(\d+)/i);if(e&&e[1]){var t=e[1];return e[2]&&(t+=".".concat(e[2])),t}}return""}(),tx=Number(ex.split(".")[0]),nx="15.1"===$N,rx="15.1"===ex,ix=function(){var e=Number(ex.split(".")[0]);return 14===e||13===e}(),ox="undefined"!=typeof location&&("file:"===location.protocol||"localhost"===location.hostname||"127.0.0.1"===location.hostname),ax=function(){var e;return function(){if(void 0===e)try{e=!!window.localStorage}catch(Ox){e=!1}return e}}(),sx=cx();function cx(){var e,t=new Map([[KD,["Firefox",qD]],[$D,["Edg",ZD]],[zN,["Chrome",YN]],[XN,["Safari",$N]],[oN,["TBS",aN]],[sN,["XWEB",cN]],[hN&&BD,["WeChat",fN]],[_N,["QQ(Win)",gN]],[mN,["QQ(Mobile)",vN]],[pN,["QQ(Mobile X5)",vN]],[yN,["QQ(Mac)",EN]],[TN,["QQ(iPad)",kN]],[DN,["MI",NN]],[xN,["HW",MN]],[LN,["Samsung",UN]],[VN,["OPPO",FN]],[BN,["VIVO",jN]],[XD,["EDGE",QD]],[tN,["SogouMobile",nN]],[rN,["Sogou",iN]]]),n="unknown",r="unknown";return t.has(!0)&&(n=(e=v(t.get(!0),2))[0],r=e[1]),{name:n,version:r}}var ux=null;function lx(){return ux&&"boolean"==typeof ux.mobile?ux.mobile:GD||HD||BD||VD||HN}var dx="";function hx(){return kR(this,null,f().mark((function e(){return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!ux){e.next=2;break}return e.abrupt("return",ux);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=ux=e.sent,!e.t0){e.next=10;break}e.t0=!dx;case 10:if(e.t1=e.t0,!e.t1){e.next=13;break}dx="UAData: ".concat(ux.platform,"/").concat(ux.platformVersion),ux.architecture&&ux.bitness&&(dx+=" ".concat(ux.architecture,"/").concat(ux.bitness)),ux.mobile&&(dx+=" mobile"),ux.model&&(dx+=" model: ".concat(ux.model)),ux.fullVersionList&&(dx+=" ".concat(ux.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",ux);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 fx(){return(null==ux?void 0:ux.model)||""}var px=new Map([[GD,"Android"],[HD,"iOS"],[SN,"Windows"],[IN,"MacOS"],[bN,"Linux"],[AN,"ChromeOS"]]),mx=function(){return px.get(!0)?px.get(!0):ux?ux.platform:"unknown"};function vx(){return SN?1:GD?2:IN?3:HD?4:bN?5:AN?6:0}var _x=function(){var e=mx();return e+="/".concat(sx.name,"/").concat(XN?sx.version:sx.version.split(".")[0]),null!=ux&&ux.platformVersion&&(e+="/".concat(ux.platformVersion)),null!=ux&&ux.architecture&&(e+="/".concat(ux.architecture)),e};function gx(){return GD?4:BD?2:VD?3:IN?12:SN?5:bN?13:HN?22:1}function yx(){return GD?"Android":BD?"iPhone":VD?"iPad":IN?"Mac":SN?"Windows":bN?"Linux":"unknown"}var Ex,Tx=new(gR(SR(),1).default),kx=((Ex=kx||{}).ROOM_DESTROY="1",Ex.JOIN_START="21",Ex.JOIN_SCHEDULE_SUCCESS="22",Ex.JOIN_SIGNAL_CONNECTION_START="23",Ex.JOIN_SIGNAL_CONNECTION_END="24",Ex.JOIN_SEND_CMD="25",Ex.JOIN_RECEIVED_CMD_RES="26",Ex.JOIN_SUCCESS="27",Ex.JOIN_FAILED="28",Ex.LEAVE_START="51",Ex.LEAVE_SEND_CMD="52",Ex.LEAVE_SUCCESS="53",Ex.PUBLISH_START="61",Ex.SEND_FIRST_VIDEO_FRAME="62",Ex.PUBLISH_FAILED="63",Ex.SUBSCRIBE_START="81",Ex.SUBSCRIBE_SUCCESS="82",Ex.SUBSCRIBE_FAILED="84",Ex.UNSUBSCRIBE_SUCCESS="83",Ex.LOCAL_TRACK_CAPTURE_START="101",Ex.LOCAL_TRACK_CAPTURE_SUCCESS="102",Ex.LOCAL_TRACK_CAPTURE_FAILED="103",Ex.LOCAL_TRACK_PUBLISHED="104",Ex.LOCAL_TRACK_UNPUBLISHED="105",Ex.LOCAL_TRACK_REPLACED="106",Ex.SWITCH_DEVICE_SUCCESS="107",Ex.TRACK_MUTED="108",Ex.TRACK_UNMUTED="109",Ex.REMOTE_TRACK_SUBSCRIBED="110",Ex.REMOTE_TRACK_UNSUBSCRIBED="111",Ex.LOCAL_TRACK_RECAPTURE="112",Ex.PLAY_TRACK_START="151",Ex.PLAYER_STATE_CHANGED="152",Ex.VIDEO_LOADED_DATA="153",Ex.AUTOPLAY_DIALOG_CLICK_CONFIRM="154",Ex.SIGNAL_CONNECTION_STATE_CHANGED="201",Ex.PEER_CONNECTION_STATE_CHANGED="202",Ex.SINGLE_CONNECTION_STAT="203",Ex.SPC_RECONNECTED="204",Ex.HEARTBEAT_REPORT="251",Ex.RECEIVED_PUBLISHED_USER_LIST="252",Ex.REMOTE_PUBLISH_STATE_CHANGED="253",Ex.AUDIO_LEVEL_INTERVAL="260",Ex.NETWORK_QUALITY="261",Ex.VIDEO_CODEC_IMPLEMENTATION_CHANGED="262",Ex.QUALITY_LIMITATION_CHANGED="263",Ex.LOG="264",Ex),Sx=kx,Ix=function(){function e(){r(this,e),ER(this,"_isEnableUploadLog",!0),ER(this,"_localJoinedUser",new Map),ER(this,"_queue",[]),ER(this,"_timeoutId",-1),ER(this,"_logLevel",1),ER(this,"_logLevelToUpload",2),!qR&&!YR&&(this.checkURLParam(),this.installEvents())}return a(e,[{key:"isAbleToUpload",get:function(){return this._isEnableUploadLog&&-1!==this._timeoutId}},{key:"installEvents",value:function(){var e=this;Tx.on(Sx.JOIN_SCHEDULE_SUCCESS,(function(t){var n,r=t.schedule;null!=(n=null==r?void 0:r.config)&&n.logLevelToUpload&&dC[r.config.logLevelToUpload]&&(e._logLevelToUpload=r.config.logLevelToUpload)})),Tx.on(Sx.JOIN_SUCCESS,(function(t){var n=t.room;e.addJoinedUser({userId:n.userId,sdkAppId:n.sdkAppId}),e.startUpload()})),Tx.once(Sx.JOIN_FAILED,(function(){e.startUpload()})),Tx.on(Sx.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(Hw(r.userId)&&Gw(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 kR(this,null,f().mark((function e(){var t,n,r,i,o,a,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()),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:FR(),sdkAppId:String(c),userId:s,version:WR,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 wD({retryFunction:function(){return kD({url:Sw(t,uC.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(VR()),"[".concat(BR(t),"] <").concat(dC[e],">")}},{key:"getLogLevel",value:function(){return this._logLevel}},{key:"setLogLevel",value:function(e){jw(dC[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(Hw(e))return e;try{return e instanceof Error?e.toString():JSON.stringify(e)}catch(zR){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(Tx.emit(Sx.LOG,{log:l}),this._isEnableUploadLog&&t>=this._logLevelToUpload&&this._queue.push(l),!(t<this._logLevel)){var d=(null==(o=dC[t])?void 0:o.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 DD(e)}},{key:"checkURLParam",value:function(){var e=new URLSearchParams(location.search).get("logLevelToUpload"),t=e?Number(e):-1;dC[t]&&(this._logLevelToUpload=t)}},{key:"getQueue",value:function(){return this._queue}}])}();ER(Ix,"PRINT_LOG_TAG",!(HD||GD||KN));var bx=new Ix,Ax=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)}))},Rx=new(function(){function e(){r(this,e),ER(this,"_prefix","TRTC"),ER(this,"_queue",new Map)}return a(e,[{key:"getRealKey",value:function(e){return"".concat(this._prefix,"_").concat(e)}},{key:"checkStorage",value:function(){var e=this;ax()&&(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(Px){return!1}return!1})).forEach((function(e){return localStorage.removeItem(e)})))}},{key:"doFlush",value:function(){if(ax())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(o){t.e(o)}finally{t.f()}}catch(Ox){bx.warn(Ox)}}},{key:"getItem",value:function(e){if(!ax())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(zR){bx.warn(zR)}}},{key:"setItem",value:function(e,t){if(ax())try{var n={expiresIn:Date.now()+mC,value:t};this._queue.set(this.getRealKey(e),n)}catch(KC){bx.warn(KC)}}},{key:"deleteItem",value:function(e){if(!ax())return!1;try{return e=this.getRealKey(e),this._queue.delete(e),localStorage.removeItem(e),!0}catch(zR){return bx.warn(zR),!1}}},{key:"clear",value:function(){if(ax())try{localStorage.clear()}catch(Ox){bx.warn(Ox)}}}])}()),Cx={};_R(Cx,{HTTPS_API:function(){return oP},IS_GET_CAPABILITIES_SUPPORTED:function(){return IP},IS_GET_SETTINGS_SUPPORTED:function(){return SP},IS_GET_SYNCHRONIZATION_SOURCES_SUPPORTED:function(){return kP},IS_INSERTABLE_STREAM_SUPPORTED:function(){return bP},IS_JITTER_BUFFER_TARGET_SUPPORTED:function(){return UP},IS_RTC_RTP_SENDER_SUPPORTED:function(){return yP},IS_SCRIPT_TRANSFORM_SUPPORTED:function(){return AP},IS_SEI_SUPPORTED:function(){return RP},IS_SPC_SUPPORTED:function(){return _P},basis:function(){return OP},capabilityCheck:function(){return MP},checkSystemRequirementsInternal:function(){return tP},decodeSupportStatus:function(){return eP},encodeSupportStatus:function(){return ZO},getBrowserInfo:function(){return zO},getDisplayResolution:function(){return sP},isAddTransceiverSupported:function(){return vP},isBrowserSupported:function(){return KO},isGetReceiversSupported:function(){return fP},isGetSendersSupported:function(){return pP},isGetTransceiversSupported:function(){return mP},isGetUserMediaSupported:function(){return cP},isMediaDevicesSupported:function(){return YO},isMediaSessionSupported:function(){return DP},isMediaStreamTrackProcessorSupported:function(){return $O},isReplaceTrackSupported:function(){return EP},isRequestVideoFrameCallbackSupported:function(){return LP},isSIMDSupported:function(){return xP},isScreenCaptureApiAvailable:function(){return rP},isSelectedCandidatePair:function(){return aP},isSetParametersSupported:function(){return TP},isSmallStreamAPISupported:function(){return lP},isSmallStreamSupported:function(){return dP},isStopTransceiverSupported:function(){return gP},isTRTCSupported:function(){return nP},isUnifiedPlanDefault:function(){return hP},isUsedInHttpProtocol:function(){return QO},isWebAudioSupported:function(){return uP},isWebCodecSupported:function(){return wP},isWebCodecsSupported:function(){return qO},isWebRTCSupported:function(){return CP},isWebTransportSupported:function(){return NP}});var wx={};_R(wx,{AUDIO_LEVEL_SCALE:function(){return yO},AudioCodecPipelineType:function(){return IO},AudioDecoderDowngradeState:function(){return eO},AudioPlayerMode:function(){return vO},AudioType:function(){return aO},BASIC_TYPE:function(){return TO},BannedReason:function(){return _O},CONNECTION_CLOSED_REASON:function(){return jx},ClientEvent:function(){return Hx},CodecType:function(){return bO},ConnectionEvent:function(){return Bx},ConnectionState:function(){return Zx},DECODE_FAILED_ERROR_CODE:function(){return AO},FacingMode:function(){return pO},LeaveReason:function(){return gO},LocalTrackEvent:function(){return Wx},MULTI_VIDEO_DATA_TYPE:function(){return lO},MediaType:function(){return iO},MediaTypeLabel:function(){return oO},MonitorEventId:function(){return dO},MutedFlag:function(){return Yx},NetworkQualityValue:function(){return hO},PlayerState:function(){return Jx},ReceiveMode:function(){return fO},RemoteStreamType:function(){return uO},RemoteTrackEvent:function(){return qx},RoomEvent:function(){return zx},SceneNumber:function(){return Xx},StreamEvent:function(){return Gx},StreamType:function(){return cO},SubscribeMediaType:function(){return EO},TIMER_TYPE:function(){return CO},TRACK_ACTION:function(){return rO},TRACK_KIND:function(){return nO},TrackEvent:function(){return Kx},UserRole:function(){return $x},UserRoleNumber:function(){return Qx},VideoCodec:function(){return kO},VideoCodecPipelineType:function(){return SO},VideoContentHint:function(){return RO},VideoDecoderDowngradeState:function(){return tO},VideoPlayerMode:function(){return mO},VideoType:function(){return sO}});var Dx,Nx,xx,Ox,Px,Mx,Lx,Ux,Vx,Fx,Bx=((Fx=Bx||{}).TRACK_ADDED="track-added",Fx.TRACK_UPDATED="track-updated",Fx.TRACK_SUBSCRIBED="track-subscribed",Fx.STREAM_ADDED="stream-added",Fx.STREAM_REMOVED="stream-removed",Fx.STREAM_UPDATED="stream-updated",Fx.STREAM_PUBLISHED="stream-published",Fx.STREAM_SUBSCRIBED="stream-subscribed",Fx.STREAM_UNSUBSCRIBED="stream-unsubscribed",Fx.STATE_CHANGED="state-changed",Fx.ERROR="error",Fx.CONNECTION_STATE_CHANGED="connection-state-changed",Fx.FIREWALL_RESTRICTION="firewall-restriction",Fx.SEI_MESSAGE="sei-message",Fx.CLOSED="closed",Fx),jx=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}(jx||{}),Hx=((Vx=Hx||{}).STREAM_ADDED="stream-added",Vx.STREAM_REMOVED="stream-removed",Vx.STREAM_UPDATED="stream-updated",Vx.STREAM_SUBSCRIBED="stream-subscribed",Vx.CONNECTION_STATE_CHANGED="connection-state-changed",Vx.PEER_JOIN="peer-join",Vx.PEER_LEAVE="peer-leave",Vx.MUTE_AUDIO="mute-audio",Vx.MUTE_VIDEO="mute-video",Vx.UNMUTE_AUDIO="unmute-audio",Vx.UNMUTE_VIDEO="unmute-video",Vx.CLIENT_BANNED="client-banned",Vx.NETWORK_QUALITY="network-quality",Vx.AUDIO_VOLUME="audio-volume",Vx.SEI_MESSAGE="sei-message",Vx.ERROR="error",Vx),Gx=((Ux=Gx||{}).PLAYER_STATE_CHANGED="player-state-changed",Ux.SCREEN_SHARING_STOPPED="screen-sharing-stopped",Ux.CONNECTION_STATE_CHANGED="connection-state-changed",Ux.DEVICE_AUTO_RECOVERED="device-auto-recovered",Ux.ERROR="error",Ux),Wx=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}(Wx||{}),Jx=function(e){return e.PAUSED="PAUSED",e.PLAYING="PLAYING",e.STOPPED="STOPPED",e}(Jx||{}),zx=((Lx=zx||{}).PEER_JOIN="peer-join",Lx.PEER_LEAVE="peer-leave",Lx.SIGNAL_CONNECTION_STATE_CHANGED="signal-connection-state-changed",Lx.MEDIA_CONNECTION_STATE_CHANGED="media-connection-state-changed",Lx.BANNED="banned",Lx.NETWORK_QUALITY="network-quality",Lx.AUDIO_VOLUME="audio-volume",Lx.SEI_MESSAGE="sei-message",Lx.ERROR="error",Lx.REMOTE_PUBLISH_STATE_CHANGED="remote-publish-state-changed",Lx.REMOTE_PUBLISHED="remote-published",Lx.REMOTE_UNPUBLISHED="remote-unpublished",Lx.FIREWALL_RESTRICTION="firewall-restriction",Lx.HEARTBEAT_REPORT="heartbeat-report",Lx.CUSTOM_MESSAGE="custom-message",Lx.LAYER_DATA="layerData",Lx.FIRST_VIDEO_FRAME="first-video-frame",Lx.DUMP="dump",Lx),Kx=((Mx=Kx||{}).PLAYER_STATE_CHANGED="player-state-changed",Mx.MUTE="mute",Mx.UNMUTE="unmute",Mx.ERROR="error",Mx.INPUT_MEDIA_TRACK_CHANGED="input-media-track-changed",Mx.OUTPUT_MEDIA_TRACK_CHANGED="output-media-track-changed",Mx.FIRST_VIDEO_FRAME="first-video-frame",Mx),qx=function(e){return e.DECODE_FAILED="decode-failed",e.DECODE_DOWNGRADE_STATE_CHANGED="decode-downgrade-state-changed",e}(qx||{}),Yx=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}(Yx||{}),Xx=function(e){return e[e.RTC=1]="RTC",e[e.LIVE=2]="LIVE",e}(Xx||{}),Qx=function(e){return e[e.ANCHOR=20]="ANCHOR",e[e.AUDIENCE=21]="AUDIENCE",e}(Qx||{}),$x=function(e){return e.ANCHOR="anchor",e.AUDIENCE="audience",e}($x||{}),Zx=function(e){return e.CONNECTED="CONNECTED",e.DISCONNECTED="DISCONNECTED",e.CONNECTING="CONNECTING",e.RECONNECTED="RECONNECTED",e.RECONNECTING="RECONNECTING",e}(Zx||{}),eO=((Px=eO||{}).INITIALIZED="INITIALIZED",Px.STARTING="STARTING",Px.STARTED="STARTED",Px.FAILED="FAILED",Px),tO=function(e){return e.INITIALIZED="INITIALIZED",e.STARTING="STARTING",e.STARTED="STARTED",e.FAILED="FAILED",e}(tO||{}),nO=function(e){return e.AUDIO="audio",e.VIDEO="video",e.AUXILIARY="auxVideo",e}(nO||{}),rO=function(e){return e.ADD="add",e.REMOVE="remove",e}(rO||{}),iO=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}(iO||{}),oO={1:"audio",2:"auxVideo",4:"video"},aO=((Ox=aO||{})[Ox.opus=111]="opus",Ox),sO=function(e){return e[e.h264=100]="h264",e[e.vp8=101]="vp8",e}(sO||{}),cO=function(e){return e.Big="big",e.Small="small",e}(cO||{}),uO=function(e){return e.Main="main",e.Aux="auxiliary",e}(uO||{}),lO=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}(lO||{}),dO=((xx=dO||{})[xx.PUBLISH_VIDEO=32768]="PUBLISH_VIDEO",xx[xx.PUBLISH_AUDIO=32769]="PUBLISH_AUDIO",xx[xx.UNPUBLISH_VIDEO=32770]="UNPUBLISH_VIDEO",xx[xx.UNPUBLISH_AUDIO=32771]="UNPUBLISH_AUDIO",xx[xx.MUTE_AUDIO=32772]="MUTE_AUDIO",xx[xx.MUTE_VIDEO=32773]="MUTE_VIDEO",xx[xx.UNMUTE_AUDIO=32774]="UNMUTE_AUDIO",xx[xx.UNMUTE_VIDEO=32775]="UNMUTE_VIDEO",xx[xx.SUBSCRIBE_VIDEO=32776]="SUBSCRIBE_VIDEO",xx[xx.SUBSCRIBE_AUDIO=32777]="SUBSCRIBE_AUDIO",xx[xx.UNSUBSCRIBE_VIDEO=32778]="UNSUBSCRIBE_VIDEO",xx[xx.UNSUBSCRIBE_AUDIO=32779]="UNSUBSCRIBE_AUDIO",xx[xx.SWITCH_CAMERA=32780]="SWITCH_CAMERA",xx[xx.SWITCH_MICROPHONE=32781]="SWITCH_MICROPHONE",xx[xx.REPLACE_VIDEO=32782]="REPLACE_VIDEO",xx[xx.REPLACE_AUDIO=32783]="REPLACE_AUDIO",xx[xx.MUTE_REMOTE_VIDEO=32784]="MUTE_REMOTE_VIDEO",xx[xx.MUTE_REMOTE_AUDIO=32785]="MUTE_REMOTE_AUDIO",xx[xx.UNMUTE_REMOTE_VIDEO=32786]="UNMUTE_REMOTE_VIDEO",xx[xx.UNMUTE_REMOTE_AUDIO=32787]="UNMUTE_REMOTE_AUDIO",xx[xx.JOIN=32788]="JOIN",xx[xx.LEAVE=32789]="LEAVE",xx[xx.SIGNAL_DISCONNECTED=32790]="SIGNAL_DISCONNECTED",xx[xx.SIGNAL_CONNECTED=32791]="SIGNAL_CONNECTED",xx[xx.TRANSPORT_UPLINK_CONNECTED=32792]="TRANSPORT_UPLINK_CONNECTED",xx[xx.TRANSPORT_DOWNLINK_CONNECTED=32793]="TRANSPORT_DOWNLINK_CONNECTED",xx[xx.SIGNAl_RECONNECTING=32794]="SIGNAl_RECONNECTING",xx[xx.SIGNAL_RECONNECT_SUCCESS=32795]="SIGNAL_RECONNECT_SUCCESS",xx[xx.SIGNAL_RECONNECT_FAIL=32796]="SIGNAL_RECONNECT_FAIL",xx[xx.TRANSPORT_UPLINK_RECONNECTING=32797]="TRANSPORT_UPLINK_RECONNECTING",xx[xx.TRANSPORT_UPLINK_RECONNECT_SUCCESS=32798]="TRANSPORT_UPLINK_RECONNECT_SUCCESS",xx[xx.TRANSPORT_UPLINK_RECONNECT_FAIL=32799]="TRANSPORT_UPLINK_RECONNECT_FAIL",xx[xx.TRANSPORT_DOWNLINK_RECONNECTING=32800]="TRANSPORT_DOWNLINK_RECONNECTING",xx[xx.TRANSPORT_DOWNLINK_RECONNECT_SUCCESS=32801]="TRANSPORT_DOWNLINK_RECONNECT_SUCCESS",xx[xx.TRANSPORT_DOWNLINK_RECONNECT_FAIL=32802]="TRANSPORT_DOWNLINK_RECONNECT_FAIL",xx[xx.SUBSCRIBE_SMALL_VIDEO=32803]="SUBSCRIBE_SMALL_VIDEO",xx[xx.UNSUBSCRIBE_SMALL_VIDEO=32804]="UNSUBSCRIBE_SMALL_VIDEO",xx[xx.PUBLISH_AUX=32805]="PUBLISH_AUX",xx[xx.UNPUBLISH_AUX=32806]="UNPUBLISH_AUX",xx[xx.DEVICE_CAPTURE=2003]="DEVICE_CAPTURE",xx[xx.VIDEO_ENCODER=4004]="VIDEO_ENCODER",xx[xx.VIDEO_DECODER=4005]="VIDEO_DECODER",xx),hO=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}(hO||{}),fO=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}(fO||{}),pO=function(e){return e.user="user",e.environment="environment",e}(pO||{}),mO=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}(mO||{}),vO=function(e){return e[e.ELEMENT=0]="ELEMENT",e[e.CONTEXT=1]="CONTEXT",e}(vO||{}),_O=function(e){return e.BANNED="banned",e.KICK="kick",e.USER_TIME_OUT="user_time_out",e.ROOM_DISBAND="room_disband",e}(_O||{}),gO=((Nx=gO||{})[Nx.USER_EXIT_REASON_TC_USER_EXIT_NORMAL=0]="USER_EXIT_REASON_TC_USER_EXIT_NORMAL",Nx[Nx.USER_EXIT_REASON_TC_USER_EXIT_TIMEOUT=1]="USER_EXIT_REASON_TC_USER_EXIT_TIMEOUT",Nx[Nx.USER_EXIT_REASON_TC_USER_EXIT_KICKED=2]="USER_EXIT_REASON_TC_USER_EXIT_KICKED",Nx[Nx.USER_EXIT_REASON_TC_USER_EXIT_CHANGED=3]="USER_EXIT_REASON_TC_USER_EXIT_CHANGED",Nx[Nx.USER_KICK_OUT_CODE_BUSINESS_USER=4]="USER_KICK_OUT_CODE_BUSINESS_USER",Nx[Nx.USER_KICK_OUT_CODE_BUSINESS_ROOM=5]="USER_KICK_OUT_CODE_BUSINESS_ROOM",Nx[Nx.USER_KICK_OUT_CODE_SERVER_USER=6]="USER_KICK_OUT_CODE_SERVER_USER",Nx[Nx.USER_KICK_OUT_CODE_SERVER_ROOM=7]="USER_KICK_OUT_CODE_SERVER_ROOM",Nx[Nx.USER_KICK_SESS_EXSIT=8]="USER_KICK_SESS_EXSIT",Nx),yO=1e8,EO=function(){function e(){r(this,e),ER(this,"mediaType",0)}return a(e,[{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}}])}(),TO=function(e){return e.String="string",e.Number="number",e.Boolean="boolean",e.Array="array",e.Object="object",e}(TO||{}),kO=function(e){return e.H264="h264",e.H265="h265",e.VP8="vp8",e}(kO||{}),SO=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}(SO||{}),IO=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}(IO||{}),bO=function(e){return e.WebRTC="webrtc",e.WebCodecs="webcodecs",e.WebAssembly="webassembly",e}(bO||{}),AO=((Dx=AO||{})[Dx.SUCCESS=0]="SUCCESS",Dx[Dx.FAILED=1]="FAILED",Dx[Dx.WEBCODEC_INIT=2]="WEBCODEC_INIT",Dx[Dx.WEBCODEC_CONFIG_NOT_SUPPORT=3]="WEBCODEC_CONFIG_NOT_SUPPORT",Dx[Dx.WEBCODEC_DECODER_ERROR=4]="WEBCODEC_DECODER_ERROR",Dx[Dx.WEBCODEC_TRACK_MUTE=5]="WEBCODEC_TRACK_MUTE",Dx[Dx.WASM_INIT=6]="WASM_INIT",Dx[Dx.WASM_WEBGL_UNAVALIABLE=7]="WASM_WEBGL_UNAVALIABLE",Dx[Dx.WASM_DECODER_ERROR=8]="WASM_DECODER_ERROR",Dx[Dx.WASM_TRACK_MUTE=9]="WASM_TRACK_MUTE",Dx[Dx.TEST=10]="TEST",Dx),RO=function(e){return e.NONE="",e.DETAIL="detail",e.MOTION="motion",e.TEXT="text",e}(RO||{}),CO=function(e){return e.INTERVAL="interval",e.TIMEOUT="timeout",e.RAF="raf",e.RIC="ric",e.INTERVAL_IN_WORKER="intervalInWorker",e}(CO||{}),wO={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"},DO={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(Fw(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(Fw(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,"()")}},NO=function(e,t){return t?"".concat(rC,"/").concat(e,"/").concat(t):"".concat(rC,"/").concat(e,"/index.html")},xO=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(cC);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 OO(e){var t=e.key,n=e.data,r=e.link,i=e.addDocLink,o=void 0===i||i,a="",s="",c="";Bw(DO[t])?a=DO[t](n):Hw(DO[t])&&(a=DO[t]);var u=xO(),l=u.TRTC_ERROR_INFO,d=u.TRTC_ERROR_LINK;r?c="".concat(r.className,".html#").concat(r.fnName):d&&d[t]&&(Bw(d[t])?c=d[t](n):Hw(d[t])&&(c=d[t]));var h=a;return Mw()&&(l&&l[t]&&(Bw(l[t])?s=l[t](n):Hw(l[t])&&(s=l[t])),s&&(h=o?"".concat(s,"\n请查看文档: ").concat(NO("zh-cn",c),"\n\n"):"".concat(s,"\n\n"),h+=a)),o&&(h+=" \nRefer to: ".concat(NO("en",c),"\n")),h}var PO,MO=gR(RR(),1),LO=function(){function e(){var t=this;r(this,e);var n=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];ER(this,"countMap",new Map),ER(this,"distributionMap",new Map),ER(this,"version"),ER(this,"log",bx.createLogger({id:"kv"})),n&&(Tx.on("102",(function(e){var n=e.track,r=e.cost;t.addSuccessEvent({key:n.kind===yC.AUDIO?501700:511700,cost:r})})),Tx.on("103",(function(e){var n=e.track,r=e.error;t.addFailedEvent({key:n.kind===yC.AUDIO?501700:511700,error:r})})))}return a(e,[{key:"getReportData",value:function(){var e={msg_sdk_basic_info:{uint32_sdk_version:gD(this.version||WR),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,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(Gw(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=PR.UNKNOWN;n&&(Gw(n)?r=n:(!jw(n.extraCode)||!jw(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})}}}])}(),UO=((PO=UO||{})[PO.enterRoom=500700]="enterRoom",PO[PO.exitRoom=500701]="exitRoom",PO[PO.switchRole=500702]="switchRole",PO[PO.destroy=500703]="destroy",PO[PO.startLocalAudio=500704]="startLocalAudio",PO[PO.updateLocalAudio=500705]="updateLocalAudio",PO[PO.stopLocalAudio=500706]="stopLocalAudio",PO[PO.startLocalVideo=500707]="startLocalVideo",PO[PO.updateLocalVideo=500708]="updateLocalVideo",PO[PO.stopLocalVideo=500709]="stopLocalVideo",PO[PO.startScreenShare=500710]="startScreenShare",PO[PO.updateScreenShare=500711]="updateScreenShare",PO[PO.stopScreenShare=500712]="stopScreenShare",PO[PO.startRemoteVideo=500713]="startRemoteVideo",PO[PO.updateRemoteVideo=500714]="updateRemoteVideo",PO[PO.stopRemoteVideo=500715]="stopRemoteVideo",PO[PO.muteRemoteAudio=500716]="muteRemoteAudio",PO[PO.setRemoteAudioVolume=500717]="setRemoteAudioVolume",PO[PO.use=500718]="use",PO[PO.sendSEIMessage=5e5]="sendSEIMessage",PO[PO.sendCustomMessage=500001]="sendCustomMessage",PO),VO=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}(VO||{}),FO=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}(FO||{}),BO=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}(BO||{}),jO=new LO(!0),HO=new LO(!1),GO=jO,WO={result:!1,detail:{isBrowserSupported:!1,isWebRTCSupported:!1,isWebCodecsSupported:!1,isMediaDevicesSupported:!1,isScreenShareSupported:!1,isSmallStreamSupported:!1,isH264EncodeSupported:!1,isVp8EncodeSupported:!1,isH264DecodeSupported:!1,isVp8DecodeSupported:!1}},JO=new Map([[KD,["Firefox",qD]],[$D,["Edg",ZD]],[zN,["Chrome",YN]],[XN,["Safari",$N]],[oN,["TBS",aN]],[sN,["XWEB",cN]],[hN&&BD,["WeChat",fN]],[_N,["QQ(Win)",gN]],[mN,["QQ(Mobile)",vN]],[pN,["QQ(Mobile X5)",vN]],[yN,["QQ(Mac)",EN]],[TN,["QQ(iPad)",kN]],[DN,["MI",NN]],[xN,["HW",MN]],[LN,["Samsung",UN]],[VN,["OPPO",FN]],[BN,["VIVO",jN]],[XD,["EDGE",QD]],[tN,["SogouMobile",nN]],[rN,["Sogou",iN]]]);function zO(){var e=JO.get(!0);return{browserName:e?e[0]:"unknown",browserVersion:e?e[1]:"unknown"}}var KO=function(){return!(CN||XD||$D&&eN<80||KD&&YD<56)},qO=function(){return["VideoDecoder","VideoEncoder","AudioEncoder","AudioDecoder","MediaStreamTrackGenerator"].every((function(e){return e in window}))},YO=function(){if(!navigator.mediaDevices)return QO()||bx.error(DO.NOT_SUPPORTED_MEDIA),!1;var e=["getUserMedia","enumerateDevices"];return e.filter((function(e){return e in navigator.mediaDevices})).length===e.length},XO=!1;function QO(){return"http:"===location.protocol&&!ox&&(XO||bx.error(OO({key:wO.NOT_SUPPORTED_HTTP})),XO=!0,!0)}var $O=function(){return(null==window?void 0:window.OffscreenCanvas)&&(null==window?void 0:window.MediaStreamTrackProcessor)&&(null==window?void 0:window.MediaStreamTrackGenerator)},ZO=function(){return kR(this,null,f().mark((function e(){var t,n,r,i,o,a;return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!WO.detail.isH264EncodeSupported||!WO.detail.isVp8EncodeSupported){e.next=2;break}return e.abrupt("return",{isH264EncodeSupported:WO.detail.isH264EncodeSupported,isVp8EncodeSupported:WO.detail.isVp8EncodeSupported});case 2:return n=!1,r=!1,e.prev=3,i=new RTCPeerConnection,(o=document.createElement(yC.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(),WO.detail.isH264EncodeSupported=n,WO.detail.isVp8EncodeSupported=r,e.abrupt("return",{isH264EncodeSupported:WO.detail.isH264EncodeSupported,isVp8EncodeSupported:WO.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]])})))},eP=function(){return kR(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(!WO.detail.isH264DecodeSupported||!WO.detail.isVp8DecodeSupported){e.next=2;break}return e.abrupt("return",{isH264DecodeSupported:WO.detail.isH264DecodeSupported,isVp8DecodeSupported:WO.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]])})))},tP=TD((function(){return kR(void 0,null,f().mark((function e(){var t,n,r,i,o,a,s,c,u,l,d,h,p,m,_;return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(WO.result&&WO.detail.isH264EncodeSupported&&WO.detail.isVp8EncodeSupported&&WO.detail.isH264DecodeSupported&&WO.detail.isVp8DecodeSupported)){e.next=2;break}return e.abrupt("return",WO);case 2:return t=Date.now(),n=KO(),r=CP(),i=qO(),o=YO(),e.next=9,ZO();case 9:return a=e.sent,s=a.isH264EncodeSupported,c=a.isVp8EncodeSupported,e.next=14,eP();case 14:if(u=e.sent,l=u.isH264DecodeSupported,d=u.isVp8DecodeSupported,s&&c){e.next=22;break}return e.next=20,ZO();case 20:h=e.sent,bx.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&&GD&&JN)||sN||oN){e.next=29;break}return e.next=25,function(){return kR(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",iP||(iP=new Promise((function(e){return kR(t,null,f().mark((function t(){var n,r,i,o,a,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"),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 p=t.sent,m=MO.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=MO.default.write(m),t.next=26,d.setLocalDescription(p);case 26:return t.next=28,l.setRemoteDescription(p);case 28:s=setInterval((function(){return kR(g,null,f().mark((function t(){var i,o,a,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,o=v(i,2),a=o[0],s=o[1],n.encode||a.forEach((function(e){"outbound-rtp"===e.type&&e.mediaType===yC.VIDEO&&e.bytesSent>0&&(n.encode=!0)})),n.decode||s.forEach((function(e){"inbound-rtp"===e.type&&e.mediaType===yC.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(),bx.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)&&bx.warn("detectH264Supported encode: ".concat(e.encode," decode: ").concat(e.decode," ").concat(dx)),e})),iP));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",(WO.result=n&&r&&o&&(s||c)&&(l||d),WO.detail.isBrowserSupported=n,WO.detail.isWebRTCSupported=r,WO.detail.isWebCodecsSupported=i,WO.detail.isMediaDevicesSupported=o,WO.detail.isScreenShareSupported=rP(),WO.detail.isSmallStreamSupported=dP(),WO.detail.isH264EncodeSupported=s,WO.detail.isVp8EncodeSupported=c,WO.detail.isH264DecodeSupported=l,WO.detail.isVp8DecodeSupported=d,WO.result||bx.error("".concat(navigator.userAgent," ").concat(pD(WO.detail,!1))),Rx.setItem(PP,{ua:navigator.userAgent,checkResult:WO}),GO.addNumber({key:523800,value:Date.now()-t}),WO));case 30:case"end":return e.stop()}}),e)})))})),nP=function(){return WO.result},rP=function(){return!(!navigator.mediaDevices||!navigator.mediaDevices.getDisplayMedia)},iP=null,oP=function(e,t,n){"http:"===location.protocol&&!ox&&(e[t]=function(){throw new LR({code:PR.INVALID_OPERATION,message:DO.NOT_SUPPORTED_HTTP})})},aP=function(e){return!("candidate-pair"!==e.type||!e.nominated||"in-progress"!==e.state&&"succeeded"!==e.state||Ww(e.selected)&&!e.selected)};function sP(){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 cP(){return navigator.getUserMedia||navigator.mediaDevices&&navigator.mediaDevices.getUserMedia}function uP(){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 lP(){return"captureStream"in HTMLCanvasElement.prototype}function dP(){return!(hN||HD||qN&&qN<63||!KO()||!lP())}var hP=function(){if(jw(window.RTCRtpTransceiver)||!("currentDirection"in RTCRtpTransceiver.prototype))return!1;var e=null,t=!1;try{(e=new RTCPeerConnection({sdpSemantics:ZC})).addTransceiver(yC.AUDIO),t=!0}catch(zR){}return null==e||e.close(),t};function fP(){return"RTCPeerConnection"in window&&"getReceivers"in window.RTCPeerConnection.prototype}function pP(){return"RTCPeerConnection"in window&&"getSenders"in window.RTCPeerConnection.prototype}function mP(){return"RTCPeerConnection"in window&&"getTransceivers"in window.RTCPeerConnection.prototype}function vP(){return 11!==tx&&"RTCPeerConnection"in window&&"addTransceiver"in window.RTCPeerConnection.prototype}var _P=!(!vP()||JN&&qN<86);function gP(){return"RTCRtpTransceiver"in window&&"stop"in window.RTCRtpTransceiver.prototype}var yP="RTCRtpSender"in window;function EP(){return yP&&"replaceTrack"in window.RTCRtpSender.prototype}function TP(){return yP&&"setParameters"in window.RTCRtpSender.prototype&&pP()}var kP="RTCRtpReceiver"in window&&"getSynchronizationSources"in window.RTCRtpReceiver.prototype,SP=window.MediaStreamTrack&&"getSettings"in MediaStreamTrack.prototype,IP=window.MediaStreamTrack&&"getCapabilities"in MediaStreamTrack.prototype,bP=yP&&"createEncodedStreams"in window.RTCRtpSender.prototype&&WN()>=86,AP="RTCRtpScriptTransform"in window,RP=yP&&(bP||AP),CP=function(){return["RTCPeerConnection","webkitRTCPeerConnection","RTCIceGatherer"].filter((function(e){return e in window})).length>0};function wP(){var e={AudioDecoder:!1,AudioEncoder:!1,VideoDecoder:!1,VideoEncoder:!1,ImageDecoder:!1};return jw(window.AudioDecoder)||(e.AudioDecoder=!0),jw(window.AudioEncoder)||(e.AudioEncoder=!0),jw(window.VideoDecoder)||(e.VideoDecoder=!0),jw(window.VideoEncoder)||(e.VideoEncoder=!0),jw(window.ImageDecoder)||(e.ImageDecoder=!0),e}function DP(){return"mediaSession"in navigator&&!jw(navigator.mediaSession.setActionHandler)}function NP(){return!jw(window.WebTransport)}function xP(){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 OP(){var e={browser:"".concat(sx.name,"/").concat(sx.version),os:mx(),displayResolution:sP(),isScreenShareSupported:rP(),isWebRTCSupported:CP(),isGetUserMediaSupported:cP(),isWebAudioSupported:uP(),isWebSocketsSupported:"WebSocket"in window&&2===window.WebSocket.CLOSING,isWebCodecSupported:wP(),isMediaSessionSupported:DP(),isWebTransportSupported:NP()};return navigator.userAgent.includes("miniProgram")&&(e.browser="mini/".concat(e.browser)),e}var PP="checkResult";function MP(){QO();var e=Rx.getItem(PP);e&&e.ua===navigator.userAgent&&(WO=e.checkResult),tP()}function LP(){return"requestVideoFrameCallback"in HTMLVideoElement.prototype}var UP="RTCRtpReceiver"in window&&"jitterBufferTarget"in window.RTCRtpReceiver.prototype,VP=gR(SR(),1),FP=Symbol("instance"),BP=Symbol("cacheResult"),jP=function(){function e(t,n,i){r(this,e),this.oldState=t,this.newState=n,this.action=i,this.aborted=!1}return a(e,[{key:"abort",value:function(e){this.aborted=!0,zP.call(e,this.oldState,new Error("action '".concat(this.action,"' aborted")))}},{key:"toString",value:function(){return"".concat(this.action,"ing")}}])}(),HP=function(e){function t(e,i,o){var a;return r(this,t),(a=n(this,t,[i])).state=e,a.message=i,a.cause=o,a}return d(t,e),a(t)}(I(Error)),GP=new Map;function WP(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=GP.get(r)||[];GP.has(r)||GP.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=KP.get("function"==typeof n.context?(r=n.context).call.apply(r,[this].concat(u)):n.context)),o.state===t)return n.sync?o[BP]:Promise.resolve(o[BP]);o.state instanceof jP&&o.state.action==n.abortAction&&o.state.abort(o);var d=null;Array.isArray(e)?0==e.length?o.state instanceof jP&&o.state.abort(o):("string"!=typeof o.state||!e.includes(o.state))&&(d=new HP(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 HP(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 jP(f,t,a);zP.call(o,p);var m=function(e){var r;return o[BP]=e,p.aborted||(zP.call(o,t),null===(r=n.success)||void 0===r||r.call(i,o[BP])),e},v=function(e){return zP.call(o,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(Vx){return v(new HP(o._state,"".concat(o.name," ").concat(a," from ").concat(e," to ").concat(t," failed: ").concat(Vx),Vx instanceof Error?Vx:new Error(String(Vx))))}}}}var JP="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 zP(e,t){var n=this._state;this._state=e;var r=e.toString();e&&this.emit(r,n),this.emit(KP.STATECHANGED,e,n,t),this.updateDevTools({value:e,old:n,err:t instanceof Error?t.message:String(t)})}var KP=function(e){function i(e,o,a){var s;r(this,i),(s=n(this,i)).name=e,s.groupName=o,s._state=i.INIT,e||(e=Date.now().toString(36)),a?Object.setPrototypeOf(t(s),a):a=Object.getPrototypeOf(t(s)),o||(s.groupName=s.constructor.name);var c=a[FP];return c?s.name=c.name+"-"+c.count++:a[FP]={name:s.name,count:0},s.updateDevTools({diagram:s.stateDiagram}),s}return d(i,e),a(i,[{key:"stateDiagram",get:function(){var e=Object.getPrototypeOf(this),t=GP.get(e)||[],n=new Set,r=[],i=[],o=new Set,a=Object.getPrototypeOf(e);GP.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=E(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]:{};JP(i.UPDATEAFSM,Object.assign({name:this.name,group:this.groupName},e))}},{key:"state",get:function(){return this._state},set:function(e){zP.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}}])}(VP.default);KP.STATECHANGED="stateChanged",KP.UPDATEAFSM="updateAFSM",KP.INIT="[*]",KP.ON="on",KP.OFF="off",KP.instances=new Map,KP.instances2=new WeakMap;var qP="undefined"!=typeof window,YP=qP&&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=qP&&window.cancelIdleCallback||function(e){clearTimeout(e)},QP=qP&&(window.cancelAnimationFrame||window.mozCancelAnimationFrame),$P=function(){function e(){r(this,e)}return a(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=pR("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=mR(pR({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=eD(),i=function(){if((n=eD()-r)>=t.delay&&(r=eD()-Math.floor(n%t.delay),t.callback(),t.loopCount+=1),!e.isBreakLoop(t))return t.ricID=YP(i,{timeout:t.delay})};return t.ricID=YP(i,{timeout:t.delay})}},{key:"raf",value:function(t){var n,r=eD(),i=function(){return document.hidden&&t.backgroundTask?(n=eD()-r,r=eD(),t.callback(),t.loopCount+=1,e.isBreakLoop(t)?void 0:t.timeoutID=setTimeout(i,t.delay-Math.floor(n%t.delay))):((n=eD()-r)>=t.delay&&(r=eD()-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=eD()-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&&QP&&QP(i),o&&XP(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)}}])}();ER($P,"taskMap",new Map),ER($P,"currentTaskID",1),ER($P,"sharedWorker",null),ER($P,"workerTasks",new Map);var ZP=$P;yC.SEI_MESSAGE;var eM={LOADED_DATA:yC.LOADEDDATA,LOADED_META_DATA:yC.LOADEDMETADATA,MEDIA_TRACK_CHANGED:"media-track-changed",PLAYER_STATE_CHANGED:"player-state-changed",ERROR:"error"},tM={};_R(tM,{create:function(){return rM},remove:function(){return iM}});var nM=new WeakMap;function rM(e,t){nM.has(e)||nM.set(e,[]);var n=nM.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 iM(e){var t=nM.get(e);t&&(t.forEach((function(e){return e()})),nM.delete(e))}var oM=new(function(){function e(){r(this,e),ER(this,"_roomIdMap",new Map),ER(this,"_configs"),"undefined"==typeof registerProcessor&&(this._configs={sdkAppId:"",userId:"",version:WR,env:lC.QCLOUD,browserVersion:sx.name+sx.version,ua:navigator.userAgent})}return a(e,[{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){ox||!bx.isAbleToUpload||this._configs.env===lC.QCLOUD&&this.uploadEventToKibana(mR(pR({},e),{result:"success"}))}},{key:"logFailedEvent",value:function(e){if(!ox&&bx.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)||PR.UNKNOWN};this._configs.env===lC.QCLOUD&&this.uploadEventToKibana(mR(pR({},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:FR(),sdkAppId:this._configs.sdkAppId,userId:n||this._configs.userId,version:WR,log:t};r&&(i.errorInfo=r.message,r.stack&&(i.errorInfo+="\n".concat(r.stack))),this.sendRequest(Sw(this._configs.sdkAppId,uC.LOG),i)}},{key:"sendRequest",value:function(e,t){setTimeout((function(){return kD({url:e,body:JSON.stringify(t),priority:"low"}).catch((function(){}))}),2e3)}}])}()),aM=new WeakMap;function sM(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=wD({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=aM.get(e))&&n.has(t)?a():s(o)}),s,c):null!=(i=aM.get(e))&&i.has(t)?a():s(o)},onRetrying:function(n,r){var o;bD(i)&&i.call(this,n,r),null!=(o=aM.get(e))&&o.has(t)&&(aM.get(e).get(t).stopRetry=r)},onRetryFailed:o});return a.value=function(){for(var n=aM.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}):aM.set(e,new Map([[t,{args:i}]])),s.apply(this,i).finally((function(){var n;return null==(n=aM.get(e))?void 0:n.delete(t)}))},a}}function cM(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,c=arguments.length,u=new Array(c),l=0;l<c;l++)u[l]=arguments[l];if(null!=(r=aM.get(e))&&r.has(t)){var d=aM.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==(o=aM.get(e))||o.delete(t))}return a.apply(this,u)},o}}var uM=function(e){function i(e,o){var a;return r(this,i),(a=n(this,i,[e.id,"".concat(o,"-player")])).kind=o,ER(t(a),"id"),ER(t(a),"element",null),ER(t(a),"track"),ER(t(a),"url"),ER(t(a),"attr"),ER(t(a),"mode"),ER(t(a),"muted"),ER(t(a),"_log"),ER(t(a),"_pausedRetryCount"),ER(t(a),"_isElementPlayingFired",!1),ER(t(a),"_interval"),ER(t(a),"_delayDestroyTimeoutId",0),ER(t(a),"_playSuccessResolve"),ER(t(a),"_isReplayByRecreateMediaStreamCalled",!1),ER(t(a),"isInAutoPlayFailedState",!1),a.id=e.id,a._log=e.log,a.track=e.track,a.muted=e.muted,a._pausedRetryCount=dw,a._state="STOPPED",a.bindTrackEvents(),a._log.info("create ".concat(o,"-player ").concat(a.id)),a}return d(i,e),a(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 kR(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=OO({key:wO.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 LR({code:PR.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&&!QN?this._delayDestroyTimeoutId||(this._log.info("destroy element after 3 * ".concat(t)),this._delayDestroyTimeoutId=setTimeout((function(){return e.destroyElement()}),3*t)):this.destroyElement(),this.handleStopped(yC.ENDED),this._interval>0&&ZP.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():rx?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 rM(this.element,this.element).add(yC.PLAYING,e).add(yC.ENDED,e).add(yC.PAUSE,e).add(yC.ERROR,e).add(yC.LOADEDDATA,e).add(yC.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==tM||tM.create(e,e).add(yC.ENDED,t).add(yC.MUTE,t).add(yC.UNMUTE,t),e.readyState===yC.ENDED&&this.handleTrackEvent({type:yC.ENDED}),e.muted&&this.handleTrackEvent({type:yC.MUTE})}}},{key:"bindAutoPlayEvent",value:function(){Tx.on(Sx.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&&iM(e)}},{key:"unbindEvents",value:function(){this.element&&iM(this.element),this.unbindTrackEvents(),Tx.off(Sx.AUTOPLAY_DIALOG_CLICK_CONFIRM,this.resume,this)}},{key:"handleElementEvent",value:function(e){var t=this;switch(e.type){case yC.PLAYING:this.isInAutoPlayFailedState=!1,this._isElementPlayingFired=!0,this._log.info("".concat(this.kind," player is playing")),this.handlePlaying(yC.PLAYING),this._interval&&(ZP.clearTask(this._interval),this._interval=-1);break;case yC.ENDED:this._log.info("".concat(this.kind," player is ended")),this.handleStopped(yC.ENDED);break;case yC.PAUSE:this._log.info("".concat(this.kind," player is paused")),this.handlePaused(yC.PAUSE),HD&&(this._interval=ZP.run("timeout",(function(){t.element&&"PAUSED"===t._state&&t.resume()}),{delay:3e3}));break;case yC.ERROR:if(this.element&&this.element.error){this.handlePaused(yC.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)),oM.uploadEvent({log:"stat-".concat(this.kind,"-").concat(YC.PLAYER_ERROR,"-").concat(r,"-").concat(navigator.userAgent),error:this.element.error}),PN||ON?this.emit(eM.ERROR,this.element.error):this.replayByRecreateMediaStream(this.element.error)}break;case yC.LOADEDDATA:this.kind===yC.VIDEO&&this.emit(eM.LOADED_DATA);break;case yC.LOADEDMETADATA:this.kind===yC.VIDEO&&this.emit(eM.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"),oM.uploadEvent({log:"stat-replayByRecreateMediaStream-success"}),GO.addSuccessEvent({key:t.kind===yC.AUDIO?506700:516700})})).catch((function(){var n;t._log.error("replayByRecreateMediaStream failed"),oM.uploadEvent({log:"stat-replayByRecreateMediaStream-failed"}),GO.addFailedEvent({key:t.kind===yC.AUDIO?506700:516700,error:null==(n=t.element)?void 0:n.error}),t.emit(eM.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){ED(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)}),ED(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 yC.ENDED:this.handleStopped(yC.ENDED);break;case yC.MUTE:this.handlePaused(yC.MUTE);break;case yC.UNMUTE:this._isElementPlayingFired?this.handlePlaying(yC.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(eM.PLAYER_STATE_CHANGED,{type:this.kind,state:"PLAYING",reason:e})}},{key:"handlePaused",value:function(e){this.emit(eM.PLAYER_STATE_CHANGED,{type:this.kind,state:"PAUSED",reason:e})}},{key:"handleStopped",value:function(e){this.emit(eM.PLAYER_STATE_CHANGED,{type:this.kind,state:"STOPPED",reason:e})}},{key:"getElement",value:function(){return this.element}}])}(KP);yR([sM({settings:{retries:2,timeout:0},onError:function(e,t,n,r){r[0]=(r[0]||1e3)+1e3,t()}})],uM.prototype,"doReplayByRecreateMediaStream",1),yR([WP([],"PLAYING",{sync:!0})],uM.prototype,"handlePlaying",1),yR([WP("PLAYING","PAUSED",{ignoreError:!0,sync:!0})],uM.prototype,"handlePaused",1),yR([WP([],"STOPPED",{sync:!0})],uM.prototype,"handleStopped",1);var lM,dM="trtc_autoplay",hM="".concat(dM,"_mask"),fM="".concat(dM,"_wrapper"),pM="".concat(dM,"_header"),mM="".concat(dM,"_content"),vM="".concat(dM,"_action_wrapper"),_M="".concat(dM,"_question"),gM="".concat(dM,"_collapse"),yM="".concat(dM,"_action_confirm"),EM="".concat(dM,"_detail"),TM="#2473E8",kM="dialog",SM="".concat(kM,"-show"),IM="".concat(kM,"-1"),bM="".concat(kM,"-2"),AM=!1,RM=function(){return!!document.querySelector(".".concat(fM))},CM="".concat(rC,"/").concat(Mw()?"zh-cn":"en","/tutorial-21-advanced-auto-play-policy.html"),wM="<br><a href='".concat(CM,"' target='_blank'>").concat(Mw()?"其他方案?":"Any other solution?","</a>"),DM="".concat(Mw()?"浏览器自动播放策略:在用户与页面产生交互(点击、触摸)之前,浏览器禁止播放有声媒体。该弹窗用于帮助用户恢复音视频播放。".concat(wM):"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(wM)),NM=function(){function e(){if(r(this,e),ER(this,"content","音视频播放被浏览器拦截,请点击“恢复播放”。"),ER(this,"_dialogNode",null),ER(this,"_bodyPosition",""),ER(this,"_showDetail",!1),ER(this,"_isCollapseClicked",!1),ER(this,"_isQuestionClicked",!1),Mw()||(this.content='Media playback failed. Click the "Resume" to resume playback.'),!AM){var t=document.createElement("style");t.innerHTML=".".concat(hM,"{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(hM," div:not(.").concat(vM,"){display:block !important;}.").concat(fM,"{padding:14px;background:#fff;border-radius:3px;box-shadow:0px 3px 15px #434343;border:1px solid #d1cfcf;max-width:500px;}.").concat(fM," a{color:").concat(TM,";}.").concat(pM,"{overflow:hidden;text-overflow:ellipsis;font-size:16px;font-weight:600;}.").concat(mM,"{margin:8px 0;}.").concat(vM,"{width:100%;display:flex !important;align-items:center;justify-content:right;float:right;}.").concat(gM,"{margin-right:auto;cursor:pointer}.").concat(_M,"{height:100%;line-height:16px;cursor:pointer;}.").concat(yM,"{margin-left:8px;color:#fff;background:").concat(TM,";padding:4px 12px;outline:none;border:1px solid;border-radius:3px;font-weight:bold;}.").concat(yM,":hover{opacity:0.9;}.").concat(gM,",.").concat(yM,",.").concat(mM,",.").concat(_M,"{font-size:14px;}@media screen and (max-width:750px){.").concat(fM,"{width:80vw;}}"),document.head.appendChild(t),AM=!0}this.addDiaLog()}return a(e,[{key:"createDiaLog",value:function(){var e=document.createElement("template");e.innerHTML='<div class="'.concat(hM,"\"><div class='").concat(fM,"'><div class='").concat(pM,"'>").concat(location.host,"</div><div class='").concat(mM,"'>").concat(this.content,"</div><div class='").concat(EM,'\' style="visibility:hidden;width:100%;height:0;font-size:12px;color:gray;">').concat(DM,"</div><div class='").concat(vM,"'></div></div></div>").trim();var t=document.createElement("button");t.className=yM,t.innerText=Mw()?"恢复播放":"Resume",t.onclick=this.onConfirm.bind(this);var n=document.createElement("div");n.className=_M,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=gM,r.innerText="".concat(Mw()?"详情 >":"Detail >"),r.onclick=this.onCollapseClick.bind(this);var i=e.content.firstChild,o=i.querySelector(".".concat(vM));return o.appendChild(r),o.appendChild(n),o.appendChild(t),i}},{key:"addDiaLog",value:function(){RM()||(this._dialogNode=this.createDiaLog(),document.body.appendChild(this._dialogNode),this._dialogNode.onclick=this.onConfirm.bind(this),this._dialogNode.querySelector(".".concat(fM)).onclick=function(e){return e.stopPropagation()},this._bodyPosition=document.body.style.position,document.body.style.position="fixed",bx.info("show autoplay dialog"),oM.uploadEvent({log:SM}))}},{key:"deleteDiaLog",value:function(){this._dialogNode&&(document.body.removeChild(this._dialogNode),document.body.style.position=this._bodyPosition,this._dialogNode=null)}},{key:"onConfirm",value:function(){bx.warn("confirm clicked, try resume stream"),Tx.emit(Sx.AUTOPLAY_DIALOG_CLICK_CONFIRM),this.deleteDiaLog()}},{key:"onCollapseClick",value:function(){var e=this._dialogNode.querySelector(".".concat(EM));e.style.visibility="".concat(this._showDetail?"hidden":"visible"),e.style.height="".concat(this._showDetail?0:"fit-content"),this._showDetail=!this._showDetail,this._isCollapseClicked||oM.uploadEvent({log:IM}),this._isCollapseClicked=!0}},{key:"onQuestionClick",value:function(){window.open(CM,"_blank"),this._isQuestionClicked||oM.uploadEvent({log:bM}),this._isQuestionClicked=!0}}])}(),xM=function(e){function i(e){var o;return r(this,i),o=n(this,i,[e,yC.VIDEO]),ER(t(o),"stat",{}),ER(t(o),"_calculateTimeout",-1),ER(t(o),"viewMirror",!1),ER(t(o),"objectFit"),ER(t(o),"container"),ER(t(o),"canvas"),ER(t(o),"canvasTrack"),o.mode=e.canvas?1:0,o.container=e.container,o.canvas=e.canvas,jw(e.viewMirror)||(o.viewMirror=e.viewMirror),jw(e.objectFit)||(o.objectFit=e.objectFit),o.initializeElement(),o}return d(i,e),a(i,[{key:"initializeElement",value:function(){var e,t=document.createElement(yC.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(yC.ENTER_PICTURE_IN_PICTURE,this.handleElementEvent).add(yC.LEAVE_PICTURE_IN_PICTURE,this.handleElementEvent)}},{key:"handleTrackEvent",value:function(e){var t;g(i,"handleTrackEvent",this,3)([e]),e.type===yC.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===yC.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&&!RM()&&(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===yC.ENTER_PICTURE_IN_PICTURE?this.element.style.transform=r.replace("scaleX(-1)",""):n===yC.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,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 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(eM.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(LP()&&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(zR){this._log.warn("init stat failed",zR)}}}])}(uM);function OM(e,t){return kR(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:bx.info("worklet addModule success"),n.next=11;break;case 8:throw n.prev=8,n.t0=n.catch(2),bx.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?lM=AudioContext:"undefined"!=typeof webkitAudioContext?lM=webkitAudioContext:"undefined"!=typeof mozAudioContext&&(lM=mozAudioContext);var PM,MM=-1;!function e(){try{if(PM)return;(PM=new lM({sampleRate:48e3})).onstatechange=function(){bx.info("context state: ".concat(PM.state).concat("running"!==PM.state?" visibilityState: ".concat(document.visibilityState):"")),LM()},clearTimeout(MM)}catch(DG){bx.error("initAudioContext failed: ".concat(DG," typeof AudioContextClass: ").concat(k(lM))),MM=setTimeout(e,1e3)}}();var LM=function(){"suspended"===PM.state?(FM(),document.addEventListener("click",LM)):"interrupted"===PM.state?FM():(document.removeEventListener("visibilitychange",LM),document.removeEventListener("click",LM))},UM=0,VM=-1;function FM(){return new Promise((function(e,t){if("running"===PM.state)return e();Date.now()-UM<1e3?(clearTimeout(VM),VM=setTimeout((function(){UM=Date.now(),PM.resume().then(e,t)}),1e3)):(clearTimeout(VM),UM=Date.now(),PM.resume().then(e,t))})).catch((function(e){bx.warn("context resume failed: ".concat(e)),document.addEventListener("visibilitychange",LM)}))}document.addEventListener("click",LM);var BM=function(e){return PM},jM=function(){function e(){r(this,e),ER(this,"node"),ER(this,"node2"),ER(this,"pre",new Set),ER(this,"next",new Set),ER(this,"context"),ER(this,"connectedNodes",new Set)}return a(e,[{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(KC){bx.error(KC)}}},{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(),GO.addSuccessEvent({key:502701})}catch(Px){bx.error(Px),GO.addFailedEvent({key:502701,error:Px})}}},{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(),GO.addSuccessEvent({key:502702})}catch(zR){bx.error(zR),GO.addFailedEvent({key:502702,error:zR})}}},{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}}])}(),HM=function(e){function i(){var e;r(this,i);var o=arguments.length>0&&void 0!==arguments[0]?arguments[0]:256;return(e=n(this,i)).fftSize=o,ER(t(e),"dataArray",new Uint8Array(0)),e}return d(i,e),a(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}}])}(jM),GM=function(){function e(){r(this,e),ER(this,"source",new jM),ER(this,"gain",new jM),ER(this,"destination",new jM)}return a(e,[{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(BM().createGain()),this.gain.node.gain.value=e):this.gain.node&&this.gain.deleteNode()}},{key:"replaceSource",value:function(e){this.source.replaceNode(KM(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}}])}(),WM=function(e){function i(e){var o;return r(this,i),(o=n(this,i)).context=e,ER(t(o),"denoiser",new jM),ER(t(o),"voiceChanger",new jM),o.source.pipeTo(o.denoiser.pipeTo(o.voiceChanger.pipeTo(o.gain.pipeTo(o.destination)))),o}return d(i,e),a(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()}}])}(GM),JM=function(){function e(){r(this,e),ER(this,"audioContext",BM()),ER(this,"destination",this.audioContext.createMediaStreamDestination()),ER(this,"inputs",new Set),ER(this,"mixWeight",0),this.destination.channelCount=1}return a(e,[{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]}}])}(),zM=new WeakMap;function KM(e){var t=zM.get(e);if(t)return t;var n=BM();if(e instanceof HTMLAudioElement)t=n.createMediaElementSource(e);else{if(!(e instanceof MediaStreamTrack))return e;t=n.createMediaStreamSource(new MediaStream([e]))}return zM.set(e,t),t}var qM=function(){function e(t){r(this,e),ER(this,"_volume",0),ER(this,"_volumeDb",0),ER(this,"_log"),ER(this,"_scriptProcessorNode",null),ER(this,"_audioWorkletNode",null),ER(this,"_interval",200),ER(this,"ready",this.preload());var n=t.log;this._log=n,Tx.on(Sx.AUDIO_LEVEL_INTERVAL,this.handleAudioLevelInterval,this)}return a(e,[{key:"node",get:function(){return this._audioWorkletNode||this._scriptProcessorNode}},{key:"preload",value:function(){var t=this;if(!e.workletReady){var n='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);';e.workletReady=OM(e.audioContext,URL.createObjectURL(new Blob([n],{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(Ox){this._log.error("volumeMeter init audio worklet error: ".concat(Ox)),oM.logFailedEvent({userId:this._log.userId,eventType:YC.LOAD_WORKLET,error:Ox}),this.initScriptProcessor()}}},{key:"initScriptProcessor",value:function(){var t=this;if(!this._scriptProcessorNode)try{this._scriptProcessorNode=BM().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(Ox){this._log.error("volumeMeter init script processor error: ".concat(Ox))}}},{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,Tx.off(Sx.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}}])}();ER(qM,"lastMessageTime",0),ER(qM,"audioContext",BM()),ER(qM,"workletReady");var YM=qM,XM=function(e){function i(e){var o;return r(this,i),o=n(this,i),ER(t(o),"_volumeMeter"),o._volumeMeter=new YM(e),o}return d(i,e),a(i,[{key:"deleteNode",value:function(){g(i,"deleteNode",this,3)([]),this._volumeMeter.destroy()}},{key:"init",value:function(){return kR(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()}}}])}(jM),QM=YM,$M=gR(SR(),1),ZM=function(e){return function(t){return t.deviceId===e}},eL=function(){function e(t){r(this,e);var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"Input";ER(this,"kind"),ER(this,"type"),ER(this,"devices",[]),this.kind=t,this.type=n}return a(e,[{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&&rL(this.devices[0])||t&&(r.forEach((function(e){if(e.deviceId&&!n.devices.find(ZM(e.deviceId))){var r="".concat(n.kind).concat(n.type,"Added");bx.warn("".concat(r,": ").concat(JSON.stringify(e))),t.emit(r,e)}})),this.devices.forEach((function(e){if(e.deviceId&&!r.find(ZM(e.deviceId))){var i="".concat(n.kind).concat(n.type,"Removed");bx.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}))}}])}(),tL=function(e){function i(){var e;return r(this,i),e=n(this,i),ER(t(e),"audioInputs",new eL(yC.AUDIO)),ER(t(e),"videoInputs",new eL(yC.VIDEO)),ER(t(e),"audioOutputs",new eL(yC.AUDIO,"Output")),e.init(),navigator.mediaDevices&&(navigator.mediaDevices.addEventListener&&navigator.mediaDevices.addEventListener("devicechange",(function(){return e.update()})),"ondevicechange"in navigator.mediaDevices||ZP.run("interval",(function(){e.update()}),{delay:1e4})),e}return d(i,e),a(i,[{key:"init",value:function(){var e=this;iL().then((function(t){e.audioInputs.update(t),e.videoInputs.update(t),e.audioOutputs.update(t)}))}},{key:"update",value:function(){return kR(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,iL(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)}))()}))}}])}($M.EventEmitter),nL=YR||qR?null:new tL;function rL(e){return e.deviceId===e.groupId&&""===e.groupId}function iL(){return kR(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(!QO()&&YO()){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){rL(e)&&(e.kind===yC.AUDIO_INPUT?r.audio=!0:e.kind===yC.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&&FM(),t.next=18;break;case 15:t.prev=15,t.t0=t.catch(8),bx.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&&uL.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 oL(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return nL.update(e?1:0).then((function(e){return e.audioInputs.devices}))}function aL(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return nL.update(e?2:0).then((function(e){return e.videoInputs.devices}))}var sL=!1;function cL(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return kR(this,null,f().mark((function t(){return f().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",((HD||XN)&&(e=!1),nL.update(e?1:0).then((function(e){return e.audioOutputs.devices}))));case 1:case"end":return t.stop()}}),t)})))}var uL=new Set;function lL(e,t){return kR(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,oL();case 2:return r=n.sent.find((function(e){return e.deviceId===hw})),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 dL,hL=function(e){function i(e){var o;return r(this,i),(o=n(this,i)).log=e,ER(t(o),"volumeMeter"),ER(t(o),"volumeDestination"),ER(t(o),"analyser",new HM),o.volumeMeter=new XM({log:o.log}),o.volumeDestination=new jM,o.volumeMeter.pipeTo(o.volumeDestination),o}return d(i,e),a(i,[{key:"destroy",value:function(){this.gain.deleteNode(),this.volumeMeter.deleteNode(),this.analyser.deleteNode(),this.source.deleteNode(),this.destination.deleteNode(),this.volumeDestination.deleteNode()}}])}(GM),fL=function(e){function i(e){var o;return r(this,i),o=n(this,i,[e,yC.AUDIO]),ER(t(o),"_outputDeviceId"),ER(t(o),"_volume",1),ER(t(o),"_destination",BM().createMediaStreamDestination()),ER(t(o),"pipeline"),ER(t(o),"volumeMeterMode","worklet"),o.mode=0,o.pipeline=new hL(o._log),o}return d(i,e),a(i,[{key:"getMediaStream",value:function(){return this.pipeline.stream||(this.track?new MediaStream([this.track]):null)}},{key:"initializeElement",value:function(e){if("15.2"!==ex&&"15.3"!==ex&&"15.4"!==ex||!this.muted){var t=dL||new Audio;t.setAttribute("autoplay","autoplay"),t.srcObject=this.getMediaStream(),t.muted=this.muted,this.element=t,Gw(e)&&(this.element.volume=Math.min(Math.max(e,0),1)),t===dL&&(dL=void 0),this.bindElementEvents()}else this._log.info("audioElement is muted.")}},{key:"play",value:function(e){return kR(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(BM().createAnalyser()),function(){kR(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=sL,e.t0){e.next=11;break}return sL=!0,e.t1=bx,e.t2="speakers:",e.next=8,cL();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",TR(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 kR(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()}}])}(uM),pL=function(e){function t(){return r(this,t),n(this,t,arguments)}return d(t,e),a(t,[{key:"setTrack",value:function(e){this.track!==e&&(this.unbindTrackEvents(),this.track=e,this.emit(eM.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)}}])}(fL),mL=function(e){function i(e){var o;return r(this,i),o=n(this,i,[e]),ER(t(o),"_sourceElement"),ER(t(o),"_output",new jM),o.pipeline.source.pipeTo(o.pipeline.gain.pipeTo(o.pipeline.volumeMeter.pipeTo(o._output),o.pipeline.destination)),o}return d(i,e),a(i,[{key:"setOutput",value:function(){this.mode=1,this._output.setNode(BM().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(eM.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"):HD||(this._log.info("start set pipeline volume: ".concat(e)),this.pipeline.setVolume(e),this.element&&!this._sourceElement&&(this.pipeline.destination.setNode(this._destination),iM(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&&QN&&(dL=t),this._sourceElement&&(this._sourceElement.srcObject=null,delete this._sourceElement),g(i,"stop",this,3)([e])}}])}(fL),vL=function(e){function i(e){var o;r(this,i);var a,s=e.userId,c=e.sdkAppId,u=e.mediaType,l=e.room,d=e.PlayerClass,h=void 0===d?1===u?mL:xM:d;return o=n(this,i),ER(t(o),"id",Ax()),ER(t(o),"userId",""),ER(t(o),"isRemote"),ER(t(o),"mediaType"),ER(t(o),"room"),ER(t(o),"user"),ER(t(o),"_log"),ER(t(o),"_inputTrack"),ER(t(o),"_outputTrack"),ER(t(o),"isPlayCalled"),ER(t(o),"container",null),ER(t(o),"player"),ER(t(o),"subVideoPlayerMap"),ER(t(o),"muted",!1),ER(t(o),"abortCtrl"),ER(t(o),"objectFit","cover"),ER(t(o),"mirror"),ER(t(o),"isScreen",!1),ER(t(o),"manager"),ER(t(o),"trackSettings"),ER(t(o),"isFirstVideoFrameEmitted",!1),o.userId=s||"",o.mediaType=u,o._log=bx.createLogger({id:"".concat(o.kind[0],"t"),userId:null==(a=l||o.room)?void 0:a.userId,remoteUserId:t(o)instanceof VL?void 0:o.userId,sdkAppId:c,type:2===o.mediaType?"auxiliary":"main",isLocal:t(o)instanceof VL}),o.player=new h({id:o.userId||o.id,track:null,muted:!1,container:null,log:o._log}),o.player.on(eM.PLAYER_STATE_CHANGED,(function(e){Tx.emit(Sx.PLAYER_STATE_CHANGED,pR({track:t(o)},e)),o.emit("player-state-changed",e)})),o.kind===yC.VIDEO&&(o.player.on(eM.LOADED_DATA,(function(){o.emitFirstVideoFrameEvent(eM.LOADED_DATA),Tx.emit(Sx.VIDEO_LOADED_DATA,{track:t(o)})})),o.player.on(eM.LOADED_META_DATA,(function(){o.emitFirstVideoFrameEvent(eM.LOADED_META_DATA)})),o.player.on(eM.MEDIA_TRACK_CHANGED,(function(e){var t;null==(t=o.subVideoPlayerMap)||t.forEach((function(t){return t.setTrack(e)}))}))),o.onTrackMuted=o.onTrackMuted.bind(t(o)),o.onTrackUnmuted=o.onTrackUnmuted.bind(t(o)),o.onTrackEnded=o.onTrackEnded.bind(t(o)),o.onPlayerError&&o.player.on(eM.ERROR,o.onPlayerError.bind(t(o))),o}return d(i,e),a(i,[{key:"log",get:function(){return this._log||bx}},{key:"kind",get:function(){return 1===this.mediaType?yC.AUDIO:yC.VIDEO}},{key:"strMediaType",get:function(){return 4===this.mediaType?yC.VIDEO:2===this.mediaType?yC.SCREEN:yC.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 kR(this,null,f().mark((function n(){var r;return f().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(r=zw(e)?e[0]:e,!this.isPlayCalled){n.next=16;break}if(this.log.info("play update options: ".concat(JSON.stringify(t))),t&&!jw(t.muted)&&this.setPlayerMute(t.muted),t&&!jw(t.objectFit)&&(this.objectFit=t.objectFit),n.t0=this.player instanceof xM,!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=zw(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&&!jw(t.muted)?this.setPlayerMute(t.muted):(!this.isRemote||this.kind===yC.VIDEO)&&this.setPlayerMute(!0),t&&!jw(t.objectFit)&&(this.objectFit=t.objectFit),this.player instanceof xM&&(this.player.setObjectFit(this.objectFit),t&&!jw(t.poster)&&this.player.setPoster(t.poster)),this.isPlayCalled=!0,r&&(this.container=r,this.player instanceof xM&&this.player.setContainer(r)),Tx.emit(Sx.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=zw(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===yC.VIDEO&&!jw(e)&&e!==this.mirror){this.mirror=e;var n=this.player;t&&(n=t);var r=this.manager;if(Ww(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 kR(this,null,f().mark((function n(){var r,i,o,a,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!==yC.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;)o=v(i.value,2),a=o[0],c=o[1],(u=this.subVideoPlayerMap.get(c))?t&&(jw(t.objectFit)||u.setObjectFit(t.objectFit)):this.subVideoPlayerMap.set(c,new xM({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(a+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(RD(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 kR(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),Tx.emit(e?Sx.TRACK_MUTED:Sx.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){rM(e,e).add(yC.MUTE,this.onTrackMuted).add(yC.UNMUTE,this.onTrackUnmuted).add(yC.ENDED,this.onTrackEnded),e.muted&&this.onTrackMuted(),e.readyState===yC.ENDED&&this.onTrackEnded()}},{key:"uninstallTrackEvent",value:function(e){iM(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(RD(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 NM;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 xM?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===eM.LOADED_META_DATA&&!o&&!a||(e===eM.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"))}}])}(KP);yR([WP([],KP.INIT,{sync:!0})],vL.prototype,"close",1);var _L=Object.prototype.hasOwnProperty,gL=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(Lw(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(_L.call(e,t))return!1;return!0}return!1},yL=wD({retryFunction:function(e){return kR(this,null,f().mark((function t(){var n,r,i,o,a,s;return f().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=function(e){return{audio:TL(e),video:kL(e)}}(e),bx.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,oL();case 7:r=t.sent,bx.info("microphones: ".concat(fD(r.map((function(e){return mR(pR({},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,aL();case 13:i=t.sent,bx.info("cameras: ".concat(fD(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",(IP&&a.getTracks().forEach((function(e){bx.info("".concat(e.kind," capabilities: ").concat(fD(e.getCapabilities(),{keysToInclude:yw})))})),n.audio&&FM(),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=OO({key:wO.CAMERA_NOT_FOUND})),e.audio&&r&&0===r.length&&(s=OO({key:wO.MICROPHONE_NOT_FOUND}))),new LR({code:PR.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,(!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===o?i[0].useDeviceIdOnly=!0:3===o&&!i[0].useExactDeviceId&&(i[0].useTrueAsConstraint=!0),n()):r(t),i[0].microphoneId&&EL(i[0].microphoneId,!1),i[0].cameraId&&EL(i[0].cameraId,!0)},onRetrying:function(e){bx.warn("getUserMedia NotReadableError observed, retrying [".concat(e,"/3]"))},onRetryFailed:function(e){oM.logFailedEvent({eventType:YC.GET_USER_MEDIA_RETRY,error:e})},onRetrySuccess:function(e){oM.logSuccessEvent({eventType:YC.GET_USER_MEDIA_RETRY}),oM.uploadEvent({log:"stat-".concat(YC.GET_USER_MEDIA_RETRY,"-success-").concat(e)})}});function EL(e,t){return kR(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,aL();case 3:n.t0=n.sent,n.next=9;break;case 6:return n.next=8,oL();case 8:n.t0=n.sent;case 9:r=n.t0.find((function(t){return t.deviceId===e})),r&&Bw(r.getCapabilities)&&bx.warn(fD(r.getCapabilities(),{keysToInclude:yw}));case 11:case"end":return n.stop()}}),n)})))}function TL(e){if(!e.audio)return!1;if(e.useTrueAsConstraint)return!0;var t={echoCancellation:!0,noiseSuppression:!0,autoGainControl:!0,sampleRate:e.sampleRate};return!gL(e.microphoneId)&&(t.deviceId=e.useExactDeviceId?{exact:e.microphoneId}:e.microphoneId,e.useDeviceIdOnly)?t:(Gw(e.channelCount)&&(t.channelCount=e.channelCount),Ww(e.echoCancellation)&&!e.echoCancellation&&(t.echoCancellation=!1),Ww(e.noiseSuppression)&&!e.noiseSuppression&&(t.noiseSuppression=!1),Ww(e.autoGainControl)&&!e.autoGainControl&&(t.autoGainControl=!1),!!gL(t)||t)}function kL(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&&!gL(r)?r:(e.width&&(r.width={ideal:e.width},n&&!KD&&(r.width.max=e.width)),e.height&&(r.height={ideal:e.height},n&&!KD&&(r.height.max=e.height)),KD&&IN&&e.width&&e.height&&e.width*e.height<101376&&(r.width=e.width,r.height=e.height),e.frameRate&&(r.frameRate=e.frameRate),!!gL(r)||r)}var SL=yL;function IL(e){return RL((function(t,n){return function(){for(var n=arguments.length,r=new Array(n),i=0;i<n;i++)r[i]=arguments[i];return kR(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 bL(e){return RL((function(t,n){return function(){for(var n=arguments.length,r=new Array(n),i=0;i<n;i++)r[i]=arguments[i];return kR(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 AL(e){return RL((function(t,n){return function(){for(var n=arguments.length,r=new Array(n),i=0;i<n;i++)r[i]=arguments[i];return kR(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 RL(e){return function(t,n,r){return r.value=e(r.value,n),r}}var CL=function(){var e=!1,t=document.visibilityState;return function(){document.visibilityState!==t&&bx.info("visibility change: ".concat(document.visibilityState)),!e&&(document.addEventListener("visibilitychange",(function(){bx.info("visibility change: ".concat(document.visibilityState)),t=document.visibilityState})),e=!0)}}(),wL=0,DL=function(){function e(){r(this,e),ER(this,"log",bx.createLogger({id:"fq".concat(++wL)})),ER(this,"isRunning",!1),ER(this,"queue",[])}return a(e,[{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=pR({},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()}))}}}])}(),NL=new WeakMap,xL=new WeakMap;function OL(){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=NL.get(this)||new DL,n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return NL.set(this,t),t.push({fn:i,args:r,context:this},e)},r}}function PL(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=NL.get(this))?void 0:t.queue)||n.forEach((function(e){return o.push(e)})),null==(r=xL.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 LR({code:PR.API_CALL_ABORTED,message:e}))})),NL.delete(this),xL.delete(this),i.apply(this,s)},r}}function ML(e){return function(t,n,r){var i=r.value,o=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=xL.get(this)||new Map,a=r.get(o(t))||new DL;return r.set(o(t),a),xL.set(this,r),a.push({fn:i,args:t,context:this})},r}}function LL(e,t){return RL((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=eD();return Yw(s)?s.then((function(e){return t?GO.addSuccessEvent({key:r,cost:eD()-c}):GO.addSuccessEvent({key:r}),e})).catch((function(e){throw GO.addFailedEvent({key:r,error:e}),e})):(GO.addSuccessEvent({key:r}),s)}catch(KR){throw GO.addFailedEvent({key:r,error:KR}),KR}}}))}var UL=function(e){function i(e,o){var a;return r(this,i),a=n(this,i,[{mediaType:e,PlayerClass:o}]),ER(t(a),"isRemote",!1),ER(t(a),"deviceId"),ER(t(a),"groupId",""),ER(t(a),"label",""),ER(t(a),"_isRecapturing",!1),ER(t(a),"_lastRecaptureTime",0),ER(t(a),"_onMuteTimeoutId",-1),ER(t(a),"_encodeCheckTimeoutId",-1),ER(t(a),"profile"),a}return d(i,e),a(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){rM(e,e).add(yC.MUTE,this.onTrackMuted).add(yC.UNMUTE,this.onTrackUnmuted).add(yC.ENDED,this.onTrackEnded),e.muted&&this.onTrackMuted(),e.readyState===yC.ENDED&&this.onTrackEnded()}},{key:"uninstallTrackEvent",value:function(e){iM(e)}},{key:"setStateToCapture",value:function(){}},{key:"capture",value:function(e){return kR(this,null,f().mark((function t(){var n,r,i,o;return f().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(t.prev=0,i=eD(),Tx.emit(Sx.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,SL(e);case 10:r=t.sent;case 11:return o=r.getTracks()[0],t.next=14,this.setInputMediaStreamTrack(o);case 14:return e.customSource||(this.updateDeviceIdInUse(),this.listenDeviceChange()),Tx.emit(Sx.LOCAL_TRACK_CAPTURE_SUCCESS,{track:this,cost:eD()-i}),t.abrupt("return",r);case 19:throw t.prev=19,t.t0=t.catch(0),Tx.emit(Sx.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===KP.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),Tx.emit(Sx.LOCAL_TRACK_UNPUBLISHED,{track:this})}},{key:"updateDeviceIdInUse",value:function(){return kR(this,null,f().mark((function e(){var t,n,r,i,o=this;return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.mediaTrack||!SP){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 kR(this,arguments,(function(e){var t=e.newDeviceId,n=e.oldDeviceId,r=e.oldGroupId,i=e.oldLabel,o=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=o!==yC.AUDIO||t!==hw,e.t1){e.next=7;break}return e.next=6,lL(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),iL().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===yC.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(yC.AUDIO_INPUT);return!!uL.has(n)}(this.mediaTrack)||this.kind===yC.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(yC.VIDEO_INPUT);return!!uL.has(n)}(this.mediaTrack)||this._isRecapturing||e&&IN&&XN)}},{key:"onTrackMuted",value:function(){var e=this;if(g(i,"onTrackMuted",this,3)([]),CL(),this.isNeedToRecapture(!0)){if(Date.now()-this._lastRecaptureTime<gw)return void setTimeout((function(){return e.onTrackMuted()}),gw);this._onMuteTimeoutId=setTimeout((function(){return kR(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(!HD&&!GD||"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 kR(this,null,f().mark((function e(){var t=this;return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(TR(i.prototype,this,"onTrackEnded").call(this),!this.isNeedToRecapture()){e.next=8;break}if(!(Date.now()-this._lastRecaptureTime<gw)){e.next=3;break}return e.abrupt("return",void setTimeout((function(){return t.onTrackEnded()}),gw));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 kR(this,null,f().mark((function t(){var n,r,i,o=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,oL();case 11:t.t0=t.sent,t.next=17;break;case 14:return t.next=16,aL();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}),Tx.emit(Sx.LOCAL_TRACK_RECAPTURE,{track:o})})).catch((function(e){o._isRecapturing=!1,o.log.warn("recapture failed ".concat(e.message)),o.emit("5",e),Tx.emit(Sx.LOCAL_TRACK_RECAPTURE,{track:o,error:e})})));case 22:case"end":return t.stop()}}),t,this)})))}},{key:"getRecoverCaptureDeviceId",value:function(){return kR(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 WL)||!this.facingMode){e.next=3;break}return e.abrupt("return",this.facingMode);case 3:if(!(n=this.deviceId)){e.next=18;break}if(r=(FL.get(n)||0)+1,FL.set(n,r),!(r>=3)){e.next=18;break}if(!t){e.next=13;break}return e.next=10,aL();case 10:e.t0=e.sent.find((function(e){return!FL.has(e.deviceId)})),e.next=16;break;case 13:return e.next=15,oL();case 15:e.t0=e.sent.find((function(e){return!FL.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)}}])}(vL);yR([WP(KP.INIT,"capture",{ignoreError:!0,sync:!0})],UL.prototype,"setStateToCapture",1),yR([OL()],UL.prototype,"capture",1),yR([WP("capture","publish",{ignoreError:!0,success:function(){var e,t,n=this;this.room.localTracks.add(this),Tx.emit(Sx.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===yC.AUDIO,i=n.stat.bytesSent>0;GO[i?"addSuccessEvent":"addFailedEvent"]({key:r?503700:513702}),i||(GO.addEnum({key:r?503701:513703,value:vx()}),oM.uploadEvent({log:"stat-encode-failed-".concat(n.kind,"-").concat(fx()||_x()),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===PR.API_CALL_ABORTED&&(t="api-call")}this.emit("4",{mediaType:this.strMediaType,state:"stopped",prevState:"starting",reason:t,error:e.cause||e})}}),LL(521714,!1)],UL.prototype,"publish",1),yR([RL((function(e){return function(){return kR(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)})))}})),WP([],"capture",{sync:!0})],UL.prototype,"unpublish",1);var VL=UL,FL=new Map;Tx.on(Sx.SWITCH_DEVICE_SUCCESS,(function(e){e.track.deviceId&&FL.delete(e.track.deviceId)}));var BL=function(e){function i(e){var o;return r(this,i),o=n(this,i,[1,pL]),ER(t(o),"mediaType",1),ER(t(o),"volume",0),ER(t(o),"profile",{echoCancellation:!0,autoGainControl:!0,noiseSuppression:!0,sampleRate:48e3,channelCount:1,bitrate:40}),ER(t(o),"playerMuted",!0),ER(t(o),"pipeline"),ER(t(o),"earMonitorGainNode",new jM),ER(t(o),"_output",new jM),ER(t(o),"stat",{bytesSent:0,packetsSent:0,audioLevel:0,totalAudioEnergy:0}),o.manager=e,o.pipeline=new WM(e),o.pipeline.gain.pipeTo(o.earMonitorGainNode.pipeTo(o._output),o.player.pipeline.volumeMeter),o.handleMicrophoneAdded=o.handleMicrophoneAdded.bind(t(o)),o.handleMicrophoneRemoved=o.handleMicrophoneRemoved.bind(t(o)),o}return d(i,e),a(i,[{key:"dbVolume",get:function(){return QM.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 kR(this,null,f().mark((function t(){var n,r,o;return f().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=this.trackSettings||{},GO.addEnum({key:501701,value:n.channelCount||0,useUV:!1}),GO.addEnum({key:501702,value:n.sampleRate||0,useUV:!1}),GO.addEnum({key:502700,value:0}),r=n.sampleRate,o=n.channelCount,this._log.info("local audio track input ".concat(JSON.stringify({sampleRate:r,channelCount:o}))),this.pipeline.replaceSource(e),t.next=7,TR(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,o=void 0===r||r,a=e.retryWhenExactFailed,s=void 0===a||a;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:o,retryWhenExactFailed:s,customSource:n}])}},{key:"switchDevice",value:function(e){return kR(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===hw){t.next=4;break}return t.abrupt("return");case 4:return t.next=6,lL(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:Tx.emit(Sx.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(){nL&&!nL.listeners("audioInputRemoved").includes(this.handleMicrophoneRemoved)&&nL.on("audioInputRemoved",this.handleMicrophoneRemoved,this)}},{key:"handleMicrophoneRemoved",value:function(e){return kR(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))),MF(this.userId,{eventId:2003,param1:6,streamType:1}),t.next=4,oL();case 4:(n=t.sent)[0]?this.recapture(n[0].deviceId):nL.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 kR(this,arguments,(function(e){var t=this,n=e.echoCancellation,r=e.noiseSuppression,i=e.autoGainControl;return f().mark((function e(){var o;return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(o=!1,!jw(n)&&n!==t.profile.echoCancellation&&(t.profile.echoCancellation=n,o=!0),!jw(r)&&r!==t.profile.noiseSuppression&&(t.profile.noiseSuppression=r,o=!0),!jw(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&&GO.addEnum({key:502700,value:2})}},{key:"setAudioVolume",value:function(e){g(i,"setAudioVolume",this,3)([0]),HD&&this.player.setMuted(!0),this.earMonitorGainNode.node||(this.earMonitorGainNode.setNode(BM().createGain()),this._output.setNode(BM().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;qN<=92&&48e3!==(null==(t=this.trackSettings)?void 0:t.sampleRate)?this._log.warn("denoiser only support sampleRate 48000 before chrome 93"):(GO.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(),nL.off("audioInputAdded",this.handleMicrophoneAdded,this),nL.off("audioInputRemoved",this.handleMicrophoneRemoved,this),g(i,"close",this,3)([])}},{key:"recapture",value:function(e){return kR(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,TR(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,oL();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,TR(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}))}}])}(VL),jL=function(){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())}return a(e,[{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(E(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(E(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}}])}(),HL=function(){function e(){r(this,e),ER(this,"_seiMessageList",[]),ER(this,"_smallSeiMessageList",[]),ER(this,"_seiPayloadType",243)}return a(e,[{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,E(new Uint8Array(a.buffer))),i.push(128),new jL(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}}])}(),GL=function(e){function i(e){var o;r(this,i),o=n(this,i,[arguments.length>1&&void 0!==arguments[1]?arguments[1]:4,xM]),ER(t(o),"profile",{width:640,height:480,frameRate:15,bitrate:500}),ER(t(o),"avoidCropping",!1),ER(t(o),"_scaleResolutionDownBy"),ER(t(o),"stat",{bytesSent:0,packetsSent:0,framesEncoded:0,framesSent:0,frameWidth:0,frameHeight:0,fpsCapture:0}),ER(t(o),"small"),ER(t(o),"isNeedToSetBandwidth"),ER(t(o),"muteImage"),ER(t(o),"manager"),ER(t(o),"_seiCodec",new HL),o.manager=e;var a=function(){o.isAllowed2k4k(o.profile)?o.room&&o.settings.height>=1440&&"publish"===o.state&&o.room.sendAbilityStatus({"2k4k":1}):(o.log.warn("Resolution is reset to 1080p, need to upgrade ability here https://cloud.tencent.com/document/product/647/85386"),o.setProfile(mR(pR({},o.profile),{width:1920,height:1080})),o.applyProfile())};return o.on("input-media-track-changed",a),o.on("publish",a),o.handleCameraAdded=o.handleCameraAdded.bind(o),o.handleCameraRemoved=o.handleCameraRemoved.bind(o),o}return d(i,e),a(i,[{key:"facingMode",get:function(){if(SP&&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 kR(this,null,f().mark((function t(){var n,r,o;return f().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!Hw(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,TR(i.prototype,this,"setMute").call(this,!1),t.next=15;break;case 11:return t.next=13,null==(o=this.manager)?void 0:o.deleteWatermark("mute");case 13:this.muteImage=void 0,TR(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,o=void 0===r||r,a=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:o,retryWhenExactFailed:c,customSource:a}])}},{key:"setProfile",value:function(e){var t=pR({},e),n=t.width>t.height;t.width*t.height<=19200&&GD&&JN&&(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&&ix&&(t.width=n?1280:720,t.height=n?720:1280,this.log.warn("reset to 1280 * 720 on iOS 13~14")),this.avoidCropping&&(JN||KD)&&!lx()&&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)([mR(pR({},this.profile),{width:1920,height:1080})]))}},{key:"applyProfile",value:function(){return kR(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!==tx){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:yC.VIDEO,videoType:yC.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 SP&&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:vD()&&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 kR(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:Tx.emit(Sx.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(){nL&&!nL.listeners("videoInputRemoved").includes(this.handleCameraRemoved)&&nL.on("videoInputRemoved",this.handleCameraRemoved,this)}},{key:"handleCameraRemoved",value:function(e){return kR(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))),MF(this.userId,{eventId:2003,param1:7,streamType:2}),t.next=4,aL();case 4:(n=t.sent)[0]?this.recapture(n[0].deviceId):nL.on("videoInputAdded",this.handleCameraAdded,this);case 6:case"end":return t.stop()}}),t,this)})))}},{key:"handleCameraAdded",value:function(e){return kR(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 jw(this.mirror)&&!this.isScreen&&this.setMirror("view"),g(i,"play",this,3)([e,t])}},{key:"close",value:function(){nL.off("videoInputAdded",this.handleCameraAdded,this),nL.off("videoInputRemoved",this.handleCameraRemoved,this),g(i,"close",this,3)([])}},{key:"recapture",value:function(e){return kR(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,TR(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,aL();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,TR(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))}}])}(VL);yR([bL((function(e){this.setContentHint(e.contentHint||"motion")}))],GL.prototype,"capture",1);var WL=GL,JL=Ax();if("undefined"!=typeof navigator&&navigator.mediaDevices&&"setCaptureHandleConfig"in navigator.mediaDevices)try{navigator.mediaDevices.setCaptureHandleConfig({handle:JL,exposeOrigin:!0,permittedOrigins:["*"]})}catch(DG){}var zL=function(e){return kR(this,null,f().mark((function t(){var n,r,i,o;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,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}(e),bx.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&&(zN&&qN<74||XN||KD)&&bx.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),bx.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 kR(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&&Bw(e.cropTo))){n.next=14;break}if(n.prev=1,(null==(r=e.getCaptureHandle())?void 0:r.handle)===JL){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),bx.warn("cropTo target failed ".concat(n.t0));case 14:case"end":return n.stop()}}),n,null,[[1,11]])})))}(o,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 jw(e.microphoneId)||(t.deviceId=e.microphoneId),{audio:t,video:!1}}(e),bx.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]])})))},KL=function(e){function i(e){var o;return r(this,i),o=n(this,i,[e,2]),ER(t(o),"profile",{width:1920,height:1080,frameRate:5,bitrate:1600}),ER(t(o),"objectFit","contain"),ER(t(o),"isScreen",!0),o._log.id="s-".concat(o._log.id),o}return d(i,e),a(i,[{key:"capture",value:function(e){return kR(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 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,zL({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 LR?e.t0:new LR({code:PR.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 kR(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)})))}}])}(WL);yR([bL((function(e){this.setContentHint(e.contentHint||"detail")}))],KL.prototype,"capture",1);var qL,YL=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),a(t)}(BL);function XL(e){return kR(this,null,f().mark((function t(){var n,r;return f().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=BM(),qL||(qL=OM(n,URL.createObjectURL(new Blob(["registerProcessor('dumper', class extends AudioWorkletProcessor {process(inputs) {this.port.postMessage(inputs);return true;}});"],{type:"application/javascript"})))),t.next=4,qL;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 QL=function(e){function i(e){var o;return r(this,i),(o=n(this,i)).room=e,ER(t(o),"_localAudioTrack"),ER(t(o),"_localScreenAudioTrack"),ER(t(o),"log",bx.createLogger({id:"am"})),ER(t(o),"denoiser"),ER(t(o),"voiceChanger"),ER(t(o),"mixChangedDebounce"),ER(t(o),"encodePipeline",[]),ER(t(o),"decodePipeline",[]),e&&(o.log.setUserId(e.userId),o.log.setSdkAppId(e.sdkAppId)),o}return d(i,e),a(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=[],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=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]]}))}}),a).catch((function(e){return u}))}));return{then:l.then.bind(l),download:u}}}},{key:"getPCM",value:function(e){var t,n=this;if(jw(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 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)))}}),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!jw(this._localAudioTrack)}},{key:"changeInput",value:function(e){return e instanceof YL?(this._localScreenAudioTrack=e,e.pipeline.connect(),this.mixOnChange()):e instanceof BL?(this._localAudioTrack=e,this.denoiser&&e.addDenoiser(this.denoiser),e.pipeline.connect(),this.mixOnChange()):e instanceof pF?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 YL?delete this._localScreenAudioTrack:e instanceof BL&&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}}])}(JM);function $L(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:30,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:2;return RL((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 LR({code:PR.API_CALL_TIMEOUT,message:"checkPendingPromise ".concat(r,"() timeout ").concat(e,"s")});bx.warn(n),2===t?s(n):1===t&&o()}),1e3*e);n.apply(i,a).then(o,s).finally((function(){clearTimeout(c)}))}))}}))}var ZL={};function eU(){}_R(ZL,{Events:function(){return mU},Inspect:function(){return aU},LastSink:function(){return sU},Sink:function(){return cU},Subscribe:function(){return uU},TimeoutError:function(){return vU},audit:function(){return EV},bindCallback:function(){return YU},bindNodeCallback:function(){return XU},buffer:function(){return wU},bufferCount:function(){return CU},bufferTime:function(){return rF},call:function(){return tU},catchError:function(){return oF},combineLatest:function(){return IU},concat:function(){return TU},concatMap:function(){return JV},concatMapTo:function(){return zV},count:function(){return nV},create:function(){return dU},debounce:function(){return SV},debounceTime:function(){return IV},defer:function(){return xU},delay:function(){return iF},deliver:function(){return hU},dispose:function(){return rU},elementAt:function(){return bV},empty:function(){return ZU},every:function(){return DV},exhaustMap:function(){return ZV},exhaustMapTo:function(){return eF},filter:function(){return aV},find:function(){return AV},findIndex:function(){return RV},first:function(){return CV},fromAnimationFrame:function(){return KU},fromArray:function(){return LU},fromEvent:function(){return jU},fromEventPattern:function(){return BU},fromFetch:function(){return GU},fromIterable:function(){return WU},fromPromise:function(){return HU},fromReadableStream:function(){return zU},fromReader:function(){return JU},groupBy:function(){return tF},identity:function(){return nU},ignoreElements:function(){return sV},iif:function(){return SU},inspect:function(){return iU},interval:function(){return UU},last:function(){return wV},map:function(){return PV},mapTo:function(){return MV},max:function(){return rV},merge:function(){return yU},mergeMap:function(){return YV},mergeMapTo:function(){return XV},min:function(){return iV},never:function(){return QU},nothing:function(){return eU},of:function(){return MU},pairwise:function(){return xV},pipe:function(){return lU},race:function(){return EU},range:function(){return qU},reduce:function(){return tV},retry:function(){return dF},scan:function(){return NV},share:function(){return gU},shareReplay:function(){return kU},skip:function(){return hV},skipUntil:function(){return fV},skipWhile:function(){return pV},startWith:function(){return AU},subject:function(){return NU},subscribe:function(){return cF},sum:function(){return oV},switchMap:function(){return BV},switchMapTo:function(){return HV},take:function(){return cV},takeLast:function(){return dV},takeUntil:function(){return uV},takeWhile:function(){return lV},tap:function(){return uF},throttle:function(){return gV},throwError:function(){return $U},timeInterval:function(){return nF},timeout:function(){return lF},timer:function(){return VU},toPromise:function(){return aF},toReadableStream:function(){return sF},withLatestFrom:function(){return RU},zip:function(){return bU}});var tU=function(e){return e()},nU=function(e){return e};function rU(){this.dispose()}var iU=function(){return"undefined"!=typeof __FASTRX_DEVTOOLS__},oU=1,aU=function(e){function t(){return r(this,t),n(this,t,arguments)}return d(t,e),a(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 pU(e,this,this.streamId++);return mU.subscribe({id:this.id,end:!1},{nodeId:t.sourceId,streamId:t.id}),this(t),t}}])}(I(Function)),sU=function(){function e(){r(this,e),this.defers=new Set,this.disposed=!1}return a(e,[{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=eU,this.error=eU,this.next=eU,this.dispose=eU,this.subscribe=eU,this.doDefer()}},{key:"subscribe",value:function(e){return e instanceof aU?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(tU),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}}])}(),cU=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),a(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)}}])}(sU),uU=function(e){function t(e){var i;r(this,t);var o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:eU,a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:eU,s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:eU;if((i=n(this,t))._next=o,i._error=a,i._complete=s,i.then=eU,e instanceof aU){var c={toString:function(){return"subscribe"},id:0,source:e};i.defer((function(){mU.defer(c,0)})),mU.create(c),mU.pipe(c),i.sourceId=c.id,i.subscribe(e),mU.subscribe({id:c.id,end:!0}),o==eU?i._next=function(e){return mU.next(c,0,e)}:i.next=function(e){mU.next(c,0,e),o(e)},s==eU?i._complete=function(){return mU.complete(c,0)}:i.complete=function(){i.dispose(),mU.complete(c,0),s()},a==eU?i._error=function(e){return mU.complete(c,0,e)}:i.error=function(e){i.dispose(),mU.complete(c,0,e),a()}}else i.subscribe(e);return i}return d(t,e),a(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)}}])}(sU);function lU(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 dU(e,t,n){if(iU()){var r=Object.defineProperties(Object.setPrototypeOf(e,aU.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}});mU.create(r);for(var i=0;i<n.length;i++){var o=n[i];"function"==typeof o&&o instanceof aU&&mU.addSource(r,o)}return r}return e}function hU(e,t){return function(){for(var n=arguments,r=arguments.length,o=new Array(r),a=0;a<r;a++)o[a]=arguments[a];return function(r){if(r instanceof aU){var a=dU((function(t){var n=i(e,[t].concat(o));n.sourceId=a.id,n.subscribe(r)}),t,n);return a.source=r,mU.pipe(a),a}return function(t){return r(i(e,[t].concat(o)))}}}}function fU(e,t){window.postMessage({source:"fastrx-devtools-backend",payload:{event:e,payload:t}})}var pU=function(e){function t(e,i,o){var a;return r(this,t),(a=n(this,t,[e])).source=i,a.id=o,a.sourceId=e.sourceId,a.defer((function(){mU.defer(a.source,a.id)})),a}return d(t,e),a(t,[{key:"next",value:function(e){mU.next(this.source,this.id,e),this.sink.next(e)}},{key:"complete",value:function(){mU.complete(this.source,this.id),this.sink.complete()}},{key:"error",value:function(e){mU.complete(this.source,this.id,e),this.sink.error(e)}}])}(cU),mU={addSource:function(e,t){fU("addSource",{id:e.id,name:e.toString(),source:{id:t.id,name:t.toString()}})},next:function(e,t,n){fU("next",{id:e.id,streamId:t,data:n&&n.toString()})},subscribe:function(e,t){fU("subscribe",{id:e.id,end:e.end,sink:{nodeId:t&&t.nodeId,streamId:t&&t.streamId}})},complete:function(e,t,n){fU("complete",{id:e.id,streamId:t,err:n?n.toString():null})},defer:function(e,t){fU("defer",{id:e.id,streamId:t})},pipe:function(e){fU("pipe",{name:e.toString(),id:e.id,source:{id:e.source.id,name:e.source.toString()}})},update:function(e){fU("update",{id:e.id,name:e.toString()})},create:function(e){e.id||(e.id=oU++),fU("create",{name:e.toString(),id:e.id})}},vU=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),a(t)}(I(Error)),_U=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),a(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()}}])}(sU);function gU(){var e=arguments;return function(t){var n=new _U(t);if(t instanceof aU){var r=dU((function(e){n.add(e)}),"share",e);return n.sourceId=r.id,r.source=t,mU.pipe(r),r}return dU(n.add.bind(n),"share",e)}}function yU(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return dU((function(e){var n=new cU(e),r=t.length;n.complete=function(){0==--r&&e.complete()},t.forEach(n.bindSubscribe)}),"merge",arguments)}function EU(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return dU((function(e){var n=new Map;t.forEach((function(t){var r=new cU(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 TU(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return dU((function(e){var n=0,r=t.length,i=new cU(e);i.complete=function(){n<r&&!i.disposed?(i.doDefer(),i.subscribe(t[n++])):e.complete()},i.complete()}),"concat",arguments)}function kU(e){var t=arguments;return function(n){var r=new _U(n),i=[];return r.next=function(t){i.push(t),i.length>e&&i.shift(),this.sinks.forEach((function(e){return e.next(t)}))},dU((function(e){e.defer((function(){return r.remove(e)})),i.forEach((function(t){return e.next(t)})),r.add(e)}),"shareReplay",t)}}function SU(e,t,n){return dU((function(r){return e()?t(r):n(r)}),"iif",arguments)}function IU(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return dU((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 cU(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 bU(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return dU((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 cU(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 AU(){for(var e=arguments,t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return function(t){return dU((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 RU=hU(function(e){function t(e){var i;r(this,t),i=n(this,t,[e]);for(var o=new cU(i.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 i.buffer=e},o.complete=eU,o.subscribe(IU.apply(void 0,s)),i}return d(t,e),a(t,[{key:"next",value:function(e){this.buffer&&this.sink.next([e].concat(E(this.buffer)))}}])}(cU),"withLatestFrom"),CU=hU(function(e){function t(e,i,o){var a;return r(this,t),(a=n(this,t,[e])).bufferSize=i,a.startBufferEvery=o,a.buffer=[],a.count=0,a.startBufferEvery&&(a.buffers=[[]]),a}return d(t,e),a(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)([])}}])}(cU),"bufferCount"),wU=hU(function(e){function t(e,i){var o;r(this,t),(o=n(this,t,[e])).buffer=[];var a=new cU(e);return a.next=function(t){e.next(o.buffer),o.buffer=[]},a.complete=eU,a.subscribe(i),o}return d(t,e),a(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)([])}}])}(cU),"buffer"),DU=function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function a(e){try{c(r.next(e))}catch(Dx){o(Dx)}}function s(e){try{c(r.throw(e))}catch(Dx){o(Dx)}}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 NU(e){var t=arguments,n=gU()(dU((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=eU,n.complete=eU,n.error=eU,n}function xU(e){return dU((function(t){return t.subscribe(e())}),"defer",arguments)}var OU=function(e){return function(t){setTimeout((function(){return e(t)}))}},PU=function(e){return OU((function(t){for(var n=0;!t.disposed&&n<e.length;n++)t.next(e[n]);t.complete()}))};function MU(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return dU(PU(t),"of",arguments)}function LU(e){return dU(PU(e),"fromArray",arguments)}function UU(e){return dU((function(t){var n=0,r=setInterval((function(){return t.next(n++)}),e);return t.defer((function(){clearInterval(r)})),"interval"}),"interval",arguments)}function VU(e,t){return dU((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 FU(e,t){return function(n){var r=function(e){return n.next(e)};n.defer((function(){return t(r)})),e(r)}}function BU(e,t){return dU(FU(e,t),"fromEventPattern",arguments)}function jU(e,t){if("on"in e&&"off"in e)return dU(FU((function(n){return e.on(t,n)}),(function(n){return e.off(t,n)})),"fromEvent",arguments);if("addListener"in e&&"removeListener"in e)return dU(FU((function(n){return e.addListener(t,n)}),(function(n){return e.removeListener(t,n)})),"fromEvent",arguments);if("addEventListener"in e)return dU(FU((function(n){return e.addEventListener(t,n)}),(function(n){return e.removeEventListener(t,n)})),"fromEvent",arguments);throw"target is not a EventDispachter"}function HU(e){return dU((function(t){e.then(t.next.bind(t),t.error.bind(t))}),"fromPromise",arguments)}function GU(e,t){return dU(xU((function(){return HU(fetch(e,t))})),"fromFetch",arguments)}function WU(e){return dU(OU((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(o){r.e(o)}finally{r.f()}t.complete()}catch(zR){t.error(zR)}})),"fromIterable",arguments)}function JU(e){var t=this,n=function(r){return DU(t,void 0,void 0,f().mark((function t(){var i,o,a;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,o=i.done,a=i.value,o?r.complete():(r.next(a),n(r));case 8:case"end":return t.stop()}}),t)})))};return dU((function(e){n(e)}),"fromReader",arguments)}function zU(e){return dU((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 KU(){return dU((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 qU(e,t){return dU((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 YU(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 dU((function(n){var i=r.concat((function(e){return n.next(e),n.complete()}));e.apply(t,i)}),"bindCallback",arguments)}function XU(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 dU((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 QU(){return dU((function(){}),"never",arguments)}function $U(e){return dU((function(t){return t.error(e)}),"throwError",arguments)}function ZU(){return dU((function(e){return e.complete()}),"empty",arguments)}var eV=function(e){function t(e,i,o){var a;r(this,t),(a=n(this,t,[e])).f=i;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),a(t,[{key:"next",value:function(e){this.acc=this.f(this.acc,e)}}])}(cU),tV=hU(eV,"reduce"),nV=function(e){return hU(eV,"count")((function(t,n){return e(n)?t+1:t}),0)},rV=function(){return hU(eV,"max")(Math.max)},iV=function(){return hU(eV,"min")(Math.min)},oV=function(){return hU(eV,"sum")((function(e,t){return e+t}),0)},aV=hU(function(e){function t(e,i,o){var a;return r(this,t),(a=n(this,t,[e])).filter=i,a.thisArg=o,a}return d(t,e),a(t,[{key:"next",value:function(e){this.filter.call(this.thisArg,e)&&this.sink.next(e)}}])}(cU),"filter"),sV=hU(function(e){function t(){return r(this,t),n(this,t,arguments)}return d(t,e),a(t,[{key:"next",value:function(e){}}])}(cU),"ignoreElements"),cV=hU(function(e){function t(e,i){var o;return r(this,t),(o=n(this,t,[e])).count=i,o}return d(t,e),a(t,[{key:"next",value:function(e){this.sink.next(e),0==--this.count&&this.complete()}}])}(cU),"take"),uV=hU(function(e){function t(e,i){var o;r(this,t),o=n(this,t,[e]);var a=new cU(e);return a.next=function(){return e.complete()},a.complete=rU,a.subscribe(i),o}return d(t,e),a(t)}(cU),"takeUntil"),lV=hU(function(e){function t(e,i){var o;return r(this,t),(o=n(this,t,[e])).f=i,o}return d(t,e),a(t,[{key:"next",value:function(e){this.f(e)?this.sink.next(e):this.complete()}}])}(cU),"takeWhile"),dV=function(e){return tV((function(t,n){return t.push(n),t.length>e&&t.shift(),t}),[])},hV=hU(function(e){function t(e,i){var o;return r(this,t),(o=n(this,t,[e])).count=i,o}return d(t,e),a(t,[{key:"next",value:function(e){0==--this.count&&(this.next=g(t,"next",this,1))}}])}(cU),"skip"),fV=hU(function(e){function t(e,i){var o;r(this,t),o=n(this,t,[e]),e.next=eU;var a=new cU(e);return a.next=function(){a.dispose(),e.resetNext()},a.complete=rU,a.subscribe(i),o}return d(t,e),a(t)}(cU),"skipUntil"),pV=hU(function(e){function t(e,i){var o;return r(this,t),(o=n(this,t,[e])).f=i,o}return d(t,e),a(t,[{key:"next",value:function(e){this.f(e)||(this.next=g(t,"next",this,1),this.next(e))}}])}(cU),"skipWhile"),mV={leading:!0,trailing:!1},vV=function(e){function t(e,i,o){var a;return r(this,t),(a=n(this,t,[e])).durationSelector=i,a.trailing=o,a}return d(t,e),a(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)}}])}(cU),_V=function(e){function t(e,i){var o;r(this,t);var a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:mV;return(o=n(this,t,[e])).durationSelector=i,o.config=a,o._throttle=new vV(o.sink,o.durationSelector,o.config.trailing),o._throttle.dispose(),o}return d(t,e),a(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=eU,this._throttle.complete(),g(t,"complete",this,3)([])}}])}(cU),gV=hU(_V,"throttle"),yV={leading:!1,trailing:!0},EV=function(e){return hU(_V,"audit")(e,yV)},TV=function(e){function t(){return r(this,t),n(this,t,arguments)}return d(t,e),a(t,[{key:"next",value:function(){this.complete()}},{key:"complete",value:function(){this.dispose(),this.sink.next(this.last)}}])}(cU),kV=function(e){function t(e,i){var o;return r(this,t),(o=n(this,t,[e])).durationSelector=i,o._debounce=new TV(o.sink),o._debounce.dispose(),o}return d(t,e),a(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)([])}}])}(cU),SV=hU(kV,"debounce"),IV=function(e){return hU(kV,"debounceTime")((function(t){return VU(e)}))},bV=hU(function(e){function t(e,i,o){var a;return r(this,t),(a=n(this,t,[e])).count=i,a.defaultValue=o,a}return d(t,e),a(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"))}}])}(cU),"elementAt"),AV=function(e){return function(t){return cV(1)(pV((function(t){return!e(t)}))(t))}},RV=hU(function(e){function t(e,i){var o;return r(this,t),(o=n(this,t,[e])).f=i,o.i=0,o}return d(t,e),a(t,[{key:"next",value:function(e){this.f(e)?(this.sink.next(this.i++),this.complete()):++this.i}}])}(cU),"findIndex"),CV=hU(function(e){function t(e,i,o){var a;return r(this,t),(a=n(this,t,[e])).f=i,a.defaultValue=o,a.index=0,a}return d(t,e),a(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"))}}])}(cU),"first"),wV=hU(function(e){function t(e,i,o){var a;return r(this,t),(a=n(this,t,[e])).f=i,a.defaultValue=o,a.index=0,a}return d(t,e),a(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"))}}])}(cU),"last"),DV=hU(function(e){function t(e,i){var o;return r(this,t),(o=n(this,t,[e])).predicate=i,o.index=0,o}return d(t,e),a(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"))}}])}(cU),"every"),NV=hU(function(e){function t(e,i,o){var a;return r(this,t),(a=n(this,t,[e])).f=i,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),a(t,[{key:"next",value:function(e){this.sink.next(this.acc=this.f(this.acc,e))}}])}(cU),"scan"),xV=hU(function(e){function t(){var e;return r(this,t),(e=n(this,t,arguments)).hasLast=!1,e}return d(t,e),a(t,[{key:"next",value:function(e){this.hasLast?this.sink.next([this.last,e]):this.hasLast=!0,this.last=e}}])}(cU),"pairwise"),OV=function(e){function t(e,i,o){var a;return r(this,t),(a=n(this,t,[e])).mapper=i,a.thisArg=o,a}return d(t,e),a(t,[{key:"next",value:function(e){g(t,"next",this,3)([this.mapper.call(this.thisArg,e)])}}])}(cU),PV=hU(OV,"map"),MV=function(e){return hU(OV,"mapTo")((function(t){return e}))},LV=function(e){function t(e,i,o){var a;return r(this,t),(a=n(this,t,[e])).data=i,a.context=o,a}return d(t,e),a(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()}}])}(cU),UV=function(e){function t(e,i,o){var a;return r(this,t),(a=n(this,t,[e])).makeSource=i,a.combineResults=o,a.index=0,a}return d(t,e),a(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()}}])}(cU),VV=function(e){function t(){return r(this,t),n(this,t,arguments)}return d(t,e),a(t)}(LV),FV=function(e){function t(){return r(this,t),n(this,t,arguments)}return d(t,e),a(t,[{key:"next",value:function(e){var t=this;this.subInner(e,VV),this.next=function(e){t.currentSink.dispose(),t.subInner(e,VV)}}}])}(UV),BV=hU(FV,"switchMap");function jV(e){return function(t,n){return e((function(){return t}),n)}}var HV=jV(hU(FV,"switchMapTo")),GV=function(e){function t(){return r(this,t),n(this,t,arguments)}return d(t,e),a(t,[{key:"tryComplete",value:function(){this.dispose(),this.context.sources.length?this.context.subNext():(this.context.resetNext(),this.context.resetComplete())}}])}(LV),WV=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),a(t,[{key:"next",value:function(e){this.next2(e),this.subNext()}},{key:"subNext",value:function(){this.next=this.next2,this.subInner(this.sources.shift(),GV),this.disposed&&0===this.sources.length&&this.currentSink.resetComplete()}},{key:"tryComplete",value:function(){0===this.sources.length&&this.currentSink.resetComplete(),this.dispose()}}])}(UV),JV=hU(WV,"concatMap"),zV=jV(hU(WV,"concatMapTo")),KV=function(e){function t(){return r(this,t),n(this,t,arguments)}return d(t,e),a(t,[{key:"tryComplete",value:function(){this.context.inners.delete(this),g(t,"dispose",this,3)([]),0===this.context.inners.size&&this.context.resetComplete()}}])}(LV),qV=function(e){function t(){var e;return r(this,t),(e=n(this,t,arguments)).inners=new Set,e}return d(t,e),a(t,[{key:"next",value:function(e){this.subInner(e,KV),this.inners.add(this.currentSink)}},{key:"tryComplete",value:function(){1===this.inners.size?this.inners.forEach((function(e){return e.resetComplete()})):this.dispose()}}])}(UV),YV=hU(qV,"mergeMap"),XV=jV(hU(qV,"mergeMapTo")),QV=function(e){function t(){return r(this,t),n(this,t,arguments)}return d(t,e),a(t,[{key:"dispose",value:function(){this.context.resetNext(),g(t,"dispose",this,3)([])}}])}(LV),$V=function(e){function t(){return r(this,t),n(this,t,arguments)}return d(t,e),a(t,[{key:"next",value:function(e){this.next=eU,this.subInner(e,QV)}}])}(UV),ZV=hU($V,"exhaustMap"),eF=jV(hU($V,"exhaustMapTo")),tF=hU(function(e){function t(e,i){var o;return r(this,t),(o=n(this,t,[e])).f=i,o.groups=new Map,o}return d(t,e),a(t,[{key:"next",value:function(e){var n=this.f(e),r=this.groups.get(n);void 0===r&&((r=NU()).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])}}])}(cU),"groupBy"),nF=hU(function(e){function t(){var e;return r(this,t),(e=n(this,t,arguments)).start=new Date,e}return d(t,e),a(t,[{key:"next",value:function(e){this.sink.next({value:e,interval:Number(new Date)-Number(this.start)}),this.start=new Date}}])}(cU),"timeInterval"),rF=hU(function(e){function t(e,i){var o;return r(this,t),(o=n(this,t,[e])).miniseconds=i,o.buffer=[],o.id=setInterval((function(){o.sink.next(o.buffer.concat()),o.buffer.length=0}),o.miniseconds),o}return d(t,e),a(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)([])}}])}(cU),"bufferTime"),iF=hU(function(e){function t(e,i){var o;return r(this,t),(o=n(this,t,[e])).buffer=[],o.delayTime=i,o}return d(t,e),a(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)}}])}(cU),"delay"),oF=hU(function(e){function t(e,i){var o;return r(this,t),(o=n(this,t,[e])).selector=i,o}return d(t,e),a(t,[{key:"error",value:function(e){this.dispose(),this.selector(e)(this.sink)}}])}(cU),"catchError"),aF=function(){return function(e){return new Promise((function(t,n){var r;new uU(e,(function(e){return r=e}),n,(function(){return t(r)}))}))}},sF=function(){return function(e){var t;return new ReadableStream({start:function(n){t=new uU(e,n.enqueue.bind(n),n.error.bind(n),n.close.bind(n))},cancel:function(){t.dispose()}})}},cF=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:eU,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:eU,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:eU;return function(r){return new uU(r,e,t,n)}},uF=hU(function(e){function t(e,i){var o;return r(this,t),o=n(this,t,[e]),i instanceof Function?o.next=function(t){i(t),e.next(t)}:(i.next&&(o.next=function(t){i.next(t),e.next(t)}),i.complete&&(o.complete=function(){i.complete(),e.complete()}),i.error&&(o.error=function(t){i.error(t),e.error(t)})),o}return d(t,e),a(t)}(cU),"tap"),lF=hU(function(e){function t(e,i){var o;return r(this,t),(o=n(this,t,[e])).timeout=i,o.id=setTimeout((function(){return o.error(new vU(o.timeout))}),o.timeout),o}return d(t,e),a(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)([])}}])}(cU),"timeout"),dF=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1/0;return function(t){if(t instanceof aU){var n=dU((function(r){var i=e,o=new cU(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,mU.pipe(n),n}return function(n){var r=e,i=new cU(n);i.error=function(e){r-- >0?t(i):n.error(e)},t(i)}}},hF=function(e){function i(e,o,a){var s;r(this,i),(s=n(this,i,[{userId:o.userId,sdkAppId:e.sdkAppId,mediaType:a,room:e}])).room=e,s.user=o,ER(t(s),"tinyId"),ER(t(s),"isRemote",!0),ER(t(s),"jitterBufferDelay",0),ER(t(s),"availableState"),ER(t(s),"remotePublishState"),ER(t(s),"_triggerCheckDecodeSubject",NU(jU(t(s),i.STATE_SUBSCRIBE))),s.tinyId=o.tinyId,s.availableState=new KP("".concat(o.userId,"-").concat(s.mediaType,"-available"),"remote-track-available"),s.remotePublishState=new KP("".concat(o.userId,"-").concat(s.mediaType,"-remote-publish"),"remote-track-publish"),lU(yU(jU(t(s),KP.STATECHANGED),jU(s.remotePublishState,KP.STATECHANGED)),PV((function(){return s.isRemotePublished&&(s.isSubscribed||s.isSubscribing)})),cF((function(e){s.availableState.state!==(e?KP.ON:KP.OFF)&&(s.availableState.state=e?KP.ON:KP.OFF),s.updatePlayingState(e)})));var c=lU(jU(s.player,eM.ERROR),aV((function(e){return e.code===MediaError.MEDIA_ERR_DECODE}))),u=lU(VU(5e3),aV((function(){return!(s.ignoreDecodeError||!s.isSubscribed||!s.isPlayCalled||!s.stat.bytesReceived||(s.player.isPlaying||(s.kind===yC.AUDIO?s.getAudioLevel()>0:s.stat.framesDecoded>0))&&(s.reportDecodeResult(!0),1))}))),l=lU(EU(c,u),uV(jU(s,KP.INIT)));return lU(s._triggerCheckDecodeSubject,aV((function(){return!s.ignoreDecodeError})),HV(l),cF((function(e){s.reportDecodeResult(!1,e)}))),s}return d(i,e),a(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===KP.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===yC.AUDIO;GO[e?"addSuccessEvent":"addFailedEvent"]({key:n?504700:514702}),e||(GO.addEnum({key:n?504701:514703,value:vx()}),oM.uploadEvent({log:"stat-decode-failed-".concat(this.kind,"-").concat(fx()||_x()),userId:this.room.userId}),this._log.warn("decode failed: isPlaying: ".concat(this.player.isPlaying," ").concat(this.kind===yC.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?KP.ON:KP.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)([])}}])}(vL);ER(hF,"STATE_SUBSCRIBE","subscribe"),yR([$L(5,1)],hF.prototype,"waitHasMediaTrack",1),yR([WP(KP.INIT,hF.STATE_SUBSCRIBE,{success:function(){this.log.info("subscribed"),Tx.emit(Sx.REMOTE_TRACK_SUBSCRIBED,{track:this})},ignoreError:!0}),LL(521716,!1)],hF.prototype,"subscribe",1),yR([WP(hF.STATE_SUBSCRIBE,KP.INIT,{sync:!0,success:function(){this.log.info("unsubscribed"),Tx.emit(Sx.REMOTE_TRACK_UNSUBSCRIBED,{track:this})}})],hF.prototype,"unsubscribe",1);var fF=hF,pF=function(e){function i(e,o){var a;return r(this,i),a=n(this,i,[e,o,1]),ER(t(a),"volume",0),ER(t(a),"mediaType",1),ER(t(a),"stat",{bytesReceived:0,packetsReceived:0,packetsLost:0,end2EndDelay:0,jitterBufferDelay:0}),a.manager=e.audioManager,a}return d(i,e),a(i,[{key:"dbVolume",get:function(){return QM.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(o){r.e(o)}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}}])}(fF),mF=[-1,-1,1,-1,-1,1,1,1],vF=[0,0,1,0,0,1,1,1],_F=function(e){function i(e,o){var a;if(r(this,i),(a=n(this,i)).context=e,ER(t(a),"name"),ER(t(a),"input"),ER(t(a),"output"),ER(t(a),"texture"),ER(t(a),"ctx2d",null),ER(t(a),"fbo"),ER(t(a),"width",0),ER(t(a),"height",0),ER(t(a),"x",0),ER(t(a),"y",0),ER(t(a),"program"),ER(t(a),"vertexShader"),ER(t(a),"fragmentShader"),ER(t(a),"totalFrames",0),ER(t(a),"dropFrames",0),ER(t(a),"matchInputSize",!0),ER(t(a),"texCoordBuffer"),ER(t(a),"positionBuffer"),ER(t(a),"lastInfo",{name:"",timestamp:0,totalFrames:0,x:0,y:0,width:0,height:0,fps:0}),ER(t(a),"cost",0),ER(t(a),"_canvas",null),ER(t(a),"_image"),ER(t(a),"log"),a.context.on("disconnect",a.close,t(a)),a.name=o.name,a.log=o.logger,a.matchInputSize=!1!==o.matchInputSize,a.width=o.width||e.width,a.height=o.height||e.height,a._image=o.image,e instanceof NF)e.ctx&&o.create2d&&("function"==typeof OffscreenCanvas&&16!==tx?a._canvas=new OffscreenCanvas(a.width,a.height):(a._canvas=document.createElement("canvas"),a._canvas.width=a.width,a._canvas.height=a.height),a.ctx2d=a._canvas.getContext("2d"),a._image=a._canvas);else try{var s=e.ctx;a.texCoordBuffer=a.createBuffer(vF),a.positionBuffer=a.createBuffer(mF),!1!==o.createTexture&&(a.texture=s.createTexture(),a.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)),o.useFbo&&(a.fbo=s.createFramebuffer(),a.useBufferFrame(),a.useTexture(),s.texImage2D(s.TEXTURE_2D,0,s.RGBA,a.width,a.height,0,s.RGBA,s.UNSIGNED_BYTE,null),s.framebufferTexture2D(s.FRAMEBUFFER,s.COLOR_ATTACHMENT0,s.TEXTURE_2D,a.texture,0)),o.useDefaultProgram?a.program=e.defaultProgam:(o.vertexShaderSource||o.fragmentShaderSource)&&(a.vertexShader=o.vertexShaderSource?e.createShader(s.VERTEX_SHADER,o.vertexShaderSource):e.defaultVShader,a.fragmentShader=o.fragmentShaderSource?e.createShader(s.FRAGMENT_SHADER,o.fragmentShaderSource):e.defaultFShader,a.program=e.createProgram(a.vertexShader,a.fragmentShader))}catch(Px){a.context.destroy(new LR({code:PR.VIDEO_MANAGER_ERROR,extraCode:3,message:"create video node ".concat(a.name," error ").concat(Px.message||Px)}))}return a}return d(i,e),a(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 DF&&this.render(e)||this.context instanceof NF&&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 DF){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,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},pR({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}}])}(KP);yR([WP(KP.INIT,"connected",{sync:!0})],_F.prototype,"connect",1),yR([WP("connected",KP.INIT,{ignoreError:!0,sync:!0})],_F.prototype,"disconnect",1),yR([WP([],"closed",{sync:!0})],_F.prototype,"close",1);var gF=lU(UU(250),PV((function(){return performance.now()})),gU()),yF=[0,1,1,1,0,0,1,0],EF=function(e){function i(e,o){var a;return r(this,i),a=n(this,i,[e,Object.assign({useDefaultProgram:!0,createTexture:!1,name:"destination"},o)]),ER(t(a),"_intervalId",0),ER(t(a),"_sequence",0),ER(t(a),"checkGLError",!1),ER(t(a),"checkVisibilityChange"),e instanceof NF?a.ctx2d=e.ctx||null:e.available&&null!=o&&o.mirrorUpAndDown&&a.setTexBuffer(yF),a}return d(i,e),a(i,[{key:"start",value:function(e){var t=this;this.log.info("".concat(this.name," start render ").concat(e," fps")),ZP.clearTask(this._intervalId),this._intervalId=ZP.run("intervalInWorker",(function(){if(e!==t.context.frameRate&&(ZP.clearTask(t._intervalId),t.start(t.context.frameRate)),t.requestFrame(t._sequence++),t.checkGLError&&t.context instanceof DF){var n=t.context.ctx.getError();n&&t.context.destroy(new LR({code:PR.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&&(ZP.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]),ZP.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)([]),ZP.clearTask(this._intervalId),document.removeEventListener("visibilitychange",this.checkVisibilityChange)}}])}(_F),TF=function(e){function i(e,o){var a,s;return r(this,i),s=n(this,i,[e,o]),ER(t(s),"_videoTrack"),ER(t(s),"_muteOb"),ER(t(s),"_closedOb",jU(t(s),"closed")),ER(t(s),"_subscription"),ER(t(s),"_canvasContainer"),Number($N)<17&&(s._canvasContainer=document.createElement("div"),s._canvasContainer.style.display="none"),a=v(e._canvas.captureStream().getVideoTracks(),1),s._videoTrack=a[0],s._muteOb=jU(s._videoTrack,"mute"),lU(jU(s._videoTrack,"ended"),uV(s._closedOb),cF((function(){s.context.destroy(new LR({code:PR.VIDEO_MANAGER_ERROR,extraCode:8,message:"video track ended"}))}))),s}return d(i,e),a(i,[{key:"enableCheckMute",value:function(){var e,t=this;this._subscription=lU(this._muteOb,uV(this._closedOb),HV((e=5e3,function(t){var n=performance.now();lU(gF,pV((function(t){return t-n<e})),cV(1))(t)})),cF((function(){var e;null!=(e=t._videoTrack)&&e.muted&&t.context.destroy(new LR({code:PR.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()}}])}(EF),kF=function(e){function t(){return r(this,t),n(this,t,arguments)}return d(t,e),a(t,[{key:"render",value:function(e){var t;return!(null==(t=this.input)||!t.requestFrame(e))}}])}(TF),SF=function(e){function t(e,i,o){var a;return r(this,t),(a=n(this,t,[e,{name:"smallDestination",logger:o}])).resolution=i,a}return d(t,e),a(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),g(t,"resize",this,3)([e/Math.sqrt(r),n/Math.sqrt(r)])}}])}(TF),IF=function(e){function i(e,o){var a;return r(this,i),a=n(this,i,[e,pR({name:"imageSource"},o)]),ER(t(a),"_lastImage"),ER(t(a),"_totalFrames",0),ER(t(a),"_autoResize",!1),ER(t(a),"_canvasRendered"),ER(t(a),"_videoCallbackId",0),a._autoResize=!1!==(null==o?void 0:o.autoResize),16===tx&&(a._canvasRendered=NU(),lU(a._canvasRendered,AU(a._image),BV((function(e){return e instanceof HTMLCanvasElement?jU(e,"rendered"):ZU()})),uV(jU(t(a),"closed")),cF((function(){a.update()})))),a}return d(i,e),a(i,[{key:"tryVideoFrameCallback",value:function(e){var t=this;this._videoCallbackId&&e.cancelVideoFrameCallback(this._videoCallbackId),LP()&&!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)}}])}(_F),bF=function(e){function i(e,o,a){var s;return r(this,i),(s=n(this,i,[e,a]))._player=o,s.name="videoPlayerSource",lU(jU(s._player,eM.PLAYER_STATE_CHANGED),uV(jU(t(s),"closed")),aV((function(e){return"PLAYING"===e.state})),cF((function(){s.tryVideoFrameCallback(s._player.element)}))),s}return d(i,e),a(i,[{key:"image",get:function(){return this._player.element}}])}(IF),AF=function(e){function t(e,i,o){var a;return r(this,t),(a=n(this,t,[e,new xM({id:o.name,track:i,muted:!0,container:null,objectFit:"contain",log:o.logger}),o])).name="videoTrackSource",a._player.play(),a}return d(t,e),a(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()}}])}(bF),RF=function(e){function i(e){var o;return r(this,i),o=n(this,i),ER(t(o),"frameRate"),ER(t(o),"_canvas"),ER(t(o),"log"),ER(t(o),"hasAlpha",!1),ER(t(o),"name"),ER(t(o),"error"),o.name=e.name,o.log=e.logger.createChild({id:"vc-".concat(o.name)}),o.frameRate=e.frameRate,o}return d(i,e),a(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 AF(this,e,{logger:this.log,name:t})}},{key:"createVideoTrackDestination",value:function(e){return new TF(this,e)}},{key:"createVideoImageSource",value:function(e,t){return new IF(this,t?Object.assign(t,{logger:this.log,image:e}):{logger:this.log,image:e})}},{key:"createVideoPlayerSource",value:function(e,t){return new bF(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")}}])}(KP);ER(RF,"_ids",0);var CF={alpha:!0,antialias:!1,premultipliedAlpha:!1,preserveDrawingBuffer:!1,depth:!1,stencil:!1,failIfMajorPerformanceCaveat:!0,powerPreference:"low-power"},wF=function(e){function i(){var e;return r(this,i),e=n(this,i,arguments),ER(t(e),"defaultProgam"),ER(t(e),"defaultVShader"),ER(t(e),"defaultFShader"),ER(t(e),"ctx"),e}return d(i,e),a(i,[{key:"create",value:function(){var e=this;if(this._canvas||(this._canvas=document.createElement("canvas"),this._canvas.id="trtc_".concat(this.name,"_").concat(RF._ids++)),this.ctx=this._canvas.getContext("webgl2",CF),!this.ctx)throw new LR({code:PR.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 LR({code:PR.VIDEO_MANAGER_ERROR,extraCode:4,message:"webgl context lost"}))}))}},{key:"destroy",value:function(e){var t="";return e&&(t=e.message,this.error=e,GO.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}}])}(RF);ER(wF,"UNAVAILABLE","unavailable"),yR([WP(KP.INIT,"created",{sync:!0,fail:function(e){this.log.error("video gl context create failed",e.cause),GO.addFailedEvent({key:512700,error:e.cause||e})},success:function(){this.log.info("video context created use webgl"),GO.addSuccessEvent({key:512700})}})],wF.prototype,"create",1),yR([WP("created",KP.INIT,{ignoreError:!0,sync:!0,success:function(e){e&&this.emit(wF.UNAVAILABLE,e),this.removeAllListeners()}})],wF.prototype,"destroy",1);var DF=wF,NF=function(e){function i(){var e;return r(this,i),e=n(this,i,arguments),ER(t(e),"ctx"),e}return d(i,e),a(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(RF._ids++),this.ctx=this._canvas.getContext("2d",{alpha:e.alpha}),!this.ctx)throw new LR({code:PR.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,GO.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(),GO.addSuccessEvent({key:512703})}}])}(RF);yR([WP(KP.INIT,"created",{sync:!0,fail:function(e){this.log.error("video 2d context create failed",e.cause),GO.addFailedEvent({key:512701,error:e.cause||e})},success:function(){this.log.info("video context created use 2d"),GO.addSuccessEvent({key:512701})}})],NF.prototype,"create",1),yR([WP("created",KP.INIT,{ignoreError:!0,sync:!0})],NF.prototype,"destroy",1);var xF=function(e){function i(e,o){var a;return r(this,i),a=n(this,i,[e,o,arguments.length>2&&void 0!==arguments[2]?arguments[2]:4]),ER(t(a),"mediaType",4),ER(t(a),"source"),ER(t(a),"stat",{bytesReceived:0,packetsReceived:0,packetsLost:0,framesReceived:0,framesDecoded:0,frameWidth:0,frameHeight:0,end2EndDelay:0,jitterBufferDelay:0}),a.manager=e.videoManager,a.once("first-video-frame",(function(e){a.room.emit("first-video-frame",e)})),a}return d(i,e),a(i,[{key:"play",value:function(e,t){var n=this;return(Ww(null==t?void 0:t.canvasRender)?t.canvasRender:17===tx)&&!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 NF({frameRate:15,logger:this.log,name:this.userId});e.create({alpha:!1});var t=new EF(e,{name:"remotePlayer",logger:this.log});this.source=e.createVideoPlayerSource(this.player),this.source.connect(t),this.player.setCanvas(e._canvas),LP()||(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})));!Gw(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)}}])}(fF),OF=function(e){function i(e,o){var a;return r(this,i),a=n(this,i,[e,o,2]),ER(t(a),"mediaType",2),ER(t(a),"objectFit","contain"),a}return d(i,e),a(i,[{key:"isRemotePublished",get:function(){return this.user.muteState.hasAuxiliary}}])}(xF),PF=new Map;function MF(e,t){var n=mR(pR({},t),{timestamp:VR()});PF.has(e)?PF.get(e).push(n):PF.set(e,[n])}Tx.on(Sx.JOIN_SUCCESS,(function(e){MF(e.room.userId,{eventId:32788})})),Tx.on(Sx.LEAVE_START,(function(e){MF(e.room.userId,{eventId:32789})})),Tx.on(Sx.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),MF(t.room.userId,{eventId:n})}})),Tx.on(Sx.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),MF(t.room.userId,{eventId:n})}})),Tx.on(Sx.TRACK_MUTED,(function(e){var t=e.track;t.room&&(t.kind===yC.AUDIO?MF(t.room.userId,{eventId:t.isRemote?32785:32772,remoteUserId:t.isRemote?t.userId:void 0}):MF(t.room.userId,{eventId:t.isRemote?32784:32773,remoteUserId:t.isRemote?t.userId:void 0}))})),Tx.on(Sx.TRACK_UNMUTED,(function(e){var t=e.track;t.room&&(t.kind===yC.AUDIO?MF(t.room.userId,{eventId:t.isRemote?32787:32774,remoteUserId:t.isRemote?t.userId:void 0}):MF(t.room.userId,{eventId:t.isRemote?32786:32775,remoteUserId:t.isRemote?t.userId:void 0}))})),Tx.on(Sx.REMOTE_TRACK_SUBSCRIBED,(function(e){var t=e.track;t.room&&(1===t.mediaType&&MF(t.room.userId,{eventId:32777,remoteUserId:t.userId}),4===t.mediaType&&MF(t.room.userId,{eventId:32776,remoteUserId:t.userId}),8===t.mediaType&&MF(t.room.userId,{eventId:32803,remoteUserId:t.userId}))})),Tx.on(Sx.REMOTE_TRACK_UNSUBSCRIBED,(function(e){var t=e.track;t.room&&(1===t.mediaType&&MF(t.room.userId,{eventId:32779,remoteUserId:t.userId}),4===t.mediaType&&MF(t.room.userId,{eventId:32778,remoteUserId:t.userId}),8===t.mediaType&&MF(t.room.userId,{eventId:32804,remoteUserId:t.userId}))})),Tx.on(Sx.SWITCH_DEVICE_SUCCESS,(function(e){var t=e.track;t.room&&MF(t.room.userId,{eventId:t.kind===yC.VIDEO?32780:32781})})),Tx.on(Sx.LOCAL_TRACK_REPLACED,(function(e){var t=e.track;t.room&&MF(t.room.userId,{eventId:t.kind===yC.VIDEO?32782:32783})})),Tx.on(Sx.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&&MF(n.userId,{eventId:t})})),Tx.on(Sx.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&&MF(n.userId,{eventId:t,remoteUserId:o})})),Tx.on(Sx.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),MF(t,s),GO.addEnum({key:n?514701:513701,value:o}),GO.addEnum({key:n?514700:513700,value:a})})),Tx.on(Sx.LOCAL_TRACK_RECAPTURE,(function(e){var t=e.track,n=e.error;if(t.userId){var r={eventId:2003,param1:0};t.kind===yC.AUDIO?(r.streamType=1,n&&(r.param1=2)):(r.streamType="auxiliary"===t.streamType?7:2,n&&(r.param1=8)),MF(t.userId,r)}}));var LF=function(e){function i(e,o){var a;r(this,i);var s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"userId";return(a=n(this,i)).mySelfId=e,a._log=o,a.key=s,ER(t(a),"userMap",new Map),ER(t(a),"remotePublishedUserMap",new Map),a}return d(i,e),a(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 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,"]");jw(t)||(r+=":".concat(vw[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=oD(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:oD(0,o),muteState:s,flag:i})}}))}},{key:"clear",value:function(){this.userMap.clear(),this.remotePublishedUserMap.clear()}}])}(gR(SR(),1).EventEmitter);function UF(e){var t=e.timesInSecond,n=e.maxSizeInSecond,r=e.getSize;return RL((function(e,i){var o=new WeakMap;return Tx.on(Sx.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 LR({code:PR.INVALID_OPERATION,message:OO({key:wO.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 VF,FF=!0,BF={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"},jF={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},HF=((VF=HF||{})[VF.INVALID_PARAMETER=5e3]="INVALID_PARAMETER",VF[VF.INVALID_PARAMETER_REQUIRED=5001]="INVALID_PARAMETER_REQUIRED",VF[VF.INVALID_PARAMETER_TYPE=5002]="INVALID_PARAMETER_TYPE",VF[VF.INVALID_PARAMETER_EMPTY=5003]="INVALID_PARAMETER_EMPTY",VF[VF.INVALID_PARAMETER_INSTANCE=5004]="INVALID_PARAMETER_INSTANCE",VF[VF.INVALID_PARAMETER_RANGE=5005]="INVALID_PARAMETER_RANGE",VF[VF.INVALID_PARAMETER_LESS_THAN_ZERO=5006]="INVALID_PARAMETER_LESS_THAN_ZERO",VF[VF.INVALID_PARAMETER_MIN=5007]="INVALID_PARAMETER_MIN",VF[VF.INVALID_PARAMETER_MAX=5008]="INVALID_PARAMETER_MAX",VF[VF.INVALID_ELEMENT_ID=5009]="INVALID_ELEMENT_ID",VF[VF.INVALID_ELEMENT_ID_TYPE=5010]="INVALID_ELEMENT_ID_TYPE",VF[VF.INVALID_STREAM_ID=5011]="INVALID_STREAM_ID",VF[VF.INVALID_ROOM_ID_STRING=5012]="INVALID_ROOM_ID_STRING",VF[VF.INVALID_ROOM_ID_INTEGER=5013]="INVALID_ROOM_ID_INTEGER",VF[VF.INVALID_STREAM_TYPE=5014]="INVALID_STREAM_TYPE",VF[VF.INVALID_ROOM_ID_REQUIED=5015]="INVALID_ROOM_ID_REQUIED",VF[VF.INVALID_ROOM_ID_INTEGER_STRING=5016]="INVALID_ROOM_ID_INTEGER_STRING",VF[VF.INVALID_BUFFER_EMPTY=5017]="INVALID_BUFFER_EMPTY",VF[VF.INVALID_BUFFER_OVERSIZE=5018]="INVALID_BUFFER_OVERSIZE",VF[VF.INVALID_OPERATION=5100]="INVALID_OPERATION",VF[VF.INVALID_OPERATION_NOT_JOINED=5101]="INVALID_OPERATION_NOT_JOINED",VF[VF.INVALID_OPERATION_REMOTE_USER_NOT_EXIST=5102]="INVALID_OPERATION_REMOTE_USER_NOT_EXIST",VF[VF.INVALID_OPERATION_STREAM_TYPE_NOT_EXIST=5103]="INVALID_OPERATION_STREAM_TYPE_NOT_EXIST",VF[VF.INVALID_OPERATION_REPEAT_CALL=5104]="INVALID_OPERATION_REPEAT_CALL",VF[VF.INVALID_OPERATION_NEED_VIDEO=5105]="INVALID_OPERATION_NEED_VIDEO",VF[VF.INVALID_OPERATION_NEED_AUDIO=5106]="INVALID_OPERATION_NEED_AUDIO",VF[VF.INVALID_ROLE_AUDIENCE=5107]="INVALID_ROLE_AUDIENCE",VF[VF.INVALID_NOT_ENABLE_SEI=5108]="INVALID_NOT_ENABLE_SEI",VF[VF.INVALID_NEED_CALL_PUBLISHED=5109]="INVALID_NEED_CALL_PUBLISHED",VF[VF.ENV_NOT_SUPPORTED=5200]="ENV_NOT_SUPPORTED",VF[VF.NOT_SUPPORTED_HTTP=5201]="NOT_SUPPORTED_HTTP",VF[VF.NOT_SUPPORTED_WEBRTC=5202]="NOT_SUPPORTED_WEBRTC",VF[VF.NOT_SUPPORTED_H264_ENCODE=5203]="NOT_SUPPORTED_H264_ENCODE",VF[VF.NOT_SUPPORTED_H264_DECODE=5204]="NOT_SUPPORTED_H264_DECODE",VF[VF.NOT_SUPPORTED_SCREEN_SHARE=5205]="NOT_SUPPORTED_SCREEN_SHARE",VF[VF.NOT_SUPPORTED_SMALL_VIDEO=5206]="NOT_SUPPORTED_SMALL_VIDEO",VF[VF.NOT_SUPPORTED_SEI=5207]="NOT_SUPPORTED_SEI",VF[VF.NOT_SUPPORTED_WEBGL=5208]="NOT_SUPPORTED_WEBGL",VF[VF.NOT_SUPPORTED_CHROME_VERSION=5209]="NOT_SUPPORTED_CHROME_VERSION",VF[VF.NOT_SUPPORTED_PLUGIN=5210]="NOT_SUPPORTED_PLUGIN",VF[VF.DEVICE_ERROR=5300]="DEVICE_ERROR",VF[VF.DEVICE_NOT_FOUND_ERROR=5301]="DEVICE_NOT_FOUND_ERROR",VF[VF.DEVICE_NOT_ALLOWED_ERROR=5302]="DEVICE_NOT_ALLOWED_ERROR",VF[VF.DEVICE_NOT_READABLE_ERROR=5303]="DEVICE_NOT_READABLE_ERROR",VF[VF.DEVICE_OVERCONSTRAINED_ERROR=5304]="DEVICE_OVERCONSTRAINED_ERROR",VF[VF.DEVICE_INVALID_STATE_ERROR=5305]="DEVICE_INVALID_STATE_ERROR",VF[VF.DEVICE_SECURITY_ERROR=5306]="DEVICE_SECURITY_ERROR",VF[VF.DEVICE_ABORT_ERROR=5307]="DEVICE_ABORT_ERROR",VF[VF.CAMERA_RECOVER_FAILED=5308]="CAMERA_RECOVER_FAILED",VF[VF.MICROPHONE_RECOVER_FAILED=5309]="MICROPHONE_RECOVER_FAILED",VF[VF.SERVER_ERROR=5400]="SERVER_ERROR",VF[VF.NEED_TO_BUY=5401]="NEED_TO_BUY",VF[VF.ACCOUNT_NO_MONEY=-100013]="ACCOUNT_NO_MONEY",VF[VF.OPERATION_FAILED=5500]="OPERATION_FAILED",VF[VF.FIREWALL_RESTRICTION=5501]="FIREWALL_RESTRICTION",VF[VF.REJOIN_FAILED=5502]="REJOIN_FAILED",VF[VF.EVENT_HANDLER_ERROR=5503]="EVENT_HANDLER_ERROR",VF[VF.VIDEO_CONTEXT_ERROR=5504]="VIDEO_CONTEXT_ERROR",VF[VF.VIDEO_DECODE_ERROR=5505]="VIDEO_DECODE_ERROR",VF[VF.OPERATION_ABORT=5998]="OPERATION_ABORT",VF[VF.UNKNOWN_ERROR=5999]="UNKNOWN_ERROR",VF),GF=mR(pR({},DO),{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(Fw(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(Fw(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?WF(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?WF(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?WF(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&&WF(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?WF(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?WF(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&&WF(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 WF(e){if(!e)return"camera";var t=e.toLowerCase();return t.includes("screen")?"screen share":t.includes("audio")?"microphone":"camera"}var JF=function(e){function i(e){var o;r(this,i);var a,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.code,r=e.params,i=e.enableDocLink,o=void 0!==i&&i,a="",s=HF[n];try{t=GF[s]}catch(p){t=GF.UNKNOWN_ERROR}return Bw(t)?a=t(r):Hw(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:c===jF.SERVER_ERROR?c:u||c,params:pR({fnName:p,error:m},h)}),o=n(this,i,[s]),ER(t(o),"name","RtcError"),ER(t(o),"code"),ER(t(o),"extraCode"),ER(t(o),"functionName"),ER(t(o),"message"),ER(t(o),"handler"),ER(t(o),"originError"),o.name=HF[c],o.code=c,o.extraCode=u,o.functionName=p,o.originError=m,o.message=s,5302===o.extraCode&&null!=(a=o.originError)&&a.message.includes("system")&&(o.handler=function(){var e=document.createElement("a");SN?e.href="ms-settings:privacy-".concat({startLocalVideo:"webcam",startLocalAudio:"microphone"}[o.functionName]):IN&&(e.href="x-apple.systempreferences:com.apple.preference.security?Privacy_".concat({startLocalVideo:"Camera",startLocalAudio:"Microphone",startScreenShare:"ScreenCapture"}[o.functionName])),e.href.length>0&&e.click()}),o}return d(i,e),a(i,null,[{key:"convertFrom",value:function(e,t,n){var r=e;if(e instanceof LR){var o=e.stack,a={code:jF.UNKNOWN_ERROR,fnName:t,originError:e};switch(e.getCode()){case PR.INVALID_PARAMETER:a.code=jF.INVALID_PARAMETER,a.message=e.message;break;case PR.INVALID_OPERATION:a.code=jF.INVALID_OPERATION;break;case PR.NOT_SUPPORTED:case PR.NOT_SUPPORTED_H264:a.code=jF.ENV_NOT_SUPPORTED,e.getCode()===PR.NOT_SUPPORTED_H264&&(a.extraCode=e.message.includes(DO.NOT_SUPPORTED_H264ENCODE)?5203:5204);break;case PR.JOIN_ROOM_FAILED:a.messageParams={fnParams:n};case PR.SERVER_TIMEOUT:case PR.SWITCH_ROLE_FAILED:a.code=jF.SERVER_ERROR,a.extraCode=e.getExtraCode();break;case PR.API_CALL_ABORTED:a.code=jF.OPERATION_ABORT;break;case PR.DEVICE_NOT_FOUND:case PR.DEVICE_AUTO_RECOVER_FAILED:case PR.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 PR.UNKNOWN:break;default:a.code=jF.OPERATION_FAILED}r=new i(a),o&&(r.stack+=o.substr(o.indexOf("\n")))}else{if(e instanceof i)return e;r=new i({code:jF.UNKNOWN_ERROR,fnName:t,originError:e})}return r}}])}(I(Error)),zF=JF,KF={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}}},qF={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}}},YF={type:["string",HTMLElement,null,"array"],arrayItem:{instanceOf:HTMLElement},validate:function(e,t,n){if(Hw(e)&&!document.getElementById(e))throw new zF({code:jF.INVALID_PARAMETER,extraCode:5009,fnName:n,messageParams:{key:t}})}},XF={name:"userId",required:!0,type:"string"},QF={type:"object",properties:{microphoneId:{type:"string"},audioTrack:{instanceOf:MediaStreamTrack},captureVolume:{type:"number",min:0},earMonitorVolume:{type:"number",min:0,max:100},profile:{values:[BF.AUDIO_PROFILE_STANDARD,BF.AUDIO_PROFILE_STANDARD_STEREO,BF.AUDIO_PROFILE_HIGH,BF.AUDIO_PROFILE_HIGH_STEREO]},echoCancellation:{type:"boolean"},autoGainControl:{type:"boolean"},noiseSuppression:{type:"boolean"}}};function $F(e,t){if(!e)throw new zF({code:jF.INVALID_OPERATION,extraCode:5101,fnName:t})}function ZF(e,t,n){if(!e)throw new zF({code:jF.INVALID_OPERATION,extraCode:5102,fnName:t,messageParams:{value:n}})}var eB={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 zF({code:jF.INVALID_OPERATION,extraCode:5104,fnName:n});if(e.roomId){if(Hw(e.roomId))throw new zF({code:jF.INVALID_PARAMETER,extraCode:5016,fnName:n,messageParams:{key:t}});if(!(/^[1-9]\d*$/.test(String(e.roomId))&&e.roomId<4294967295))throw new zF({code:jF.INVALID_PARAMETER,extraCode:5013,fnName:n,messageParams:{key:t}})}else{if(!e.strRoomId)throw new zF({code:jF.INVALID_PARAMETER,extraCode:5015,fnName:n});if(!/^[A-Za-z\d\s!#$%&()+\-:;<=.>?@[\]^_{}|~,]{1,64}$/.test(e.strRoomId))throw new zF({code:jF.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:YF,mute:{type:["boolean","string"]},publish:{type:"boolean"},option:KF},validate:function(e){var t;if((null==(t=null==e?void 0:e.option)||!t.videoTrack)&&QO())throw new zF({code:jF.ENV_NOT_SUPPORTED,extraCode:5201})}},updateLocalVideo:{name:"updateLocalVideoConfig",type:"object",required:!0,properties:{view:mR(pR({},YF),{required:!1}),publish:{type:"boolean"},mute:{type:["boolean","string"]},option:KF}},startLocalAudio:{name:"LocalAudioConfig",type:"object",properties:{publish:{type:"boolean"},option:QF},validate:function(e){var t;if((null==(t=null==e?void 0:e.option)||!t.audioTrack)&&QO())throw new zF({code:jF.ENV_NOT_SUPPORTED,extraCode:5201})}},updateLocalAudio:{name:"updateLocalAudioConfig",type:"object",required:!0,properties:{publish:{type:"boolean"},mute:{type:"boolean"},option:QF}},startScreenShare:{name:"ScreenShareConfig",type:"object",properties:{view:YF,publish:{type:"boolean"},option:qF},validate:function(e,t,n,r,i){var o;if(null==(o=null==e?void 0:e.option)||!o.videoTrack){if(QO())throw new zF({code:jF.ENV_NOT_SUPPORTED,extraCode:5201});if(!rP())throw new zF({code:jF.ENV_NOT_SUPPORTED,fnName:n,extraCode:5205})}}},updateScreenShare:{name:"updateScreenShareConfig",type:"object",required:!0,properties:{view:YF,publish:{type:"boolean"},option:qF}},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:YF,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){$F(this._room.isJoined,n);var r=this._room.remotePublishedUserMap.get(e.userId);if(ZF(!!r,n,e),r&&("main"===e.streamType&&!r.muteState.videoAvailable||"sub"===e.streamType&&!r.muteState.hasAuxiliary))throw new zF({code:jF.INVALID_OPERATION,extraCode:5103,fnName:n,messageParams:{value:e}})}},updateRemoteVideo:{name:"updateRemoteVideoConfig",type:"object",required:!0,properties:{view:mR(pR({},YF),{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){$F(this._room.isJoined,n);var r=this._room.remotePublishedUserMap.get(e.userId);if(ZF(!!r,n,e),r&&("main"===e.streamType&&!r.muteState.videoAvailable||"sub"===e.streamType&&!r.muteState.hasAuxiliary))throw new zF({code:jF.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&&jw(e.streamType))throw new zF({code:jF.INVALID_PARAMETER,extraCode:5014,fnName:n})}},switchRole:{name:"role",required:!0,values:["anchor","audience"],validate:function(e,t,n){$F(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(!RP)throw new zF({code:jF.ENV_NOT_SUPPORTED,fnName:n,extraCode:5207});if(!this._room.enableSEI)throw new zF({code:jF.INVALID_OPERATION,fnName:n,extraCode:5108});if(e.byteLength>1e3)throw new zF({code:jF.INVALID_PARAMETER,extraCode:5018,fnName:n});if(0===e.byteLength)throw new zF({code:jF.INVALID_PARAMETER,extraCode:5017,messageParams:{key:t},fnName:n});$F(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 zF({code:jF.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 zF({code:jF.INVALID_PARAMETER,extraCode:5018,fnName:n});if(0===e.byteLength)throw new zF({code:jF.INVALID_PARAMETER,extraCode:5017,fnName:n,messageParams:{key:t}})}}},validate:function(e,t,n){if($F(this._room.isJoined,n),"live"===this._room.scene&&"audience"===this._room.role)throw new zF({code:jF.INVALID_OPERATION,extraCode:5107,fnName:n,messageParams:{key:t}})}}},tB={TRTC:eB},nB=function(e){function t(){return r(this,t),n(this,t,arguments)}return d(t,e),a(t)}(I(Error));function rB(e,t){for(var n=uD(e),r=0;r<t.length;r++)cD(n[r],t[r]);return n}function iB(e){this._resolve=Promise.resolve(e)}function oB(e){this._reject=Promise.reject(e)}var aB=function(){function e(t,n){r(this,e),this.instance=t,this.group=n,ER(this,"started",!1),ER(this,"ops",[]),ER(this,"startSame",(function(){return!0})),ER(this,"mergeUpdate",rB);var i=e.instances.get(t);i?i.set(n,this):e.instances.set(t,new Map([[n,this]]))}return a(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 nB("start failed")),null==(i=r.currentOp)||i.action(),t},a={type:e,action:function(){return t.apply(void 0,E(a.args)).then(i,o)},args:n,resolve:iB,reject:oB};try{switch(this.state){case 1:if(0===e)throw new nB("already started");break;case 4:if(2===e)throw new nB("not started");break;default:return this.cacheOp(a)}}catch(Mx){return Promise.reject(Mx)}return this.ops.push(a),a.promise=t.apply(void 0,E(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 nB("already start");break;case 3:switch(e.type){case 2:throw new nB("update not allowed when stopping");case 3:return this.currentOp.promise}break;default:throw new nB("unknown state")}else switch(e.type){case 3:if(3===this.lastOpType)return this.lastOp.promise;var t=new nB("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 nB("update not allowed after stop")}break;case 0:switch(this.lastOpType){case 2:throw new nB("start not allowed after update");case 0:throw new nB("duplicate start");case 3:if(this.startSame(this.currentOp.args,e.args))throw this.ops.pop().reject(new nB("keep start")),new nB("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}}])}();ER(aB,"instances",new WeakMap);var sB=aB,cB=new WeakMap,uB=function(e,t){if(t instanceof nB){var n=t.stack;t=new zF({code:jF.OPERATION_ABORT,message:"".concat(e," abort: ").concat(t.message),fnName:e}),n&&(t.stack+=n.substr(n.indexOf("\n")))}throw t};function lB(e,t){return RL((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=sB.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(uB.bind(null,r))):n.apply(this,o)}}))}function dB(e,t){var n=t||{},r=n.merge,i=n.debounce;return RL((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=sB.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=cB.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(uB.bind(null,n)).then(e,r)}),l);cB.has(o)?null==(a=cB.get(o))||a.set(d.apply(void 0,s),{timeoutId:p,resolve:e}):cB.set(o,new Map([[d.apply(void 0,s),{timeoutId:p,resolve:e}]]))}))}return u.action(2,t.bind(this),s).catch(uB.bind(null,n))}}))}function hB(e){return RL((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(sB.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=sB.get(this,s);return c?c.action(3,t.bind(this),o).catch(uB.bind(null,n)):t.apply(this,o)}}))}var fB={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"},pB=new Set([fB.ERROR,fB.AUTOPLAY_FAILED,fB.KICKED_OUT,fB.REMOTE_USER_ENTER,fB.REMOTE_USER_EXIT,fB.REMOTE_AUDIO_AVAILABLE,fB.REMOTE_AUDIO_UNAVAILABLE,fB.REMOTE_VIDEO_AVAILABLE,fB.REMOTE_VIDEO_UNAVAILABLE,fB.CONNECTION_STATE_CHANGED,fB.PUBLISH_STATE_CHANGED,fB.SCREEN_SHARE_STOPPED,fB.DEVICE_CHANGED,fB.FIRST_VIDEO_FRAME]);function mB(e){return"sub"===e?"auxiliary":"auxiliary"===e?"sub":"main"}function vB(e){return e===BF.QOS_PREFERENCE_CLEAR?"detail":e===BF.QOS_PREFERENCE_SMOOTH?"motion":""}var _B={};_R(_B,{bytes2ms:function(){return Dw},convertObjectNumberToInt:function(){return yD},copyProperties:function(){return ww},deepClone:function(){return uD},deepMerge:function(){return cD},delay:function(){return ED},fibonacci:function(){return Uw},formatedTime:function(){return hD},getConstructorName:function(){return Qw},getContainerFromElement:function(){return dD},getEnv:function(){return Tw},getInternalVersion:function(){return nD},getLoggerUrl:function(){return Sw},getMuteStateFromFlag:function(){return oD},getNetworkType:function(){return bw},getNumNetworkType:function(){return Cw},getReconnectionTimeout:function(){return Vw},getStringByteLength:function(){return mD},getTurnServer:function(){return aD},getUint32Version:function(){return gD},getValueType:function(){return Fw},getViewListFromView:function(){return lD},glog:function(){return Pw},ipv4ToUint32:function(){return sD},isArray:function(){return zw},isAudioWorkletSupported:function(){return $w},isBoolean:function(){return Ww},isConstructor:function(){return Xw},isEmpty:function(){return iD},isFunction:function(){return Bw},isLangChinese:function(){return Mw},isMediaStreamTrack:function(){return Kw},isNumber:function(){return Gw},isObject:function(){return Jw},isOverseaSdkAppId:function(){return kw},isPlainObject:function(){return Lw},isPortrait:function(){return vD},isPromise:function(){return Yw},isRemoteTrack:function(){return qw},isString:function(){return Hw},isUndefined:function(){return jw},loadImage:function(){return _D},ms2bytes:function(){return xw},ms2samples:function(){return Ow},performanceNow:function(){return eD},promiseAny:function(){return Zw},samples2ms:function(){return Nw},setNetworkType:function(){return Rw},stringify:function(){return fD},stringifyIncludeValue:function(){return pD},throttlePromise:function(){return TD}});var gB={};_R(gB,{ScheduleRequestType:function(){return bB},getAbilityConfig:function(){return RB},getScheduleDomain:function(){return CB},isNeedToSchedule:function(){return EB},scheduleProxy:function(){return SB},sendScheduleRequest:function(){return kB},setIsNeedToSchedule:function(){return TB},setScheduleProxy:function(){return IB}});var yB=null,EB=!0;function TB(e){Ww(e)&&e!==EB&&(EB=e,bx.info("setIsNeedToSchedule ".concat(e)))}function kB(e){return kR(this,arguments,(function(e){var t=e.userId,n=e.sdkAppId,r=e.useStringRoomId,i=e.roomId,o=e.userSig,a=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(EB||!yB){e.next=2;break}return e.abrupt("return",{isCached:!0,result:yB});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",a),h.append("userSig",String(o)),u&&h.append("role",String(u)),l&&h.append("latencyLevel",String(l)),c&&h.append("frameWorkType",String(c)),p=eD(),e.next=9,function(e,t,n){return new Promise((function(r,i){var o=null;Zw([DB((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]=AB(n,"config",yC.MAIN,!0)),i())}))(AB(n,"config",yC.MAIN),e,{get timeout(){return 1e3*Uw(2+t.count[0])}}),DB((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]=AB(n,"config",yC.BACKUP,!0)),i())}))(AB(n,"config",yC.BACKUP),e,{get timeout(){return 1e3*Uw(2+t.count[1])}})]).then((function(e){r(o=e)})).catch(i)}))}(h,d,n);case 9:return(m=e.sent).config&&(m.config.loggerDomain&&$R(m.config.loggerDomain),Ww(m.config.scheduleCache)&&TB(!m.config.scheduleCache)),d.delta=eD()-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,a=performance.getEntriesByType("resource"),c=AB(e,"config",yC.MAIN),u=AB(e,"config",yC.BACKUP),l=s(a);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?yC.MAIN:yC.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];oM.uploadEvent({log:"stat-schedule-net:".concat(f,"(").concat(p,"(").concat(m,"->").concat(v,")->").concat(k.join("->"),") ").concat(h),userId:t}),r=mR(pR({},r),{totalCost:f,local:p,dns:_,tcp:y,tls:g,request:E,response:T});break}}}catch(S){l.e(S)}finally{l.f()}}catch(o){bx.error("getScheduleDetailCost error",o)}return r}(Number(n),t,p),e.abrupt("return",(yB=m,{isCached:!1,result:m,detailCost:v}));case 15:throw e.prev=15,e.t0=e.catch(3),_=zw(e.t0)?e.t0[0]:e.t0,g=Gw(_.code)?_.code:0,y="schedule failed".concat(_.message?": ".concat(_.message):""),E=new LR({code:PR.SCHEDULE_FAILED,extraCode:g,message:OO({key:wO.JOIN_ROOM_FAILED,data:{error:y,code:g}})}),bx.error(y,g),E;case 19:case"end":return e.stop()}}),e,null,[[3,15]])}))()}))}"undefined"!=typeof document&&document.head.insertAdjacentHTML("beforeend",Object.values(cw).map((function(e){return'<link rel="dns-prefetch" href="https://'.concat(e,'">')})).join("\r\n")),Tx.on("28",(function(){return TB(!0)})),Tx.on("63",(function(){return TB(!0)})),Tx.on("84",(function(){return TB(!0)})),Tx.on("201",(function(e){"RECONNECTING"===e.state&&TB(!0)})),Tx.on("202",(function(e){"RECONNECTING"===e.state&&TB(!0)}));var SB={main:"",backup:""};function IB(e){zw(e)?(SB.main=e[0],SB.backup=e[1]):SB.main=e}var bB=function(e){return e.CONFIG="config",e.TRTC_AUTO_CONF="trtcAutoConf",e.AUDIO_AI_AUTH="audioAiAuth",e}(bB||{});function AB(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:yC.MAIN,r=arguments.length>3&&void 0!==arguments[3]&&arguments[3];return"https://".concat(SB[n]||CB(e,n,r),"/api/v1/").concat(t)}function RB(e,t,n){var r=AB(e,t),i=AB(e,t,yC.BACKUP),o=new URLSearchParams(n).toString();return Zw([fetch("".concat(r,"?").concat(o)).then((function(e){return e.json()})),fetch("".concat(i,"?").concat(o)).then((function(e){return e.json()}))])}function CB(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:yC.MAIN,n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];return kw(e)?n?t===yC.MAIN?cw.MAIN_OVERSEA_BACKUP:cw.BACKUP_OVERSEA:t===yC.MAIN?cw.MAIN_OVERSEA:cw.BACKUP_OVERSEA:t===yC.MAIN?cw.MAIN:cw.BACKUP}function wB(e,t,n){return new Promise((function(r,i){kD({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 DB=function(e,t){return wD({retryFunction:wB,settings:{retries:3,timeout:0},onError:t,onRetrying:e})},NB=function(){function e(){r(this,e),ER(this,"_log"),this._log=bx.createLogger({id:"fd"})}return a(e,[{key:"download",value:function(e,t){return kR(this,null,f().mark((function n(){var r,i,o,a,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,a=eD(),!Bw(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((o=n.t0)&&o.data){n.next=16;break}throw new Error("data is empty");case 16:return s=eD()-a,n.abrupt("return",(this._log.info("downloaded: ".concat(e,", return type: ").concat(i,", cost: ").concat(s,"ms")),GO.addSuccessEvent({key:522700,cost:eD()-a}),o.data));case 20:throw n.prev=20,n.t1=n.catch(2),this._log.error("failed to download: ".concat(e,", error: ").concat(n.t1)),GO.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 kR(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 kR(this,null,f().mark((function n(){var r,i,o,a,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=eD(),i=null,o=null,!Bw(WebAssembly.instantiateStreaming)||e.startsWith("data:application/octet-stream;base64,")||function(e){return e.startsWith("file://")}(e)||!Bw(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=eD()-r,n.abrupt("return",(this._log.info("loadedWasm ".concat(e,", cost: ").concat(c,"ms")),GO.addSuccessEvent({key:522701,cost:c}),i));case 29:throw this._log.error("failed to loadWasm ".concat(e,", error: ").concat(o)),GO.addFailedEvent({key:522701,error:o}),o;case 30:case"end":return n.stop()}}),n,this,[[3,10],[14,23]])})))}}])}();yR([sM({settings:{timeout:0,retries:3},onRetrying:function(e){this._log.warn("download retrying: ".concat(e))}})],NB.prototype,"download",1);var xB=new NB;function OB(e){var t=this,n=e.TRTC,r=e.room,i=e.errorModule;return{TRTC:n,room:r,assetsPath:e.assetsPath,fileDownloader:xB,innerEmitter:Tx,constants:HR,environment:ND,utils:_B,eventLogger:oM,log:this.room.getLogger(),loggerManager:bx,errorModule:i,kvStatManager:GO,rtcDectection:Cx,trtc:this,rx:ZL,enums:wx,schedule:gB,clearStarted:function(e,n){var r=e.getAlias(),i=sB.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:XL,createAudioNode:KM}}var PB=new WeakMap;function MB(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return RL((function(e,n){return function(){for(var r=arguments.length,i=new Array(r),o=0;o<r;o++)i[o]=arguments[o];try{UB.call(this,t,i,n,this._name)}catch(Px){return Promise.reject(Px)}return e.apply(this,i)}}))}function LB(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return RL((function(e,n){return function(){for(var r=arguments.length,i=new Array(r),o=0;o<r;o++)i[o]=arguments[o];try{UB.call(this,t,i,n,this._name)}catch(Px){throw Px}return e.apply(this,i)}}))}function UB(e,t,n,r){if(zw(e))for(var i=0;i<e.length;i++)VB.call(this,{rule:e[i],value:t[i],key:e[i].name,fnName:n,className:r});else VB.call(this,{rule:e,value:t[0],key:e.name,fnName:n,className:r})}function VB(e){var t=this,n=e.rule,r=e.value,i=e.key,o=e.fnName,a=e.className;function s(e){return{code:jF.INVALID_PARAMETER,extraCode:e,fnName:o,messageParams:{key:i,rule:n,value:r}}}if(jw(r)){if(n.required)throw new zF(s(5001));if(jw(n.defaultValue))return void(Bw(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),Bw(n.type[u])&&r instanceof n.type[u]&&(c=!0),Hw(n.type[u])&&Fw(r)===n.type[u].toLowerCase()&&(c=!0);if(!c)throw new zF({code:jF.INVALID_PARAMETER,extraCode:5002,fnName:o,messageParams:{key:i,rule:{type:n.type.map((function(e){return Xw(e)?Qw(e):Hw(e)?e:Fw(e)}))},value:r}})}else if(!jw(n.type)&&Fw(r)!==n.type)throw new zF(s(5002));if(!1===n.allowEmpty){var l=Gw(r)&&(0===r||Number.isNaN(r)),d=Hw(r)&&""===r.trim();if(l||d)throw new zF(s(5003))}if(n.notLessThanZero&&Gw(r)&&r<0)throw new zF(s(5006));if(!jw(n.min)&&Gw(r)&&r<n.min)throw new zF(s(5007));if(!jw(n.max)&&Gw(r)&&r>n.max)throw new zF(s(5008));if(Hw(n.instanceOf)){if(!r||r._name!==n.instanceOf)throw new zF(s(5004))}else if(Bw(n.instanceOf)&&!(r instanceof n.instanceOf))throw new zF(s(5004));if(Array.isArray(n.values)&&!n.values.includes(r))throw new zF(s(5005));var h=n.properties;Lw(h)&&Jw(r)&&Object.keys(h).forEach((function(e){VB.call(t,{rule:h[e],value:r&&r[e],key:"".concat(e),fnName:o,className:a})}));var f=n.arrayItem;Lw(f)&&zw(r)&&r.forEach((function(e,n){VB.call(t,{rule:f,value:e,key:"".concat(i,"[").concat(n,"]"),fnName:o,className:a})})),Bw(n.validate)&&n.validate.call(this,r,i,o,a,this)}function FB(){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 RL((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(Fw(t)):(JSON.stringify(t),t)}catch(Fx){return"type:".concat(Fw(t))}}var h=this._log||bx;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):UO[t];try{var p=e.apply(this,u),m=eD();return Yw(p)?p.then((function(e){return h.info("".concat(t,"() success ").concat(n.call.apply(n,[s].concat(u)))),GO.addSuccessEvent({key:f,cost:eD()-m}),e})).catch((function(e){var r,i=(e=zF.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))),GO.addFailedEvent({key:f,error:e}),e})):(GO.addSuccessEvent({key:f}),p)}catch(w){var v=(w=zF.convertFrom.call(this,w,t)).extraCode||w.code,_=null!=(a=w.message)&&a.includes(v)?"":" code:".concat(v);throw h.error("".concat(t,"() failed ").concat(w).concat(_," params: ").concat(JSON.stringify(u,d))),GO.addFailedEvent({key:f,error:w}),w}}}))}var BB=function(e){return RL((function(t,n){return function(r,i){return kR(this,null,f().mark((function o(){var a;return f().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 zF({code:jF.OPERATION_ABORT,message:"plugin ".concat(String(r)," is not found"),fnName:n});case 3:if(!Bw(a.constructor.isSupported)||a.constructor.isSupported()){o.next=5;break}throw this._log.error("plugin ".concat(String(r)," is not supported")),new zF({code:jF.ENV_NOT_SUPPORTED,message:"plugin ".concat(String(r)," is not supported"),extraCode:5210,fnName:n});case 5:return o.abrupt("return",(UB.call(this,a.getValidateRule(e),[i],n,"TRTC"),t.call(this,a,i)));case 6:case"end":return o.stop()}}),o,this)})))}}))},jB=0,HB=function(){function e(t,n){r(this,e),ER(this,"player"),ER(this,"publisher"),ER(this,"mixInput"),this.mixInput=new WM(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()}return a(e,[{key:"updateSettings",value:function(e){this.player&&(jw(e.volume)||(this.volume=e.volume),jw(e.loop)||(this.loop=e.loop),jw(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 GB(e,t){if(t&&"function"!=typeof t)throw new zF({code:jF.INVALID_PARAMETER,message:"start audioMixer plugin: param ".concat(e," should be a function.")})}var WB=function(){function e(t){r(this,e),this.core=t,ER(this,"log"),ER(this,"mixedMusicMap",new Map),ER(this,"cacheMusicMap",new Map),jB+=1,this.log=t.log.createChild({id:"".concat(this.getAlias()).concat(jB)}),this.log.info("[audioMixer] created id=".concat(this.getAlias()).concat(jB)),this.core=t}return a(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 kR(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 HB(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.")),GO.addEnum({key:502700,value:3}),this.kvUpload(e);case 15:case"end":return t.stop()}}),t,this)})))}},{key:"update",value:function(e){return kR(this,null,f().mark((function t(){var n,r,i,o;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))),(o=this.mixedMusicMap.get(n))?(o.updateSettings(e),o.updateListener(e),jw(r)||o.setOperation(r),jw(i)||o.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 kR(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,o=e.operation,a=e.seekFrom,s=e.onTimeUpdate,c=e.onDurationChange,u=e.onEnded;t&&GO.addCount({key:502711}),n&&GO.addCount({key:502703}),r&&GO.addCount({key:502704}),i&&GO.addCount({key:502705}),o&&GO.addCount({key:502706}),a&&GO.addCount({key:502707}),"function"!=typeof s&&GO.addCount({key:502709}),"function"!=typeof u&&GO.addCount({key:502710}),"function"!=typeof c&&GO.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()}}])}();ER(WB,"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=["mp3","ogg","wav","flac"],o=r.split(".").pop(),a=i.indexOf(o)>=0,s=r.startsWith("blob"),c=r.startsWith("data");if(!(a||s||c))throw new zF({code:jF.INVALID_PARAMETER,message:"start audioMixer plugin: music url is invalid, please check your file format.",fnName:n})}if(!e.url&&!e.track)throw new zF({code:jF.INVALID_PARAMETER,message:"start audioMixer plugin: param url or track is required.",fnName:n});GB("onTimeUpdate",e.onTimeUpdate),GB("onEnded",e.onEnded),GB("onDurationChange",e.onDurationChange)}}),ER(WB,"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){GB("onTimeUpdate",e.onTimeUpdate),GB("onEnded",e.onEnded),GB("onDurationChange",e.onDurationChange)}}),ER(WB,"stopValidateRule",{name:"options",type:"object",required:!0,properties:{id:{type:"string",required:!0}}}),ER(WB,"Name","AudioMixer");var JB,zB=WB,KB=0,qB=function(){function e(t){r(this,e),this.core=t,ER(this,"log"),ER(this,"audioContext",BM()),ER(this,"workletNode"),KB+=1,this.log=t.log.createChild({id:"".concat(this.getAlias()).concat(KB)}),this.log.info("[audioDenoiser] created id=".concat(this.getAlias()).concat(KB)),t.assetsPath&&this.preload("".concat(t.assetsPath,"/denoiser-wasm.js")).catch((function(e){}))}return a(e,[{key:"preload",value:function(e){return JB||(JB=this.doPreload(e)),JB}},{key:"doPreload",value:function(e){return kR(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,OM(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 kR(this,null,f().mark((function t(){var n,r,i,o,a,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 o=String(Date.now()).slice(0,-3),t.next=7,function(e,t){return kR(this,arguments,(function(e,t){var n=t.sdkAppId,r=t.userId,i=t.userSig,o=t.timestamp;return f().mark((function t(){var a,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: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.",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,mR(pR({},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 zF({code:jF.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(BR(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 kR(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 kR(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 zF({code:jF.INVALID_OPERATION,extraCode:5106,fnName:r})}}}}])}();ER(qB,"updateValidateRule",{type:"object"}),ER(qB,"stopValidateRule",{type:"object"}),ER(qB,"Name","AIDenoiser");var YB=qB,XB=function(e){function i(){var e;return r(this,i),e=n(this,i),ER(t(e),"observer"),ER(t(e),"state","nominal"),e.onPressureChange=e.onPressureChange.bind(t(e)),e}return d(i,e),a(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 kR(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&&!GD,!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),oM.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)&&bx.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(KC){oM.uploadEvent({log:"stat-pressure-detector-destroy-failed",error:KC})}}}])}(gR(SR(),1).EventEmitter),QB=new XB;function $B(e){var t=v(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,E(new Uint8Array(u.buffer))),s.push(128),new jL(new DataView(new Uint8Array(s).buffer),!0)}function ZB(e){return"empty"===e.type||0===e.data.byteLength}function ej(e){return 1===e.getInt32(0)&&6===e.getInt8(4)}function tj(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 nj(e){var t=e.frame,n=e.seiMessageList;if(!n||0===n.length||0===t.data.byteLength)return t;var r=9-tj(t.data);if(r<=0)return t;for(var i=n.splice(0,r).reverse().map($B),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 rj(e){var t=e.frame,n=e.onSEI;try{var r=new DataView(t.data);if(ZB(t)||!ej(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 jL(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(zR){}return t}var ij=0,oj=function(){function e(t){r(this,e),this.core=t,ER(this,"log"),ER(this,"_seiMessageList",[]),ER(this,"_smallSeiMessageList",[]),ER(this,"_subStreamSeiMessageList",[]),ij++,this.log=t.log.createChild({id:"".concat(this.getAlias()).concat(ij)}),this.log.info("[sei] created id=".concat(this.getAlias()).concat(ij)),this.core=t,this.encode=this.encode.bind(this),this.decode=this.decode.bind(this)}return a(e,[{key:"encode",value:function(e){var t=e.frame,n=e.mediaType;try{return nj({frame:t,seiMessageList:8===n?this._smallSeiMessageList:2===n?this._subStreamSeiMessageList:this._seiMessageList})}catch(KC){this.log.warn(KC)}return t}},{key:"decode",value:function(e){var t=this,n=e.frame,r=e.track;return rj({frame:n,onSEI:function(e){e.forEach((function(e){t.core.trtc.emit(fB.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:bP?this.encode:nj,type:2}),this.core.room.videoManager.addDecodeProcessor({processor:bP?this.decode:rj,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"}}])}();ER(oj,"autoStart",!0),ER(oj,"Name","SEI");var aj=oj;function sj(e){var t=e.frame,n=e.onDump;return null==n||n(),t}function cj(e){var t=e.frame,n=e.onDump;return null==n||n(),t}var uj,lj=0,dj=function(){function e(t){r(this,e),this.core=t,ER(this,"_core"),ER(this,"log"),ER(this,"dumpLocalVideoMap",{}),ER(this,"dumpRemoteVideoMap",{}),ER(this,"dialog"),this._core=t,this.log=t.log.createChild({id:"".concat(this.getAlias()).concat(++lj)}),this.log.info("created")}return a(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 kR(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 kR(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,!uj){e.next=6;break}return e.next=4,uj;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(WR,"/assets/debug-dialog.js"),uj=this.loadScript(r),e.next=10,uj;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):sj,type:1}),this._core.room.videoManager.addDecodeProcessor({processor:this._core.rtcDectection.IS_INSERTABLE_STREAM_SUPPORTED?this.decodeVideo.bind(this):cj,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 sj({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 cj({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)}))}}])}();ER(dj,"Name","Debug"),ER(dj,"autoStart",!0),yR([sM({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)}})],dj.prototype,"loadScript",1);var hj=dj,fj=function(e){switch(e){case"webCodecs":return 504703;case"wasm":return 504704}throw new Error("decoder type not supported")},pj=function(){function e(t,n,i){var o=this;r(this,e),ER(this,"trackDoneOB"),ER(this,"startOB"),ER(this,"stopOB"),ER(this,"inputFrameCount",0),ER(this,"decodedFrameCount",0),ER(this,"type","auto"),ER(this,"config"),ER(this,"decoder"),ER(this,"_decodeSink");var a=t.kvStatManager;t.trtc,this.config=i.config,this.trackDoneOB=jU(n,KP.INIT),this.stopOB=NU(this.trackDoneOB),this.startOB=NU(),"auto"===i.type?this.type="webCodecs":this.type=i.type;var s=NU();lU(this.startOB,AU(0),BV((function(e){var t=o.pipe(n);return s.next("STARTING"),n.log.info("decoder type: ".concat(o.type)),lU(t,uV(o.stopOB),cF((function(){}),(function(t){n.log.error(t),a.addFailedEvent({key:fj(o.type),error:t}),e>4?o.startOB.error(t):o.startOB.next(e+1)}))),lU(t,cV(1),oF(ZU))})),uV(this.stopOB),cF((function(){n.player.setOutput(),s.next("STARTED")}),(function(e){s.next("FAILED")}),(function(){a.addSuccessEvent({key:fj(o.type)}),a.addSuccessEvent({key:504702})})))}return a(e,[{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 gU()((function(n){return kR(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(Px){e.log.error(Px),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"}))}}])}(),mj={type:"object"},vj=function(){function e(t){r(this,e),this.core=t,ER(this,"log"),ER(this,"contextMap",new Map),ER(this,"decodeProcessorMap",new WeakMap),this.log=t.log.createChild({id:"".concat(this.getAlias())})}return a(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 mj}},{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 pj(t.core,i,e);return lU(o.trackDoneOB,cV(1),cF((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 pj(this.core,e.track,e))}}}])}();ER(vj,"Name","TRTCAudioDecoder");var _j=vj,gj=0,yj=new Set,Ej=null;JR("5.10.1-beta.7"),Rx.checkStorage(),MP();var Tj={RtcError:zF,ErrorCode:jF,ErrorCodeDictionary:HF},kj=function(e){function i(e,o){var a;return r(this,i),a=n(this,i),ER(t(a),"_room"),ER(t(a),"_eventListened",new Set),ER(t(a),"_localVideoTrack",null),ER(t(a),"_localAudioTrack",null),ER(t(a),"_localScreenTrack",null),ER(t(a),"_localScreenAudioTrack",null),ER(t(a),"_localVideoConfig",null),ER(t(a),"_localScreenConfig",null),ER(t(a),"_localAudioConfig",null),ER(t(a),"_remoteVideoConfigMap",new Map),ER(t(a),"_remoteAudioConfigMap",new Map),ER(t(a),"_remoteAudioVolumeMap",new Map),ER(t(a),"_remoteAudioMuteMap",new Map),ER(t(a),"_mediaTrackMap",new WeakMap),ER(t(a),"_log",bx.createLogger({id:"t".concat(++gj)})),ER(t(a),"_plugins",new Map),ER(t(a),"_networkQuality",null),ER(t(a),"_speakerId"),ER(t(a),"_getPCMAbortCtrl"),a._room=new e(pR({logger:a._log,frameWorkType:i.frameWorkType},o)),a._room.videoDecodeFallbackType=o.videoDecodeFallback,a._log.info("create() ".concat(JSON.stringify(o,(function(e,t){return"plugins"===e?t.map((function(e){return e.Name})):t})))),Object.defineProperties(t(a),{dumpAudio:{enumerable:!1,value:function(e){return this._room.audioManager.dump(e)}}}),o.plugins&&o.plugins.forEach((function(e){a._use(e,o.assetsPath)})),a._use(zB,o.assetsPath),a._use(YB,o.assetsPath),a._use(_j,o.assetsPath||iC),a._use(hj),o.enableSEI&&RP&&a._use(aj),a._room.on("audio-volume",(function(e){!e.find((function(e){return""===e.userId}))&&a._localAudioTrack&&e.push({userId:"",volume:Math.floor(100*a._localAudioTrack.getAudioLevel())}),1===o.volumeType&&e.forEach((function(e){var t,n=""===e.userId?a._localAudioTrack:null==(t=a.room.remotePublishedUserMap.get(e.userId))?void 0:t.remoteAudioTrack;n&&(e.volume=n.dbVolume)})),a.emit(fB.AUDIO_VOLUME,{result:e.sort((function(e,t){return t.volume-e.volume}))})})),a._room.videoManager.on("error",(function(e){a._log.error(new zF({code:jF.OPERATION_FAILED,extraCode:5504,message:e.message,originError:e}))})),a._listenEvents(),a._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(Px){var a=OO({key:wO.CATCH_HANDLER_ERROR,data:{name:t,event:i[0]},addDocLink:!1});return bx.warn("".concat(a,"\n\n").concat(Px.stack)),!1}}}(t(a),"trtc"),a}return d(i,e),a(i,[{key:"room",get:function(){return this._room}},{key:"_listenEvents",value:function(){var e=this;rM(this,this._room).add("peer-join",(function(t){var n=t.userId;e.emit(fB.REMOTE_USER_ENTER,{userId:n})})).add("peer-leave",(function(t){e.emit(fB.REMOTE_USER_EXIT,{userId:t}),e._remoteAudioVolumeMap.delete(t)})).add("banned",(function(t){e._exitRoom().finally((function(){e.emit(fB.KICKED_OUT,{reason:t.reason})}))})).add("error",(function(t){e._exitRoom().finally((function(){e.emit(fB.ERROR,zF.convertFrom(t))}))})).add("signal-connection-state-changed",(function(t){e.emit(fB.CONNECTION_STATE_CHANGED,t)})).add("network-quality",(function(t){e._networkQuality=t;var n=mR(pR({},t),{uplinkRTT:Math.min(t.uplinkRTT,Ew),downlinkRTT:Math.min(t.downlinkRTT,Ew)});e.emit(fB.NETWORK_QUALITY,n)})).add("remote-published",(function(t){[t.remoteAudioTrack,t.remoteVideoTrack,t.remoteAuxiliaryTrack].forEach((function(n){rM(n,n).add("player-state-changed",(function(r){var i=mR(pR({},r),{userId:t.userId});n.kind===yC.VIDEO&&(i.streamType=mB(n.streamType)),e.emit(n.kind===yC.AUDIO?fB.AUDIO_PLAY_STATE_CHANGED:fB.VIDEO_PLAY_STATE_CHANGED,i)})).add("error",(function(t){t.getCode()===PR.PLAY_NOT_ALLOWED&&e.emit(fB.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){iM(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?fB.REMOTE_VIDEO_AVAILABLE:fB.REMOTE_VIDEO_UNAVAILABLE,{userId:i,streamType:"main"})),o!==s&&(s?e._onAudioAvailable({userId:i}):e._onAudioUnavailable({userId:i,muteState:r}),e.emit(s?fB.REMOTE_AUDIO_AVAILABLE:fB.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?fB.REMOTE_VIDEO_AVAILABLE:fB.REMOTE_VIDEO_UNAVAILABLE,{userId:i,streamType:"sub"}))})).add("sei-message",(function(t){e.emit(fB.SEI_MESSAGE,mR(pR({},t),{streamType:mB(t.streamType)}))})).add("firewall-restriction",(function(){e.emit(fB.ERROR,new zF({code:jF.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,Ew),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)/yO},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)/yO},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(fB.STATISTICS,l)})).add("custom-message",(function(t){e.emit(fB.CUSTOM_MESSAGE,t)})).add("layerData",(function(t){return e.emit(fB.LAYER_DATA,t)})).add("first-video-frame",(function(t){e.emit(fB.FIRST_VIDEO_FRAME,mR(pR({},t),{streamType:mB(t.streamType)}))})),rM(this,nL).add("audioInputAdded",(function(t){e.emit(fB.DEVICE_CHANGED,{type:"microphone",action:"add",device:t})})).add("audioInputRemoved",(function(t){e.emit(fB.DEVICE_CHANGED,{type:"microphone",action:"remove",device:t})})).add("videoInputAdded",(function(t){e.emit(fB.DEVICE_CHANGED,{type:"camera",action:"add",device:t})})).add("videoInputRemoved",(function(t){e.emit(fB.DEVICE_CHANGED,{type:"camera",action:"remove",device:t})})).add("audioOutputAdded",(function(t){return kR(e,null,f().mark((function e(){var n;return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.emit(fB.DEVICE_CHANGED,{type:"speaker",action:"add",device:t}),!Ej||Ej.deviceId!==fw){e.next=5;break}return e.next=3,cL();case 3:n=e.sent.find((function(e){return e.deviceId===fw})),n&&Ej.groupId!==n.groupId&&(Ej=n,this.emit(fB.DEVICE_CHANGED,{type:"speaker",action:"active",device:n}));case 5:case"end":return e.stop()}}),e,this)})))})).add("audioOutputRemoved",(function(t){return kR(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(fB.DEVICE_CHANGED,{type:"speaker",action:"remove",device:t}),e.next=3,cL();case 3:if((n=e.sent[0])&&Ej&&Ej.groupId!==n.groupId){e.next=6;break}return e.abrupt("return");case 6:r=Ej.deviceId===t.deviceId,i=Ej.deviceId===fw&&Ej.deviceId===n.deviceId,(r||i)&&(Ej=n,this.emit(fB.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||iC)}},{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(OB.call(this,{TRTC:i,room:this._room,errorModule:Tj,assetsPath:t}));this._plugins.set(e.Name,n),e.autoStart&&this.startPlugin(e.Name)}}},{key:"enterRoom",value:function(e){return kR(this,null,f().mark((function t(){var n,r,o,a,s,c,u,l,d,h,p;return f().wrap((function(t){for(;;)switch(t.prev=t.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),!Hw(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,Ww(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,a,i.frameWorkType);case 6:this._checkTrackToPublish(),QB.start();case 8:case"end":return t.stop()}}),t,this)})))}},{key:"exitRoom",value:function(){return kR(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 kR(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(){iM(this),this.removeAllListeners(),this._room.destroy(),yj.delete(this),0===yj.size&&QB.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(),Tx.off("102",this._onLocalTrackCaptured,this)}},{key:"startLocalAudio",value:function(){return kR(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,o,a,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,o=void 0===r||r,a=t.mute,s=t.option,c=new BL(e._room.audioManager),u={},l={muted:!0},s&&(jw(s.microphoneId)?jw(s.audioTrack)||(u.customSource=s.audioTrack):u.deviceId=s.microphoneId,s&&Gw(s.captureVolume)&&c.setCaptureVolume(s.captureVolume),jw(s.profile)||(Hw(s.profile)?vC[s.profile]&&c.setProfile(vC[s.profile]):c.setProfile(s.profile)),Gw(s.earMonitorVolume)&&(l.muted=!(s.earMonitorVolume>0),l.volume=s.earMonitorVolume),jw(s.echoCancellation)||(c.profile.echoCancellation=s.echoCancellation),jw(s.noiseSuppression)||(c.profile.noiseSuppression=s.noiseSuppression),jw(s.autoGainControl)||(c.profile.autoGainControl=s.autoGainControl)),c.on("5",(function(t){e.emit(fB.ERROR,new zF({code:jF.DEVICE_ERROR,extraCode:5309,messageParams:{error:t}}))})),c.on("2",(function(t){e.emit(fB.DEVICE_CHANGED,{type:"microphone",action:"active",device:t})})),c.on("4",(function(t){var n;t.error&&(n=zF.convertFrom(t.error)),e.emit(fB.PUBLISH_STATE_CHANGED,mR(pR({},t),{error:n}))})),e._listenOutputTrackChanged(c),e._speakerId&&c.setAudioOutput(e._speakerId),n.next=11,c.capture(u);case 11:return jw(a)||c.setMute(a),rM(c,c).add("player-state-changed",(function(t){e.emit(fB.AUDIO_PLAY_STATE_CHANGED,mR(pR({},t),{userId:""}))})),e.listeners(fB.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})})))})),o&&e._room.isJoined&&e._room.publish(c).catch((function(){})),e._localAudioTrack=c,e._localAudioConfig=mR(pR({},t),{publish:o}),n.next=20,e._updateAudioPlayOption({playOption:l,track:c});case 20:case"end":return n.stop()}}),n)}))()}))}},{key:"updateLocalAudio",value:function(e){return kR(this,null,f().mark((function t(){var n,r,i,o;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,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=jw(i.audioTrack),t.t1){t.next=14;break}return t.next=14,this._localAudioTrack.setInputMediaStreamTrack(i.audioTrack);case 14:return jw(i.captureVolume)||this._localAudioTrack.setCaptureVolume(i.captureVolume),jw(i.earMonitorVolume)||(o.muted=!(i.earMonitorVolume>0),o.volume=i.earMonitorVolume),t.next=18,this._localAudioTrack.update3A(i);case 18:return this._room.isJoined&&!jw(n)&&(n&&!this._localAudioConfig.publish&&this._room.publish(this._localAudioTrack).catch((function(){})),this._localAudioConfig.publish&&!n&&this._room.unpublish(this._localAudioTrack).catch((function(){}))),jw(r)||this._localAudioTrack.setMute(r),t.next=22,this._updateAudioPlayOption({playOption:o,track:this._localAudioTrack,prevConfig:this._localAudioConfig});case 22:cD(this._localAudioConfig,e);case 23:case"end":return t.stop()}}),t,this)})))}},{key:"stopLocalAudio",value:function(){return kR(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),iM(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 kR(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,o,a,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,o=void 0===i||i,a=t.mute,s=t.option,c=new WL(e._room.videoManager),u={},l={},Ww(null==s?void 0:s.avoidCropping)&&(c.avoidCropping=s.avoidCropping),s&&(s.cameraId?u.deviceId=s.cameraId:jw(s.useFrontCamera)?jw(s.videoTrack)||(u.customSource=s.videoTrack):u.facingMode=s.useFrontCamera?yC.FACING_MODE_USER:yC.FACING_MODE_ENVIRONMENT,s.qosPreference&&(u.contentHint=vB(s.qosPreference)),jw(s.profile)||(Hw(s.profile)?_C[s.profile]&&c.setProfile(_C[s.profile]):c.setProfile(s.profile)),jw(s.fillMode)||(l.objectFit=s.fillMode),jw(s.mirror)||(l.mirror=s.mirror),jw(s.small)||(dP()?Hw(s.small)?c.small=_C[s.small]:!0===s.small?c.small=_C["120p"]:c.small=s.small:e._log.warn("small stream is not supported"))),c.once("first-video-frame",(function(t){e.emit(fB.FIRST_VIDEO_FRAME,mR(pR({},t),{streamType:mB(t.streamType)}))})),c.on("5",(function(t){e.emit(fB.ERROR,new zF({code:jF.DEVICE_ERROR,extraCode:5308,messageParams:{error:t}}))})),c.on("2",(function(t){e.emit(fB.DEVICE_CHANGED,{type:"camera",action:"active",device:t})})),c.on("4",(function(t){var n;t.error&&(n=zF.convertFrom(t.error)),e.emit(fB.PUBLISH_STATE_CHANGED,mR(pR({},t),{error:n}))})),e._listenOutputTrackChanged(c),n.next=12,c.capture(u);case 12:if(n.t0=jw(a),n.t0){n.next=16;break}return n.next=16,c.setMute(a);case 16:return rM(c,c).add("player-state-changed",(function(t){e.emit(fB.VIDEO_PLAY_STATE_CHANGED,mR(pR({},t),{userId:"",streamType:"main"}))})),o&&e._room.isJoined&&e._room.publish(c).catch((function(){})),e._localVideoTrack=c,e._localVideoConfig=mR(pR({},t),{view:r,publish:o}),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 kR(this,null,f().mark((function t(){var n,r,i,o,a,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,o=e.option,a={},!o){t.next=28;break}if(jw(o.profile)||(Hw(o.profile)?_C[o.profile]&&this._localVideoTrack.setProfile(_C[o.profile]):this._localVideoTrack.setProfile(o.profile),(!o.cameraId||!this._localVideoTrack.isNeedToSwitchDevice(o.cameraId))&&jw(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(!jw(o.useFrontCamera)){t.next=17;break}if(t.t0=jw(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?yC.FACING_MODE_USER:yC.FACING_MODE_ENVIRONMENT);case 19:if(jw(o.fillMode)||(a.objectFit=o.fillMode),jw(o.mirror)||(a.mirror=o.mirror),o.qosPreference&&this._localVideoTrack.mediaTrack&&this._localVideoTrack.setContentHint(vB(o.qosPreference)),!o.small){t.next=27;break}s=!this._localVideoTrack.small,dP()?(!0===o.small?this._localVideoTrack.small=_C["120p"]:Hw(o.small)?this._localVideoTrack.small=_C[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&&!jw(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=jw(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:cD(this._localVideoConfig,e);case 36:case"end":return t.stop()}}),t,this)})))}},{key:"stopLocalVideo",value:function(){return kR(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(),iM(this._localVideoTrack),this._localVideoTrack=null,this._localVideoConfig=null;case 11:case"end":return e.stop()}}),e,this)})))}},{key:"startScreenShare",value:function(){return kR(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,o,a,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,o=t.publish,a=void 0===o||o,s=t.option,(c=new KL(e._room.videoManager)).on("4",(function(t){var n;t.error&&(n=zF.convertFrom(t.error)),e.emit(fB.PUBLISH_STATE_CHANGED,mR(pR({},t),{error:n}))})),c.once("first-video-frame",(function(t){e.emit(fB.FIRST_VIDEO_FRAME,mR(pR({},t),{streamType:mB(t.streamType)}))})),e._listenOutputTrackChanged(c),"main"===t.streamType&&(c.mediaType=4),u=null,l={},d={},s&&(jw(s.profile)||(Hw(s.profile)?gC[s.profile]&&c.setProfile(gC[s.profile]):c.setProfile(s.profile)),s.systemAudio&&(l.systemAudio=!0,l.echoCancellation=s.echoCancellation,l.noiseSuppression=s.noiseSuppression,l.autoGainControl=s.autoGainControl),jw(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=vB(s.qosPreference))),n.next=8,c.capture(l);case 8:if(h=n.sent,c.mediaTrack.addEventListener(yC.ENDED,(function(){e._stopScreenShare(),e.emit(fB.SCREEN_SHARE_STOPPED)})),n.t0=h.getAudioTracks()[0],!n.t0){n.next=16;break}return u=new YL(e._room.audioManager),n.next=15,u.setInputMediaStreamTrack(h.getAudioTracks()[0]);case 15:e._speakerId&&u.setAudioOutput(e._speakerId);case 16:if(rM(c,c).add("player-state-changed",(function(t){e.emit(fB.VIDEO_PLAY_STATE_CHANGED,mR(pR({},t),{userId:"",streamType:"sub"}))})),!a||!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=mR(pR({},t),{view:i,publish:a}),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 kR(this,null,f().mark((function t(){var n,r,i,o,a;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,o={},i&&(jw(i.fillMode)||(o.objectFit=i.fillMode),i.qosPreference)&&(a=vB(i.qosPreference),this._localScreenTrack.setContentHint(a)),this._room.isJoined&&!jw(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:cD(this._localScreenConfig,e);case 8:case"end":return t.stop()}}),t,this)})))}},{key:"stopScreenShare",value:function(){return kR(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 kR(this,null,f().mark((function t(){var n,r,i,o,a,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,o=e.option,a="".concat(r,"_").concat(i),!this._remoteVideoConfigMap.has(a)){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),o&&(jw(o.fillMode)||(c.objectFit=o.fillMode),jw(o.mirror)||(c.mirror=o.mirror),jw(o.poster)||(c.poster=o.poster),c.canvasRender=o.canvasRender,"main"===i&&!jw(o.small)&&(!s.remoteVideoTrack.isSubscribing&&!s.remoteVideoTrack.isSubscribed&&s.remoteVideoTrack.setMediaType(o.small?8:4),this._room.changeType(o.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(a,{config:e}),o&&!jw(o.receiveWhenViewVisible)&&this._observeView({remoteTrack:u,view:n,receiveWhenViewVisible:o.receiveWhenViewVisible,viewRoot:null==o?void 0:o.viewRoot});case 18:case"end":return t.stop()}}),t,this)})))}},{key:"updateRemoteVideo",value:function(e){return kR(this,null,f().mark((function t(){var n,r,i,o,a,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,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&&(jw(s.fillMode)||(l.objectFit=s.fillMode),jw(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 p=u.config,"main"===a&&s&&!jw(s.small)&&this._room.changeType(s.small,d.user),t.next=12,this._updateVideoPlayOption({view:i,playOption:l,track:d,prevConfig:p});case 12:cD(p,e),m=jw(null==s?void 0:s.receiveWhenViewVisible)?null==(n=p.option)?void 0:n.receiveWhenViewVisible:s.receiveWhenViewVisible,v=jw(i)?p.view:i,_=jw(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 kR(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 kR(this,null,f().mark((function n(){var r,i,o,a,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))&&(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 kR(this,null,f().mark((function n(){var r,i,o,a;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((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=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(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 kR(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 kR(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 kR(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{pB.has(e)&&this._log.debug("emit ".concat(e," ").concat(JSON.stringify(n)))}catch(Px){}return g(i,"emit",this,3)([e].concat(n))}},{key:"off",value:function(e,t,n){var r,o;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==(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(Hw(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 kR(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,cL();case 2:t.sent.forEach((function(t){t.deviceId===e&&(n._setCurrentSpeaker(e),n.emit(fB.DEVICE_CHANGED,{type:"speaker",action:"active",device:t}),Ej=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 kR(this,null,f().mark((function t(){var n,r,i,o,a,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={},o=r.remoteAudioTrack,this._listenOutputTrackChanged(o),this._speakerId&&o.setAudioOutput(this._speakerId),t.prev=8,a=this._remoteAudioVolumeMap.get(n),s=Gw(a)?a:100,i.volume=s,this._remoteAudioConfigMap.set(n,e),t.next=14,this._room.subscribe(o);case 14:return lU(jU(o,"decode-failed"),uV(jU(o,KP.INIT)),cF((function(){c.startPlugin(_j.Name,{track:o,type:"auto",config:{codec:"opus",sampleRate:48e3,numberOfChannels:1}})}))),t.next=17,this._updateAudioPlayOption({playOption:i,track:o});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(o);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 kR(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),lU(jU(e,"decode-failed"),uV(jU(e,KP.INIT)),uF((function(){r.startPlugin("TRTCVideoDecoder",{type:"auto",renderer:"videoFrame",track:e,config:{codec:"avc1.420028"},fallback:i})})),HV(jU(e,"decode-downgrade-state-changed")),cF((function(i){n=i.state,r.emit(fB.VIDEO_DECODE_DOWNGRADE_STATE_CHANGED,mR(pR({},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 kR(this,arguments,(function(e){var t=e.view,n=e.playOption,r=e.track,i=e.prevConfig;return f().mark((function e(){var o,a;return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r.setMirror(n.mirror),!(jw(t)&&i&&i.view)||iD(n)){e.next=6;break}if(o=lD(i.view),e.t0=o.length>0,!e.t0){e.next=6;break}return e.next=6,r.play(o,n);case 6:if(jw(t)){e.next=14;break}if(!((a=lD(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 kR(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:jw(n.muted)||r.setPlayerMute(n.muted),jw(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(fB.TRACK,{userId:n,streamType:mB(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(!jw(r)){var s=this._remoteVideoConfigMap.get("".concat(n.userId,"_").concat(mB(n.streamType)));if(s){var c=s.observer||void 0;if(null===r||zw(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=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:a}));var d=new Set(lD(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 kR(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=PB.get(e);t&&(t.forEach((function(e){return clearTimeout(e)})),PB.delete(e))}(this),this._room.remotePublishedUserMap.forEach((function(e){iM(e.remoteAudioTrack),iM(e.remoteVideoTrack),iM(e.remoteAuxiliaryTrack)}));case 12:case"end":return e.stop()}}),e,this)})))}},{key:"_stopScreenShare",value:function(){return kR(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),iM(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&&(!Ej||rL(Ej))&&(this._initActiveSpeaker(),Tx.off("102",this._onLocalTrackCaptured,this))}},{key:"_initActiveSpeaker",value:function(){return kR(this,null,f().mark((function e(){var t;return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!Ej||rL(Ej)){e.next=4;break}this.emit(fB.DEVICE_CHANGED,{type:"speaker",action:"active",device:Ej}),e.next=8;break;case 4:return e.next=6,cL();case 6:(t=e.sent)[0]&&!rL(t[0])?(Ej=t[0],this.emit(fB.DEVICE_CHANGED,{type:"speaker",action:"active",device:t[0]})):Tx.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:mR(pR({seiPayloadType:243},t),{small:!(null==(n=this._localVideoTrack)||!n.small)})}),GO.addCount({key:5e5,useUV:!0}))}},{key:"sendCustomMessage",value:function(e){var t,n;null==(n=(t=this._room).sendCustomMessage)||n.call(t,e),GO.addCount({key:500001,useUV:!0})}}],[{key:"create",value:function(e){}},{key:"_create",value:function(e,t){var n;FF&&(FF=!1,5!==bx.getLogLevel()&&(console.info("******************************************************************************"),console.info("* TRTC Web SDK"),console.info("* API Document: ".concat(rC,"/en/index.html")),console.info("* Changelog: ".concat(rC,"/en/tutorial-01-info-changelog.html")),console.info("* Report issues: https://github.com/LiteAVSDK/TRTC_Web/issues"),console.info("******************************************************************************")),bx.info("TRTC Web SDK Version:",WR),ox||bx.debug("Build Time:","2025-04-23 17:40:08"),bx.info("UA:",navigator.userAgent),bx.info("URL: ".concat(location.href).concat("IFRAME"===(null==(n=self.frameElement)?void 0:n.tagName)?" in iframe":"")),hx().then((function(e){e&&bx.info(dx)})));var r=new i(e,t||{});return yj.add(r),r}},{key:"setLogLevel",value:function(e,t){bx.setLogLevel(e),jw(t)||(t?bx.enableUploadLog():bx.disableUploadLog())}},{key:"isSupported",value:function(){return tP()}},{key:"getCameraList",value:function(){return aL(!(arguments.length>0&&void 0!==arguments[0])||arguments[0])}},{key:"getMicrophoneList",value:function(){return oL(!(arguments.length>0&&void 0!==arguments[0])||arguments[0])}},{key:"getSpeakerList",value:function(){return cL(!(arguments.length>0&&void 0!==arguments[0])||arguments[0])}},{key:"setCurrentSpeaker",value:function(e){return kR(this,null,f().mark((function t(){var n,r,o=this;return f().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(GD&&(e===BF.SPEAKER||e===BF.HEADSET)){t.next=6;break}return t.next=3,cL();case 3:t.sent.forEach((function(t){t.deviceId===e&&(yj.forEach((function(n){n._setCurrentSpeaker(e),n.emit(fB.DEVICE_CHANGED,{type:"speaker",action:"active",device:t})})),Ej=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:yj.forEach((function(e){return kR(o,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,o=e.useUV,a=e.version;switch(a&&(HO.version=a),t){case"count":HO.addCount({key:n,useUV:o});break;case"enum":HO.addEnum({key:n,value:r,useUV:o});break;case"number":HO.addNumber({key:n,value:r,split:i})}}}])}(xR.EventEmitter);ER(kj,"_loggerManager",bx),ER(kj,"EVENT",fB),ER(kj,"ERROR_CODE",jF),ER(kj,"TYPE",BF),ER(kj,"frameWorkType",30),yR([FB({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"}}}})],kj.prototype,"use",1),yR([MB(tB.TRTC.enterRoom),lB("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})),RL((function(e){return function(t){return this._log.setUserId(t.userId),this._log.setSdkAppId(t.sdkAppId),e.call(this,t)}})),FB()],kj.prototype,"enterRoom",1),yR([FB()],kj.prototype,"exitRoom",1),yR([MB(tB.TRTC.switchRole),dB("room",{merge:function(e,t){return t}}),FB()],kj.prototype,"switchRole",1),yR([FB()],kj.prototype,"destroy",1),yR([MB(tB.TRTC.startLocalAudio),lB("audio",(function(e,t){var n,r,i=v(e,1)[0],o=v(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)})),FB()],kj.prototype,"startLocalAudio",1),yR([MB(tB.TRTC.updateLocalAudio),dB("audio",{debounce:{delay:200,getKey:function(){return"".concat(gj,"-localAudio")},isNeedToDebounce:function(e){var t;return!jw(null==(t=e.option)?void 0:t.captureVolume)}}}),FB()],kj.prototype,"updateLocalAudio",1),yR([hB("audio"),FB()],kj.prototype,"stopLocalAudio",1),yR([MB(tB.TRTC.startLocalVideo),lB("video",(function(e,t){var n,r,i=v(e,1)[0],o=v(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)})),FB()],kj.prototype,"startLocalVideo",1),yR([MB(tB.TRTC.updateLocalVideo),dB("video"),FB()],kj.prototype,"updateLocalVideo",1),yR([hB("video"),FB()],kj.prototype,"stopLocalVideo",1),yR([MB(tB.TRTC.startScreenShare),lB("screen",(function(){return!0})),FB()],kj.prototype,"startScreenShare",1),yR([MB(tB.TRTC.updateScreenShare),dB("screen"),FB()],kj.prototype,"updateScreenShare",1),yR([FB()],kj.prototype,"stopScreenShare",1),yR([MB(tB.TRTC.startRemoteVideo),lB((function(e){return"v".concat(e.userId).concat(e.streamType)}),(function(){return!0})),FB({getRemoteId:function(e){return"".concat(e.userId,"_").concat(e.streamType)}})],kj.prototype,"startRemoteVideo",1),yR([MB(tB.TRTC.updateRemoteVideo),dB((function(e){return"v".concat(e.userId).concat(e.streamType)})),FB({getRemoteId:function(e){return"".concat(e.userId,"_").concat(e.streamType)}})],kj.prototype,"updateRemoteVideo",1),yR([MB(tB.TRTC.stopRemoteVideo),RL((function(e){return function(t){return kR(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)})))}})),FB({getRemoteId:function(e){return"".concat(e.userId,"_").concat(e.streamType)}})],kj.prototype,"stopRemoteVideo",1),yR([hB((function(e){return"v".concat(e.userId).concat(e.streamType)}))],kj.prototype,"_stopRemoteVideo",1),yR([MB.apply(void 0,E(tB.TRTC.muteRemoteAudio)),FB({getRemoteId:function(e){return e}})],kj.prototype,"muteRemoteAudio",1),yR([LB.apply(void 0,E(tB.TRTC.setRemoteAudioVolume)),function(e,t){return RL((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=PB.get(this);s||(s=new Map,PB.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=PB.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=PB.get(r))||e.delete(c)}),e);s.set(c,d)}}}))}(200,(function(e){return e})),FB({getRemoteId:function(e){return e}})],kj.prototype,"setRemoteAudioVolume",1),yR([BB("start"),bL((function(e){var t;return null==(t=e.afterStart)?void 0:t.call(e)})),lB((function(e,t){return e.disableRandomCall?null:e.getAlias()+e.getGroup(t)})),FB({replaceArg:function(e){return{argIndex:0,value:e.getName()}},getKVReportKey:function(e){return VO[e.getName()]},ignoreLog:function(e){return"Debug"===e.getName()}})],kj.prototype,"startPlugin",1),yR([BB("update"),dB((function(e,t){return e.disableRandomCall?null:e.getAlias()+e.getGroup(t)})),FB({replaceArg:function(e){return{argIndex:0,value:e.getName()}},getKVReportKey:function(e){return FO[e.getName()]}})],kj.prototype,"updatePlugin",1),yR([BB("stop"),hB((function(e,t){if(e.disableRandomCall)return null;var n=e.getGroup(t),r=e.getAlias();return"*"===n?new RegExp("".concat(r,".*")):r+n})),FB({replaceArg:function(e){return{argIndex:0,value:e.getName()}},getKVReportKey:function(e){return BO[e.getName()]}})],kj.prototype,"stopPlugin",1),yR([LB.apply(void 0,E(tB.TRTC.enableAudioVolumeEvaluation))],kj.prototype,"enableAudioVolumeEvaluation",1),yR([FB()],kj.prototype,"getVideoSnapshot",1),yR([FB()],kj.prototype,"_setCurrentSpeaker",1),yR([lB((function(e){return"a".concat(e.userId)}),(function(){return!0}))],kj.prototype,"_startRemoteAudio",1),yR([RL((function(e){return function(t){return kR(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(mR(pR({},t),{userId:e.userId})).catch((function(){}))}))):e.call(this,t));case 1:case"end":return n.stop()}}),n,this)})))}})),hB((function(e){return"a".concat(e.userId)}))],kj.prototype,"_stopRemoteAudio",1),yR([hB("room")],kj.prototype,"_exitRoom",1),yR([hB("screen")],kj.prototype,"_stopScreenShare",1),yR([MB.apply(void 0,E(tB.TRTC.sendSEIMessage)),UF({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}})],kj.prototype,"sendSEIMessage",1),yR([MB(tB.TRTC.sendCustomMessage),UF({timesInSecond:30,maxSizeInSecond:8e3,getSize:function(e){return e.data.byteLength}})],kj.prototype,"sendCustomMessage",1),yR([MB(tB.TRTC.create)],kj,"_create",1);var Sj=kj,Ij=function(){function e(){r(this,e),ER(this,"_set",new Set),Tx.on(Sx.LEAVE_SUCCESS,this.delete,this)}return a(e,[{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 bj(){return kR(this,null,f().mark((function e(){var t,n,r,i,o,a,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,oL();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,aL();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=Cx.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:o},m={isWebCodecSupported:d.isWebCodecSupported,isMediaSessionSupported:d.isMediaSessionSupported,isWebTransportSupported:d.isWebTransportSupported},oM.uploadEvent({log:"trtcstats-".concat(JSON.stringify(p)),userId:this.userId}),this._log.info("TrtcStats-".concat(JSON.stringify(p))),oM.uploadEvent({log:"trtcadvancedstats-".concat(JSON.stringify(m)),userId:this.userId});case 20:case"end":return e.stop()}}),e,this,[[0,7],[9,16]])})))}var Aj=gR(SR()),Rj="1",Cj="2",wj="3",Dj="4",Nj="5",xj="6",Oj={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},Pj=[Oj.UPDATE_REMOTE_MUTE_STAT,Oj.UPLINK_NETWORK_STATS,Oj.USER_LIST_RES,Oj.MUTE_RESULT,Oj.SERVER_FIRST_PACKAGE_RECEIVED,Oj.RECEIVE_CUSTOM_MSG],Mj={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"},Lj="publish_change",Uj="join",Vj="leave",Fj="quality_report",Bj="mute_uplink",jj="publish",Hj="publish_state_change",Gj="unpublish",Wj="subscribe",Jj="unsubscribe",zj="subscribe_change",Kj="start_publishing",qj="stop_publishing",Yj="start_push_user_cdn",Xj="stop_push_user_cdn",Qj="start_mcu_mix",$j="stop_mcu_mix",Zj="start_publish_cdn_stream",eH="update_publish_cdn_stream",tH="stop_publish_cdn_stream",nH="get_user_list",rH="change_role",iH="update_constraint_config",oH="rebuild_pc",aH="join/v2",sH="publish/v2",cH="subscribe/v3",uH="ability_status_report",lH="reconnect",dH="channel_msg",hH=new Set,fH=function(e){function i(e){var o,a,s,c;r(this,i),o=n(this,i),ER(t(o),"room"),ER(t(o),"sdkAppId"),ER(t(o),"userId"),ER(t(o),"userSig"),ER(t(o),"url"),ER(t(o),"backupUrl"),ER(t(o),"race"),ER(t(o),"destroyed",!1),ER(t(o),"_socketInUse"),ER(t(o),"_socket"),ER(t(o),"_backupSocket"),ER(t(o),"_signalInfo",{tinyId:void 0,clientIp:"",signalIp:"",relayIp:"",relayInnerIp:"",relayPort:0,endReportExtend:void 0,bakRelayIps:[]}),ER(t(o),"_currentState","DISCONNECTED"),ER(t(o),"_isReconnecting",!1),ER(t(o),"_seq",0),ER(t(o),"_log"),ER(t(o),"_lastMessageTime",-1),ER(t(o),"_connectStartTime",-1),ER(t(o),"_stopConnectRetry"),ER(t(o),"bytesSent",0),ER(t(o),"bytesReceived",0),ER(t(o),"keepAlive",!1),ER(t(o),"signalDomainWhenUnifiedProxy"),ER(t(o),"stopKeepAliveTimeout"),ER(t(o),"rtt",0),o.room=e.room,o.sdkAppId=e.sdkAppId,o.userId=e.userId,o.userSig=e.userSig,o.race=!!jw(e.race)||e.race,o.signalDomainWhenUnifiedProxy=e.signalDomainWhenUnifiedProxy;var u=(null==(s=null==(a=o.room.scheduleResult)?void 0:a.config)?void 0:s.keepAliveClient)||0;return null!=(c=o.room.joinParams)&&c.keepAlive&&!u&&(u=1),u-hH.size>0&&o.room.enableSPC&&(o.keepAlive=!0,hH.add(o)),o.url=e.url,o.backupUrl=e.backupUrl,o._seq=0,o._log=bx.createLogger({id:"ws",userId:o.userId,sdkAppId:o.sdkAppId}),o.onmessage=o.onmessage.bind(o),o.onerror=o.onerror.bind(o),o.onclose=o.onclose.bind(o),o}return d(i,e),a(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 kR(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=eD(),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,Zw(r);case 7:e._socketInUse=n.sent,e.unbindAndCloseSocket(e._socketInUse===e._socket?yC.BACKUP:yC.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?yC.MAIN:yC.BACKUP),n(new LR({code:PR.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===yC.MAIN){if(this._socket){this.unbindSocket(this._socket);try{this._socket.close(1e3)}catch(KC){}this._socket=null}}else if(this._backupSocket){this.unbindSocket(this._backupSocket);try{this._backupSocket.close(1e3)}catch(KC){}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(Nj,new LR({code:PR.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(yC.MAIN),this.unbindAndCloseSocket(yC.BACKUP),this._socketInUse=null,this.reconnect()),this.room.isJoining&&this.emit(Nj,new LR({code:PR.SIGNAL_CHANNEL_SETUP_FAILED,message:"websocket onerror"}))}},{key:"onmessage",value:function(e){if(this.isConnected){this._lastMessageTime=Date.now(),this.bytesReceived+=mD(e.data);var t=JSON.parse(e.data),n=t.cmd,r=t.data,i=Object.values(Oj),o=Object.keys(Oj)[i.indexOf(n)],a=Mj[o]||n;switch(Pj.includes(n)||(this._log.debug("received ".concat(n," msg: ").concat(e.data)),a&&this._log.info("Received event: [ ".concat(a," ]"))),n){case Oj.CHANNEL_SETUP_RESULT:if(0===t.code)this._signalInfo.clientIp=r.clientIp,this._signalInfo.signalIp=r.signalInnerIp,r.svrTime&&function(e){UR=e-(new Date).getTime();var t=new Date;t.setTime(e),bx.info("baseTime from server: ".concat(t," offset: ").concat(UR))}(r.svrTime),this._log.info("ChannelSetup Success ".concat(eD()-this._connectStartTime)),GO.addSuccessEvent({key:521701,cost:eD()-this._connectStartTime}),this._connectStartTime=-1,this.emit(Rj,{signalInfo:this._signalInfo});else{var s=new LR({code:PR.SIGNAL_CHANNEL_SETUP_FAILED,extraCode:t.code,message:OO({key:wO.SIGNAL_CHANNEL_SETUP_FAILED,data:{errorCode:t.code,errorMsg:t.message}})});this._log.error("".concat(t.code,", ").concat(t.message)),this.close(),GO.addFailedEvent({key:521701,error:s}),this.emit(Nj,s)}break;case Oj.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 kR(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 TB(!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?yC.MAIN:yC.BACKUP),this._socketInUse=null,this.emitConnectionStateChanged("DISCONNECTED"),this.reconnect()}}},{key:"reconnect",value:function(){return kR(this,null,f().mark((function e(){var t,n,r,i,o,a,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,o=i.relayIp,a=i.relayInnerIp,s=i.relayPort,e.next=17,this.sendWaitForResponse({command:lH,data:{roomId:n,useStringRoomId:r,relayInnerIp:a,relayOuterIp:o,relayPort:s},responseCommand:Mj.CHANNEL_RECONNECT_RESULT});case 17:c=e.sent,0===(u=c.data).code?(this._log.warn("reconnect success"),this.stopReconnection(),GO.addSuccessEvent({key:521702,cost:eD()-this._connectStartTime}),this._connectStartTime=-1,this.room.syncUserList(),this.room.checkConnectionsToReconnect()):(GO.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+=mD(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 LR({code:PR.API_CALL_TIMEOUT,message:OO({key:wO.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 wD({retryFunction:this.sendWaitForResponse,onError:function(e){var n=e.retry;t.isOnline?n():(t._log.warn("retry ".concat(r," when connected")),t.once(wj,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),hH.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(yC.MAIN),this.unbindAndCloseSocket(yC.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(Mj.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(Mj.JOIN_ROOM_RESULT,n))};this.on(Mj.JOIN_ROOM_RESULT,n)}}},{key:"emitConnectionStateChanged",value:function(e){e!==this._currentState&&(this._log.info("".concat(this._currentState," -> ").concat(e)),this.emit(Cj,{prevState:this._currentState,state:e}),this._currentState=e,"CONNECTED"===e?this.emit(wj):"DISCONNECTED"===e&&this.emit(xj))}}])}(Aj.default);yR([sM({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())}})],fH.prototype,"connect",1);var pH=gR(SR()),mH=0,vH=!1,_H=new Set,gH=!1,yH=function(){function e(t){r(this,e),ER(this,"userId"),ER(this,"tinyId"),ER(this,"_sdpSemantics"),ER(this,"_isUplink"),ER(this,"_room"),ER(this,"_log"),ER(this,"_signalChannel"),ER(this,"_isErrorObserved",!1),ER(this,"_waitForPeerConnectionConnectedPromise"),ER(this,"_waitForPeerConnectionConnectedPromiseReject",null),ER(this,"_peerConnection",null),ER(this,"_emitter",new pH.default),ER(this,"_currentState","DISCONNECTED"),ER(this,"_isReconnecting",!1),ER(this,"_reconnectionCount",0),ER(this,"_reconnectionTimer",-1),ER(this,"_isFirstConnection",!0),ER(this,"_prevTime",-1),ER(this,"_localAddress"),ER(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=bx.createLogger({id:"n-mpc",userId:this._room.userId,remoteUserId:this.userId,sdkAppId:this._room.sdkAppId,isLocal:this._isUplink}),this._signalChannel=t.signalChannel}return a(e,[{key:"beforeConnect",value:function(){this._prevTime<0&&(this._prevTime=eD())}},{key:"afterConnect",value:function(){try{this._isFirstConnection?(this._isFirstConnection=!1,GO.addSuccessEvent({key:521705,cost:Math.min(eD()-this._prevTime,3e4)})):this._isReconnecting&&GO.addSuccessEvent({key:521706,cost:eD()-this._prevTime}),this._prevTime=-1}catch(Ox){throw this._isFirstConnection?(this._isFirstConnection=!1,GO.addFailedEvent({key:521705,error:Ox})):this._isReconnecting&&this._reconnectionCount>=3&&GO.addFailedEvent({key:521706,error:Ox}),Ox}}},{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(),_H.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 LR({code:PR.API_CALL_ABORTED,message:"connection closed"}))}},{key:"getDTLSTransportState",value:function(){if(!this._peerConnection)return HC;var e=null;if(this._isUplink){if(!pP()||0===this._peerConnection.getSenders().length)return HC;e=this._peerConnection.getSenders()[0].transport}else{if(!fP()||0===this._peerConnection.getReceivers().length)return HC;e=this._peerConnection.getReceivers()[0].transport}return e?e.state:HC}},{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===GC.CONNECTING&&this.emitConnectionStateChangedEvent("CONNECTING"),e.target.connectionState===GC.FAILED||e.target.connectionState===GC.CLOSED){var r="connection ".concat(e.target.connectionState,". ICE Transport state: ").concat(t,", DTLS Transport state: ").concat(n),i=new LR({message:r,code:PR.ICE_TRANSPORT_ERROR});this.emitConnectionStateChangedEvent("DISCONNECTED"),this.startReconnection(),this._isErrorObserved||this._emitter.emit("error",i)}(e.target.connectionState===GC.CONNECTED||e.target.connectionState===GC.COMPLETED)&&(this.logSelectedCandidate(),oM.logSuccessEvent({userId:this._room.userId,eventType:YC.ICE_CONNECTION_STATE}),this.emitConnectionStateChangedEvent("CONNECTED"))}},{key:"emitConnectionStateChangedEvent",value:function(e){return e!==this._currentState&&("CONNECTED"===e?(mH=0,vH=!1,gH=!0,_H.add(this)):_H.delete(this),Tx.emit(Sx.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 kR(this,null,f().mark((function e(){var t,n,r,i,o,a,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),o=i[1],!aP(o)){e.next=14;break}return a=t.get(o.localCandidateId),c=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)),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(a),o(),t())},i=function(t){t.room===e._room&&(clearTimeout(a),o(),n(new LR({code:PR.API_CALL_ABORTED,message:OO({key:wO.CONNECTION_ABORTED,data:"leave room"})})))},o=function(){Tx.off(Sx.LEAVE_SUCCESS,i,e),e._emitter.off("connection-state-changed",r,e)},a=setTimeout((function(){o();var t,r=new LR({code:PR.API_CALL_TIMEOUT,message:"connection timeout"});mH+=1,t=e._signalChannel.isConnected,mH>2&&!vH&&0===_H.size&&t&&(e._log.warn("firewall restriction"),vH=!0,e._emitter.emit("firewall-restriction")),n(r)}),sw);Tx.on(Sx.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(wj,this.reconnect,this)}},{key:"beforeReconnect",value:function(){if(-1!==this._reconnectionTimer)return this._log.warn("reconnect() is reconnecting, ignore"),-1;if(this._reconnectionCount>=zC()){this._log.warn("SDK has tried reconnect for ".concat(this._reconnectionCount," times, but all failed, please check your network")),this.stopReconnection();var e=new LR({code:this._isUplink?PR.UPLINK_RECONNECTION_FAILED:PR.DOWNLINK_RECONNECTION_FAILED,message:OO({key:this._isUplink?wO.UPLINK_RECONNECTION_FAILED:wO.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(wj,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)}}])}();yR([LL(521712,!1)],yH.prototype,"setOffer",1),yR([LL(521713,!1)],yH.prototype,"setAnswer",1);var EH=gR(NR()),TH=function(e){return EH.default.parse(e)},kH=function(e){return EH.default.write(e)};function SH(e){return Object.keys(e).filter((function(t){return e[t]}))}var IH=function(e){function i(e){var o;return r(this,i),o=n(this,i,[mR(pR({},e),{isUplink:!1})]),ER(t(o),"_flag",0),ER(t(o),"isRobot",!1),ER(t(o),"role","anchor"),ER(t(o),"remoteAudioTrack"),ER(t(o),"remoteVideoTrack"),ER(t(o),"remoteAuxiliaryTrack"),ER(t(o),"ssrc",{audio:0,video:0,auxiliary:0}),ER(t(o),"_isSDPExchanging",!1),o.flag=e.flag,o.isRobot=e.isRobot||!1,o.remoteAudioTrack=e.remoteAudioTrack||new pF(o._room,t(o)),o.remoteVideoTrack=e.remoteVideoTrack||new xF(o._room,t(o)),o.remoteAuxiliaryTrack=e.remoteAuxiliaryTrack||new OF(o._room,t(o)),o}return d(i,e),a(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 oD(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===yC.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,o=g(i,"emitConnectionStateChangedEvent",this,3)([e]);return o&&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})),o}},{key:"onTrack",value:function(e){var t=e.streams[0],n=e.track,r=t.id===NC?yC.MAIN:yC.AUXILIARY;this._log.debug("ontrack ".concat(r," ").concat(n.kind));var i=yC.AUDIO;n.kind===yC.VIDEO&&(i=r===yC.MAIN?yC.VIDEO:yC.AUXILIARY);var o=this.remoteAudioTrack;i===yC.VIDEO?o=this.remoteVideoTrack:i===yC.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=E(n),i=0;i<r.length;i++){var o=v(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=TH(e);return t.media.forEach((function(e){e.type===yC.VIDEO&&e.fmtp.forEach((function(e){e.config+=";sps-pps-idr-in-keyframe=1"}))})),kH(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=TH(e);return n.media.forEach((function(e){e.ext&&(e.ext=e.ext.filter((function(e){return!t.includes(e.uri)})))})),kH(n)}},{key:"isSubscriptionStateNotChanged",value:function(e){return JSON.stringify(e)===JSON.stringify(this.subscribeState)}},{key:"subscribe",value:function(e,t){return kR(this,null,f().mark((function n(){var r,i,o;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)===GC.NEW||(null==(i=this._peerConnection)?void 0:i.connectionState)===GC.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 o="subscribe_change",Object.values(e).find((function(e){return!0===e}))||(o="unsubscribe"),n.next=18,this.sendSubscription(o,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 LR({code:PR.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 kR(this,arguments,(function(e){var t=this,n=e.remoteTracks,r=e.streamType;return f().mark((function e(){var i,o;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=pR({},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(SH(i),"]")),e.next=9,t.sendSubscription(o,i);case 9:"unsubscribe"===o&&(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=Jj,o=Mj.UNSUBSCRIBE_RESULT;return"subscribe_change"===e&&(r={audio:n.audio,bigVideo:n.video,auxVideo:n.auxiliary,smallVideo:n.smallVideo,srcTinyId:this.tinyId},i=zj,o=Mj.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 LR({code:r.code,message:OO({key:wO.ERROR_MESSAGE,data:{type:e,message:r.message}})});throw t._log.error(i),i}}))}},{key:"connect",value:function(){return kR(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 kR(this,null,f().mark((function t(){var n,r,i,o,a,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,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:Wj,commandDesc:"exchange sdp",data:o,responseCommand:Mj.SUBSCRIBE_RESULT,timeout:$C});case 11:if(a=t.sent,this._peerConnection){t.next=15;break}throw s=new LR({code:PR.INVALID_OPERATION,message:OO({key:wO.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 kR(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},vP()&&this._sdpSemantics===ZC?(this._peerConnection.addTransceiver(yC.AUDIO,{direction:EC.RECVONLY}),this._peerConnection.addTransceiver(yC.VIDEO,{direction:EC.RECVONLY}),this._peerConnection.addTransceiver(yC.VIDEO,{direction:EC.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,eP();case 8:e.sent.isH264DecodeSupported||(this._log.warn("remove h264 desc from sdp"),n.sdp=function(e){var t=TH(e);return t.media.forEach((function(e){var t,n;if(e.type===yC.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(" ")}})),kH(t)}(n.sdp)),n.sdp=this.addRRTRLine(n.sdp),n.sdp=this.addSPSDescription(n.sdp),n.sdp=function(e){var t=TH(e);return t.media.forEach((function(e){e.type===yC.AUDIO&&e.fmtp.forEach((function(e){e.config+=";sprop-stereo=1;stereo=1"}))})),kH(t)}(n.sdp),this._sdpSemantics===ZC&&(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 kR(this,null,f().mark((function t(){var n,r,i,o,a,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,o=void 0===i?"":i,a=e&&e.data&&e.data.data||{},s=a.type,c=a.sdp,r!==tw){t.next=3;break}throw new LR({code:PR.NOT_SUPPORTED_H264,message:OO({key:wO.NOT_SUPPORTED_H264DECODE})});case 3:if(t.prev=3,0===r){t.next=6;break}throw new LR({code:r,message:OO({key:wO.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{TH(e).media.forEach((function(e){if(e.ssrcs)if(e.type===yC.AUDIO){var n=e.ssrcs.find((function(e){var t;return null==(t=e.value)?void 0:t.includes(NC)}));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(NC)})),i=e.ssrcs.find((function(e){var t;return null==(t=e.value)?void 0:t.includes(xC)}));r&&(t.ssrc.video=Number(r.id)),i&&(t.ssrc.auxiliary=Number(i.id))}}))}catch(KC){}}},{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 kR(this,null,f().mark((function e(){var t,n=this;return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(TR(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=Vw(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}}])}(yH);yR([RL((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 LR({code:PR.API_CALL_ABORTED,message:OO({key:wO.CONNECTION_ABORTED,data:e})}))};t._emitter.on("closed",o),e.apply(t,r).then(n,i).finally((function(){t._emitter.off("closed",o)}))}))}}))],IH.prototype,"subscribe",1),yR([LL(521717,!1)],IH.prototype,"unsubscribe",1),yR([bL(yH.prototype.afterConnect),IL(yH.prototype.beforeConnect)],IH.prototype,"connect",1);var bH=IH,AH={voiceActivityDetection:!1},RH=function(e){function i(e){var o;return r(this,i),o=n(this,i,[mR(pR({},e),{isUplink:!0})]),ER(t(o),"localMainAudioTrack",null),ER(t(o),"localMainVideoTrack",null),ER(t(o),"localAuxAudioTrack",null),ER(t(o),"localAuxVideoTrack",null),ER(t(o),"ssrc",{audio:0,video:0,small:0,auxiliary:0}),ER(t(o),"_isPublishingAux",!1),ER(t(o),"_publishingLocalAudioTrack"),ER(t(o),"_publishingLocalVideoTrack"),ER(t(o),"_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}),ER(t(o),"flag",0),o}return d(i,e),a(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,o={audio:!1,bigVideo:!1,smallVideo:!1,auxVideo:!1};if(this._peerConnection){var a=this._peerConnection.getSenders();a&&(mP()?(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===yC.AUDIO?o.audio=!0:(o.bigVideo=!0,i._room.videoManager.hasSmall&&(o.smallVideo=!0)))})))}return o}},{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,o,a=this._currentState,s=g(i,"emitConnectionStateChangedEvent",this,3)([e]);return s&&a!==e&&(t?t.emit("connection-state-changed",{prevState:a,state:e}):(null==(n=this.localMainVideoTrack)||n.emit("connection-state-changed",{prevState:a,state:e}),null==(r=this.localAuxVideoTrack)||r.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 kR(this,arguments,(function(e){var t=this,n=e.localAudioTrack,r=e.localVideoTrack,i=e.isAuxiliary;return f().mark((function e(){var o;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&&(o=t._room.videoManager.smallTrack),t.sendMediaSettings(),!vP()){e.next=11;break}return e.next=9,t.publishByTransceiver({localAudioTrack:n,localVideoTrack:r,smallTrack:o,isAuxiliary:i});case 9:e.next=13;break;case 11:return e.next=13,t.publishByAddTrack({localAudioTrack:n,localVideoTrack:r,smallTrack:o});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 kR(this,arguments,(function(e){var t=this,n=e.localAudioTrack,r=e.localVideoTrack,i=e.smallTrack,o=e.isAuxiliary;return f().mark((function e(){var a,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"),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||yC.AUDIO,{direction:EC.SENDONLY,streams:[a]}),t._peerConnection.addTransceiver(o?yC.VIDEO:s||yC.VIDEO,{direction:EC.SENDONLY,streams:[a]}),t._peerConnection.addTransceiver(i||yC.VIDEO,{direction:EC.SENDONLY,streams:[a]}),t._peerConnection.addTransceiver(o&&s||yC.VIDEO,{direction:EC.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:yC.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:yC.VIDEO,videoType:o?yC.AUXILIARY:yC.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:yC.VIDEO,videoType:yC.SMALL});case 34:l.push(2);case 35:return e.next=37,t.setTransceiverDirection(EC.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 kR(this,arguments,(function(e){var t=this,n=e.localAudioTrack,r=e.localVideoTrack,i=e.smallTrack;return f().mark((function e(){var o,a,s,c;return f().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=13;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=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,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=17,t.connect();case 17:case"end":return e.stop()}}),e)}))()}))}},{key:"enableSmall",value:function(e){return kR(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(EC.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(EC.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 kR(this,arguments,(function(e){var t=this,n=e.localAudioTrack,r=e.localVideoTrack;return f().mark((function e(){var i,o,a,s;return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(mP()){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,o=null==r?void 0:r.outMediaTrack,a=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,a[0].replaceTrack(null);case 27:s.push(0);case 28:if(e.t4=o,!e.t4){e.next=45;break}if(!i){e.next=38;break}return e.next=33,a[3].replaceTrack(null);case 33:t.localAuxVideoTrack=null,t._mediaSettings=mR(pR({},t._mediaSettings),{auxVideoBps:0,auxVideoFps:0,auxVideoWidth:0,auxVideoHeight:0}),s.push(3),e.next=45;break;case 38:return e.next=40,a[1].replaceTrack(null);case 40:return e.next=42,a[2].replaceTrack(null);case 42:t.localMainVideoTrack=null,t._mediaSettings=mR(pR({},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(EC.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 kR(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:Hj,data:n,responseCommand:Mj.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:Gj,commandDesc:"unpublish",responseCommand:Mj.UNPUBLISH_RESULT,enableLog:e}).catch((function(e){if(e.getCode()===PR.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),SP){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:iH,data:this._mediaSettings,responseCommand:Mj.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 kR(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?yC.AUXILIARY:yC.MAIN," stream")),!vP()){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 kR(this,null,f().mark((function n(){var r,i,o;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!==yC.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===EC.INACTIVE,!n.t1){n.next=19;break}return n.next=19,this.setTransceiverDirection(EC.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 kR(this,null,f().mark((function t(){var n,r,i,o,a;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=mP()&&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===yC.VIDEO&&e instanceof WL&&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===ew||!this._peerConnection||!this._peerConnection.localDescription)return!1;for(var e=this._peerConnection.localDescription.sdp,t=TH(e),n=0;n<t.media.length;n++)if(0===Number(t.media[n].mid)&&t.media[n].type===yC.VIDEO)return!0;return!1}},{key:"removeSender",value:function(e){var t=null;mP()&&(t=this._peerConnection.getTransceivers().find((function(t){return t.sender&&t.sender.track===e.track}))),this._peerConnection.removeTrack(e),t&&Bw(t.stop)&&(this._log.info("stop transceiver"),t.stop())}},{key:"removeTrack",value:function(e){return kR(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?yC.AUXILIARY:yC.MAIN," stream")),!vP()){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 kR(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!==yC.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(EC.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 kR(this,null,f().mark((function n(){var r,i,o,a,s,c;return f().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(KD){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(EC.INACTIVE,"|").concat(EC.RECVONLY,"|").concat(EC.SENDONLY,")")))&&s++,t.includes(s)){if(e===EC.INACTIVE&&n.includes("a=".concat(EC.RECVONLY)))return i=!0,"a=".concat(e);if(e===EC.SENDONLY&&n.includes("a=".concat(EC.INACTIVE)))return i=!0,"a=".concat(EC.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 kR(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!==yC.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===yC.VIDEO&&e.small&&this._peerConnection.getSenders().forEach((function(e){e.track&&e.track.kind===yC.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 kR(this,null,f().mark((function t(){var n,r,i,o;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=vP()?e.kind===yC.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(o=e===this.localAuxAudioTrack||e===this.localAuxVideoTrack,this._log.info("is replacing ".concat(e.kind," track on ").concat(o?yC.AUXILIARY:yC.MAIN," stream")),e.kind!==yC.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===yC.VIDEO,!t.t0){t.next=23;break}if(!o){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 kR(this,null,f().mark((function n(){var r,i,o,a,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(AH);case 3:return r=n.sent,KD&&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===yC.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:Lj,data:o,responseCommand:Mj.UPDATE_OFFER_RESULT,timeout:QC,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 kR(this,arguments,(function(e){var t=this,n=e.bandwidth,r=e.type,i=e.videoType,o=e.sdp;return f().mark((function e(){var a,s,c,u;return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(TP()){e.next=2;break}return e.abrupt("return",o?r===yC.VIDEO?t.updateVideoBandwidthRestriction(o,n,i):t.updateAudioBandwidthRestriction(o,n):void 0);case 2:if(s=t._peerConnection.getSenders(),vP()?(c=0,r===yC.VIDEO&&(c=i===yC.SMALL?2:i===yC.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===yC.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";KD&&(r="TIAS",t*=1e3);var i=0,o=-1;return n===yC.SMALL?i=1:n===yC.AUXILIARY&&(i=2),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 KD&&(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 kR(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 kR(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 kR(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(AH);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:jj,responseCommand:Mj.PUBLISH_RESULT,data:{type:this._peerConnection.localDescription.type,sdp:this.removeVideoOrientation(this._peerConnection.localDescription.sdp),screen:this.localMainVideoTrack instanceof KL||this.localAuxVideoTrack instanceof KL,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=TH(e);return r.media.forEach((function(e){("all"===n||e.type===n)&&(e.direction=t)})),kH(r)}},{key:"acceptAnswer",value:function(e){return kR(this,null,f().mark((function t(){var n,r,i,o,a,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==(o=this.localMainAudioTrack)?void 0:o.profile.bitrate),!c){t.next=8;break}return l=this._isPublishingAux?yC.AUXILIARY:yC.BIG,t.next=7,this.setBandwidth({bandwidth:c,type:yC.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:yC.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:yC.VIDEO,videoType:yC.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(Bj,i)}}},{key:"getIsReconnecting",value:function(){return this._isReconnecting}},{key:"reconnect",value:function(){return kR(this,null,f().mark((function e(){var t,n=this;return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(TR(i.prototype,this,"beforeReconnect").call(this)<0){e.next=22;break}return e.prev=1,e.next=4,this._signalChannel.sendWaitForResponse({command:Gj,responseCommand:Mj.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=Vw(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)&&Tx.emit(Sx.SEND_FIRST_VIDEO_FRAME,{room:this._room})}},{key:"updateSSRC",value:function(e){var t=this;try{TH(e).media.forEach((function(e,n){if(e.type===yC.AUDIO){var r=e.ssrcs&&e.ssrcs[0];r&&(t.ssrc.audio=Number(r.id))}else{if(t._sdpSemantics===ew&&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(KC){}}},{key:"getVideoTrackId",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:yC.VIDEO;if(this._peerConnection){var t=this._peerConnection.getSenders();if(e===yC.AUXILIARY&&t[3]&&t[3].track)return t[3].track.id;if(e===yC.VIDEO&&t[1]&&t[1].track)return t[1].track.id}if(this.localMainVideoTrack&&e===yC.VIDEO){var n=this.localMainVideoTrack.mediaTrack;if(n)return n.id}if(this.localAuxVideoTrack&&e===yC.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===tw?(this._log.error(DO.NOT_SUPPORTED_H264ENCODE),new LR({code:PR.NOT_SUPPORTED_H264,message:OO({key:wO.NOT_SUPPORTED_H264ENCODE})})):new LR({code:PR.UNKNOWN,message:OO({key:wO.SIGNAL_RESPONSE_FAILED,data:{signalResponse:Mj.PUBLISH_RESULT,code:e,message:t}})})}}])}(yH);yR([RL((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 LR({code:PR.API_CALL_ABORTED,message:OO({key:wO.CONNECTION_ABORTED,data:e})}))};t._emitter.on("closed",o),e.apply(t,r).then(n,i).finally((function(){t._emitter.off("closed",o)}))}))}}))],RH.prototype,"publish",1),yR([LL(521715,!1)],RH.prototype,"unpublish",1),yR([bL(yH.prototype.afterConnect),IL(yH.prototype.beforeConnect)],RH.prototype,"connect",1);var CH=RH,wH=function(){function e(t,n){r(this,e),this.room=t,ER(this,"_log"),ER(this,"_prevReportTime",0),ER(this,"_prevReport",{}),ER(this,"_prevStats",null),ER(this,"_prevEncoderImplementation",""),ER(this,"_prevAuxEncoderImpl",""),ER(this,"_prevQualityLimitationReason",""),ER(this,"_prevAuxQualityLimitationReason",""),ER(this,"_prevDecoderImplementationMap",new Map),ER(this,"totalBytesSent",0),ER(this,"totalBytesReceived",0),ER(this,"_spcStats",null),this._log=n}return a(e,[{key:"statInterval",get:function(){return 0===this._prevReportTime?2:(Date.now()-this._prevReportTime)/1e3}},{key:"getSenderStats",value:function(e){return kR(this,null,f().mark((function t(){var n,r,i,o,a,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(),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)===yC.VIDEO){if(t.ssrc===o.video?(c=yC.VIDEO,e.localMainVideoTrack):t.ssrc===o.small?c=yC.SMALL:t.ssrc===o.auxiliary&&(e.localAuxVideoTrack,c=yC.AUXILIARY),!c)return;if(r[c].bytesSent=t.bytesSent,r[c].packetsSent=t.packetsSent,r[c].framesEncoded=t.framesEncoded,jw(t.keyFramesEncoded)||(r[c].keyFramesEncoded=t.keyFramesEncoded),jw(t.nackCount)||(r[c].nackCount=t.nackCount),jw(t.pliCount)||(r[c].pliCount=t.pliCount),jw(t.retransmittedPacketsSent)||(r[c].retransmittedPacketsSent=t.retransmittedPacketsSent),jw(t.totalEncodeTime)||(r[c].totalEncodeTime=t.totalEncodeTime),jw(t.totalPacketSendDelay)||(r[c].totalPacketSendDelay=t.totalPacketSendDelay),!jw(t.encoderImplementation)&&(c===yC.VIDEO&&s._prevEncoderImplementation!==t.encoderImplementation||c===yC.AUXILIARY&&s._prevAuxEncoderImpl!==t.encoderImplementation)){var u=2,l=s._prevEncoderImplementation;c===yC.AUXILIARY&&(u=7,l=s._prevAuxEncoderImpl),Tx.emit("262",{userId:e.userId,streamType:u,prevImplementation:l,implementation:t.encoderImplementation,codec:e.videoCodec,isHWCodec:t.powerEfficientEncoder}),s[c===yC.VIDEO?"_prevEncoderImplementation":"_prevAuxEncoderImpl"]=t.encoderImplementation,s._log.info("".concat(c===yC.AUXILIARY?"aux ":"","encoderImplementation change to ").concat(t.encoderImplementation,"(").concat(e.videoCodec,") HWEncoder: ").concat(t.powerEfficientEncoder))}t.ssrc===o.video?!jw(t.qualityLimitationReason)&&0!==t.bytesSent&&s._prevQualityLimitationReason!==t.qualityLimitationReason&&(s._log.info("qualityLimitationReason change to ".concat(t.qualityLimitationReason)),Tx.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&&!jw(t.qualityLimitationReason)&&0!==t.bytesSent&&s._prevAuxQualityLimitationReason!==t.qualityLimitationReason&&(s._log.info("aux qualityLimitationReason change to ".concat(t.qualityLimitationReason)),Tx.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?aP(t)&&(s.totalBytesSent=t.bytesSent,Gw(t.currentRoundTripTime)&&(r.rtt=Math.floor(1e3*t.currentRoundTripTime))):"media-source"===t.type&&(t.kind===yC.AUDIO?(r.audio.audioLevel=t.audioLevel||0,r.audio.totalAudioEnergy=t.totalAudioEnergy||0,t.echoReturnLoss,t.totalSamplesDuration&&(r.audio.totalSamplesDuration=t.totalSamplesDuration)):t.kind===yC.VIDEO&&(t.trackIdentifier===e.getVideoTrackId(yC.VIDEO)?r.video.fpsCapture=t.framesPerSecond:t.trackIdentifier===e.getVideoTrackId(yC.AUXILIARY)?r.auxiliary.fpsCapture=t.framesPerSecond:r.small.fpsCapture=t.framesPerSecond));if(!jw(t.audioLevel)&&null!=(a=e.localMainAudioTrack)&&a.mediaTrack&&t.trackIdentifier===e.localMainAudioTrack.mediaTrack.id&&(r.audio.audioLevel=t.audioLevel||0),!jw(t.frameWidth)){var d=yC.SMALL;t.trackIdentifier===e.getVideoTrackId(yC.VIDEO)||t.ssrc===o.video?d=yC.VIDEO:(t.trackIdentifier===e.getVideoTrackId(yC.AUXILIARY)||t.ssrc===o.auxiliary)&&(d=yC.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===yC.AUDIO?(e.localMainAudioTrack&&(e.localMainAudioTrack.stat=r[t]),e.localAuxAudioTrack&&(e.localAuxAudioTrack.stat=r[t])):t===yC.VIDEO?e.localMainVideoTrack&&(e.localMainVideoTrack.stat=r[t]):t===yC.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 kR(this,null,f().mark((function t(){var n,r,i,o,a,s,c,u,l=this;return f().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)===yC.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(KD&&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)),Tx.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&&aP(t)&&(l.totalBytesReceived=t.bytesReceived,Gw(t.currentRoundTripTime)&&(o.rtt=Math.floor(1e3*t.currentRoundTripTime)));jw(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)),!jw(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),jw(null==(n=e.remoteVideoTrack.player.stat)?void 0:n.fps)||(o.video.fpsRender=e.remoteVideoTrack.player.stat.fps),jw(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 kR(this,null,f().mark((function n(){var r,i,o,a,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(o=this.room.singlePC.getPeerConnection()){n.next=5;break}return n.abrupt("return",{senderStats:r,receiverStats:i});case 5:return a=eD(),n.next=8,o.getStats();case 8:c=n.sent,(u=eD())-a>2e3&&this._log.warn("getStats cost ".concat(u-a,"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(gL(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(!gL(r.senderStats)){var a={uint32_audio_level:r.senderStats.audio.audioLevel*yO,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*yO),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(OC)),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(PC)),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),jw(t.uint32_key_frame_count)||(e.uint32_key_frame_count=Math.round(n.getDifferenceValue(t.uint32_key_frame_count,e.uint32_key_frame_count))),jw(t.uint32_nack_count)||(e.uint32_nack_count=Math.round(n.getDifferenceValue(t.uint32_nack_count,e.uint32_nack_count))),jw(t.uint32_pli_count)||(e.uint32_pli_count=Math.round(n.getDifferenceValue(t.uint32_pli_count,e.uint32_pli_count))),jw(t.uint32_video_arq_packets)||(e.uint32_video_arq_packets=Math.round(n.getDifferenceValue(t.uint32_video_arq_packets,e.uint32_video_arq_packets))),jw(t.uint32_encode_cost)||(e.uint32_encode_cost=Math.round(n.getDifferenceValue(t.uint32_encode_cost,e.uint32_encode_cost)/h)),jw(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(gL(e.msg_audio_status)||gL(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 kR(this,arguments,(function(e){var t=this,n=e.uplinkConnection,r=e.downlinkConnections,i=e.freezeMap;return f().mark((function e(){var o,a;return f().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}}])}();function DH(e){var t=this;return new Promise((function(n){return kR(t,null,f().mark((function t(){var r,i,o,a;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(),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),a=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 o=n.value;if(o.name===e){var a=Math.round(o.duration),c=Math.max(Math.round(o.domainLookupStart-o.startTime),0),u=o.redirectStart>0?Math.max(Math.round(o.redirectEnd-o.redirectStart),0):0,l=o.fetchStart>0?Math.max(Math.round(o.domainLookupStart-o.fetchStart),0):0,d=Math.round(o.domainLookupEnd-o.domainLookupStart),h=Math.round(o.requestStart-o.secureConnectionStart),f=Math.round(o.secureConnectionStart-o.connectStart),p=Math.round(o.responseStart-o.requestStart),m=Math.round(o.responseEnd-(o.responseStart||o.startTime));t=mR(pR({},t),{totalCost:a,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}(o),0===a.totalCost&&(a.totalCost=Date.now()-i),n(a);case 11:case"end":return t.stop()}}),t,null,[[1,6]])})))}))}var NH=function(e){function i(e){var o;r(this,i);var a=e.signalChannel,s=e.room;return o=n(this,i),ER(t(o),"_room"),ER(t(o),"_signalChannel"),ER(t(o),"_log"),ER(t(o),"uplinkRTT",0),ER(t(o),"uplinkLoss",0),ER(t(o),"downlinkRTT",0),ER(t(o),"downlinkLoss",0),ER(t(o),"pingResults",{}),ER(t(o),"_downlinkPrevStatMap",new Map),ER(t(o),"_downlinkLossAndRTTMap",new Map),ER(t(o),"_interval",-1),ER(t(o),"_uplinkNetworkQuality",0),ER(t(o),"_downlinkNetworkQuality",0),o._room=s,o._signalChannel=a,o._log=bx.createLogger({id:"q",userId:o._room.userId,sdkAppId:o._room.sdkAppId}),o.initialize(),o}return d(i,e),a(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(Mj.UPLINK_NETWORK_STATS,(function(t){e.handleUplinkNetworkQuality(t)})),this._signalChannel.on(Cj,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 kR(this,null,f().mark((function e(){var t,n,r,i,o,a,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)===GC.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(o=e.sent,a=o.rtt,s=o.totalPacketsLost,c=o.totalPacketsReceived,this._downlinkPrevStatMap.has(i)){e.next=19;break}return this._downlinkPrevStatMap.set(i,{totalPacketsLost:s,totalPacketsReceived:c}),e.abrupt("continue",21);case 19: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 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 kR(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&&fP()){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&&Gw(e.currentRoundTripTime)&&(n.rtt=Math.round(1e3*e.currentRoundTripTime)),"inbound-rtp"===e.type&&(e.mediaType===yC.AUDIO||e.mediaType===yC.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!==GC.DISCONNECTED&&e.connectionState!==GC.FAILED&&e.connectionState!==GC.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=ZP.run("ric",(function(){var t;e.handleDownlinkNetworkQuality();var n=E(e._downlinkLossAndRTTMap.values());Tx.emit(Sx.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,o={uplinkNetworkQuality:e.uplinkNetworkQuality,downlinkNetworkQuality:e.downlinkNetworkQuality,uplinkRTT:e.uplinkRTT,uplinkLoss:e.uplinkLoss,downlinkRTT:e.downlinkRTT,downlinkLoss:e.downlinkLoss};r&&(o=mR(pR({},o),{pingResults:e.uplinkRTT>r.rttThreshold||e.downlinkRTT>r.rttThreshold?e.pingResults:{}})),e.emit(i.EVENT_NETWORK_QUALITY,o);var a=Date.now();if(r&&(e.uplinkRTT>r.rttThreshold||e.downlinkRTT>r.rttThreshold)&&a-i.lastPingTime>1e3*r.interval){i.lastPingTime=Date.now();var s=r.domain.map((function(e){return DH(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){GO.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&&(ZP.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})}}))}}])}(gR(SR()).default);ER(NH,"EVENT_NETWORK_QUALITY","0"),ER(NH,"lastPingTime",0);var xH=NH,OH=function(){function e(t){var n=this;r(this,e),ER(this,"_frameWorkType"),ER(this,"_component"),ER(this,"_language"),ER(this,"connectionType"),ER(this,"_room"),ER(this,"_signalInfo",{tinyId:void 0,clientIp:"",signalIp:"",relayIp:"",relayInnerIp:"",relayPort:0,endReportExtend:void 0}),ER(this,"_keyPrefix"),ER(this,"_log"),ER(this,"_intervalId"),ER(this,"_firstPublishedUserList"),ER(this,"_networkQuality"),ER(this,"_basicInfo"),ER(this,"_pathJoinRoom"),ER(this,"_pathLeaveRoom"),ER(this,"_pathMainVideoMap"),ER(this,"_pathMainAudioMap"),ER(this,"_pathAuxiliaryMap"),ER(this,"_remoteStreamStatMap"),ER(this,"_localStreamStat"),ER(this,"_eventMap",new Map),ER(this,"_captureCostSum",0),ER(this,"_captureCostCount",0),ER(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=bx.createLogger({id:"kpm",userId:this._room.userId,sdkAppId:this._room.sdkAppId}),Object.getOwnPropertyNames(this.__proto__).forEach((function(e){e.startsWith("handle")&&Bw(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 Yw(o)?o.catch((function(e){return bx.error("".concat(t.name,"() error observed ").concat(e))})):o}catch(KC){bx.error("".concat(t.name,"() error observed ").concat(KC))}}}({fn:n[e],context:n}))})),this.initData(),this.installEvents()}return a(e,[{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:WR,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,hx().then((function(t){e._basicInfo.string_os_version=_x(),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),Tx.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(Sx.JOIN_START,this.handleJoinStart).addEvent(Sx.JOIN_SCHEDULE_SUCCESS,this.handleJoinScheduleSuccess).addEvent(Sx.JOIN_SIGNAL_CONNECTION_START,this.handleSignalConnectionStart).addEvent(Sx.JOIN_SIGNAL_CONNECTION_END,this.handleSignalConnectionEnd).addEvent(Sx.JOIN_SEND_CMD,this.handleJoinSendCMD).addEvent(Sx.JOIN_RECEIVED_CMD_RES,this.handleJoinReceivedCMDResponce).addEvent(Sx.JOIN_SUCCESS,this.handleJoinSuccess).addEvent(Sx.JOIN_FAILED,this.handleJoinFailed).addEvent(Sx.LEAVE_START,this.handleLeaveStart).addEvent(Sx.LEAVE_SUCCESS,this.handleLeaveSuccess).addEvent(Sx.LEAVE_SEND_CMD,this.handleLeaveSendCMD).addEvent(Sx.LOCAL_TRACK_CAPTURE_START,this.handleTrackCaptureStart).addEvent(Sx.LOCAL_TRACK_CAPTURE_SUCCESS,this.handleTrackCaptureSuccess).addEvent(Sx.LOCAL_TRACK_CAPTURE_FAILED,this.handleTrackCaptureFailed).addEvent(Sx.PUBLISH_START,this.handlePublishStart).addEvent(Sx.SEND_FIRST_VIDEO_FRAME,this.handleSendFirstVideoFrame).addEvent(Sx.SUBSCRIBE_START,this.handleSubscribeStart).addEvent(Sx.SUBSCRIBE_SUCCESS,this.handleSubscribed).addEvent(Sx.PLAY_TRACK_START,this.handlePlayStart).addEvent(Sx.VIDEO_LOADED_DATA,this.handleVideoLoadedData).addEvent(Sx.PLAYER_STATE_CHANGED,(function(t){var n=t.track,r=t.state,i=t.type;!n.isRemote||!e.hitTest(n.room)||"PLAYING"===r&&(i===yC.AUDIO?e.handleAudioPlaying(n):e.handleVideoPlaying(n))})).addEvent(Sx.NETWORK_QUALITY,this.handleNetworkQuality).addEvent(Sx.HEARTBEAT_REPORT,this.handleHeartbeatStats).addEvent(Sx.RECEIVED_PUBLISHED_USER_LIST,this.handleReceivedPublishUserList).addEvent(Sx.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(Sx.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 Tx.off(t,e)})),this._eventMap.clear()}},{key:"destroy",value:function(){this.uninstallEvents(),ZP.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&&(jw(e.params.frameWorkType)||(this._frameWorkType=e.params.frameWorkType,this._basicInfo.uint32_framework=this._frameWorkType),jw(e.params.component)||(this._component=e.params.component,this._basicInfo.uint32_component=this._component),jw(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 LR?Number(n.getExtraCode()||n.getCode()):PR.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:mR(pR({},MH),{msg_user_info:new LH({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 LH({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,GO.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/yO*100)>0&&(this._localStreamStat.totalAudioLevel+=d/yO,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*hR(10,6)))}})),!iD(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/yO*100)>0&&(c.totalAudioLevel+=r.uint32_audio_level/yO,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 LR?n.getExtraCode()||n.getCode():PR.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&SC}))>=0}},{key:"hasAudioFlag",value:function(e){return this._firstPublishedUserList.findIndex((function(t){return t.userId===e&&t.flag&AC}))>=0}},{key:"hasAuxFlag",value:function(e){return this._firstPublishedUserList.findIndex((function(t){return t.userId===e&&t.flag&bC}))>=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,yC.AUDIO),t.statsToReport.uint32_video_play_time=d.getDuration(n,yC.VIDEO)),t.statsToReport.uint32_video_render_first&&(t.statsToReport.uint32_video_render_first=Math.min(t.statsToReport.uint32_video_render_first,PH));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>PH&&(t.statsToReport.uint64_play_first_frame_time=t.statsToReport.uint64_start_enter_time+PH):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>PH&&(t.statsToReport.uint64_render_first_frame_time=t.statsToReport.uint64_start_enter_time+PH):e._pathMainVideoMap.delete(n)})),this._pathJoinRoom.uint64_end_time-this._pathJoinRoom.uint64_start_time>PH&&(this._pathJoinRoom.uint64_end_time=this._pathJoinRoom.uint64_start_time+PH)}},{key:"getReportData",value:function(){this._basicInfo.uint32_networkType=Cw();var e={uint32_sdk_app_id:Number(this._room.sdkAppId),msg_user_info:new LH({userId:this._room.userId,tinyId:this._room.tinyId,role:"anchor"===this._room.role?20:21}),msg_basic_info:this._basicInfo,uint32_acc_ip:sD(this._signalInfo.relayIp),uint32_client_ip:sD(this._signalInfo.clientIp,!1),uint32_acc_port:this._signalInfo.relayPort||0,uint64_timestamp:Date.now(),uint32_seq:Math.floor(Math.random()*hR(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:sD(this._signalInfo.clientIp,!1),error_code:[],msg_local_statistics:this._localStreamStat.statsToReport,bytes_report_buf_from_0x1:this._signalInfo.endReportExtend};return yD(e),e}},{key:"report",value:function(){return kR(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 kR(this,null,f().mark((function t(){var n,r,i,o,a,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,SD(e);case 5:return r=t.sent,i=r instanceof ArrayBuffer,o="".concat(Sw(n,uC.KEY_POINT),"&gzip=").concat(+i),a=!1,navigator.sendBeacon&&(a=navigator.sendBeacon(o,r)),s=[this.uploadKVStat(GO),this.uploadKVStat(HO)],a||s.push(kD({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 kR(this,null,f().mark((function t(){var n,r,i,o;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=mR(pR({},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,SD(n);case 6:r=t.sent,i="".concat(Sw(+this._room.sdkAppId,uC.KV_STAT),"&gzip=").concat(+(r instanceof ArrayBuffer)),o=!1,navigator.sendBeacon&&(o=navigator.sendBeacon(i,r)),o||kD({url:i,body:r});case 10:case"end":return t.stop()}}),t,this)})))}}])}();yR([sM({settings:{timeout:500,retries:3}})],OH.prototype,"upload",1);var PH=5e3,MH={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},LH=a((function e(t){r(this,e),ER(this,"str_identifier"),ER(this,"str_tinyid"),ER(this,"uint32_role"),this.str_identifier=String(t.userId),this.str_tinyid=String(t.tinyId||0),this.uint32_role=t.role})),UH=OH,VH=function(){function e(){r(this,e),ER(this,"_startTime"),ER(this,"_endTime"),this._startTime=0,this._endTime=0,this.start()}return a(e,[{key:"start",value:function(){0===this._startTime&&(this._startTime=eD())}},{key:"stop",value:function(){0===this._endTime&&(this._endTime=eD())}},{key:"getDuration",value:function(){return 0===this._endTime?eD()-this._startTime:this._endTime-this._startTime}},{key:"startTime",get:function(){return this._startTime}},{key:"endTime",get:function(){return this._endTime}}])}(),FH=function(){function e(t){r(this,e),ER(this,"_room",null),ER(this,"_durationMap"),ER(this,"_eventMap",new Map),this._room=t.room,this._durationMap=new Map,this.installEvents()}return a(e,[{key:"installEvents",value:function(){var e=this;this._eventMap.set(Sx.REMOTE_TRACK_SUBSCRIBED,this.handleSubscribed).set(Sx.REMOTE_TRACK_UNSUBSCRIBED,this.handleUnsubscribed).set(Sx.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"),yC.AUDIO),i.hasVideo&&!o.hasVideo&&e.stopDurationItem("".concat(a,"_main"),yC.VIDEO),i.hasAuxiliary&&!o.hasAuxiliary&&e.stopDurationItem("".concat(a,"_auxiliary"),yC.VIDEO);var s=null==(n=e._room)?void 0:n.remotePublishedUserMap.get(a);s&&(!i.hasAudio&&o.hasAudio&&s.remoteAudioTrack.isSubscribed&&e.addDuractionItem(a,yC.AUDIO,"main"),!i.hasVideo&&o.hasVideo&&s.remoteVideoTrack.isSubscribed&&e.addDuractionItem(a,yC.VIDEO,"main"),!i.hasAuxiliary&&o.hasAuxiliary&&s.remoteAuxiliaryTrack.isSubscribed&&e.addDuractionItem(a,yC.VIDEO,"auxiliary"))}})),this._eventMap.forEach((function(t,n){return Tx.on(n,t,e)}))}},{key:"uninstallEvents",value:function(){var e=this;this._eventMap.forEach((function(t,n){return Tx.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 VH,o=this._durationMap.get(r);o?this.isRecording(o[t])||o[t].push(i):this._durationMap.set(r,{userId:e,type:n,audio:t===yC.AUDIO?[i]:[],video:t===yC.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()}}])}(),BH=function(){function e(t){r(this,e),ER(this,"_room"),ER(this,"_renderFreezeMap",new Map),ER(this,"_isVideoPlayingEventFiredMap",new Map),ER(this,"_dataFreezeMap",new Map),ER(this,"_monitorFreezeData",new Map),ER(this,"_eventMap",new Map),this._room=t.room,this.installEvents()}return a(e,[{key:"getRenderFreezeMap",value:function(){return this._renderFreezeMap}},{key:"getDataFreezeMap",value:function(){return this._dataFreezeMap}},{key:"installEvents",value:function(){var e=this;this._eventMap.set(Sx.LEAVE_SUCCESS,(function(t){var n=t.room;e.hitTest(n)&&e.stop()})).set(Sx.PLAY_TRACK_START,this.onPlayTrackStart).set(Sx.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(Sx.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(Sx.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===yC.VIDEO){if("PLAYING"===r){var a="".concat(n.userId,"_").concat(n.streamType);e._isVideoPlayingEventFiredMap.set(a,!0)}i===yC.MUTE?e.onVideoTrackMuted(n):i===yC.UNMUTE&&e.onVideoTrackUnmuted(n)}})).set(Sx.HEARTBEAT_REPORT,this.onHearBeatReport),this._eventMap.forEach((function(t,n){return Tx.on(n,t,e)}))}},{key:"uninstallEvents",value:function(){var e=this;this._eventMap.forEach((function(t,n){return Tx.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 VH;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>rw?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 kR(this,arguments,(function(e){var t=this,n=e.userId,r=e.fps,i=e.type;return f().mark((function e(){var o,a,s,c,u;return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:o="".concat(n,"_").concat(i),a=t._renderFreezeMap.get(o),r<=2?(s=eD(),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=eD(),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===yC.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()<rw&&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=eD()-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()}}])}(),jH=gR(SR(),1),HH=[1,0,0,0,1,1,0,1],GH=function(e){function t(e,i){var o;if(r(this,t),o=n(this,t,[e,{useDefaultProgram:!0,useFbo:!0,create2d:!0,name:"mirror",logger:i}]),e instanceof DF)try{o.setTexBuffer(HH)}catch(KC){e.destroy(new LR({code:PR.VIDEO_MANAGER_ERROR,extraCode:3,message:"create video node ".concat(o.name," error ").concat(KC.message||KC)}))}return o}return d(t,e),a(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=g(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))}}])}(_F),WH=function(){function e(t,n){r(this,e),this.node=t,this.layout=n,ER(this,"positionBuffer")}return a(e,[{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}}])}(),JH=function(e){function i(e,o){var a;return r(this,i),a=n(this,i,[e,{useDefaultProgram:!0,useFbo:!0,name:"mix",create2d:!0,logger:o}]),ER(t(a),"inputs",[]),a}return d(i,e),a(i,[{key:"addInput",value:function(e,t){if(this.inputs[t.zIndex])throw new Error("input already exists");var n=new WH(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 DF&&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,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},pR({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 DF))try{null==(r=e.context.ctx)||r.deleteBuffer(t.positionBuffer)}catch(Ux){}}))}}])}(_F),zH=function(e){function i(e,o){var a;r(this,i),a=n(this,i,[e,o.input,{name:"vb",create2d:!1,useDefaultProgram:!1,useFbo:!1,createTexture:!0,logger:e.log}]),ER(t(a),"_bgTexture"),ER(t(a),"_waterMarkTexture"),ER(t(a),"_lastMaskTexture"),ER(t(a),"_lastMaskFbo"),ER(t(a),"_textureValid",!1),ER(t(a),"_selfieTextureValid",!1),ER(t(a),"_selfieSegmentation"),ER(t(a),"wasm"),ER(t(a),"_prePrograme"),ER(t(a),"_segmentationMask"),ER(t(a),"_weixin",!1),o.selfieSegmentation&&(a._selfieSegmentation=o.selfieSegmentation,a._selfieSegmentation.onResults=a.onPredict.bind(t(a)));try{a.init(o)}catch(Px){e.log.error(Px),e.destroy(new LR({code:PR.VIDEO_MANAGER_ERROR,extraCode:6,message:"init vb node error ".concat(Px.message||Px)}))}return a}return d(i,e),a(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,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;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()}}])}(AF),KH=function(e){function i(e){var o;r(this,i),o=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 }"}]),ER(t(o),"yTextureRef"),ER(t(o),"uTextureRef"),ER(t(o),"vTextureRef"),ER(t(o),"Y"),ER(t(o),"U"),ER(t(o),"V"),o.useProgram();var a=o.context.ctx;return a.pixelStorei(a.PACK_ALIGNMENT,1),a.pixelStorei(a.UNPACK_ALIGNMENT,1),o.setTexBuffer([0,1,1,1,0,0,1,0]),o.yTextureRef=o._initTexture("ySampler",0),o.uTextureRef=o._initTexture("uSampler",1),o.vTextureRef=o._initTexture("vSampler",2),o._canvas=e._canvas,o}return d(i,e),a(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)}}])}(_F),qH=[function(e){e.codec="avc1.420028"},function(e){delete e.hardwareAcceleration}],YH=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")},XH=0,QH=function(){function e(t){var n=this;r(this,e),ER(this,"id",XH++),ER(this,"trackDoneOB"),ER(this,"startOB"),ER(this,"stopOB"),ER(this,"decoder"),ER(this,"videoContext"),ER(this,"gop",0),ER(this,"gop_helper",0),ER(this,"waitFirstKeyFrame",!0),ER(this,"startTimestamp",0),ER(this,"startTime",0),ER(this,"startPerformanceTime",0),ER(this,"inputFrameCount",0),ER(this,"decodedFrameCount",0),ER(this,"decodeFrameCount",0),ER(this,"downgradeLevel",0),ER(this,"lastDowngradeTime",0),ER(this,"lastFrameDiff",0),ER(this,"lastDecodeFrameTimestamp",0),ER(this,"config"),ER(this,"gop_before_configure",[]),ER(this,"videoElement"),ER(this,"type","wasm"),ER(this,"goodType"),ER(this,"renderer","2d"),ER(this,"wasmOption"),ER(this,"createDecoder"),ER(this,"_decodeSink"),ER(this,"isReported",!1),ER(this,"track"),ER(this,"stateChangeOB"),ER(this,"failedReason");var i=t.track,o=t.createDecoder;if(this.stateChangeOB=NU(),this.track=i,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=jU(i.availableState,KP.OFF),this.stopOB=NU(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),lU(this.stateChangeOB,NV((function(e,t){return e!==t&&i.onDecodeDowngradeStateChanged({type:n.type,renderer:n.renderer,reason:n.failedReason,prevState:e,state:t}),t}),"INITIALIZED"),uV(this.stopOB),cF()),this.start()}return a(e,[{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=lU(this.pipe(this.track),uV(this.stopOB),gU());lU(n,cF((function(){e.track.stat.framesDecoded++}),(function(n){if(e.track.log.error("".concat(e.id," play failed: ").concat(n," retryCount: ").concat(t)),GO.addFailedEvent({key:YH(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")),GO.addSuccessEvent({key:YH(e.type,e.renderer)}),GO.addSuccessEvent({key:514704})}))),lU(n,cV(1),cF((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&&!$O()&&(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,a=new Uint8Array(e.data);if(0!==(o=a)[0]||0!==o[1]||0!==o[2]||1!==o[3]||a.length<5)return this.stateChangeOB.next("FAILED"),this.close("not h26x frame ".concat(a.subarray(0,5))),e;var s=!1;switch(31&a[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(a.subarray(0,5).join(" ")));this.waitFirstKeyFrame=!1,this.startTimestamp=c,this.startTime=Date.now(),this.startPerformanceTime=eD()}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 kR(t,null,f().mark((function t(){var r,i,o,a,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})),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:27;break;case 9:return r=this.createDecoder(a,this.wasmOption),t.abrupt("break",28);case 11:s=0;case 12:if(!(s<=qH.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!==qH.length){t.next=21;break}return t.abrupt("return",void n.error(3));case 21:qH[s](this.config);case 22:s++,t.next=12;break;case 25:return r=this.createDecoder(a),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"===a?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"===a&&"webgl"===o?(this.videoContext=new DF({frameRate:15,logger:e.log,name:e.userId}),this.videoContext.create(),this.videoContext.on(DF.UNAVAILABLE,(function(t){e.log.error(t),n.error(7)})),u=new KH(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"===o?(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 NF({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 EF(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"===a?2:6);case 42:case"end":return t.stop()}}),t,this,[[5,39]])})))}}}])}(),$H=function(e){function i(e){var o;return r(this,i),(o=n(this,i)).room=e,ER(t(o),"videoContext"),ER(t(o),"_glVideoContext"),ER(t(o),"_2dVideoContext"),ER(t(o),"destination"),ER(t(o),"smallVideoContext"),ER(t(o),"smallDestination"),ER(t(o),"smallTrackSource"),ER(t(o),"smallImageSource"),ER(t(o),"_isMirror",!1),ER(t(o),"cameraTrack"),ER(t(o),"cameraNode"),ER(t(o),"mirrorNode"),ER(t(o),"mixNode"),ER(t(o),"screenTrack"),ER(t(o),"screenNode"),ER(t(o),"selfModel",!1),ER(t(o),"blurRadius",3),ER(t(o),"arTrack"),ER(t(o),"Wasm"),ER(t(o),"waterMarkNode"),ER(t(o),"_waterMarkOption"),ER(t(o),"watermarkImageList",[]),ER(t(o),"_beautyParams"),ER(t(o),"isUsingArTrack",!1),ER(t(o),"_isMixScreen",!1),ER(t(o),"_virtualBackground"),ER(t(o),"_virtualBackgroundAbortCallback"),ER(t(o),"virtualBackgroundInstance"),ER(t(o),"_bgAssetPath"),ER(t(o),"log",bx.createLogger({id:"vm"})),ER(t(o),"_checkId",0),ER(t(o),"_use2d",!1),ER(t(o),"_autoSwitchRenderMode",!0),ER(t(o),"_selfieSegmentation"),ER(t(o),"encodePipeline",[]),ER(t(o),"decodePipeline",[]),e&&(o.log.setUserId(e.userId),o.log.setSdkAppId(e.sdkAppId)),o.smallVideoContext=new NF({frameRate:15,logger:o.log,name:"s"}),o.enablePrintDetail(),o}return d(i,e),a(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 NF({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 DF({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(DF.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(zR){this.emit("error",zR)}}},{key:"enablePrintDetail",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:2e3;this._checkId=ZP.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(),ZP.clearTask(this._checkId)}},{key:"needAlpha",get:function(){return this._hasWaterMark||this._hasVirtualBg}},{key:"active",get:function(){return(QN||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?GO.addFailedEvent({key:t,error:e}):GO.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 DF({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 SF(this.smallVideoContext,e,this.log),this.smallVideoContext.on(DF.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),QN&&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(Px){this.log.error("set main output failed",Px)}}},{key:"update",value:function(){return kR(this,null,f().mark((function e(){var t,n,r,i,o,a;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,o=r.profile,this._use2d||!this._virtualBackground&&!this._beautyParams?(this.destination||(this.destination=this.videoContext.createVideoTrackDestination({name:"mainDestination2d",logger:this.log})),16===tx?this.initialTrack instanceof CanvasCaptureMediaStreamTrack?(this.cameraNode&&(this.cameraNode instanceof AF?(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 AF?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 kF(this.videoContext,{name:"mainDestination",logger:this.log}),this.cameraNode=new zH(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 GH(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 JH(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 KL)return this.log.info("change screen input",null==(t=e.mediaTrack)?void 0:t.label),this.setScreenTrack(e);if(e instanceof WL)return this.log.info("change video input",null==(n=e.mediaTrack)?void 0:n.label),this.setCameraTrack(e);if(e instanceof xF){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 KL?(null==(t=this.screenNode)||t.close(),delete this.screenNode,delete this.screenTrack,this.update()):e instanceof WL?(this.clear(),delete this.cameraTrack,this.smallImageSource&&(this.smallImageSource.close(),delete this.smallImageSource),this.smallTrackSource&&(this.smallTrackSource.close(),delete this.smallTrackSource)):e instanceof xF&&e.source&&e.source.context.destroy()}},{key:"setCameraTrack",value:function(e){return kR(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 kR(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 LR({code:PR.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)})),_D(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 kR(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 kR(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 kR(this,null,f().mark((function t(){var n,r,i,o,a,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,_D((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 LR({code:PR.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,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: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 kR(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 kR(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 kR(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,_D(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 LR({code:PR.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 kR(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 QH(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}}])}(jH.EventEmitter);yR([AL((function(e){this.log.error("update failed",e)}))],$H.prototype,"update",1);var ZH=0,eG=function(e){function i(e){var o;return r(this,i),o=n(this,i,["room"]),ER(t(o),"seq",++ZH),ER(t(o),"sdkAppId"),ER(t(o),"userId"),ER(t(o),"userSig"),ER(t(o),"privateMapKey"),ER(t(o),"latencyLevel"),ER(t(o),"tinyId"),ER(t(o),"scene"),ER(t(o),"roomId"),ER(t(o),"useStringRoomId"),ER(t(o),"role","anchor"),ER(t(o),"joinParams",null),ER(t(o),"localTracks",new Set),ER(t(o),"enableAutoPlayDialog",!0),ER(t(o),"autoReceiveAudio",!0),ER(t(o),"autoReceiveVideo",!0),ER(t(o),"proxy_ws"),ER(t(o),"proxy_wt"),ER(t(o),"proxy_unified"),ER(t(o),"checkSystemResult",{result:!0,detail:{isBrowserSupported:!0,isWebRTCSupported:!0,isWebCodecsSupported:!0,isMediaDevicesSupported:!0,isScreenShareSupported:!0,isSmallStreamSupported:!0,isH264EncodeSupported:!0,isVp8EncodeSupported:!0,isH264DecodeSupported:!0,isVp8DecodeSupported:!0}}),ER(t(o),"keyPointManager"),ER(t(o),"audioManager"),ER(t(o),"videoManager"),ER(t(o),"callDurationCalculator"),ER(t(o),"badCaseDetector"),ER(t(o),"scheduleResult",{domains:null,iceServers:null,iceTransportPolicy:null,trtcAutoConf:null}),ER(t(o),"videoDecodeFallbackType"),ER(t(o),"_isUsingCachedSchedule",!1),ER(t(o),"_log",bx.createLogger({id:"r".concat(o.seq)})),ER(t(o),"_joinedTimestamp",0),ER(t(o),"_sdkType"),ER(t(o),"heartbeatReport"),ER(t(o),"quality"),ER(t(o),"enableSEI"),ER(t(o),"isDestroyed",!1),o.useStringRoomId=!!e.useStringRoomId,Ww(e.autoReceiveAudio)&&(o.autoReceiveAudio=e.autoReceiveAudio),Ww(e.autoReceiveVideo)&&(o.autoReceiveVideo=e.autoReceiveVideo),Ww(e.enableAutoPlayDialog)&&(o.enableAutoPlayDialog=e.enableAutoPlayDialog),o._sdkType=e.sdkType,o.keyPointManager=new UH({room:t(o),frameWorkType:e.frameWorkType,component:e.component,language:e.language}),o.callDurationCalculator=new FH({room:t(o)}),o.badCaseDetector=new BH({room:t(o)}),o.audioManager=new QL(t(o)),o.videoManager=new $H(t(o)),o}return d(i,e),a(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 kR(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 kR(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 kR(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(Hw(e))e.startsWith("wss://")?this.proxy_ws=e:e.startsWith("https://")&&(this.proxy_wt=e);else if(Lw(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?(IB([a,a]),$R("https://".concat(a))):(i&&$R(i),o&&IB(o))}Tx.once(Sx.JOIN_RECEIVED_CMD_RES,(function(){return t.sendAbilityStatus({sched_domain:SB.main,sched_back_domain:SB.backup,signal_domain:t.proxy_ws||t.proxy_wt||""})}))}},{key:"getRemoteAudioStats",value:function(){return kR(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 kR(this,null,f().mark((function e(){var t,n,r,i,o;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;)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 kR(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 LR({code:PR.INVALID_OPERATION,message:OO({key:wO.CLIENT_DESTROYED,data:{funName:"join"}})})}},{key:"destroy",value:function(){if(this.isJoined)throw this._log.warn(DO.INVALID_DESTROY),new LR({code:PR.INVALID_OPERATION,message:OO({key:wO.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,Tx.emit(Sx.ROOM_DESTROY,{room:this})}},{key:"schedule",value:function(e,t){return kR(this,null,f().mark((function n(){var r,i,o,a,s,c,u,l,d=this;return f().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return a=eD(),n.prev=1,n.next=4,kB({userId:this.userId,sdkAppId:this.sdkAppId,roomId:this.useStringRoomId?e.strRoomId:e.roomId,useStringRoomId:this.useStringRoomId,version:WR,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(fD(u,{keysToExclude:["username","credential"]}))),c&&Tx.once(Sx.JOIN_RECEIVED_CMD_RES,(function(){return d.sendAbilityStatus({scheduleCache:1})})),this.scheduleResult=pR(pR({},this.scheduleResult),u),Gw(null==(r=u.config)?void 0:r.retryCount)&&JC(u.config.retryCount),Hw(null==(i=u.config)?void 0:i.loggerDomain)&&$R(u.config.loggerDomain),this.videoDecodeFallbackType=(null==(o=u.config)?void 0:o.videoDecodeFallback)||this.videoDecodeFallbackType,Tx.emit(Sx.JOIN_SCHEDULE_SUCCESS,{room:this,schedule:this.scheduleResult,detailCost:l}),GO.addSuccessEvent({key:521700,cost:eD()-a,split:50}),n.next=14;break;case 11:throw n.prev=11,n.t0=n.catch(1),GO.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()}}])}(KP),tG=gR(SR()),nG=gR(NR());function rG(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 iG=function(e,t){return kR(void 0,null,f().mark((function n(){var r,i,o,a,s,c,u;return f().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return i=TH(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=E(rG(s)).filter((function(e){return u.includes(e.codec.toLocaleLowerCase())})),n.next=11,function(){return kR(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(yC.VIDEO,{direction:yC.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=rG(TH(n.sdp).media[0]),e.abrupt("return",(t.close(),r));case 9:case"end":return e.stop()}}),e)})))}();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)})))},oG=function(e){var t=e.serverAbility,n=e.clientAbility,r=e.offerSDP,i=e.enableCustomMessage,o=TH(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:yC.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:yC.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(aG({mid:e,serverAbility:t,clientAbility:n,parsedOffer:o}))})),i&&a.media.push(o.media.find((function(e){return"dc"===e.mid}))),kH(a)},aG=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:yC.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:yC.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){sG(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];sG(s,l)}return s},sG=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}))},cG=function(e,t,n){var r=nG.default.parse(e);return r.media.forEach((function(e,i){var o;if((e.type===yC.AUDIO||e.type===yC.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===yC.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===yC.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===yC.VIDEO))if(i<4)e.payloads="",e.fmtp=[],e.rtp=[],e.rtcpFb=[],t.video.codecs.forEach((function(t){return sG(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 sG(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")})),nG.default.write(r)},uG=function(e){function i(e){var o;return r(this,i),(o=n(this,i)).room=e,ER(t(o),"mainFpsHealth",1),ER(t(o),"mainBitrateHealth",1),ER(t(o),"badMainBitrateHealthCount",0),ER(t(o),"lastEmitBadHealthTime",0),ER(t(o),"log"),!GD&&JN&&Tx.on("262",o.onVideoCodecChanged,t(o)),o.log=e.getLogger().createChild({id:"h-d"}),o}return d(i,e),a(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(){Tx.off("262",this.onVideoCodecChanged,this),this.room.off("heartbeat-report",this.onHeartbeatReport,this)}}])}(gR(SR()).EventEmitter);ER(uG,"EVENT_BAD_HEALTH","bad_health");var lG=uG;function dG(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 hG(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 fG=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}(fG||{}),pG=0,mG=!1,vG=new Set,_G=1,gG=function(e){function i(e){var o;r(this,i);var a=e.signalChannel,s=e.room,c=e.enableCustomMessage;return o=n(this,i),ER(t(o),"stat",{iceStartTime:0,iceEndTime:0,dtlsStartTime:0,dtlsEndTime:0,peerConnectionStartTime:0,peerConnectionEndTime:0}),ER(t(o),"currentState","DISCONNECTED"),ER(t(o),"_room"),ER(t(o),"_signalChannel"),ER(t(o),"_peerConnection",null),ER(t(o),"_datachannel",null),ER(t(o),"_enableCustomMessage"),ER(t(o),"_log"),ER(t(o),"_downlinkMIDMap",new Map),ER(t(o),"_downlinkMIDUserIDMap",new Map),ER(t(o),"_reconnectionTimer",-1),ER(t(o),"reconnectionCount",0),ER(t(o),"clientAbility"),ER(t(o),"_serverAbility",null),ER(t(o),"addDownlinkQueue",new Set),ER(t(o),"removeDownlinkQueue",new Set),ER(t(o),"_parsedAnswer",null),ER(t(o),"_updateSDPPromise",null),ER(t(o),"_waitForPCConnectedPromise"),ER(t(o),"clearConnectTimeout"),ER(t(o),"_isSDPLogged",!1),ER(t(o),"enableInsertableStreams",!1),ER(t(o),"insertableStreamsAbortMap",new Map),ER(t(o),"receiverRemoteTrackMap",new WeakMap),ER(t(o),"scriptTransformWorker"),ER(t(o),"_isRelayTried",!1),ER(t(o),"_rttOverCount",0),ER(t(o),"originOffer",null),o._room=s,o._enableCustomMessage=c,o._signalChannel=a,o._log=bx.createLogger({id:"spc".concat(_G++),userId:o._room.userId,sdkAppId:o._room.sdkAppId}),o._room.enableCodecPipeline&&(bP?o.enableInsertableStreams=!0:o.initScriptTransformWorker()),o._room.healthDetector.on("1",o.onBadHealth,t(o)),o}return d(i,e),a(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=TH(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&&!jw(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;AP&&(this.scriptTransformWorker=function(e){var t=[jL],n=[tj,ZB,ej,$B,dG,hG],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?hG(i.userId,i.streamType,i.isAudio):dG({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 kR(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(),GO.addSuccessEvent({key:521711,cost:i.stat.iceEndTime-i.stat.iceStartTime})):"failed"===e&&GO.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 EG(e.data);i.emit("data_channel_msg",{data:t})},this._datachannel.onerror=function(e){i._log.warn("datachannel error",e)}),this._peerConnection.addTransceiver(yC.AUDIO,{direction:yC.TRANSCEIVER_DIRECTION_SENDONLY}),this._peerConnection.addTransceiver(yC.VIDEO,{direction:yC.TRANSCEIVER_DIRECTION_SENDONLY}),this._peerConnection.addTransceiver(yC.VIDEO,{direction:yC.TRANSCEIVER_DIRECTION_SENDONLY}),this._peerConnection.addTransceiver(yC.VIDEO,{direction:yC.TRANSCEIVER_DIRECTION_SENDONLY}),t.next=13,this._peerConnection.createOffer();case 13:return r=t.sent,t.next=16,iG(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()))}),GO.addSuccessEvent({key:521707}),t.abrupt("return",this.clientAbility);case 23:throw t.prev=23,t.t0=t.catch(0),GO.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 kR(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(KC){this._log.warn("setPriority error ",KC)}}},{key:"connect",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return kR(this,null,f().mark((function n(){var r,i,o,a,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 a=eD(),s={type:"answer",sdp:oG({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||GO.addSuccessEvent({key:521703,cost:eD()-a}),n.next=21;break;case 17:throw n.prev=17,n.t1=n.catch(0),(u=n.t1 instanceof LR&&n.t1.code===PR.API_CALL_ABORTED)||this._log.error("connect failed: ".concat(n.t1),e),this.reset(),!u&&!this.isReconnecting&&(GO.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 kR(this,null,f().mark((function e(){var t,n,r,i,o,a=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(wj,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=pR({ability:n},t),e.next=12,this._signalChannel.sendWaitForResponse({command:oH,responseCommand:Mj.REBUILD_PEER_CONNECTION_RES,data:r,enableLog:!1});case 12:if(0===(i=e.sent).data.code){e.next=15;break}throw new LR({code:i.data.code,message:i.data.message});case 15:return e.next=17,this.connect(i.data.data.ability,!0);case 17:GO.addSuccessEvent({key:521704}),this._log.warn("reconnect() success"),this.stopReconnection(),Tx.emit(Sx.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 o=Vw(this.reconnectionCount),this._log.warn("reconnect() timeout, try again after ".concat(o/1e3,"s")),e.next=33,ED(o,(function(e){a._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)),GO.addFailedEvent({key:521704,error:e.t0}),this.reconnectionCount>=zC()&&this._log.warn("SDK has tried reconnect for ".concat(zC()," 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 kR(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(wj,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)===GC.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===GC.CONNECTING&&(0===this.stat.peerConnectionStartTime&&(this.stat.peerConnectionStartTime=Date.now()),this.emitConnectionStateChangedEvent("CONNECTING")),(e.target.connectionState===GC.FAILED||e.target.connectionState===GC.CLOSED)&&(this.emitConnectionStateChangedEvent("DISCONNECTED"),this._room.forceRelay?this.switchRelay(!1):this.startReconnection()),(e.target.connectionState===GC.CONNECTED||e.target.connectionState===GC.COMPLETED)&&(0===this.stat.peerConnectionEndTime&&(this.stat.peerConnectionEndTime=Date.now()),Tx.emit(Sx.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 HC;var e=null;return pP()&&0!==this._peerConnection.getSenders().length?(e=this._peerConnection.getSenders()[0].transport,fP()&&0!==this._peerConnection.getReceivers().length&&e?e.state:HC):HC}},{key:"emitConnectionStateChangedEvent",value:function(e){e!==this.currentState&&("RECONNECTING"===this.currentState&&"CONNECTING"===e||(this.emit(fG.CONNECTION_STATE_CHANGED,{prevState:this.currentState,state:e}),this.currentState=e))}},{key:"logSelectedCandidate",value:function(){return kR(this,null,f().mark((function e(){var t,n,r,i,o,a,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],o=i[1],!aP(o)){e.next=14;break}return a=t.get(o.localCandidateId),c=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&&Rw(a.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(a),o(),t())},i=function(t){t.room===e._room&&(clearTimeout(a),o(),n(new LR({code:PR.API_CALL_ABORTED,message:OO({key:wO.CONNECTION_ABORTED,data:"leave room"})})))},o=function(){Tx.off(Sx.LEAVE_SUCCESS,i,e),e.off(fG.CONNECTION_STATE_CHANGED,r,e)},a=setTimeout((function(){o();var t,r=new LR({code:PR.API_CALL_TIMEOUT,message:"connection timeout"});pG+=1,t=e._signalChannel.isConnected,pG>2&&!mG&&0===vG.size&&t&&(e._log.warn("firewall restriction"),mG=!0,e.emit(fG.FIREWALL_RESTRICTION)),n(r)}),sw);e.clearConnectTimeout=function(){o(),clearTimeout(a),delete e.clearConnectTimeout},Tx.on(Sx.LEAVE_SUCCESS,i,e),e.on(fG.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 kR(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=yC.TRANSCEIVER_DIRECTION_RECVONLY,Number(e.mid)}));this._parsedAnswer||(this._parsedAnswer=TH(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(yC.AUDIO,{direction:yC.TRANSCEIVER_DIRECTION_RECVONLY}),this._peerConnection.addTransceiver(yC.VIDEO,{direction:yC.TRANSCEIVER_DIRECTION_RECVONLY}),this._peerConnection.addTransceiver(yC.VIDEO,{direction:yC.TRANSCEIVER_DIRECTION_RECVONLY}),o=JSON.parse(JSON.stringify(this._parsedAnswer.media[0]));var u=aG({mid:1,serverAbility:this._serverAbility,clientAbility:this.clientAbility,parsedOffer:TH(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=yC.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(yC.MAIN," ").concat(l,"-audio")}],a.direction=yC.TRANSCEIVER_DIRECTION_SENDONLY,a.ssrcs=[{id:t.video,attribute:"cname",value:"".concat(l)},{id:t.video,attribute:"msid",value:"".concat(l,"-").concat(yC.MAIN," ").concat(l,"-bigvideo")},{id:t.videoRtx,attribute:"cname",value:"".concat(l)},{id:t.videoRtx,attribute:"msid",value:"".concat(l,"-").concat(yC.MAIN," ").concat(l,"-bigvideo")}],a.ssrcGroups=[{semantics:"FID",ssrcs:"".concat(t.video," ").concat(t.videoRtx)}],s.direction=yC.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(yC.VIDEO)},{id:t.auxiliaryRtx,attribute:"cname",value:"".concat(d," ").concat(l,"-aux").concat(yC.VIDEO)},{id:t.auxiliaryRtx,attribute:"msid",value:"".concat(d," ").concat(l,"-aux").concat(yC.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 kR(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=TH(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 kR(this,null,f().mark((function t(){var n,r,i,o,a,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,o=e.auxVideo,t.prev=3,!TP()){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=void 0,u=a[s],0===s&&n?c=n:1===s&&r?c=r:2===s&&i?c=i:3===s&&o&&(c=o),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&&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=TH(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=TH(this._peerConnection.localDescription.sdp);this._parsedAnswer||(this._parsedAnswer=TH(this._peerConnection.remoteDescription.sdp));var a=KD?"TIAS":"AS";t&&(o.media[0].bandwidth=[{type:a,limit:KD?1e3*t:t}],this._parsedAnswer.media[0].bandwidth=[{type:a,limit:KD?1e3*t:t}]),n&&(o.media[1].bandwidth=[{type:a,limit:KD?1e3*n:n}],this._parsedAnswer.media[1].bandwidth=[{type:a,limit:KD?1e3*n:n}]),r&&(o.media[2].bandwidth=[{type:a,limit:KD?1e3*r:r}],this._parsedAnswer.media[2].bandwidth=[{type:a,limit:KD?1e3*r:r}]),i&&(o.media[3].bandwidth=[{type:a,limit:KD?1e3*i:i}],this._parsedAnswer.media[3].bandwidth=[{type:a,limit:KD?1e3*i:i}]);var s={type:"offer",sdp:kH(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(jw(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=kH(this._parsedAnswer);return this._updateSDPPromise=new Promise((function(r,i){return kR(e,null,f().mark((function e(){var o,a;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==(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 kR(this,null,f().mark((function n(){var r,i,o,a,c;return f().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(KD&&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();!(o=i.n()).done;)a=o.value,c=this._parsedAnswer.media[a].direction,e===EC.INACTIVE&&c===EC.RECVONLY&&(this._parsedAnswer.media[a].direction=e),e===EC.SENDONLY&&c===EC.INACTIVE&&(this._parsedAnswer.media[a].direction=EC.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 TH(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=cG(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 kR(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===yC.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=[],sG(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 kR(this,null,f().mark((function n(){var r,i,o=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=[],jw(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===yC.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=[],sG(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 bD(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 kR(this,null,f().mark((function n(){var r,i,o;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)),o=Date.now(),n.next=8,this.doSwitchRelay(r);case 8:this._log.warn("switchRelay ".concat(r," success")),GO.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),GO.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)}}])}(tG.default);yR([PL("reconnect")],gG.prototype,"startReconnection",1),yR([ML((function(e){return e.userId}))],gG.prototype,"addDownlink",1),yR([ML((function(e){return e}))],gG.prototype,"removeDownlink",1),yR([OL(!0)],gG.prototype,"updateSDP",1),yR([LL(521712,!1)],gG.prototype,"setOffer",1),yR([LL(521713,!1)],gG.prototype,"setAnswer",1);var yG=a((function e(t){r(this,e),ER(this,"tag"),ER(this,"len"),ER(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})),EG=a((function e(t){var n=this;r(this,e),ER(this,"tinyId"),ER(this,"data");for(var i=new DataView(t),o=0,a=[];o<i.byteLength;){var s=i.getUint16(o+2),c=new yG(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)}))})),TG=new Set;function kG(){var e=Math.floor(4294967296*Math.random());return TG.has(e)?kG():(TG.add(e),e)}var SG=function(e){function i(e){var o;return r(this,i),o=n(this,i),ER(t(o),"userId"),ER(t(o),"tinyId"),ER(t(o),"_sdpSemantics"),ER(t(o),"_isUplink"),ER(t(o),"_room"),ER(t(o),"_log"),ER(t(o),"_currentState","DISCONNECTED"),ER(t(o),"_prevTime",-1),o.userId=e.userId,o.tinyId=e.tinyId,o._room=e.room,o._sdpSemantics=e.room.sdpSemantics,o._isUplink=e.isUplink,o._log=bx.createLogger({id:"n",userId:o._room.userId,remoteUserId:o._isUplink?void 0:o.userId,sdkAppId:o._room.sdkAppId,isLocal:o._isUplink}),o}return d(i,e),a(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&&(Tx.emit(Sx.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"))}}])}(gR(SR()).default),IG=function(e){function i(e){var o;return r(this,i),o=n(this,i,[mR(pR({},e),{isUplink:!0})]),ER(t(o),"localMainAudioTrack",null),ER(t(o),"localMainVideoTrack",null),ER(t(o),"localAuxAudioTrack",null),ER(t(o),"localAuxVideoTrack",null),ER(t(o),"_isPublishingAux",!1),ER(t(o),"_publishingLocalAudioTrack"),ER(t(o),"_publishingLocalVideoTrack"),ER(t(o),"_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}),ER(t(o),"_flag",0),ER(t(o),"_checkPublishStateTimeoutId",-1),o.initialize(),o}return d(i,e),a(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=ZP.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(_x()," ").concat(fx())),GO.addCount({key:521e3})}ZP.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&&(mP()?(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===yC.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=pR({},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&AC),bigVideo:!!(this.flag&SC),smallVideo:!!(this.flag&IC),auxVideo:!!(this.flag&bC)}}},{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(o){r.e(o)}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,o,a=this._currentState,s=g(i,"emitConnectionStateChangedEvent",this,3)([e]);return s&&a!==e&&(t?t.emit("connection-state-changed",{prevState:a,state:e}):(null==(n=this.localMainVideoTrack)||n.emit("connection-state-changed",{prevState:a,state:e}),null==(r=this.localAuxVideoTrack)||r.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 kR(this,arguments,(function(e){var t=this,n=e.localAudioTrack,r=e.localVideoTrack,i=e.isAuxiliary;return f().mark((function e(){var o,a,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 LR({code:PR.NOT_SUPPORTED_H264,message:OO({key:wO.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=GD&&115===WN()&&r.profile.width*r.profile.height<=230400,!e.t1){e.next=20;break}return t._log.warn("fallback video to 480p"),r.setProfile(_C["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:sH,responseCommand:Mj.SPC_PUBLISH_RESULT,data:mR(pR({},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==(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(vP()){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(EC.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 kR(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(EC.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(EC.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 kR(this,arguments,(function(e){var t=this,n=e.localAudioTrack,r=e.localVideoTrack;return f().mark((function e(){var i,o,a,s;return f().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=mR(pR({},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=mR(pR({},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(EC.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 kR(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:Hj,data:n,responseCommand:Mj.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:Gj,commandDesc:"unpublish",responseCommand:Mj.UNPUBLISH_RESULT,enableLog:e}).catch((function(e){if(e.getCode()===PR.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),SP){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:iH,data:this._mediaSettings,responseCommand:Mj.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 kR(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?yC.AUXILIARY:yC.MAIN," stream")),t.t0=mP(),!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 kR(this,null,f().mark((function n(){var r,i,o;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!==yC.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===EC.INACTIVE,!n.t1){n.next=19;break}return n.next=19,this.singlePC.setTransceiverDirection(EC.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 kR(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?yC.AUXILIARY:yC.MAIN," stream")),t.t0=mP(),!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 kR(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!==yC.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(EC.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 kR(this,null,f().mark((function t(){var n,r,i,o;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(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?yC.AUXILIARY:yC.MAIN," stream")),t.t0=i.kind===yC.AUDIO&&r[0],!t.t0){t.next=9;break}return t.next=9,r[0].replaceTrack(i);case 9:if(t.t1=i.kind===yC.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 kR(this,arguments,(function(e){var t=this,n=e.bandwidth,r=e.type,i=e.videoType;return f().mark((function e(){var o;return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!t.singlePC){e.next=5;break}return o={},r===yC.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:Bj,responseCommand:Mj.MUTE_RESULT,data:this.muteState,retries:3}).catch((function(){})))}},{key:"handleConnectionStateChange",value:function(e){"CONNECTED"===e.state&&(this.localMainVideoTrack||this._publishingLocalVideoTrack&&!this._isPublishingAux)&&Tx.emit(Sx.SEND_FIRST_VIDEO_FRAME,{room:this._room})}},{key:"getVideoTrackId",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:yC.VIDEO;if(this._peerConnection){var t=this._peerConnection.getSenders();if(e===yC.AUXILIARY&&t[3]&&t[3].track)return t[3].track.id;if(e===yC.VIDEO&&t[1]&&t[1].track)return t[1].track.id}if(this.localMainVideoTrack&&e===yC.VIDEO){var n=this.localMainVideoTrack.mediaTrack;if(n)return n.id}if(this.localAuxVideoTrack&&e===yC.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===tw?(this._log.error(DO.NOT_SUPPORTED_H264ENCODE),new LR({code:PR.NOT_SUPPORTED_H264,message:OO({key:wO.NOT_SUPPORTED_H264ENCODE})})):new LR({code:PR.UNKNOWN,message:OO({key:wO.SIGNAL_RESPONSE_FAILED,data:{signalResponse:Mj.PUBLISH_RESULT,code:e,message:t}})})}},{key:"onSinglePCReconnected",value:function(){return kR(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)})))}}])}(SG);yR([bL((function(e){var t=e.localVideoTrack;null==t||t.once("6",this.onVideoEncodeFailed,this)}))],IG.prototype,"publish",1),yR([bL((function(e){var t=e.localVideoTrack;null==t||t.off("6",this.onVideoEncodeFailed,this)}))],IG.prototype,"unpublish",1);var bG=IG;function AG(e){return Object.keys(e).filter((function(t){return e[t]}))}var RG=function(e){function i(e){var o;return r(this,i),o=n(this,i,[mR(pR({},e),{isUplink:!1})]),ER(t(o),"_flag",0),ER(t(o),"isRobot",!1),ER(t(o),"role","anchor"),ER(t(o),"remoteAudioTrack"),ER(t(o),"remoteVideoTrack"),ER(t(o),"remoteAuxiliaryTrack"),ER(t(o),"ssrc",{audio:0,video:0,videoRtx:0,auxiliary:0,auxiliaryRtx:0}),ER(t(o),"jitterBufferTimeoutId",-1),o.flag=e.flag,o.isRobot=e.isRobot||!1,o.remoteAudioTrack=new pF(o._room,t(o)),o.remoteVideoTrack=new xF(o._room,t(o)),o.remoteAuxiliaryTrack=new OF(o._room,t(o)),o.initialize(),o}return d(i,e),a(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 oD(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===yC.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,o=g(i,"emitConnectionStateChangedEvent",this,3)([e]);return o&&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})),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=yC.AUDIO;i.kind===yC.VIDEO&&(s=a===yC.MAIN?yC.VIDEO:yC.AUXILIARY);var c=this.remoteAudioTrack;s===yC.VIDEO?c=this.remoteVideoTrack:s===yC.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===yC.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 kR(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(AG(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 LR({code:PR.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"),JN&&qN<92)return;this.singlePC.startReconnection()}}},{key:"unsubscribe",value:function(e){return kR(this,arguments,(function(e){var t=this,n=e.remoteTracks,r=e.streamType;return f().mark((function e(){var i,o,a;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 o=pR({},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(AG(o),"]")),"unsubscribe"===a&&(null==(i=t.singlePC)||i.removeDownlinkQueue.add(t.tinyId)),e.next=10,t.sendSubscription(a,o);case 10:if(e.t0="unsubscribe"===a,!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=Jj,o=Mj.UNSUBSCRIBE_RESULT;return"subscribe_change"===e&&(r={audio:n.audio,bigVideo:n.video,auxVideo:n.auxiliary,smallVideo:n.smallVideo,srcTinyId:this.tinyId},i=zj,o=Mj.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 LR({code:r.code,message:OO({key:wO.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 kR(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 kR(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,o,a,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:kG(),bigVideoSsrc:kG(),bigVideoRtxSsrc:kG(),auxVideoSsrc:kG(),auxVideoRtxSsrc:kG()},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:cH,responseCommand:Mj.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 LR({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,UP){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,(Gw(_)||Gw(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 kR(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(!UP||!this.singlePC||!this._peerConnection||AD(n)&&AD(r))return Promise.resolve();this._log.info("set jitterBuffer main: ".concat(n," aux: ").concat(r));var i=this.singlePC.getReceiversByUserId(this.userId);return Gw(n)&&(this.remoteAudioTrack.jitterBufferDelay=n,this.remoteVideoTrack.jitterBufferDelay=n),Gw(r)&&(this.remoteAuxiliaryTrack.jitterBufferDelay=r,AD(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||AD(n)&&e.track===t.remoteAudioTrack.outMediaTrack;if(!(o&&AD(r)||!o&&AD(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(KR){this._log.warn("set jitterBuffer delay error: ".concat(KR)),clearTimeout(this.jitterBufferTimeoutId),o()}}},{key:"audioReceiver",get:function(){var e;return(null==(e=this.singlePC)?void 0:e.getReceiversByUserId(this.userId)[0])||null}}])}(SG);yR([OL(),RL((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 LR({code:PR.API_CALL_ABORTED,message:OO({key:wO.CONNECTION_ABORTED,data:e})}))};t.on("closed",o),e.apply(t,r).then(n,i).finally((function(){t.off("closed",o)}))}))}}))],RG.prototype,"subscribe",1),yR([OL()],RG.prototype,"unsubscribe",1),yR([ML((function(){return"jitter"}))],RG.prototype,"setJitterBufferDelay",1);var CG=RG,wG=function(e){function i(e,o){var a;return r(this,i),(a=n(this,i)).room=e,a.signalChannel=o,ER(t(a),"log"),ER(t(a),"cmdIdSeqMap",new Map),ER(t(a),"messageMap",new Map),a.log=bx.createLogger({id:"cmm",userId:e.userId}),a.onReceiveMsg=a.onReceiveMsg.bind(t(a)),o.on(Mj.RECEIVE_CUSTOM_MSG,a.onReceiveMsg),a.room.on("peer-leave",(function(e){E(a.messageMap.keys()).forEach((function(t){t.split("_").slice(0,-1).join("_")===e&&a.messageMap.delete(t)}))})),a}return d(i,e),a(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(dH,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 o={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 a="".concat(r,"_").concat(o.cmdId),s=this.messageMap.get(a);if(s&&0!==s.lastSeq)if(Math.abs(s.lastSeq-o.seq)>i.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 t.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 t.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(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),ED(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 o=E(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)}}])}(gR(SR()).EventEmitter);ER(wG,"SEQ_INTERVAL",300);var DG,NG=wG,xG=jR.isString,OG=jR.isUndefined,PG=jR.getNetworkType,MG=jR.isEmpty,LG=function(e){function i(e){var o;return r(this,i),o=n(this,i,[e]),ER(t(o),"_businessInfo"),ER(t(o),"userManager"),ER(t(o),"_version"),ER(t(o),"_heartbeat",-1),ER(t(o),"_lastHeartBeatTime",-1),ER(t(o),"_stats"),ER(t(o),"_joinTimeout",-1),ER(t(o),"_firstPublishedList",null),ER(t(o),"_joinReject",null),ER(t(o),"_isRelayChanged",!1),ER(t(o),"sdpSemantics"),ER(t(o),"signalChannel",null),ER(t(o),"uplinkConnection",null),ER(t(o),"singlePC",null),ER(t(o),"enableSPC",_P),ER(t(o),"_changeBigSmallRecords",new Map),ER(t(o),"networkQuality"),ER(t(o),"_iceTransportPolicy"),ER(t(o),"forceRelay",!1),ER(t(o),"_turnServers",[]),ER(t(o),"_iceServersFromJoin"),ER(t(o),"_syncUserListInterval",-1),ER(t(o),"_smallStreamConfig",{bitrate:100,frameRate:15,height:120,width:160}),ER(t(o),"enableSEI",!1),ER(t(o),"_enableAudioVolumeEvaluation",!1),ER(t(o),"_audioVolumeIntervalId",0),ER(t(o),"_enableMultiAuxStream",!1),ER(t(o),"_pureAudioPushMode",!1),ER(t(o),"_customMessageManager"),ER(t(o),"preferHW",!1),ER(t(o),"healthDetector"),ER(t(o),"playoutDelay"),ER(t(o),"jitterBufferDelay"),ER(t(o),"_updateAudioLevelTaskId",-1),o._stats=new wH(t(o),o._log),o.userManager=new LF(o.userId,o._log),o._version=WR,o.sdpSemantics=ew,OG(e.sdpSemantics)?Cx.isUnifiedPlanDefault()&&(o.sdpSemantics=ZC):o.sdpSemantics=e.sdpSemantics,o._log.info("sdpSemantics: ".concat(o.sdpSemantics,", netType: ").concat(PG())),e.iceTransportPolicy&&(o._iceTransportPolicy=e.iceTransportPolicy),o._enableMultiAuxStream=!OG(e.enableMultiAuxStream)&&e.enableMultiAuxStream,o.enableSEI=e.enableSEI&&_P,!OG(e.enableSPC)&&_P&&(o.enableSPC=e.enableSPC),o.preferHW=!!e.preferHW,o._initBusinessInfo(e),o.healthDetector=new lG(t(o)),o}return d(i,e),a(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 kR(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)uR.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&sR){var i,o=s(sR(e));try{for(o.s();!(i=o.n()).done;)r=i.value,t.indexOf(r)<0&&lR.call(e,r)&&(n[r]=e[r])}catch(a){o.e(a)}finally{o.f()}}return n}(e,[]);Tx.emit(Sx.REMOTE_PUBLISH_STATE_CHANGED,pR({room:n},t)),n.emit("remote-publish-state-changed",pR({},t))})),this.joinParams=e,new Promise((function(t,r){return kR(n,null,f().mark((function n(){var i,o,a;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 LR&&n.t0.code===PR.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 a=eD(),n.next=18,this.doJoin(e,null==(o=this.singlePC)?void 0:o.clientAbility);case 18:GO.addSuccessEvent({key:521708,cost:eD()-a}),t(),this._firstPublishedList&&this.onPublishedUserList({data:{userList:this._firstPublishedList}}),n.next=26;break;case 23:n.prev=23,n.t1=n.catch(1),GO.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 kR(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 gG({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 LR({code:PR.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 kR(n,null,f().mark((function n(){var o,a,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(Nj,(function(e){l.clearJoinTimeout(),Tx.emit(Sx.JOIN_SIGNAL_CONNECTION_END,{room:l,error:e}),i(e)})),Ww(null==(a=null==(o=this.scheduleResult)?void 0:o.config)?void 0:a.singlePC)&&_P&&(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:gx(),netType:Cw(),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 LR({code:PR.JOIN_ROOM_FAILED,message:OO({key:wO.JOIN_ROOM_TIMEOUT})}))}),u),Tx.emit(Sx.JOIN_SEND_CMD,{room:this}),this.signalChannel.send(this.singlePC?aH:Uj,c),this.signalChannel.once(Mj.JOIN_ROOM_RESULT,(function(t){return kR(l,null,f().mark((function n(){var o,a,s,c,u;return f().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,Tx.emit(Sx.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(mR(pR({},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 LR({code:PR.JOIN_ROOM_FAILED,extraCode:a,message:OO({key:wO.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 kR(this,null,f().mark((function t(){var n,r,i,o=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(mR(pR({},this.joinParams),{role:"anchor"===this.role?20:21,privateMapKey:this.privateMapKey,latencyLevel:this.latencyLevel}),n);case 10:if(this._log.warn("reJoin success"),oM.logSuccessEvent({userId:this.userId,eventType:YC.REJOIN}),!this.singlePC){t.next=15;break}i=function(e){var t;"CONNECTED"===e.state&&(null==(t=o.singlePC)||t.off(fG.CONNECTION_STATE_CHANGED,i),o.uplinkConnection instanceof bG&&(o.uplinkConnection.installEvents(),o.uplinkConnection.onSinglePCReconnected()),o.remotePublishedUserMap.forEach((function(e){e.installEvents(),e.onSinglePCReconnected()})))},this.singlePC.on(fG.CONNECTION_STATE_CHANGED,i),this.checkConnectionsToReconnect(),this.uplinkConnection instanceof CH&&!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(),oM.logFailedEvent({userId:this.userId,eventType:YC.REJOIN,error:t.t0}),this.emit("error",new LR({code:PR.JOIN_ROOM_FAILED,message:OO({key:wO.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 kR(this,null,f().mark((function e(){var t,n,r,i,o,a,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,o=this.signalChannel||function(e){return E(hH.values()).find((function(t){return t.room.userId===e&&!t.room.isJoined}))||null}(this.userId),a=!!(o&&o.isConnected&&o.keepAlive&&o.userId===this.userId),Array.isArray(this.scheduleResult.domains)&&this.scheduleResult.domains.length>0&&(t=this.scheduleResult.domains[0]),this._log.info("".concat(a?"reuse":"setup"," signal channel")),a?(o.url=r,o.backupUrl=i,o.room=this,this.signalChannel=o):(o&&o.close(),this.signalChannel=new fH({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 NG(this,this.signalChannel),this._customMessageManager.on("message",(function(e){s.emit("custom-message",e)}))),this.networkQuality||(this.networkQuality=new xH({signalChannel:this.signalChannel,room:this}),this.networkQuality.on(xH.EVENT_NETWORK_QUALITY,(function(e){var t;s.emit("network-quality",e),null==(t=s.singlePC)||t.detectTCPAndUDP(e)}))),rM(this,this.signalChannel).add(Cj,(function(e){Tx.emit(Sx.SIGNAL_CONNECTION_STATE_CHANGED,pR({room:s},e)),s.emit("signal-connection-state-changed",e)})).add(Dj,(function(e){s.reset(),s.emit("error",e)})).add(Mj.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(Mj.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(Mj.UPDATE_REMOTE_MUTE_STAT,(function(e){s._lastHeartBeatTime>0&&Date.now()-s._lastHeartBeatTime>=1e4&&s.doHeartbeat(),s.onPublishedUserList(e.data)})).add(Mj.CLIENT_BANNED,(function(e){var t=e.data.data.reason;if(oM.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(Rj,(function(e){s.tinyId=e.signalInfo.tinyId,Tx.emit(Sx.JOIN_SIGNAL_CONNECTION_END,{room:s})})),Tx.emit(Sx.JOIN_SIGNAL_CONNECTION_START,{room:this}),e.next=10,this.signalChannel.connect();case 10:return a&&Tx.emit(Sx.JOIN_SIGNAL_CONNECTION_END,{room:this}),e.abrupt("return",a);case 12:case"end":return e.stop()}}),e,this)})))}},{key:"setSignalChannel",value:function(e){this.signalChannel=e,e||iM(this)}},{key:"leave",value:function(){return kR(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"),Tx.emit(Sx.LEAVE_SEND_CMD,{room:this}),null==(t=this.signalChannel)||t.send(Vj);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=ZP.run("ric",this.doHeartbeat.bind(this),{delay:2e3}))}},{key:"stopHeartbeat",value:function(){-1!==this._heartbeat&&(this._log.info("stopHeartbeat"),ZP.clearTask(this._heartbeat),this._heartbeat=-1,this._lastHeartBeatTime=-1)}},{key:"doHeartbeat",value:function(){return kR(this,null,f().mark((function e(){var t,n,r,i,o,a;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(PF.has(e)){var t=PF.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 PF.delete(e),t}return[]}(this.userId):[],o=mR(pR({str_sdk_version:GR,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:pR({uint32_terminal_type:15,str_device_name:navigator.platform,str_os_version:"",uint32_net_type:Cw()},r.msg_device_info)}),this.heartbeatReport=o,Tx.emit(Sx.HEARTBEAT_REPORT,{room:this,report:o}),this.signalChannel&&(this.signalChannel.isConnected&&(this.signalChannel.send(Fj,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",mR(pR({},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!==DC})).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})})),Tx.emit(Sx.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 CH&&(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?CG:bH)({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!==PR.ICE_TRANSPORT_ERROR&&(r===PR.DOWNLINK_RECONNECTION_FAILED&&n.closeDownLinkConnection(t),n.emit("error",e))})),e.on("connection-state-changed",(function(t){n.emit("media-connection-state-changed",mR(pR({},t),{userId:e.userId}))})),e.on("firewall-restriction",(function(){n.emit("firewall-restriction")}))}},{key:"startSyncUserListInterval",value:function(){-1===this._syncUserListInterval&&(this._syncUserListInterval=ZP.run("ric",this.syncUserList.bind(this)))}},{key:"stopSyncUserListInterval",value:function(){ZP.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:nH,responseCommand:Mj.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 OO({key:wO.SIGNAL_RESPONSE_FAILED,data:{signalResponse:Mj.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||!gH)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)===GC.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 yH&&!e.getIsReconnecting()){var n=e.getPeerConnection();n&&n.connectionState===GC.CLOSED&&(t._log.warn("[".concat(e.getUserId(),"] pc is closed but not reconnect")),e.startReconnection())}}))}},{key:"fallbackToMPC",value:function(){return kR(this,null,f().mark((function e(){var t,n,r,i,o,a;return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._log.warn("fallback to multi pc"),oM.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 CH({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(o=i[r],a=new bH({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),g(i,"destroy",this,3)([]),this._joinReject&&(this._joinReject(new LR({code:PR.INVALID_OPERATION,message:OO({key:wO.CLIENT_DESTROYED,data:{funName:"join"}})})),this.clearJoinTimeout(),this.reset()),this.removeAllListeners(),this.healthDetector.destroy(),ZP.clearTask(this._audioVolumeIntervalId))}},{key:"switchRole",value:function(e){return kR(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:rH,data:{role:"anchor"===e?20:21,privateMapKey:this.privateMapKey,latencyLevel:this.latencyLevel},responseCommand:Mj.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 LR({code:PR.SWITCH_ROLE_FAILED,message:OO({key:wO.SWITCH_ROLE_FAILED,data:{message:o,code:i}})});t.role=e})).catch((function(e){throw e instanceof LR&&e.getCode()===PR.API_CALL_TIMEOUT&&(e=new LR({code:PR.SWITCH_ROLE_FAILED,message:OO({key:wO.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 kR(this,null,f().mark((function e(){var n,r,i,o,a,s=this;return f().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n={},r={},t.forEach((function(e){e instanceof BL&&(e instanceof YL?r.audio=e:n.audio=e),e instanceof WL&&(e instanceof KL&&2===e.mediaType?r.video=e:n.video=e)})),i=MG(n),o=MG(r),(!i||!o)&&!this.uplinkConnection&&(this.singlePC?this.uplinkConnection=new bG({userId:this.userId,tinyId:this.tinyId,room:this}):this.uplinkConnection=new CH({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",mR(pR({},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!==PR.ICE_TRANSPORT_ERROR&&(t===PR.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 kR(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 BL&&(e instanceof YL?r.audio=e:n.audio=e),e instanceof WL&&(e instanceof KL&&2===e.mediaType?r.video=e:n.video=e))})),e.prev=4,i=t.map((function(e){return e.kind})).join(","),e.t0=MG(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=MG(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&&EP()?this.uplinkConnection.replaceTrack(e).then((function(t){t&&Tx.emit(Sx.LOCAL_TRACK_REPLACED,{track:e})})):Promise.resolve()}},{key:"setBandWidth",value:function(e){return kR(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 kR(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:yC.VIDEO,videoType:yC.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 kR(this,null,f().mark((function e(){var n,r,i,o,a,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,o=pR({},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),Tx.emit(Sx.SUBSCRIBE_START,{room:this,streamType:i,remotePublishedUser:r,subscribeState:o}),this._log.info("subscribe() => ".concat(n," ").concat(i," [").concat(SH(o),"] prev: [").concat(SH(r.subscribeState),"]")),e.next=15,r.subscribe(o,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:Tx.emit(Sx.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 LR?e.t2.getCode():PR.UNKNOWN,h=e.t2,e.t2 instanceof LR?d===PR.REMOTE_STREAM_NOT_EXIST&&(h=new LR({code:PR.API_CALL_ABORTED,message:OO({key:wO.API_CALL_ABORTED,data:{message:e.t2.message,userId:n,streamType:i}})}),this._log.warn(h)):(h=new LR({code:d,message:OO({key:wO.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 kR(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)})),Tx.emit(Sx.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 ZP.clearTask(this._audioVolumeIntervalId);t=Math.floor(Math.max(t,100)),Tx.emit(Sx.AUDIO_LEVEL_INTERVAL,{interval:t}),this._audioVolumeIntervalId&&ZP.clearTask(this._audioVolumeIntervalId),this._enableAudioVolumeEvaluation=!0,this._audioVolumeIntervalId=ZP.run("intervalInWorker",(function(){var r;QM.isRunning?e.stopUpdateAudioLevelFromSenderStat():e.updateAudioLevelFromSenderStat(t,n);var i=[];null==(r=e.remotePublishedUserMap)||r.forEach((function(t){if(t.muteState.hasAudio){!QM.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 kR(this,null,f().mark((function n(){var r,i,o,a=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:o=Math.max(e,500),this._log.warn("updateAudioLevelFromSenderStat ".concat(o)),this._updateAudioLevelTaskId=ZP.run("intervalInWorker",(function(){return kR(a,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: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"),ZP.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(kP&&n){var r=null==(t=n.getSynchronizationSources()[0])?void 0:t.audioLevel;Gw(r)?e.remoteAudioTrack.volume=Math.min(2*r,1):n.getStats().then((function(t){t.forEach((function(t){"inbound-rtp"===t.type&&Gw(t.audioLevel)&&(e.remoteAudioTrack.volume=t.audioLevel)}))}))}}},{key:"getLocalAudioStats",value:function(){return kR(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 kR(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 kR(this,null,f().mark((function e(){var t,n,r,i,o,a,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 o=v(i.value,2),a=o[1],e.next=13,this._stats.getReceiverStats(a);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 kR(this,null,f().mark((function t(){var n,r,i,o,a,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;)o=v(i.value,2),a=o[0],c=o[1],"main"===e&&c.muteState.hasVideo&&(n[a]=c.remoteVideoTrack.stat),"auxiliary"===e&&c.muteState.hasAuxiliary&&(n[a]=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 kR(this,null,f().mark((function e(){var t,n,r,i,o,a;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),o=i[0],(a=i[1]).muteState.hasAudio&&(t[o]=a.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(jR.getTurnServer(e))})):jR.isPlainObject(e)&&n.push(jR.getTurnServer(e)),this._turnServers=n,t&&(this._iceTransportPolicy=t)}},{key:"sendStartMixTranscode",value:function(e){return this.signalChannel.sendWaitForResponse({command:Qj,data:e,timeout:5e3,responseCommand:Mj.START_MIX_TRANSCODE_RES,commandDesc:"startMixTranscode"})}},{key:"sendStopMixTranscode",value:function(e){return this.signalChannel.sendWaitForResponse({command:$j,data:e,timeout:5e3,responseCommand:Mj.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?Kj:Yj,data:e,timeout:5e3,responseCommand:t?Mj.START_PUBLISH_TENCENT_CDN_RES:Mj.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?qj:Xj,data:e,timeout:5e3,responseCommand:t?Mj.STOP_PUBLISH_TENCENT_CDN_RES:Mj.STOP_PUBLISH_GIVEN_CDN_RES,commandDesc:"stopPublishCDN"})}},{key:"sendStartPushStreamToRoom",value:function(e){return this.signalChannel.sendWaitForResponse({command:Zj,data:e,timeout:5e3,responseCommand:Mj.START_PUBLISH_CDN_STREAM_RES,commandDesc:"startPublishCDNStream"})}},{key:"sendUpdatePushStreamToRoom",value:function(e){return this.signalChannel.sendWaitForResponse({command:eH,data:e,timeout:5e3,responseCommand:Mj.UPDATE_PUBLISH_CDN_STREAM_RES,commandDesc:"updatePublishCDNStream"})}},{key:"sendStopPushStreamToRoom",value:function(e){return this.signalChannel.sendWaitForResponse({command:tH,data:e,timeout:5e3,responseCommand:Mj.STOP_PUBLISH_CDN_STREAM_RES,commandDesc:"stopPublishCDNStream"})}},{key:"sendAbilityStatus",value:function(e){var t;null==(t=this.signalChannel)||t.sendWaitForResponse({command:uH,data:e,timeout:5e3,responseCommand:Mj.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=jR.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 kR(this,null,f().mark((function t(){var n,r,i,o,a,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,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(_w-s.reSubscribeCount,".")),s.isSubscribing=!1,s.reSubscribeCount=_w,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(_w-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:_w};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(xG(e.businessInfo)&&(t=JSON.parse(e.businessInfo)),!OG(e.pureAudioPushMode)){if(!Number.isInteger(Number(e.pureAudioPushMode)))throw new LR({code:PR.INVALID_PARAMETER,message:OO({key:wO.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(!OG(e.userDefineRecordId)){var n=/^[A-Za-z0-9_-]{1,64}$/gi;if(null===e.userDefineRecordId.match(n))throw new LR({code:PR.INVALID_PARAMETER,message:OO({key:wO.INVALID_USER_DEFINE_RECORDID})});t.Str_uc_params||(t.Str_uc_params={}),t.Str_uc_params.userdefine_record_id=e.userDefineRecordId}if(!OG(e.userDefinePushArgs)){if(!(xG(e.userDefinePushArgs)&&String(e.userDefinePushArgs)&&String(e.userDefinePushArgs).length<=256))throw new LR({code:PR.INVALID_PARAMETER,message:OO({key:wO.INVALID_USER_DEFINE_PUSH_ARGS})});t.Str_uc_params||(t.Str_uc_params={}),t.Str_uc_params.userdefine_push_args=e.userDefinePushArgs}MG(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 kR(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||!bP){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 LR({code:PR.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}}])}(eG);return yR([WP(["left",KP.INIT],"joined"),sM({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"),TB(!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())}}),RL((function(e){var t=new Ij;return function(n,r,i){return kR(this,null,f().mark((function o(){var a,s,c,u=this;return f().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 LR({code:PR.INVALID_OPERATION,message:OO({key:wO.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 LR({code:PR.INVALID_OPERATION,message:OO({key:wO.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)),Tx.emit(Sx.JOIN_START,{room:this,roomId:a,params:n}),(s=jR.getEnv())||(s=lC.QCLOUD,this.proxy_ws&&(this.proxy_ws.startsWith(TC.OLD_CLOUD_LADDER)?s=lC.OLD_CLOUD_LADDER:this.proxy_ws.startsWith(TC.WEBRTC)&&(s=lC.WEBRTC))),oM.setConfig({env:s,sdkAppId:String(this.sdkAppId),userId:this.userId,roomId:a}),Cx.checkSystemRequirementsInternal().then((function(e){u.checkSystemResult=e,bj.call(u)})),o.prev=8,o.t0=!(this.proxy_ws||this.proxy_wt||this.scheduleResult.domains||jR.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=jR.performanceNow(),Tx.emit(Sx.JOIN_SUCCESS,{room:this}),30===i&&!n.component&&oM.uploadEvent({log:"stat-conv-".concat(Number(ox),"-").concat(location.hostname),userId:this.userId}),c));case 19:throw o.prev=19,o.t1=o.catch(8),t.delete({room:this,roomId:a}),Tx.emit(Sx.JOIN_FAILED,{room:this,error:o.t1}),o.t1;case 22:case"end":return o.stop()}}),o,this,[[8,19]])})))}}))],LG.prototype,"join",1),yR([WP("joined","left",{ignoreError:!0,success:function(){this.reset(!0)}}),RL((function(e){return function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return kR(this,null,f().mark((function t(){return f().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Tx.emit(Sx.LEAVE_START,{room:this}),t.next=3,e.call.apply(e,[this].concat(n));case 3:Tx.emit(Sx.LEAVE_SUCCESS,{room:this,roomId:this.roomId});case 4:case"end":return t.stop()}}),t,this)})))}})),PL("leave room"),cM({fnName:"publish",validateArgs:!1}),cM({fnName:"unsubscribe",validateArgs:!1})],LG.prototype,"leave",1),yR([OL(),RL((function(e){return function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return kR(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 Tx.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)})))}})),sM({settings:{retries:zC,timeout:function(e){return Vw(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),Tx.emit(Sx.PUBLISH_FAILED,{room:this}))}})],LG.prototype,"publish",1),yR([cM({fnName:"publish"}),(DG="api-call",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=NL.get(this);if(i){var o=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 LR({code:PR.API_CALL_ABORTED,message:DG})),!1)}));i.queue=o}return r.apply(this,t)},n}),OL(),RL((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}})),bL((function(){var e,t;0===this.localTracks.size&&pP()&&(null==(t=null==(e=this.singlePC)?void 0:e.getPeerConnection())||t.getSenders().forEach((function(e){return e.track&&e.replaceTrack(null)})))}))],LG.prototype,"unpublish",1),yR([AL((function(e){if(e.code!==PR.API_CALL_ABORTED)throw e})),ML((function(e){return e.userId}))],LG.prototype,"replaceTrack",1),yR([ML((function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return t[0].userId})),$L(),RL((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}})),sM({settings:{retries:zC,timeout:function(e){return Vw(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),Tx.emit(Sx.SUBSCRIBE_FAILED,{room:this,remoteTracks:r}))}})],LG.prototype,"subscribe",1),yR([cM({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")}))}}),ML((function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return t[0].userId}))],LG.prototype,"unsubscribe",1),Sj.create=Sj._create.bind(Sj,LG),Sj}()}({get exports(){return OF},set exports(e){OF=e}}),A(OF)}));
|