trtc-sdk-v5 5.11.2-beta.2 → 5.11.2-beta.3

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.
@@ -1 +1 @@
1
- !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).VideoMixer=t()}(this,(function(){"use strict";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,t,n,r,i,a,o){try{var s=e[a](o),c=s.value}catch(e){return void n(e)}s.done?t(c):Promise.resolve(c).then(r,i)}function n(e){return function(){var n=this,r=arguments;return new Promise((function(i,a){var o=e.apply(n,r);function s(e){t(o,i,a,s,c,"next",e)}function c(e){t(o,i,a,s,c,"throw",e)}s(void 0)}))}}function r(e,t,n){return t=l(t),f(e,h()?Reflect.construct(t,n||[],l(e).constructor):t.apply(e,n))}function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function a(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 s(e,t,n){return t&&o(e.prototype,t),n&&o(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}function c(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=b(e))||t){n&&(e=n);var r=0,i=function(){};return{s:i,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,o=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return o=e.done,e},e:function(e){s=!0,a=e},f:function(){try{o||null==n.return||n.return()}finally{if(s)throw a}}}}function u(){return u="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(e,t,n){var r=g(e,t);if(r){var i=Object.getOwnPropertyDescriptor(r,t);return i.get?i.get.call(arguments.length<3?e:n):i.value}},u.apply(null,arguments)}function l(e){return l=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},l(e)}function d(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&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(e,t){if(t&&("object"==typeof t||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}function p(){p=function(){return t};var e,t={},n=Object.prototype,r=n.hasOwnProperty,i=Object.defineProperty||function(e,t,n){e[t]=n.value},a="function"==typeof Symbol?Symbol:{},o=a.iterator||"@@iterator",s=a.asyncIterator||"@@asyncIterator",c=a.toStringTag||"@@toStringTag";function u(e,t,n){return Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{u({},"")}catch(e){u=function(e,t,n){return e[t]=n}}function l(e,t,n,r){var a=t&&t.prototype instanceof g?t:g,o=Object.create(a.prototype),s=new D(r||[]);return i(o,"_invoke",{value:A(e,n,s)}),o}function d(e,t,n){try{return{type:"normal",arg:e.call(t,n)}}catch(e){return{type:"throw",arg:e}}}t.wrap=l;var h="suspendedStart",f="suspendedYield",v="executing",m="completed",y={};function g(){}function k(){}function E(){}var _={};u(_,o,(function(){return this}));var T=Object.getPrototypeOf,I=T&&T(T(O([])));I&&I!==n&&r.call(I,o)&&(_=I);var b=E.prototype=g.prototype=Object.create(_);function S(e){["next","throw","return"].forEach((function(t){u(e,t,(function(e){return this._invoke(t,e)}))}))}function w(e,t){function n(i,a,o,s){var c=d(e[i],e,a);if("throw"!==c.type){var u=c.arg,l=u.value;return l&&"object"==typeof l&&r.call(l,"__await")?t.resolve(l.__await).then((function(e){n("next",e,o,s)}),(function(e){n("throw",e,o,s)})):t.resolve(l).then((function(e){u.value=e,o(u)}),(function(e){return n("throw",e,o,s)}))}s(c.arg)}var a;i(this,"_invoke",{value:function(e,r){function i(){return new t((function(t,i){n(e,r,t,i)}))}return a=a?a.then(i,i):i()}})}function A(t,n,r){var i=h;return function(a,o){if(i===v)throw Error("Generator is already running");if(i===m){if("throw"===a)throw o;return{value:e,done:!0}}for(r.method=a,r.arg=o;;){var s=r.delegate;if(s){var c=R(s,r);if(c){if(c===y)continue;return c}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if(i===h)throw i=m,r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);i=v;var u=d(t,n,r);if("normal"===u.type){if(i=r.done?m:f,u.arg===y)continue;return{value:u.arg,done:r.done}}"throw"===u.type&&(i=m,r.method="throw",r.arg=u.arg)}}}function R(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,R(t,n),"throw"===n.method)||"return"!==r&&(n.method="throw",n.arg=new TypeError("The iterator does not provide a '"+r+"' method")),y;var a=d(i,t.iterator,n.arg);if("throw"===a.type)return n.method="throw",n.arg=a.arg,n.delegate=null,y;var o=a.arg;return o?o.done?(n[t.resultName]=o.value,n.next=t.nextLoc,"return"!==n.method&&(n.method="next",n.arg=e),n.delegate=null,y):o:(n.method="throw",n.arg=new TypeError("iterator result is not an object"),n.delegate=null,y)}function x(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 C(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function D(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(x,this),this.reset(!0)}function O(t){if(t||""===t){var n=t[o];if(n)return n.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var i=-1,a=function n(){for(;++i<t.length;)if(r.call(t,i))return n.value=t[i],n.done=!1,n;return n.value=e,n.done=!0,n};return a.next=a}}throw new TypeError(typeof t+" is not iterable")}return k.prototype=E,i(b,"constructor",{value:E,configurable:!0}),i(E,"constructor",{value:k,configurable:!0}),k.displayName=u(E,c,"GeneratorFunction"),t.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===k||"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(b),e},t.awrap=function(e){return{__await:e}},S(w.prototype),u(w.prototype,s,(function(){return this})),t.AsyncIterator=w,t.async=function(e,n,r,i,a){void 0===a&&(a=Promise);var o=new w(l(e,n,r,i),a);return t.isGeneratorFunction(n)?o:o.next().then((function(e){return e.done?e.value:o.next()}))},S(b),u(b,c,"Generator"),u(b,o,(function(){return this})),u(b,"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=O,D.prototype={constructor:D,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(C),!t)for(var n in this)"t"===n.charAt(0)&&r.call(this,n)&&!isNaN(+n.slice(1))&&(this[n]=e)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var n=this;function i(r,i){return s.type="throw",s.arg=t,n.next=r,i&&(n.method="next",n.arg=e),!!i}for(var a=this.tryEntries.length-1;a>=0;--a){var o=this.tryEntries[a],s=o.completion;if("root"===o.tryLoc)return i("end");if(o.tryLoc<=this.prev){var c=r.call(o,"catchLoc"),u=r.call(o,"finallyLoc");if(c&&u){if(this.prev<o.catchLoc)return i(o.catchLoc,!0);if(this.prev<o.finallyLoc)return i(o.finallyLoc)}else if(c){if(this.prev<o.catchLoc)return i(o.catchLoc,!0)}else{if(!u)throw Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return i(o.finallyLoc)}}}},abrupt:function(e,t){for(var n=this.tryEntries.length-1;n>=0;--n){var i=this.tryEntries[n];if(i.tryLoc<=this.prev&&r.call(i,"finallyLoc")&&this.prev<i.finallyLoc){var a=i;break}}a&&("break"===e||"continue"===e)&&a.tryLoc<=t&&t<=a.finallyLoc&&(a=null);var o=a?a.completion:{};return o.type=e,o.arg=t,a?(this.method="next",this.next=a.finallyLoc,y):this.complete(o)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),y},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),C(n),y}},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;C(n)}return i}}throw Error("illegal catch attempt")},delegateYield:function(t,n,r){return this.delegate={iterator:O(t),resultName:n,nextLoc:r},"next"===this.method&&(this.arg=e),y}},t}function v(e,t,n,r){return v="undefined"!=typeof Reflect&&Reflect.set?Reflect.set:function(e,t,n,r){var i,a=g(e,t);if(a){if((i=Object.getOwnPropertyDescriptor(a,t)).set)return i.set.call(r,n),!0;if(!i.writable)return!1}if(i=Object.getOwnPropertyDescriptor(r,t)){if(!i.writable)return!1;i.value=n,Object.defineProperty(r,t,i)}else!function(e,t,n){(t=T(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n}(r,t,n);return!0},v(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 y(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,i,a,o,s=[],c=!0,u=!1;try{if(a=(n=n.call(e)).next,0===t){if(Object(n)!==n)return;c=!1}else for(;!(c=(r=a.call(n)).done)&&(s.push(r.value),s.length!==t);c=!0);}catch(e){u=!0,i=e}finally{try{if(!c&&null!=n.return&&(o=n.return(),Object(o)!==o))return}finally{if(u)throw i}}return s}}(e,t)||b(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function g(e,t){for(;!{}.hasOwnProperty.call(e,t)&&null!==(e=l(e)););return e}function k(e,t,n,r){var i=u(l(1&r?e.prototype:e),t,n);return 2&r&&"function"==typeof i?function(e){return i.apply(n,e)}:i}function E(e,t,n,r,i,a){return function(e,t,n,r,i){if(!v(e,t,n,r||e)&&i)throw new TypeError("failed to set property");return n}(l(e.prototype),t,n,r,i)}function _(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)||b(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);if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e,"string");return"symbol"==typeof t?t:t+""}function I(e){return I="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},I(e)}function b(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 S(e){var t="function"==typeof Map?new Map:void 0;return S=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 a(e,arguments,l(this).constructor)}return n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),m(n,e)},S(e)}var w=Object.create,A=Object.defineProperty,R=Object.defineProperties,x=Object.getOwnPropertyDescriptor,C=Object.getOwnPropertyDescriptors,D=Object.getOwnPropertyNames,O=Object.getOwnPropertySymbols,N=Object.getPrototypeOf,M=Object.prototype.hasOwnProperty,L=Object.prototype.propertyIsEnumerable,P=function(e,t,n){return t in e?A(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n},U=function(e,t){for(var n in t||(t={}))M.call(t,n)&&P(e,n,t[n]);if(O){var r,i=c(O(t));try{for(i.s();!(r=i.n()).done;){n=r.value;L.call(t,n)&&P(e,n,t[n])}}catch(e){i.e(e)}finally{i.f()}}return e},V=function(e,t){return R(e,C(t))},F=function(e,t){return function(){return t||(0,e[D(e)[0]])((t={exports:{}}).exports,t),t.exports}},B=function(e,t){for(var n in t)A(e,n,{get:t[n],enumerable:!0})},j=function(e,t,n){return n=null!=e?w(N(e)):{},function(e,t,n,r){if(t&&"object"===I(t)||"function"==typeof t){var i,a=c(D(t));try{var o=function(){var a=i.value;M.call(e,a)||a===n||A(e,a,{get:function(){return t[a]},enumerable:!(r=x(t,a))||r.enumerable})};for(a.s();!(i=a.n()).done;)o()}catch(e){a.e(e)}finally{a.f()}}return e}(A(n,"default",{value:e,enumerable:!0}),e)},H=function(e,t,n,r){for(var i,a=x(t,n),o=e.length-1;o>=0;o--)(i=e[o])&&(a=i(t,n,a)||a);return a&&A(t,n,a),a},G=function(e,t,n){return P(e,"symbol"!==I(t)?t+"":t,n)},W=F({"../node_modules/.pnpm/eventemitter3@4.0.7/node_modules/eventemitter3/index.js":function(e,t){var n=Object.prototype.hasOwnProperty,r="~";function i(){}function a(e,t,n){this.fn=e,this.context=t,this.once=n||!1}function o(e,t,n,i,o){if("function"!=typeof n)throw new TypeError("The listener must be a function");var s=new a(n,i||e,o),c=r?r+t:t;return e._events[c]?e._events[c].fn?e._events[c]=[e._events[c],s]:e._events[c].push(s):(e._events[c]=s,e._eventsCount++),e}function s(e,t){0==--e._eventsCount?e._events=new i:delete e._events[t]}function c(){this._events=new i,this._eventsCount=0}Object.create&&(i.prototype=Object.create(null),(new i).__proto__||(r=!1)),c.prototype.eventNames=function(){var e,t,i=[];if(0===this._eventsCount)return i;for(t in e=this._events)n.call(e,t)&&i.push(r?t.slice(1):t);return Object.getOwnPropertySymbols?i.concat(Object.getOwnPropertySymbols(e)):i},c.prototype.listeners=function(e){var t=r?r+e:e,n=this._events[t];if(!n)return[];if(n.fn)return[n.fn];for(var i=0,a=n.length,o=new Array(a);i<a;i++)o[i]=n[i].fn;return o},c.prototype.listenerCount=function(e){var t=r?r+e:e,n=this._events[t];return n?n.fn?1:n.length:0},c.prototype.emit=function(e,t,n,i,a,o){var s=r?r+e:e;if(!this._events[s])return!1;var c,u,l=this._events[s],d=arguments.length;if(l.fn){switch(l.once&&this.removeListener(e,l.fn,void 0,!0),d){case 1:return l.fn.call(l.context),!0;case 2:return l.fn.call(l.context,t),!0;case 3:return l.fn.call(l.context,t,n),!0;case 4:return l.fn.call(l.context,t,n,i),!0;case 5:return l.fn.call(l.context,t,n,i,a),!0;case 6:return l.fn.call(l.context,t,n,i,a,o),!0}for(u=1,c=new Array(d-1);u<d;u++)c[u-1]=arguments[u];l.fn.apply(l.context,c)}else{var h,f=l.length;for(u=0;u<f;u++)switch(l[u].once&&this.removeListener(e,l[u].fn,void 0,!0),d){case 1:l[u].fn.call(l[u].context);break;case 2:l[u].fn.call(l[u].context,t);break;case 3:l[u].fn.call(l[u].context,t,n);break;case 4:l[u].fn.call(l[u].context,t,n,i);break;default:if(!c)for(h=1,c=new Array(d-1);h<d;h++)c[h-1]=arguments[h];l[u].fn.apply(l[u].context,c)}}return!0},c.prototype.on=function(e,t,n){return o(this,e,t,n,!1)},c.prototype.once=function(e,t,n){return o(this,e,t,n,!0)},c.prototype.removeListener=function(e,t,n,i){var a=r?r+e:e;if(!this._events[a])return this;if(!t)return s(this,a),this;var o=this._events[a];if(o.fn)o.fn!==t||i&&!o.once||n&&o.context!==n||s(this,a);else{for(var c=0,u=[],l=o.length;c<l;c++)(o[c].fn!==t||i&&!o[c].once||n&&o[c].context!==n)&&u.push(o[c]);u.length?this._events[a]=1===u.length?u[0]:u:s(this,a)}return this},c.prototype.removeAllListeners=function(e){var t;return e?(t=r?r+e:e,this._events[t]&&s(this,t)):(this._events=new i,this._eventsCount=0),this},c.prototype.off=c.prototype.removeListener,c.prototype.addListener=c.prototype.on,c.prefixed=r,c.EventEmitter=c,void 0!==t&&(t.exports=c)}}),q=F({"../node_modules/.pnpm/sdp-transform@2.15.0/node_modules/sdp-transform/lib/grammar.js":function(e,t){var n=t.exports={v:[{name:"version",reg:/^(\d*)$/}],o:[{name:"origin",reg:/^(\S*) (\d*) (\d*) (\S*) IP(\d) (\S*)/,names:["username","sessionId","sessionVersion","netType","ipVer","address"],format:"%s %s %d %s IP%d %s"}],s:[{name:"name"}],i:[{name:"description"}],u:[{name:"uri"}],e:[{name:"email"}],p:[{name:"phone"}],z:[{name:"timezones"}],r:[{name:"repeats"}],t:[{name:"timing",reg:/^(\d*) (\d*)/,names:["start","stop"],format:"%d %d"}],c:[{name:"connection",reg:/^IN IP(\d) (\S*)/,names:["version","ip"],format:"IN IP%d %s"}],b:[{push:"bandwidth",reg:/^(TIAS|AS|CT|RR|RS):(\d*)/,names:["type","limit"],format:"%s:%s"}],m:[{reg:/^(\w*) (\d*) ([\w/]*)(?: (.*))?/,names:["type","port","protocol","payloads"],format:"%s %d %s %s"}],a:[{push:"rtp",reg:/^rtpmap:(\d*) ([\w\-.]*)(?:\s*\/(\d*)(?:\s*\/(\S*))?)?/,names:["payload","codec","rate","encoding"],format:function(e){return e.encoding?"rtpmap:%d %s/%s/%s":e.rate?"rtpmap:%d %s/%s":"rtpmap:%d %s"}},{push:"fmtp",reg:/^fmtp:(\d*) ([\S| ]*)/,names:["payload","config"],format:"fmtp:%d %s"},{name:"control",reg:/^control:(.*)/,format:"control:%s"},{name:"rtcp",reg:/^rtcp:(\d*)(?: (\S*) IP(\d) (\S*))?/,names:["port","netType","ipVer","address"],format:function(e){return null!=e.address?"rtcp:%d %s IP%d %s":"rtcp:%d"}},{push:"rtcpFbTrrInt",reg:/^rtcp-fb:(\*|\d*) trr-int (\d*)/,names:["payload","value"],format:"rtcp-fb:%s trr-int %d"},{push:"rtcpFb",reg:/^rtcp-fb:(\*|\d*) ([\w-_]*)(?: ([\w-_]*))?/,names:["payload","type","subtype"],format:function(e){return null!=e.subtype?"rtcp-fb:%s %s %s":"rtcp-fb:%s %s"}},{push:"ext",reg:/^extmap:(\d+)(?:\/(\w+))?(?: (urn:ietf:params:rtp-hdrext:encrypt))? (\S*)(?: (\S*))?/,names:["value","direction","encrypt-uri","uri","config"],format:function(e){return"extmap:%d"+(e.direction?"/%s":"%v")+(e["encrypt-uri"]?" %s":"%v")+" %s"+(e.config?" %s":"")}},{name:"extmapAllowMixed",reg:/^(extmap-allow-mixed)/},{push:"crypto",reg:/^crypto:(\d*) ([\w_]*) (\S*)(?: (\S*))?/,names:["id","suite","config","sessionConfig"],format:function(e){return null!=e.sessionConfig?"crypto:%d %s %s %s":"crypto:%d %s %s"}},{name:"setup",reg:/^setup:(\w*)/,format:"setup:%s"},{name:"connectionType",reg:/^connection:(new|existing)/,format:"connection:%s"},{name:"mid",reg:/^mid:([^\s]*)/,format:"mid:%s"},{name:"msid",reg:/^msid:(.*)/,format:"msid:%s"},{name:"ptime",reg:/^ptime:(\d*(?:\.\d*)*)/,format:"ptime:%d"},{name:"maxptime",reg:/^maxptime:(\d*(?:\.\d*)*)/,format:"maxptime:%d"},{name:"direction",reg:/^(sendrecv|recvonly|sendonly|inactive)/},{name:"icelite",reg:/^(ice-lite)/},{name:"iceUfrag",reg:/^ice-ufrag:(\S*)/,format:"ice-ufrag:%s"},{name:"icePwd",reg:/^ice-pwd:(\S*)/,format:"ice-pwd:%s"},{name:"fingerprint",reg:/^fingerprint:(\S*) (\S*)/,names:["type","hash"],format:"fingerprint:%s %s"},{push:"candidates",reg:/^candidate:(\S*) (\d*) (\S*) (\d*) (\S*) (\d*) typ (\S*)(?: raddr (\S*) rport (\d*))?(?: tcptype (\S*))?(?: generation (\d*))?(?: network-id (\d*))?(?: network-cost (\d*))?/,names:["foundation","component","transport","priority","ip","port","type","raddr","rport","tcptype","generation","network-id","network-cost"],format:function(e){var t="candidate:%s %d %s %d %s %d typ %s";return t+=null!=e.raddr?" raddr %s rport %d":"%v%v",t+=null!=e.tcptype?" tcptype %s":"%v",null!=e.generation&&(t+=" generation %d"),t+=null!=e["network-id"]?" network-id %d":"%v",t+=null!=e["network-cost"]?" network-cost %d":"%v"}},{name:"endOfCandidates",reg:/^(end-of-candidates)/},{name:"remoteCandidates",reg:/^remote-candidates:(.*)/,format:"remote-candidates:%s"},{name:"iceOptions",reg:/^ice-options:(\S*)/,format:"ice-options:%s"},{push:"ssrcs",reg:/^ssrc:(\d*) ([\w_-]*)(?::(.*))?/,names:["id","attribute","value"],format:function(e){var t="ssrc:%d";return null!=e.attribute&&(t+=" %s",null!=e.value&&(t+=":%s")),t}},{push:"ssrcGroups",reg:/^ssrc-group:([\x21\x23\x24\x25\x26\x27\x2A\x2B\x2D\x2E\w]*) (.*)/,names:["semantics","ssrcs"],format:"ssrc-group:%s %s"},{name:"msidSemantic",reg:/^msid-semantic:\s?(\w*) (\S*)/,names:["semantic","token"],format:"msid-semantic: %s %s"},{push:"groups",reg:/^group:(\w*) (.*)/,names:["type","mids"],format:"group:%s %s"},{name:"rtcpMux",reg:/^(rtcp-mux)/},{name:"rtcpRsize",reg:/^(rtcp-rsize)/},{name:"sctpmap",reg:/^sctpmap:([\w_/]*) (\S*)(?: (\S*))?/,names:["sctpmapNumber","app","maxMessageSize"],format:function(e){return null!=e.maxMessageSize?"sctpmap:%s %s %s":"sctpmap:%s %s"}},{name:"xGoogleFlag",reg:/^x-google-flag:([^\s]*)/,format:"x-google-flag:%s"},{push:"rids",reg:/^rid:([\d\w]+) (\w+)(?: ([\S| ]*))?/,names:["id","direction","params"],format:function(e){return e.params?"rid:%s %s %s":"rid:%s %s"}},{push:"imageattrs",reg:new RegExp("^imageattr:(\\d+|\\*)[\\s\\t]+(send|recv)[\\s\\t]+(\\*|\\[\\S+\\](?:[\\s\\t]+\\[\\S+\\])*)(?:[\\s\\t]+(recv|send)[\\s\\t]+(\\*|\\[\\S+\\](?:[\\s\\t]+\\[\\S+\\])*))?"),names:["pt","dir1","attrs1","dir2","attrs2"],format:function(e){return"imageattr:%s %s %s"+(e.dir2?" %s %s":"")}},{name:"simulcast",reg:new RegExp("^simulcast:(send|recv) ([a-zA-Z0-9\\-_~;,]+)(?:\\s?(send|recv) ([a-zA-Z0-9\\-_~;,]+))?$"),names:["dir1","list1","dir2","list2"],format:function(e){return"simulcast:%s %s"+(e.dir2?" %s %s":"")}},{name:"simulcast_03",reg:/^simulcast:[\s\t]+([\S+\s\t]+)$/,names:["value"],format:"simulcast: %s"},{name:"framerate",reg:/^framerate:(\d+(?:$|\.\d+))/,format:"framerate:%s"},{name:"sourceFilter",reg:/^source-filter: *(excl|incl) (\S*) (IP4|IP6|\*) (\S*) (.*)/,names:["filterMode","netType","addressTypes","destAddress","srcList"],format:"source-filter: %s %s %s %s %s"},{name:"bundleOnly",reg:/^(bundle-only)/},{name:"label",reg:/^label:(.+)/,format:"label:%s"},{name:"sctpPort",reg:/^sctp-port:(\d+)$/,format:"sctp-port:%s"},{name:"maxMessageSize",reg:/^max-message-size:(\d+)$/,format:"max-message-size:%s"},{push:"tsRefClocks",reg:/^ts-refclk:([^\s=]*)(?:=(\S*))?/,names:["clksrc","clksrcExt"],format:function(e){return"ts-refclk:%s"+(null!=e.clksrcExt?"=%s":"")}},{name:"mediaClk",reg:/^mediaclk:(?:id=(\S*))? *([^\s=]*)(?:=(\S*))?(?: *rate=(\d+)\/(\d+))?/,names:["id","mediaClockName","mediaClockValue","rateNumerator","rateDenominator"],format:function(e){var t="mediaclk:";return t+=null!=e.id?"id=%s %s":"%v%s",t+=null!=e.mediaClockValue?"=%s":"",t+=null!=e.rateNumerator?" rate=%s":"",t+=null!=e.rateDenominator?"/%s":""}},{name:"keywords",reg:/^keywds:(.+)$/,format:"keywds:%s"},{name:"content",reg:/^content:(.+)/,format:"content:%s"},{name:"bfcpFloorCtrl",reg:/^floorctrl:(c-only|s-only|c-s)/,format:"floorctrl:%s"},{name:"bfcpConfId",reg:/^confid:(\d+)/,format:"confid:%s"},{name:"bfcpUserId",reg:/^userid:(\d+)/,format:"userid:%s"},{name:"bfcpFloorId",reg:/^floorid:(.+) (?:m-stream|mstrm):(.+)/,names:["id","mStream"],format:"floorid:%s mstrm:%s"},{push:"invalid",names:["value"]}]};Object.keys(n).forEach((function(e){n[e].forEach((function(e){e.reg||(e.reg=/(.*)/),e.format||(e.format="%s")}))}))}}),K=F({"../node_modules/.pnpm/sdp-transform@2.15.0/node_modules/sdp-transform/lib/parser.js":function(e){var t=function(e){return String(Number(e))===e?Number(e):e},n=function(e,n,r){var i=e.name&&e.names;e.push&&!n[e.push]?n[e.push]=[]:i&&!n[e.name]&&(n[e.name]={});var a=e.push?{}:i?n[e.name]:n;!function(e,n,r,i){if(i&&!r)n[i]=t(e[1]);else for(var a=0;a<r.length;a+=1)null!=e[a+1]&&(n[r[a]]=t(e[a+1]))}(r.match(e.reg),a,e.names,e.name),e.push&&n[e.push].push(a)},r=q(),i=RegExp.prototype.test.bind(/^([a-z])=(.*)/);e.parse=function(e){var t={},a=[],o=t;return e.split(/(\r\n|\r|\n)/).filter(i).forEach((function(e){var t=e[0],i=e.slice(2);"m"===t&&(a.push({rtp:[],fmtp:[]}),o=a[a.length-1]);for(var s=0;s<(r[t]||[]).length;s+=1){var c=r[t][s];if(c.reg.test(i))return n(c,o,i)}})),t.media=a,t};var a=function(e,n){var r=n.split(/=(.+)/,2);return 2===r.length?e[r[0]]=t(r[1]):1===r.length&&n.length>1&&(e[r[0]]=void 0),e};e.parseParams=function(e){return e.split(/;\s?/).reduce(a,{})},e.parseFmtpConfig=e.parseParams,e.parsePayloads=function(e){return e.toString().split(" ").map(Number)},e.parseRemoteCandidates=function(e){for(var n=[],r=e.split(" ").map(t),i=0;i<r.length;i+=3)n.push({component:r[i],ip:r[i+1],port:r[i+2]});return n},e.parseImageAttributes=function(e){return e.split(" ").map((function(e){return e.substring(1,e.length-1).split(",").reduce(a,{})}))},e.parseSimulcastStreamList=function(e){return e.split(";").map((function(e){return e.split(",").map((function(e){var n,r=!1;return"~"!==e[0]?n=t(e):(n=t(e.substring(1,e.length)),r=!0),{scid:n,paused:r}}))}))}}}),z=F({"../node_modules/.pnpm/sdp-transform@2.15.0/node_modules/sdp-transform/lib/writer.js":function(e,t){var n=q(),r=/%[sdv%]/g,i=function(e){var t=1,n=arguments,i=n.length;return e.replace(r,(function(e){if(t>=i)return e;var r=n[t];switch(t+=1,e){case"%%":return"%";case"%s":return String(r);case"%d":return Number(r);case"%v":return""}}))},a=function(e,t,n){var r=[e+"="+(t.format instanceof Function?t.format(t.push?n:n[t.name]):t.format)];if(t.names)for(var a=0;a<t.names.length;a+=1){var o=t.names[a];t.name?r.push(n[t.name][o]):r.push(n[t.names[a]])}else r.push(n[t.name]);return i.apply(null,r)},o=["v","o","s","i","u","e","p","c","b","t","r","z","a"],s=["i","c","b","a"];t.exports=function(e,t){t=t||{},null==e.version&&(e.version=0),null==e.name&&(e.name=" "),e.media.forEach((function(e){null==e.payloads&&(e.payloads="")}));var r=t.outerOrder||o,i=t.innerOrder||s,c=[];return r.forEach((function(t){n[t].forEach((function(n){n.name in e&&null!=e[n.name]?c.push(a(t,n,e)):n.push in e&&null!=e[n.push]&&e[n.push].forEach((function(e){c.push(a(t,n,e))}))}))})),e.media.forEach((function(e){c.push(a("m",n.m[0],e)),i.forEach((function(t){n[t].forEach((function(n){n.name in e&&null!=e[n.name]?c.push(a(t,n,e)):n.push in e&&null!=e[n.push]&&e[n.push].forEach((function(e){c.push(a(t,n,e))}))}))}))})),c.join("\r\n")+"\r\n"}}}),Y=F({"../node_modules/.pnpm/sdp-transform@2.15.0/node_modules/sdp-transform/lib/index.js":function(e){var t=K(),n=z(),r=q();e.grammar=r,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}});B({},{bytes2ms:function(){return De},calculateScaleResolutionDownNumber:function(){return St},convertObjectNumberToInt:function(){return Et},copyProperties:function(){return Ce},deepClone:function(){return lt},deepMerge:function(){return ut},delay:function(){return _t},fibonacci:function(){return Ve},formatedTime:function(){return ft},getConstructorName:function(){return Ze},getContainerFromElement:function(){return ht},getEnv:function(){return Te},getInternalVersion:function(){return rt},getLoggerUrl:function(){return be},getMediaStreamTrackInfo:function(){return bt},getMuteStateFromFlag:function(){return ot},getNetworkType:function(){return we},getNumNetworkType:function(){return xe},getReconnectionTimeout:function(){return Fe},getStringByteLength:function(){return mt},getTurnServer:function(){return st},getUint32Version:function(){return kt},getValueType:function(){return Be},getViewListFromView:function(){return dt},glog:function(){return Le},ipv4ToUint32:function(){return ct},isArray:function(){return ze},isAudioWorkletSupported:function(){return $e},isBoolean:function(){return qe},isConstructor:function(){return Je},isEmpty:function(){return at},isFunction:function(){return je},isLangChinese:function(){return Pe},isMediaStreamTrack:function(){return Ye},isNumber:function(){return We},isObject:function(){return Ke},isOverseaSdkAppId:function(){return Ie},isPlainObject:function(){return Ue},isPortrait:function(){return yt},isPromise:function(){return Qe},isRemoteTrack:function(){return Xe},isRotate90Or270:function(){return wt},isString:function(){return Ge},isUndefined:function(){return He},loadImage:function(){return gt},loadVideo:function(){return At},ms2bytes:function(){return Ne},ms2samples:function(){return Me},normalizeUrl:function(){return It},performanceNow:function(){return tt},promiseAny:function(){return et},samples2ms:function(){return Oe},setNetworkType:function(){return Re},stringify:function(){return pt},stringifyIncludeValue:function(){return vt},throttlePromise:function(){return Tt}});var X="5.0.0",Q="undefined"!=typeof importScripts,J="undefined"!=typeof registerProcessor,Z="https://".concat("web.sdk.qcloud.com","/trtc/webrtc/v5/doc"),$="jssdk_log",ee="qcloud",te=function(e){return e[e.TRACE=0]="TRACE",e[e.DEBUG=1]="DEBUG",e[e.INFO=2]="INFO",e[e.WARN=3]="WARN",e[e.ERROR=4]="ERROR",e[e.NONE=5]="NONE",e}(te||{}),ne={unknown:0,wifi:1,"3g":2,"2g":3,"4g":4,wired:5,"5g":6},re={"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}},ie=re["480p_2"],ae={"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}},oe={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"},se=1,ce=2,ue=4,le=8,de=64,he=16,fe="player-error",pe="load-worklet",ve="getUserMedia-retry",me="default",ye=2e3,ge=["width","height","frameRate","facingMode","sampleRate","sampleSize","channelCount","deviceId","min","max"],ke=function(e){return e[e.INVALID_PARAMETER=4096]="INVALID_PARAMETER",e[e.INVALID_OPERATION=4097]="INVALID_OPERATION",e[e.NOT_SUPPORTED=4098]="NOT_SUPPORTED",e[e.DEVICE_NOT_FOUND=4099]="DEVICE_NOT_FOUND",e[e.INITIALIZE_FAILED=4100]="INITIALIZE_FAILED",e[e.SIGNAL_CHANNEL_SETUP_FAILED=16385]="SIGNAL_CHANNEL_SETUP_FAILED",e[e.SIGNAL_CHANNEL_ERROR=16386]="SIGNAL_CHANNEL_ERROR",e[e.ICE_TRANSPORT_ERROR=16387]="ICE_TRANSPORT_ERROR",e[e.JOIN_ROOM_FAILED=16388]="JOIN_ROOM_FAILED",e[e.CREATE_OFFER_FAILED=16389]="CREATE_OFFER_FAILED",e[e.SIGNAL_CHANNEL_RECONNECTION_FAILED=16390]="SIGNAL_CHANNEL_RECONNECTION_FAILED",e[e.UPLINK_RECONNECTION_FAILED=16391]="UPLINK_RECONNECTION_FAILED",e[e.DOWNLINK_RECONNECTION_FAILED=16392]="DOWNLINK_RECONNECTION_FAILED",e[e.REMOTE_STREAM_NOT_EXIST=16400]="REMOTE_STREAM_NOT_EXIST",e[e.CLIENT_BANNED=16448]="CLIENT_BANNED",e[e.SERVER_TIMEOUT=16449]="SERVER_TIMEOUT",e[e.SUBSCRIPTION_TIMEOUT=16450]="SUBSCRIPTION_TIMEOUT",e[e.PLAY_NOT_ALLOWED=16451]="PLAY_NOT_ALLOWED",e[e.DEVICE_AUTO_RECOVER_FAILED=16452]="DEVICE_AUTO_RECOVER_FAILED",e[e.START_PUBLISH_CDN_FAILED=16453]="START_PUBLISH_CDN_FAILED",e[e.STOP_PUBLISH_CDN_FAILED=16454]="STOP_PUBLISH_CDN_FAILED",e[e.START_MIX_TRANSCODE_FAILED=16455]="START_MIX_TRANSCODE_FAILED",e[e.STOP_MIX_TRANSCODE_FAILED=16456]="STOP_MIX_TRANSCODE_FAILED",e[e.NOT_SUPPORTED_H264=16457]="NOT_SUPPORTED_H264",e[e.SWITCH_ROLE_FAILED=16458]="SWITCH_ROLE_FAILED",e[e.API_CALL_TIMEOUT=16459]="API_CALL_TIMEOUT",e[e.SCHEDULE_FAILED=16460]="SCHEDULE_FAILED",e[e.API_CALL_ABORTED=16461]="API_CALL_ABORTED",e[e.SPC_INITIALIZED_FAILED=16462]="SPC_INITIALIZED_FAILED",e[e.VIDEO_MANAGER_ERROR=16463]="VIDEO_MANAGER_ERROR",e[e.SWITCH_ROOM_FAILED=16464]="SWITCH_ROOM_FAILED",e[e.UNKNOWN=65535]="UNKNOWN",e}(ke||{}),Ee=ke,_e=function(e){function t(e){var n,a=e.name,o=void 0===a?"RtcError":a,s=e.message,c=e.code,u=void 0===c?Ee.UNKNOWN:c,l=e.extraCode,d=void 0===l?0:l,h=e.constraint;i(this,t);var f="<".concat(function(e){for(var t in Ee)if(Ee[t]===e)return t;return"UNKNOWN"}(u)," 0x").concat(u.toString(16),">"),p="".concat(s).concat(h?" constraint: ".concat(h):"").concat((null==s?void 0:s.includes(f))?"":" ".concat(f));return n=r(this,t,[p]),G(n,"code"),G(n,"extraCode"),G(n,"message"),G(n,"originMessage"),G(n,"name"),G(n,"constraint"),n.code=u,n.extraCode=d,n.name=o,n.message=p,n.constraint=h,n.originMessage=s,n}return d(t,e),s(t,[{key:"getCode",value:function(){return this.code}},{key:"getExtraCode",value:function(){return this.extraCode}},{key:"toString",value:function(){return this.originMessage}}])}(S(Error)),Te=function(){return new URLSearchParams(location.search).get("trtc_env")||""},Ie=function(e){return Number(e)<14e8},be=function(e,t){var n;n=Ie(e)?"https://apisgp.my-imcloud.com":"https://yun.tim.qq.com";var r=Math.floor(Math.random()*Math.pow(2,31));return"".concat(n,"/v5/AVQualityReportSvc/C2S?random=").concat(r,"&sdkappid=").concat(e,"&cmdtype=").concat(t)},Se="unknown";function we(){if("unknown"!==Se)return Se;var e=navigator,t=e.userAgent,n=e.connection,r=(t.match(/NetType\/\S+/)||[])[0]||"";"3gnet"===(r=r.toLowerCase().replace("nettype/",""))&&(r="3g");var i=n&&n.type&&n.type.toLowerCase(),a=n&&n.effectiveType&&n.effectiveType.toLowerCase();return"slow-2"===a&&(a="2g"),i&&(Se=Ae(i,a)),Se}function Ae(e,t){if(ne[e])return e;switch(e){case"cellular":case"wimax":return t||"unknown";case"ethernet":return"wired";default:return"unknown"}}function Re(e){Se=Ae(e)}function xe(){return ne[we()]}function Ce(e,t){var n,r=c(Reflect.ownKeys(t));try{for(r.s();!(n=r.n()).done;){var i=n.value;if("constructor"!==i&&"prototype"!==i&&"name"!==i){var a=Object.getOwnPropertyDescriptor(t,i)||"";Object.defineProperty(e,i,a)}}}catch(e){r.e(e)}finally{r.f()}return e}function De(e){return Oe(e/4,arguments.length>1&&void 0!==arguments[1]?arguments[1]:48e3)}function Oe(e){return 1e3*e/(arguments.length>1&&void 0!==arguments[1]?arguments[1]:48e3)}function Ne(e){return 4*Me(e,arguments.length>1&&void 0!==arguments[1]?arguments[1]:48e3)}function Me(e){return e*(arguments.length>1&&void 0!==arguments[1]?arguments[1]:48e3)/1e3}var Le="undefined"!=typeof window&&"function"==typeof window.glog?window.glog:function(){},Pe=function(){var e=navigator.language;return"zh"===(e=e.substring(0,2))},Ue=function(e){if(!e||"object"!==I(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 Ve(e){var t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1;return e<=1?t:Ve(e-1,t,(arguments.length>1&&void 0!==arguments[1]?arguments[1]:1)+t)}function Fe(e){return e>8?3e4:1e3*Ve(e)}function Be(e){return Reflect.apply(Object.prototype.toString,e,[]).replace(/^\[object\s(\w+)\]$/,"$1").toLowerCase()}var je=function(e){return"function"==typeof e},He=function(e){return void 0===e},Ge=function(e){return"string"==typeof e},We=function(e){return"number"==typeof e},qe=function(e){return"boolean"==typeof e},Ke=function(e){return"object"===Be(e)},ze=function(e){return"array"===Be(e)},Ye=function(e){return Be(e)==="MediaStreamTrack".toLowerCase()},Xe=function(e){return e.isRemote},Qe=function(e){return"promise"===Be(e)},Je=function(e){return je(e)&&e.prototype.constructor===e},Ze=function(e){return Je(e)?e.prototype.constructor.name:""},$e="undefined"!=typeof AudioWorkletNode;function et(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 tt(){return performance&&performance.now?Math.floor(performance.now()):Date.now()}var nt=function(e){return+e<10?"0".concat(e):e},rt=function(e){var t=e.match(/^\d+\.\d+\.\d+/)[0];if(!t)return e;var n=t.split("."),r=nt(n[1])+nt(n[2]);return n[1]-15>0&&(n[1]="15"),n[2]-15>0&&(n[2]="15"),"".concat(n.join("."),".").concat(r)},it=Object.prototype.hasOwnProperty;function at(e){if(null==e)return!0;if("boolean"==typeof e)return!1;if("number"==typeof e)return 0===e;if("string"==typeof e)return 0===e.length;if("function"==typeof e)return 0===e.length;if(Array.isArray(e))return 0===e.length;if(e instanceof Error)return""===e.message;if(Ue(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(it.call(e,t))return!1;return!0}return!1}function ot(e,t){return{userId:t,hasAudio:!!(e&le),hasVideo:!!(e&se),hasAuxiliary:!!(e&ue),hasSmall:!!(e&ce),audioMuted:!!(e&de),videoMuted:!!(e&he),audioAvailable:!(!(e&le)||e&de),videoAvailable:!(!(e&se)||e&he)}}function st(e){var t={urls:e.url.startsWith("turn:")||e.url.startsWith("turns:")?e.url:"turn:".concat(e.url)};return He(e.username)||He(e.credential)||(t.username=e.username,t.credential=e.credential,t.credentialType="password",He(e.credentialType)||(t.credentialType=e.credentialType)),t}function ct(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];if(!Ge(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 ut=function(e,t,n,r){if(!Ke(e)||!Ke(t))return 0;for(var i,a=0,o=Object.keys(t),s=0,c=o.length;s<c;s++)if(i=o[s],!(He(t[i])||n&&n.includes(i)))if(Ke(e[i])&&Ke(t[i]))a+=ut(e[i],t[i],n,r);else{if(r&&r.includes(t[i]))continue;e[i]!==t[i]&&(e[i]=lt(t[i]),a+=1)}return a};function lt(e){if(ze(e)){var t=[];return e.forEach((function(e,n){t[n]=lt(e)})),t}if(Ke(e)){var n={};return Object.keys(e).forEach((function(t){n[t]=lt(e[t])})),n}return e}var dt=function(e){var t=[];if(ze(e))t=_(e);else if(Ge(e)){var n=document.getElementById(e);n&&t.push(n)}else e&&t.push(e);return t},ht=function(e){return Ge(e)?document.getElementById(e):e},ft=function(){return t=function(e){return e<10?"0".concat(e):"".concat(e)},n=(e=new Date).getFullYear(),r=e.getMonth()+1,i=e.getDate(),a=t(e.getHours()),o=t(e.getMinutes()),s=t(e.getSeconds()),"".concat(n,"/").concat(r,"/").concat(i," ").concat(a,":").concat(o,":").concat(s);var e,t,n,r,i,a,o,s};function pt(e,t){var n=t.keysToInclude,r=t.keysToExclude;try{if(ze(e))return"[".concat(e.map((function(e){return pt(e,{keysToInclude:n,keysToExclude:r})})).join(","),"]");if(!Ue(e)||!ze(n)&&!ze(r))return JSON.stringify(e);var i={},a=new Set(n),o=new Set(r);return Object.keys(e).forEach((function(t){(0===o.size&&a.has(t)||0===a.size&&!o.has(t))&&(i[t]=Ue(e[t])||ze(e[t])?JSON.parse(pt(e[t],{keysToExclude:r,keysToInclude:n})):e[t])})),JSON.stringify(i)}catch(e){return"{}"}}function vt(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)})),pt(e,{keysToInclude:n})}function mt(e){return e.replace(/[\u4e00-\u9fa5]/g,"aa").length}var yt=function(){var e,t,n,r;return(null==(e=window.screen)?void 0:e.orientation)?!!(null==(r=null==(n=null==(t=window.screen)?void 0:t.orientation)?void 0:n.type)?void 0:r.includes("portrait")):0===window.orientation||180===window.orientation},gt=function(){var e=n(p().mark((function e(t){return p().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",new Promise((function(e,n){var r;if(Ge(t))(r=new Image).crossOrigin="anonymous",r.src=t;else if((r=t).complete)return void e(r);r.onload=function(){return e(r)},r.onerror=function(){n(new _e({code:Ee.INVALID_PARAMETER,message:"load image failed, url: ".concat(t)}))}})));case 1:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),kt=function(e){var t=e.split(".");return+t[0]<<24|+t[1]<<16|+t[2]<<8|+t[3]},Et=function(e){return Object.keys(e).forEach((function(t){We(e[t])&&(t.startsWith("uint")||t.startsWith("int"))?e[t]=Math.floor(e[t]):(Ue(e[t])||ze(e[t]))&&Et(e[t])})),e};function _t(e,t){return new Promise((function(n){var r=setTimeout(n,e);t&&t(r)}))}function Tt(e,t){var n=null;return function(){if(n)return n;for(var r=arguments.length,i=new Array(r),a=0;a<r;a++)i[a]=arguments[a];return(n=e.apply(t||this,i)).finally((function(){return n=null})),n}}function It(e){return e.replace(/(^|[^:])\/{2,}/g,"$1/")}function bt(e){var t;try{var n=null==(t=e.getSettings)?void 0:t.call(e),r=n.width,i=n.height,a=n.frameRate,o=n.sampleRate,s=n.sampleSize,c=n.channelCount,u=e.kind===oe.AUDIO?"".concat(o,"x").concat(s,"@").concat(c):"".concat(r,"x").concat(i,"@").concat(a),l=e.stats?" stats: ".concat(JSON.stringify(e.stats).replaceAll('"',"")):"";return"".concat(e.id," ").concat(e.readyState," muted:").concat(e.muted," ").concat(e.kind," ").concat(e.label," ").concat(u).concat(l)}catch(e){return""}}function St(e,t){return e.width*e.height==t.width*t.height?1:yt()&&t.width>t.height&&e.height>t.width?Math.max(e.width/t.height,e.height/t.width,1):Math.max(e.width/t.width,e.height/t.height,1)}function wt(e){return 90===e||270===e}function At(e){return Rt.apply(this,arguments)}function Rt(){return(Rt=n(p().mark((function e(t){return p().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",new Promise((function(e,n){var r=document.createElement("video");r.crossOrigin="anonymous",r.src=t,r.muted=!0,r.loop=!0,r.playsInline=!0,r.play(),r.onloadeddata=function(){e(r)},r.onerror=function(){n(r.error)}})));case 1:case"end":return e.stop()}}),e)})))).apply(this,arguments)}B({},{HTTPS_API:function(){return qr},IS_GET_CAPABILITIES_SUPPORTED:function(){return hi},IS_GET_SETTINGS_SUPPORTED:function(){return di},IS_GET_SYNCHRONIZATION_SOURCES_SUPPORTED:function(){return li},IS_INSERTABLE_STREAM_SUPPORTED:function(){return fi},IS_JITTER_BUFFER_TARGET_SUPPORTED:function(){return Si},IS_RTC_RTP_SENDER_SUPPORTED:function(){return si},IS_SCRIPT_TRANSFORM_SUPPORTED:function(){return pi},IS_SEI_SUPPORTED:function(){return vi},IS_SPC_SUPPORTED:function(){return ai},basis:function(){return _i},capabilityCheck:function(){return Ii},checkSystemRequirementsInternal:function(){return Fr},decodeSupportStatus:function(){return Vr},encodeSupportStatus:function(){return Ur},getBrowserInfo:function(){return Cr},getDisplayResolution:function(){return zr},isAddTransceiverSupported:function(){return ii},isBrowserSupported:function(){return Dr},isCanvasCaptureStreamAPISupported:function(){return Qr},isCanvasSmallStreamSupported:function(){return Jr},isGetReceiversSupported:function(){return ti},isGetSendersSupported:function(){return ni},isGetTransceiversSupported:function(){return ri},isGetUserMediaSupported:function(){return Yr},isMediaDevicesSupported:function(){return Nr},isMediaSessionSupported:function(){return gi},isMediaStreamTrackProcessorSupported:function(){return Pr},isReplaceTrackSupported:function(){return ci},isRequestVideoFrameCallbackSupported:function(){return bi},isSIMDSupported:function(){return Ei},isScaleResolutionDownBySupported:function(){return Zr},isScreenCaptureApiAvailable:function(){return jr},isSelectedCandidatePair:function(){return Kr},isSetParametersSupported:function(){return ui},isSmallStreamSupported:function(){return $r},isStopTransceiverSupported:function(){return oi},isTRTCSupported:function(){return Br},isUnifiedPlanDefault:function(){return ei},isUsedInHttpProtocol:function(){return Lr},isWebAudioSupported:function(){return Xr},isWebCodecSupported:function(){return yi},isWebCodecsSupported:function(){return Or},isWebRTCSupported:function(){return mi},isWebTransportSupported:function(){return ki}});var xt="undefined"==typeof navigator?"":navigator.userAgent,Ct=function(e){return new RegExp(e,"i").test(xt)},Dt=function(e){if(Ct(e)){var t=new RegExp("".concat(e,"\\/([\\d.]+)")),n=xt.match(t);if(n&&n[1])return n[1]}return""},Ot=function(e){if(Ct(e)){var t=new RegExp("".concat(e,"\\/(\\d+)")),n=xt.match(t);if(n&&n[1])return parseFloat(n[1])}return NaN},Nt=/AppleWebKit\/([\d.]+)/i.exec(xt);Nt&&parseFloat(Nt[1]);var Mt=Ct("iPad"),Lt="undefined"!=typeof navigator&&navigator.maxTouchPoints&&navigator.maxTouchPoints>2&&Ct("Macintosh"),Pt=Ct("iPhone")&&!Mt,Ut=Ct("iPod"),Vt=Pt||Mt||Ut||Lt,Ft=Ct("Android");!function(){if(Ft){var e=xt.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}}}();Ft&&Ct("webkit");var Bt=Ct("Firefox"),jt=Dt("Firefox"),Ht=Ot("Firefox"),Gt=Ct("Edge"),Wt=Dt("Edge"),qt=Ct("Edg"),Kt=Dt("Edg"),zt=Ot("Edg"),Yt=Ct("SogouMobileBrowser"),Xt=Dt("SogouMobileBrowser"),Qt=Ct("MetaSr\\s"),Jt=Dt("MetaSr\\s"),Zt=Ct("TBS"),$t=Dt("TBS"),en=Ct("XWEB"),tn=Dt("XWEB");Ct("MSIE\\s8\\.0");var nn=Ct("MSIE\\/\\d+");!function(){if(nn){var e=/MSIE\s(\d+)\.\d/.exec(xt),t=e&&parseFloat(e[1]);return!t&&/Trident\/7.0/i.test(xt)&&/rv:11.0/.test(xt)&&(t=11),t}}();var rn=Ct("(micromessenger|webbrowser)"),an=Dt("MicroMessenger"),on=!Zt&&Ct("MQQBrowser")&&Ct("COVC"),sn=!Zt&&Ct("MQQBrowser")&&!Ct("COVC"),cn=sn||on?Dt("MQQBrowser"):"",un=!Zt&&Ct(" QQBrowser"),ln=Dt(" QQBrowser"),dn=!Zt&&Ct("QQBrowserLite"),hn=Dt("QQBrowserLite"),fn=!Zt&&Ct("MQBHD"),pn=Dt("MQBHD"),vn=Ct("Windows"),mn=!Vt&&Ct("MAC OS X"),yn=!Ft&&Ct("Linux"),gn=Ct("CrOS");Ct("MicroMessenger");var kn=Ct("UCBrowser");Ct("Electron");var En=Ct("MiuiBrowser"),_n=Dt("MiuiBrowser"),Tn=Ct("HuaweiBrowser"),In=Ct("Huawei")||Ct("HUAWEI"),bn=Ct("Honor")||Ct("HONOR"),Sn=Dt("HuaweiBrowser"),wn=Ct("SamsungBrowser"),An=Dt("SamsungBrowser"),Rn=Ct("HeyTapBrowser"),xn=Dt("HeyTapBrowser"),Cn=Ct("VivoBrowser"),Dn=Dt("VivoBrowser"),On=Ct("OpenHarmony");Dt("OpenHarmony");var Nn,Mn=function(){return Ot("Chrome")},Ln=Ct("Chrome"),Pn=!Gt&&!Qt&&!Yt&&!Zt&&!en&&!qt&&!un&&!En&&!Tn&&!wn&&!Rn&&!Cn&&Ln,Un=Ct("HeadlessChrome"),Vn=Mn(),Fn=Dt("Chrome"),Bn=!Ln&&!sn&&!on&&!dn&&!fn&&Ct("Safari"),jn=Bn||Vt,Hn=Dt("Version"),Gn=function(){if(Lt)return Hn;if(Vt){var e=xt.match(/OS (\d+)_(\d+)/i);if(e&&e[1]){var t=e[1];return e[2]&&(t+=".".concat(e[2])),t}}return""}(),Wn=Number(Gn.split(".")[0]),qn="15.1"===Gn,Kn=14===(Nn=Number(Gn.split(".")[0]))||13===Nn,zn=Ct("CriOS")&&"11.1.1"===Hn,Yn="undefined"!=typeof location&&("file:"===location.protocol||"localhost"===location.hostname||"127.0.0.1"===location.hostname),Xn=function(){var e;return function(){if(void 0===e)try{e=!!window.localStorage}catch(t){e=!1}return e}}(),Qn=function(){var e=new Map([[Bt,["Firefox",jt]],[qt,["Edg",Kt]],[Pn,["Chrome",Fn]],[Bn,["Safari",Hn]],[Zt,["TBS",$t]],[en,["XWEB",tn]],[rn&&Pt,["WeChat",an]],[un,["QQ(Win)",ln]],[sn,["QQ(Mobile)",cn]],[on,["QQ(Mobile X5)",cn]],[dn,["QQ(Mac)",hn]],[fn,["QQ(iPad)",pn]],[En,["MI",_n]],[Tn,["HW",Sn]],[wn,["Samsung",An]],[Rn,["OPPO",xn]],[Cn,["VIVO",Dn]],[Gt,["EDGE",Wt]],[Yt,["SogouMobile",Xt]],[Qt,["Sogou",Jt]]]),t="unknown",n="unknown";if(e.has(!0)){var r=y(e.get(!0),2);t=r[0],n=r[1]}return{name:t,version:n}}();var Jn=new Map([[Ft,"Android"],[Vt,"iOS"],[vn,"Windows"],[mn,"MacOS"],[yn,"Linux"],[gn,"ChromeOS"]]),Zn=function(){return Jn.get(!0)?Jn.get(!0):"unknown"};function $n(){return vn?1:Ft?2:mn?3:Vt?4:yn?5:gn?6:0}var er=function(){var e=Zn();return e+="/".concat(Qn.name,"/").concat(Bn?Qn.version:Qn.version.split(".")[0])},tr={PLAY_FAILED:"PLAY_FAILED",NOT_SUPPORTED_HTTP:"NOT_SUPPORTED_HTTP",MICROPHONE_NOT_FOUND:"MICROPHONE_NOT_FOUND",CAMERA_NOT_FOUND:"CAMERA_NOT_FOUND"},nr={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,a="".concat(t||n.name),o="";return o=Array.isArray(n.type)?n.type.join("|"):n.type,"'".concat(a,"' must be type of ").concat(o," when calling ").concat(r,"(), received type: ").concat(Be(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,a="".concat(t||n.name),o="".concat(n.instanceOf.name||n.instanceOf);return"'".concat(a,"' must be instanceof ").concat(o," when calling ").concat(r,"(), received type: ").concat(Be(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/".concat("audience",', please call switchRole("',"anchor",'") firstly before publish().'),INVALID_INITIALIZE:"cannot publish stream because stream is not initialized, is switching device, or has been closed.",INVALID_DUPLICATE_PUBLISHING: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 ".concat("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,"()")}};(new Date).getTime();var rr=function(){return(new Date).getTime()+0},ir=function(){var e=new Date;return e.setTime(rr()),e.toLocaleString()};function ar(e){var t=e.url,n=e.body,r=e.method,i=void 0===r?"POST":r,a=e.timeout,o=e.priority;return new Promise((function(e,r){if("fetch"in window)return fetch(t,{method:i,body:n,priority:o}).then((function(e){return e.text()})).then((function(t){try{e({data:JSON.parse(t)})}catch(n){e({data:t})}}),r);var s=new XMLHttpRequest;s.onreadystatechange=function(){if(4===s.readyState)if(s.status>=200&&s.status<300)try{var t=JSON.parse(s.response);e({data:t})}catch(t){e({data:s.response})}else r({status:s.status,statusText:s.statusText||"request failed!"})},s.timeout=a||5e3,s.open(i,t,!0),s.send(n)}))}var or=Object.prototype.hasOwnProperty,sr=function(e){return"function"==typeof e},cr=function(e){return e.isRemote};function ur(e){if(null==e)return!0;if("boolean"==typeof e)return!1;if("number"==typeof e)return 0===e;if("string"==typeof e)return 0===e.length;if("function"==typeof e)return 0===e.length;if(Array.isArray(e))return 0===e.length;if(e instanceof Error)return""===e.message;if(function(e){if(!e||"object"!==I(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(or.call(e,t))return!1;return!0}return!1}var lr=function(e){var t=e.retryFunction,r=e.settings,i=e.onError,a=e.onRetrying,o=e.onRetryFailed,s=e.onRetrySuccess,c=e.context;return function(){for(var e=this,u=arguments.length,l=new Array(u),d=0;d<u;d++)l[d]=arguments[d];var h=r.retries,f=void 0===h?5:h,v=r.timeout,m=void 0===v?1e3:v,y=0,g=-1,k=0,E=function(){var r=n(p().mark((function n(r,u){var d,h,v,_;return p().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return d=c||e,n.prev=1,n.next=4,t.apply(d,l);case 4:h=n.sent,y>0&&s&&s.call(e,y),y=0,r(h),n.next=15;break;case 10:n.prev=10,n.t0=n.catch(1),v=function(){clearTimeout(g),y=0,k=2,u(n.t0)},_=function(){2!==k&&y<(sr(f)?f():f)?(y++,k=1,sr(a)&&a.call(e,y,v),g=window.setTimeout((function(){g=-1,E(r,u)}),sr(m)?m(y):m)):(v(),sr(o)&&o.call(e,n.t0))},sr(i)?i.call(e,{error:n.t0,retry:_,reject:u,retryFuncArgs:l,retriedCount:y}):_();case 15:case"end":return n.stop()}}),n,null,[[1,10]])})));return function(e,t){return r.apply(this,arguments)}}();return new Promise(E)}},dr=function(){return s((function e(t){i(this,e),G(this,"userId"),G(this,"remoteUserId"),G(this,"id"),G(this,"sdkAppId"),G(this,"type"),G(this,"isLocal"),this.id=t.id,this.userId=t.userId,this.sdkAppId=t.sdkAppId,this.remoteUserId=t.remoteUserId,this.isLocal="boolean"!=typeof t.isLocal||t.isLocal,this.type=this.isLocal?"":t.type}),[{key:"createChild",value:function(e){return Object.setPrototypeOf(e,this)}},{key:"setUserId",value:function(e){this.userId=e}},{key:"setSdkAppId",value:function(e){this.sdkAppId=e}},{key:"log",value:function(e,t){var n=this.isLocal?this.userId:this.remoteUserId;t.unshift("[".concat(this.isLocal?"↑":"↓").concat(this.type&&"main"!==this.type?"*":"").concat(this.id).concat(n?"|".concat(n):"","]")),kr.log(e,t,void 0===this.userId||ur(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)}}])}(),hr=new(j(W()).default),fr=function(e){return e.ROOM_DESTROY="1",e.JOIN_START="21",e.JOIN_SCHEDULE_SUCCESS="22",e.JOIN_SIGNAL_CONNECTION_START="23",e.JOIN_SIGNAL_CONNECTION_END="24",e.JOIN_SEND_CMD="25",e.JOIN_RECEIVED_CMD_RES="26",e.JOIN_SUCCESS="27",e.JOIN_FAILED="28",e.LEAVE_START="51",e.LEAVE_SEND_CMD="52",e.LEAVE_SUCCESS="53",e.PUBLISH_START="61",e.SEND_FIRST_VIDEO_FRAME="62",e.PUBLISH_FAILED="63",e.SUBSCRIBE_START="81",e.SUBSCRIBE_SUCCESS="82",e.SUBSCRIBE_FAILED="84",e.UNSUBSCRIBE_SUCCESS="83",e.LOCAL_TRACK_CAPTURE_START="101",e.LOCAL_TRACK_CAPTURE_SUCCESS="102",e.LOCAL_TRACK_CAPTURE_FAILED="103",e.LOCAL_TRACK_PUBLISHED="104",e.LOCAL_TRACK_UNPUBLISHED="105",e.LOCAL_TRACK_REPLACED="106",e.SWITCH_DEVICE_SUCCESS="107",e.TRACK_MUTED="108",e.TRACK_UNMUTED="109",e.REMOTE_TRACK_SUBSCRIBED="110",e.REMOTE_TRACK_UNSUBSCRIBED="111",e.LOCAL_TRACK_RECAPTURE="112",e.LOCAL_AUDIO_STARTED="113",e.LOCAL_AUDIO_STOPPED="114",e.REMOTE_AUDIO_STARTED="115",e.REMOTE_AUDIO_STOPPED="116",e.PLAY_TRACK_START="151",e.PLAYER_STATE_CHANGED="152",e.VIDEO_LOADED_DATA="153",e.AUTOPLAY_DIALOG_CLICK_CONFIRM="154",e.SIGNAL_CONNECTION_STATE_CHANGED="201",e.PEER_CONNECTION_STATE_CHANGED="202",e.SINGLE_CONNECTION_STAT="203",e.SPC_RECONNECTED="204",e.HEARTBEAT_REPORT="251",e.RECEIVED_PUBLISHED_USER_LIST="252",e.REMOTE_PUBLISH_STATE_CHANGED="253",e.AUDIO_LEVEL_INTERVAL="260",e.NETWORK_QUALITY="261",e.VIDEO_CODEC_IMPLEMENTATION_CHANGED="262",e.QUALITY_LIMITATION_CHANGED="263",e.LOG="264",e.AUDIO_PROCESSOR_DEBUG="265",e.SWITCH_ROOM_START="401",e.SWITCH_ROOM_SUCCESS="407",e.SWITCH_ROOM_FAILED="408",e}(fr||{}),pr=fr,vr="%cTRTC%c%s",mr="padding: 1px 4px;border-radius: 3px;color: #fff;background: #1E88E5;",yr="display: inline",gr=function(){function e(){i(this,e),G(this,"_isEnableUploadLog",!0),G(this,"_localJoinedUser",new Map),G(this,"_queue",[]),G(this,"_timeoutId",-1),G(this,"_logLevel",1),G(this,"_logLevelToUpload",2),Q||J||(this.checkURLParam(),this.installEvents())}return s(e,[{key:"isAbleToUpload",get:function(){return this._isEnableUploadLog&&-1!==this._timeoutId}},{key:"installEvents",value:function(){var e=this;hr.on(pr.JOIN_SCHEDULE_SUCCESS,(function(t){var n,r=t.schedule;(null==(n=null==r?void 0:r.config)?void 0:n.logLevelToUpload)&&te[r.config.logLevelToUpload]&&(e._logLevelToUpload=r.config.logLevelToUpload)})),hr.on(pr.JOIN_SUCCESS,(function(t){var n=t.room;e.addJoinedUser({userId:n.userId,sdkAppId:n.sdkAppId}),e.startUpload()})),hr.once(pr.JOIN_FAILED,(function(){e.startUpload()})),hr.on(pr.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(){if(50===n)return 1;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(Ge(r.userId)&&We(r.sdkAppId)){var i=r.userId,a=r.sdkAppId;t.map.has(i)?t.map.get(i).logs.push(r):t.map.set(i,{userId:i,sdkAppId:a,logs:[r]})}};n<this._queue.length&&!r();n++);return t.map.size>0&&(t.splicedQueue=this._queue.splice(0,n)),t}},{key:"upload",value:(t=n(p().mark((function e(){var t,n,r,i,a,o,s,c,u,l;return p().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(0!==this._queue.length&&this._isEnableUploadLog){e.next=2;break}return e.abrupt("return");case 2:if(t=this.getLogsToUpload(),n=t.map,r=t.splicedQueue,0!==n.size){e.next=5;break}return e.abrupt("return");case 5:e.prev=5,i=_(n.values()),a=0;case 8:if(!(a<i.length)){e.next=16;break}return o=i[a],s=o.userId,c=o.sdkAppId,u=o.logs,e.next=12,this.uploadLogWithRetry(JSON.stringify({timestamp:ir(),sdkAppId:String(c),userId:s,version:X,log:u.map((function(e){return e.log})).join("\n")}),c);case 12:u.forEach((function(e){return e.uploaded=!0}));case 13:a++,e.next=8;break;case 16:e.next=20;break;case 18:e.prev=18,e.t0=e.catch(5);case 20:(l=r.filter((function(e){return!e.uploaded}))).length>0&&(this._queue=l.concat(this._queue));case 22:case"end":return e.stop()}}),e,this,[[5,18]])}))),function(){return t.apply(this,arguments)})},{key:"uploadLogWithRetry",value:function(e,t){return lr({retryFunction:function(){return ar({url:be(t,$),body:e,timeout:5e3,priority:"low"})},settings:{retries:3,timeout:2e3},onError:function(e){(0,e.retry)()}})()}},{key:"getPrefix",value:function(e){var t,n,r=new Date;return r.setTime(rr()),"[".concat((t=r,n=String(t.getMilliseconds()),"padStart"in String.prototype&&(n=n.toString().padStart(3,"0")),"".concat(t.toTimeString().replace(/.*(\d{2}:\d{2}:\d{2}).*/,"$1"),":").concat(n)),"] <").concat(te[e],">")}},{key:"getLogLevel",value:function(){return this._logLevel}},{key:"setLogLevel",value:function(e){He(te[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(Ge(e))return e;try{return e instanceof Error?e.toString():JSON.stringify(e)}catch(e){return""}}},{key:"log",value:function(t,n){var r,i=this,a=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],o=arguments.length>3?arguments[3]:void 0,s=arguments.length>4?arguments[4]:void 0;n.unshift(this.getPrefix(t));var c={log:n.reduce((function(e,t){return"".concat(e," ").concat(i.logChunkToString(t)).trim()}),""),level:t,userId:o,sdkAppId:s,forAllJoinedClients:a};if(hr.emit(pr.LOG,{log:c}),this._isEnableUploadLog&&t>=this._logLevelToUpload&&this._queue.push(c),!(t<this._logLevel)){var u,l,d=(null==(r=te[t])?void 0:r.toLowerCase())||"info";if(e.PRINT_LOG_TAG)(u=console)[d].apply(u,[vr,mr,yr].concat(_(n)));else(l=console)[d].apply(l,_(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 dr(e)}},{key:"checkURLParam",value:function(){var e=new URLSearchParams(location.search).get("logLevelToUpload"),t=e?Number(e):-1;te[t]&&(this._logLevelToUpload=t)}},{key:"getQueue",value:function(){return this._queue}}]);var t}();G(gr,"PRINT_LOG_TAG",!(Vt||Ft||Un));var kr=new gr,Er=function(e,t){return t?"".concat(Z,"/").concat(e,"/").concat(t):"".concat(Z,"/").concat(e,"/index.html")},_r=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("trtc_error_assistance");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 Tr(e){var t=e.key,n=e.data,r=e.link,i=e.addDocLink,a=void 0===i||i,o="",s="",c="";je(nr[t])?o=nr[t](n):Ge(nr[t])&&(o=nr[t]);var u=_r(),l=u.TRTC_ERROR_INFO,d=u.TRTC_ERROR_LINK;r?c="".concat(r.className,".html#").concat(r.fnName):d&&d[t]&&(je(d[t])?c=d[t](n):Ge(d[t])&&(c=d[t]));var h=o;return Pe()&&(l&&l[t]&&(je(l[t])?s=l[t](n):Ge(l[t])&&(s=l[t])),s&&(h=a?"".concat(s,"\n请查看文档: ").concat(Er("zh-cn",c),"\n\n"):"".concat(s,"\n\n"),h+=o)),a&&(h+=" \nRefer to: ".concat(Er("en",c),"\n")),h}var Ir=new(function(){return s((function e(){i(this,e),G(this,"_prefix","TRTC"),G(this,"_queue",new Map)}),[{key:"getRealKey",value:function(e){return"".concat(this._prefix,"_").concat(e)}},{key:"checkStorage",value:function(){var e=this;Xn()&&(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(e){return!1}return!1})).forEach((function(e){return localStorage.removeItem(e)})))}},{key:"doFlush",value:function(){if(Xn())try{var e,t=c(this._queue);try{for(t.s();!(e=t.n()).done;){var n=y(e.value,2),r=n[0],i=n[1];localStorage.setItem(r,JSON.stringify(i))}}catch(e){t.e(e)}finally{t.f()}}catch(e){kr.warn(e)}}},{key:"getItem",value:function(e){if(!Xn())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(e){kr.warn(e)}}},{key:"setItem",value:function(e,t){if(Xn())try{var n={expiresIn:Date.now()+6048e5,value:t};this._queue.set(this.getRealKey(e),n)}catch(e){kr.warn(e)}}},{key:"deleteItem",value:function(e){if(!Xn())return!1;try{return e=this.getRealKey(e),this._queue.delete(e),localStorage.removeItem(e),!0}catch(e){return kr.warn(e),!1}}},{key:"clear",value:function(){if(Xn())try{localStorage.clear()}catch(e){kr.warn(e)}}}])}()),br=j(Y()),Sr=function(){return s((function e(){var t=this,n=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];i(this,e),G(this,"countMap",new Map),G(this,"distributionMap",new Map),G(this,"version"),G(this,"log",kr.createLogger({id:"kv"})),n&&(hr.on("102",(function(e){var n=e.track,r=e.cost;t.addSuccessEvent({key:n.kind===oe.AUDIO?501700:511700,cost:r})})),hr.on("103",(function(e){var n=e.track,r=e.error;t.addFailedEvent({key:n.kind===oe.AUDIO?501700:511700,error:r})})))}),[{key:"getReportData",value:function(){var e={msg_sdk_basic_info:{uint32_sdk_version:kt(this.version||X),uint32_terminal_type:15,bytes_device_name:"",bytes_os_version:"",uint32_framework:30,uint32_network_type:0},stats_count:_(this.countMap.entries()).map((function(e){var t=y(e,2);return{uint32_key:t[0],uint32_count:t[1]}})),stats_distribution:_(this.distributionMap.entries()).map((function(e){var t=y(e,2);return{uint32_key:t[0],distribution_items:_(t[1].entries()).map((function(e){var t=y(e,2);return{uint32_item_key:t[0],uint32_item_value:t[1]}}))}}))};return this.countMap.clear(),this.distributionMap.clear(),e}},{key:"clear",value:function(){this.countMap.clear(),this.distributionMap.clear()}},{key:"isEnumKey",value:function(e){var t=+String(e).slice(-3);return t>=700&&t<799}},{key:"isErrorCodeKey",value:function(e){var t=+String(e).slice(-3);return t>=600&&t<699}},{key:"isCountKey",value:function(e){var t=+String(e).slice(-3);return t>=0&&t<599}},{key:"isNumberKey",value:function(e){var t=+String(e).slice(-3);return t>=800&&t<899}},{key:"addCount",value:function(e){var t=e.key,n=e.useUV,r=void 0!==n&&n;this.isCountKey(t)?r&&this.countMap.has(t)||this.countMap.set(t,(this.countMap.get(t)||0)+1):this.log.debug("".concat(t," is not count key, last 3 number should be 0~599"))}},{key:"addEnum",value:function(e){var t,n=e.key,r=e.value,i=e.useUV,a=void 0===i||i;if(!this.isEnumKey(n))return this.log.debug("".concat(n," is not enum key, last 3 number should be 700~799"));if(!a||!this.countMap.has(n)){this.countMap.set(n,(this.countMap.get(n)||0)+1);var o=(null==(t=this.distributionMap)?void 0:t.get(n))||new Map;o.set(r,(o.get(r)||0)+1),this.distributionMap.set(n,o)}}},{key:"addNumber",value:function(e){var t,n=e.key,r=e.value,i=e.split,a=void 0===i?100:i,o=e.useUV,s=void 0!==o&&o,c=e.max,u=void 0===c?5e3:c;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)){r>u&&(r=u),this.countMap.set(n,(this.countMap.get(n)||0)+1);var l=(null==(t=this.distributionMap)?void 0:t.get(n))||new Map,d=0;if(We(a))d=Math.floor(r/a);else for(var h=a.length-1;h>0;h--)if(r>a[h]){d=h;break}l.set(d,(l.get(d)||0)+1),this.distributionMap.set(n,l)}}},{key:"addSuccessEvent",value:function(e){var t=e.key,n=e.cost,r=e.timeKey,i=e.split;if(t&&(this.addEnum({key:t,value:1,useUV:!1}),n)){var a=+String(t).slice(-3);a<800&&a>=700?this.addNumber({key:r||t+100,value:n,split:i}):r||this.log.debug("time stat ignored, ".concat(t))}}},{key:"addFailedEvent",value:function(e){var t=e.key,n=e.error;if(t){var r=Ee.UNKNOWN;n&&(We(n)?r=n:He(n.extraCode)&&He(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})}}}])}(),wr=new Sr(!0);new Sr(!1);var Ar=wr,Rr={result:!1,detail:{isBrowserSupported:!1,isWebRTCSupported:!1,isWebCodecsSupported:!1,isMediaDevicesSupported:!1,isScreenShareSupported:!1,isSmallStreamSupported:!1,isH264EncodeSupported:!1,isVp8EncodeSupported:!1,isH264DecodeSupported:!1,isVp8DecodeSupported:!1}},xr=new Map([[Bt,["Firefox",jt]],[qt,["Edg",Kt]],[Pn,["Chrome",Fn]],[Bn,["Safari",Hn]],[Zt,["TBS",$t]],[en,["XWEB",tn]],[rn&&Pt,["WeChat",an]],[un,["QQ(Win)",ln]],[sn,["QQ(Mobile)",cn]],[on,["QQ(Mobile X5)",cn]],[dn,["QQ(Mac)",hn]],[fn,["QQ(iPad)",pn]],[En,["MI",_n]],[Tn,["HW",Sn]],[wn,["Samsung",An]],[Rn,["OPPO",xn]],[Cn,["VIVO",Dn]],[Gt,["EDGE",Wt]],[Yt,["SogouMobile",Xt]],[Qt,["Sogou",Jt]]]);function Cr(){var e=xr.get(!0);return{browserName:e?e[0]:"unknown",browserVersion:e?e[1]:"unknown"}}var Dr=function(){return!kn&&!Gt&&(!(qt&&zt<80)&&!(Bt&&Ht<56))},Or=function(){return["VideoDecoder","VideoEncoder","AudioEncoder","AudioDecoder"].every((function(e){return e in window}))},Nr=function(){if(!navigator.mediaDevices)return Lr()||kr.error(nr.NOT_SUPPORTED_MEDIA),!1;var e=["getUserMedia","enumerateDevices"];return e.filter((function(e){return e in navigator.mediaDevices})).length===e.length},Mr=!1;function Lr(){return"http:"===location.protocol&&!Yn&&(Mr||kr.error(Tr({key:tr.NOT_SUPPORTED_HTTP})),Mr=!0,!0)}var Pr=function(){return(null==window?void 0:window.OffscreenCanvas)&&(null==window?void 0:window.MediaStreamTrackProcessor)&&(null==window?void 0:window.MediaStreamTrackGenerator)},Ur=function(){var e=n(p().mark((function e(){var t,n,r,i,a,o;return p().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!Rr.detail.isH264EncodeSupported||!Rr.detail.isVp8EncodeSupported){e.next=2;break}return e.abrupt("return",{isH264EncodeSupported:Rr.detail.isH264EncodeSupported,isVp8EncodeSupported:Rr.detail.isVp8EncodeSupported});case 2:return n=!1,r=!1,e.prev=4,i=new RTCPeerConnection,(a=document.createElement(oe.CANVAS)).getContext("2d"),o=a.captureStream(0),i.addTrack(o.getVideoTracks()[0],o),e.next=12,i.createOffer();case 12:return-1!==(t=e.sent).sdp.toLowerCase().indexOf("h264")&&(n=!0),-1!==t.sdp.toLowerCase().indexOf("vp8")&&(r=!0),i.close(),Rr.detail.isH264EncodeSupported=n,Rr.detail.isVp8EncodeSupported=r,e.abrupt("return",{isH264EncodeSupported:Rr.detail.isH264EncodeSupported,isVp8EncodeSupported:Rr.detail.isVp8EncodeSupported});case 21:return e.prev=21,e.t0=e.catch(4),e.abrupt("return",{isH264EncodeSupported:!1,isVp8EncodeSupported:!1});case 24:case"end":return e.stop()}}),e,null,[[4,21]])})));return function(){return e.apply(this,arguments)}}(),Vr=function(){var e=n(p().mark((function e(){var t,n,r,i;return p().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!Rr.detail.isH264DecodeSupported||!Rr.detail.isVp8DecodeSupported){e.next=2;break}return e.abrupt("return",{isH264DecodeSupported:Rr.detail.isH264DecodeSupported,isVp8DecodeSupported:Rr.detail.isVp8DecodeSupported});case 2:if(n=!1,r=!1,e.prev=4,i=new RTCPeerConnection,ii()){e.next=12;break}return e.next=9,i.createOffer({offerToReceiveVideo:!0});case 9:t=e.sent,e.next=16;break;case 12:return i.addTransceiver(oe.VIDEO,{direction:"recvonly"}),e.next=15,i.createOffer();case 15:t=e.sent;case 16:return-1!==t.sdp.toLowerCase().indexOf("h264")&&(n=!0),-1!==t.sdp.toLowerCase().indexOf("vp8")&&(r=!0),i.close(),e.abrupt("return",{isH264DecodeSupported:n,isVp8DecodeSupported:r});case 22:return e.prev=22,e.t0=e.catch(4),e.abrupt("return",{isH264DecodeSupported:!1,isVp8DecodeSupported:!1});case 25:case"end":return e.stop()}}),e,null,[[4,22]])})));return function(){return e.apply(this,arguments)}}(),Fr=Tt(n(p().mark((function e(){var t,n,r,i,a,o,s,c,u,l,d,h,f,v,m,g,k;return p().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(Rr.result&&Rr.detail.isH264EncodeSupported&&Rr.detail.isVp8EncodeSupported&&Rr.detail.isH264DecodeSupported&&Rr.detail.isVp8DecodeSupported)){e.next=2;break}return e.abrupt("return",Rr);case 2:return t=Date.now(),n=Dr(),r=mi(),i=Or(),a=Nr(),e.next=9,Promise.all([Ur(),Vr()]);case 9:if(o=e.sent,s=y(o,2),c=s[0],u=c.isH264EncodeSupported,l=c.isVp8EncodeSupported,d=s[1],h=d.isH264DecodeSupported,f=d.isVp8DecodeSupported,u&&l){e.next=24;break}return e.next=20,Ur();case 20:v=e.sent,kr.warn("detect encode again h264:".concat(u," vp8:").concat(l," result: ").concat(JSON.stringify(v))),u=v.isH264EncodeSupported,l=v.isVp8EncodeSupported;case 24:if(!(u&&h&&Ft&&Ln)||en||Zt){e.next=32;break}return e.next=27,Gr();case 27:m=e.sent,g=m.encode,k=m.decode,u=g,h=k;case 32:return Rr.result=n&&r&&a&&(u||l)&&(h||f),Rr.detail.isBrowserSupported=n,Rr.detail.isWebRTCSupported=r,Rr.detail.isWebCodecsSupported=i,Rr.detail.isMediaDevicesSupported=a,Rr.detail.isScreenShareSupported=jr(),Rr.detail.isSmallStreamSupported=$r(),Rr.detail.isH264EncodeSupported=u,Rr.detail.isVp8EncodeSupported=l,Rr.detail.isH264DecodeSupported=h,Rr.detail.isVp8DecodeSupported=f,Rr.result||kr.error("".concat(navigator.userAgent," ").concat(vt(Rr.detail,!1))),Ir.setItem(Ti,{ua:navigator.userAgent,checkResult:Rr}),Ar.addNumber({key:523800,value:Date.now()-t}),e.abrupt("return",Rr);case 47:case"end":return e.stop()}}),e)})))),Br=function(){return Rr.result},jr=function(){return!(!navigator.mediaDevices||!navigator.mediaDevices.getDisplayMedia)},Hr=null;function Gr(){return Wr.apply(this,arguments)}function Wr(){return Wr=n(p().mark((function e(){return p().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!Hr){e.next=2;break}return e.abrupt("return",Hr);case 2:return Hr=new Promise(function(){var e=n(p().mark((function e(t){var r,i,a,o,s,c,u,l,d,h,f,v,m,g;return p().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r={encode:!1,decode:!1},i=function(){},e.prev=2,a=document.createElement("canvas"),o=a.getContext("2d"),a.width=320,a.height=240,s=setInterval((function(){o.fillText("test",Math.floor(320*Math.random()),Math.floor(240*Math.random()))}),66),c=-1,u=-1,i=function(){clearInterval(c),clearInterval(s),clearTimeout(u),d.close(),h.close(),l.getTracks().forEach((function(e){return e.stop()}))},u=setTimeout((function(){i(),t(r)}),2e3),l=a.captureStream(),d=new RTCPeerConnection({}),h=new RTCPeerConnection({offerToReceiveAudio:!0,offerToReceiveVideo:!0}),d.addEventListener("icecandidate",(function(e){return h.addIceCandidate(e.candidate)})),h.addEventListener("icecandidate",(function(e){return d.addIceCandidate(e.candidate)})),d.addTrack(l.getVideoTracks()[0],l),e.next=20,d.createOffer();case 20:return f=e.sent,e.next=23,d.setLocalDescription(f);case 23:return e.next=25,h.setRemoteDescription(f);case 25:return e.next=27,h.createAnswer();case 27:return v=e.sent,m=br.default.parse(v.sdp),g=m.media[0].rtp.findIndex((function(e){return"H264"===e.codec})),m.media[0].rtp=[m.media[0].rtp[g]],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}))),v.sdp=br.default.write(m),e.next=36,h.setLocalDescription(v);case 36:return e.next=38,d.setRemoteDescription(v);case 38:c=setInterval(n(p().mark((function e(){var n,a,o,s;return p().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r.encode&&r.decode&&(i(),t(r)),e.next=3,Promise.all([d.getSenders()[0].getStats(),h.getReceivers()[0].getStats()]);case 3:n=e.sent,a=y(n,2),o=a[0],s=a[1],r.encode||o.forEach((function(e){"outbound-rtp"===e.type&&e.mediaType===oe.VIDEO&&e.bytesSent>0&&(r.encode=!0)})),r.decode||s.forEach((function(e){"inbound-rtp"===e.type&&e.mediaType===oe.VIDEO&&e.bytesReceived>0&&(r.decode=!0)}));case 9:case"end":return e.stop()}}),e)}))),100),e.next=46;break;case 41:e.prev=41,e.t0=e.catch(2),i(),kr.warn("detectH264Supported failed",e.t0),t({encode:!0,decode:!0});case 46:case"end":return e.stop()}}),e,null,[[2,41]])})));return function(t){return e.apply(this,arguments)}}()).then((function(e){return e.encode||(e.decode=!0),e.encode&&e.decode||kr.warn("detectH264Supported encode: ".concat(e.encode," decode: ").concat(e.decode," ").concat("")),e})),e.abrupt("return",Hr);case 4:case"end":return e.stop()}}),e)}))),Wr.apply(this,arguments)}var qr=function(e,t,n){"http:"!==location.protocol||Yn||(e[t]=function(){throw new _e({code:Ee.INVALID_OPERATION,message:nr.NOT_SUPPORTED_HTTP})})},Kr=function(e){return!("candidate-pair"!==e.type||!e.nominated||"in-progress"!==e.state&&"succeeded"!==e.state)&&!(qe(e.selected)&&!e.selected)};function zr(){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 Yr(){return navigator.getUserMedia||navigator.mediaDevices&&navigator.mediaDevices.getUserMedia}function Xr(){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 Qr(){return"captureStream"in HTMLCanvasElement.prototype}function Jr(){return!(rn||Vt||Vn&&Vn<63)&&!(!Dr()||!Qr())}function Zr(){return!(Vn<74||Gt||Wn<11||Ht<46)}function $r(){return Jr()||Zr()}var ei=function(){if(He(window.RTCRtpTransceiver)||!ii())return!1;if(!("currentDirection"in RTCRtpTransceiver.prototype))return!1;var e=null,t=!1;try{(e=new RTCPeerConnection({sdpSemantics:"unified-plan"})).addTransceiver(oe.AUDIO),t=!0}catch(e){}return null==e||e.close(),t};function ti(){return"RTCPeerConnection"in window&&"getReceivers"in window.RTCPeerConnection.prototype}function ni(){return"RTCPeerConnection"in window&&"getSenders"in window.RTCPeerConnection.prototype}function ri(){return"RTCPeerConnection"in window&&"getTransceivers"in window.RTCPeerConnection.prototype}function ii(){return!(11===Wn&&!zn)&&("RTCPeerConnection"in window&&"addTransceiver"in window.RTCPeerConnection.prototype)}var ai=!(!ii()||Ln&&Vn<86);function oi(){return"RTCRtpTransceiver"in window&&"stop"in window.RTCRtpTransceiver.prototype}var si="RTCRtpSender"in window;function ci(){return si&&"replaceTrack"in window.RTCRtpSender.prototype}function ui(){return si&&"setParameters"in window.RTCRtpSender.prototype&&ni()}var li="RTCRtpReceiver"in window&&"getSynchronizationSources"in window.RTCRtpReceiver.prototype,di=window.MediaStreamTrack&&"getSettings"in MediaStreamTrack.prototype,hi=window.MediaStreamTrack&&"getCapabilities"in MediaStreamTrack.prototype,fi=si&&"createEncodedStreams"in window.RTCRtpSender.prototype&&Mn()>=86,pi="RTCRtpScriptTransform"in window,vi=si&&(fi||pi),mi=function(){return["RTCPeerConnection","webkitRTCPeerConnection","RTCIceGatherer"].filter((function(e){return e in window})).length>0};function yi(){var e={AudioDecoder:!1,AudioEncoder:!1,VideoDecoder:!1,VideoEncoder:!1,ImageDecoder:!1};return He(window.AudioDecoder)||(e.AudioDecoder=!0),He(window.AudioEncoder)||(e.AudioEncoder=!0),He(window.VideoDecoder)||(e.VideoDecoder=!0),He(window.VideoEncoder)||(e.VideoEncoder=!0),He(window.ImageDecoder)||(e.ImageDecoder=!0),e}function gi(){return"mediaSession"in navigator&&!He(navigator.mediaSession.setActionHandler)}function ki(){return!He(window.WebTransport)}function Ei(){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 _i(){var e={browser:"".concat(Qn.name,"/").concat(Qn.version),os:Zn(),displayResolution:zr(),isScreenShareSupported:jr(),isWebRTCSupported:mi(),isGetUserMediaSupported:Yr(),isWebAudioSupported:Xr(),isWebSocketsSupported:"WebSocket"in window&&2===window.WebSocket.CLOSING,isWebCodecSupported:yi(),isMediaSessionSupported:gi(),isWebTransportSupported:ki()};return navigator.userAgent.includes("miniProgram")&&(e.browser="mini/".concat(e.browser)),e}var Ti="checkResult";function Ii(){Lr();var e,t,n=Ir.getItem(Ti);n&&n.ua===navigator.userAgent&&n.checkResult&&(e=n.checkResult.detail,t=Rr.detail,Ke(e)&&Object.keys(t).every((function(t){return t in e})))&&(Rr=n.checkResult),Fr()}function bi(){return"requestVideoFrameCallback"in HTMLVideoElement.prototype}var Si="RTCRtpReceiver"in window&&"jitterBufferTarget"in window.RTCRtpReceiver.prototype,wi={x:{required:!0,type:"number"},y:{required:!0,type:"number"},width:{required:!0,type:"number",notLessThanZero:!0,min:1},height:{required:!0,type:"number",notLessThanZero:!0,min:1},zIndex:{required:!0,type:"number"},fillMode:{required:!1,type:"string"},mirror:{required:!1,type:"boolean"},rotation:{required:!1,type:"number"}},Ai=function(e){return{required:!1,type:["string",HTMLElement,null],validate:function(t,n,r){var i=e.errorModule,a=i.RtcError,o=i.ErrorCode,s=i.ErrorCodeDictionary;if(Ge(t)&&!document.getElementById(t))throw new a({code:o.INVALID_PARAMETER,extraCode:s.INVALID_ELEMENT_ID,fnName:r,messageParams:{key:n}})}}},Ri=function(e){return{type:"object",required:!(arguments.length>1&&void 0!==arguments[1])||arguments[1],properties:U({},wi),validate:function(t,n,r,i){var a=e.errorModule,o=a.RtcError,s=a.ErrorCode,c=a.ErrorCodeDictionary;if(t){if(t.fillMode&&!["contain","cover","fill"].includes(t.fillMode))throw new o({code:s.INVALID_PARAMETER,extraCode:c.INVALID_PARAMETER_TYPE,message:"The fillMode parameter must be 'contain', 'cover' or 'fill'",fnName:r});if(t.rotation&&![0,90,180,270].includes(t.rotation))throw new o({code:s.INVALID_PARAMETER,extraCode:c.INVALID_PARAMETER_TYPE,message:"The rotation parameter must be 0, 90, 180 or 270",fnName:r})}}}},xi=function(e){return{type:"array",required:!1,arrayItem:{type:"object",properties:{id:{required:!0,type:"string"},cameraId:{required:!1,type:"string"},videoTrack:{required:!1,instanceof:MediaStreamTrack},profile:{required:!1,type:["string","object"],properties:{width:{type:"number"},height:{type:"number"},frameRate:{type:"number"},bitrate:{type:"number"}}},layout:U({},Ri(e))}}}},Ci=function(e){return{type:"array",required:!1,arrayItem:{type:"object",properties:{id:{required:!0,type:"string"},profile:{required:!1,type:["string","object"],properties:{width:{type:"number"},height:{type:"number"},frameRate:{type:"number"},bitrate:{type:"number"}}},captureElement:{required:!1,type:HTMLElement},preferDisplaySurface:{required:!1,type:"string"},layout:U({},Ri(e))},validate:function(t,n,r){var i=e.errorModule,a=i.RtcError,o=i.ErrorCode,s=i.ErrorCodeDictionary;if(!jr())throw new a({code:o.ENV_NOT_SUPPORTED,fnName:r,extraCode:s.NOT_SUPPORTED_SCREEN_SHARE})}}}},Di=function(e){return{type:"array",required:!1,arrayItem:{type:"object",properties:{id:{required:!0,type:"string"},content:{required:!0,type:"string"},font:{required:!1,type:"string"},color:{required:!1,type:["string",CanvasGradient,CanvasPattern]},layout:U({},Ri(e))}}}},Oi=function(e){return{type:"array",required:!1,arrayItem:{type:"object",properties:{id:{required:!0,type:"string"},url:{required:!0,type:"string"},layout:U({},Ri(e))}}}},Ni=function(e){return{type:"array",required:!1,arrayItem:{type:"object",properties:{id:{required:!0,type:"string"},url:{required:!0,type:"string"},layout:U({},Ri(e))}}}};var Mi=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)}))},Li=j(W()),Pi=Symbol("instance"),Ui=Symbol("cacheResult"),Vi=function(){return s((function e(t,n,r){i(this,e),this.oldState=t,this.newState=n,this.action=r,this.aborted=!1}),[{key:"abort",value:function(e){this.aborted=!0,qi.call(e,this.oldState,new Error("action '".concat(this.action,"' aborted")))}},{key:"toString",value:function(){return"".concat(this.action,"ing")}}])}(),Fi=function(e){function t(e,n,a){var o;return i(this,t),(o=r(this,t,[n])).state=e,o.message=n,o.cause=a,o}return d(t,e),s(t)}(S(Error));var Bi=new Map;function ji(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return function(r,i,a){var o=n.action||i;if(!n.context){var s=Bi.get(r)||[];Bi.has(r)||Bi.set(r,s),s.push({from:e,to:t,action:o})}var c=a.value;a.value=function(){for(var r,i=this,a=this,s=arguments.length,u=new Array(s),l=0;l<s;l++)u[l]=arguments[l];n.context&&(a=Ki.get("function"==typeof n.context?(r=n.context).call.apply(r,[this].concat(u)):n.context));if(a.state===t)return n.sync?a[Ui]:Promise.resolve(a[Ui]);a.state instanceof Vi&&a.state.action==n.abortAction&&a.state.abort(a);var d=null;Array.isArray(e)?0==e.length?a.state instanceof Vi&&a.state.abort(a):"string"==typeof a.state&&e.includes(a.state)||(d=new Fi(a._state,"".concat(a.name," ").concat(o," to ").concat(t," failed: current state ").concat(a._state," not from ").concat(e.join("|")))):e!==a.state&&(d=new Fi(a._state,"".concat(a.name," ").concat(o," to ").concat(t," failed: current state ").concat(a._state," not from ").concat(e)));var h=function(e){if(n.fail&&n.fail.call(i,e),n.sync){if(n.ignoreError)return e;throw e}return n.ignoreError?Promise.resolve(e):Promise.reject(e)};if(d)return h(d);var f=a.state,p=new Vi(f,t,o);qi.call(a,p);var v,m=function(e){var r;return a[Ui]=e,p.aborted||(qi.call(a,t),null===(r=n.success)||void 0===r||r.call(i,a[Ui])),e},y=function(e){return qi.call(a,f,e),h(e)};try{var g=c.apply(this,u);return"object"===I(v=g)&&v&&"then"in v?g.then(m).catch(y):n.sync?m(g):Promise.resolve(m(g))}catch(n){return y(new Fi(a._state,"".concat(a.name," ").concat(o," from ").concat(e," to ").concat(t," failed: ").concat(n),n instanceof Error?n:new Error(String(n))))}}}}var Hi,Gi,Wi=(Hi="undefined"!=typeof window&&window.__AFSM__,Gi="undefined"!=typeof importScripts,Hi?function(e,t){window.dispatchEvent(new CustomEvent(e,{detail:t}))}:Gi?function(e,t){postMessage({type:e,payload:t})}:function(){});function qi(e,t){var n=this._state;this._state=e;var r=e.toString();e&&this.emit(r,n),this.emit(Ki.STATECHANGED,e,n,t),this.updateDevTools({value:e,old:n,err:t instanceof Error?t.message:String(t)})}var Ki=function(e){function t(e,n,a){var o;i(this,t),(o=r(this,t)).name=e,o.groupName=n,o._state=t.INIT,e||(e=Date.now().toString(36)),a?Object.setPrototypeOf(o,a):a=Object.getPrototypeOf(o),n||(o.groupName=o.constructor.name);var s=a[Pi];return s?o.name=s.name+"-"+s.count++:a[Pi]={name:o.name,count:0},o.updateDevTools({diagram:o.stateDiagram}),o}return d(t,e),s(t,[{key:"stateDiagram",get:function(){var e=Object.getPrototypeOf(this),t=Bi.get(e)||[],n=new Set,r=[],i=[],a=new Set,o=Object.getPrototypeOf(e);Bi.has(o)&&(o.stateDiagram.forEach((function(e){return n.add(e)})),o.allStates.forEach((function(e){return a.add(e)}))),t.forEach((function(e){var t=e.from,n=e.to,a=e.action;"string"==typeof t?r.push({from:t,to:n,action:a}):t.length?t.forEach((function(e){r.push({from:e,to:n,action:a})})):i.push({to:n,action:a})})),r.forEach((function(e){var t=e.from,r=e.to,i=e.action;a.add(t),a.add(r),a.add(i+"ing"),n.add("".concat(t," --\x3e ").concat(i,"ing : ").concat(i)),n.add("".concat(i,"ing --\x3e ").concat(r," : ").concat(i," 🟢")),n.add("".concat(i,"ing --\x3e ").concat(t," : ").concat(i," 🔴"))})),i.forEach((function(e){var t=e.to,r=e.action;n.add("".concat(r,"ing --\x3e ").concat(t," : ").concat(r," 🟢")),a.forEach((function(e){e!==t&&n.add("".concat(e," --\x3e ").concat(r,"ing : ").concat(r))}))}));var s=_(n);return Object.defineProperties(e,{stateDiagram:{value:s},allStates:{value:a}}),s}},{key:"updateDevTools",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};Wi(t.UPDATEAFSM,Object.assign({name:this.name,group:this.groupName},e))}},{key:"state",get:function(){return this._state},set:function(e){qi.call(this,e)}}],[{key:"get",value:function(e){var n;return"string"==typeof e?(n=t.instances.get(e))||t.instances.set(e,n=new t(e,void 0,Object.create(t.prototype))):(n=t.instances2.get(e))||t.instances2.set(e,n=new t(e.constructor.name,void 0,Object.create(t.prototype))),n}},{key:"getState",value:function(e){var n;return null===(n=t.get(e))||void 0===n?void 0:n.state}}])}(Li.default);Ki.STATECHANGED="stateChanged",Ki.UPDATEAFSM="updateAFSM",Ki.INIT="[*]",Ki.ON="on",Ki.OFF="off",Ki.instances=new Map,Ki.instances2=new WeakMap;var zi="undefined"!=typeof window,Yi=zi&&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)},Xi=zi&&window.cancelIdleCallback||function(e){clearTimeout(e)},Qi=zi&&(window.cancelAnimationFrame||window.mozCancelAnimationFrame),Ji=function(){function e(){i(this,e)}return s(e,null,[{key:"generateTaskID",value:function(){return this.currentTaskID++}},{key:"run",value:function(e,t,n){(null==n?void 0:n.fps)&&(n.delay=n.delay||Number((1e3/n.fps).toFixed(2))),n=U(U({},"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=V(U({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&&(e.isBreakLoop(r)?(null==(n=e.sharedWorker)||n.postMessage({type:"stop",taskId:r.taskID}),e.workerTasks.delete(r.taskID)):(r.callback(),r.loopCount+=1))}}),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=tt(),i=function(){if((n=tt()-r)>=t.delay&&(r=tt()-Math.floor(n%t.delay),t.callback(),t.loopCount+=1),!e.isBreakLoop(t))return t.ricID=Yi(i,{timeout:t.delay})};return t.ricID=Yi(i,{timeout:t.delay})}},{key:"raf",value:function(t){var n,r=tt(),i=function(){if(document.hidden&&t.backgroundTask){if(n=tt()-r,r=tt(),t.callback(),t.loopCount+=1,e.isBreakLoop(t))return;return t.timeoutID=setTimeout(i,t.delay-Math.floor(n%t.delay))}if((n=tt()-r)>=t.delay&&(r=tt()-Math.floor(n%t.delay),t.callback(),t.loopCount+=1),!e.isBreakLoop(t))return t.rafID=requestAnimationFrame(i)};if(t.rafID=requestAnimationFrame(i),t.backgroundTask){var a=function(){if(document.hidden){var e=tt()-r;e>=t.delay?i():t.timeoutID=setTimeout(i,t.delay-e)}};document.addEventListener("visibilitychange",a),t.onVisibilitychange=a,document.hidden&&a()}return t.taskID}},{key:"hasTask",value:function(e){return this.taskMap.has(e)}},{key:"clearTask",value:function(e){if(!this.taskMap.has(e))return!0;var t=this.taskMap.get(e),n=t.intervalID,r=t.timeoutID,i=t.rafID,a=t.ricID,o=t.onVisibilitychange;return n&&clearInterval(n),r&&clearTimeout(r),i&&Qi&&Qi(i),a&&Xi(a),o&&document.removeEventListener("visibilitychange",o),this.taskMap.delete(e),!0}},{key:"isBreakLoop",value:function(e){return!this.hasTask(e.taskID)||0!==e.count&&e.loopCount>=e.count&&(this.clearTask(e.taskID),!0)}}])}();G(Ji,"taskMap",new Map),G(Ji,"currentTaskID",1),G(Ji,"sharedWorker",null),G(Ji,"workerTasks",new Map);var Zi=Ji,$i={LOADED_DATA:oe.LOADEDDATA,LOADED_META_DATA:oe.LOADEDMETADATA,MEDIA_TRACK_CHANGED:"media-track-changed",PLAYER_STATE_CHANGED:"player-state-changed",ERROR:"error"},ea={};B(ea,{create:function(){return na},remove:function(){return ra}});var ta=new WeakMap;function na(e,t){ta.has(e)||ta.set(e,[]);var n=ta.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 ra(e){var t=ta.get(e);t&&(t.forEach((function(e){return e()})),ta.delete(e))}var ia=new(function(){return s((function e(){i(this,e),G(this,"_roomIdMap",new Map),G(this,"_configs"),"undefined"==typeof registerProcessor&&(this._configs={sdkAppId:"",userId:"",version:X,env:ee,browserVersion:Qn.name+Qn.version,ua:navigator.userAgent})}),[{key:"setConfig",value:function(e){var t=e.sdkAppId,n=e.env,r=e.userId,i=e.roomId;t!==this._configs.sdkAppId&&(this._configs.sdkAppId=String(t)),this._configs.env=n,this._configs.userId=r,this._roomIdMap.set(r,String(i))}},{key:"logSuccessEvent",value:function(e){!Yn&&kr.isAbleToUpload&&this._configs.env===ee&&this.uploadEventToKibana(V(U({},e),{result:"success"}))}},{key:"logFailedEvent",value:function(e){if(!Yn&&kr.isAbleToUpload){var t=e.eventType,n=e.code,r=e.error,i=e.userId,a={roomId:this._roomIdMap.get(i||this._configs.userId),userId:i,eventType:t,result:"failed",code:n||(null==r?void 0:r.extraCode)||(null==r?void 0:r.code)||Ee.UNKNOWN};this._configs.env===ee&&this.uploadEventToKibana(V(U({},a),{error:r}))}}},{key:"uploadEventToKibana",value:function(e){var t="stat-".concat(e.eventType,"-").concat(e.result);"delta-join"!==e.eventType&&"delta-leave"!==e.eventType&&"delta-publish"!==e.eventType||(t="".concat(e.eventType,":").concat(e.delta)),this.uploadEvent({log:t,userId:e.userId}),"failed"===e.result&&(t="stat-".concat(e.eventType,"-").concat(e.result,"-").concat(e.code),this.uploadEvent({log:t,userId:e.userId,error:e.error}))}},{key:"uploadEvent",value:function(e){var t=e.log,n=e.userId,r=e.error,i={timestamp:ir(),sdkAppId:this._configs.sdkAppId,userId:n||this._configs.userId,version:X,log:t};r&&(i.errorInfo=r.message,r.stack&&(i.errorInfo+="\n".concat(r.stack))),this.sendRequest(be(this._configs.sdkAppId,$),i)}},{key:"sendRequest",value:function(e,t){setTimeout((function(){return ar({url:e,body:JSON.stringify(t),priority:"low"}).catch((function(){}))}),2e3)}}])}()),aa=new WeakMap;var oa,sa,ca,ua,la,da,ha=function(e){function t(e,n){var a;return i(this,t),(a=r(this,t,[e.id,"".concat(n,"-player")])).kind=n,G(a,"id"),G(a,"element",null),G(a,"track"),G(a,"url"),G(a,"attr"),G(a,"mode"),G(a,"muted"),G(a,"_log"),G(a,"_pausedRetryCount"),G(a,"_isElementPlayingFired",!1),G(a,"_interval"),G(a,"_delayDestroyTimeoutId",0),G(a,"_playSuccessResolve"),G(a,"_isReplayByRecreateMediaStreamCalled",!1),G(a,"isInAutoPlayFailedState",!1),a.id=e.id,a._log=e.log,a.track=e.track,a.muted=e.muted,a._pausedRetryCount=5,a._state="STOPPED",a.bindTrackEvents(),a._log.info("create ".concat(n,"-player ").concat(a.id)),a}return d(t,e),s(t,[{key:"isPlaying",get:function(){var e;return"PLAYING"===this._state&&!1===(null==(e=this.element)?void 0:e.paused)}},{key:"isPaused",get:function(){var e;return"PAUSED"===this._state||!0===(null==(e=this.element)?void 0:e.paused)}},{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:(o=n(p().mark((function e(){var t,n=this;return p().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.isPlaying){e.next=2;break}return e.abrupt("return");case 2:return e.prev=2,this._delayDestroyTimeoutId&&(clearTimeout(this._delayDestroyTimeoutId),this._delayDestroyTimeoutId=0,this.bindTrackEvents(),this.bindElementEvents()),this.bindAutoPlayEvent(),e.next=7,new Promise((function(e,t){n._playSuccessResolve=e,n.element.play().then(e,t)}));case 7:e.next=16;break;case 9:if(e.prev=9,e.t0=e.catch(2),t=Tr({key:tr.PLAY_FAILED,data:{media:this.kind,error:e.t0}}),this._log.warn(e.t0),!t.includes("NotAllowedError")){e.next=16;break}throw this.isInAutoPlayFailedState=!0,new _e({code:Ee.PLAY_NOT_ALLOWED,message:t});case 16:case"end":return e.stop()}}),e,this,[[2,9]])}))),function(){return o.apply(this,arguments)})},{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&&!jn?this._delayDestroyTimeoutId||(this._log.info("destroy element after 3 * ".concat(t)),this._delayDestroyTimeoutId=setTimeout((function(){return e.destroyElement()}),3*t)):this.destroyElement(),this.handleStopped(oe.ENDED),this._interval>0&&Zi.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():qn?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 na(this.element,this.element).add(oe.PLAYING,e).add(oe.ENDED,e).add(oe.PAUSE,e).add(oe.ERROR,e).add(oe.LOADEDDATA,e).add(oe.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==ea||ea.create(e,e).add(oe.ENDED,t).add(oe.MUTE,t).add(oe.UNMUTE,t),e.readyState===oe.ENDED&&this.handleTrackEvent({type:oe.ENDED}),e.muted&&this.handleTrackEvent({type:oe.MUTE})}}},{key:"bindAutoPlayEvent",value:function(){hr.on(pr.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&&ra(e)}},{key:"unbindEvents",value:function(){this.element&&ra(this.element),this.unbindTrackEvents(),hr.off(pr.AUTOPLAY_DIALOG_CLICK_CONFIRM,this.resume,this)}},{key:"handleElementEvent",value:function(e){var t=this;switch(e.type){case oe.PLAYING:this.isInAutoPlayFailedState=!1,this._isElementPlayingFired=!0,this._log.info("".concat(this.kind," player is playing")),this.handlePlaying(oe.PLAYING),this._interval&&(Zi.clearTask(this._interval),this._interval=-1);break;case oe.ENDED:this._log.info("".concat(this.kind," player is ended")),this.handleStopped(oe.ENDED);break;case oe.PAUSE:this._log.info("".concat(this.kind," player is paused")),this.handlePaused(oe.PAUSE),Vt&&(this._interval=Zi.run("timeout",(function(){t.element&&"PAUSED"===t._state&&t.resume()}),{delay:3e3}));break;case oe.ERROR:if(this.element&&this.element.error){this.handlePaused(oe.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)),ia.uploadEvent({log:"stat-".concat(this.kind,"-").concat(fe,"-").concat(r,"-").concat(navigator.userAgent),error:this.element.error}),bn||In?this.emit($i.ERROR,this.element.error):this.replayByRecreateMediaStream(this.element.error)}break;case oe.LOADEDDATA:this.kind===oe.VIDEO&&this.emit($i.LOADED_DATA);break;case oe.LOADEDMETADATA:this.kind===oe.VIDEO&&this.emit($i.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"),ia.uploadEvent({log:"stat-replayByRecreateMediaStream-success"}),Ar.addSuccessEvent({key:t.kind===oe.AUDIO?506700:516700})})).catch((function(){var n;t._log.error("replayByRecreateMediaStream failed"),ia.uploadEvent({log:"stat-replayByRecreateMediaStream-failed"}),Ar.addFailedEvent({key:t.kind===oe.AUDIO?506700:516700,error:null==(n=t.element)?void 0:n.error}),t.emit($i.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){_t(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)}),_t(5e3).then((function(){var e,i;t.isPlaying&&!(null==(e=t.element)?void 0:e.error)||r(null==(i=t.element)?void 0:i.error),n()}))}))})).finally((function(){t.element&&(t.element.onerror=null)}))}},{key:"handleTrackEvent",value:(a=n(p().mark((function e(t){var n;return p().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=t.type,e.t0=n,e.next=e.t0===oe.ENDED?4:e.t0===oe.MUTE?6:e.t0===oe.UNMUTE?8:19;break;case 4:return this.handleStopped(oe.ENDED),e.abrupt("break",19);case 6:return this.handlePaused(oe.MUTE),e.abrupt("break",19);case 8:if(!(this.mode>0)){e.next=12;break}this.handlePlaying(this.mode.toString()),e.next=18;break;case 12:if(!this.element){e.next=18;break}if(!this.element.paused){e.next=17;break}return this._log.warn("track unmuted and element is paused, resume"),e.next=17,this.resume();case 17:!this.element.paused&&this._isElementPlayingFired&&this.handlePlaying(oe.UNMUTE);case 18:return e.abrupt("break",19);case 19:case"end":return e.stop()}}),e,this)}))),function(e){return a.apply(this,arguments)})},{key:"handlePlaying",value:function(e){var t;this._log.debug("handlePlaying",e),null==(t=this._playSuccessResolve)||t.call(this,e),this.emit($i.PLAYER_STATE_CHANGED,{type:this.kind,state:"PLAYING",reason:e})}},{key:"handlePaused",value:function(e){this._log.debug("handlePaused",e),this.emit($i.PLAYER_STATE_CHANGED,{type:this.kind,state:"PAUSED",reason:e})}},{key:"handleStopped",value:function(e){this._log.debug("handleStopped",e),this.emit($i.PLAYER_STATE_CHANGED,{type:this.kind,state:"STOPPED",reason:e})}},{key:"getElement",value:function(){return this.element}}]);var a,o}(Ki);H([(oa={settings:{retries:2,timeout:0},onError:function(e,t,n,r){r[0]=(r[0]||1e3)+1e3,t()}},sa=oa.settings,ca=void 0===sa?{retries:5,timeout:2e3}:sa,ua=oa.onError,la=oa.onRetrying,da=oa.onRetryFailed,function(e,t,n){var r=lr({retryFunction:n.value,settings:ca,onError:function(n){var r,i=n.error,a=n.retry,o=n.reject,s=n.retryFuncArgs;ua?ua.call(this,i,(function(){var n;(null==(n=aa.get(e))?void 0:n.has(t))?a():o(i)}),o,s):(null==(r=aa.get(e))?void 0:r.has(t))?a():o(i)},onRetrying:function(n,r){var i;sr(la)&&la.call(this,n,r),(null==(i=aa.get(e))?void 0:i.has(t))&&(aa.get(e).get(t).stopRetry=r)},onRetryFailed:da});return n.value=function(){for(var n=aa.get(e),i=arguments.length,a=new Array(i),o=0;o<i;o++)a[o]=arguments[o];return n?n.set(t,{args:a}):aa.set(e,new Map([[t,{args:a}]])),r.apply(this,a).finally((function(){var n;return null==(n=aa.get(e))?void 0:n.delete(t)}))},n})],ha.prototype,"doReplayByRecreateMediaStream"),H([ji([],"PLAYING",{sync:!0})],ha.prototype,"handlePlaying"),H([ji("PLAYING","PAUSED",{ignoreError:!0,sync:!0})],ha.prototype,"handlePaused"),H([ji([],"STOPPED",{sync:!0})],ha.prototype,"handleStopped");var fa,pa,va="trtc_autoplay",ma="".concat(va,"_mask"),ya="".concat(va,"_wrapper"),ga="".concat(va,"_header"),ka="".concat(va,"_content"),Ea="".concat(va,"_action_wrapper"),_a="".concat(va,"_question"),Ta="".concat(va,"_collapse"),Ia="".concat(va,"_action_confirm"),ba="".concat(va,"_detail"),Sa="#2473E8",wa="dialog",Aa="".concat(wa,"-show"),Ra="".concat(wa,"-1"),xa="".concat(wa,"-2"),Ca=!1,Da=function(){return!!document.querySelector(".".concat(ya))},Oa="".concat(Z,"/").concat(Pe()?"zh-cn":"en","/tutorial-21-advanced-auto-play-policy.html"),Na="<br><a href='".concat(Oa,"' target='_blank'>").concat(Pe()?"其他方案?":"Any other solution?","</a>"),Ma="".concat(Pe()?"浏览器自动播放策略:在用户与页面产生交互(点击、触摸)之前,浏览器禁止播放有声媒体。该弹窗用于帮助用户恢复音视频播放。".concat(Na):"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(Na)),La=function(){return s((function e(){if(i(this,e),G(this,"content","音视频播放被浏览器拦截,请点击“恢复播放”。"),G(this,"_dialogNode",null),G(this,"_bodyPosition",""),G(this,"_showDetail",!1),G(this,"_isCollapseClicked",!1),G(this,"_isQuestionClicked",!1),Pe()||(this.content='Media playback failed. Click the "Resume" to resume playback.'),!Ca){var t=document.createElement("style");t.innerHTML=".".concat(ma,"{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(ma," div:not(.").concat(Ea,"){display:block !important;}.").concat(ya,"{padding:14px;background:#fff;border-radius:3px;box-shadow:0px 3px 15px #434343;border:1px solid #d1cfcf;max-width:500px;}.").concat(ya," a{color:").concat(Sa,";}.").concat(ga,"{overflow:hidden;text-overflow:ellipsis;font-size:16px;font-weight:600;}.").concat(ka,"{margin:8px 0;}.").concat(Ea,"{width:100%;display:flex !important;align-items:center;justify-content:right;float:right;}.").concat(Ta,"{margin-right:auto;cursor:pointer}.").concat(_a,"{height:100%;line-height:16px;cursor:pointer;}.").concat(Ia,"{margin-left:8px;color:#fff;background:").concat(Sa,";padding:4px 12px;outline:none;border:1px solid;border-radius:3px;font-weight:bold;}.").concat(Ia,":hover{opacity:0.9;}.").concat(Ta,",.").concat(Ia,",.").concat(ka,",.").concat(_a,"{font-size:14px;}@media screen and (max-width:750px){.").concat(ya,"{width:80vw;}}"),document.head.appendChild(t),Ca=!0}this.addDiaLog()}),[{key:"createDiaLog",value:function(){var e=document.createElement("template");e.innerHTML='<div class="'.concat(ma,"\"><div class='").concat(ya,"'><div class='").concat(ga,"'>").concat(location.host,"</div><div class='").concat(ka,"'>").concat(this.content,"</div><div class='").concat(ba,'\' style="visibility:hidden;width:100%;height:0;font-size:12px;color:gray;">').concat(Ma,"</div><div class='").concat(Ea,"'></div></div></div>").trim();var t=document.createElement("button");t.className=Ia,t.innerText=Pe()?"恢复播放":"Resume",t.onclick=this.onConfirm.bind(this);var n=document.createElement("div");n.className=_a,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=Ta,r.innerText="".concat(Pe()?"详情 >":"Detail >"),r.onclick=this.onCollapseClick.bind(this);var i=e.content.firstChild,a=i.querySelector(".".concat(Ea));return a.appendChild(r),a.appendChild(n),a.appendChild(t),i}},{key:"addDiaLog",value:function(){Da()||(this._dialogNode=this.createDiaLog(),document.body.appendChild(this._dialogNode),this._dialogNode.onclick=this.onConfirm.bind(this),this._dialogNode.querySelector(".".concat(ya)).onclick=function(e){return e.stopPropagation()},this._bodyPosition=document.body.style.position,document.body.style.position="fixed",kr.info("show autoplay dialog"),ia.uploadEvent({log:Aa}))}},{key:"deleteDiaLog",value:function(){this._dialogNode&&(document.body.removeChild(this._dialogNode),document.body.style.position=this._bodyPosition,this._dialogNode=null)}},{key:"onConfirm",value:function(){kr.warn("confirm clicked, try resume stream"),hr.emit(pr.AUTOPLAY_DIALOG_CLICK_CONFIRM),this.deleteDiaLog()}},{key:"onCollapseClick",value:function(){var e=this._dialogNode.querySelector(".".concat(ba));e.style.visibility="".concat(this._showDetail?"hidden":"visible"),e.style.height="".concat(this._showDetail?0:"fit-content"),this._showDetail=!this._showDetail,this._isCollapseClicked||ia.uploadEvent({log:Ra}),this._isCollapseClicked=!0}},{key:"onQuestionClick",value:function(){window.open(Oa,"_blank"),this._isQuestionClicked||ia.uploadEvent({log:xa}),this._isQuestionClicked=!0}}])}(),Pa=function(e){function t(e){var n;return i(this,t),n=r(this,t,[e,oe.VIDEO]),G(n,"stat",{}),G(n,"_calculateTimeout",-1),G(n,"viewMirror",!1),G(n,"objectFit"),G(n,"container"),G(n,"canvas"),n.mode=e.canvas?1:0,n.container=e.container,n.canvas=e.canvas,He(e.viewMirror)||(n.viewMirror=e.viewMirror),He(e.objectFit)||(n.objectFit=e.objectFit),n.initializeElement(),n}return d(t,e),s(t,[{key:"isPlaying",get:function(){var e;return"PLAYING"===this._state&&((!this.element||!this.element.paused)&&("live"===(null==(e=this.track)?void 0:e.readyState)&&!this.track.muted))}},{key:"initializeElement",value:function(){var e,t=document.createElement(oe.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.elementToRender&&(null==(t=this.container)||t.appendChild(this.elementToRender))}},{key:"bindElementEvents",value:function(){var e=k(t,"bindElementEvents",this,3)([]);this.handleElementEvent=this.handleElementEvent.bind(this),e&&e.add(oe.ENTER_PICTURE_IN_PICTURE,this.handleElementEvent).add(oe.LEAVE_PICTURE_IN_PICTURE,this.handleElementEvent)}},{key:"handleTrackEvent",value:function(e){var n;k(t,"handleTrackEvent",this,3)([e]),e.type===oe.MUTE&&(null==(n=this.stat)?void 0:n.fps)&&(this.stat.fps=0)}},{key:"handleElementEvent",value:function(e){var n,r;if(2!==this.mode){k(t,"handleElementEvent",this,3)([e]);var i=e.type;if(i===oe.PAUSE)this.container&&document.getElementById(this.container.id)||this._log.warn("".concat(this.kind," player has been remove, element ID: ").concat(null==(n=this.container)?void 0:n.id)),this.container&&this.container!==document.getElementById(this.container.id)&&(this._pausedRetryCount=5,this._log.info("view container ".concat(null==(r=this.container)?void 0:r.id," is recreated"))),this._pausedRetryCount>0&&!Da()&&(this._log.info("[".concat(5-this._pausedRetryCount+1,"/").concat(5,"] ").concat(this.kind," player auto resume when paused")),this.resume(),this._pausedRetryCount--),this.stat.fps&&(this.stat.fps=0);if(this.viewMirror&&this.element){var a=this.element.style.transform;i===oe.ENTER_PICTURE_IN_PICTURE?this.element.style.transform=a.replace("scaleX(-1)",""):i!==oe.LEAVE_PICTURE_IN_PICTURE||a.includes("scaleX")||(this.element.style.transform="".concat(a," scaleX(-1)"))}}}},{key:"setCanvas",value:function(e){var t,n,r,i,a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;this.canvas!==e&&(null==(t=this.canvas)||t.remove(),null==e||e.setAttribute("style",this.styleAttribute),this.canvas=e,this.mode=e?a:0,2===this.mode&&this.setTrack(e.captureStream().getVideoTracks()[0]),e?(null==(n=this.element)||n.remove(),null==(r=this.container)||r.appendChild(e)):this.element&&(null==(i=this.container)||i.appendChild(this.element)))}},{key:"setAttr",value:function(e){var n=Object.assign({autoplay:"autoplay",playsinline:"playsinline",muted:!0},e);n.style=Object.assign({width:"100%",height:"100%"},n.style),k(t,"setAttr",this,3)([n])}},{key:"mirror",get:function(){return this.viewMirror}},{key:"setRect",value:function(e,t){this.elementToRender&&(this.elementToRender.style.width="".concat(e,"px"),this.elementToRender.style.height="".concat(t,"px"))}},{key:"setViewMirror",value:function(e){this.elementToRender&&(this.elementToRender.style.transform=e?"scaleX(-1)":""),this.viewMirror=e}},{key:"setObjectFit",value:function(e){this.elementToRender&&(this.elementToRender.style.objectFit="".concat(e)),this.objectFit=e}},{key:"setPoster",value:function(e){this.element&&(this.element.poster=e)}},{key:"stop",value:function(){var e,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;k(t,"stop",this,3)([n]),null==(e=this.canvas)||e.remove()}},{key:"play",value:function(){return this.element?this.elementToRender&&this.elementToRender.parentElement!==this.container&&this.container&&this.container.append(this.elementToRender):this.initializeElement(),2===this.mode?Promise.resolve():k(t,"play",this,3)([])}},{key:"elementToRender",get:function(){return this.canvas||this.element}},{key:"setTrack",value:function(e){e!==this.track&&(this.unbindTrackEvents(),this.track=e,this.emit($i.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(bi()&&this.element&&this._calculateTimeout<0){var t=0,n=null,r=function(i,a){e.stat.width=a.width,e.stat.height=a.height,n&&(e.stat.fps=Math.round((a.presentedFrames-n.presentedFrames)/(i-t)*1e3)),t=i,n=a,e._calculateTimeout=-1,e.element&&(e._calculateTimeout=setTimeout((function(){var t;return null==(t=e.element)?void 0:t.requestVideoFrameCallback(r)}),2e3))};this.element.requestVideoFrameCallback(r)}}catch(e){this._log.warn("init stat failed",e)}}}])}(ha);function Ua(){return(Ua=n(p().mark((function e(t,n){return p().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t.audioWorklet){e.next=2;break}return e.abrupt("return",Promise.reject("audioWorklet is not supported"));case 2:return e.prev=2,e.next=5,t.audioWorklet.addModule(n);case 5:kr.info("worklet addModule success"),e.next=12;break;case 8:throw e.prev=8,e.t0=e.catch(2),kr.info("worklet addModule catch error. ".concat(e.t0.message)),e.t0;case 12:case"end":return e.stop()}}),e,null,[[2,8]])})))).apply(this,arguments)}"undefined"!=typeof AudioContext?fa=AudioContext:"undefined"!=typeof webkitAudioContext?fa=webkitAudioContext:"undefined"!=typeof mozAudioContext&&(fa=mozAudioContext);var Va=-1;!function e(){try{if(pa)return;(pa=new fa({sampleRate:48e3})).onstatechange=function(){kr.info("context state: ".concat(pa.state).concat("running"!==pa.state?" visibilityState: ".concat(document.visibilityState):"")),Fa()},clearTimeout(Va)}catch(t){kr.error("initAudioContext failed: ".concat(t," typeof AudioContextClass: ").concat(I(fa))),Va=setTimeout(e,1e3)}}();var Fa=function(){"suspended"===pa.state?(Ha(),document.addEventListener("click",Fa)):"interrupted"===pa.state?Ha():(document.removeEventListener("visibilitychange",Fa),document.removeEventListener("click",Fa))},Ba=0,ja=-1;function Ha(){return new Promise((function(e,t){if("running"===pa.state)return e();Date.now()-Ba<1e3?(clearTimeout(ja),ja=setTimeout((function(){Ba=Date.now(),pa.resume().then(e,t)}),1e3)):(clearTimeout(ja),Ba=Date.now(),pa.resume().then(e,t))})).catch((function(e){kr.warn("context resume failed: ".concat(e)),document.addEventListener("visibilitychange",Fa)}))}document.addEventListener("click",Fa);var Ga=function(e){return pa},Wa=function(){return s((function e(t){i(this,e),this.name=t,G(this,"node"),G(this,"node2"),G(this,"pre",new Set),G(this,"next",new Set),G(this,"context"),G(this,"connectedNodes",new Set),G(this,"nextInputChannelMap",new Map),G(this,"_channelCount",1)}),[{key:"channelCount",get:function(){return this._channelCount},set:function(e){this._channelCount=e,this.setChannelCount(this.node,e),this.setChannelCount(this.node2,e),this.next.forEach((function(t){return t.channelCount=e}))}},{key:"setChannelCount",value:function(e,t){!e||e instanceof ScriptProcessorNode||(e.channelCountMode="explicit",e.channelCount=t||this.channelCount||1)}},{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.setChannelCount(this.node),this.preNodeReconnect(),this.reconnect()}catch(e){kr.error(e)}}},{key:"setNode",value:function(e,t){var n;if(!this.node)try{null==(n=this.context)||n.addMixWeight(),this.node=e,this.setChannelCount(this.node),t&&(this.node2=t,this.setChannelCount(this.node2)),this.preNodeReconnect(),this.reconnect(),Ar.addSuccessEvent({key:502701})}catch(e){kr.error(e),Ar.addFailedEvent({key:502701,error:e})}}},{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(),Ar.addSuccessEvent({key:502702})}catch(e){kr.error(e),Ar.addFailedEvent({key:502702,error:e})}}},{key:"preNodeReconnect",value:function(){this.pre.forEach((function(e){e.node?e.reconnect():e.preNodeReconnect()}))}},{key:"connectNext",value:function(e){var t=this;this.next.forEach((function(n){var r=t.nextInputChannelMap.get(n);e._connect(n.node,r)||n.connectNext(e)}))}},{key:"_connect",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return!(!this.node||!e)&&((this.node2||this.node).connect(e,0,t),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(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return this.next.add(e),e.pre.add(this),this.nextInputChannelMap.set(e,t),e}}])}(),qa=function(e){function t(){var e,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:256;return i(this,t),(e=r(this,t)).fftSize=n,G(e,"dataArray",new Uint8Array(0)),e}return d(t,e),s(t,[{key:"setNode",value:function(e){e.fftSize=this.fftSize,this.dataArray=new Uint8Array(e.frequencyBinCount),k(t,"setNode",this,3)([e])}},{key:"getByteTimeDomainData",value:function(){var e;return null==(e=this.node)||e.getByteTimeDomainData(this.dataArray),this.dataArray}},{key:"level",get:function(){var e;return null==(e=this.node)||e.getByteTimeDomainData(this.dataArray),Math.max.apply(Math,_(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=100*(e[i]/128)/2,r+="L".concat(t,",").concat(n),t+=1}return r}}])}(Wa),Ka=function(){return s((function e(){i(this,e),G(this,"source",new Wa),G(this,"gain",new Wa),G(this,"destination",new Wa)}),[{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(Ga().createGain()),this.gain.node.gain.value=e):this.gain.node&&this.gain.deleteNode()}},{key:"replaceSource",value:function(e){this.source.replaceNode(function(e){var t=za.get(e);if(t)return t;var n=Ga();if(e instanceof HTMLAudioElement)t=n.createMediaElementSource(e);else{if(!(e instanceof MediaStreamTrack))return e;t=n.createMediaStreamSource(new MediaStream([e]))}return za.set(e,t),t}(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}}])}(),za=new WeakMap;var Ya=function(){function e(t){i(this,e),G(this,"_volume",0),G(this,"_volumeDb",0),G(this,"_log"),G(this,"_scriptProcessorNode",null),G(this,"_audioWorkletNode",null),G(this,"_interval",200),G(this,"ready",this.preload());var n=t.log;this._log=n,hr.on(pr.AUDIO_LEVEL_INTERVAL,this.handleAudioLevelInterval,this)}return s(e,[{key:"node",get:function(){return this._audioWorkletNode||this._scriptProcessorNode}},{key:"preload",value:function(){var t=this;if(!e.workletReady){e.workletReady=function(e,t){return Ua.apply(this,arguments)}(e.audioContext,URL.createObjectURL(new Blob(['class VolumeMeterWorklet extends AudioWorkletProcessor{constructor(){super(),this.volume=0,this.intervalTime=200,this.tick=200,this.isStop=!1,this.cache=[],this.sentFirstInfo1=!1,this.unmute=!1,this.port.onmessage=t=>{var e=t.data;switch(e.name){case"chunk":this.cache.push(...e.data),this.sentFirstInfo1||(this.port.postMessage({cl:e.data.length}),this.sentFirstInfo1=!0);break;case"setIntervalTime":this.intervalTime=e.intervalTime;break;case"unmute":this.unmute=!0;break;case"stop":this.isStop=!0}}}process(t,s){t=t[0],s=s[0];if(t||s){if(this.isStop)return!1;var i=s&&s[0]?s[0].length:0,h=this.cache.length,a=(i<h?(s[0].set(this.cache.slice(0,i)),this.cache=this.cache.slice(i)):this.unmute&&s[0].set(t[0]),(i<h?s:t)[0]);if(a){let e=0;for(let t=0;t<a.length;++t)e=Math.max(Math.abs(a[t]),e);s=a.reduce((t,e)=>t+e*e,0)/a.length;this.volume=e,this.tick-=a.length,this.tick<0&&(this.tick+=this.intervalTime/1e3*sampleRate,this.port.postMessage({volume:this.volume,volumeDb:Math.max(10*Math.log10(s)+100,0)/100,cacheLen:h,outputLen:i}))}}return!0}}registerProcessor("volume-meter",VolumeMeterWorklet);'],{type:"application/javascript"})))}return e.workletReady.then((function(){return t.initAudioWorklet()})).catch((function(e){return t._log.error("volumeMeter preload error: ".concat(e)),t.initScriptProcessor()}))}},{key:"initAudioWorklet",value:function(){var t=this;if(!this._audioWorkletNode)try{this._audioWorkletNode=new AudioWorkletNode(e.audioContext,"volume-meter");var n=!1;this._audioWorkletNode.port.onmessage=function(r){e.lastMessageTime=Date.now(),t._volume=r.data.volume||0,t._volumeDb=r.data.volumeDb||0,!n&&r.data.cacheLen&&r.data.outputLen&&(t._log.warn("worklet play success"),n=!0)},this.handleAudioLevelInterval({interval:this._interval})}catch(e){this._log.error("volumeMeter init audio worklet error: ".concat(e)),ia.logFailedEvent({userId:this._log.userId,eventType:pe,error:e}),this.initScriptProcessor()}}},{key:"initScriptProcessor",value:function(){var t=this;if(!this._scriptProcessorNode)try{this._scriptProcessorNode=Ga().createScriptProcessor(2048,1,1),this._scriptProcessorNode.onaudioprocess=function(n){e.lastMessageTime=Date.now();for(var r=n.inputBuffer.getChannelData(0),i=0,a=0;a<r.length;++a)i+=r[a]*r[a];t._volume=Math.sqrt(i/r.length)||0}}catch(e){this._log.error("volumeMeter init script processor error: ".concat(e))}}},{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,hr.off(pr.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}}])}();G(Ya,"lastMessageTime",0),G(Ya,"audioContext",Ga()),G(Ya,"workletReady");var Xa=Ya,Qa=function(e){function t(e){var n;return i(this,t),n=r(this,t),G(n,"_volumeMeter"),n._volumeMeter=new Xa(e),n}return d(t,e),s(t,[{key:"deleteNode",value:function(){k(t,"deleteNode",this,3)([]),this._volumeMeter.destroy()}},{key:"init",value:(a=n(p().mark((function e(){return p().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._volumeMeter.preload();case 2:this.setNode(this._volumeMeter.node);case 3:case"end":return e.stop()}}),e,this)}))),function(){return a.apply(this,arguments)})},{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()}}}]);var a}(Wa),Ja=j(W()),Za=function(e){return function(t){return t.deviceId===e}},$a=function(){return s((function e(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"Input";i(this,e),G(this,"kind"),G(this,"type"),G(this,"devices",[]),this.kind=t,this.type=n}),[{key:"update",value:function(e,t){var n=this,r=e.filter((function(e){return e.kind==="".concat(n.kind).concat(n.type.toLocaleLowerCase())}));1===this.devices.length&&no(this.devices[0])||t&&(r.forEach((function(e){if(e.deviceId&&!n.devices.find(Za(e.deviceId))){var r="".concat(n.kind).concat(n.type,"Added");kr.warn("".concat(r,": ").concat(JSON.stringify(e))),t.emit(r,e)}})),this.devices.forEach((function(e){if(e.deviceId&&!r.find(Za(e.deviceId))){var i="".concat(n.kind).concat(n.type,"Removed");kr.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}))}}])}(),eo=function(e){function t(){var e;return i(this,t),e=r(this,t),G(e,"audioInputs",new $a(oe.AUDIO)),G(e,"videoInputs",new $a(oe.VIDEO)),G(e,"audioOutputs",new $a(oe.AUDIO,"Output")),e.init(),navigator.mediaDevices&&(navigator.mediaDevices.addEventListener&&navigator.mediaDevices.addEventListener("devicechange",(function(){return e.update()})),"ondevicechange"in navigator.mediaDevices||Zi.run("interval",(function(){e.update()}),{delay:1e4})),e}return d(t,e),s(t,[{key:"init",value:function(){var e=this;ro().then((function(t){e.audioInputs.update(t),e.videoInputs.update(t),e.audioOutputs.update(t)}))}},{key:"update",value:(a=n(p().mark((function e(){var t,n,r=arguments;return p().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=r.length>0&&void 0!==r[0]?r[0]:0,e.next=3,ro(t);case 3:return n=e.sent,this.audioInputs.update(n,this),this.videoInputs.update(n,this),this.audioOutputs.update(n,this),e.abrupt("return",this);case 8:case"end":return e.stop()}}),e,this)}))),function(){return a.apply(this,arguments)})}]);var a}(Ja.EventEmitter),to=J||Q?null:new eo;function no(e){return e.deviceId===e.groupId&&""===e.groupId}function ro(){return io.apply(this,arguments)}function io(){return io=n(p().mark((function e(){var t,n,r,i,a=arguments;return p().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=a.length>0&&void 0!==a[0]?a[0]:0,!Lr()&&Nr()){e.next=3;break}return e.abrupt("return",[]);case 3:return e.next=5,navigator.mediaDevices.enumerateDevices();case 5:if(n=e.sent,0===t){e.next=26;break}if(r={audio:!1,video:!1},n.forEach((function(e){no(e)&&(e.kind===oe.AUDIO_INPUT?r.audio=!0:e.kind===oe.VIDEO_INPUT&&(r.video=!0))})),2===t&&(r.audio=!1),1===t&&(r.video=!1),!r.audio&&!r.video){e.next=26;break}return e.prev=12,e.next=15,navigator.mediaDevices.getUserMedia(r);case 15:i=e.sent,r.audio&&Ha(),e.next=22;break;case 19:e.prev=19,e.t0=e.catch(12),kr.debug("capture before getDevices failed: ",e.t0);case 22:return e.next=24,navigator.mediaDevices.enumerateDevices();case 24:n=e.sent,null==i||i.getTracks().forEach((function(e){return e.stop()}));case 26:return e.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&&po.add("".concat(e.deviceId,"_").concat(e.kind)),e.getCapabilities&&(n.getCapabilities=function(){return e.getCapabilities()}),n})));case 27:case"end":return e.stop()}}),e,null,[[12,19]])}))),io.apply(this,arguments)}function ao(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return to.update(e?1:0).then((function(e){return e.audioInputs.devices}))}function oo(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return to.update(e?2:0).then((function(e){return e.videoInputs.devices}))}var so=!1;function co(){return uo.apply(this,arguments)}function uo(){return(uo=n(p().mark((function e(){return p().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(e.prev=0,so){e.next=10;break}return so=!0,e.t0=kr,e.t1="speakers:",e.next=7,lo();case 7:e.t2=e.sent.map((function(e){return" ".concat(e.deviceId.slice(0,8),": ").concat(e.label)})),e.t3=e.t1.concat.call(e.t1,e.t2),e.t0.info.call(e.t0,e.t3);case 10:e.next=14;break;case 12:e.prev=12,e.t4=e.catch(0);case 14:case"end":return e.stop()}}),e,null,[[0,12]])})))).apply(this,arguments)}function lo(){return ho.apply(this,arguments)}function ho(){return ho=n(p().mark((function e(){var t,n=arguments;return p().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=n.length>0&&void 0!==n[0]&&n[0],(Vt||Bn)&&(t=!1),e.abrupt("return",to.update(t?1:0).then((function(e){return e.audioOutputs.devices})));case 3:case"end":return e.stop()}}),e)}))),ho.apply(this,arguments)}var fo,po=new Set;function vo(e,t){return mo.apply(this,arguments)}function mo(){return(mo=n(p().mark((function e(t,n){var r,i;return p().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,ao();case 2:if(r=e.sent,i=r.find((function(e){return e.deviceId===me})),n||(null==i?void 0:i.groupId)!==t){e.next=6;break}return e.abrupt("return",!0);case 6:if((null==i?void 0:i.groupId)!==t||i.label!==n){e.next=8;break}return e.abrupt("return",!0);case 8:return e.abrupt("return",!1);case 9:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function yo(e){return go.apply(this,arguments)}function go(){return(go=n(p().mark((function e(t){var n,r,i,a,o;return p().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=t.newDeviceId,r=t.oldDeviceId,i=t.oldGroupId,a=t.oldLabel,o=t.kind,n===r){e.next=3;break}return e.abrupt("return",!1);case 3:if(o!==oe.AUDIO||n!==me){e.next=7;break}return e.next=6,vo(i,a);case 6:return e.abrupt("return",e.sent);case 7:return e.abrupt("return",!0);case 8:case"end":return e.stop()}}),e)})))).apply(this,arguments)}var ko=function(e){function t(e){var n;return i(this,t),(n=r(this,t)).log=e,G(n,"volumeMeter"),G(n,"volumeDestination"),G(n,"analyser",new qa),n.volumeMeter=new Qa({log:n.log}),n.volumeDestination=new Wa,n.volumeMeter.pipeTo(n.volumeDestination),n}return d(t,e),s(t,[{key:"destroy",value:function(){this.gain.deleteNode(),this.volumeMeter.deleteNode(),this.analyser.deleteNode(),this.source.deleteNode(),this.destination.deleteNode(),this.volumeDestination.deleteNode()}}])}(Ka),Eo=function(e){function t(e){var n;return i(this,t),n=r(this,t,[e,oe.AUDIO]),G(n,"_outputDeviceId"),G(n,"_volume",1),G(n,"_destination",Ga().createMediaStreamDestination()),G(n,"pipeline"),G(n,"volumeMeterMode","worklet"),n.mode=0,n.pipeline=new ko(n._log),n}return d(t,e),s(t,[{key:"getMediaStream",value:function(){return this.pipeline.stream||(this.track?new MediaStream([this.track]):null)}},{key:"initializeElement",value:function(e){if(("15.2"===Gn||"15.3"===Gn||"15.4"===Gn)&&this.muted)this._log.info("audioElement is muted.");else{var t=fo||new Audio;t.setAttribute("autoplay","autoplay"),t.srcObject=this.getMediaStream(),t.muted=this.muted,this.element=t,We(e)&&(this.element.volume=Math.min(Math.max(e,0),1)),t===fo&&(fo=void 0),this.bindElementEvents()}}},{key:"play",value:(o=n(p().mark((function e(n){return p().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.track){e.next=2;break}return e.abrupt("return");case 2:if(this.pipeline.source.node||this.pipeline.replaceSource(this.track),this.element||this.initializeElement(null==n?void 0:n.volume),!this._outputDeviceId){e.next=7;break}return e.next=7,this.setSinkId(this._outputDeviceId);case 7:return"worklet"===this.volumeMeterMode?this.pipeline.volumeMeter.init():"analyser"===this.volumeMeterMode&&this.pipeline.analyser.setNode(Ga().createAnalyser()),co(),e.abrupt("return",k(t,"play",this,3)([]));case 10:case"end":return e.stop()}}),e,this)}))),function(e){return o.apply(this,arguments)})},{key:"stop",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;this.pipeline.destroy(),k(t,"stop",this,3)([e])}},{key:"setSinkId",value:(a=n(p().mark((function e(t){var n,r;return p().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._outputDeviceId!==t&&(this._outputDeviceId=t),!this.element||this.element.sinkId===t){e.next=4;break}return e.next=4,null==(r=(n=this.element).setSinkId)?void 0:r.call(n,t);case 4:case"end":return e.stop()}}),e,this)}))),function(e){return a.apply(this,arguments)})},{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()}}]);var a,o}(ha),_o=function(e){function t(e){var n;return i(this,t),n=r(this,t,[e]),G(n,"_sourceElement"),G(n,"_output",new Wa),n.pipeline.source.pipeTo(n.pipeline.gain),n.pipeline.gain.pipeTo(n.pipeline.volumeMeter).pipeTo(n._output),n.pipeline.gain.pipeTo(n.pipeline.destination),n}return d(t,e),s(t,[{key:"setOutput",value:function(){this.mode=1,this._output.setNode(Ga().destination)}},{key:"write",value:function(e){this.pipeline.volumeMeter.write(e)}},{key:"setTrack",value:function(e){var t,n,r;(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($i.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.source.channelCount=(null==(r=e.getSettings())?void 0:r.channelCount)||1,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"):Vt||(this._log.info("start set pipeline volume: ".concat(e)),this.pipeline.setVolume(e),this.element&&!this._sourceElement&&(this.pipeline.destination.setNode(this._destination),ra(this.element),this._sourceElement=this.element,this._sourceElement.muted=!0,this.element=null,this.play()))}},{key:"stop",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;this.pipeline.destroy();var n=this._sourceElement||this.element;n&&jn&&(fo=n),this._sourceElement&&(this._sourceElement.srcObject=null,delete this._sourceElement),k(t,"stop",this,3)([e])}}])}(Eo),To=function(e){function t(e){var n,a,o=e.userId,s=e.sdkAppId,c=e.mediaType,u=e.room,l=e.PlayerClass,d=void 0===l?1===c?_o:Pa:l;return i(this,t),n=r(this,t),G(n,"id",Mi()),G(n,"userId",""),G(n,"isRemote"),G(n,"mediaType"),G(n,"room"),G(n,"user"),G(n,"_log"),G(n,"_inputTrack"),G(n,"_outputTrack"),G(n,"isPlayCalled"),G(n,"container",null),G(n,"player"),G(n,"subVideoPlayerMap"),G(n,"muted",!1),G(n,"abortCtrl"),G(n,"objectFit","cover"),G(n,"mirror"),G(n,"rotation"),G(n,"isScreen",!1),G(n,"manager"),G(n,"trackSettings"),G(n,"isFirstVideoFrameEmitted",!1),n.userId=o||"",n.mediaType=c,n._log=kr.createLogger({id:"".concat(n.kind[0],"t"),userId:null==(a=u||n.room)?void 0:a.userId,remoteUserId:n instanceof jo?void 0:n.userId,sdkAppId:s,type:2===n.mediaType?"auxiliary":"main",isLocal:n instanceof jo}),n.player=new d({id:n.userId||n.id,track:null,muted:!1,container:null,log:n._log}),n.player.on($i.PLAYER_STATE_CHANGED,(function(e){hr.emit(pr.PLAYER_STATE_CHANGED,U({track:n},e)),n.emit("player-state-changed",e)})),n.kind===oe.VIDEO&&(n.player.on($i.LOADED_DATA,(function(){n.emitFirstVideoFrameEvent($i.LOADED_DATA),hr.emit(pr.VIDEO_LOADED_DATA,{track:n})})),n.player.on($i.LOADED_META_DATA,(function(){n.emitFirstVideoFrameEvent($i.LOADED_META_DATA)})),n.player.on($i.MEDIA_TRACK_CHANGED,(function(e){var t;null==(t=n.subVideoPlayerMap)||t.forEach((function(t){return t.setTrack(e)}))}))),n.onTrackMuted=n.onTrackMuted.bind(n),n.onTrackUnmuted=n.onTrackUnmuted.bind(n),n.onTrackEnded=n.onTrackEnded.bind(n),n.onPlayerError&&n.player.on($i.ERROR,n.onPlayerError.bind(n)),n}return d(t,e),s(t,[{key:"log",get:function(){return this._log||kr}},{key:"kind",get:function(){return 1===this.mediaType?oe.AUDIO:oe.VIDEO}},{key:"strMediaType",get:function(){return 4===this.mediaType?oe.VIDEO:2===this.mediaType?oe.SCREEN:oe.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:(u=n(p().mark((function e(t,n){var r;return p().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=ze(t)?t[0]:t,!this.isPlayCalled){e.next=12;break}if(this.log.info("play update options: ".concat(JSON.stringify(n))),n&&!He(n.muted)&&this.setPlayerMute(n.muted),n&&!He(n.objectFit)&&(this.objectFit=n.objectFit),!(this.player instanceof Pa)){e.next=11;break}if(this.player.setObjectFit(this.objectFit),this.container!==r&&r&&(this.container=r,this.player.setContainer(r)),!(ze(t)&&t.length>=1)){e.next=11;break}return e.next=11,this.playSubContainer(t.slice(1),n);case 11:return e.abrupt("return");case 12:if(n&&!He(n.muted)?this.setPlayerMute(n.muted):this.isRemote&&this.kind!==oe.VIDEO||this.setPlayerMute(!0),n&&!He(n.objectFit)&&(this.objectFit=n.objectFit),this.player instanceof Pa&&(this.player.setObjectFit(this.objectFit),n&&!He(n.poster)&&this.player.setPoster(n.poster)),this.isPlayCalled=!0,r&&(this.container=r,this.player instanceof Pa&&this.player.setContainer(r)),hr.emit(pr.PLAY_TRACK_START,{track:this}),this._outputTrack){e.next=21;break}return this.log.info("play has not mediaTrack, abort"),e.abrupt("return");case 21:return this._log.info("play with options: ".concat(JSON.stringify(n))),e.prev=22,this.player.setTrack(this.playerMediaTrack),e.next=26,this.player.play(n);case 26:if(!(ze(t)&&t.length>1)){e.next=29;break}return e.next=29,this.playSubContainer(t.slice(1),n);case 29:e.next=35;break;case 31:throw e.prev=31,e.t0=e.catch(22),this.handleAutoPlayFailed(e.t0),e.t0;case 35:case"end":return e.stop()}}),e,this,[[22,31]])}))),function(e,t){return u.apply(this,arguments)})},{key:"setMirror",value:function(e,t){if(!this.isScreen&&this.kind===oe.VIDEO&&!He(e)&&e!==this.mirror){this.mirror=e;var n=this.player;t&&(n=t);var r=this.manager;if(qe(this.mirror))return n.setViewMirror(this.mirror),void(!this.isRemote&&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:(o=n(p().mark((function e(t,n){var r,i,a,o,s,u,l,d,h,f,v=this;return p().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._outputTrack&&this.kind!==oe.AUDIO){e.next=2;break}return e.abrupt("return");case 2:this.subVideoPlayerMap||(this.subVideoPlayerMap=new Map),this.subVideoPlayerMap.forEach((function(e,n){var r;t.find((function(e){return n===e}))||(e.stop(),null==(r=v.subVideoPlayerMap)||r.delete(n))})),r=c(t.entries());try{for(r.s();!(i=r.n()).done;)a=y(i.value,2),o=a[0],s=a[1],(u=this.subVideoPlayerMap.get(s))?n&&(He(n.objectFit)||u.setObjectFit(n.objectFit)):this.subVideoPlayerMap.set(s,new Pa({id:this.userId||this.id,track:this.playerMediaTrack,container:s,muted:this.player.muted,objectFit:this.objectFit,log:this.log.createChild({id:"vp-sub".concat(o+1)})}))}catch(e){r.e(e)}finally{r.f()}l=_(this.subVideoPlayerMap.values()),d=c(l),e.prev=8,d.s();case 10:if((h=d.n()).done){e.next=17;break}return(f=h.value).setViewMirror(this.player.mirror),e.next=15,f.play();case 15:e.next=10;break;case 17:e.next=22;break;case 19:e.prev=19,e.t0=e.catch(8),d.e(e.t0);case 22:return e.prev=22,d.f(),e.finish(22);case 25:case"end":return e.stop()}}),e,this,[[8,19,22,25]])}))),function(e,t){return o.apply(this,arguments)})},{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(cr(this)&&!e?this.jitterBufferDelay:0)),this.subVideoPlayerMap&&this.subVideoPlayerMap.size>0&&this.subVideoPlayerMap.forEach((function(e){e.stop()})),this.container=null)}},{key:"resume",value:(a=n(p().mark((function e(){var t;return p().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.isPlayCalled){e.next=2;break}return e.abrupt("return");case 2:return e.next=4,null==(t=this.player)?void 0:t.resume();case 4:case"end":return e.stop()}}),e,this)}))),function(){return a.apply(this,arguments)})},{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),hr.emit(e?pr.TRACK_MUTED:pr.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){na(e,e).add(oe.MUTE,this.onTrackMuted).add(oe.UNMUTE,this.onTrackUnmuted).add(oe.ENDED,this.onTrackEnded),e.muted&&this.onTrackMuted(),e.readyState===oe.ENDED&&this.onTrackEnded()}},{key:"uninstallTrackEvent",value:function(e){ra(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(cr(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 La;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 Pa?this.player.getVideoFrame():""}},{key:"emitFirstVideoFrameEvent",value:function(e){var t,n,r;if(!this.isFirstVideoFrameEmitted){var i=null==(t=this.mediaTrack)?void 0:t.getSettings(),a=(null==i?void 0:i.width)||(null==(n=this.player.element)?void 0:n.videoWidth)||0,o=(null==i?void 0:i.height)||(null==(r=this.player.element)?void 0:r.videoHeight)||0;if(e!==$i.LOADED_META_DATA||a||o){if(e!==$i.LOADED_DATA||a||o||this._log.warn("the dimension of video is 0x0 in first-video-frame event"),this.isFirstVideoFrameEmitted=!0,wt(this.rotation)){var s=[o,a];a=s[0],o=s[1]}this.emit("first-video-frame",{width:a,height:o,streamType:this.streamType,userId:this.isRemote?this.userId:""})}}}},{key:"onTrackMuted",value:function(){this._log.warn("".concat(this.kind," track is unable to provide media output"))}},{key:"onTrackUnmuted",value:function(){this._log.info("".concat(this.kind," track is able to provide media output"))}},{key:"onTrackEnded",value:function(){this._log.warn("".concat(this.kind," track ended"))}}]);var a,o,u}(Ki);H([ji([],Ki.INIT,{sync:!0})],To.prototype,"close");var Io=Object.prototype.hasOwnProperty;var bo=function(e){if(null==e)return!0;if("boolean"==typeof e)return!1;if("number"==typeof e)return 0===e;if("string"==typeof e)return 0===e.length;if("function"==typeof e)return 0===e.length;if(Array.isArray(e))return 0===e.length;if(e instanceof Error)return""===e.message;if(Ue(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(Io.call(e,t))return!1;return!0}return!1},So=function(){var e=n(p().mark((function e(t){var n,r,i,a,o,s;return p().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=Ro(t),kr.info("getUserMedia with constraints: ".concat(JSON.stringify(n))),r=[],i=[],a=["label","deviceId","groupId"],!n.audio){e.next=10;break}return e.next=8,ao();case 8:r=e.sent,kr.info("microphones: ".concat(pt(r.map((function(e){return V(U({},e),{groupId:e.groupId.substring(0,8)})})),{keysToInclude:a})));case 10:if(!n.video){e.next=15;break}return e.next=13,oo();case 13:i=e.sent,kr.info("cameras: ".concat(pt(i,{keysToInclude:a})));case 15:return e.prev=15,e.next=18,navigator.mediaDevices.getUserMedia(n);case 18:return o=e.sent,hi&&o.getTracks().forEach((function(e){kr.info("".concat(e.kind," capabilities: ").concat(pt(e.getCapabilities(),{keysToInclude:ge})))})),n.audio&&Ha(),e.abrupt("return",o);case 24:throw e.prev=24,e.t0=e.catch(15),s=e.t0.message,"NotFoundError"===e.t0.name&&(t.video&&i&&0===i.length&&(s=Tr({key:tr.CAMERA_NOT_FOUND})),t.audio&&r&&0===r.length&&(s=Tr({key:tr.MICROPHONE_NOT_FOUND}))),new _e({code:Ee.INITIALIZE_FAILED,name:e.t0.name,message:s,constraint:e.t0.constraint});case 29:case"end":return e.stop()}}),e,null,[[15,24]])})));return function(t){return e.apply(this,arguments)}}();function wo(e,t){return Ao.apply(this,arguments)}function Ao(){return(Ao=n(p().mark((function e(t,n){var r,i;return p().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!n){e.next=6;break}return e.next=3,oo();case 3:e.t0=e.sent,e.next=9;break;case 6:return e.next=8,ao();case 8:e.t0=e.sent;case 9:r=e.t0,(i=r.find((function(e){return e.deviceId===t})))&&je(i.getCapabilities)&&kr.warn(pt(i.getCapabilities(),{keysToInclude:ge}));case 12:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function Ro(e){return{audio:xo(e),video:Co(e)}}function xo(e){if(!e.audio)return!1;if(e.useTrueAsConstraint)return!0;var t={echoCancellation:!0,noiseSuppression:!0,autoGainControl:!0,sampleRate:e.sampleRate};return!bo(e.microphoneId)&&(t.deviceId=e.useExactDeviceId?{exact:e.microphoneId}:e.microphoneId,e.useDeviceIdOnly)?t:(We(e.channelCount)&&(t.channelCount=e.channelCount),qe(e.echoCancellation)&&!e.echoCancellation&&(t.echoCancellation=!1),qe(e.noiseSuppression)&&!e.noiseSuppression&&(t.noiseSuppression=!1),qe(e.autoGainControl)&&!e.autoGainControl&&(t.autoGainControl=!1),!!bo(t)||t)}function Co(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&&!bo(r)?r:(e.width&&(r.width={ideal:e.width},n&&!Bt&&(r.width.max=e.width)),e.height&&(r.height={ideal:e.height},n&&!Bt&&(r.height.max=e.height)),Bt&&mn&&e.width&&e.height&&e.width*e.height<101376&&(r.width=e.width,r.height=e.height),e.frameRate&&(r.frameRate=e.frameRate),!!bo(r)||r)}var Do=lr({retryFunction:So,settings:{retries:3,timeout:500},onError:function(e){var t=e.error,n=e.retry,r=e.reject,i=e.retryFuncArgs,a=e.retriedCount+1;"NotReadableError"===t.name||"OverconstrainedError"===t.name?(1===a?(i[0].video&&(i[0].maxResolution=!1,(!Bn||i[0].width*i[0].height<=2073600)&&i[0].frameRate&&(i[0].frameRate=i[0].frameRate>10?10:5)),i[0].retryWhenExactFailed&&i[0].useExactDeviceId&&(i[0].useExactDeviceId=!1)):2===a?i[0].useDeviceIdOnly=!0:3!==a||i[0].useExactDeviceId||(i[0].useTrueAsConstraint=!0),n()):r(t),i[0].microphoneId&&wo(i[0].microphoneId,!1),i[0].cameraId&&wo(i[0].cameraId,!0)},onRetrying:function(e){kr.warn("getUserMedia NotReadableError observed, retrying [".concat(e,"/3]"))},onRetryFailed:function(e){ia.logFailedEvent({eventType:ve,error:e})},onRetrySuccess:function(e){ia.logSuccessEvent({eventType:ve}),ia.uploadEvent({log:"stat-".concat(ve,"-success-").concat(e)})}});function Oo(e){return No((function(t,r){return n(p().mark((function n(){var r,i,a,o,s=arguments;return p().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:for(r=s.length,i=new Array(r),a=0;a<r;a++)i[a]=s[a];return n.next=3,t.apply(this,i);case 3:return o=n.sent,n.next=6,e.call.apply(e,[this].concat(i));case 6:return n.abrupt("return",o);case 7:case"end":return n.stop()}}),n,this)})))}))}function No(e){return function(t,n,r){return r.value=e(r.value,n),r}}var Mo,Lo,Po=(Mo=!1,Lo=document.visibilityState,function(){document.visibilityState!==Lo&&kr.info("visibility change: ".concat(document.visibilityState)),Mo||(document.addEventListener("visibilitychange",(function(){kr.info("visibility change: ".concat(document.visibilityState)),Lo=document.visibilityState})),Mo=!0)}),Uo=0,Vo=function(){return s((function e(){i(this,e),G(this,"log",kr.createLogger({id:"fq".concat(++Uo)})),G(this,"isRunning",!1),G(this,"queue",[])}),[{key:"length",get:function(){return this.queue.length}},{key:"lastQueueItem",get:function(){return 0===this.length?null:this.queue[this.length-1]}},{key:"push",value:function(e){var t,n,r=arguments.length>1&&void 0!==arguments[1]&&arguments[1],i=U({},e),a=new Promise((function(e,t){i.resolve=e,i.reject=t}));return i.promise=a,r?this.length<=1?this.queue.push(i):null==(n=null==(t=this.lastQueueItem)?void 0:t.promise)||n.then(i.resolve,i.reject):this.queue.push(i),this.log.debug("push ".concat(this.length)),this.isRunning||this.callNext(),a}},{key:"shift",value:function(){var e=this.queue.shift();return this.log.debug("shift ".concat(this.length)),e}},{key:"callNext",value:function(){var e=this;if(!this.isRunning&&0!==this.length){this.log.debug("callNext ",this.length);var t=this.queue[0],n=t.fn,r=t.args,i=t.context,a=t.resolve,o=t.reject;this.isRunning=!0,n.apply(i,r).then(a,o).finally((function(){e.isRunning=!1,e.shift(),e.callNext()}))}}}])}(),Fo=new WeakMap;function Bo(e,t){return No((function(n,r){return function(){var r=e;try{for(var i=arguments.length,a=new Array(i),o=0;o<i;o++)a[o]=arguments[o];var s=n.apply(this,a);tt();return Qe(s)?s.then((function(e){return t||Ar.addSuccessEvent({key:r}),e})).catch((function(e){throw Ar.addFailedEvent({key:r,error:e}),e})):(Ar.addSuccessEvent({key:r}),s)}catch(e){throw Ar.addFailedEvent({key:r,error:e}),e}}}))}var jo=function(e){function t(e,n){var a;return i(this,t),a=r(this,t,[{mediaType:e,PlayerClass:n}]),G(a,"isRemote",!1),G(a,"deviceId"),G(a,"groupId",""),G(a,"label",""),G(a,"sourceTrack"),G(a,"_isRecapturing",!1),G(a,"_lastRecaptureTime",0),G(a,"_onMuteTimeoutId",-1),G(a,"_encodeCheckTimeoutId",-1),G(a,"profile"),a}return d(t,e),s(t,[{key:"enableEncodeFrame",get:function(){return!1}},{key:"isPublishing",get:function(){return"publishing"===this.state.toString()}},{key:"isPublished",get:function(){return"publish"===this.state}},{key:"encodeFrame",value:function(e,t){throw new Error("Method not implemented.")}},{key:"installTrackEvent",value:function(e){na(e,e).add(oe.MUTE,this.onTrackMuted).add(oe.UNMUTE,this.onTrackUnmuted).add(oe.ENDED,this.onTrackEnded),e.muted&&this.onTrackMuted(),e.readyState===oe.ENDED&&this.onTrackEnded()}},{key:"uninstallTrackEvent",value:function(e){ra(e)}},{key:"setStateToReady",value:function(){}},{key:"capture",value:(l=n(p().mark((function e(t){var n,r,i,a;return p().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(e.prev=0,r=tt(),hr.emit(pr.LOCAL_TRACK_CAPTURE_START,{track:this}),!t.customSource){e.next=8;break}(i=new MediaStream).addTrack(t.customSource),e.next=12;break;case 8:return null==(n=this.mediaTrack)||n.stop(),e.next=11,Do(t);case 11:i=e.sent;case 12:return a=i.getTracks()[0],e.next=15,this.setInputMediaStreamTrack(a);case 15:return t.customSource||(this.sourceTrack=a,this.updateDeviceIdInUse(),this.listenDeviceChange()),hr.emit(pr.LOCAL_TRACK_CAPTURE_SUCCESS,{track:this,cost:tt()-r}),e.abrupt("return",i);case 20:throw e.prev=20,e.t0=e.catch(0),hr.emit(pr.LOCAL_TRACK_CAPTURE_FAILED,{track:this,error:e.t0}),this.log.error("getUserMedia error observed ".concat(e.t0)),e.t0;case 25:case"end":return e.stop()}}),e,this,[[0,20]])}))),function(e){return l.apply(this,arguments)})},{key:"setOutputMediaStreamTrack",value:function(e){var n;if(k(t,"setOutputMediaStreamTrack",this,3)([e]),this.setStateToReady(),this.isPublishing||this.isPublished)return null==(n=this.room)?void 0:n.replaceTrack(this)}},{key:"publish",value:function(e,t){return this.room=e,this.emit("4",{mediaType:this.strMediaType,state:"starting",prevState:"stopped"}),this.userId=e.userId,this._log.setUserId(e.userId),this._log.setSdkAppId(e.sdkAppId),t}},{key:"unpublish",value:function(){this.room&&this.room.localTracks.delete(this),hr.emit(pr.LOCAL_TRACK_UNPUBLISHED,{track:this})}},{key:"updateDeviceIdInUse",value:(u=n(p().mark((function e(){var t,n,r,i,a=this;return p().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.mediaTrack||!di){e.next=7;break}return t=this.mediaTrack.getSettings(),n=t.deviceId,r=t.groupId,i=this.mediaTrack.label,e.next=5,yo({newDeviceId:n,oldDeviceId:this.deviceId,oldGroupId:this.groupId,oldLabel:this.label,kind:this.kind});case 5:e.sent||(this.deviceId=n,this.label=i,r&&(this.groupId=r),ro().then((function(e){var t=e.find((function(e){return e.deviceId===n}));t&&a.emit("2",t)})));case 7:case"end":return e.stop()}}),e,this)}))),function(){return u.apply(this,arguments)})},{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===oe.AUDIO&&!function(e){if(e instanceof CanvasCaptureMediaStreamTrack)return!1;if(!(e instanceof MediaStreamTrack))return!1;var t=e.label.toLocaleLowerCase();if(t.includes("mic")||t.includes("麦克风"))return!0;var n=(null==e?void 0:e.getSettings())||{},r="".concat(n.deviceId,"_").concat(oe.AUDIO_INPUT);return!!po.has(r)}(this.mediaTrack)||this.kind===oe.VIDEO&&!function(e){if(e instanceof CanvasCaptureMediaStreamTrack)return!1;if(!(e instanceof MediaStreamTrack))return!1;var t=e.label.toLocaleLowerCase();if(t.includes("camera")||t.includes("webcam"))return!0;var n=(null==e?void 0:e.getSettings())||{},r="".concat(n.deviceId,"_").concat(oe.VIDEO_INPUT);return!!po.has(r)}(this.mediaTrack)||this._isRecapturing||e&&mn&&Bn)}},{key:"onTrackMuted",value:function(){var e=this;k(t,"onTrackMuted",this,3)([]),Po(),this.isNeedToRecapture(!0)&&(Date.now()-this._lastRecaptureTime<ye?setTimeout((function(){return e.onTrackMuted()}),ye):this._onMuteTimeoutId=setTimeout(n(p().mark((function t(){var n;return p().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!(null==(n=e.mediaTrack)?void 0:n.muted)){t.next=8;break}if(!Vt&&!Ft||"visible"===document.visibilityState){t.next=3;break}return t.abrupt("return");case 3:return t.t0=e,t.next=6,e.getRecoverCaptureDeviceId();case 6:t.t1=t.sent,t.t0.recapture.call(t.t0,t.t1);case 8:case"end":return t.stop()}}),t)}))),5e3))}},{key:"onTrackUnmuted",value:function(){k(t,"onTrackUnmuted",this,3)([]),this._onMuteTimeoutId>0&&clearTimeout(this._onMuteTimeoutId)}},{key:"onTrackEnded",value:(c=n(p().mark((function e(){var n=this;return p().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(k(t,"onTrackEnded",this,3)([]),this.isNeedToRecapture()){e.next=3;break}return e.abrupt("return");case 3:if(!(Date.now()-this._lastRecaptureTime<ye)){e.next=6;break}return setTimeout((function(){return n.onTrackEnded()}),ye),e.abrupt("return");case 6:return e.t0=this,e.next=9,this.getRecoverCaptureDeviceId();case 9:e.t1=e.sent,e.t0.recapture.call(e.t0,e.t1);case 11:case"end":return e.stop()}}),e,this)}))),function(){return c.apply(this,arguments)})},{key:"recapture",value:(o=n(p().mark((function e(t){var n,r,i,a=this;return p().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._isRecapturing&&this._inputTrack){e.next=2;break}return e.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"!==t&&"environment"!==t){e.next=11;break}r.facingMode=t,e.next=24;break;case 11:if(i=void 0,"audio"!==this.kind){e.next=18;break}return e.next=15,ao();case 15:e.t0=e.sent,e.next=21;break;case 18:return e.next=20,oo();case 20:e.t0=e.sent;case 21:e.t0.find((function(e){return e.deviceId===t}))&&(i=t),r.deviceId=i;case 24:return e.abrupt("return",this.capture(r).then((function(){a._isRecapturing=!1,a.log.warn("recapture success"),a.emit("1",{deviceId:a.deviceId}),hr.emit(pr.LOCAL_TRACK_RECAPTURE,{track:a})})).catch((function(e){a._isRecapturing=!1,a.log.warn("recapture failed ".concat(e.message)),a.emit("5",e),hr.emit(pr.LOCAL_TRACK_RECAPTURE,{track:a,error:e})})));case 25:case"end":return e.stop()}}),e,this)}))),function(e){return o.apply(this,arguments)})},{key:"getRecoverCaptureDeviceId",value:(a=n(p().mark((function e(){var t,n,r,i;return p().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(t=this instanceof qo)||!this.facingMode){e.next=3;break}return e.abrupt("return",this.facingMode);case 3:if(!(n=this.deviceId)){e.next=19;break}if(r=(Ho.get(n)||0)+1,Ho.set(n,r),!(r>=3)){e.next=19;break}if(!t){e.next=14;break}return e.next=11,oo();case 11:e.t0=e.sent.find((function(e){return!Ho.has(e.deviceId)})),e.next=17;break;case 14:return e.next=16,ao();case 16:e.t0=e.sent.find((function(e){return!Ho.has(e.deviceId)}));case 17:(i=e.t0)&&(this.log.warn("".concat(n," capture fail ").concat(r," times, change new ").concat(i.deviceId)),n=i.deviceId);case 19:return e.abrupt("return",n);case 20:case"end":return e.stop()}}),e,this)}))),function(){return a.apply(this,arguments)})},{key:"stopCapture",value:function(){var e;this.sourceTrack&&(this.sourceTrack.stop(),this.uninstallTrackEvent(this.sourceTrack)),null==(e=this.manager)||e.removeInput(this)}},{key:"close",value:function(){k(t,"close",this,3)([]),this.stopCapture()}}]);var a,o,c,u,l}(To);H([ji(Ki.INIT,"ready",{ignoreError:!0,sync:!0})],jo.prototype,"setStateToReady"),H([function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return function(t,n,r){var i=r.value;return r.value=function(){var t=Fo.get(this)||new Vo;Fo.set(this,t);for(var n=arguments.length,r=new Array(n),a=0;a<n;a++)r[a]=arguments[a];return t.push({fn:i,args:r,context:this},e)},r}}()],jo.prototype,"capture"),H([ji("ready","publish",{ignoreError:!0,success:function(){var e,t,n=this;this.room.localTracks.add(this),hr.emit(pr.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===oe.AUDIO,i=n.stat.bytesSent>0;Ar[i?"addSuccessEvent":"addFailedEvent"]({key:r?503700:513702}),i||(Ar.addEnum({key:r?503701:513703,value:$n()}),ia.uploadEvent({log:"stat-encode-failed-".concat(n.kind,"-").concat(er()),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===Ee.API_CALL_ABORTED&&(t="api-call")}this.emit("4",{mediaType:this.strMediaType,state:"stopped",prevState:"starting",reason:t,error:e.cause||e})}}),Bo(521714,!1)],jo.prototype,"publish"),H([No((function(e){return n(p().mark((function t(){var n;return p().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:n="publish"===this.state?"started":"starting",e.call(this),this.emit("4",{mediaType:this.strMediaType,state:"stopped",prevState:n,reason:"api-call"}),clearTimeout(this._encodeCheckTimeoutId);case 4:case"end":return t.stop()}}),t,this)})))})),ji([],"ready",{sync:!0})],jo.prototype,"unpublish");var Ho=new Map;hr.on(pr.SWITCH_DEVICE_SUCCESS,(function(e){e.track.deviceId&&Ho.delete(e.track.deviceId)}));var Go=function(){return s((function e(t){var n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];i(this,e),this.dataView=t,this.isSEI&&(n?this.addPreventionByte():this.removePreventionByte())}),[{key:"addPreventionByte",value:function(){for(var e=this.seiPayloadStartIndex,t=this.dataView.byteLength-2,n=[],r=0,i=e;i<=t;i++){var a=this.dataView.getInt8(i);switch(a){case 0:case 1:case 2:case 3:2===r&&(n.push(3),r=0),0==a?r++:r=0,n.push(a);break;default:r=0,n.push(a)}}n.push(this.dataView.getInt8(this.dataView.byteLength-1));var o=new DataView(new Uint8Array([].concat(_(new Uint8Array(this.dataView.buffer).slice(0,e)),n)).buffer);this.dataView=o}},{key:"removePreventionByte",value:function(){for(var e=this.seiPayloadStartIndex,t=this.dataView.byteLength-1,n=[],r=0,i=e;i<=t;i++)switch(this.dataView.getInt8(i)){case 0:r++,n.push(this.dataView.getInt8(i));break;case 3:2!==r&&n.push(this.dataView.getInt8(i)),r=0;break;default:n.push(this.dataView.getInt8(i)),r=0}var a=new DataView(new Uint8Array([].concat(_(new Uint8Array(this.dataView.buffer).slice(0,e)),n)).buffer);this.dataView=a}},{key:"isSEI",get:function(){return 6===this.dataView.getUint8(4)}},{key:"seiPayloadStartIndex",get:function(){for(var e=6,t=6;t<this.dataView.buffer.byteLength&&(e++,255===this.dataView.getUint8(t));t++);return e}},{key:"seiPayloadType",get:function(){return this.isSEI?this.dataView.getUint8(5):null}},{key:"seiPayload",get:function(){if(!this.isSEI)return null;for(var e=0,t=6,n=6;n<this.dataView.buffer.byteLength;n++){var r=this.dataView.getUint8(n);if(t++,255!==r){e+=r;break}e+=255}for(var i=new ArrayBuffer(e),a=new DataView(i),o=0;o<i.byteLength;o++,t++)a.setInt8(o,this.dataView.getInt8(t));return a}}])}(),Wo=function(){return s((function e(){i(this,e),G(this,"_seiMessageList",[]),G(this,"_smallSeiMessageList",[]),G(this,"_seiPayloadType",243)}),[{key:"encodeSEINalu",value:function(e){var t=e.byteLength,n=parseInt(String(t/255),10),r=t%255,i=[];i.push(0,0,0,1,6,this._seiPayloadType);for(var a=0;a<n;a++)i.push(255);i.push(r);var o=new DataView(e);return i.push.apply(i,_(new Uint8Array(o.buffer))),i.push(128),new Go(new DataView(new Uint8Array(i).buffer),!0)}},{key:"sendSEI",value:function(e,t){(null==t?void 0:t.seiPayloadType)&&(this._seiPayloadType=t.seiPayloadType),this._seiMessageList.push(e),(null==t?void 0:t.small)&&this._smallSeiMessageList.push(e)}},{key:"isEmpty",value:function(){return!this._seiMessageList.length}},{key:"getNaluCount",value:function(e){for(var t=0,n=0,r=new DataView(e),i=0;i<e.byteLength;i++)switch(r.getUint8(i)){case 0:t++;break;case 1:2!==t&&3!==t||n++,t=0;break;default:t=0}return n}},{key:"encode",value:function(e,t){var n=t?this._smallSeiMessageList:this._seiMessageList;if(n.length>0&&e.data.byteLength>0){var r=9-this.getNaluCount(e.data);if(r<=0)return 0;for(var i=n.splice(0,r).reverse().map(this.encodeSEINalu.bind(this)),a=i.reduce((function(e,t){return e+t.dataView.byteLength}),0),o=new ArrayBuffer(a+e.data.byteLength),s=new DataView(o),c=new DataView(e.data),u=0,l=0;l<i.length;l++)for(var d=0;d<i[l].dataView.byteLength;d++)s.setInt8(u++,i[l].dataView.getInt8(d));for(var h=0;h<e.data.byteLength;h++)s.setInt8(u++,c.getInt8(h));return e.data=o,i.length}return 0}}])}(),qo=function(e){function t(e){var n,a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:4;i(this,t),n=r(this,t,[a,Pa]),G(n,"profile",U({},ie)),G(n,"avoidCropping",!1),G(n,"_scaleResolutionDownBy"),G(n,"stat",{bytesSent:0,packetsSent:0,framesEncoded:0,framesSent:0,frameWidth:0,frameHeight:0,fpsCapture:0}),G(n,"small"),G(n,"isNeedToSetBandwidth"),G(n,"muteImage"),G(n,"manager"),G(n,"_seiCodec",new Wo),n.manager=e;var o=function(){n.isAllowed2k4k(n.profile)?n.room&&n.settings.height>=1440&&"publish"===n.state&&n.room.sendAbilityStatus({"2k4k":1}):(n.log.warn("Resolution is reset to 1080p, need to upgrade ability here https://cloud.tencent.com/document/product/647/85386"),n.setProfile(V(U({},n.profile),{width:1920,height:1080})),n.applyProfile())};return n.on("input-media-track-changed",o),n.on("publish",o),n.handleCameraAdded=n.handleCameraAdded.bind(n),n.handleCameraRemoved=n.handleCameraRemoved.bind(n),n}return d(t,e),s(t,[{key:"facingMode",get:function(){if(di&&this.mediaTrack)return this.mediaTrack.getSettings().facingMode}},{key:"contentHint",get:function(){var e;return(null==(e=this._inputTrack)?void 0:e.contentHint)||""}},{key:"isQosClearFirst",get:function(){var e;return"detail"===(null==(e=this._inputTrack)?void 0:e.contentHint)}},{key:"setMute",value:(h=n(p().mark((function e(n){var r,i,a;return p().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!Ge(n)){e.next=11;break}if(this.muteImage!==n){e.next=3;break}return e.abrupt("return");case 3:return e.next=5,null==(r=this.manager)?void 0:r.deleteWatermark("mute");case 5:return e.next=7,null==(i=this.manager)?void 0:i.setWatermark({x:0,y:0,width:this.settings.width,height:this.settings.height,type:"mute",zIndex:999,imageUrl:n});case 7:this.muteImage=n,k(t,"setMute",this,3)([!1]),e.next=16;break;case 11:if(!this.muteImage){e.next=15;break}return e.next=14,null==(a=this.manager)?void 0:a.deleteWatermark("mute");case 14:this.muteImage=void 0;case 15:k(t,"setMute",this,3)([n]);case 16:case"end":return e.stop()}}),e,this)}))),function(e){return h.apply(this,arguments)})},{key:"capture",value:function(e){var n=e.deviceId,r=e.facingMode,i=e.useExactDeviceId,a=void 0===i||i,o=e.customSource,s=e.retryWhenExactFailed,c=void 0===s||s;return k(t,"capture",this,3)([{audio:!1,video:!0,facingMode:r||this.facingMode,cameraId:n,width:this.profile.width,height:this.profile.height,frameRate:this.profile.frameRate,useExactDeviceId:a,retryWhenExactFailed:c,customSource:o}])}},{key:"setProfile",value:function(e){var n=this.fallbackProfile(e);n.bitrate&&(this.isNeedToSetBandwidth=n.bitrate!==this.profile.bitrate),this.isAllowed2k4k(this.profile)?k(t,"setProfile",this,3)([n]):(this.log.warn("Resolution is reset to 1080p, need to upgrade ability here https://cloud.tencent.com/document/product/647/85386"),k(t,"setProfile",this,3)([V(U({},this.profile),{width:1920,height:1080})]))}},{key:"applyProfile",value:(l=n(p().mark((function e(){var t,n,r,i,a,o,s,c,u,l,d,h,f;return p().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.mediaTrack){e.next=2;break}return e.abrupt("return");case 2:if(n=(this.sourceTrack||this.mediaTrack).getSettings(),r=n.width,i=void 0===r?0:r,a=n.height,o=i*(void 0===a?0:a),s=this.settings,!(c=s.height!==this.profile.height||s.width!==this.profile.width||s.frameRate!==this.profile.frameRate)){e.next=16;break}if(16!==Wn||!this.deviceId){e.next=12;break}return e.next=10,this.recapture(this.deviceId);case 10:e.next=15;break;case 12:return e.next=14,null==(t=this.sourceTrack||this.mediaTrack)?void 0:t.applyConstraints({width:this.profile.width,height:this.profile.height,frameRate:this.profile.frameRate});case 14:this.manager&&this.manager.changeInput(this);case 15:this.room&&this.settings.height>=1440&&"publish"===this.state&&this.room.sendAbilityStatus({"2k4k":1});case 16:if(!(this.isNeedToSetBandwidth&&this.room&&this.room.setBandWidth)){e.next=24;break}if(this.isNeedToSetBandwidth=!1,u=(this.sourceTrack||this.mediaTrack).getSettings(),l=u.width,d=void 0===l?0:l,h=u.height,f=d*(void 0===h?0:h),!(c&&f&&o&&f===o)){e.next=23;break}return this.log.warn("set bandwidth failed: resolution is not changed"),e.abrupt("return");case 23:return e.abrupt("return",this.room.setBandWidth({bandwidth:this.profile.bitrate,type:oe.VIDEO,videoType:oe.BIG}));case 24:case"end":return e.stop()}}),e,this)}))),function(){return l.apply(this,arguments)})},{key:"settings",get:function(){var e={width:this.profile.width,height:this.profile.height,frameRate:this.profile.frameRate},t=this.sourceTrack||this.mediaTrack;return di&&t&&Object.assign(e,t.getSettings()),e}},{key:"scaleResolutionDownBy",get:function(){return this._scaleResolutionDownBy?this._scaleResolutionDownBy:St(this.settings,this.profile)}},{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:(u=n(p().mark((function e(t){var n;return p().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(e.prev=0,this.isNeedToSwitchDevice(t)){e.next=3;break}return e.abrupt("return");case 3:return n={useExactDeviceId:!0,retryWhenExactFailed:!1},"user"===t||"environment"===t?n.facingMode=t:n.deviceId=t,this.mediaTrack.stop(),e.next=8,this.capture(n);case 8:hr.emit(pr.SWITCH_DEVICE_SUCCESS,{track:this}),this.log.info("switch camera success"),e.next=17;break;case 12:throw e.prev=12,e.t0=e.catch(0),this.log.error("switch camera failed ".concat(e.t0)),this.deviceId&&this.recapture(this.deviceId),e.t0;case 17:case"end":return e.stop()}}),e,this,[[0,12]])}))),function(e){return u.apply(this,arguments)})},{key:"updateSmallConfig",value:function(e){var t,n;this._log.info("update small stream config: ".concat(JSON.stringify(e)));var r=!this.small;this.small=this.fallbackProfile(e,!0),null==(t=this.manager)||t.update(),r&&(null==(n=this.room)||n.enableSmall(!0)),this.log.info("update small stream config success")}},{key:"fallbackProfile",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=e.width>e.height,r=U({},e);return e.width*e.height<=19200&&Ft&&Ln&&(this.log.warn("".concat(t?"small ":"","resolution is ").concat(e.width,"*").concat(e.height,", fallback to 240*180 for android chrome")),r.width=n?240:180,r.height=n?180:240,r.bitrate=Math.max(e.bitrate,150)),e.width*e.height>921600&&Kn&&(r.width=n?1280:720,r.height=n?720:1280,this.log.warn("reset to 1280 * 720 on iOS 13~14")),!t&&this.avoidCropping&&(Ln||Bt)&&!(Ft||Vt||Pt||Mt||On)&&e.width*e.height<=230400&&e.width/e.height==16/9&&(this._scaleResolutionDownBy=1280/e.width,e.width=1280,e.height=720,this.log.warn("capture 720p, scale: ".concat(this._scaleResolutionDownBy))),r}},{key:"stopSmall",value:function(){var e,t;this.small&&(delete this.small,null==(e=this.manager)||e.update(),null==(t=this.room)||t.enableSmall(!1))}},{key:"listenDeviceChange",value:function(){to&&!to.listeners("videoInputRemoved").includes(this.handleCameraRemoved)&&to.on("videoInputRemoved",this.handleCameraRemoved,this)}},{key:"handleCameraRemoved",value:(c=n(p().mark((function e(t){var n;return p().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t.deviceId!==this.deviceId){e.next=7;break}return this.log.warn("current camera is lost: ".concat(JSON.stringify(t))),Qs(this.userId,{eventId:2003,param1:7,streamType:2}),e.next=5,oo();case 5:(n=e.sent)[0]?this.recapture(n[0].deviceId):to.on("videoInputAdded",this.handleCameraAdded,this);case 7:case"end":return e.stop()}}),e,this)}))),function(e){return c.apply(this,arguments)})},{key:"handleCameraAdded",value:(o=n(p().mark((function e(t){return p().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this.log.warn("camera added: ".concat(JSON.stringify(t))),this.recapture(t.deviceId);case 2:case"end":return e.stop()}}),e,this)}))),function(e){return o.apply(this,arguments)})},{key:"encodeFrame",value:function(e,t){if(!this.manager)return e;var n=t?8:this.mediaType;return this.manager.encodePipeline.reduceRight((function(e,t){return t?t({frame:e,mediaType:n}):e}),e)}},{key:"enableEncodeFrame",get:function(){return!!this.manager&&this.manager.encodePipeline.some((function(e){return e}))}},{key:"play",value:function(e,n){return He(this.mirror)&&!this.isScreen&&this.setMirror("view"),k(t,"play",this,3)([e,n])}},{key:"close",value:function(){to.off("videoInputAdded",this.handleCameraAdded,this),to.off("videoInputRemoved",this.handleCameraRemoved,this),k(t,"close",this,3)([])}},{key:"recapture",value:(a=n(p().mark((function e(n){var r;return p().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,k(t,"recapture",this,3)([n]);case 3:case 13:e.next=16;break;case 5:return e.prev=5,e.t0=e.catch(0),e.next=9,oo();case 9:if(!(r=e.sent.find((function(e){return e.deviceId!==n})))){e.next=15;break}return e.next=13,k(t,"recapture",this,3)([r.deviceId]);case 15:throw e.t0;case 16:case"end":return e.stop()}}),e,this,[[0,5]])}))),function(e){return a.apply(this,arguments)})},{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))}},{key:"setRotation",value:function(e){this.manager&&(this.isScreen||He(e)||e!==this.rotation&&(this.rotation=e,this.manager.rotation=e))}}]);var a,o,c,u,l,h}(jo);H([Oo((function(e){this.setContentHint(e.contentHint||"motion")}))],qo.prototype,"capture");var Ko=[-1,-1,1,-1,-1,1,1,1],zo=[0,0,1,0,0,1,1,1],Yo=function(e){function t(e,n){var a;if(i(this,t),(a=r(this,t)).context=e,G(a,"name"),G(a,"input"),G(a,"output"),G(a,"texture"),G(a,"ctx2d",null),G(a,"fbo"),G(a,"width",0),G(a,"height",0),G(a,"x",0),G(a,"y",0),G(a,"program"),G(a,"vertexShader"),G(a,"fragmentShader"),G(a,"totalFrames",0),G(a,"dropFrames",0),G(a,"matchInputSize",!0),G(a,"texCoordBuffer"),G(a,"positionBuffer"),G(a,"lastInfo",{name:"",timestamp:0,totalFrames:0,x:0,y:0,width:0,height:0,fps:0}),G(a,"cost",0),G(a,"_canvas",null),G(a,"_image"),G(a,"log"),a.context.on("disconnect",a.close,a),a.name=n.name,a.log=n.logger,a.matchInputSize=!1!==n.matchInputSize,a.width=n.width||e.width,a.height=n.height||e.height,a._image=n.image,e instanceof Fs)return e.ctx&&n.create2d&&("function"==typeof OffscreenCanvas&&16!==Wn?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),f(a);try{var o=e.ctx;a.texCoordBuffer=a.createBuffer(zo),a.positionBuffer=a.createBuffer(Ko),!1!==n.createTexture&&(a.texture=o.createTexture(),a.useTexture(),o.texParameteri(o.TEXTURE_2D,o.TEXTURE_MIN_FILTER,o.LINEAR),o.texParameteri(o.TEXTURE_2D,o.TEXTURE_MAG_FILTER,o.LINEAR),o.texParameteri(o.TEXTURE_2D,o.TEXTURE_WRAP_S,o.CLAMP_TO_EDGE),o.texParameteri(o.TEXTURE_2D,o.TEXTURE_WRAP_T,o.CLAMP_TO_EDGE),o.pixelStorei(o.PACK_ALIGNMENT,1),o.pixelStorei(o.UNPACK_ALIGNMENT,1)),n.useFbo&&(a.fbo=o.createFramebuffer(),a.useBufferFrame(),a.useTexture(),o.texImage2D(o.TEXTURE_2D,0,o.RGBA,a.width,a.height,0,o.RGBA,o.UNSIGNED_BYTE,null),o.framebufferTexture2D(o.FRAMEBUFFER,o.COLOR_ATTACHMENT0,o.TEXTURE_2D,a.texture,0)),n.useDefaultProgram?a.program=e.defaultProgam:(n.vertexShaderSource||n.fragmentShaderSource)&&(a.vertexShader=n.vertexShaderSource?e.createShader(o.VERTEX_SHADER,n.vertexShaderSource):e.defaultVShader,a.fragmentShader=n.fragmentShaderSource?e.createShader(o.FRAGMENT_SHADER,n.fragmentShaderSource):e.defaultFShader,a.program=e.createProgram(a.vertexShader,a.fragmentShader))}catch(e){a.context.destroy(new _e({code:Ee.VIDEO_MANAGER_ERROR,extraCode:3,message:"create video node ".concat(a.name," error ").concat(e.message||e)}))}return a}return d(t,e),s(t,[{key:"image",get:function(){return this._image},set:function(e){this._image=e}},{key:"createFramebuffer",value:function(e){var t=this.context.ctx,n=t.createFramebuffer();return t.bindFramebuffer(t.FRAMEBUFFER,n),t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,e,0),n}},{key:"connect",value:function(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r];return e.addInput.apply(e,[this].concat(n)),this.output=e,e}},{key:"addInput",value:function(e){this.input=e,this.matchInputSize&&e.width&&e.height&&this.resize(e.width,e.height)}},{key:"requestFrame",value:function(e){var t=Date.now();return!!(this.context instanceof Vs&&this.render(e)||this.context instanceof Fs&&this.render2d(e))&&(this.totalFrames++,this.cost=Date.now()-t,!0)}},{key:"render2d",value:function(e){var t;return!!(null==(t=this.input)?void 0: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 Vs){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(_(this.getVertexPoint(e.x,e.y)),_(this.getVertexPoint(e.x+e.width,e.y)),_(this.getVertexPoint(e.x,e.y+e.height)),_(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,a,o,s,c){var u=void 0!==a&&void 0!==o&&void 0!==s&&void 0!==c;return!(!this.ctx2d||!e)&&(e instanceof ImageData?u?this.ctx2d.putImageData(e,t,n,a,o,s,c):this.ctx2d.putImageData(e,t,n):(u?this.ctx2d.drawImage(e,a,o,s,c,t,n,r,i):this.ctx2d.drawImage(e,t,n,r,i),"undefined"!=typeof VideoFrame&&e instanceof VideoFrame&&e.close()),!0)}},{key:"drawBackGround2d",value:function(e){this.ctx2d&&(this.ctx2d.save(),this.ctx2d.fillStyle=e,this.ctx2d.fillRect(0,0,this.width,this.height),this.ctx2d.restore())}},{key:"getInfo",value:function(){var e,t=this.totalFrames,n=this.x,r=this.y,i=this.width,a=this.height,o=this.name,s=this.cost,c=Date.now(),u=(t-this.lastInfo.totalFrames)/((c-this.lastInfo.timestamp)/1e3)|0;return this.lastInfo={totalFrames:t,x:n,y:r,width:i,height:a,timestamp:c,fps:u,name:o,cost:s},U({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}}])}(Ki);function Xo(){}H([ji(Ki.INIT,"connected",{sync:!0})],Yo.prototype,"connect"),H([ji("connected",Ki.INIT,{ignoreError:!0,sync:!0})],Yo.prototype,"disconnect"),H([ji([],"closed",{sync:!0})],Yo.prototype,"close");var Qo=function(e){return e()};function Jo(){this.dispose()}var Zo=1,$o=function(e){function t(){return i(this,t),r(this,t,arguments)}return d(t,e),s(t,[{key:"toString",value:function(){return"".concat(this.name,"(").concat(this.args.length?_(this.args).join(", "):"",")")}},{key:"subscribe",value:function(e){var t=new ss(e,this,this.streamId++);return cs.subscribe({id:this.id,end:!1},{nodeId:t.sourceId,streamId:t.id}),this(t),t}}])}(S(Function)),es=function(){return s((function e(){i(this,e),this.defers=new Set,this.disposed=!1}),[{key:"next",value:function(e){}},{key:"complete",value:function(){this.dispose()}},{key:"error",value:function(e){this.dispose()}},{key:"bindDispose",get:function(){var e=this;return function(){return e.dispose()}}},{key:"dispose",value:function(){this.disposed=!0,this.complete=Xo,this.error=Xo,this.next=Xo,this.dispose=Xo,this.subscribe=Xo,this.doDefer()}},{key:"subscribe",value:function(e){return e instanceof $o?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(Qo),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}}])}(),ts=function(e){function t(e){var n;return i(this,t),(n=r(this,t)).sink=e,e.defer(n.bindDispose),n}return d(t,e),s(t,[{key:"next",value:function(e){this.sink.next(e)}},{key:"complete",value:function(){this.sink.complete()}},{key:"error",value:function(e){this.sink.error(e)}}])}(es),ns=function(e){function t(e){var n,a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Xo,o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:Xo,s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:Xo;if(i(this,t),(n=r(this,t))._next=a,n._error=o,n._complete=s,n.then=Xo,e instanceof $o){var c={toString:function(){return"subscribe"},id:0,source:e};n.defer((function(){cs.defer(c,0)})),cs.create(c),cs.pipe(c),n.sourceId=c.id,n.subscribe(e),cs.subscribe({id:c.id,end:!0}),a==Xo?n._next=function(e){return cs.next(c,0,e)}:n.next=function(e){cs.next(c,0,e),a(e)},s==Xo?n._complete=function(){return cs.complete(c,0)}:n.complete=function(){n.dispose(),cs.complete(c,0),s()},o==Xo?n._error=function(e){return cs.complete(c,0,e)}:n.error=function(e){n.dispose(),cs.complete(c,0,e),o()}}else n.subscribe(e);return n}return d(t,e),s(t,[{key:"next",value:function(e){this._next(e)}},{key:"complete",value:function(){this.dispose(),this._complete()}},{key:"error",value:function(e){this.dispose(),this._error(e)}}])}(es);function rs(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 is(e,t,n){if("undefined"!=typeof __FASTRX_DEVTOOLS__){var r=Object.defineProperties(Object.setPrototypeOf(e,$o.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}});cs.create(r);for(var i=0;i<n.length;i++){var a=n[i];"function"==typeof a&&a instanceof $o&&cs.addSource(r,a)}return r}return e}function as(e,t){return function(){for(var n=arguments,r=arguments.length,i=new Array(r),o=0;o<r;o++)i[o]=arguments[o];return function(r){if(r instanceof $o){var o=is((function(t){var n=a(e,[t].concat(i));n.sourceId=o.id,n.subscribe(r)}),t,n);return o.source=r,cs.pipe(o),o}return function(t){return r(a(e,[t].concat(i)))}}}}function os(e,t){window.postMessage({source:"fastrx-devtools-backend",payload:{event:e,payload:t}})}var ss=function(e){function t(e,n,a){var o;return i(this,t),(o=r(this,t,[e])).source=n,o.id=a,o.sourceId=e.sourceId,o.defer((function(){cs.defer(o.source,o.id)})),o}return d(t,e),s(t,[{key:"next",value:function(e){cs.next(this.source,this.id,e),this.sink.next(e)}},{key:"complete",value:function(){cs.complete(this.source,this.id),this.sink.complete()}},{key:"error",value:function(e){cs.complete(this.source,this.id,e),this.sink.error(e)}}])}(ts),cs={addSource:function(e,t){os("addSource",{id:e.id,name:e.toString(),source:{id:t.id,name:t.toString()}})},next:function(e,t,n){os("next",{id:e.id,streamId:t,data:n&&n.toString()})},subscribe:function(e,t){os("subscribe",{id:e.id,end:e.end,sink:{nodeId:t&&t.nodeId,streamId:t&&t.streamId}})},complete:function(e,t,n){os("complete",{id:e.id,streamId:t,err:n?n.toString():null})},defer:function(e,t){os("defer",{id:e.id,streamId:t})},pipe:function(e){os("pipe",{name:e.toString(),id:e.id,source:{id:e.source.id,name:e.source.toString()}})},update:function(e){os("update",{id:e.id,name:e.toString()})},create:function(e){e.id||(e.id=Zo++),os("create",{name:e.toString(),id:e.id})}},us=function(e){function t(e){var n;return i(this,t),(n=r(this,t)).source=e,n.sinks=new Set,n}return d(t,e),s(t,[{key:"add",value:function(e){var t=this;e.defer((function(){return t.remove(e)})),1===this.sinks.add(e).size&&(this.reset(),this.subscribe(this.source))}},{key:"remove",value:function(e){this.sinks.delete(e),0===this.sinks.size&&this.dispose()}},{key:"next",value:function(e){this.sinks.forEach((function(t){return t.next(e)}))}},{key:"complete",value:function(){this.sinks.forEach((function(e){return e.complete()})),this.sinks.clear()}},{key:"error",value:function(e){this.sinks.forEach((function(t){return t.error(e)})),this.sinks.clear()}}])}(es);function ls(){var e=arguments;return function(t){var n=new us(t);if(t instanceof $o){var r=is((function(e){n.add(e)}),"share",e);return n.sourceId=r.id,r.source=t,cs.pipe(r),r}return is(n.add.bind(n),"share",e)}}function ds(e){var t=arguments,n=ls()(is((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=Xo,n.complete=Xo,n.error=Xo,n}function hs(e,t){return function(n){var r=function(e){return n.next(e)};n.defer((function(){return t(r)})),e(r)}}function fs(e,t){if("on"in e&&"off"in e)return is(hs((function(n){return e.on(t,n)}),(function(n){return e.off(t,n)})),"fromEvent",arguments);if("addListener"in e&&"removeListener"in e)return is(hs((function(n){return e.addListener(t,n)}),(function(n){return e.removeListener(t,n)})),"fromEvent",arguments);if("addEventListener"in e)return is(hs((function(n){return e.addEventListener(t,n)}),(function(n){return e.removeEventListener(t,n)})),"fromEvent",arguments);throw"target is not a EventDispachter"}var ps=as(function(e){function t(e,n,a){var o;return i(this,t),(o=r(this,t,[e])).filter=n,o.thisArg=a,o}return d(t,e),s(t,[{key:"next",value:function(e){this.filter.call(this.thisArg,e)&&this.sink.next(e)}}])}(ts),"filter"),vs=as(function(e){function t(e,n){var a;return i(this,t),(a=r(this,t,[e])).count=n,a}return d(t,e),s(t,[{key:"next",value:function(e){this.sink.next(e),0==--this.count&&this.complete()}}])}(ts),"take"),ms=as(function(e){function t(e,n){var a;i(this,t),a=r(this,t,[e]);var o=new ts(e);return o.next=function(){return e.complete()},o.complete=Jo,o.subscribe(n),a}return d(t,e),s(t)}(ts),"takeUntil"),ys=function(e){function t(e,n){var a;return i(this,t),(a=r(this,t,[e])).f=n,a}return d(t,e),s(t,[{key:"next",value:function(e){this.f(e)||(this.next=k(t,"next",this,1),this.next(e))}}])}(ts),gs=as(ys,"skipWhile"),ks=as(function(e){function t(e,n,a){var o;return i(this,t),(o=r(this,t,[e])).mapper=n,o.thisArg=a,o}return d(t,e),s(t,[{key:"next",value:function(e){k(t,"next",this,3)([this.mapper.call(this.thisArg,e)])}}])}(ts),"map"),Es=function(e){function t(e,n,a){var o;return i(this,t),(o=r(this,t,[e])).data=n,o.context=a,o}return d(t,e),s(t,[{key:"next",value:function(e){var t=this.context.combineResults;t?this.sink.next(t(this.data,e)):this.sink.next(e)}},{key:"tryComplete",value:function(){this.context.resetComplete(),this.dispose()}}])}(ts),_s=function(e){function t(e,n,a){var o;return i(this,t),(o=r(this,t,[e])).makeSource=n,o.combineResults=a,o.index=0,o}return d(t,e),s(t,[{key:"subInner",value:function(e,t){var n=this.currentSink=new t(this.sink,e,this);this.complete=this.tryComplete,n.complete=n.tryComplete,n.subscribe(this.makeSource(e,this.index++))}},{key:"tryComplete",value:function(){this.currentSink.resetComplete(),this.dispose()}}])}(ts),Ts=function(e){function t(){return i(this,t),r(this,t,arguments)}return d(t,e),s(t)}(Es),Is=function(e){function t(){return i(this,t),r(this,t,arguments)}return d(t,e),s(t,[{key:"next",value:function(e){var t=this;this.subInner(e,Ts),this.next=function(e){t.currentSink.dispose(),t.subInner(e,Ts)}}}])}(_s),bs=as(Is,"switchMap");var Ss,ws=(Ss=as(Is,"switchMapTo"),function(e,t){return Ss((function(){return e}),t)}),As=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:Xo,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Xo,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:Xo;return function(r){return new ns(r,e,t,n)}},Rs=rs(function(e){return is((function(t){var n=0,r=setInterval((function(){return t.next(n++)}),e);return t.defer((function(){clearInterval(r)})),"interval"}),"interval",arguments)}(250),ks((function(){return performance.now()})),ls()),xs=[0,1,1,1,0,0,1,0],Cs=function(e){function t(e,n){var a;return i(this,t),a=r(this,t,[e,Object.assign({useDefaultProgram:!0,createTexture:!1,name:"destination"},n)]),G(a,"_intervalId",0),G(a,"_sequence",0),G(a,"checkGLError",!1),G(a,"checkVisibilityChange"),e instanceof Fs?a.ctx2d=e.ctx||null:e.available&&(null==n?void 0:n.mirrorUpAndDown)&&a.setTexBuffer(xs),a}return d(t,e),s(t,[{key:"start",value:function(e){var t=this;this.log.info("".concat(this.name," start render ").concat(e," fps")),Zi.clearTask(this._intervalId),this._intervalId=Zi.run("intervalInWorker",(function(){if(e!==t.context.frameRate&&(Zi.clearTask(t._intervalId),t.start(t.context.frameRate)),t.requestFrame(t._sequence++),t.checkGLError&&t.context instanceof Vs){var n=t.context.ctx.getError();n&&t.context.destroy(new _e({code:Ee.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)?void 0:t.requestFrame(e))&&(this.useProgram(),this.useBufferFrame(),this.useInputTexture(),this.draw(),!0)}},{key:"addInput",value:function(e){for(var n=arguments.length,r=new Array(n>1?n-1:0),i=1;i<n;i++)r[i-1]=arguments[i];k(t,"addInput",this,3)([e].concat(r)),this.start(this.context.frameRate)}},{key:"update",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;if(this._intervalId&&(Zi.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){k(t,"removeInput",this,3)([e]),Zi.clearTask(this._intervalId)}},{key:"resize",value:function(e,n){k(t,"resize",this,3)([e,n]),this.context.setSize(e,n)}},{key:"close",value:function(){k(t,"close",this,3)([]),Zi.clearTask(this._intervalId),document.removeEventListener("visibilitychange",this.checkVisibilityChange)}}])}(Yo),Ds=function(e){function t(e,n){var a;i(this,t),a=r(this,t,[e,n]),G(a,"_videoTrack"),G(a,"_muteOb"),G(a,"_closedOb",fs(a,"closed")),G(a,"_subscription"),G(a,"_canvasContainer"),Number(Hn)<17&&(a._canvasContainer=document.createElement("div"),a._canvasContainer.style.display="none");var o=y(e._canvas.captureStream().getVideoTracks(),1);return a._videoTrack=o[0],a._muteOb=fs(a._videoTrack,"mute"),rs(fs(a._videoTrack,"ended"),ms(a._closedOb),As((function(){a.context.destroy(new _e({code:Ee.VIDEO_MANAGER_ERROR,extraCode:8,message:"video track ended"}))}))),a}return d(t,e),s(t,[{key:"enableCheckMute",value:function(){var e,t=this;this._subscription=rs(this._muteOb,ms(this._closedOb),ws((e=5e3,function(t){var n=performance.now();rs(Rs,gs((function(t){return t-n<e})),vs(1))(t)})),ps((function(){var e;return!!(null==(e=t._videoTrack)?void 0:e.muted)&&!document.hidden})),As((function(){t.context.destroy(new _e({code:Ee.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(),k(t,"render",this,3)([e])}},{key:"render2d",value:function(e){return this.putCanvasIntoDom(),k(t,"render2d",this,3)([e])}},{key:"close",value:function(){var e,n;k(t,"close",this,3)([]),null==(e=this._videoTrack)||e.stop(),delete this._videoTrack,null==(n=this._canvasContainer)||n.remove()}}])}(Cs),Os=function(e){function t(e,n){var a;return i(this,t),a=r(this,t,[e,U({name:"imageSource"},n)]),G(a,"_lastImage"),G(a,"_totalFrames",0),G(a,"_autoResize",!1),G(a,"_canvasRendered"),G(a,"_videoCallbackId",0),G(a,"waitingFirstFrame",!0),G(a,"shouldUpdate",!0),a._autoResize=!1!==(null==n?void 0:n.autoResize),16===Wn&&(a._canvasRendered=ds(),rs(a._canvasRendered,function(){for(var e=arguments,t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return function(t){return is((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)}}(a._image),bs((function(e){return e instanceof HTMLCanvasElement?fs(e,"rendered"):function(){return is((function(e){return e.complete()}),"empty",arguments)}()})),ms(fs(a,"closed")),As((function(){a.update()})))),a}return d(t,e),s(t,[{key:"onFirstFrame",value:function(){this.waitingFirstFrame=!1}},{key:"tryVideoFrameCallback",value:function(){var e=this;if(this.shouldUpdate){var t=this.image;this._videoCallbackId&&t.cancelVideoFrameCallback(this._videoCallbackId),bi()&&!document.hidden&&(this._videoCallbackId=t.requestVideoFrameCallback((function(t,n){e.waitingFirstFrame&&e.onFirstFrame(),document.hidden||(e._totalFrames=n.presentedFrames,e.update(1))})))}}},{key:"_render",value:function(e,t){var n,r=this.width,i=this.height,a=this.image;if(a instanceof HTMLVideoElement){if(this.tryVideoFrameCallback(),r=a.videoWidth,i=a.videoHeight,!r||!i)return!1;a.width=r,a.height=i}else if(a instanceof HTMLImageElement||a instanceof ImageData||a instanceof ImageBitmap){if(r=a.width,i=a.height,a!==this._lastImage)this._lastImage=a;else if(r===this.width&&i===this.height)return!0}else a instanceof HTMLCanvasElement||a instanceof OffscreenCanvas?(r=a.width,i=a.height,this._lastImage=a):"undefined"!=typeof VideoFrame&&a instanceof VideoFrame&&(r=a.displayWidth,i=a.displayHeight,null==(n=this._lastImage)||n.close(),this._lastImage=a);if(!this._autoResize)return!0;if(this.width===r&&this.height===i&&this.totalFrames){if(t){this.useTexture();var o=this.context.ctx;o.texSubImage2D(o.TEXTURE_2D,0,0,0,o.RGBA,o.UNSIGNED_BYTE,a)}}else{if(t){this.useTexture();var s=this.context.ctx;s.texImage2D(s.TEXTURE_2D,0,s.RGBA,s.RGBA,s.UNSIGNED_BYTE,a)}this.resize(r,i)}return!0}},{key:"image",get:function(){return this._image},set:function(e){var t;null==(t=this._canvasRendered)||t.next(e),this._image=e}},{key:"render",value:function(e){return this._render(e,!0)}},{key:"render2d",value:function(e){return this._render(e,!1)}},{key:"close",value:function(){k(t,"close",this,3)([]);var e=this.image;e instanceof HTMLVideoElement&&(e.pause(),e.srcObject=null,e.remove())}}])}(Yo),Ns=function(e){function t(e,n,a){var o;return i(this,t),(o=r(this,t,[e,a]))._player=n,o.name="videoPlayerSource",rs(fs(o._player,$i.PLAYER_STATE_CHANGED),ms(fs(o,"closed")),ps((function(e){return"PLAYING"===e.state})),As((function(){o.tryVideoFrameCallback()}))),o}return d(t,e),s(t,[{key:"image",get:function(){return this._player.element}}])}(Os),Ms=function(e){function t(e,n,a){var o;return i(this,t),(o=r(this,t,[e,new Pa({id:a.name,track:n,muted:!0,container:null,objectFit:"contain",log:a.logger}),a])).name="videoTrackSource",o._player.play(),o}return d(t,e),s(t,[{key:"available",get:function(){return this._player.isPlaying&&!this.waitingFirstFrame}},{key:"replaceTrack",value:function(e){this.waitingFirstFrame=!0,this._player.setTrack(e),this._player.play()}},{key:"close",value:function(){k(t,"close",this,3)([]),this._player.stop()}}])}(Ns),Ls=function(e){function t(e){var n;return i(this,t),n=r(this,t),G(n,"frameRate"),G(n,"_canvas"),G(n,"log"),G(n,"hasAlpha",!1),G(n,"name"),G(n,"error"),n.name=e.name,n.log=e.logger.createChild({id:"vc-".concat(n.name)}),n.frameRate=e.frameRate,n}return d(t,e),s(t,[{key:"width",get:function(){var e;return(null==(e=this._canvas)?void 0:e.width)||0},set:function(e){this._canvas&&(this._canvas.width=e)}},{key:"height",get:function(){var e;return(null==(e=this._canvas)?void 0:e.height)||0},set:function(e){this._canvas&&(this._canvas.height=e)}},{key:"setSize",value:function(e,t){this._canvas&&(this._canvas.width=e,this._canvas.height=t)}},{key:"createVideoTrackSource",value:function(e,t){return new Ms(this,e,{logger:this.log,name:t})}},{key:"createVideoTrackDestination",value:function(e){return new Ds(this,e)}},{key:"createVideoImageSource",value:function(e,t){return new Os(this,t?Object.assign(t,{logger:this.log,image:e}):{logger:this.log,image:e})}},{key:"createVideoPlayerSource",value:function(e,t){return new Ns(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")}}])}(Ki);G(Ls,"_ids",0);var Ps={alpha:!0,antialias:!1,premultipliedAlpha:!1,preserveDrawingBuffer:!1,depth:!1,stencil:!1,failIfMajorPerformanceCaveat:!0,powerPreference:"low-power"},Us=function(e){function t(){var e;return i(this,t),e=r(this,t,arguments),G(e,"defaultProgam"),G(e,"defaultVShader"),G(e,"defaultFShader"),G(e,"ctx"),e}return d(t,e),s(t,[{key:"create",value:function(){var e=this;if(this._canvas||(this._canvas=document.createElement("canvas"),this._canvas.id="trtc_".concat(this.name,"_").concat(Ls._ids++)),this.ctx=this._canvas.getContext("webgl2",Ps),!this.ctx)throw new _e({code:Ee.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 _e({code:Ee.VIDEO_MANAGER_ERROR,extraCode:4,message:"webgl context lost"}))}))}},{key:"destroy",value:function(e){var t="";return e&&(t=e.message,this.error=e,Ar.addFailedEvent({key:512702,error:e})),this.disconnect(),this.log.info("video context destroy".concat(t)?": ".concat(t):""),this.ctx&&(this.ctx.deleteShader(this.defaultVShader),this.ctx.deleteShader(this.defaultFShader),this.ctx.deleteProgram(this.defaultProgam),delete this.ctx),e}},{key:"width",set:function(e){var n;null==(n=this.ctx)||n.viewport(0,0,e,this.height),E(t,"width",e,this,1)}},{key:"height",set:function(e){var n;null==(n=this.ctx)||n.viewport(0,0,this.width,e),E(t,"height",e,this,1)}},{key:"setSize",value:function(e,n){var r;null==(r=this.ctx)||r.viewport(0,0,e,n),k(t,"setSize",this,3)([e,n])}},{key:"createShader",value:function(e,t){var n=this.ctx,r=n.createShader(e);return n.shaderSource(r,t),n.compileShader(r),r}},{key:"createProgram",value:function(e,t){var n=this.ctx,r=n.createProgram();return n.attachShader(r,e),n.attachShader(r,t),n.linkProgram(r),n.getProgramParameter(r,n.LINK_STATUS)||this.log.error(n.getProgramInfoLog(r)),r}}])}(Ls);G(Us,"UNAVAILABLE","unavailable"),H([ji(Ki.INIT,"created",{sync:!0,fail:function(e){this.log.error("video gl context create failed",e.cause),Ar.addFailedEvent({key:512700,error:e.cause||e})},success:function(){this.log.info("video context created use webgl"),Ar.addSuccessEvent({key:512700})}})],Us.prototype,"create"),H([ji("created",Ki.INIT,{ignoreError:!0,sync:!0,success:function(e){e&&this.emit(Us.UNAVAILABLE,e),this.removeAllListeners()}})],Us.prototype,"destroy");var Vs=Us,Fs=function(e){function t(){var e;return i(this,t),e=r(this,t,arguments),G(e,"ctx"),e}return d(t,e),s(t,[{key:"create",value:function(e){var t=this;if(this.hasAlpha=e.alpha,this._canvas=document.createElement("canvas"),this._canvas.id="trtc_".concat(this.name,"_").concat(Ls._ids++),this.ctx=this._canvas.getContext("2d",{alpha:e.alpha}),!this.ctx)throw new _e({code:Ee.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,Ar.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(),Ar.addSuccessEvent({key:512703})}}])}(Ls);H([ji(Ki.INIT,"created",{sync:!0,fail:function(e){this.log.error("video 2d context create failed",e.cause),Ar.addFailedEvent({key:512701,error:e.cause||e})},success:function(){this.log.info("video context created use 2d"),Ar.addSuccessEvent({key:512701})}})],Fs.prototype,"create"),H([ji("created",Ki.INIT,{ignoreError:!0,sync:!0})],Fs.prototype,"destroy");var Bs=Mi();if("undefined"!=typeof navigator&&navigator.mediaDevices&&"setCaptureHandleConfig"in navigator.mediaDevices)try{navigator.mediaDevices.setCaptureHandleConfig({handle:Bs,exposeOrigin:!0,permittedOrigins:["*"]})}catch(e){}var js=function(){var e=n(p().mark((function e(t){var n,r,i,a,o;return p().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=null,r=qs(t),kr.info("getDisplayMedia with constraints: ".concat(JSON.stringify(r))),e.next=5,navigator.mediaDevices.getDisplayMedia(r);case 5:if(i=e.sent,t.systemAudio&&0===i.getAudioTracks().length&&(Pn&&Vn<74||Bn||Bt)&&kr.warn("Your browser not support capture system audio"),!(a=i.getVideoTracks()[0])){e.next=21;break}if(!t.frameRate){e.next=18;break}return e.prev=10,e.next=13,a.applyConstraints({frameRate:{min:t.frameRate,ideal:t.frameRate},width:t.width,height:t.height});case 13:e.next=18;break;case 15:e.prev=15,e.t0=e.catch(10),kr.warn("screen applyConstraints failed: ".concat(e.t0));case 18:if(!t.captureElement){e.next=21;break}return e.next=21,Hs(a,t.captureElement);case 21:if(!t.audio){e.next=28;break}return o=Ws(t),kr.info("getUserMedia with constraints: ".concat(JSON.stringify(o))),e.next=26,navigator.mediaDevices.getUserMedia(o);case 26:n=e.sent,i.addTrack(n.getAudioTracks()[0]);case 28:return e.abrupt("return",i);case 29:case"end":return e.stop()}}),e,null,[[10,15]])})));return function(t){return e.apply(this,arguments)}}();function Hs(e,t){return Gs.apply(this,arguments)}function Gs(){return(Gs=n(p().mark((function e(t,n){var r,i;return p().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!("CropTarget"in window&&"fromElement"in CropTarget&&je(t.cropTo))){e.next=15;break}if(e.prev=1,(null==(r=t.getCaptureHandle())?void 0:r.handle)===Bs){e.next=5;break}return e.abrupt("return");case 5:return e.next=7,CropTarget.fromElement(n);case 7:return i=e.sent,e.next=10,t.cropTo(i);case 10:e.next=15;break;case 12:e.prev=12,e.t0=e.catch(1),kr.warn("cropTo target failed ".concat(e.t0));case 15:case"end":return e.stop()}}),e,null,[[1,12]])})))).apply(this,arguments)}function Ws(e){var t={echoCancellation:e.echoCancellation,autoGainControl:e.autoGainControl,noiseSuppression:e.noiseSuppression,sampleRate:e.sampleRate,channelCount:e.channelCount};return He(e.microphoneId)||(t.deviceId=e.microphoneId),{audio:t,video:!1}}function qs(e){var t={preferCurrentTab:"current-tab"===e.preferDisplaySurface||!!e.captureElement,systemAudio:"include",selfBrowserSurface:"include",surfaceSwitching:"include"},n={width:Bn?{max:e.width}:{ideal:e.width,max:e.width},height:Bn?{max:e.height}:{ideal:e.height,max:e.height},frameRate:e.frameRate,displaySurface:e.preferDisplaySurface||"monitor"};if(t.video=n,e.systemAudio){var r=e.echoCancellation,i=void 0===r||r,a=e.noiseSuppression,o=void 0!==a&&a,s=e.autoGainControl,c=void 0!==s&&s;t.audio={echoCancellation:i,noiseSuppression:o,autoGainControl:c,sampleRate:48e3}}return t}var Ks=js,zs=function(e){function t(e){var n;return i(this,t),n=r(this,t,[e,2]),G(n,"profile",{width:1920,height:1080,frameRate:5,bitrate:1600}),G(n,"objectFit","contain"),G(n,"isScreen",!0),n._log.id="s-".concat(n._log.id),n}return d(t,e),s(t,[{key:"isShareCurrentTab",get:function(){var e,t;try{return Bs===(null==(t=null==(e=this.mediaTrack)?void 0:e.getCaptureHandle())?void 0:t.handle)}catch(e){return}}},{key:"capture",value:(o=n(p().mark((function e(t){var n,r,i,a,o,s,c,u,l,d,h;return p().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=t.systemAudio,r=void 0!==n&&n,i=t.autoGainControl,a=t.echoCancellation,o=t.noiseSuppression,s=t.audioTrack,c=t.videoTrack,u=t.captureElement,l=t.preferDisplaySurface,e.prev=1,!c&&!s){e.next=8;break}d=new MediaStream,c&&d.addTrack(c),s&&d.addTrack(s),e.next=11;break;case 8:return e.next=10,Ks({audio:!1,systemAudio:r,width:this.profile.width,height:this.profile.height,frameRate:this.profile.frameRate,autoGainControl:i,echoCancellation:a,noiseSuppression:o,captureElement:u,preferDisplaySurface:l});case 10:d=e.sent;case 11:return h=d.getVideoTracks()[0],this.sourceTrack=h,e.next=15,this.setInputMediaStreamTrack(h);case 15:return e.abrupt("return",d);case 18:throw e.prev=18,e.t0=e.catch(1),this.log.error("getDisplayMedia error observed ".concat(e.t0)),e.t0 instanceof _e?e.t0:new _e({code:Ee.INITIALIZE_FAILED,name:e.t0.name,message:e.t0.message});case 22:case"end":return e.stop()}}),e,this,[[1,18]])}))),function(e){return o.apply(this,arguments)})},{key:"switchDevice",value:(a=n(p().mark((function e(t){return p().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:throw new Error("Method not implemented.");case 1:case"end":return e.stop()}}),e)}))),function(e){return a.apply(this,arguments)})}]);var a,o}(qo);H([Oo((function(e){this.setContentHint(e.contentHint||"detail")}))],zs.prototype,"capture");var Ys=function(e){function t(e,n,a){var o;i(this,t),(o=r(this,t,[{userId:n.userId,sdkAppId:e.sdkAppId,mediaType:a,room:e}])).room=e,o.user=n,G(o,"tinyId"),G(o,"isRemote",!0),G(o,"jitterBufferDelay",0),G(o,"availableState"),G(o,"remotePublishState"),G(o,"_triggerCheckDecodeSubject",ds(fs(o,t.STATE_SUBSCRIBE))),o.tinyId=n.tinyId,o.availableState=new Ki("".concat(n.userId,"-").concat(o.mediaType,"-available"),"remote-track-available"),o.remotePublishState=new Ki("".concat(n.userId,"-").concat(o.mediaType,"-remote-publish"),"remote-track-publish"),rs(function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return is((function(e){var n=new ts(e),r=t.length;n.complete=function(){0==--r&&e.complete()},t.forEach(n.bindSubscribe)}),"merge",arguments)}(fs(o,Ki.STATECHANGED),fs(o.remotePublishState,Ki.STATECHANGED)),ks((function(){return o.isRemotePublished&&(o.isSubscribed||o.isSubscribing)})),As((function(e){o.availableState.state!==(e?Ki.ON:Ki.OFF)&&(o.availableState.state=e?Ki.ON:Ki.OFF),o.updatePlayingState(e)})));var s=rs(fs(o.player,$i.ERROR),ps((function(e){return e.code===MediaError.MEDIA_ERR_DECODE}))),c=rs(function(e,t){return is((function(t){var n=0,r=setTimeout((function(){t.removeDefer(i),t.next(n++),t.complete()}),e),i=function(){clearTimeout(r)};t.defer(i)}),"timer",arguments)}(5e3),ps((function(){return!(o.ignoreDecodeError||!o.isSubscribed||!o.isPlayCalled||!o.stat.bytesReceived)&&(!(o.player.isPlaying||(o.kind===oe.AUDIO?o.getAudioLevel()>0:o.stat.framesDecoded>0))||(o.reportDecodeResult(!0),!1))}))),u=rs(function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return is((function(e){var n=new Map;t.forEach((function(t){var r=new ts(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)}(s,c),ms(fs(o,Ki.INIT)));return rs(o._triggerCheckDecodeSubject,ps((function(){return!o.ignoreDecodeError})),ws(u),As((function(e){o.reportDecodeResult(!1,e)}))),o}return d(t,e),s(t,[{key:"setMute",value:function(e){this.isRemotePublished&&k(t,"setMute",this,3)([e])}},{key:"setInputMediaStreamTrack",value:function(e){k(t,"setInputMediaStreamTrack",this,3)([e]),this.isRemotePublished&&this.isSubscribed&&this.player.setTrack(this.outMediaTrack)}},{key:"checkDecodeResult",value:function(){this._triggerCheckDecodeSubject.next(!0)}},{key:"waitHasMediaTrack",value:function(){var e=this;return new Promise((function(t){e.mediaTrack?t():e.once("input-media-track-changed",t)}))}},{key:"ignoreDecodeError",get:function(){var e,t;return((null==(t=null==(e=this.room)?void 0:e.networkQuality)?void 0:t.downlinkNetworkQuality)||0)>3||this.player.isInAutoPlayFailedState}},{key:"isSubscribing",get:function(){return"subscribeing"===this.state.toString()}},{key:"isSubscribed",get:function(){return this.state===t.STATE_SUBSCRIBE}},{key:"isAvailable",get:function(){return this.availableState.state===Ki.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===oe.AUDIO;Ar[e?"addSuccessEvent":"addFailedEvent"]({key:n?504700:514702}),e||(Ar.addEnum({key:n?504701:514703,value:$n()}),ia.uploadEvent({log:"stat-decode-failed-".concat(this.kind,"-").concat(er()),userId:this.room.userId}),this._log.warn("decode failed: isPlaying: ".concat(this.player.isPlaying," ").concat(this.kind===oe.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," "));k(t,"updatePlayingState",this,3)([e])}}},{key:"close",value:function(){k(t,"close",this,3)([]),this.outMediaTrack&&this.uninstallTrackEvent(this.outMediaTrack)}},{key:"onFlagChanged",value:function(){this.remotePublishState.state=this.isRemotePublished?Ki.ON:Ki.OFF}},{key:"onTrackMuted",value:function(){this.isNeedPlay&&k(t,"onTrackMuted",this,3)([])}},{key:"onTrackUnmuted",value:function(){this.isNeedPlay&&k(t,"onTrackUnmuted",this,3)([])}},{key:"onTrackEnded",value:function(){this.isNeedPlay&&k(t,"onTrackEnded",this,3)([])}}])}(To);G(Ys,"STATE_SUBSCRIBE","subscribe"),H([function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:30,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:2;return No((function(n,r){return function(){for(var i=this,a=arguments.length,o=new Array(a),s=0;s<a;s++)o[s]=arguments[s];return new Promise((function(a,s){var c=setTimeout((function(){var n=new _e({code:Ee.API_CALL_TIMEOUT,message:"checkPendingPromise ".concat(r,"() timeout ").concat(e,"s")});kr.warn(n),2===t?s(n):1===t&&a()}),1e3*e);n.apply(i,o).then(a,s).finally((function(){clearTimeout(c)}))}))}}))}(5,1)],Ys.prototype,"waitHasMediaTrack"),H([ji(Ki.INIT,Ys.STATE_SUBSCRIBE,{success:function(){this.log.info("subscribed"),hr.emit(pr.REMOTE_TRACK_SUBSCRIBED,{track:this})},ignoreError:!0}),Bo(521716,!1)],Ys.prototype,"subscribe"),H([ji(Ys.STATE_SUBSCRIBE,Ki.INIT,{sync:!0,success:function(){this.log.info("unsubscribed"),hr.emit(pr.REMOTE_TRACK_UNSUBSCRIBED,{track:this})}})],Ys.prototype,"unsubscribe");var Xs=new Map;function Qs(e,t){var n=V(U({},t),{timestamp:rr()});Xs.has(e)?Xs.get(e).push(n):Xs.set(e,[n])}hr.on(pr.JOIN_SUCCESS,(function(e){Qs(e.room.userId,{eventId:32788})})),hr.on(pr.LEAVE_START,(function(e){Qs(e.room.userId,{eventId:32789})})),hr.on(pr.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),Qs(t.room.userId,{eventId:n})}})),hr.on(pr.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),Qs(t.room.userId,{eventId:n})}})),hr.on(pr.TRACK_MUTED,(function(e){var t=e.track;t.room&&(t.kind===oe.AUDIO?Qs(t.room.userId,{eventId:t.isRemote?32785:32772,remoteUserId:t.isRemote?t.userId:void 0}):Qs(t.room.userId,{eventId:t.isRemote?32784:32773,remoteUserId:t.isRemote?t.userId:void 0}))})),hr.on(pr.TRACK_UNMUTED,(function(e){var t=e.track;t.room&&(t.kind===oe.AUDIO?Qs(t.room.userId,{eventId:t.isRemote?32787:32774,remoteUserId:t.isRemote?t.userId:void 0}):Qs(t.room.userId,{eventId:t.isRemote?32786:32775,remoteUserId:t.isRemote?t.userId:void 0}))})),hr.on(pr.REMOTE_TRACK_SUBSCRIBED,(function(e){var t=e.track;t.room&&(1===t.mediaType&&Qs(t.room.userId,{eventId:32777,remoteUserId:t.userId}),4===t.mediaType&&Qs(t.room.userId,{eventId:32776,remoteUserId:t.userId}),8===t.mediaType&&Qs(t.room.userId,{eventId:32803,remoteUserId:t.userId}))})),hr.on(pr.REMOTE_TRACK_UNSUBSCRIBED,(function(e){var t=e.track;t.room&&(1===t.mediaType&&Qs(t.room.userId,{eventId:32779,remoteUserId:t.userId}),4===t.mediaType&&Qs(t.room.userId,{eventId:32778,remoteUserId:t.userId}),8===t.mediaType&&Qs(t.room.userId,{eventId:32804,remoteUserId:t.userId}))})),hr.on(pr.SWITCH_DEVICE_SUCCESS,(function(e){var t=e.track;t.room&&Qs(t.room.userId,{eventId:t.kind===oe.VIDEO?32780:32781})})),hr.on(pr.LOCAL_TRACK_REPLACED,(function(e){var t=e.track;t.room&&Qs(t.room.userId,{eventId:t.kind===oe.VIDEO?32782:32783})})),hr.on(pr.SIGNAL_CONNECTION_STATE_CHANGED,(function(e){var t=e.room,n=e.prevState,r=void 0;switch(e.state){case"CONNECTED":r="RECONNECTING"===n?32795:32791;break;case"DISCONNECTED":r="RECONNECTING"===n?32796:32790;break;case"RECONNECTING":r=32794}r&&Qs(t.userId,{eventId:r})})),hr.on(pr.PEER_CONNECTION_STATE_CHANGED,(function(e){var t=e.room,n=e.prevState,r=e.state,i=e.remoteUserId,a=!!i,o=void 0;switch(r){case"CONNECTED":o="RECONNECTING"===n?a?32801:32798:a?32793:32792;break;case"DISCONNECTED":"RECONNECTING"===n&&(o=a?32802:32799);break;case"RECONNECTING":o=a?32800:32797}o&&Qs(t.userId,{eventId:o,remoteUserId:i})})),hr.on(pr.VIDEO_CODEC_IMPLEMENTATION_CHANGED,(function(e){e.implementation;var t=e.userId,n=e.remoteUserId,r=e.codec,i=e.isHWCodec,a=i?1:0;e.prevImplementation||(a=i?3:2);var o="h264"===r?0:2,s={eventId:4004,param1:a,param2:o,streamType:e.streamType||2};n&&(s.remoteUserId=n,s.eventId=4005),Qs(t,s),Ar.addEnum({key:n?514701:513701,value:a}),Ar.addEnum({key:n?514700:513700,value:o})})),hr.on(pr.LOCAL_TRACK_RECAPTURE,(function(e){var t=e.track,n=e.error;if(t.userId){var r={eventId:2003,param1:0};t.kind===oe.AUDIO?(r.streamType=1,n&&(r.param1=2)):(r.streamType="auxiliary"===t.streamType?7:2,n&&(r.param1=8)),Qs(t.userId,r)}})),j(W());var Js=0,Zs=function(){function e(t){i(this,e),this.core=t,G(this,"seq"),G(this,"log"),G(this,"localMixVideoTrack",null),G(this,"_mixVideoConfig"),Js+=1,this.seq=Js,this.log=t.log.createChild({id:"".concat(this.getAlias()).concat(Js)}),this.log.info("created")}return s(e,[{key:"getName",value:function(){return e.Name}},{key:"getAlias",value:function(){return"vmix"}},{key:"getValidateRule",value:function(e){switch(e){case"start":return t=this.core,{name:"VideoMixerOptions",type:"object",required:!0,allowEmpty:!1,properties:{view:U({},Ai(t)),canvasInfo:{type:"object",required:!0,properties:{canvasColor:{required:!1,type:"string"},width:{required:!0,type:"number",notLessThanZero:!0,min:1},height:{required:!0,type:"number",notLessThanZero:!0,min:1},frameRate:{required:!1,type:"number",notLessThanZero:!0}}},camera:U({},xi(t)),screen:U({},Ci(t)),text:U({},Di(t)),image:U({},Oi(t)),video:U({},Ni(t))}};case"update":return function(e){return{name:"VideoMixerOptions",type:"object",required:!1,allowEmpty:!1,properties:{view:U({},Ai(e)),canvasInfo:{type:"object",required:!1,properties:{canvasColor:{required:!1,type:"string"},width:{required:!0,type:"number",notLessThanZero:!0,min:1},height:{required:!0,type:"number",notLessThanZero:!0,min:1},frameRate:{required:!1,type:"number",notLessThanZero:!0}}},camera:U({},xi(e)),screen:U({},Ci(e)),text:U({},Di(e)),image:U({},Oi(e)),video:U({},Ni(e))}}}(this.core);case"stop":return this.core,{name:"StopVideoMixerOptions",required:!1}}var t}},{key:"getGroup",value:function(){return"vmix"}},{key:"subStream",get:function(){return this.core.trtc.getVideoTrack({streamType:this.core.TRTC.TYPE.STREAM_TYPE_SUB})}},{key:"mainStream",get:function(){return this.core.trtc.getVideoTrack()}},{key:"start",value:(d=n(p().mark((function e(t){var n;return p().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.localMixVideoTrack||(this.localMixVideoTrack=new this.core.LocalMixVideoTrack),e.next=3,this.parseMixInput(t);case 3:return n=t.view,this._updatePreview({view:n,track:this.localMixVideoTrack}),this._mixVideoConfig=t,e.next=8,this.localMixVideoTrack.startMix();case 8:return e.abrupt("return",this.localMixVideoTrack._outputTrack);case 9:case"end":return e.stop()}}),e,this)}))),function(e){return d.apply(this,arguments)})},{key:"update",value:(l=n(p().mark((function e(t){var n;return p().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.localMixVideoTrack){e.next=2;break}throw new Error("can't update without mixTrack!");case 2:return e.next=4,this.parseMixInput(t);case 4:return n=t.view,e.next=7,this._updatePreview({view:n,track:this.localMixVideoTrack,prevConfig:this._mixVideoConfig});case 7:return ut(this._mixVideoConfig,t),e.abrupt("return",this.localMixVideoTrack._outputTrack);case 9:case"end":return e.stop()}}),e,this)}))),function(e){return l.apply(this,arguments)})},{key:"parseMixInput",value:(u=n(p().mark((function e(t){var n,r,i,a,o,s,u,l,d,h,f,v,m,y,g,k,E,_,T,I,b,S,w,A,R,x,C,D,O,N,M,L,P,U,V,F,B,j,H,G,W,q,K,z,Y,X,Q,J,Z,$,ee,te,ne,ie,ae,oe,se,ce,ue,le,de,he,fe,pe,ve=this;return p().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.localMixVideoTrack){e.next=2;break}return e.abrupt("return");case 2:if(h=t.canvasInfo,f=t.camera,v=t.screen,m=t.text,y=t.image,g=t.video,h&&(k=h.canvasColor,E=h.width,_=h.height,T=h.frameRate,k&&this.localMixVideoTrack.setMixBackground(k),T&&this.localMixVideoTrack.setFps(T),this.localMixVideoTrack.resizeMixCanvas(E,_)),!f){e.next=26;break}I=(null==(n=this._mixVideoConfig)?void 0:n.camera)||[],b=new Set(f.map((function(e){return e.id}))),S=I.filter((function(e){return!b.has(e.id)})).map((function(e){return e.id})),w=c(S);try{for(w.s();!(A=w.n()).done;)R=A.value,this.localMixVideoTrack.removeCameraSource(R)}catch(e){w.e(e)}finally{w.f()}x=c(f),e.prev=11,D=p().mark((function e(){var t,n,s,c,u,l,d,h;return p().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=C.value,n=t.id,s=t.layout,t.cameraId,t.videoTrack,c=t.profile,!I.some((function(e){return e.id===n}))){e.next=11;break}return u=null==(i=null==(r=ve.localMixVideoTrack)?void 0:r.inputLocalVideoTracks.get(n))?void 0:i.mediaTrack,e.next=6,ve.updateCameraProfile(t);case 6:l=null==(o=null==(a=ve.localMixVideoTrack)?void 0:a.inputLocalVideoTracks.get(n))?void 0:o.mediaTrack,c&&(d=Ge(c)?re[c]:c),l!==u?ve.localMixVideoTrack.updateCameraSource(n,s,l,d):ve.localMixVideoTrack.updateCameraSource(n,s,null,d),e.next=22;break;case 11:return e.prev=11,e.next=14,ve.captureCamera(t);case 14:h=e.sent,ve.localMixVideoTrack.addCameraSource(n,h,s),e.next=22;break;case 18:e.prev=18,e.t0=e.catch(11),ve.log.error("".concat(n," mix failed: "),e.t0),t.id="some err occurs_"+Date.now();case 22:case"end":return e.stop()}}),e,null,[[11,18]])})),x.s();case 14:if((C=x.n()).done){e.next=18;break}return e.delegateYield(D(),"t0",16);case 16:e.next=14;break;case 18:e.next=23;break;case 20:e.prev=20,e.t1=e.catch(11),x.e(e.t1);case 23:return e.prev=23,x.f(),e.finish(23);case 26:if(!v){e.next=48;break}O=(null==(s=this._mixVideoConfig)?void 0:s.screen)||[],N=new Set(v.map((function(e){return e.id}))),M=O.filter((function(e){return!N.has(e.id)})).map((function(e){return e.id})),L=c(M);try{for(L.s();!(P=L.n()).done;)U=P.value,this.localMixVideoTrack.removeScreenSource(U)}catch(e){L.e(e)}finally{L.f()}V=c(v),e.prev=33,B=p().mark((function e(){var t,n,r,i;return p().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=F.value,n=t.id,t.profile,t.captureElement,t.preferDisplaySurface,r=t.layout,!O.some((function(e){return e.id===n}))){e.next=6;break}ve.localMixVideoTrack.updateScreenSource(n,r),e.next=17;break;case 6:return e.prev=6,e.next=9,ve.captureScreen(t);case 9:i=e.sent,ve.localMixVideoTrack.addScreenSource(n,i,r),e.next=17;break;case 13:e.prev=13,e.t0=e.catch(6),ve.log.error("".concat(n," mix failed: "),e.t0),t.id="some err occurs_"+Date.now();case 17:case"end":return e.stop()}}),e,null,[[6,13]])})),V.s();case 36:if((F=V.n()).done){e.next=40;break}return e.delegateYield(B(),"t2",38);case 38:e.next=36;break;case 40:e.next=45;break;case 42:e.prev=42,e.t3=e.catch(33),V.e(e.t3);case 45:return e.prev=45,V.f(),e.finish(45);case 48:if(!m){e.next=70;break}j=(null==(u=this._mixVideoConfig)?void 0:u.text)||[],H=new Set(m.map((function(e){return e.id}))),G=j.filter((function(e){return!H.has(e.id)})).map((function(e){return e.id})),W=c(G);try{for(W.s();!(q=W.n()).done;)K=q.value,this.localMixVideoTrack.removeTextSource(K)}catch(e){W.e(e)}finally{W.f()}z=c(m),e.prev=55,X=p().mark((function e(){var t,n;return p().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=Y.value,n=t.id,t.content,t.font,t.color,t.layout,j.some((function(e){return e.id===n}))?ve.localMixVideoTrack.updateTextSource(t):ve.localMixVideoTrack.addTextSource(t);case 3:case"end":return e.stop()}}),e)})),z.s();case 58:if((Y=z.n()).done){e.next=62;break}return e.delegateYield(X(),"t4",60);case 60:e.next=58;break;case 62:e.next=67;break;case 64:e.prev=64,e.t5=e.catch(55),z.e(e.t5);case 67:return e.prev=67,z.f(),e.finish(67);case 70:if(!y){e.next=92;break}Q=(null==(l=this._mixVideoConfig)?void 0:l.image)||[],J=new Set(y.map((function(e){return e.id}))),Z=Q.filter((function(e){return!J.has(e.id)})).map((function(e){return e.id})),$=c(Z);try{for($.s();!(ee=$.n()).done;)te=ee.value,this.localMixVideoTrack.removeImageSource(te)}catch(e){$.e(e)}finally{$.f()}ne=c(y),e.prev=77,ae=p().mark((function e(){var t,n,r,i,a;return p().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=ie.value,n=t.id,r=t.url,i=t.layout,!Q.some((function(e){return e.id===n}))){e.next=6;break}ve.localMixVideoTrack.updateImageSource(n,i),e.next=10;break;case 6:return e.next=8,gt(r);case 8:a=e.sent,ve.localMixVideoTrack.addImageSource(n,a,i);case 10:case"end":return e.stop()}}),e)})),ne.s();case 80:if((ie=ne.n()).done){e.next=84;break}return e.delegateYield(ae(),"t6",82);case 82:e.next=80;break;case 84:e.next=89;break;case 86:e.prev=86,e.t7=e.catch(77),ne.e(e.t7);case 89:return e.prev=89,ne.f(),e.finish(89);case 92:if(!g){e.next=114;break}oe=(null==(d=this._mixVideoConfig)?void 0:d.video)||[],se=new Set(g.map((function(e){return e.id}))),ce=oe.filter((function(e){return!se.has(e.id)})).map((function(e){return e.id})),ue=c(ce);try{for(ue.s();!(le=ue.n()).done;)de=le.value,this.localMixVideoTrack.removeVideoSource(de)}catch(e){ue.e(e)}finally{ue.f()}he=c(g),e.prev=99,pe=p().mark((function e(){var t,n,r,i,a;return p().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=fe.value,n=t.id,r=t.url,i=t.layout,!oe.some((function(e){return e.id===n}))){e.next=6;break}ve.localMixVideoTrack.updateVideoSource(n,i),e.next=10;break;case 6:return e.next=8,At(r);case 8:a=e.sent,ve.localMixVideoTrack.addVideoSource(n,a,i);case 10:case"end":return e.stop()}}),e)})),he.s();case 102:if((fe=he.n()).done){e.next=106;break}return e.delegateYield(pe(),"t8",104);case 104:e.next=102;break;case 106:e.next=111;break;case 108:e.prev=108,e.t9=e.catch(99),he.e(e.t9);case 111:return e.prev=111,he.f(),e.finish(111);case 114:case"end":return e.stop()}}),e,this,[[11,20,23,26],[33,42,45,48],[55,64,67,70],[77,86,89,92],[99,108,111,114]])}))),function(e){return u.apply(this,arguments)})},{key:"captureCamera",value:(o=n(p().mark((function e(t){var n,r,i,a,o;return p().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=t.cameraId,r=t.videoTrack,i=t.profile,a=new this.core.LocalVideoTrack(this.core.room.videoManager),o={},n?o.deviceId=n:He(r)||(o.customSource=r),He(i)||(Ge(i)?re[i]&&a.setProfile(re[i]):a.setProfile(i)),e.next=7,a.capture(o);case 7:return e.abrupt("return",a);case 8:case"end":return e.stop()}}),e,this)}))),function(e){return o.apply(this,arguments)})},{key:"updateCameraProfile",value:(a=n(p().mark((function e(t){var n,r,i,a,o,s;return p().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=t.id,i=t.cameraId,a=t.videoTrack,o=t.profile,t.layout,s=null==(n=this.localMixVideoTrack)?void 0:n.inputLocalVideoTracks.get(r)){e.next=4;break}return e.abrupt("return");case 4:if(!i){e.next=9;break}return e.next=7,s.switchDevice(i);case 7:e.next=12;break;case 9:if(He(a)){e.next=12;break}return e.next=12,s.setInputMediaStreamTrack(a);case 12:if(He(o)){e.next=17;break}if(Ge(o)?re[o]&&s.setProfile(re[o]):s.setProfile(o),i&&s.isNeedToSwitchDevice(i)){e.next=17;break}return e.next=17,s.applyProfile();case 17:case"end":return e.stop()}}),e,this)}))),function(e){return a.apply(this,arguments)})},{key:"captureScreen",value:(r=n(p().mark((function e(t){var n,r,i,a,o,s,c=this;return p().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=t.id,r=t.profile,i=t.captureElement,a=t.preferDisplaySurface,o=new this.core.LocalScreenTrack(this.core.room.videoManager),s={},He(r)||(Ge(r)?ae[r]&&o.setProfile(ae[r]):o.setProfile(r)),i&&(s.captureElement=i),a&&(s.preferDisplaySurface=a),e.next=8,o.capture(s);case 8:return e.sent,o.mediaTrack.addEventListener(oe.ENDED,(function(){var e;null==(e=c.localMixVideoTrack)||e.removeScreenSource(n)})),e.abrupt("return",o);case 11:case"end":return e.stop()}}),e,this)}))),function(e){return r.apply(this,arguments)})},{key:"_updatePreview",value:(t=n(p().mark((function e(t){var n,r,i,a,o;return p().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=t.view,r=t.track,i=t.prevConfig,!(He(n)&&i&&i.view)){e.next=6;break}if(!((a=dt(i.view)).length>0)){e.next=6;break}return e.next=6,r.play(a);case 6:if(He(n)){e.next=14;break}if(!((o=dt(n)).length>0)){e.next=13;break}return e.next=11,r.play(o);case 11:e.next=14;break;case 13:r.stop();case 14:case"end":return e.stop()}}),e)}))),function(e){return t.apply(this,arguments)})},{key:"stop",value:function(){var e;null==(e=this.localMixVideoTrack)||e.close(),this.localMixVideoTrack=null,delete this._mixVideoConfig}}]);var t,r,a,o,u,l,d}();return G(Zs,"Name","VideoMixer"),Zs}));
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).VideoMixer=t()}(this,(function(){"use strict";function e(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,o=Array(t);r<t;r++)o[r]=e[r];return o}function t(e,t,r){return t&&function(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,o(n.key),n)}}(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e}function r(t,r){var o="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!o){if(Array.isArray(t)||(o=function(t,r){if(t){if("string"==typeof t)return e(t,r);var o={}.toString.call(t).slice(8,-1);return"Object"===o&&t.constructor&&(o=t.constructor.name),"Map"===o||"Set"===o?Array.from(t):"Arguments"===o||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(o)?e(t,r):void 0}}(t))||r){o&&(t=o);var n=0,i=function(){};return{s:i,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},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 u,a=!0,c=!1;return{s:function(){o=o.call(t)},n:function(){var e=o.next();return a=e.done,e},e:function(e){c=!0,u=e},f:function(){try{a||null==o.return||o.return()}finally{if(c)throw u}}}}function o(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var o=r.call(e,t);if("object"!=typeof o)return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e,"string");return"symbol"==typeof t?t:t+""}function n(e){return n="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},n(e)}var i=Object.defineProperty,u=Object.getOwnPropertySymbols,a=Object.prototype.hasOwnProperty,c=Object.prototype.propertyIsEnumerable,s=function(e,t,r){return t in e?i(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r},p=function(e,t){for(var o in t||(t={}))a.call(t,o)&&s(e,o,t[o]);if(u){var n,i=r(u(t));try{for(i.s();!(n=i.n()).done;){o=n.value;c.call(t,o)&&s(e,o,t[o])}}catch(e){i.e(e)}finally{i.f()}}return e},l=function(e,t,r){return s(e,"symbol"!==n(t)?t+"":t,r)},f={x:{required:!1,type:"number"},y:{required:!1,type:"number"},width:{required:!1,type:"number",notLessThanZero:!0,min:1},height:{required:!1,type:"number",notLessThanZero:!0,min:1}};var y=0,d=function(){function e(t){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.core=t,l(this,"seq"),l(this,"log"),y+=1,this.seq=y,this.log=t.log.createChild({id:"".concat(this.getAlias()).concat(y)}),this.log.info("created")}return t(e,[{key:"getName",value:function(){return e.Name}},{key:"getAlias",value:function(){return"vmix"}},{key:"getValidateRule",value:function(e){switch(e){case"start":return this.core,{name:"VideoMixerOptions",type:"object",required:!1,allowEmpty:!1,properties:{container:{type:"object",required:!0,properties:{width:{required:!0,type:"number",notLessThanZero:!0,min:1},height:{required:!0,type:"number",notLessThanZero:!0,min:1}}},camera:{type:"object",required:!1,properties:p({},f)},screen:{type:"object",required:!1,properties:p({},f)}}};case"update":return this.core,{name:"VideoMixerOptions",type:"object",required:!1,allowEmpty:!1,properties:{container:{type:"object",required:!1,properties:{width:{required:!0,type:"number",notLessThanZero:!0,min:1},height:{required:!0,type:"number",notLessThanZero:!0,min:1}}},camera:{type:"object",required:!1,properties:p({},f)},screen:{type:"object",required:!1,properties:p({},f)}}};case"stop":return this.core,{name:"StopVideoMixerOptions",required:!1}}}},{key:"getGroup",value:function(){return"vmix"}},{key:"subStream",get:function(){return this.core.trtc.getVideoTrack({streamType:this.core.TRTC.TYPE.STREAM_TYPE_SUB})}},{key:"mainStream",get:function(){return this.core.trtc.getVideoTrack()}},{key:"start",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return this.subStream&&(this.core.trtc.updateScreenShare({publish:!1}),this.core.trtc.updateLocalVideo({publish:!0})),this.core.trtc.on(this.core.TRTC.EVENT.PUBLISH_STATE_CHANGED,this.stopSubStream,this),this.core.room.videoManager.setVideoMixer(e)}},{key:"update",value:function(e){return this.core.room.videoManager.updateVideoMixer(e)}},{key:"stop",value:function(){return this.core.trtc.off(this.core.TRTC.EVENT.PUBLISH_STATE_CHANGED,this.stopSubStream,this),this.subStream&&this.core.trtc.updateScreenShare({publish:!0}),this.core.room.videoManager.deleteVideoMixer()}},{key:"stopSubStream",value:function(e){var t=e.mediaType,r=e.state;e.reason,"screen"===t&&"started"===r&&(this.core.trtc.updateScreenShare({publish:!1}),this.core.trtc.updateLocalVideo({publish:!0}))}}])}();return l(d,"Name","VideoMixer"),d}));